/home/lnzliplg/public_html/__pycache__.zip
PK�
�\4')6OOresult.cpython-38.opt-2.pycnu�[���U

e5d�@sXddlZddlZddlZddlmZddlmZdZdd�ZdZ	d	Z
Gd
d�de�ZdS)�N�)�util��wrapsTcst���fdd��}|S)Ncs$t|dd�r|���|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw��method��'/usr/lib64/python3.8/unittest/result.py�inner
szfailfast.<locals>.innerr)r
rrrrrsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZd-dd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Zedd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZdS).�
TestResultNFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r	�streamZdescriptions�	verbosityrrr�__init__&szTestResult.__init__cCsdS�Nr�r	rrr�printErrors7szTestResult.printErrorscCs |jd7_d|_|��dS)NrF)rr"�_setupStdout�r	�testrrr�	startTest:szTestResult.startTestcCs8|jr4|jdkr$t��|_t��|_|jt_|jt_dSr&)rr�io�StringIOrrrr r'rrrr)@s


zTestResult._setupStdoutcCsdSr&rr'rrr�startTestRunHszTestResult.startTestRuncCs|��d|_dS)NF)�_restoreStdoutr"r*rrr�stopTestNszTestResult.stopTestcCs�|jr�|jrltj��}tj��}|rF|�d�s6|d7}|j�t	|�|rl|�d�s\|d7}|j
�t|�|jt_|j
t_|j�
d�|j��|j�
d�|j��dS)N�
r)rr"rr�getvaluer �endswithr�write�STDOUT_LINEr!�STDERR_LINEr�seek�truncater)r	�output�errorrrrr0Ss$




zTestResult._restoreStdoutcCsdSr&rr'rrr�stopTestRunhszTestResult.stopTestRuncCs"|j�||�||�f�d|_dS�NT)r�append�_exc_info_to_stringr"�r	r+�errrrr�addErrornszTestResult.addErrorcCs"|j�||�||�f�d|_dSr=)rr>r?r"r@rrr�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|��t|d|j�r4|j}n|j}|�||�||�f�d|_dS)NrFrT)	rr�
issubclass�failureExceptionrrr>r?r")r	r+ZsubtestrArrrr�
addSubTest}szTestResult.addSubTestcCsdSr&rr*rrr�
addSuccess�szTestResult.addSuccesscCs|j�||f�dSr&)rr>)r	r+�reasonrrr�addSkip�szTestResult.addSkipcCs|j�||�||�f�dSr&)rr>r?r@rrr�addExpectedFailure�s�zTestResult.addExpectedFailurecCs|j�|�dSr&)rr>r*rrr�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)Nrr)�lenrr�hasattrrr'rrr�
wasSuccessful�s$�zTestResult.wasSuccessfulcCs
d|_dSr=)rr'rrrr�szTestResult.stopcCs�|\}}}|r |�|�r |j}q
||jkr6|�|�}nd}tj|||||jd�}t|���}|j	r�t
j��}	t
j
��}
|	r�|	�d�s�|	d7}	|�t|	�|
r�|
�d�s�|
d7}
|�t|
�d�|�S)N)�limit�capture_localsr2�)�_is_relevant_tb_level�tb_nextrE�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr3r r4r>r6r7�join)r	rAr+�exctype�value�tb�lengthZtb_eZmsgLinesr:r;rrrr?�s4

�



zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)r	r\rrrrR�sz TestResult._is_relevant_tb_levelcCs&d}|r"|�|�s"|d7}|j}q|S)Nrr)rRrS)r	r\r]rrrrT�s
z$TestResult._count_relevant_tb_levelscCs&dt�|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrLrrr'rrr�__repr__�s
��zTestResult.__repr__)NNN)�__name__�
__module__�__qualname__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r(r,r)r/r1r0r<rrBrCrFrGrIrJrKrNrr?rRrTrbrrrrrs6



	r)
r-rrUrQr�	functoolsrr^rr6r7�objectrrrrr�<module>sPK�
�\�f�YYasync_case.cpython-38.pycnu�[���U

e5d��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd �fdd�	Z�ZS)!�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��+/usr/lib64/python3.8/unittest/async_case.pyr"sz IsolatedAsyncioTestCase.__init__c�sdSrr�rrrr�
asyncSetUp'sz"IsolatedAsyncioTestCase.asyncSetUpc�sdSrrrrrr�
asyncTearDown*sz%IsolatedAsyncioTestCase.asyncTearDowncOs|j|f|�|�dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup-s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp<sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod@sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownCsz%IsolatedAsyncioTestCase._callTearDowncOs|j|f|�|�dSrr)rZfunctionrrrrr�_callCleanupGsz$IsolatedAsyncioTestCase._callCleanupcOsL|jdk	st�|||�}t�|�s&t�|j��}|j�||f�|j�|�Sr�r	�AssertionError�inspectZisawaitable�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrJs

z"IsolatedAsyncioTestCase._callAsynccOsP|jdk	st�|||�}t�|�rH|j��}|j�||f�|j�|�S|SdSrrr%rrrrRs


z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s�t��|_}|�d�|��IdH}|��|dkr:dS|\}}z |IdH}|��s`|�|�Wqttfk
r|�Yqt	tj
fk
r�}z|��s�|�|�W5d}~XYqXqdSr)�asyncioZQueuer
Z
set_result�getZ	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr'ZqueueZqueryZ	awaitabler&Zexrrr�_asyncioLoopRunner\s 

z*IsolatedAsyncioTestCase._asyncioLoopRunnercCsX|jdkst�t��}t�|�|�d�||_|��}|�|�|��|_	|�
|�dS)NT)r	r r(Znew_event_loop�set_event_loopZ	set_debugr"Zcreate_taskr.Z_asyncioCallsTaskr$)r�loopr'rrr�_setupAsyncioLoopos

z)IsolatedAsyncioTestCase._setupAsyncioLoopc	Cs�|jdk	st�|j}d|_|j�d�|�|j���z�t�	|�}|sNW�vdS|D]}|�
�qR|�tj||dd���|D]0}|��r�q||�
�dk	r||�d|�
�|d��q||�|���W5t�d�|��XdS)NT)r0Zreturn_exceptionsz(unhandled exception during test shutdown)�message�	exception�task)r	r r
r#r$�joinr(r/�closeZ	all_tasksZcancelZgatherr*r3Zcall_exception_handlerZshutdown_asyncgens)rr0Z	to_cancelr4rrr�_tearDownAsyncioLoopys4

��

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs(|��zt��|�W�S|��XdSr)r1r7r�run)r�resultrrrr8�szIsolatedAsyncioTestCase.run)r)N)�__name__�
__module__�__qualname__rrrrrrrrrrr.r1r7r8�
__classcell__rrrrrs

"r)r(r!Zcaserrrrrr�<module>sPK�
�\jr�&6�6�case.cpython-38.pycnu�[���U

e5d���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZdZe�ZdZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�ZgZdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%Gd d!�d!�Z&Gd"d#�d#e&�Z'Gd$d%�d%e'�Z(Gd&d'�d'e'�Z)e�*d(d)d*g�Z+Gd+d,�d,ej,�Z-Gd-d.�d.e&�Z.Gd/d0�d0ej/�Z0Gd1d2�d2e�Z1Gd3d4�d4e1�Z2Gd5d6�d6e1�Z3dS)7zTest case implementation�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdZdS)�SkipTestz�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    N��__name__�
__module__�__qualname__�__doc__�rr�%/usr/lib64/python3.8/unittest/case.pyr	sr	c@seZdZdZdS)�_ShouldStopz
    The test should stop.
    Nr
rrrrr"src@seZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    Nr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fc
cs�|j}d|_z�z
dVWn�tk
r.�Yn�tk
rh}zd|_|j�|t|�f�W5d}~XYnjtk
rzYnXt��}|j	r�||_
nd|_|j�||f�d}YnX|jr�|jr�|j�|df�W5|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er"rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)rrr
r�
contextlib�contextmanagerr&rrrrr-s
	rcCs|S�Nr)�objrrr�_idUsr+cOst�|||f�dS)znSame as addCleanup, except the cleanup items are called even if
    setUpModule fails (unlike tearDownModule).N)�_module_cleanupsr)�function�args�kwargsrrr�addModuleCleanupZsr0c
Csdg}trTt��\}}}z|||�Wqtk
rP}z|�|�W5d}~XYqXq|r`|d�dS)zWExecute all module cleanup functions. Normally called for you after
    tearDownModule.Nr)r,�pop�	Exceptionr)�
exceptionsr-r.r/�excrrr�doModuleCleanups`sr5cs,�fdd�}t�tj�r(�}d�||�S|S)z&
    Unconditionally skip a test.
    cs4t|t�s$t�|��fdd��}|}d|_�|_|S)Ncst���dSr)�r	�r.r/��reasonrr�skip_wrappervsz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr:r8rr�	decoratorts
zskip.<locals>.decorator�)r;�types�FunctionType)r9rBrArr8r�skipps
rFcCs|rt|�StS)z/
    Skip a test if the condition is true.
    �rFr+�Z	conditionr9rrr�skipIf�srIcCs|st|�StS)z3
    Skip a test unless the condition is true.
    rGrHrrr�
skipUnless�srJcCs
d|_|S)NT)�__unittest_expecting_failure__)rArrrr�srcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdSr))�_is_subtype)�.0r%��basetyperr�	<genexpr>�sz_is_subtype.<locals>.<genexpr>)r;�tuple�allr<�
issubclass)�expectedrOrrNrrL�s
rLc@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dSr))r#)rr#rrrr�sz_BaseTestCaseContext.__init__cCs |j�|j|�}|j�|��dSr))r#�_formatMessage�msg�failureException)r�standardMsgrWrrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)rrr
rrZrrrrrU�srUc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@t�||�||_||_|dk	r*t�|�}||_d|_d|_dSr))	rUrrTr#�re�compile�expected_regex�obj_namerW)rrTr#r^rrrr�s
z!_AssertRaisesBaseContext.__init__c	Cs�z�t|j|j�s"td||jf��|sV|�dd�|_|rNtdtt|��f��|W�TS|^}}z|j	|_
Wntk
r�t|�|_
YnX|�|||�W5QRXW5d}XdS)z�
        If args is empty, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If args is not empty, call a callable passing positional and keyword
        arguments.
        Nz%s() arg 1 must be %srWz3%r is an invalid keyword argument for this function)
rLrT�
_base_type�	TypeError�_base_type_strr1rW�next�iterrr_�AttributeErrorr )r�namer.r/Zcallable_objrrr�handle�s(��z_AssertRaisesBaseContext.handle)N)rrr
rrgrrrrr[�s

r[c@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|Sr)r�rrrr�	__enter__�sz_AssertRaisesContext.__enter__cCs�|dkrbz|jj}Wntk
r2t|j�}YnX|jrP|�d�||j��ql|�d�|��n
t�|�t	||j�s|dS|�
d�|_|jdkr�dS|j}|�
t|��s�|�d�|jt|���dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")rTrrer r_rZ�format�	traceback�clear_framesrS�with_tracebackZ	exceptionr^�search�pattern)r�exc_type�	exc_value�tb�exc_namer^rrr�__exit__�s.
�

�z_AssertRaisesContext.__exit__N)	rrr
r�
BaseExceptionr`rbrjrvrrrrrh�s
rhc@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRttj���D]}t|dd�ri|_qtjdd�|_|j�	�|_t�
d|j�|S)N�__warningregistry__T)�record�always)�listr!�modules�values�getattrry�warnings�catch_warnings�warnings_managerrj�simplefilterrT)r�vrrrrj�sz_AssertWarnsContext.__enter__cCs|j�|||�|dk	rdSz|jj}Wntk
rFt|j�}YnXd}|jD]Z}|j}t||j�sjqR|dkrv|}|j	dk	r�|j	�
t|��s�qR||_|j|_|j
|_
dS|dk	r�|�d�|j	jt|���|jr�|�d�||j��n|�d�|��dS)Nrkz{} not triggered by {}z{} not triggered)r�rvrTrrer r��messager;r^rpZwarning�filename�linenorZrlrqr_)rrrrsrtruZfirst_matching�m�wrrrrvs@

��
�z_AssertWarnsContext.__exit__N)	rrr
r�Warningr`rbrjrvrrrrrx�s
rx�_LoggingWatcher�records�outputc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    cCstj�|�tgg�|_dSr))�logging�Handlerrr��watcherrirrrr3sz_CapturingHandler.__init__cCsdSr)rrirrr�flush7sz_CapturingHandler.flushcCs*|jj�|�|�|�}|jj�|�dSr))r�r�rrlr�)rrzrWrrr�emit:s
z_CapturingHandler.emitN)rrr
rrr�r�rrrrr�.sr�c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)scCs:t�||�||_|r(tj�||�|_ntj|_d|_dSr))	rUr�logger_namer�Z_nameToLevel�get�level�INFOrW)rr#r�r�rrrrFsz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_nt�|j�}|_t�|j�}t�}|�	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|�|j
�d|_|j
S)NF)r;r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrrjOs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|j�|j�|dk	r.dSt|jj	�dkr\|�
d�t�
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r�rZrlr�ZgetLevelNamer�rf)rrrrsrtrrrrv`s


��z_AssertLogsContext.__exit__N)rrr
rr�rrjrvrrrrr�As
	r�c@seZdZdd�ZdS)�_OrderedChainMapccs8t�}|jD]&}|D]}||kr|�|�|VqqdSr))�set�maps�add)r�seen�mapping�krrr�__iter__ns

z_OrderedChainMap.__iter__N)rrr
r�rrrrr�msr�c@seZdZdZeZdZdZdZdZ	gZ
d�dd�Zd	d
�Zdd�Z
d
e
_edd��Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zeje fd*d+��Z!d,d-�Z"d.d/�Z#d0d1�Z$d2d3�Z%d4d5�Z&d6d7�Z'd8d9�Z(d�d;d<�Z)d=d>�Z*ed?d@��Z+dAdB�Z,dCdD�Z-dEdF�Z.d�dGdH�Z/d�dIdJ�Z0d�dKdL�Z1dMdN�Z2dOdP�Z3dQdR�Z4d�dSdT�Z5dUdV�Z6d�dWdX�Z7d�dYdZ�Z8d�d[d\�Z9d�d]d^�Z:d�d_d`�Z;d�dadb�Z<dcdd�Z=d�dedf�Z>d�dgdh�Z?d�didj�Z@d�dkdl�ZAd�dmdn�ZBd�dodp�ZCd�dqdr�ZDd�dsdt�ZEd�dudv�ZFd�dwdx�ZGd�dydz�ZHd�d{d|�ZId�d}d~�ZJd�dd��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d�d��ZPd�d��ZQd�d��ZRd�d�d��ZSd�d�d��ZTd�d��ZUeUe8�ZVZWeUe9�ZXZYeUe:�ZZZ[eUe;�Z\Z]eUe1�Z^Z_eUe3�Z`eUe0�ZaeUeQ�ZbeUeS�ZceUeT�Zdd:S)��TestCaseaWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    Ti�iF�runTestcCs�||_d|_d|_zt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|�td�|�t
d�|�td�|�td�|�td�|�td	�dS)
z�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrre�
ValueError�	__class__r�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr|rQr��	frozensetr )rZ
methodName�
testMethodrrrr�s(�zTestCase.__init__cCs||j|<dS)a[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N)r�)rZtypeobjr-rrrr��s
zTestCase.addTypeEqualityFunccOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d	��t|�}|j�|||f�dS)
aAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).�z>descriptor 'addCleanup' of 'TestCase' object needs an argumentr-rNz4Passing 'function' as keyword argument is deprecated)�
stacklevelz:addCleanup expected at least 1 positional argument, got %dr)	r�rar1r��warn�DeprecationWarningrQr�r)r.r/rr-r�rrr�
addCleanup�s"

�
�zTestCase.addCleanupz%($self, function, /, *args, **kwargs)cOs|j�|||f�dS)zpSame as addCleanup, except the cleanup items are called even if
        setUpClass fails (unlike tearDownClass).N)�_class_cleanupsr)�clsr-r.r/rrr�addClassCleanup�szTestCase.addClassCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.Nrrirrr�setUp�szTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.Nrrirrr�tearDown�szTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nr�r�rrr�
setUpClass�szTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrr�rrr�
tearDownClassszTestCase.tearDownClasscCsdS)Nrrrirrr�countTestCasesszTestCase.countTestCasescCst��Sr))rZ
TestResultrirrr�defaultTestResult	szTestCase.defaultTestResultcCs$|j}|r |���d�d��SdS)z�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        �
rN)r��strip�split�r�docrrr�shortDescriptionszTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s�rr�r�rirrr�idszTestCase.idcCs t|�t|�k	rtS|j|jkSr))r<�NotImplementedr��r�otherrrr�__eq__szTestCase.__eq__cCstt|�|jf�Sr))�hashr<r�rirrr�__hash__ szTestCase.__hash__cCsd|jt|j�fS�Nz%s (%s))r�rr�rirrr�__str__#szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>r�rirrr�__repr__&s�zTestCase.__repr__cCs<t|dd�}|dk	r |||�nt�dtd�|�|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rr�r��RuntimeWarning�
addSuccess)rrr#r9r�rrr�_addSkip*s�zTestCase._addSkipc	ks�|jdks|jjsdVdS|j}|dkr4t|�}n|j�|�}t|||�|_zX|jj|jdd��dVW5QRX|jjs�|jj	}|dk	r�|j
r�t�n|jjr�t�W5||_XdS)aPReturn a context manager that will return the enclosed block
        of code in a subtest identified by the optional message and
        keyword parameters.  A failure in the subtest marks the test
        case as failed but resumes execution at the end of the enclosed
        block, allowing further test code to be executed.
        NT�r$)
r�rr�r��params�	new_child�_SubTestr&rrZfailfastrr)rrWr��parentZ
params_maprrrr�subTest3s$
zTestCase.subTestcCs`|D]V\}}t|t�r(|�|j||�q|dk	rt|d|j�rN|�||�q|�||�qdS)Nr)r;r�rr#rSrX�
addFailureZaddError)rrr�testr"rrr�_feedErrorsToResultRs
zTestCase._feedErrorsToResultcCsDz
|j}Wn*tk
r4t�dt�|�|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerer�r�r�r�)rrr"r�rrr�_addExpectedFailure\s
�zTestCase._addExpectedFailurecCshz
|j}WnPtk
rZt�dt�z
td�Wn$tk
rT|�|t���YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrer�r�r�rr�r!r")rrr�rrr�_addUnexpectedSuccessfs
�
zTestCase._addUnexpectedSuccesscCs|��dSr))r�rirrr�
_callSetUpuszTestCase._callSetUpcCs
|�dSr)r)r�methodrrr�_callTestMethodxszTestCase._callTestMethodcCs|��dSr))r�rirrr�
_callTearDown{szTestCase._callTearDowncOs|||�dSr)r�rr-r.r/rrr�_callCleanup~szTestCase._callCleanupNc

Cs|}|dkr.|��}t|dd�}|dk	r.|�|�|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|�|||�W5|�|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	�|��|�
�W5QRX|	j�r@||	_|	j|dd	��|�|�W5QRXd|	_|	�|��|��W5QRX|��|	jD]\}}|�|||��qN|�||	j�|	j�r�|�r�|	j
�r�|�||	j
�n
|�|�n
|�|�|W�S|�|�|dk�r�t|dd�}
|
dk	�r�|
�|	j�	�d|	_
d|_XdS)
N�startTestRunr?Fr@rCrK�stopTestRunTr�)r�rZ	startTestr�r�ZstopTestr�rr�clearrr�r&r�rrr�r��
doCleanupsrr�r�r�r�)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r�r9rrr�run�st

�
���




zTestCase.runc	CsR|jp
t�}|jrL|j��\}}}|�|��|j|f|�|�W5QRXq|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.)r�rr�r1r&r�r)rr�r-r.r/rrrr��szTestCase.doCleanupsc
Csdg|_|jr`|j��\}}}z|||�Wqtk
r\}z|j�t���W5d}~XYqXqdS)zYExecute all class cleanup functions. Normally called for you after
        tearDownClass.N)ZtearDown_exceptionsr�r1r2rr!r")r�r-r.r/r4rrr�doClassCleanups�szTestCase.doClassCleanupscOs|j||�Sr))r�)rr.�kwdsrrr�__call__�szTestCase.__call__cCsF|��t||j��|��|jrB|j�d�\}}}|||�qdS)z6Run the test without collecting errors in a TestResult���N)r�rr�r�r�r1r�rrr�debug�szTestCase.debugcCst|��dS)zSkip this test.Nr6)rr9rrr�skipTest�szTestCase.skipTestcCs|�|��dS)z)Fail immediately, with the given message.N)rX)rrWrrr�fail�sz
TestCase.failcCs&|r"|�|dt|��}|�|��dS)z#Check that the expression is false.z%s is not falseN�rVrrX�r�exprrWrrr�assertFalse�szTestCase.assertFalsecCs&|s"|�|dt|��}|�|��dS)z"Check that the expression is true.z%s is not trueNrrrrr�
assertTrue�szTestCase.assertTruecCsV|js|p|S|dkr|Szd||fWStk
rPdt|�t|�fYSXdS)a�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrWrYrrrrV�s
zTestCase._formatMessagecOs(t||�}z|�d||�W�Sd}XdS)a=Fail unless an exception of class expected_exception is raised
           by the callable when invoked with specified positional and
           keyword arguments. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertRaises
           is used as a context object.

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        N�assertRaises�rhrg)r�expected_exceptionr.r/�contextrrrrs
zTestCase.assertRaisescOst||�}|�d||�S)a�Fail unless a warning of class warnClass is triggered
           by the callable when invoked with specified positional and
           keyword arguments.  If a different type of warning is
           triggered, it will not be handled: depending on the other
           warning filtering rules in effect, it might be silenced, printed
           out, or raised as an exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertWarns(SomeWarning):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertWarns
           is used as a context object.

           The context manager keeps a reference to the first matching
           warning as the 'warning' attribute; similarly, the 'filename'
           and 'lineno' attributes give you information about the line
           of Python code from which the warning was triggered.
           This allows you to inspect the warning after the assertion::

               with self.assertWarns(SomeWarning) as cm:
                   do_something()
               the_warning = cm.warning
               self.assertEqual(the_warning.some_attribute, 147)
        �assertWarns�rxrg)r�expected_warningr.r/rrrrr5s
zTestCase.assertWarnscCst|||�S)a�Fail unless a log message of level *level* or higher is emitted
        on *logger_name* or its children.  If omitted, *level* defaults to
        INFO and *logger* defaults to the root logger.

        This method must be used as a context manager, and will yield
        a recording object with two attributes: `output` and `records`.
        At the end of the context manager, the `output` attribute will
        be a list of the matching formatted log messages and the
        `records` attribute will be a list of the corresponding LogRecord
        objects.

        Example::

            with self.assertLogs('foo', level='INFO') as cm:
                logging.getLogger('foo').info('first message')
                logging.getLogger('foo.bar').error('second message')
            self.assertEqual(cm.output, ['INFO:foo:first message',
                                         'ERROR:foo.bar:second message'])
        )r�)rr�r�rrr�
assertLogsTszTestCase.assertLogscCsFt|�t|�kr@|j�t|��}|dk	r@t|t�r<t||�}|S|jS)aGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N)r<r�r�r;r r�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFuncjs

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|�||�}|�|��dS)z:The default assertEqual implementation, not type specific.�%s != %sN)rrVrX)rrrrWrYrrrr�szTestCase._baseAssertEqualcCs|�||�}||||d�dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )rWN)r)rrrrWZassertion_funcrrr�assertEqual�szTestCase.assertEqualcCs2||ks.|�|dt|�t|�f�}|�|��dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        z%s == %sNr)rrrrWrrr�assertNotEqual�s
�zTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��t||�}|dk	rf||krDdSdt|�t|�t|�t|�f}n:|dkrrd}t||�dkr�dSdt|�t|�|t|�f}|�||�}|�|��dS)a'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        N� specify delta or places not bothz(%s != %s within %s delta (%s difference)�rz)%s != %s within %r places (%s difference)�ra�absr�roundrVrX�rrrZplacesrWZdelta�diffrYrrr�assertAlmostEqual�s4��zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��t||�}|dk	rb||ks@||kr@dSdt|�t|�t|�t|�f}n<|dkrnd}||ks�t||�dkr�dSdt|�t|�|f}|�||�}|�|��dS)a�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        Nrz(%s == %s within %s delta (%s difference)rrz%s == %s within %r placesrrrrr�assertNotAlmostEqual�s,��zTestCase.assertNotAlmostEqualcCs�|dk	rP|j}t||�s.|�d|t|�f��t||�sT|�d|t|�f��nd}d}zt|�}Wn ttfk
r�d|}YnX|dkr�zt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|��ft||�}t	t
||��D]�}	z||	}
Wn4tttfk
�r<|d|	|f7}Y�q�YnXz||	}Wn4tttfk
�r~|d	|	|f7}Y�q�YnX|
|kr�|d
|	ft|
|�7}�q�q�||k�r�|dk�r�t|�t|�k�r�dS||k�r<|d|||f7}z|d|t||�f7}Wn,tttfk
�r8|d
||f7}YnXnh||k�r�|d|||f7}z|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}dd�
t�t�|���t�|�����}
|�||
�}|�||�}|�|�dS)aAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)rr;rXrr�ra�NotImplementedError�
capitalizer�range�min�
IndexErrorr<�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerVr)rZseq1Zseq2rW�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rY�diffMsgrrr�assertSequenceEqual�s�

�

��
�

������

��
�

��
���zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�Sr))�maxDiffr��DIFF_OMITTED)rr�rZmax_diffrrrr+NszTestCase._truncateMessagecCs|j|||td�dS)aA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        �r,N)r/r|)rZlist1Zlist2rWrrrr�Ts
zTestCase.assertListEqualcCs|j|||td�dS)aA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        r2N)r/rQ)rZtuple1Ztuple2rWrrrr�`s	zTestCase.assertTupleEqualc

Cs`z|�|�}Wn^tk
r>}z|�d|�W5d}~XYn0tk
rl}z|�d|�W5d}~XYnXz|�|�}Wn^tk
r�}z|�d|�W5d}~XYn0tk
r�}z|�d|�W5d}~XYnX|s�|s�dSg}|�r|�d�|D]}|�t|���q|�r@|�d�|D]}|�t|���q*d�|�}	|�|�||	��dS)a�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerarrer�reprr%rV)
rZset1Zset2rWZdifference1r%Zdifference2�lines�itemrYrrrr�ks2
  


zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN�rrrV�r�memberZ	containerrWrYrrr�assertIn�s
�zTestCase.assertIncCs2||kr.dt|�t|�f}|�|�||��dS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sNr7r8rrr�assertNotIn�s
�zTestCase.assertNotIncCs2||k	r.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a is b), but with a nicer default message.z%s is not %sNr7�rZexpr1Zexpr2rWrYrrr�assertIs�s
�zTestCase.assertIscCs,||kr(dt|�f}|�|�||��dS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sNr7r<rrr�assertIsNot�szTestCase.assertIsNotc	Cs~|�|td�|�|td�||krzdt||�}dd�t�t�|���t�|�����}|�	||�}|�
|�||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrr�)�assertIsInstancer�rr%r&r'r(r)r*r+rrV)rZd1Zd2rWrYrrrrr��s
�zTestCase.assertDictEqualc		Cs�t�dt�g}g}|��D]L\}}||kr8|�|�q|||kr|�dt|�t|�t||�f�q|sv|svdSd}|r�dd�dd�|D��}|r�|r�|d	7}|d
d�|�7}|�|�||��dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNrCzMissing: %s�,css|]}t|�VqdSr))r)rMr�rrrrP�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	r�r�r��itemsrrr%rrV)	rZsubsetZ
dictionaryrWZmissingZ
mismatched�key�valuerYrrr�assertDictContainsSubset�s4�
���
z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}zt�|�}t�|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}d�|�}	|�||	�}|�||�}|�	|�dS)a[Asserts that two iterables have the same elements, the same number of
        times, without regard to order.

            self.assertEqual(Counter(list(first)),
                             Counter(list(second)))

         Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.

        NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)rMrrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r|�collections�Counterrarrr%r+rVr)
rrrrWZ	first_seqZ
second_seqZdifferencesrYr5r.rrr�assertCountEqual�s 


zTestCase.assertCountEqualcCs�|�|td�|�|td�||kr�t|�|jks@t|�|jkrN|�|||�|jdd�}|jdd�}t|�dkr�|�d�|kr�|dg}|dg}dt||�}dd	�t	�
||��}|�||�}|�|�
||��d
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�rrCN)r?r r��_diffThresholdrr*r�rr%r&r'r+rrV)rrrrWZ
firstlinesZsecondlinesrYrrrrr��s �

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sNr7�r�a�brWrYrrr�
assertLessszTestCase.assertLesscCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sNr7rKrrr�assertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr7rKrrr�
assertGreaterszTestCase.assertGreatercCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sNr7rKrrr�assertGreaterEqual szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|�|�||��dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner7�rr*rWrYrrr�assertIsNone&szTestCase.assertIsNonecCs"|dkrd}|�|�||��dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rrVrRrrr�assertIsNotNone,szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|�|�||��dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z%s is not an instance of %rN�r;rrrV�rr*r�rWrYrrrr?2s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|�|�||��dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrUrVrrr�assertNotIsInstance9s
zTestCase.assertNotIsInstancecOst|||�}|�d||�S)aAsserts that the message in a raised exception matches a regex.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertRaisesRegex is used as a context manager.
        �assertRaisesRegexr	)rr
r^r.r/rrrrrX?s
zTestCase.assertRaisesRegexcOst|||�}|�d||�S)a�Asserts that the message in a triggered warning matches a regexp.
        Basic functioning is similar to assertWarns() with the addition
        that only warnings whose messages also match the regular expression
        are considered successful matches.

        Args:
            expected_warning: Warning class expected to be triggered.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertWarnsRegex is used as a context manager.
        �assertWarnsRegexr
)rrr^r.r/rrrrrYOszTestCase.assertWarnsRegexcCsVt|ttf�r$|std��t�|�}|�|�sRd|j|f}|�||�}|�	|��dS)z=Fail the test unless the text matches the regular expression.z!expected_regex must not be empty.z&Regex didn't match: %r not found in %rN)
r;r �bytes�AssertionErrorr\r]rprqrVrX)r�textr^rWrYrrr�assertRegexbs

�zTestCase.assertRegexcCs`t|ttf�rt�|�}|�|�}|r\d||��|���|j|f}|�	||�}|�
|��dS)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN)r;r rZr\r]rp�start�endrqrVrX)rr\Zunexpected_regexrW�matchrYrrr�assertNotRegexns

�zTestCase.assertNotRegexcs�fdd�}|S)Ncs t�d��j�td��||�S)NzPlease use {0} instead.r�)r�r�rlrr�r7��
original_funcrr�deprecated_func~s
�z,TestCase._deprecate.<locals>.deprecated_funcr)rcrdrrbr�
_deprecate}szTestCase._deprecate)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)errr
rr[rXrr0rJZ_classSetupFailedr�rr�r��__text_signature__�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r(�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrVrrrrrrrrrr/r+r�r�r�r:r;r=r>r�rDrHr�rNrOrPrQrSrTr?rWrXrYr]rareZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�ws� 
 


	


E

	


!



	�
-�
#
c


+






 










	r�csjeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�FunctionTestCaseaIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    Ncs*tt|���||_||_||_||_dSr))�superrir�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription�r�rrr�s
zFunctionTestCase.__init__cCs|jdk	r|��dSr))rkrirrrr��s
zFunctionTestCase.setUpcCs|jdk	r|��dSr))rlrirrrr��s
zFunctionTestCase.tearDowncCs|��dSr))rmrirrrr��szFunctionTestCase.runTestcCs|jjSr))rmrrirrrr��szFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkSr))r;r�r�rkrlrmrnr�rrrr��s
�
�
�zFunctionTestCase.__eq__cCstt|�|j|j|j|jf�Sr))r�r<rkrlrmrnrirrrr��s�zFunctionTestCase.__hash__cCsdt|j�|jjfSr�)rr�rmrrirrrr��s
�zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�rmrirrrr��s
�zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|�d�d��p0dS)Nr�r)rnrmrr�r�r�rrrr��s
z!FunctionTestCase.shortDescription)NNN)rrr
rrr�r�r�r�r�r�r�r�r��
__classcell__rrrorri�s	ricsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t���||_||_||_|j|_dSr))rjr�_messager#r�rX)rr#r�r�rorrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r rirrrr��sz_SubTest.runTestcCs^g}|jtk	r |�d�|j��|jrPd�dd�|j��D��}|�d�|��d�|�p\dS)Nz[{}]z, css|]\}}d�||�VqdS)z{}={!r}N)rl)rMr�r�rrrrP�s�z+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rqrhrrlr�r%rA)r�partsZparams_descrrr�_subDescription�s

�z_SubTest._subDescriptioncCsd�|j��|���S�Nz{} {})rlr#r�rtrirrrr��sz_SubTest.idcCs
|j��S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r#r�rirrrr��sz_SubTest.shortDescriptioncCsd�|j|���Sru)rlr#rtrirrrr��sz_SubTest.__str__)
rrr
rr�rtr�r�r�rprrrorr��sr�)4rr!r=r&r�r(r\r�rFr'rmrDrCr�utilrrrrrZ
__unittest�objectrhr1r2r	rrrr+r,r0r5rFrIrJrrLrUr[rhrx�
namedtupler�r�r�r��ChainMapr�r�rir�rrrr�<module>sd(	*%5�,
$:PK�
�\w;���__main__.cpython-38.opt-1.pycnu�[���U

e5dC�@s&ddlZddlmZe�ed��dS)�N�)�mainz
lib2to3.fixes)�sysr�exit�rr�(/usr/lib64/python3.8/lib2to3/__main__.py�<module>sPK�
�\#T�^�%�%util.cpython-38.opt-2.pycnu�[���U

e5d�Q�@sddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd�Zd	d
�Zdd�Zd
d�Zdadd�Zdd�Zd)dd�Zdaaadd�Zdd�Zd*dd�Zdd�Zd+dd �Zd!d"�Zd,d#d$�Z d-d%d&�Z!Gd'd(�d(�Z"dS).�N)�DistutilsPlatformError)�newer)�spawn)�log)�DistutilsByteCompileErrorc
Cs�tjdkrFdtj��krdSdtj��kr.dSdtj��kr@dStjSdtjkrZtjdStjd	ksnttd
�sttjSt��\}}}}}|���	dd�}|�	d
d�}|�	dd�}|dd�dkr�d||fS|dd�dk�r,|ddk�r�d}dt
|d�d|dd�f}ddd�}|d|tj7}n�|dd�dk�rLd|||fS|dd �d!k�r�d!}t�
d"tj�}|�|�}|�r�|��}n>|dd �d#k�r�ddl}ddl}	|�|	j��|||�\}}}d$|||fS)%N�ntZamd64�	win-amd64z(arm)�	win-arm32z(arm64)z	win-arm64Z_PYTHON_HOST_PLATFORM�posix�uname�/�� �_�-�Zlinuxz%s-%sZsunosr�5Zsolarisz%d.%s��Z32bitZ64bit)i���l����z.%sZaixz%s-%s.%s��cygwinz[\d.]+�darwinz%s-%s-%s)�os�name�sys�version�lower�platform�environ�hasattrr�replace�int�maxsize�re�compile�ASCII�match�group�_osx_supportZdistutils.sysconfigZget_platform_osxZ	sysconfigZget_config_vars)
ZosnameZhost�releaser�machineZbitnessZrel_re�mr(�	distutils�r-�&/usr/lib64/python3.8/distutils/util.py�get_host_platformsR


 


�
r/cCs8tjdkr.dddd�}|�tj�d��p,t�St�SdS)NrZwin32rr	)Zx86Zx64ZarmZVSCMD_ARG_TGT_ARCH)rr�getrr/)ZTARGET_TO_PLATr-r-r.�get_platformas
�r1cCsztjdkr|S|s|S|ddkr.td|��|ddkrFtd|��|�d�}d|krd|�d�qP|sntjStjj|�S)Nrrzpath '%s' cannot be absolute���zpath '%s' cannot end with '/'�.)r�sep�
ValueError�split�remove�curdir�path�join)�pathname�pathsr-r-r.�convert_pathls	

r=cCs�tjdkr<tj�|�s$tj�||�Stj�||dd��SnNtjdkr|tj�|�\}}|ddkrn|dd�}tj�||�Stdtj��dS)Nr
�rr�\z!nothing known about platform '%s')rrr9�isabsr:�
splitdriver)Znew_rootr;Zdriver9r-r-r.�change_root�s

rBc	CsxtrdStjdkrZdtjkrZz$ddl}|�t���dtjd<Wnttfk
rXYnXdtjkrpt	�tjd<dadS)Nr
�HOMErrZPLATr>)
�_environ_checkedrrr�pwd�getpwuid�getuid�ImportError�KeyErrorr1)rEr-r-r.�
check_environ�s	
rJc
CsVt�|fdd�}zt�d||�WStk
rP}ztd|��W5d}~XYnXdS)NcSs,|�d�}||krt||�Stj|SdS)Nr>)r'�strrr)r&�
local_varsZvar_namer-r-r.�_subst�s
zsubst_vars.<locals>._substz\$([a-zA-Z_][a-zA-Z_0-9]*)zinvalid variable '$%s')rJr#�subrIr5)�srLrM�varr-r-r.�
subst_vars�s	rQ�error: cCs|t|�S�N)rK)�exc�prefixr-r-r.�grok_environment_error�srVcCs(t�dtj�at�d�at�d�adS)Nz
[^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")r#r$�string�
whitespace�
_wordchars_re�
_squote_re�
_dquote_rer-r-r-r.�_init_regex�s
r\cCs�tdkrt�|��}g}d}|�r�t�||�}|��}|t|�krZ|�|d|���q�||tjkr�|�|d|��||d��	�}d}n�||dkr�|d|�||dd�}|d}n�||dkr�t
�||�}n*||dkr�t�||�}ntd||��|dk�r t
d||��|��\}}|d|�||d|d�||d�}|��d}|t|�kr|�|��q�q|S)	Nrr?r>�'�"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?)r)rYr\�stripr&�end�len�appendrWrX�lstriprZr[�RuntimeErrorr5�span)rOZwords�posr+r`Zbegr-r-r.�split_quoted�s@

,
rgcCsP|dkr6d|j|f}|dd�dkr6|dd�d}t�|�|sL||�dS)Nz%s%r���z,)r�))�__name__r�info)�func�args�msg�verbose�dry_runr-r-r.�executes	
rqcCs2|��}|dkrdS|dkr dStd|f��dS)N)�yZyes�t�trueZon�1r>)�nZno�fZfalseZoff�0rzinvalid truth value %r)rr5)�valr-r-r.�	strtobool2srzr>c	CsTddl}tjrtd��|dkr*do(|dk}|�s@zddlm}	|	d�\}
}Wn.tk
rzddlm}d|d�}
}YnXt�	d|�|s�|
dk	r�t
�|
d�}
n
t|d�}
|
�B|
�
d	�|
�
d
�tt|��d�|
�
d|||||f�W5QRXtjg}|�|���|�|�t||d
�tt
j|fd||d
��nddlm}|D]�}|dd�dk�rj�qP|dk�r�|dk�r�dn|}tjj||d�}ntj�|�}|}|�r�|dt|��|k�r�td||f��|t|�d�}|�r�t
j�||�}t
j� |�}|�rP|�st!||��r>t�	d||�|�sL||||�nt�"d||��qPdS)Nrzbyte-compiling is disabled.F)�mkstemp�.py)�mktempz$writing byte-compilation script '%s'�wz2from distutils.util import byte_compile
files = [
z,
z]
z�
byte_compile(files, optimize=%r, force=%r,
             prefix=%r, base_dir=%r,
             verbose=%r, dry_run=0,
             direct=1)
)rpzremoving %s)r$���r
)�optimizationz1invalid prefix: filename %r doesn't start with %rzbyte-compiling %s to %sz%skipping byte-compilation of %s to %s)#�
subprocessr�dont_write_bytecoderZtempfiler{rHr}rrkr�fdopen�open�writer:�map�repr�
executable�extendZ"_optim_args_from_interpreter_flagsrbrrqr7�
py_compiler$�	importlib�util�cache_from_sourcerar5r9�basenamer�debug)Zpy_files�optimizeZforcerUZbase_dirrorpZdirectr�r{Z	script_fdZscript_namer}Zscript�cmdr$�file�opt�cfile�dfileZ
cfile_baser-r-r.�byte_compileBsx$

�
�

���r�cCs|�d�}d}|�|�S)N�
z	
        )r6r:)�header�linesr4r-r-r.�
rfc822_escape�s
r�cCsV|sdSddlm}m}Gdd�d|�}|dkr8|d�}|||d�}|j|dd�dS)	Nr)�RefactoringTool�get_fixers_from_packagec@s$eZdZdd�Zdd�Zdd�ZdS)z*run_2to3.<locals>.DistutilsRefactoringToolc_stj|f|��dSrS)r�error)�selfrnrm�kwr-r-r.�	log_error�sz4run_2to3.<locals>.DistutilsRefactoringTool.log_errorcWstj|f|��dSrS)rrk�r�rnrmr-r-r.�log_message�sz6run_2to3.<locals>.DistutilsRefactoringTool.log_messagecWstj|f|��dSrS)rr�r�r-r-r.�	log_debug�sz4run_2to3.<locals>.DistutilsRefactoringTool.log_debugN)rj�
__module__�__qualname__r�r�r�r-r-r-r.�DistutilsRefactoringTool�sr�z
lib2to3.fixes)�optionsT)r�)Zlib2to3.refactorr�r�Zrefactor)�files�fixer_namesr��explicitr�r�r��rr-r-r.�run_2to3�s
r�c	Csddlm}ddlm}ddlm}|�}	t��}
t�|�z|	�	�W5t�|
�X|	j
|	jdd�<|r�|��D]}|�
�}|s�qr|	�|�qrg}|	jD]L}
tj�||
�}|tj�|��|tj�||
�|dd�}|dr�|�|�q�tdd�|D�|||d	�|S)
Nr)�mkpath)�	copy_file)�FileListr>)�updatecSsg|]}|���d�r|�qS)r|)r�endswith)�.0�fnr-r-r.�
<listcomp>sz$copydir_run_2to3.<locals>.<listcomp>)r�r�r�)Zdistutils.dir_utilr�Zdistutils.file_utilr�Zdistutils.filelistr�r�getcwd�chdir�findallZallfilesr��
splitlinesr_Zprocess_template_liner9r:�dirnamerbr�)�src�dest�templater�r�r�r�r�r�Zfilelistr8�lineZcopied�filenameZoutname�resr-r-r.�copydir_run_2to3�s:

�r�c@s eZdZdZdZdZdd�ZdS)�	Mixin2to3NcCst||j|j|j�SrS)r�r�r�r�)r�r�r-r-r.r�-szMixin2to3.run_2to3)rjr�r�r�r�r�r�r-r-r-r.r�sr�)rR)Nrr)rrNNr>rN)NNN)NNNN)#rr#�importlib.utilr�rWrZdistutils.errorsrZdistutils.dep_utilrZdistutils.spawnrr,rrr/r1r=rBrDrJrQrVrYrZr[r\rgrqrzr�r�r�r�r�r-r-r-r.�<module>sLO
=
�


�
!PK�
�\2B�Z�"�"suite.cpython-38.opt-2.pycnu�[���U

e5d2�@sxddlZddlmZddlmZdZdd�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Z	dd�Z
Gdd�de�ZdS)�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS�N�rrr�&/usr/lib64/python3.8/unittest/suite.py�<lambda>�z!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sjeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
BaseTestSuiteTrcCsg|_d|_|�|�dS�Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdt�|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list�rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kSr)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr�__iter__"szBaseTestSuite.__iter__cCs$|j}|D]}|r
||��7}q
|Sr)r�countTestCases)rZcases�testrrrr"%s
zBaseTestSuite.countTestCasescCsLt|�std�t|����t|t�r<t|tjt	f�r<td��|j
�|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCase�	TestSuiter�append�rr#rrr�addTest,s�zBaseTestSuite.addTestcCs*t|t�rtd��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr%r-)rrr#rrrr6s
zBaseTestSuite.addTestscCs8t|�D]*\}}|jrq4||�|jr|�|�q|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr#rrr�run<szBaseTestSuite.runcCsNz|j|}Wntk
r"Yn(Xt|d�r@|j|��7_d|j|<dS)Nr")rr%�hasattrrr")rr4r#rrrr2Es
z BaseTestSuite._removeTestAtIndexcOs|j||�Sr�r5)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCs|D]}|��qdSr)�debugr,rrrr;VszBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__r1rrrr!r"r-rr5r2r:r;rrrrrs

	rc@sZeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Zddd�Z	dd�Z
dd�ZdS)r*FcCs�d}t|dd�dkrd|_}t|�D]�\}}|jr8q�t|�r�|�||�|�||�|�||�|j|_	t|jdd�s&t|dd�r�q&|s�||�n|�
�|jr&|�|�q&|r�|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)r
r?r/r0�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr;r1r2�_handleModuleTearDown)rr3r;ZtopLevelr4r#rrrr5fs2

�

z
TestSuite.runcCst�}|�|d�dS)NT)�_DebugResultr5)rr;rrrr;�szTestSuite.debugc	Cs2t|dd�}|j}||krdS|jr(dSt|dd�r8dSz
d|_Wntk
rVYnXt|dd�}|dk	�r.t|d�z^z
|�WnNt
k
r�}z0t|t�r��d|_t
�|�}|�	||d|�W5d}~XYnXW5t|d�|jdk�r,|��t|j�dk�r,|jD]}|j	||d	d||d
��qXdS)NrF�__unittest_skip__F�
setUpClass�_setupStdout�_restoreStdoutTrr��info)r
rrAr@r%r�doClassCleanups�len�tearDown_exceptions�"_createClassOrModuleLevelException�	ExceptionrrHrr)	rr#r3�
previousClass�currentClassrJ�exc�	className�errrrE�sL





�

�zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrF)r
r=)rr3�previousModulerTrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	
Cs|�|�}|jj}||krdS|�|�d|_ztj|}Wntk
rRYdSXt|dd�}|dk	�rt	|d�z�z
|�Wn�t
k
�r}zfzt��Wn2t
k
r�}z|�
||d|�W5d}~XYnXt|t�r�d|_|�
||d|�W5d}~XYnXW5t	|d�XdS)NF�setUpModulerKrLT)rZrr=rGrA�sys�modules�KeyErrorr
rrSr�doModuleCleanupsrRrrH)	rr#r3rYZ
currentModule�moduler[rXrVrrrrD�s>




�
�zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr3rVZmethod_namerrN�	errorNamerrrrR�sz,TestSuite._createClassOrModuleLevelExceptioncCs^t|�}t|dd�}|dk	r8t|tj�r8||t|��n"|sN|�|t���n|�||�dS)N�addSkip)	�_ErrorHolderr
rrZSkipTestr.ZaddErrorr\�exc_info)rr3Z	exceptionrcrN�errorrdrrrrb�sz)TestSuite._addClassOrModuleLevelExceptioncCs|�|�}|dkrdS|jr dSztj|}Wntk
rDYdSXt|dd�}|dk	�rt|d�zNz
|�Wn>t	k
r�}z t|t�r��|�
||d|�W5d}~XYnXW5t|d�zt��Wn4t	k
�r}z|�
||d|�W5d}~XYnXXdS)N�tearDownModulerKrL)
rZrAr\r]r^r
rrr_rSrRrrH)rr3rYr`rhrXrrrrG�s:




�
�zTestSuite._handleModuleTearDownc	Cst|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	�rt|d�zXz
|�WnHt	k
r�}z*t
|t�r��t�|�}|�||d|�W5d}~XYnXW5t|d�|��t|j�d	k�r|jD]&}t�|�}|j||d
d||d�q�XdS)NrFr@FrArI�
tearDownClassrKrLrrrM)r
rrrOrPrQrrrRrSrrH)	rr#r3rTrUrirVrWrXrrrrCsB




�


�z TestSuite._tearDownPreviousClass)F)N)N)r<r=r>r5r;rErZrDrRrbrGrCrrrrr*\s

!($�
�
 r*c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)reNcCs
||_dSr��description)rrkrrrrBsz_ErrorHolder.__init__cCs|jSrrjrrrr�idEsz_ErrorHolder.idcCsdSrrrrrr�shortDescriptionHsz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rjrrrrrKsz_ErrorHolder.__repr__cCs|��Sr)rlrrrr�__str__Nsz_ErrorHolder.__str__cCsdSrr�rr3rrrr5Qsz_ErrorHolder.runcCs
|�|�Srr7rorrrr:Vsz_ErrorHolder.__call__cCsdSrrrrrrr"Ysz_ErrorHolder.countTestCases)r<r=r>ZfailureExceptionrrlrmrrnr5r:r"rrrrre6s
recCs(zt|�Wntk
r"YdSXdS)NTF)r r%)r#rrrrB\s
rBc@seZdZdZdZdZdS)rHNF)r<r=r>rFrAr0rrrrrHesrH)r\�rrZ
__unittestr�objectrr*rerBrHrrrr�<module>sL[&	PK�
�\��.z�&�&suite.cpython-38.pycnu�[���U

e5d2�@s|dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS�N�rrr�&/usr/lib64/python3.8/unittest/suite.py�<lambda>�z!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sneZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TrcCsg|_d|_|�|�dS�Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdt�|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list�rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kSr)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr�__iter__"szBaseTestSuite.__iter__cCs$|j}|D]}|r
||��7}q
|Sr)r�countTestCases)rZcases�testrrrr#%s
zBaseTestSuite.countTestCasescCsLt|�std�t|����t|t�r<t|tjt	f�r<td��|j
�|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCaserr�append�rr$rrr�addTest,s�zBaseTestSuite.addTestcCs*t|t�rtd��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr&r-)rrr$rrrr6s
zBaseTestSuite.addTestscCs8t|�D]*\}}|jrq4||�|jr|�|�q|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr$rrr�run<szBaseTestSuite.runcCsNz|j|}Wntk
r"Yn(Xt|d�r@|j|��7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r#N)rr&�hasattrrr#)rr4r$rrrr2Es
z BaseTestSuite._removeTestAtIndexcOs|j||�Sr�r5)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCs|D]}|��qdS)�7Run the tests without collecting errors in a TestResultN)�debugr,rrrr<VszBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__�__doc__r1rrr r"r#r-rr5r2r:r<rrrrrs

	rc@s^eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	ddd�Z
dd�Zdd�Zd
S)ra�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    FcCs�d}t|dd�dkrd|_}t|�D]�\}}|jr8q�t|�r�|�||�|�||�|�||�|j|_	t|jdd�s&t|dd�r�q&|s�||�n|�
�|jr&|�|�q&|r�|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrAr/r0�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr<r1r2�_handleModuleTearDown)rr3r<ZtopLevelr4r$rrrr5fs2

�

z
TestSuite.runcCst�}|�|d�dS)r;TN)�_DebugResultr5)rr<rrrr<�szTestSuite.debugc	Cs2t|dd�}|j}||krdS|jr(dSt|dd�r8dSz
d|_Wntk
rVYnXt|dd�}|dk	�r.t|d�z^z
|�WnNt
k
r�}z0t|t�r��d|_t
�|�}|�	||d|�W5d}~XYnXW5t|d�|jdk�r,|��t|j�dk�r,|jD]}|j	||d	d||d
��qXdS)NrH�__unittest_skip__F�
setUpClass�_setupStdout�_restoreStdoutTrr��info)rrrCrBr&r�doClassCleanups�len�tearDown_exceptions�"_createClassOrModuleLevelException�	ExceptionrrJrr)	rr$r3�
previousClass�currentClassrL�exc�	className�errrrG�sL





�

�zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrH)rr>)rr3�previousModulerVrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	
Cs|�|�}|jj}||krdS|�|�d|_ztj|}Wntk
rRYdSXt|dd�}|dk	�rt	|d�z�z
|�Wn�t
k
�r}zfzt��Wn2t
k
r�}z|�
||d|�W5d}~XYnXt|t�r�d|_|�
||d|�W5d}~XYnXW5t	|d�XdS)NF�setUpModulerMrNT)r\rr>rIrC�sys�modules�KeyErrorrrrUr�doModuleCleanupsrTrrJ)	rr$r3r[Z
currentModule�moduler]rZrXrrrrF�s>




�
�zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr3rXZmethod_namerrP�	errorNamerrrrT�sz,TestSuite._createClassOrModuleLevelExceptioncCs^t|�}t|dd�}|dk	r8t|tj�r8||t|��n"|sN|�|t���n|�||�dS)N�addSkip)	�_ErrorHolderrrrZSkipTestr.ZaddErrorr^�exc_info)rr3Z	exceptionrerP�errorrfrrrrd�sz)TestSuite._addClassOrModuleLevelExceptioncCs|�|�}|dkrdS|jr dSztj|}Wntk
rDYdSXt|dd�}|dk	�rt|d�zNz
|�Wn>t	k
r�}z t|t�r��|�
||d|�W5d}~XYnXW5t|d�zt��Wn4t	k
�r}z|�
||d|�W5d}~XYnXXdS)N�tearDownModulerMrN)
r\rCr^r_r`rrrrarUrTrrJ)rr3r[rbrjrZrrrrI�s:




�
�zTestSuite._handleModuleTearDownc	Cst|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	�rt|d�zXz
|�WnHt	k
r�}z*t
|t�r��t�|�}|�||d|�W5d}~XYnXW5t|d�|��t|j�d	k�r|jD]&}t�|�}|j||d
d||d�q�XdS)NrHrBFrCrK�
tearDownClassrMrNrrrO)rrrrQrRrSrrrTrUrrJ)	rr$r3rVrWrkrXrYrZrrrrEsB




�


�z TestSuite._tearDownPreviousClass)F)N)N)
r=r>r?r@r5r<rGr\rFrTrdrIrErrrrr\s	
!($�
�
 c@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rgz�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    NcCs
||_dSr��description)rrmrrrrBsz_ErrorHolder.__init__cCs|jSrrlrrrr�idEsz_ErrorHolder.idcCsdSrrrrrr�shortDescriptionHsz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rlrrrrrKsz_ErrorHolder.__repr__cCs|��Sr)rnrrrr�__str__Nsz_ErrorHolder.__str__cCsdSrr�rr3rrrr5Qsz_ErrorHolder.runcCs
|�|�Srr7rqrrrr:Vsz_ErrorHolder.__call__cCsdSrrrrrrr#Ysz_ErrorHolder.countTestCases)
r=r>r?r@ZfailureExceptionrrnrorrpr5r:r#rrrrrg6s	rgcCs(zt|�Wntk
r"YdSXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r&)r$rrrrD\s
rDc@seZdZdZdZdZdZdS)rJzCUsed by the TestSuite to hold previous class when running in debug.NF)r=r>r?r@rHrCr0rrrrrJesrJ)
r@r^�rrZ
__unittestr�objectrrrgrDrJrrrr�<module>sL[&	PK�
�\��.z�&�&suite.cpython-38.opt-1.pycnu�[���U

e5d2�@s|dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS�N�rrr�&/usr/lib64/python3.8/unittest/suite.py�<lambda>�z!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sneZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TrcCsg|_d|_|�|�dS�Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdt�|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list�rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kSr)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr�__iter__"szBaseTestSuite.__iter__cCs$|j}|D]}|r
||��7}q
|Sr)r�countTestCases)rZcases�testrrrr#%s
zBaseTestSuite.countTestCasescCsLt|�std�t|����t|t�r<t|tjt	f�r<td��|j
�|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCaserr�append�rr$rrr�addTest,s�zBaseTestSuite.addTestcCs*t|t�rtd��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr&r-)rrr$rrrr6s
zBaseTestSuite.addTestscCs8t|�D]*\}}|jrq4||�|jr|�|�q|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr$rrr�run<szBaseTestSuite.runcCsNz|j|}Wntk
r"Yn(Xt|d�r@|j|��7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r#N)rr&�hasattrrr#)rr4r$rrrr2Es
z BaseTestSuite._removeTestAtIndexcOs|j||�Sr�r5)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCs|D]}|��qdS)�7Run the tests without collecting errors in a TestResultN)�debugr,rrrr<VszBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__�__doc__r1rrr r"r#r-rr5r2r:r<rrrrrs

	rc@s^eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	ddd�Z
dd�Zdd�Zd
S)ra�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    FcCs�d}t|dd�dkrd|_}t|�D]�\}}|jr8q�t|�r�|�||�|�||�|�||�|j|_	t|jdd�s&t|dd�r�q&|s�||�n|�
�|jr&|�|�q&|r�|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrAr/r0�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr<r1r2�_handleModuleTearDown)rr3r<ZtopLevelr4r$rrrr5fs2

�

z
TestSuite.runcCst�}|�|d�dS)r;TN)�_DebugResultr5)rr<rrrr<�szTestSuite.debugc	Cs2t|dd�}|j}||krdS|jr(dSt|dd�r8dSz
d|_Wntk
rVYnXt|dd�}|dk	�r.t|d�z^z
|�WnNt
k
r�}z0t|t�r��d|_t
�|�}|�	||d|�W5d}~XYnXW5t|d�|jdk�r,|��t|j�dk�r,|jD]}|j	||d	d||d
��qXdS)NrH�__unittest_skip__F�
setUpClass�_setupStdout�_restoreStdoutTrr��info)rrrCrBr&r�doClassCleanups�len�tearDown_exceptions�"_createClassOrModuleLevelException�	ExceptionrrJrr)	rr$r3�
previousClass�currentClassrL�exc�	className�errrrG�sL





�

�zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrH)rr>)rr3�previousModulerVrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	
Cs|�|�}|jj}||krdS|�|�d|_ztj|}Wntk
rRYdSXt|dd�}|dk	�rt	|d�z�z
|�Wn�t
k
�r}zfzt��Wn2t
k
r�}z|�
||d|�W5d}~XYnXt|t�r�d|_|�
||d|�W5d}~XYnXW5t	|d�XdS)NF�setUpModulerMrNT)r\rr>rIrC�sys�modules�KeyErrorrrrUr�doModuleCleanupsrTrrJ)	rr$r3r[Z
currentModule�moduler]rZrXrrrrF�s>




�
�zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr3rXZmethod_namerrP�	errorNamerrrrT�sz,TestSuite._createClassOrModuleLevelExceptioncCs^t|�}t|dd�}|dk	r8t|tj�r8||t|��n"|sN|�|t���n|�||�dS)N�addSkip)	�_ErrorHolderrrrZSkipTestr.ZaddErrorr^�exc_info)rr3Z	exceptionrerP�errorrfrrrrd�sz)TestSuite._addClassOrModuleLevelExceptioncCs|�|�}|dkrdS|jr dSztj|}Wntk
rDYdSXt|dd�}|dk	�rt|d�zNz
|�Wn>t	k
r�}z t|t�r��|�
||d|�W5d}~XYnXW5t|d�zt��Wn4t	k
�r}z|�
||d|�W5d}~XYnXXdS)N�tearDownModulerMrN)
r\rCr^r_r`rrrrarUrTrrJ)rr3r[rbrjrZrrrrI�s:




�
�zTestSuite._handleModuleTearDownc	Cst|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	�rt|d�zXz
|�WnHt	k
r�}z*t
|t�r��t�|�}|�||d|�W5d}~XYnXW5t|d�|��t|j�d	k�r|jD]&}t�|�}|j||d
d||d�q�XdS)NrHrBFrCrK�
tearDownClassrMrNrrrO)rrrrQrRrSrrrTrUrrJ)	rr$r3rVrWrkrXrYrZrrrrEsB




�


�z TestSuite._tearDownPreviousClass)F)N)N)
r=r>r?r@r5r<rGr\rFrTrdrIrErrrrr\s	
!($�
�
 c@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rgz�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    NcCs
||_dSr��description)rrmrrrrBsz_ErrorHolder.__init__cCs|jSrrlrrrr�idEsz_ErrorHolder.idcCsdSrrrrrr�shortDescriptionHsz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rlrrrrrKsz_ErrorHolder.__repr__cCs|��Sr)rnrrrr�__str__Nsz_ErrorHolder.__str__cCsdSrr�rr3rrrr5Qsz_ErrorHolder.runcCs
|�|�Srr7rqrrrr:Vsz_ErrorHolder.__call__cCsdSrrrrrrr#Ysz_ErrorHolder.countTestCases)
r=r>r?r@ZfailureExceptionrrnrorrpr5r:r#rrrrrg6s	rgcCs(zt|�Wntk
r"YdSXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r&)r$rrrrD\s
rDc@seZdZdZdZdZdZdS)rJzCUsed by the TestSuite to hold previous class when running in debug.NF)r=r>r?r@rHrCr0rrrrrJesrJ)
r@r^�rrZ
__unittestr�objectrrrgrDrJrrrr�<module>sL[&	PK�
�\�����case.cpython-38.opt-1.pycnu�[���U

e5d���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZdZe�ZdZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�ZgZdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%Gd d!�d!�Z&Gd"d#�d#e&�Z'Gd$d%�d%e'�Z(Gd&d'�d'e'�Z)e�*d(d)d*g�Z+Gd+d,�d,ej,�Z-Gd-d.�d.e&�Z.Gd/d0�d0ej/�Z0Gd1d2�d2e�Z1Gd3d4�d4e1�Z2Gd5d6�d6e1�Z3dS)7zTest case implementation�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdZdS)�SkipTestz�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    N��__name__�
__module__�__qualname__�__doc__�rr�%/usr/lib64/python3.8/unittest/case.pyr	sr	c@seZdZdZdS)�_ShouldStopz
    The test should stop.
    Nr
rrrrr"src@seZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    Nr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fc
cs�|j}d|_z�z
dVWn�tk
r.�Yn�tk
rh}zd|_|j�|t|�f�W5d}~XYnjtk
rzYnXt��}|j	r�||_
nd|_|j�||f�d}YnX|jr�|jr�|j�|df�W5|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er"rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)rrr
r�
contextlib�contextmanagerr&rrrrr-s
	rcCs|S�Nr)�objrrr�_idUsr+cOst�|||f�dS)znSame as addCleanup, except the cleanup items are called even if
    setUpModule fails (unlike tearDownModule).N)�_module_cleanupsr)�function�args�kwargsrrr�addModuleCleanupZsr0c
Csdg}trTt��\}}}z|||�Wqtk
rP}z|�|�W5d}~XYqXq|r`|d�dS)zWExecute all module cleanup functions. Normally called for you after
    tearDownModule.Nr)r,�pop�	Exceptionr)�
exceptionsr-r.r/�excrrr�doModuleCleanups`sr5cs,�fdd�}t�tj�r(�}d�||�S|S)z&
    Unconditionally skip a test.
    cs4t|t�s$t�|��fdd��}|}d|_�|_|S)Ncst���dSr)�r	�r.r/��reasonrr�skip_wrappervsz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr:r8rr�	decoratorts
zskip.<locals>.decorator�)r;�types�FunctionType)r9rBrArr8r�skipps
rFcCs|rt|�StS)z/
    Skip a test if the condition is true.
    �rFr+�Z	conditionr9rrr�skipIf�srIcCs|st|�StS)z3
    Skip a test unless the condition is true.
    rGrHrrr�
skipUnless�srJcCs
d|_|S)NT)�__unittest_expecting_failure__)rArrrr�srcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdSr))�_is_subtype)�.0r%��basetyperr�	<genexpr>�sz_is_subtype.<locals>.<genexpr>)r;�tuple�allr<�
issubclass)�expectedrOrrNrrL�s
rLc@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dSr))r#)rr#rrrr�sz_BaseTestCaseContext.__init__cCs |j�|j|�}|j�|��dSr))r#�_formatMessage�msg�failureException)r�standardMsgrWrrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)rrr
rrZrrrrrU�srUc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@t�||�||_||_|dk	r*t�|�}||_d|_d|_dSr))	rUrrTr#�re�compile�expected_regex�obj_namerW)rrTr#r^rrrr�s
z!_AssertRaisesBaseContext.__init__c	Cs�z�t|j|j�s"td||jf��|sV|�dd�|_|rNtdtt|��f��|W�TS|^}}z|j	|_
Wntk
r�t|�|_
YnX|�|||�W5QRXW5d}XdS)z�
        If args is empty, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If args is not empty, call a callable passing positional and keyword
        arguments.
        Nz%s() arg 1 must be %srWz3%r is an invalid keyword argument for this function)
rLrT�
_base_type�	TypeError�_base_type_strr1rW�next�iterrr_�AttributeErrorr )r�namer.r/Zcallable_objrrr�handle�s(��z_AssertRaisesBaseContext.handle)N)rrr
rrgrrrrr[�s

r[c@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|Sr)r�rrrr�	__enter__�sz_AssertRaisesContext.__enter__cCs�|dkrbz|jj}Wntk
r2t|j�}YnX|jrP|�d�||j��ql|�d�|��n
t�|�t	||j�s|dS|�
d�|_|jdkr�dS|j}|�
t|��s�|�d�|jt|���dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")rTrrer r_rZ�format�	traceback�clear_framesrS�with_tracebackZ	exceptionr^�search�pattern)r�exc_type�	exc_value�tb�exc_namer^rrr�__exit__�s.
�

�z_AssertRaisesContext.__exit__N)	rrr
r�
BaseExceptionr`rbrjrvrrrrrh�s
rhc@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRttj���D]}t|dd�ri|_qtjdd�|_|j�	�|_t�
d|j�|S)N�__warningregistry__T)�record�always)�listr!�modules�values�getattrry�warnings�catch_warnings�warnings_managerrj�simplefilterrT)r�vrrrrj�sz_AssertWarnsContext.__enter__cCs|j�|||�|dk	rdSz|jj}Wntk
rFt|j�}YnXd}|jD]Z}|j}t||j�sjqR|dkrv|}|j	dk	r�|j	�
t|��s�qR||_|j|_|j
|_
dS|dk	r�|�d�|j	jt|���|jr�|�d�||j��n|�d�|��dS)Nrkz{} not triggered by {}z{} not triggered)r�rvrTrrer r��messager;r^rpZwarning�filename�linenorZrlrqr_)rrrrsrtruZfirst_matching�m�wrrrrvs@

��
�z_AssertWarnsContext.__exit__N)	rrr
r�Warningr`rbrjrvrrrrrx�s
rx�_LoggingWatcher�records�outputc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    cCstj�|�tgg�|_dSr))�logging�Handlerrr��watcherrirrrr3sz_CapturingHandler.__init__cCsdSr)rrirrr�flush7sz_CapturingHandler.flushcCs*|jj�|�|�|�}|jj�|�dSr))r�r�rrlr�)rrzrWrrr�emit:s
z_CapturingHandler.emitN)rrr
rrr�r�rrrrr�.sr�c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)scCs:t�||�||_|r(tj�||�|_ntj|_d|_dSr))	rUr�logger_namer�Z_nameToLevel�get�level�INFOrW)rr#r�r�rrrrFsz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_nt�|j�}|_t�|j�}t�}|�	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|�|j
�d|_|j
S)NF)r;r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrrjOs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|j�|j�|dk	r.dSt|jj	�dkr\|�
d�t�
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r�rZrlr�ZgetLevelNamer�rf)rrrrsrtrrrrv`s


��z_AssertLogsContext.__exit__N)rrr
rr�rrjrvrrrrr�As
	r�c@seZdZdd�ZdS)�_OrderedChainMapccs8t�}|jD]&}|D]}||kr|�|�|VqqdSr))�set�maps�add)r�seen�mapping�krrr�__iter__ns

z_OrderedChainMap.__iter__N)rrr
r�rrrrr�msr�c@seZdZdZeZdZdZdZdZ	gZ
d�dd�Zd	d
�Zdd�Z
d
e
_edd��Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zeje fd*d+��Z!d,d-�Z"d.d/�Z#d0d1�Z$d2d3�Z%d4d5�Z&d6d7�Z'd8d9�Z(d�d;d<�Z)d=d>�Z*ed?d@��Z+dAdB�Z,dCdD�Z-dEdF�Z.d�dGdH�Z/d�dIdJ�Z0d�dKdL�Z1dMdN�Z2dOdP�Z3dQdR�Z4d�dSdT�Z5dUdV�Z6d�dWdX�Z7d�dYdZ�Z8d�d[d\�Z9d�d]d^�Z:d�d_d`�Z;d�dadb�Z<dcdd�Z=d�dedf�Z>d�dgdh�Z?d�didj�Z@d�dkdl�ZAd�dmdn�ZBd�dodp�ZCd�dqdr�ZDd�dsdt�ZEd�dudv�ZFd�dwdx�ZGd�dydz�ZHd�d{d|�ZId�d}d~�ZJd�dd��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d�d��ZPd�d��ZQd�d��ZRd�d�d��ZSd�d�d��ZTd�d��ZUeUe8�ZVZWeUe9�ZXZYeUe:�ZZZ[eUe;�Z\Z]eUe1�Z^Z_eUe3�Z`eUe0�ZaeUeQ�ZbeUeS�ZceUeT�Zdd:S)��TestCaseaWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    Ti�iF�runTestcCs�||_d|_d|_zt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|�td�|�t
d�|�td�|�td�|�td�|�td	�dS)
z�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrre�
ValueError�	__class__r�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr|rQr��	frozensetr )rZ
methodName�
testMethodrrrr�s(�zTestCase.__init__cCs||j|<dS)a[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N)r�)rZtypeobjr-rrrr��s
zTestCase.addTypeEqualityFunccOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d	��t|�}|j�|||f�dS)
aAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).�z>descriptor 'addCleanup' of 'TestCase' object needs an argumentr-rNz4Passing 'function' as keyword argument is deprecated)�
stacklevelz:addCleanup expected at least 1 positional argument, got %dr)	r�rar1r��warn�DeprecationWarningrQr�r)r.r/rr-r�rrr�
addCleanup�s"

�
�zTestCase.addCleanupz%($self, function, /, *args, **kwargs)cOs|j�|||f�dS)zpSame as addCleanup, except the cleanup items are called even if
        setUpClass fails (unlike tearDownClass).N)�_class_cleanupsr)�clsr-r.r/rrr�addClassCleanup�szTestCase.addClassCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.Nrrirrr�setUp�szTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.Nrrirrr�tearDown�szTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nr�r�rrr�
setUpClass�szTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrr�rrr�
tearDownClassszTestCase.tearDownClasscCsdS)Nrrrirrr�countTestCasesszTestCase.countTestCasescCst��Sr))rZ
TestResultrirrr�defaultTestResult	szTestCase.defaultTestResultcCs$|j}|r |���d�d��SdS)z�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        �
rN)r��strip�split�r�docrrr�shortDescriptionszTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s�rr�r�rirrr�idszTestCase.idcCs t|�t|�k	rtS|j|jkSr))r<�NotImplementedr��r�otherrrr�__eq__szTestCase.__eq__cCstt|�|jf�Sr))�hashr<r�rirrr�__hash__ szTestCase.__hash__cCsd|jt|j�fS�Nz%s (%s))r�rr�rirrr�__str__#szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>r�rirrr�__repr__&s�zTestCase.__repr__cCs<t|dd�}|dk	r |||�nt�dtd�|�|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rr�r��RuntimeWarning�
addSuccess)rrr#r9r�rrr�_addSkip*s�zTestCase._addSkipc	ks�|jdks|jjsdVdS|j}|dkr4t|�}n|j�|�}t|||�|_zX|jj|jdd��dVW5QRX|jjs�|jj	}|dk	r�|j
r�t�n|jjr�t�W5||_XdS)aPReturn a context manager that will return the enclosed block
        of code in a subtest identified by the optional message and
        keyword parameters.  A failure in the subtest marks the test
        case as failed but resumes execution at the end of the enclosed
        block, allowing further test code to be executed.
        NT�r$)
r�rr�r��params�	new_child�_SubTestr&rrZfailfastrr)rrWr��parentZ
params_maprrrr�subTest3s$
zTestCase.subTestcCs`|D]V\}}t|t�r(|�|j||�q|dk	rt|d|j�rN|�||�q|�||�qdS)Nr)r;r�rr#rSrX�
addFailureZaddError)rrr�testr"rrr�_feedErrorsToResultRs
zTestCase._feedErrorsToResultcCsDz
|j}Wn*tk
r4t�dt�|�|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerer�r�r�r�)rrr"r�rrr�_addExpectedFailure\s
�zTestCase._addExpectedFailurecCshz
|j}WnPtk
rZt�dt�z
td�Wn$tk
rT|�|t���YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrer�r�r�rr�r!r")rrr�rrr�_addUnexpectedSuccessfs
�
zTestCase._addUnexpectedSuccesscCs|��dSr))r�rirrr�
_callSetUpuszTestCase._callSetUpcCs
|�dSr)r)r�methodrrr�_callTestMethodxszTestCase._callTestMethodcCs|��dSr))r�rirrr�
_callTearDown{szTestCase._callTearDowncOs|||�dSr)r�rr-r.r/rrr�_callCleanup~szTestCase._callCleanupNc

Cs|}|dkr.|��}t|dd�}|dk	r.|�|�|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|�|||�W5|�|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	�|��|�
�W5QRX|	j�r@||	_|	j|dd	��|�|�W5QRXd|	_|	�|��|��W5QRX|��|	jD]\}}|�|||��qN|�||	j�|	j�r�|�r�|	j
�r�|�||	j
�n
|�|�n
|�|�|W�S|�|�|dk�r�t|dd�}
|
dk	�r�|
�|	j�	�d|	_
d|_XdS)
N�startTestRunr?Fr@rCrK�stopTestRunTr�)r�rZ	startTestr�r�ZstopTestr�rr�clearrr�r&r�rrr�r��
doCleanupsrr�r�r�r�)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r�r9rrr�run�st

�
���




zTestCase.runc	CsR|jp
t�}|jrL|j��\}}}|�|��|j|f|�|�W5QRXq|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.)r�rr�r1r&r�r)rr�r-r.r/rrrr��szTestCase.doCleanupsc
Csdg|_|jr`|j��\}}}z|||�Wqtk
r\}z|j�t���W5d}~XYqXqdS)zYExecute all class cleanup functions. Normally called for you after
        tearDownClass.N)ZtearDown_exceptionsr�r1r2rr!r")r�r-r.r/r4rrr�doClassCleanups�szTestCase.doClassCleanupscOs|j||�Sr))r�)rr.�kwdsrrr�__call__�szTestCase.__call__cCsF|��t||j��|��|jrB|j�d�\}}}|||�qdS)z6Run the test without collecting errors in a TestResult���N)r�rr�r�r�r1r�rrr�debug�szTestCase.debugcCst|��dS)zSkip this test.Nr6)rr9rrr�skipTest�szTestCase.skipTestcCs|�|��dS)z)Fail immediately, with the given message.N)rX)rrWrrr�fail�sz
TestCase.failcCs&|r"|�|dt|��}|�|��dS)z#Check that the expression is false.z%s is not falseN�rVrrX�r�exprrWrrr�assertFalse�szTestCase.assertFalsecCs&|s"|�|dt|��}|�|��dS)z"Check that the expression is true.z%s is not trueNrrrrr�
assertTrue�szTestCase.assertTruecCsV|js|p|S|dkr|Szd||fWStk
rPdt|�t|�fYSXdS)a�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrWrYrrrrV�s
zTestCase._formatMessagecOs(t||�}z|�d||�W�Sd}XdS)a=Fail unless an exception of class expected_exception is raised
           by the callable when invoked with specified positional and
           keyword arguments. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertRaises
           is used as a context object.

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        N�assertRaises�rhrg)r�expected_exceptionr.r/�contextrrrrs
zTestCase.assertRaisescOst||�}|�d||�S)a�Fail unless a warning of class warnClass is triggered
           by the callable when invoked with specified positional and
           keyword arguments.  If a different type of warning is
           triggered, it will not be handled: depending on the other
           warning filtering rules in effect, it might be silenced, printed
           out, or raised as an exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertWarns(SomeWarning):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertWarns
           is used as a context object.

           The context manager keeps a reference to the first matching
           warning as the 'warning' attribute; similarly, the 'filename'
           and 'lineno' attributes give you information about the line
           of Python code from which the warning was triggered.
           This allows you to inspect the warning after the assertion::

               with self.assertWarns(SomeWarning) as cm:
                   do_something()
               the_warning = cm.warning
               self.assertEqual(the_warning.some_attribute, 147)
        �assertWarns�rxrg)r�expected_warningr.r/rrrrr5s
zTestCase.assertWarnscCst|||�S)a�Fail unless a log message of level *level* or higher is emitted
        on *logger_name* or its children.  If omitted, *level* defaults to
        INFO and *logger* defaults to the root logger.

        This method must be used as a context manager, and will yield
        a recording object with two attributes: `output` and `records`.
        At the end of the context manager, the `output` attribute will
        be a list of the matching formatted log messages and the
        `records` attribute will be a list of the corresponding LogRecord
        objects.

        Example::

            with self.assertLogs('foo', level='INFO') as cm:
                logging.getLogger('foo').info('first message')
                logging.getLogger('foo.bar').error('second message')
            self.assertEqual(cm.output, ['INFO:foo:first message',
                                         'ERROR:foo.bar:second message'])
        )r�)rr�r�rrr�
assertLogsTszTestCase.assertLogscCsFt|�t|�kr@|j�t|��}|dk	r@t|t�r<t||�}|S|jS)aGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N)r<r�r�r;r r�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFuncjs

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|�||�}|�|��dS)z:The default assertEqual implementation, not type specific.�%s != %sN)rrVrX)rrrrWrYrrrr�szTestCase._baseAssertEqualcCs|�||�}||||d�dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )rWN)r)rrrrWZassertion_funcrrr�assertEqual�szTestCase.assertEqualcCs2||ks.|�|dt|�t|�f�}|�|��dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        z%s == %sNr)rrrrWrrr�assertNotEqual�s
�zTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��t||�}|dk	rf||krDdSdt|�t|�t|�t|�f}n:|dkrrd}t||�dkr�dSdt|�t|�|t|�f}|�||�}|�|��dS)a'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        N� specify delta or places not bothz(%s != %s within %s delta (%s difference)�rz)%s != %s within %r places (%s difference)�ra�absr�roundrVrX�rrrZplacesrWZdelta�diffrYrrr�assertAlmostEqual�s4��zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��t||�}|dk	rb||ks@||kr@dSdt|�t|�t|�t|�f}n<|dkrnd}||ks�t||�dkr�dSdt|�t|�|f}|�||�}|�|��dS)a�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        Nrz(%s == %s within %s delta (%s difference)rrz%s == %s within %r placesrrrrr�assertNotAlmostEqual�s,��zTestCase.assertNotAlmostEqualcCs�|dk	rP|j}t||�s.|�d|t|�f��t||�sT|�d|t|�f��nd}d}zt|�}Wn ttfk
r�d|}YnX|dkr�zt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|��ft||�}t	t
||��D]�}	z||	}
Wn4tttfk
�r<|d|	|f7}Y�q�YnXz||	}Wn4tttfk
�r~|d	|	|f7}Y�q�YnX|
|kr�|d
|	ft|
|�7}�q�q�||k�r�|dk�r�t|�t|�k�r�dS||k�r<|d|||f7}z|d|t||�f7}Wn,tttfk
�r8|d
||f7}YnXnh||k�r�|d|||f7}z|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}dd�
t�t�|���t�|�����}
|�||
�}|�||�}|�|�dS)aAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)rr;rXrr�ra�NotImplementedError�
capitalizer�range�min�
IndexErrorr<�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerVr)rZseq1Zseq2rW�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rY�diffMsgrrr�assertSequenceEqual�s�

�

��
�

������

��
�

��
���zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�Sr))�maxDiffr��DIFF_OMITTED)rr�rZmax_diffrrrr+NszTestCase._truncateMessagecCs|j|||td�dS)aA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        �r,N)r/r|)rZlist1Zlist2rWrrrr�Ts
zTestCase.assertListEqualcCs|j|||td�dS)aA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        r2N)r/rQ)rZtuple1Ztuple2rWrrrr�`s	zTestCase.assertTupleEqualc

Cs`z|�|�}Wn^tk
r>}z|�d|�W5d}~XYn0tk
rl}z|�d|�W5d}~XYnXz|�|�}Wn^tk
r�}z|�d|�W5d}~XYn0tk
r�}z|�d|�W5d}~XYnX|s�|s�dSg}|�r|�d�|D]}|�t|���q|�r@|�d�|D]}|�t|���q*d�|�}	|�|�||	��dS)a�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerarrer�reprr%rV)
rZset1Zset2rWZdifference1r%Zdifference2�lines�itemrYrrrr�ks2
  


zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN�rrrV�r�memberZ	containerrWrYrrr�assertIn�s
�zTestCase.assertIncCs2||kr.dt|�t|�f}|�|�||��dS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sNr7r8rrr�assertNotIn�s
�zTestCase.assertNotIncCs2||k	r.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a is b), but with a nicer default message.z%s is not %sNr7�rZexpr1Zexpr2rWrYrrr�assertIs�s
�zTestCase.assertIscCs,||kr(dt|�f}|�|�||��dS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sNr7r<rrr�assertIsNot�szTestCase.assertIsNotc	Cs~|�|td�|�|td�||krzdt||�}dd�t�t�|���t�|�����}|�	||�}|�
|�||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrr�)�assertIsInstancer�rr%r&r'r(r)r*r+rrV)rZd1Zd2rWrYrrrrr��s
�zTestCase.assertDictEqualc		Cs�t�dt�g}g}|��D]L\}}||kr8|�|�q|||kr|�dt|�t|�t||�f�q|sv|svdSd}|r�dd�dd�|D��}|r�|r�|d	7}|d
d�|�7}|�|�||��dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNrCzMissing: %s�,css|]}t|�VqdSr))r)rMr�rrrrP�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	r�r�r��itemsrrr%rrV)	rZsubsetZ
dictionaryrWZmissingZ
mismatched�key�valuerYrrr�assertDictContainsSubset�s4�
���
z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}zt�|�}t�|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}d�|�}	|�||	�}|�||�}|�	|�dS)a[Asserts that two iterables have the same elements, the same number of
        times, without regard to order.

            self.assertEqual(Counter(list(first)),
                             Counter(list(second)))

         Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.

        NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)rMrrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r|�collections�Counterrarrr%r+rVr)
rrrrWZ	first_seqZ
second_seqZdifferencesrYr5r.rrr�assertCountEqual�s 


zTestCase.assertCountEqualcCs�|�|td�|�|td�||kr�t|�|jks@t|�|jkrN|�|||�|jdd�}|jdd�}t|�dkr�|�d�|kr�|dg}|dg}dt||�}dd	�t	�
||��}|�||�}|�|�
||��d
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�rrCN)r?r r��_diffThresholdrr*r�rr%r&r'r+rrV)rrrrWZ
firstlinesZsecondlinesrYrrrrr��s �

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sNr7�r�a�brWrYrrr�
assertLessszTestCase.assertLesscCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sNr7rKrrr�assertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr7rKrrr�
assertGreaterszTestCase.assertGreatercCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sNr7rKrrr�assertGreaterEqual szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|�|�||��dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner7�rr*rWrYrrr�assertIsNone&szTestCase.assertIsNonecCs"|dkrd}|�|�||��dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rrVrRrrr�assertIsNotNone,szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|�|�||��dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z%s is not an instance of %rN�r;rrrV�rr*r�rWrYrrrr?2s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|�|�||��dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrUrVrrr�assertNotIsInstance9s
zTestCase.assertNotIsInstancecOst|||�}|�d||�S)aAsserts that the message in a raised exception matches a regex.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertRaisesRegex is used as a context manager.
        �assertRaisesRegexr	)rr
r^r.r/rrrrrX?s
zTestCase.assertRaisesRegexcOst|||�}|�d||�S)a�Asserts that the message in a triggered warning matches a regexp.
        Basic functioning is similar to assertWarns() with the addition
        that only warnings whose messages also match the regular expression
        are considered successful matches.

        Args:
            expected_warning: Warning class expected to be triggered.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertWarnsRegex is used as a context manager.
        �assertWarnsRegexr
)rrr^r.r/rrrrrYOszTestCase.assertWarnsRegexcCsJt|ttf�rt�|�}|�|�sFd|j|f}|�||�}|�|��dS)z=Fail the test unless the text matches the regular expression.z&Regex didn't match: %r not found in %rN)	r;r �bytesr\r]rprqrVrX)r�textr^rWrYrrr�assertRegexbs

�zTestCase.assertRegexcCs`t|ttf�rt�|�}|�|�}|r\d||��|���|j|f}|�	||�}|�
|��dS)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN)r;r rZr\r]rp�start�endrqrVrX)rr[Zunexpected_regexrW�matchrYrrr�assertNotRegexns

�zTestCase.assertNotRegexcs�fdd�}|S)Ncs t�d��j�td��||�S)NzPlease use {0} instead.r�)r�r�rlrr�r7��
original_funcrr�deprecated_func~s
�z,TestCase._deprecate.<locals>.deprecated_funcr)rbrcrrar�
_deprecate}szTestCase._deprecate)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)errr
r�AssertionErrorrXrr0rJZ_classSetupFailedr�rr�r��__text_signature__�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r(�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrVrrrrrrrrrr/r+r�r�r�r:r;r=r>r�rDrHr�rNrOrPrQrSrTr?rWrXrYr\r`rdZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�ws� 
 


	


E

	


!



	�
-�
#
c


+






 










	r�csjeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�FunctionTestCaseaIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    Ncs*tt|���||_||_||_||_dSr))�superrir�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription�r�rrr�s
zFunctionTestCase.__init__cCs|jdk	r|��dSr))rkrirrrr��s
zFunctionTestCase.setUpcCs|jdk	r|��dSr))rlrirrrr��s
zFunctionTestCase.tearDowncCs|��dSr))rmrirrrr��szFunctionTestCase.runTestcCs|jjSr))rmrrirrrr��szFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkSr))r;r�r�rkrlrmrnr�rrrr��s
�
�
�zFunctionTestCase.__eq__cCstt|�|j|j|j|jf�Sr))r�r<rkrlrmrnrirrrr��s�zFunctionTestCase.__hash__cCsdt|j�|jjfSr�)rr�rmrrirrrr��s
�zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�rmrirrrr��s
�zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|�d�d��p0dS)Nr�r)rnrmrr�r�r�rrrr��s
z!FunctionTestCase.shortDescription)NNN)rrr
rrr�r�r�r�r�r�r�r�r��
__classcell__rrrorri�s	ricsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t���||_||_||_|j|_dSr))rjr�_messager#r�rX)rr#r�r�rorrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r rirrrr��sz_SubTest.runTestcCs^g}|jtk	r |�d�|j��|jrPd�dd�|j��D��}|�d�|��d�|�p\dS)Nz[{}]z, css|]\}}d�||�VqdS)z{}={!r}N)rl)rMr�r�rrrrP�s�z+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rqrhrrlr�r%rA)r�partsZparams_descrrr�_subDescription�s

�z_SubTest._subDescriptioncCsd�|j��|���S�Nz{} {})rlr#r�rtrirrrr��sz_SubTest.idcCs
|j��S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r#r�rirrrr��sz_SubTest.shortDescriptioncCsd�|j|���Sru)rlr#rtrirrrr��sz_SubTest.__str__)
rrr
rr�rtr�r�r�rprrrorr��sr�)4rr!r=r&r�r(r\r�rFr'rmrDrCr�utilrrrrrZ
__unittest�objectrhr1r2r	rrrr+r,r0r5rFrIrJrrLrUr[rhrx�
namedtupler�r�r�r��ChainMapr�r�rir�rrrr�<module>sd(	*%5�,
$:PK�
�\w;���__main__.cpython-38.pycnu�[���U

e5dC�@s&ddlZddlmZe�ed��dS)�N�)�mainz
lib2to3.fixes)�sysr�exit�rr�(/usr/lib64/python3.8/lib2to3/__main__.py�<module>sPK�
�\a!n�}}result.cpython-38.pycnu�[���U

e5d�@s\dZddlZddlZddlZddlmZddlmZdZdd�Z	d	Z
d
ZGdd�de�Z
dS)
zTest result object�N�)�util��wrapsTcst���fdd��}|S)Ncs$t|dd�r|���|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw��method��'/usr/lib64/python3.8/unittest/result.py�inner
szfailfast.<locals>.innerr)r
rrrrrsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZdZd.dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/�
TestResulta�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    NFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r	�streamZdescriptions�	verbosityrrr�__init__&szTestResult.__init__cCsdS)z#Called by TestRunner after test runNr�r	rrr�printErrors7szTestResult.printErrorscCs |jd7_d|_|��dS)z-Called when the given test is about to be runrFN)rr"�_setupStdout�r	�testrrr�	startTest:szTestResult.startTestcCs8|jr4|jdkr$t��|_t��|_|jt_|jt_dS)N)rr�io�StringIOrrrr r&rrrr(@s


zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nrr&rrr�startTestRunHszTestResult.startTestRuncCs|��d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr"r)rrr�stopTestNszTestResult.stopTestcCs�|jr�|jrltj��}tj��}|rF|�d�s6|d7}|j�t	|�|rl|�d�s\|d7}|j
�t|�|jt_|j
t_|j�
d�|j��|j�
d�|j��dS)N�
r)rr"rr�getvaluer �endswithr�write�STDOUT_LINEr!�STDERR_LINEr�seek�truncater)r	�output�errorrrrr/Ss$




zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nrr&rrr�stopTestRunhszTestResult.stopTestRuncCs"|j�||�||�f�d|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        TN)r�append�_exc_info_to_stringr"�r	r*�errrrr�addErrornszTestResult.addErrorcCs"|j�||�||�f�d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rr<r=r"r>rrr�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|��t|d|j�r4|j}n|j}|�||�||�f�d|_dS)z�Called at the end of a subtest.
        'err' is None if the subtest ended successfully, otherwise it's a
        tuple of values as returned by sys.exc_info().
        NrFrT)	rr�
issubclass�failureExceptionrrr<r=r")r	r*Zsubtestr?rrrr�
addSubTest}szTestResult.addSubTestcCsdS)z-Called when a test has completed successfullyNrr)rrr�
addSuccess�szTestResult.addSuccesscCs|j�||f�dS)zCalled when a test is skipped.N)rr<)r	r*�reasonrrr�addSkip�szTestResult.addSkipcCs|j�||�||�f�dS)z/Called when an expected failure/error occurred.N)rr<r=r>rrr�addExpectedFailure�s�zTestResult.addExpectedFailurecCs|j�|�dS)z5Called when a test was expected to fail, but succeed.N)rr<r)rrr�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrrr&rrr�
wasSuccessful�s$�zTestResult.wasSuccessfulcCs
d|_dS)z+Indicates that the tests should be aborted.TN)rr&rrrr�szTestResult.stopcCs�|\}}}|r |�|�r |j}q
||jkr6|�|�}nd}tj|||||jd�}t|���}|j	r�t
j��}	t
j
��}
|	r�|	�d�s�|	d7}	|�t|	�|
r�|
�d�s�|
d7}
|�t|
�d�|�S)z>Converts a sys.exc_info()-style tuple of values into a string.N)�limit�capture_localsr1�)�_is_relevant_tb_level�tb_nextrC�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr2r r3r<r5r6�join)r	r?r*�exctype�value�tb�lengthZtb_eZmsgLinesr9r:rrrr=�s4

�



zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)r	rZrrrrP�sz TestResult._is_relevant_tb_levelcCs&d}|r"|�|�s"|d7}|j}q|S)Nrr)rPrQ)r	rZr[rrrrR�s
z$TestResult._count_relevant_tb_levelscCs&dt�|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrJrrr&rrr�__repr__�s
��zTestResult.__repr__)NNN)�__name__�
__module__�__qualname__�__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r'r+r(r.r0r/r;rr@rArDrErGrHrIrLrr=rPrRr`rrrrrs8




	r)rdr,rrSrOr�	functoolsrr\rr5r6�objectrrrrr�<module>sPK�
�\P�<��signals.cpython-38.opt-1.pycnu�[���U

e5dc	�@sbddlZddlZddlmZdZGdd�de�Ze��Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS�N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.8/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsRt�tj�}||k	r |�||�|jr2|�||�d|_t��D]}|��q@dS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r�rrrr�registerResult*sr cCstt�|d��Sr)�boolr�poprrrr�removeResult-sr#cCs.tdkr*t�tj�}t|�at�tjt�dSr)�_interrupt_handlerrrrr)rrrr�installHandler1sr%cs<�dk	r t���fdd��}|Stdk	r8t�tjtj�dS)Nc
s6t�tj�}t�z�||�W�St�tj|�XdSr)rrr�
removeHandler)�args�kwargs�initial��methodrr�inner;s
zremoveHandler.<locals>.inner)rr$rrr	)r+r,rr*rr&9sr&)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrr r#r$r%r&rrrr�<module>s PK�
�\��E��__init__.cpython-38.opt-2.pycnu�[���U

e5d	8�
@s�dZdddddddgZdZd	d
lmZmZd	dlmZdd
lZeddddd
d
d
d�Z	ddddd
d
d
d
dd�	dd�Z
ddddd
d
d
d
dd�	dd�Zed
d
d�Zdd�Z
d
d
d
d
d
d
d�dd�Zd
d
d
d
d
d
d�dd�Zd
S)z2.0.9�dump�dumps�load�loads�JSONDecoder�JSONDecodeError�JSONEncoderzBob Ippolito <bob@redivi.com>�)rr)r�NFT)�skipkeys�ensure_ascii�check_circular�	allow_nan�indent�
separators�default)	r
rrr
�clsrrr�	sort_keysc	Ks�|sD|rD|rD|rD|dkrD|dkrD|dkrD|	dkrD|
sD|sDt�|�}n2|dkrPt}|f|||||||	|
d�|���|�}|D]}
|�|
�qzdS�N)r
rrr
rrrr)�_default_encoder�
iterencoder�write)�obj�fpr
rrr
rrrrr�kw�iterable�chunk�r�%/usr/lib64/python3.8/json/__init__.pyrxsD-�����������c	Kst|sB|rB|rB|rB|dkrB|dkrB|dkrB|dkrB|	sB|
sBt�|�S|dkrNt}|f||||||||	d�|
���|�Sr)r�encoder)rr
rrr
rrrrrrrrrr�sD,��������
���)�object_hook�object_pairs_hookcCs�|j}|tjtjf�rdS|tjtjf�r.dS|tj�r<dSt|�dkr�|ds`|dr\dSdS|ds�|d	sx|d
r|dSdSn$t|�d	kr�|ds�dS|ds�dSd
S)Nzutf-32zutf-16z	utf-8-sig�r	rz	utf-16-bez	utf-32-be��z	utf-16-lez	utf-32-lezutf-8)�
startswith�codecs�BOM_UTF32_BE�BOM_UTF32_LE�BOM_UTF16_BE�BOM_UTF16_LE�BOM_UTF8�len)�bZbstartswithrrr�detect_encoding�s$
r-�rr�parse_float�	parse_int�parse_constantr c	Ks"t|��f||||||d�|��S)Nr.)r�read)rrrr/r0r1r rrrrrs
��c	Ks&t|t�r"|�d�rRtd|d��n0t|ttf�sBtd|jj����|�	t
|�d�}d|krxddl}|jdt
dd	�|d=|dkr�|dkr�|dkr�|dkr�|dkr�|dkr�|s�t�	|�S|dkr�t}|dk	r�||d
<|dk	r�||d<|dk	r�||d<|dk	�r||d
<|dk	�r||d<|f|��	|�S)Nuz-Unexpected UTF-8 BOM (decode using utf-8-sig)r	z5the JSON object must be str, bytes or bytearray, not �
surrogatepass�encodingzF'encoding' is ignored and deprecated. It will be removed in Python 3.9r")�
stacklevelrr r/r0r1)�
isinstance�strr$r�bytes�	bytearray�	TypeError�	__class__�__name__�decoder-�warnings�warn�DeprecationWarning�_default_decoderr)	�srrr/r0r1r rr>rrrr+sT$

�������


)�__version__�__all__�
__author__�decoderrr�encoderrr%rrrrAr-rrrrrr�<module>bsb��
�?�:��PK�
�\�٢�<�<util.cpython-38.pycnu�[���U

e5d�Q�@sdZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZdd	�Zd
d�Zdd
�Zdd�Zdadd�Zdd�Zd*dd�Zdaaadd�Zdd�Zd+dd�Zdd�Zd,d d!�Zd"d#�Z d-d$d%�Z!d.d&d'�Z"Gd(d)�d)�Z#dS)/zudistutils.util

Miscellaneous utility functions -- anything that doesn't fit into
one of the other *util.py modules.
�N)�DistutilsPlatformError)�newer)�spawn)�log)�DistutilsByteCompileErrorc
Cs�tjdkrFdtj��krdSdtj��kr.dSdtj��kr@dStjSdtjkrZtjdStjd	ksnttd
�sttjSt��\}}}}}|���	dd�}|�	d
d�}|�	dd�}|dd�dkr�d||fS|dd�dk�r,|ddk�r�d}dt
|d�d|dd�f}ddd�}|d|tj7}n�|dd�dk�rLd |||fS|dd!�d"k�r�d"}t�
d#tj�}|�|�}|�r�|��}n>|dd!�d$k�r�ddl}ddl}	|�|	j��|||�\}}}d%|||fS)&a�Return a string that identifies the current platform.  This is used mainly to
    distinguish platform-specific build directories and platform-specific built
    distributions.  Typically includes the OS name and version and the
    architecture (as supplied by 'os.uname()'), although the exact information
    included depends on the OS; eg. on Linux, the kernel version isn't
    particularly important.

    Examples of returned values:
       linux-i586
       linux-alpha (?)
       solaris-2.6-sun4u

    Windows will return one of:
       win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
       win32 (all others - specifically, sys.platform is returned)

    For other non-POSIX platforms, currently just returns 'sys.platform'.

    �ntZamd64�	win-amd64z(arm)�	win-arm32z(arm64)z	win-arm64Z_PYTHON_HOST_PLATFORM�posix�uname�/�� �_�-N�Zlinuxz%s-%sZsunosr�5Zsolarisz%d.%s��Z32bitZ64bit)i���l����z.%sZaixz%s-%s.%s��cygwinz[\d.]+�darwinz%s-%s-%s)�os�name�sys�version�lower�platform�environ�hasattrr�replace�int�maxsize�re�compile�ASCII�match�group�_osx_supportZdistutils.sysconfigZget_platform_osxZ	sysconfigZget_config_vars)
ZosnameZhost�releaser�machineZbitnessZrel_re�mr(�	distutils�r-�&/usr/lib64/python3.8/distutils/util.py�get_host_platformsR


 


�
r/cCs8tjdkr.dddd�}|�tj�d��p,t�St�SdS)NrZwin32rr	)Zx86Zx64ZarmZVSCMD_ARG_TGT_ARCH)rr�getrr/)ZTARGET_TO_PLATr-r-r.�get_platformas
�r1cCsztjdkr|S|s|S|ddkr.td|��|ddkrFtd|��|�d�}d|krd|�d�qP|sntjStjj|�S)a�Return 'pathname' as a name that will work on the native filesystem,
    i.e. split it on '/' and put it back together again using the current
    directory separator.  Needed because filenames in the setup script are
    always supplied in Unix style, and have to be converted to the local
    convention before we can actually use them in the filesystem.  Raises
    ValueError on non-Unix-ish systems if 'pathname' either starts or
    ends with a slash.
    rrzpath '%s' cannot be absolute���zpath '%s' cannot end with '/'�.)r�sep�
ValueError�split�remove�curdir�path�join)�pathname�pathsr-r-r.�convert_pathls	

r=cCs�tjdkr<tj�|�s$tj�||�Stj�||dd��SnNtjdkr|tj�|�\}}|ddkrn|dd�}tj�||�Stdtj��dS)a	Return 'pathname' with 'new_root' prepended.  If 'pathname' is
    relative, this is equivalent to "os.path.join(new_root,pathname)".
    Otherwise, it requires making 'pathname' relative and then joining the
    two, which is tricky on DOS/Windows and Mac OS.
    r
�Nrr�\z!nothing known about platform '%s')rrr9�isabsr:�
splitdriver)Znew_rootr;Zdriver9r-r-r.�change_root�s

rBc	CsxtrdStjdkrZdtjkrZz$ddl}|�t���dtjd<Wnttfk
rXYnXdtjkrpt	�tjd<dadS)aLEnsure that 'os.environ' has all the environment variables we
    guarantee that users can use in config files, command-line options,
    etc.  Currently this includes:
      HOME - user's home directory (Unix only)
      PLAT - description of the current platform, including hardware
             and OS (see 'get_platform()')
    Nr
�HOMErrZPLATr>)
�_environ_checkedrrr�pwd�getpwuid�getuid�ImportError�KeyErrorr1)rEr-r-r.�
check_environ�s	
rJc
CsVt�|fdd�}zt�d||�WStk
rP}ztd|��W5d}~XYnXdS)a�Perform shell/Perl-style variable substitution on 'string'.  Every
    occurrence of '$' followed by a name is considered a variable, and
    variable is substituted by the value found in the 'local_vars'
    dictionary, or in 'os.environ' if it's not in 'local_vars'.
    'os.environ' is first checked/augmented to guarantee that it contains
    certain values: see 'check_environ()'.  Raise ValueError for any
    variables not found in either 'local_vars' or 'os.environ'.
    cSs,|�d�}||krt||�Stj|SdS)Nr>)r'�strrr)r&�
local_varsZvar_namer-r-r.�_subst�s
zsubst_vars.<locals>._substz\$([a-zA-Z_][a-zA-Z_0-9]*)zinvalid variable '$%s'N)rJr#�subrIr5)�srLrM�varr-r-r.�
subst_vars�s	rQ�error: cCs|t|�S�N)rK)�exc�prefixr-r-r.�grok_environment_error�srVcCs(t�dtj�at�d�at�d�adS)Nz
[^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")r#r$�string�
whitespace�
_wordchars_re�
_squote_re�
_dquote_rer-r-r-r.�_init_regex�s
r\cCs�tdkrt�|��}g}d}|�r�t�||�}|��}|t|�krZ|�|d|���q�||tjkr�|�|d|��||d��	�}d}n�||dkr�|d|�||dd�}|d}n�||dkr�t
�||�}n*||dkr�t�||�}ntd||��|dk�r t
d||��|��\}}|d|�||d|d�||d�}|��d	}|t|�kr|�|��q�q|S)
aSplit a string up according to Unix shell-like rules for quotes and
    backslashes.  In short: words are delimited by spaces, as long as those
    spaces are not escaped by a backslash, or inside a quoted string.
    Single and double quotes are equivalent, and the quote characters can
    be backslash-escaped.  The backslash is stripped from any two-character
    escape sequence, leaving only the escaped character.  The quote
    characters are stripped from any quoted string.  Returns a list of
    words.
    Nrr?r>�'�"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?)r)rYr\�stripr&�end�len�appendrWrX�lstriprZr[�RuntimeErrorr5�span)rOZwords�posr+r`Zbegr-r-r.�split_quoted�s@

,
rgcCsP|dkr6d|j|f}|dd�dkr6|dd�d}t�|�|sL||�dS)a�Perform some action that affects the outside world (eg.  by
    writing to the filesystem).  Such actions are special because they
    are disabled by the 'dry_run' flag.  This method takes care of all
    that bureaucracy for you; all you have to do is supply the
    function to call and an argument tuple for it (to embody the
    "external action" being performed), and an optional message to
    print.
    Nz%s%r���z,)r�))�__name__r�info)�func�args�msg�verbose�dry_runr-r-r.�executes	
rqcCs2|��}|dkrdS|dkr dStd|f��dS)z�Convert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.
    )�yZyes�t�trueZon�1r>)�nZno�fZfalseZoff�0rzinvalid truth value %rN)rr5)�valr-r-r.�	strtobool2srzr>c	CsTddl}tjrtd��|dkr*do(|dk}|�s@zddlm}	|	d�\}
}Wn.tk
rzddlm}d|d�}
}YnXt�	d|�|s�|
dk	r�t
�|
d	�}
n
t|d	�}
|
�B|
�
d
�|
�
d�tt|��d�|
�
d
|||||f�W5QRXtjg}|�|���|�|�t||d�tt
j|fd||d��nddlm}|D]�}|dd�dk�rj�qP|dk�r�|dk�r�dn|}tjj||d�}ntj�|�}|}|�r�|dt|��|k�r�td||f��|t|�d�}|�r�t
j�||�}t
j� |�}|�rP|�st!||��r>t�	d||�|�sL||||�nt�"d||��qPdS)a~Byte-compile a collection of Python source files to .pyc
    files in a __pycache__ subdirectory.  'py_files' is a list
    of files to compile; any files that don't end in ".py" are silently
    skipped.  'optimize' must be one of the following:
      0 - don't optimize
      1 - normal optimization (like "python -O")
      2 - extra optimization (like "python -OO")
    If 'force' is true, all files are recompiled regardless of
    timestamps.

    The source filename encoded in each bytecode file defaults to the
    filenames listed in 'py_files'; you can modify these with 'prefix' and
    'basedir'.  'prefix' is a string that will be stripped off of each
    source filename, and 'base_dir' is a directory name that will be
    prepended (after 'prefix' is stripped).  You can supply either or both
    (or neither) of 'prefix' and 'base_dir', as you wish.

    If 'dry_run' is true, doesn't actually do anything that would
    affect the filesystem.

    Byte-compilation is either done directly in this interpreter process
    with the standard py_compile module, or indirectly by writing a
    temporary script and executing it.  Normally, you should let
    'byte_compile()' figure out to use direct compilation or not (see
    the source for details).  The 'direct' flag is used by the script
    generated in indirect mode; unless you know what you're doing, leave
    it set to None.
    rNzbyte-compiling is disabled.T)�mkstemp�.py)�mktempz$writing byte-compilation script '%s'�wz2from distutils.util import byte_compile
files = [
z,
z]
z�
byte_compile(files, optimize=%r, force=%r,
             prefix=%r, base_dir=%r,
             verbose=%r, dry_run=0,
             direct=1)
)rpzremoving %s)r$���r
)�optimizationz1invalid prefix: filename %r doesn't start with %rzbyte-compiling %s to %sz%skipping byte-compilation of %s to %s)#�
subprocessr�dont_write_bytecoderZtempfiler{rHr}rrkr�fdopen�open�writer:�map�repr�
executable�extendZ"_optim_args_from_interpreter_flagsrbrrqr7�
py_compiler$�	importlib�util�cache_from_sourcerar5r9�basenamer�debug)Zpy_files�optimizeZforcerUZbase_dirrorpZdirectr�r{Z	script_fdZscript_namer}Zscript�cmdr$�file�opt�cfile�dfileZ
cfile_baser-r-r.�byte_compileBsx$

�
�

���r�cCs|�d�}d}|�|�S)z�Return a version of the string escaped for inclusion in an
    RFC-822 header, by ensuring there are 8 spaces space after each newline.
    �
z	
        )r6r:)�header�linesr4r-r-r.�
rfc822_escape�s
r�cCsV|sdSddlm}m}Gdd�d|�}|dkr8|d�}|||d�}|j|dd	�dS)
aInvoke 2to3 on a list of Python files.
    The files should all come from the build area, as the
    modification is done in-place. To reduce the build time,
    only files modified since the last invocation of this
    function should be passed in the files argument.Nr)�RefactoringTool�get_fixers_from_packagec@s$eZdZdd�Zdd�Zdd�ZdS)z*run_2to3.<locals>.DistutilsRefactoringToolc_stj|f|��dSrS)r�error)�selfrnrm�kwr-r-r.�	log_error�sz4run_2to3.<locals>.DistutilsRefactoringTool.log_errorcWstj|f|��dSrS)rrk�r�rnrmr-r-r.�log_message�sz6run_2to3.<locals>.DistutilsRefactoringTool.log_messagecWstj|f|��dSrS)rr�r�r-r-r.�	log_debug�sz4run_2to3.<locals>.DistutilsRefactoringTool.log_debugN)rj�
__module__�__qualname__r�r�r�r-r-r-r.�DistutilsRefactoringTool�sr�z
lib2to3.fixes)�optionsT)r�)Zlib2to3.refactorr�r�Zrefactor)�files�fixer_namesr��explicitr�r�r��rr-r-r.�run_2to3�s
r�c	Csddlm}ddlm}ddlm}|�}	t��}
t�|�z|	�	�W5t�|
�X|	j
|	jdd�<|r�|��D]}|�
�}|s�qr|	�|�qrg}|	jD]L}
tj�||
�}|tj�|��|tj�||
�|dd�}|dr�|�|�q�tdd	�|D�|||d
�|S)z�Recursively copy a directory, only copying new and changed files,
    running run_2to3 over all newly copied Python modules afterward.

    If you give a template string, it's parsed like a MANIFEST.in.
    r)�mkpath)�	copy_file)�FileListNr>)�updatecSsg|]}|���d�r|�qS)r|)r�endswith)�.0�fnr-r-r.�
<listcomp>sz$copydir_run_2to3.<locals>.<listcomp>)r�r�r�)Zdistutils.dir_utilr�Zdistutils.file_utilr�Zdistutils.filelistr�r�getcwd�chdir�findallZallfilesr��
splitlinesr_Zprocess_template_liner9r:�dirnamerbr�)�src�dest�templater�r�r�r�r�r�Zfilelistr8�lineZcopied�filenameZoutname�resr-r-r.�copydir_run_2to3�s:

�r�c@s$eZdZdZdZdZdZdd�ZdS)�	Mixin2to3z�Mixin class for commands that run 2to3.
    To configure 2to3, setup scripts may either change
    the class variables, or inherit from individual commands
    to override how 2to3 is invoked.NcCst||j|j|j�SrS)r�r�r�r�)r�r�r-r-r.r�-szMixin2to3.run_2to3)rjr�r��__doc__r�r�r�r�r-r-r-r.r�s
r�)rR)Nrr)rrNNr>rN)NNN)NNNN)$r�rr#�importlib.utilr�rWrZdistutils.errorsrZdistutils.dep_utilrZdistutils.spawnrr,rrr/r1r=rBrDrJrQrVrYrZr[r\rgrqrzr�r�r�r�r�r-r-r-r.�<module>sNO
=
�


�
!PK�
�\w;���__main__.cpython-38.opt-2.pycnu�[���U

e5dC�@s&ddlZddlmZe�ed��dS)�N�)�mainz
lib2to3.fixes)�sysr�exit�rr�(/usr/lib64/python3.8/lib2to3/__main__.py�<module>sPK�
�\��W�؉؉case.cpython-38.opt-2.pycnu�[���U

e5d���@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZdZe�ZdZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Zdd�ZgZdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$Gdd �d �Z%Gd!d"�d"e%�Z&Gd#d$�d$e&�Z'Gd%d&�d&e&�Z(e�)d'd(d)g�Z*Gd*d+�d+ej+�Z,Gd,d-�d-e%�Z-Gd.d/�d/ej.�Z/Gd0d1�d1e�Z0Gd2d3�d3e0�Z1Gd4d5�d5e0�Z2dS)6�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdS)�SkipTestN��__name__�
__module__�__qualname__�rr�%/usr/lib64/python3.8/unittest/case.pyr	sr	c@seZdZdS)�_ShouldStopNr
rrrrr"src@seZdZdS)�_UnexpectedSuccessNr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fc
cs�|j}d|_z�z
dVWn�tk
r.�Yn�tk
rh}zd|_|j�|t|�f�W5d}~XYnjtk
rzYnXt��}|j	r�||_
nd|_|j�||f�d}YnX|jr�|jr�|j�|df�W5|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er!rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)rrr
r�
contextlib�contextmanagerr%rrrrr-s
	rcCs|S�Nr)�objrrr�_idUsr*cOst�|||f�dSr()�_module_cleanupsr)�function�args�kwargsrrr�addModuleCleanupZsr/c
Csdg}trTt��\}}}z|||�Wqtk
rP}z|�|�W5d}~XYqXq|r`|d�dS�Nr)r+�pop�	Exceptionr)�
exceptionsr,r-r.�excrrr�doModuleCleanups`sr5cs,�fdd�}t�tj�r(�}d�||�S|S)Ncs4t|t�s$t�|��fdd��}|}d|_�|_|S)Ncst���dSr(�r	�r-r.��reasonrr�skip_wrappervsz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr:r8rr�	decoratorts
zskip.<locals>.decorator�)r;�types�FunctionType)r9rBrArr8r�skipps
rFcCs|rt|�StSr(�rFr*�Z	conditionr9rrr�skipIf�srIcCs|st|�StSr(rGrHrrr�
skipUnless�srJcCs
d|_|S)NT)�__unittest_expecting_failure__)rArrrr�srcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdSr()�_is_subtype)�.0r$��basetyperr�	<genexpr>�sz_is_subtype.<locals>.<genexpr>)r;�tuple�allr<�
issubclass)�expectedrOrrNrrL�s
rLc@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dSr()r")rr"rrrr�sz_BaseTestCaseContext.__init__cCs |j�|j|�}|j�|��dSr()r"�_formatMessage�msg�failureException)r�standardMsgrWrrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)rrr
rrZrrrrrU�srUc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@t�||�||_||_|dk	r*t�|�}||_d|_d|_dSr()	rUrrTr"�re�compile�expected_regex�obj_namerW)rrTr"r^rrrr�s
z!_AssertRaisesBaseContext.__init__c	Cs�z�t|j|j�s"td||jf��|sV|�dd�|_|rNtdtt|��f��|W�TS|^}}z|j	|_
Wntk
r�t|�|_
YnX|�|||�W5QRXW5d}XdS)Nz%s() arg 1 must be %srWz3%r is an invalid keyword argument for this function)
rLrT�
_base_type�	TypeError�_base_type_strr1rW�next�iterrr_�AttributeErrorr)r�namer-r.Zcallable_objrrr�handle�s(��z_AssertRaisesBaseContext.handle)N)rrr
rrgrrrrr[�s

r[c@s$eZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextz-an exception type or tuple of exception typescCs|Sr(r�rrrr�	__enter__�sz_AssertRaisesContext.__enter__cCs�|dkrbz|jj}Wntk
r2t|j�}YnX|jrP|�d�||j��ql|�d�|��n
t�|�t	||j�s|dS|�
d�|_|jdkr�dS|j}|�
t|��s�|�d�|jt|���dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")rTrrerr_rZ�format�	traceback�clear_framesrS�with_tracebackZ	exceptionr^�search�pattern)r�exc_type�	exc_value�tb�exc_namer^rrr�__exit__�s.
�

�z_AssertRaisesContext.__exit__N)rrr
�
BaseExceptionr`rbrjrvrrrrrh�srhc@s$eZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextz(a warning type or tuple of warning typescCsRttj���D]}t|dd�ri|_qtjdd�|_|j�	�|_t�
d|j�|S)N�__warningregistry__T)�record�always)�listr �modules�values�getattrry�warnings�catch_warnings�warnings_managerrj�simplefilterrT)r�vrrrrj�sz_AssertWarnsContext.__enter__cCs|j�|||�|dk	rdSz|jj}Wntk
rFt|j�}YnXd}|jD]Z}|j}t||j�sjqR|dkrv|}|j	dk	r�|j	�
t|��s�qR||_|j|_|j
|_
dS|dk	r�|�d�|j	jt|���|jr�|�d�||j��n|�d�|��dS)Nrkz{} not triggered by {}z{} not triggered)r�rvrTrrerr��messager;r^rpZwarning�filename�linenorZrlrqr_)rrrrsrtruZfirst_matching�m�wrrrrvs@

��
�z_AssertWarnsContext.__exit__N)rrr
�Warningr`rbrjrvrrrrrx�srx�_LoggingWatcher�records�outputc@s$eZdZdd�Zdd�Zdd�ZdS)�_CapturingHandlercCstj�|�tgg�|_dSr()�logging�Handlerrr��watcherrirrrr3sz_CapturingHandler.__init__cCsdSr(rrirrr�flush7sz_CapturingHandler.flushcCs*|jj�|�|�|�}|jj�|�dSr()r�r�rrlr�)rrzrWrrr�emit:s
z_CapturingHandler.emitN)rrr
rr�r�rrrrr�.sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_AssertLogsContextz"%(levelname)s:%(name)s:%(message)scCs:t�||�||_|r(tj�||�|_ntj|_d|_dSr()	rUr�logger_namer�Z_nameToLevel�get�level�INFOrW)rr"r�r�rrrrFsz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_nt�|j�}|_t�|j�}t�}|�	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|�|j
�d|_|j
S)NF)r;r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrrjOs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|j�|j�|dk	r.dSt|jj	�dkr\|�
d�t�
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r�rZrlr�ZgetLevelNamer�rf)rrrrsrtrrrrv`s


��z_AssertLogsContext.__exit__N)rrr
r�rrjrvrrrrr�As	r�c@seZdZdd�ZdS)�_OrderedChainMapccs8t�}|jD]&}|D]}||kr|�|�|VqqdSr()�set�maps�add)r�seen�mapping�krrr�__iter__ns

z_OrderedChainMap.__iter__N)rrr
r�rrrrr�msr�c@seZdZeZdZdZdZdZgZ	d�dd�Z
dd	�Zd
d�Zde_
ed
d��Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zejefd)d*��Z d+d,�Z!d-d.�Z"d/d0�Z#d1d2�Z$d3d4�Z%d5d6�Z&d7d8�Z'd�d:d;�Z(d<d=�Z)ed>d?��Z*d@dA�Z+dBdC�Z,dDdE�Z-d�dFdG�Z.d�dHdI�Z/d�dJdK�Z0dLdM�Z1dNdO�Z2dPdQ�Z3d�dRdS�Z4dTdU�Z5d�dVdW�Z6d�dXdY�Z7d�dZd[�Z8d�d\d]�Z9d�d^d_�Z:d�d`da�Z;dbdc�Z<d�ddde�Z=d�dfdg�Z>d�dhdi�Z?d�djdk�Z@d�dldm�ZAd�dndo�ZBd�dpdq�ZCd�drds�ZDd�dtdu�ZEd�dvdw�ZFd�dxdy�ZGd�dzd{�ZHd�d|d}�ZId�d~d�ZJd�d�d��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d��ZPd�d��ZQd�d�d��ZRd�d�d��ZSd�d��ZTeTe7�ZUZVeTe8�ZWZXeTe9�ZYZZeTe:�Z[Z\eTe0�Z]Z^eTe2�Z_eTe/�Z`eTeP�ZaeTeR�ZbeTeS�Zcd9S)��TestCaseTi�iF�runTestcCs�||_d|_d|_zt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|�td�|�t
d�|�td�|�td�|�td�|�td�dS)	NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrre�
ValueError�	__class__�__doc__�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr|rQr��	frozensetr)rZ
methodName�
testMethodrrrr�s(�zTestCase.__init__cCs||j|<dSr()r�)rZtypeobjr,rrrr��s
zTestCase.addTypeEqualityFunccOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d��t|�}|j�|||f�dS)	N�z>descriptor 'addCleanup' of 'TestCase' object needs an argumentr,rz4Passing 'function' as keyword argument is deprecated)�
stacklevelz:addCleanup expected at least 1 positional argument, got %dr)	r�rar1r��warn�DeprecationWarningrQr�r)r-r.rr,r�rrr�
addCleanup�s"

�
�zTestCase.addCleanupz%($self, function, /, *args, **kwargs)cOs|j�|||f�dSr()�_class_cleanupsr)�clsr,r-r.rrr�addClassCleanup�szTestCase.addClassCleanupcCsdSr(rrirrr�setUp�szTestCase.setUpcCsdSr(rrirrr�tearDown�szTestCase.tearDowncCsdSr(r�r�rrr�
setUpClass�szTestCase.setUpClasscCsdSr(rr�rrr�
tearDownClassszTestCase.tearDownClasscCsdS)Nrrrirrr�countTestCasesszTestCase.countTestCasescCst��Sr()rZ
TestResultrirrr�defaultTestResult	szTestCase.defaultTestResultcCs$|j}|r |���d�d��SdS�N�
r)r��strip�split�r�docrrr�shortDescriptionszTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s�rr�r�rirrr�idszTestCase.idcCs t|�t|�k	rtS|j|jkSr()r<�NotImplementedr��r�otherrrr�__eq__szTestCase.__eq__cCstt|�|jf�Sr()�hashr<r�rirrr�__hash__ szTestCase.__hash__cCsd|jt|j�fS�Nz%s (%s))r�rr�rirrr�__str__#szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>r�rirrr�__repr__&s�zTestCase.__repr__cCs<t|dd�}|dk	r |||�nt�dtd�|�|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rr�r��RuntimeWarning�
addSuccess)rrr"r9r�rrr�_addSkip*s�zTestCase._addSkipc	ks�|jdks|jjsdVdS|j}|dkr4t|�}n|j�|�}t|||�|_zX|jj|jdd��dVW5QRX|jjs�|jj	}|dk	r�|j
r�t�n|jjr�t�W5||_XdS)NT�r#)
r�rr�r��params�	new_child�_SubTestr%rrZfailfastrr)rrWr��parentZ
params_maprrrr�subTest3s$
zTestCase.subTestcCs`|D]V\}}t|t�r(|�|j||�q|dk	rt|d|j�rN|�||�q|�||�qdSr0)r;r�rr"rSrX�
addFailureZaddError)rrr�testr!rrr�_feedErrorsToResultRs
zTestCase._feedErrorsToResultcCsDz
|j}Wn*tk
r4t�dt�|�|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerer�r�r�r�)rrr!r�rrr�_addExpectedFailure\s
�zTestCase._addExpectedFailurecCshz
|j}WnPtk
rZt�dt�z
td�Wn$tk
rT|�|t���YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrer�r�r�rr�r r!)rrr�rrr�_addUnexpectedSuccessfs
�
zTestCase._addUnexpectedSuccesscCs|��dSr()r�rirrr�
_callSetUpuszTestCase._callSetUpcCs
|�dSr(r)r�methodrrr�_callTestMethodxszTestCase._callTestMethodcCs|��dSr()r�rirrr�
_callTearDown{szTestCase._callTearDowncOs|||�dSr(r�rr,r-r.rrr�_callCleanup~szTestCase._callCleanupNc

Cs|}|dkr.|��}t|dd�}|dk	r.|�|�|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|�|||�W5|�|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	�|��|�
�W5QRX|	j�r@||	_|	j|dd	��|�|�W5QRXd|	_|	�|��|��W5QRX|��|	jD]\}}|�|||��qN|�||	j�|	j�r�|�r�|	j
�r�|�||	j
�n
|�|�n
|�|�|W�S|�|�|dk�r�t|dd�}
|
dk	�r�|
�|	j�	�d|	_
d|_XdS)
N�startTestRunr?Fr@rCrK�stopTestRunTr�)r�rZ	startTestr�r�ZstopTestr�rr�clearrr�r%r�rrr�r��
doCleanupsrr�r�r�r�)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r�r9rrr�run�st

�
���




zTestCase.runc	CsR|jp
t�}|jrL|j��\}}}|�|��|j|f|�|�W5QRXq|jSr()r�rr�r1r%r�r)rr�r,r-r.rrrr��szTestCase.doCleanupsc
Csdg|_|jr`|j��\}}}z|||�Wqtk
r\}z|j�t���W5d}~XYqXqdSr()ZtearDown_exceptionsr�r1r2rr r!)r�r,r-r.r4rrr�doClassCleanups�szTestCase.doClassCleanupscOs|j||�Sr()r�)rr-�kwdsrrr�__call__�szTestCase.__call__cCsF|��t||j��|��|jrB|j�d�\}}}|||�qdS)N���)r�rr�r�r�r1r�rrr�debug�szTestCase.debugcCst|��dSr(r6)rr9rrr�skipTest�szTestCase.skipTestcCs|�|��dSr()rX)rrWrrr�fail�sz
TestCase.failcCs&|r"|�|dt|��}|�|��dS)Nz%s is not false�rVrrX�r�exprrWrrr�assertFalse�szTestCase.assertFalsecCs&|s"|�|dt|��}|�|��dS)Nz%s is not truerrrrr�
assertTrue�szTestCase.assertTruecCsV|js|p|S|dkr|Szd||fWStk
rPdt|�t|�fYSXdS)Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrWrYrrrrV�s
zTestCase._formatMessagecOs(t||�}z|�d||�W�Sd}XdS)N�assertRaises�rhrg)r�expected_exceptionr-r.�contextrrrr
s
zTestCase.assertRaisescOst||�}|�d||�S)N�assertWarns�rxrg)r�expected_warningr-r.r
rrrr5s
zTestCase.assertWarnscCst|||�Sr()r�)rr�r�rrr�
assertLogsTszTestCase.assertLogscCsFt|�t|�kr@|j�t|��}|dk	r@t|t�r<t||�}|S|jSr()r<r�r�r;rr�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFuncjs

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|�||�}|�|��dS)N�%s != %s)rrVrX)rrrrWrYrrrr�szTestCase._baseAssertEqualcCs|�||�}||||d�dS)N)rW)r)rrrrWZassertion_funcrrr�assertEqual�szTestCase.assertEqualcCs2||ks.|�|dt|�t|�f�}|�|��dS)Nz%s == %sr)rrrrWrrr�assertNotEqual�s
�zTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��t||�}|dk	rf||krDdSdt|�t|�t|�t|�f}n:|dkrrd}t||�dkr�dSdt|�t|�|t|�f}|�||�}|�|��dS)N� specify delta or places not bothz(%s != %s within %s delta (%s difference)�rz)%s != %s within %r places (%s difference)�ra�absr�roundrVrX�rrrZplacesrWZdelta�diffrYrrr�assertAlmostEqual�s4��zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��t||�}|dk	rb||ks@||kr@dSdt|�t|�t|�t|�f}n<|dkrnd}||ks�t||�dkr�dSdt|�t|�|f}|�||�}|�|��dS)Nrz(%s == %s within %s delta (%s difference)rrz%s == %s within %r placesrrrrr�assertNotAlmostEqual�s,��zTestCase.assertNotAlmostEqualcCs�|dk	rP|j}t||�s.|�d|t|�f��t||�sT|�d|t|�f��nd}d}zt|�}Wn ttfk
r�d|}YnX|dkr�zt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|��ft||�}t	t
||��D]�}	z||	}
Wn4tttfk
�r<|d|	|f7}Y�q�YnXz||	}Wn4tttfk
�r~|d|	|f7}Y�q�YnX|
|kr�|d	|	ft|
|�7}�q�q�||k�r�|dk�r�t|�t|�k�r�dS||k�r<|d
|||f7}z|d|t||�f7}Wn,tttfk
�r8|d||f7}YnXnh||k�r�|d
|||f7}z|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}dd�
t�t�|���t�|�����}
|�||
�}|�||�}|�|�dS)NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)rr;rXrr�ra�NotImplementedError�
capitalizer�range�min�
IndexErrorr<�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerVr)rZseq1Zseq2rW�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rY�diffMsgrrr�assertSequenceEqual�s�

�

��
�

������

��
�

��
���zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�Sr()�maxDiffr��DIFF_OMITTED)rr�rZmax_diffrrrr-NszTestCase._truncateMessagecCs|j|||td�dS�N)r.)r1r|)rZlist1Zlist2rWrrrr�Ts
zTestCase.assertListEqualcCs|j|||td�dSr4)r1rQ)rZtuple1Ztuple2rWrrrr�`s	zTestCase.assertTupleEqualc

Cs`z|�|�}Wn^tk
r>}z|�d|�W5d}~XYn0tk
rl}z|�d|�W5d}~XYnXz|�|�}Wn^tk
r�}z|�d|�W5d}~XYn0tk
r�}z|�d|�W5d}~XYnX|s�|s�dSg}|�r|�d�|D]}|�t|���q|�r@|�d�|D]}|�t|���q*d�|�}	|�|�||	��dS)Nz/invalid type when attempting set difference: %sz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerarrer�reprr'rV)
rZset1Zset2rWZdifference1r$Zdifference2�lines�itemrYrrrr�ks2
  


zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|�|�||��dS)Nz%s not found in %s�rrrV�r�memberZ	containerrWrYrrr�assertIn�s
�zTestCase.assertIncCs2||kr.dt|�t|�f}|�|�||��dS)Nz%s unexpectedly found in %sr9r:rrr�assertNotIn�s
�zTestCase.assertNotIncCs2||k	r.dt|�t|�f}|�|�||��dS)Nz%s is not %sr9�rZexpr1Zexpr2rWrYrrr�assertIs�s
�zTestCase.assertIscCs,||kr(dt|�f}|�|�||��dS)Nzunexpectedly identical: %sr9r>rrr�assertIsNot�szTestCase.assertIsNotc	Cs~|�|td�|�|td�||krzdt||�}dd�t�t�|���t�|�����}|�	||�}|�
|�||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrr�)�assertIsInstancer�rr'r(r)r*r+r,r-rrV)rZd1Zd2rWrYrrrrr��s
�zTestCase.assertDictEqualc		Cs�t�dt�g}g}|��D]L\}}||kr8|�|�q|||kr|�dt|�t|�t||�f�q|sv|svdSd}|r�dd�dd�|D��}|r�|r�|d7}|d	d�|�7}|�|�||��dS)
Nz&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %srCzMissing: %s�,css|]}t|�VqdSr()r)rMr�rrrrP�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	r�r�r��itemsrrr'rrV)	rZsubsetZ
dictionaryrWZmissingZ
mismatched�key�valuerYrrr�assertDictContainsSubset�s4�
���
z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}zt�|�}t�|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}d�|�}	|�||	�}|�||�}|�	|�dS)NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)rMrrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r|�collections�Counterrarrr'r-rVr)
rrrrWZ	first_seqZ
second_seqZdifferencesrYr7r0rrr�assertCountEqual�s 


zTestCase.assertCountEqualcCs�|�|td�|�|td�||kr�t|�|jks@t|�|jkrN|�|||�|jdd�}|jdd�}t|�dkr�|�d�|kr�|dg}|dg}dt||�}dd	�t	�
||��}|�||�}|�|�
||��dS)
NzFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�rrC)rArr��_diffThresholdrr,r�rr'r(r)r-rrV)rrrrWZ
firstlinesZsecondlinesrYrrrrr��s �

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|�|�||��dS)Nz%s not less than %sr9�r�a�brWrYrrr�
assertLessszTestCase.assertLesscCs2||ks.dt|�t|�f}|�|�||��dS)Nz%s not less than or equal to %sr9rMrrr�assertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|�|�||��dS)Nz%s not greater than %sr9rMrrr�
assertGreaterszTestCase.assertGreatercCs2||ks.dt|�t|�f}|�|�||��dS)Nz"%s not greater than or equal to %sr9rMrrr�assertGreaterEqual szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|�|�||��dS)Nz%s is not Noner9�rr)rWrYrrr�assertIsNone&szTestCase.assertIsNonecCs"|dkrd}|�|�||��dS)Nzunexpectedly None)rrVrTrrr�assertIsNotNone,szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|�|�||��dS)Nz%s is not an instance of %r�r;rrrV�rr)r�rWrYrrrrA2s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|�|�||��dS)Nz%s is an instance of %rrWrXrrr�assertNotIsInstance9s
zTestCase.assertNotIsInstancecOst|||�}|�d||�S)N�assertRaisesRegexr)rrr^r-r.r
rrrrZ?s
zTestCase.assertRaisesRegexcOst|||�}|�d||�S)N�assertWarnsRegexr)rrr^r-r.r
rrrr[OszTestCase.assertWarnsRegexcCsJt|ttf�rt�|�}|�|�sFd|j|f}|�||�}|�|��dS)Nz&Regex didn't match: %r not found in %r)	r;r�bytesr\r]rprqrVrX)r�textr^rWrYrrr�assertRegexbs

�zTestCase.assertRegexcCs`t|ttf�rt�|�}|�|�}|r\d||��|���|j|f}|�	||�}|�
|��dS)Nz"Regex matched: %r matches %r in %r)r;rr\r\r]rp�start�endrqrVrX)rr]Zunexpected_regexrW�matchrYrrr�assertNotRegexns

�zTestCase.assertNotRegexcs�fdd�}|S)Ncs t�d��j�td��||�S)NzPlease use {0} instead.r�)r�r�rlrr�r7��
original_funcrr�deprecated_func~s
�z,TestCase._deprecate.<locals>.deprecated_funcr)rdrerrcr�
_deprecate}szTestCase._deprecate)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)drrr
�AssertionErrorrXrr2rLZ_classSetupFailedr�rr�r��__text_signature__�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r&r'�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�rrrrrrVr
rrrrrrr r!r1r-r�r�r�r<r=r?r@r�rFrJr�rPrQrRrSrUrVrArYrZr[r^rbrfZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�ws�!
 


	


E

	


!



	�
-�
#
c


+






 










	r�csfeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Z�Z
S)�FunctionTestCaseNcs*tt|���||_||_||_||_dSr()�superrkr�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription�r�rrr�s
zFunctionTestCase.__init__cCs|jdk	r|��dSr()rmrirrrr��s
zFunctionTestCase.setUpcCs|jdk	r|��dSr()rnrirrrr��s
zFunctionTestCase.tearDowncCs|��dSr()rorirrrr��szFunctionTestCase.runTestcCs|jjSr()rorrirrrr��szFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkSr()r;r�r�rmrnrorpr�rrrr��s
�
�
�zFunctionTestCase.__eq__cCstt|�|j|j|j|jf�Sr()r�r<rmrnrorprirrrr��s�zFunctionTestCase.__hash__cCsdt|j�|jjfSr�)rr�rorrirrrr��s
�zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�rorirrrr��s
�zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|�d�d��p0dSr�)rpror�r�r�r�rrrr��s
z!FunctionTestCase.shortDescription)NNN)rrr
rr�r�r�r�r�r�r�r�r��
__classcell__rrrqrrk�s		rkcsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t���||_||_||_|j|_dSr()rlr�_messager"r�rX)rr"r�r�rqrrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r"rirrrr��sz_SubTest.runTestcCs^g}|jtk	r |�d�|j��|jrPd�dd�|j��D��}|�d�|��d�|�p\dS)Nz[{}]z, css|]\}}d�||�VqdS)z{}={!r}N)rl)rMr�r�rrrrP�s�z+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rsrjrrlr�r'rC)r�partsZparams_descrrr�_subDescription�s

�z_SubTest._subDescriptioncCsd�|j��|���S�Nz{} {})rlr"r�rvrirrrr��sz_SubTest.idcCs
|j��Sr()r"r�rirrrr��sz_SubTest.shortDescriptioncCsd�|j|���Srw)rlr"rvrirrrr��sz_SubTest.__str__)
rrr
rr�rvr�r�r�rrrrrqrr��sr�)3r r=r(r�r*r\r�rHr&rmrDrCr�utilrrrrrZ
__unittest�objectrjr3r2r	rrrr*r+r/r5rFrIrJrrLrUr[rhrx�
namedtupler�r�r�r��ChainMapr�r�rkr�rrrr�<module>sb(	*%5�,
$:PK�
�\�V)��-�-loader.cpython-38.opt-2.pycnu�[���U

e5d�X�@sddlZddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZdZ
e�dej�ZGdd�de
j�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejdfdd�Zdejejfdd�Zdejejfdd�Z dS)�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|��|�dS�N)�
_exception�superr�__init__)�selfZmethod_name�	exception��	__class__��'/usr/lib64/python3.8/unittest/loader.pyrsz_FailedTest.__init__cs*|�jkrtt���|�S�fdd�}|S)Ncs
�j�dSr	)r
r�r
rr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamerr�__getattr__)r
�namerrrrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcCs"d|t��f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&s
�r"cCsdt��f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrr r!rrr�_make_failed_load_tests+s�r#cCst||�}||f�|fSr	)r)�
methodnamerr r!�testrrrr0s
rcCs<t�t|��dd��}||i}tdtjf|�}|||�f�S)NcSsdSr	rrrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r$rr r&�attrsZ	TestClassrrr�_make_skipped_test4s

r,cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r0rrr�_jython_aware_splitext<sr2cs�eZdZdZeej�ZdZe	j
ZdZ�fdd�Z
dd�Zdd�dd	�Zd d
d�Zd!dd
�Zdd�Zd"dd�Zdd�Zdd�Zdd�Zdd�Zd#dd�Zd$dd�Z�ZS)%�
TestLoaderr%Ncs tt|���g|_t�|_dSr	)rr3r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|S)NzYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr �map)r
�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseTs
z TestLoader.loadTestsFromTestCase��patternc

Os:t|�dksd|kr,t�dt�|�dd�t|�dkrRt|�d}td�|���t|�dkrxt|�d}td�|���g}t|�D]4}t	||�}t
|t�r�t|t
j�r�|�|�|��q�t	|dd�}	|�|�}|	dk	�r6z|	|||�WStk
�r4}
z,t|j|
|j�\}}|j�|�|WY�Sd}
~
XYnX|S)NrZuse_load_testsz(use_load_tests is deprecated and ignoredrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr9�format�sorted�dir�getattr�
isinstancer)r7rr*�appendr>r �	Exceptionr#rr4)
r
�moduler@�argsZkwsZ	complaint�testsr�objrA�e�
error_case�
error_messagerrr�loadTestsFromModulebs<�


�zTestLoader.loadTestsFromModulecCsX|�d�}d\}}|dkr�|dd�}|r�zd�|�}t|�}Wq�Wq&tk
r�|��}t||j�\}}|s�|j�|�|YSYq&Xq&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
k
�rN}zvt	|	dd�dk	�r|dk	�r|j�|�|WY�DSt|
||jdt�
�f�\}}|j�|�|WY�
SW5d}~XYq�Xq�t|	tj��rj|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|�|
g�Snt|	tj��r�|	St|	��rH|	�}t|tj��r|St|tj��r6|�|g�Std|	|f��ntd|	��dS)	N�.)NNr�__path__zFailed to access attribute:
%s���z"calling %s returned %s, not a testz$don't know how to make test from: %s)�split�join�
__import__rrFr"r r4rLrJ�AttributeErrorrrrrK�types�
ModuleTyperUr)r7rr*r>�FunctionTyperr8�callabler9)r
rrN�partsrSrTZ
parts_copy�module_nameZnext_attributerQ�part�parentrR�instr%rrr�loadTestsFromName�s�	

����$

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)Ncsg|]}��|���qSr)rf)�.0r�rNr
rr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrNZsuitesrrhr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)NcsZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdkpXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rgr@�ZfullNamerr�	<genexpr>�szKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrJr`rr�testNamePatterns�any)�attrnameZtestFunc�r
r=rlr�shouldIncludeMethod�s
�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrI�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r=rtZtestFnNamesrrsrr:�s
zTestLoader.getTestCaseNames�test*.pycCsJd}|dkr|jdk	r|j}n|dkr.d}|}tj�|�}|tjkrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�npzt	|�Wnt
k
r�d}Y�nJXtj|}|�d�d}	ztj�tj�
|j��}Wn�tk
�r�z
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}|jD]P}|�s||�|��s|�qb|�|j�dtjj��d|_|�|j||dd���qbn*|jtjk�r�td�d�ntd�|��d�YnX|�r|�s|�|	�|_tj�|�ntj�|�|�r*t
d	|��|�s@t|�||��}|� |�S)
NFTr�__init__.pyrV)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr/r0�abspath�sys�insert�isdir�isfilerZr[r�modulesrY�dirname�__file__r\�__spec__�loader�submodule_search_locationsrWrnr�replace�sep�extend�_find_tests�builtin_module_namesr9rG� _get_directory_containing_module�removervr )r
�	start_dirr@Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerPZ
the_moduleZtop_part�specr0rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr})
r�r�r/r0r�r��basenamer-rnr�)r
rbrN�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttj�|��}tj�||j�}|�tjjd�}|S�NrV)rr2r/r0�normpath�relpathr�r�)r
r0Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)r[r�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r0r�r@rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jkrD|�|||�\}}|dk	r<|V|sDdStt�|��}|D]t}tj�||�}	|�|	||�\}}|dk	r�|V|rV|�|	�}|j�|�z|�
|	||�EdHW5|j�	|�XqVdSr�)r�r6�_find_test_pathrHr/�listdirr0rZ�add�discardr�)
r
r�r@r~rrPZshould_recurse�pathsr0r�rrrr��s6
��
zTestLoader._find_testsc
Csttj�|�}tj�|��rVt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnht	j
k
r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXtj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r@tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�ntj�|��rl|�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnjt	j
k
�r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXt|dd�}|j�|�z0|j||d�}|dk	�rP|dfW�S|dfW�S|j�|�XndSdS)	N)NFFr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r?r}rAT)r/r0r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr,r r"r4rLr�rJr2�realpathr-r�rrUr�rZr6r�r�)r
r�r@r~r�rrNrRrSrTZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgrArP�packagerrrr��s|

&
�
�
�
�
���
&
�
zTestLoader._find_test_path)N)N)r|N)F)F)rrrro�staticmethodr�
three_way_cmprxrprr8r rrr>rUrfrkr:r�r�r�r�r�r�r�rrrrrr3Bs$
(
N

n
"r3cCs&t�}||_||_||_|r"||_|Sr	)r3rxrorpr )�prefix�	sortUsingr rpr�rrr�_makeLoader�sr�cCst|||d��|�S)N)rp)r�r:)r=r�r�rprrrr:�sr:r%cCst|||��|�Sr	)r�r>)r=r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rU)rNr�r�r rrr�
findTestCasess�r�)NN)!r/�rer�rr]rzrCrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr,r2�objectr3ZdefaultTestLoaderr�r�r:r8r�r�rrrr�<module>s:/
	�
�PK�
�\P�<��signals.cpython-38.opt-2.pycnu�[���U

e5dc	�@sbddlZddlZddlmZdZGdd�de�Ze��Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS�N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.8/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsRt�tj�}||k	r |�||�|jr2|�||�d|_t��D]}|��q@dS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r�rrrr�registerResult*sr cCstt�|d��Sr)�boolr�poprrrr�removeResult-sr#cCs.tdkr*t�tj�}t|�at�tjt�dSr)�_interrupt_handlerrrrr)rrrr�installHandler1sr%cs<�dk	r t���fdd��}|Stdk	r8t�tjtj�dS)Nc
s6t�tj�}t�z�||�W�St�tj|�XdSr)rrr�
removeHandler)�args�kwargs�initial��methodrr�inner;s
zremoveHandler.<locals>.inner)rr$rrr	)r+r,rr*rr&9sr&)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrr r#r$r%r&rrrr�<module>s PK�
�\�6��jjrunner.cpython-38.opt-1.pycnu�[���U

e5dW�@sndZddlZddlZddlZddlmZddlmZdZGdd�de	�Z
Gd	d
�d
ej�ZGdd�de	�Z
dS)
z
Running tests�N�)�result)�registerResultTc@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS�N)�stream)�selfr�r	�'/usr/lib64/python3.8/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)N)r�__getstate__)�AttributeError�getattrr)r�attrr	r	r
�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS�N�
)�write)r�argr	r	r
�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__�__doc__rrrr	r	r	r
r
srcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd	�Z�fd
d�Z	�fdd
�Z
�fdd�Z�fdd�Z�fdd�Z
�fdd�Zdd�Zdd�Z�ZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    zF======================================================================zF----------------------------------------------------------------------cs8tt|��|||�||_|dk|_|dk|_||_dS)Nr)�superrrr�showAll�dots�descriptions)rrr�	verbosity��	__class__r	r
r%s


zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdSr)ZshortDescriptionr�join�str)r�testZdoc_first_liner	r	r
�getDescription,s
zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr�	startTestrrrr%�flush�rr$r r	r
r&3s
zTextTestResult.startTestcsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)N�ok�.)	rr�
addSuccessrrrrrr'r(r r	r
r+:szTextTestResult.addSuccesscsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�ERROR�E)	rr�addErrorrrrrrr'�rr$�errr r	r
r.BszTextTestResult.addErrorcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�FAIL�F)	rr�
addFailurerrrrrr'r/r r	r
r3JszTextTestResult.addFailurecsLtt|��||�|jr,|j�d�|��n|jrH|j�d�|j�	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr')rr$�reasonr r	r
r5RszTextTestResult.addSkipcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr'r/r r	r
r9Zsz!TextTestResult.addExpectedFailurecsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr'r(r r	r
r;bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|j��|�d|j�|�d|j�dS)Nr,r1)rrrr�printErrorList�errors�failures�rr	r	r
�printErrorsjs
zTextTestResult.printErrorscCsX|D]N\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�qdS)Nz%s: %sz%s)rr�
separator1r%�
separator2)rZflavourr=r$r0r	r	r
r<ps
zTextTestResult.printErrorList)rrrrrArBrr%r&r+r.r3r5r9r;r@r<�
__classcell__r	r	r r
rsrc@s4eZdZdZeZd
dd�dd�Zd	d
�Zdd�ZdS)�TextTestRunnerz�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    NTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrrr�failfast�bufferrE�warnings�resultclass)	rrrrrHrIrKrJrEr	r	r
r�s
zTextTestRunner.__init__cCs|�|j|j|j�Sr)rKrrrr?r	r	r
�_makeResult�szTextTestRunner._makeResultcCs2|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdkr^tjdt	dd�t
��}t|dd�}|dk	r�|�z||�W5t|dd�}|dk	r�|�Xt
��}W5QRX||}|�
�t|d�r�|j�|j�|j}|j�d	||d
ko�d�pd|f�|j��d
}	}
}ztt|j|j|jf�}Wntk
�rTYnX|\}	}
}g}
|���s�|j�d�t|j�t|j�}}|�r�|
�d|�|�r�|
�d|�n|j�d�|�r�|
�d|�|	�r�|
�d|	�|
�r|
�d|
�|
�r"|j�dd�|
�f�n|j�d�|S)z&Run the given test case or test suite.)�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRunN�stopTestRunrBzRan %d test%s in %.3fsrr4�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rLrrHrIrErJ�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr@�hasattrrrrBZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr
Z
wasSuccessfulrr>r=�appendr")rr$rZ	startTimerRrSZstopTimeZ	timeTaken�runZ
expectedFailsr^r_ZresultsZinfosZfailedZerroredr	r	r
ra�sx

�
�
�


zTextTestRunner.run)NTrFFNN)	rrrrrrKrrLrar	r	r	r
rDxs��rD)rrFrYrJrTrZsignalsrZ
__unittest�objectrZ
TestResultrrDr	r	r	r
�<module>s[PK�
�\���8�8loader.cpython-38.pycnu�[���U

e5d�X�@sdZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZm
Z
dZe�dej�ZGdd	�d	ej�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Ze
jdfdd�Zde
jejfdd�Z de
jejfdd�Z!dS) zLoading unittests.�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|��|�dS�N)�
_exception�superr�__init__)�selfZmethod_name�	exception��	__class__��'/usr/lib64/python3.8/unittest/loader.pyrsz_FailedTest.__init__cs*|�jkrtt���|�S�fdd�}|S)Ncs
�j�dSr	)r
r�r
rr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamerr�__getattr__)r
�namerrrrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcCs"d|t��f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&s
�r"cCsdt��f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrr r!rrr�_make_failed_load_tests+s�r#cCst||�}||f�|fSr	)r)�
methodnamerr r!�testrrrr0s
rcCs<t�t|��dd��}||i}tdtjf|�}|||�f�S)NcSsdSr	rrrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r$rr r&�attrsZ	TestClassrrr�_make_skipped_test4s

r,cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r0rrr�_jython_aware_splitext<sr2cs�eZdZdZdZeej�ZdZ	e
jZdZ
�fdd�Zdd�Zdd�d	d
�Zd!dd�Zd"d
d�Zdd�Zd#dd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zd%dd �Z�ZS)&�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r%Ncs tt|���g|_t�|_dSr	)rr3r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|S)z;Return a suite of all test cases contained in testCaseClasszYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr �map)r
�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseTs
z TestLoader.loadTestsFromTestCase��patternc

Os:t|�dksd|kr,t�dt�|�dd�t|�dkrRt|�d}td�|���t|�dkrxt|�d}td�|���g}t|�D]4}t	||�}t
|t�r�t|t
j�r�|�|�|��q�t	|dd�}	|�|�}|	dk	�r6z|	|||�WStk
�r4}
z,t|j|
|j�\}}|j�|�|WY�Sd}
~
XYnX|S)	z>Return a suite of all test cases contained in the given modulerZuse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr9�format�sorted�dir�getattr�
isinstancer)r7rr*�appendr>r �	Exceptionr#rr4)
r
�moduler@�argsZkwsZ	complaint�testsr�objrA�e�
error_case�
error_messagerrr�loadTestsFromModulebs<�


�zTestLoader.loadTestsFromModulecCsX|�d�}d\}}|dkr�|dd�}|r�zd�|�}t|�}Wq�Wq&tk
r�|��}t||j�\}}|s�|j�|�|YSYq&Xq&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
k
�rN}zvt	|	dd�dk	�r|dk	�r|j�|�|WY�DSt|
||jdt�
�f�\}}|j�|�|WY�
SW5d}~XYq�Xq�t|	tj��rj|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|�|
g�Snt|	tj��r�|	St|	��rH|	�}t|tj��r|St|tj��r6|�|g�Std|	|f��ntd	|	��dS)
aSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        �.)NNNr�__path__zFailed to access attribute:
%s���z"calling %s returned %s, not a testz$don't know how to make test from: %s)�split�join�
__import__rrFr"r r4rLrJ�AttributeErrorrrrrK�types�
ModuleTyperUr)r7rr*r>�FunctionTyperr8�callabler9)r
rrN�partsrSrTZ
parts_copy�module_nameZnext_attributerQ�part�parentrR�instr%rrr�loadTestsFromName�s�	

����$

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        csg|]}��|���qSr)rf)�.0r�rNr
rr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrNZsuitesrrhr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)zLReturn a sorted sequence of method names found within testCaseClass
        csZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdkpXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rgr@�ZfullNamerr�	<genexpr>�szKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrJr`rr�testNamePatterns�any)�attrnameZtestFunc�r
r=rlr�shouldIncludeMethod�s
�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrI�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r=rtZtestFnNamesrrsrr:�s
zTestLoader.getTestCaseNames�test*.pycCsJd}|dkr|jdk	r|j}n|dkr.d}|}tj�|�}|tjkrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�npzt	|�Wnt
k
r�d}Y�nJXtj|}|�d�d}	ztj�tj�
|j��}Wn�tk
�r�z
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}|jD]P}|�s||�|��s|�qb|�|j�dtjj��d|_|�|j||dd���qbn*|jtjk�r�td�d�ntd	�|��d�YnX|�r|�s|�|	�|_tj�|�ntj�|�|�r*t
d
|��|�s@t|�||��}|� |�S)a%Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        FNTr�__init__.pyrV)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr/r0�abspath�sys�insert�isdir�isfilerZr[r�modulesrY�dirname�__file__r\�__spec__�loader�submodule_search_locationsrWrnr�replace�sep�extend�_find_tests�builtin_module_namesr9rG� _get_directory_containing_module�removervr )r
�	start_dirr@Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerPZ
the_moduleZtop_part�specr0rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr})
r�r�r/r0r�r��basenamer-rnr�)r
rbrN�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsh||jkrdSttj�|��}tj�||j�}tj�|�rBtd��|�d�rTtd��|�	tjj
d�}|S)NrVzPath must be within the projectz..)rr2r/r0�normpath�relpath�isabs�AssertionErrorrnr�r�)r
r0Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)r[r�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r0r�r@rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jkrD|�|||�\}}|dk	r<|V|sDdStt�|��}|D]t}tj�||�}	|�|	||�\}}|dk	r�|V|rV|�|	�}|j�|�z|�
|	||�EdHW5|j�	|�XqVdS)z/Used by discovery. Yields test suites it loads.rVN)r�r6�_find_test_pathrHr/�listdirr0rZ�add�discardr�)
r
r�r@r~rrPZshould_recurse�pathsr0r�rrrr��s6
��
zTestLoader._find_testsc
Csttj�|�}tj�|��rVt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnht	j
k
r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXtj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r@tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�ntj�|��rl|�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnjt	j
k
�r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXt|dd�}|j�|�z0|j||d�}|dk	�rP|dfW�S|d	fW�S|j�|�XndSdS)
z�Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        )NFFNr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r?r}rAT)r/r0r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr,r r"r4rLr�rJr2�realpathr-r�rrUr�rZr6r�r�)r
r�r@r~r�rrNrRrSrTZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgrArP�packagerrrr��s|

&
�
�
�
�
���
&
�
zTestLoader._find_test_path)N)N)r|N)F)F)rrr�__doc__ro�staticmethodr�
three_way_cmprxrprr8r rrr>rUrfrkr:r�r�r�r�r�r�r�rrrrrr3Bs&
(
N

n
"r3cCs&t�}||_||_||_|r"||_|Sr	)r3rxrorpr )�prefix�	sortUsingr rpr�rrr�_makeLoader�sr�cCst|||d��|�S)N)rp)r�r:)r=r�r�rprrrr:�sr:r%cCst|||��|�Sr	)r�r>)r=r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rU)rNr�r�r rrr�
findTestCasess�r�)NN)"r�r/�rer�rr]rzrCrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr,r2�objectr3ZdefaultTestLoaderr�r�r:r8r�r�rrrr�<module>s</
	�
�PK�
�\:��runner.cpython-38.opt-2.pycnu�[���U

e5dW�@sjddlZddlZddlZddlmZddlmZdZGdd�de�Z	Gdd	�d	ej
�ZGd
d�de�ZdS)�N�)�result)�registerResultTc@s&eZdZdd�Zdd�Zddd�ZdS)	�_WritelnDecoratorcCs
||_dS�N)�stream)�selfr�r	�'/usr/lib64/python3.8/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)N)r�__getstate__)�AttributeError�getattrr)r�attrr	r	r
�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS�N�
)�write)r�argr	r	r
�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__rrrr	r	r	r
r
srcs�eZdZdZdZ�fdd�Zdd�Z�fdd�Z�fd	d
�Z�fdd�Z	�fd
d�Z
�fdd�Z�fdd�Z�fdd�Z
dd�Zdd�Z�ZS)�TextTestResultzF======================================================================zF----------------------------------------------------------------------cs8tt|��|||�||_|dk|_|dk|_||_dS)Nr)�superrrr�showAll�dots�descriptions)rrr�	verbosity��	__class__r	r
r%s


zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdSr)ZshortDescriptionr�join�str)r�testZdoc_first_liner	r	r
�getDescription,s
zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr�	startTestrrrr$�flush�rr#rr	r
r%3s
zTextTestResult.startTestcsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)N�ok�.)	rr�
addSuccessrrrrrr&r'rr	r
r*:szTextTestResult.addSuccesscsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�ERROR�E)	rr�addErrorrrrrrr&�rr#�errrr	r
r-BszTextTestResult.addErrorcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�FAIL�F)	rr�
addFailurerrrrrr&r.rr	r
r2JszTextTestResult.addFailurecsLtt|��||�|jr,|j�d�|��n|jrH|j�d�|j�	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr&)rr#�reasonrr	r
r4RszTextTestResult.addSkipcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr&r.rr	r
r8Zsz!TextTestResult.addExpectedFailurecsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr&r'rr	r
r:bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|j��|�d|j�|�d|j�dS)Nr+r0)rrrr�printErrorList�errors�failures�rr	r	r
�printErrorsjs
zTextTestResult.printErrorscCsX|D]N\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�qdS)Nz%s: %sz%s)rr�
separator1r$�
separator2)rZflavourr<r#r/r	r	r
r;ps
zTextTestResult.printErrorList)rrrr@rArr$r%r*r-r2r4r8r:r?r;�
__classcell__r	r	rr
rsrc@s0eZdZeZddd�dd�Zdd	�Zd
d�ZdS)
�TextTestRunnerNTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dSr)�sys�stderrrrrr�failfast�bufferrD�warnings�resultclass)	rrrrrGrHrJrIrDr	r	r
r�s
zTextTestRunner.__init__cCs|�|j|j|j�Sr)rJrrrr>r	r	r
�_makeResult�szTextTestRunner._makeResultcCs2|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdkr^tjdt	dd�t
��}t|dd�}|dk	r�|�z||�W5t|dd�}|dk	r�|�Xt
��}W5QRX||}|�
�t|d�r�|j�|j�|j}|j�d||d	ko�d
�pd|f�|j��d}	}
}ztt|j|j|jf�}Wntk
�rTYnX|\}	}
}g}
|���s�|j�d
�t|j�t|j�}}|�r�|
�d|�|�r�|
�d|�n|j�d�|�r�|
�d|�|	�r�|
�d|	�|
�r|
�d|
�|
�r"|j�dd�|
�f�n|j�d�|S)N)�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRun�stopTestRunrAzRan %d test%s in %.3fsrr3�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rKrrGrHrDrI�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr?�hasattrrrrAZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr
Z
wasSuccessfulrr=r<�appendr!)rr#rZ	startTimerQrRZstopTimeZ	timeTaken�runZ
expectedFailsr]r^ZresultsZinfosZfailedZerroredr	r	r
r`�sx

�
�
�


zTextTestRunner.run)NTrFFNN)rrrrrJrrKr`r	r	r	r
rCxs��rC)
rErXrIrSrZsignalsrZ
__unittest�objectrZ
TestResultrrCr	r	r	r
�<module>s[PK�
�\�6��jjrunner.cpython-38.pycnu�[���U

e5dW�@sndZddlZddlZddlZddlmZddlmZdZGdd�de	�Z
Gd	d
�d
ej�ZGdd�de	�Z
dS)
z
Running tests�N�)�result)�registerResultTc@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS�N)�stream)�selfr�r	�'/usr/lib64/python3.8/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)N)r�__getstate__)�AttributeError�getattrr)r�attrr	r	r
�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS�N�
)�write)r�argr	r	r
�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__�__doc__rrrr	r	r	r
r
srcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd	�Z�fd
d�Z	�fdd
�Z
�fdd�Z�fdd�Z�fdd�Z
�fdd�Zdd�Zdd�Z�ZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    zF======================================================================zF----------------------------------------------------------------------cs8tt|��|||�||_|dk|_|dk|_||_dS)Nr)�superrrr�showAll�dots�descriptions)rrr�	verbosity��	__class__r	r
r%s


zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdSr)ZshortDescriptionr�join�str)r�testZdoc_first_liner	r	r
�getDescription,s
zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr�	startTestrrrr%�flush�rr$r r	r
r&3s
zTextTestResult.startTestcsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)N�ok�.)	rr�
addSuccessrrrrrr'r(r r	r
r+:szTextTestResult.addSuccesscsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�ERROR�E)	rr�addErrorrrrrrr'�rr$�errr r	r
r.BszTextTestResult.addErrorcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�FAIL�F)	rr�
addFailurerrrrrr'r/r r	r
r3JszTextTestResult.addFailurecsLtt|��||�|jr,|j�d�|��n|jrH|j�d�|j�	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr')rr$�reasonr r	r
r5RszTextTestResult.addSkipcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr'r/r r	r
r9Zsz!TextTestResult.addExpectedFailurecsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr'r(r r	r
r;bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|j��|�d|j�|�d|j�dS)Nr,r1)rrrr�printErrorList�errors�failures�rr	r	r
�printErrorsjs
zTextTestResult.printErrorscCsX|D]N\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�qdS)Nz%s: %sz%s)rr�
separator1r%�
separator2)rZflavourr=r$r0r	r	r
r<ps
zTextTestResult.printErrorList)rrrrrArBrr%r&r+r.r3r5r9r;r@r<�
__classcell__r	r	r r
rsrc@s4eZdZdZeZd
dd�dd�Zd	d
�Zdd�ZdS)�TextTestRunnerz�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    NTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrrr�failfast�bufferrE�warnings�resultclass)	rrrrrHrIrKrJrEr	r	r
r�s
zTextTestRunner.__init__cCs|�|j|j|j�Sr)rKrrrr?r	r	r
�_makeResult�szTextTestRunner._makeResultcCs2|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdkr^tjdt	dd�t
��}t|dd�}|dk	r�|�z||�W5t|dd�}|dk	r�|�Xt
��}W5QRX||}|�
�t|d�r�|j�|j�|j}|j�d	||d
ko�d�pd|f�|j��d
}	}
}ztt|j|j|jf�}Wntk
�rTYnX|\}	}
}g}
|���s�|j�d�t|j�t|j�}}|�r�|
�d|�|�r�|
�d|�n|j�d�|�r�|
�d|�|	�r�|
�d|	�|
�r|
�d|
�|
�r"|j�dd�|
�f�n|j�d�|S)z&Run the given test case or test suite.)�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRunN�stopTestRunrBzRan %d test%s in %.3fsrr4�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rLrrHrIrErJ�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr@�hasattrrrrBZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr
Z
wasSuccessfulrr>r=�appendr")rr$rZ	startTimerRrSZstopTimeZ	timeTaken�runZ
expectedFailsr^r_ZresultsZinfosZfailedZerroredr	r	r
ra�sx

�
�
�


zTextTestRunner.run)NTrFFNN)	rrrrrrKrrLrar	r	r	r
rDxs��rD)rrFrYrJrTrZsignalsrZ
__unittest�objectrZ
TestResultrrDr	r	r	r
�<module>s[PK�
�\a!n�}}result.cpython-38.opt-1.pycnu�[���U

e5d�@s\dZddlZddlZddlZddlmZddlmZdZdd�Z	d	Z
d
ZGdd�de�Z
dS)
zTest result object�N�)�util��wrapsTcst���fdd��}|S)Ncs$t|dd�r|���|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw��method��'/usr/lib64/python3.8/unittest/result.py�inner
szfailfast.<locals>.innerr)r
rrrrrsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZdZd.dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/�
TestResulta�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    NFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r	�streamZdescriptions�	verbosityrrr�__init__&szTestResult.__init__cCsdS)z#Called by TestRunner after test runNr�r	rrr�printErrors7szTestResult.printErrorscCs |jd7_d|_|��dS)z-Called when the given test is about to be runrFN)rr"�_setupStdout�r	�testrrr�	startTest:szTestResult.startTestcCs8|jr4|jdkr$t��|_t��|_|jt_|jt_dS)N)rr�io�StringIOrrrr r&rrrr(@s


zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nrr&rrr�startTestRunHszTestResult.startTestRuncCs|��d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr"r)rrr�stopTestNszTestResult.stopTestcCs�|jr�|jrltj��}tj��}|rF|�d�s6|d7}|j�t	|�|rl|�d�s\|d7}|j
�t|�|jt_|j
t_|j�
d�|j��|j�
d�|j��dS)N�
r)rr"rr�getvaluer �endswithr�write�STDOUT_LINEr!�STDERR_LINEr�seek�truncater)r	�output�errorrrrr/Ss$




zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nrr&rrr�stopTestRunhszTestResult.stopTestRuncCs"|j�||�||�f�d|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        TN)r�append�_exc_info_to_stringr"�r	r*�errrrr�addErrornszTestResult.addErrorcCs"|j�||�||�f�d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rr<r=r"r>rrr�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|��t|d|j�r4|j}n|j}|�||�||�f�d|_dS)z�Called at the end of a subtest.
        'err' is None if the subtest ended successfully, otherwise it's a
        tuple of values as returned by sys.exc_info().
        NrFrT)	rr�
issubclass�failureExceptionrrr<r=r")r	r*Zsubtestr?rrrr�
addSubTest}szTestResult.addSubTestcCsdS)z-Called when a test has completed successfullyNrr)rrr�
addSuccess�szTestResult.addSuccesscCs|j�||f�dS)zCalled when a test is skipped.N)rr<)r	r*�reasonrrr�addSkip�szTestResult.addSkipcCs|j�||�||�f�dS)z/Called when an expected failure/error occurred.N)rr<r=r>rrr�addExpectedFailure�s�zTestResult.addExpectedFailurecCs|j�|�dS)z5Called when a test was expected to fail, but succeed.N)rr<r)rrr�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrrr&rrr�
wasSuccessful�s$�zTestResult.wasSuccessfulcCs
d|_dS)z+Indicates that the tests should be aborted.TN)rr&rrrr�szTestResult.stopcCs�|\}}}|r |�|�r |j}q
||jkr6|�|�}nd}tj|||||jd�}t|���}|j	r�t
j��}	t
j
��}
|	r�|	�d�s�|	d7}	|�t|	�|
r�|
�d�s�|
d7}
|�t|
�d�|�S)z>Converts a sys.exc_info()-style tuple of values into a string.N)�limit�capture_localsr1�)�_is_relevant_tb_level�tb_nextrC�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr2r r3r<r5r6�join)r	r?r*�exctype�value�tb�lengthZtb_eZmsgLinesr9r:rrrr=�s4

�



zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)r	rZrrrrP�sz TestResult._is_relevant_tb_levelcCs&d}|r"|�|�s"|d7}|j}q|S)Nrr)rPrQ)r	rZr[rrrrR�s
z$TestResult._count_relevant_tb_levelscCs&dt�|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrJrrr&rrr�__repr__�s
��zTestResult.__repr__)NNN)�__name__�
__module__�__qualname__�__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r'r+r(r.r0r/r;rr@rArDrErGrHrIrLrr=rPrRr`rrrrrs8




	r)rdr,rrSrOr�	functoolsrr\rr5r6�objectrrrrr�<module>sPK�
�\O��EB1B1__init__.cpython-38.pycnu�[���U

e5d	8�
@s�dZdZdddddddgZd	Zd
dlmZmZd
dlmZd
dl	Z	edddddddd�Z
dddddddddd�	dd�Zdddddddddd�	dd�Zeddd�Z
dd�Zddddddd�dd�Zddddddd�dd�ZdS)aJSON (JavaScript Object Notation) <http://json.org> is a subset of
JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
interchange format.

:mod:`json` exposes an API familiar to users of the standard library
:mod:`marshal` and :mod:`pickle` modules.  It is derived from a
version of the externally maintained simplejson library.

Encoding basic Python object hierarchies::

    >>> import json
    >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
    '["foo", {"bar": ["baz", null, 1.0, 2]}]'
    >>> print(json.dumps("\"foo\bar"))
    "\"foo\bar"
    >>> print(json.dumps('\u1234'))
    "\u1234"
    >>> print(json.dumps('\\'))
    "\\"
    >>> print(json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True))
    {"a": 0, "b": 0, "c": 0}
    >>> from io import StringIO
    >>> io = StringIO()
    >>> json.dump(['streaming API'], io)
    >>> io.getvalue()
    '["streaming API"]'

Compact encoding::

    >>> import json
    >>> mydict = {'4': 5, '6': 7}
    >>> json.dumps([1,2,3,mydict], separators=(',', ':'))
    '[1,2,3,{"4":5,"6":7}]'

Pretty printing::

    >>> import json
    >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))
    {
        "4": 5,
        "6": 7
    }

Decoding JSON::

    >>> import json
    >>> obj = ['foo', {'bar': ['baz', None, 1.0, 2]}]
    >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') == obj
    True
    >>> json.loads('"\\"foo\\bar"') == '"foo\x08ar'
    True
    >>> from io import StringIO
    >>> io = StringIO('["streaming API"]')
    >>> json.load(io)[0] == 'streaming API'
    True

Specializing JSON object decoding::

    >>> import json
    >>> def as_complex(dct):
    ...     if '__complex__' in dct:
    ...         return complex(dct['real'], dct['imag'])
    ...     return dct
    ...
    >>> json.loads('{"__complex__": true, "real": 1, "imag": 2}',
    ...     object_hook=as_complex)
    (1+2j)
    >>> from decimal import Decimal
    >>> json.loads('1.1', parse_float=Decimal) == Decimal('1.1')
    True

Specializing JSON object encoding::

    >>> import json
    >>> def encode_complex(obj):
    ...     if isinstance(obj, complex):
    ...         return [obj.real, obj.imag]
    ...     raise TypeError(f'Object of type {obj.__class__.__name__} '
    ...                     f'is not JSON serializable')
    ...
    >>> json.dumps(2 + 1j, default=encode_complex)
    '[2.0, 1.0]'
    >>> json.JSONEncoder(default=encode_complex).encode(2 + 1j)
    '[2.0, 1.0]'
    >>> ''.join(json.JSONEncoder(default=encode_complex).iterencode(2 + 1j))
    '[2.0, 1.0]'


Using json.tool from the shell to validate and pretty-print::

    $ echo '{"json":"obj"}' | python -m json.tool
    {
        "json": "obj"
    }
    $ echo '{ 1.2:3.4}' | python -m json.tool
    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
z2.0.9�dump�dumps�load�loads�JSONDecoder�JSONDecodeError�JSONEncoderzBob Ippolito <bob@redivi.com>�)rr)r�NFT)�skipkeys�ensure_ascii�check_circular�	allow_nan�indent�
separators�default)	r
rrr
�clsrrr�	sort_keysc	Ks�|sD|rD|rD|rD|dkrD|dkrD|dkrD|	dkrD|
sD|sDt�|�}n2|dkrPt}|f|||||||	|
d�|���|�}|D]}
|�|
�qzdS)a�Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
    ``.write()``-supporting file-like object).

    If ``skipkeys`` is true then ``dict`` keys that are not basic types
    (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
    instead of raising a ``TypeError``.

    If ``ensure_ascii`` is false, then the strings written to ``fp`` can
    contain non-ASCII characters if they appear in strings contained in
    ``obj``. Otherwise, all such characters are escaped in JSON strings.

    If ``check_circular`` is false, then the circular reference check
    for container types will be skipped and a circular reference will
    result in an ``OverflowError`` (or worse).

    If ``allow_nan`` is false, then it will be a ``ValueError`` to
    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
    in strict compliance of the JSON specification, instead of using the
    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).

    If ``indent`` is a non-negative integer, then JSON array elements and
    object members will be pretty-printed with that indent level. An indent
    level of 0 will only insert newlines. ``None`` is the most compact
    representation.

    If specified, ``separators`` should be an ``(item_separator, key_separator)``
    tuple.  The default is ``(', ', ': ')`` if *indent* is ``None`` and
    ``(',', ': ')`` otherwise.  To get the most compact JSON representation,
    you should specify ``(',', ':')`` to eliminate whitespace.

    ``default(obj)`` is a function that should return a serializable version
    of obj or raise TypeError. The default simply raises TypeError.

    If *sort_keys* is true (default: ``False``), then the output of
    dictionaries will be sorted by key.

    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
    ``.default()`` method to serialize additional types), specify it with
    the ``cls`` kwarg; otherwise ``JSONEncoder`` is used.

    N�r
rrr
rrrr)�_default_encoder�
iterencoder�write)�obj�fpr
rrr
rrrrr�kw�iterable�chunk�r�%/usr/lib64/python3.8/json/__init__.pyrxsD-�����������c	Kst|sB|rB|rB|rB|dkrB|dkrB|dkrB|dkrB|	sB|
sBt�|�S|dkrNt}|f||||||||	d�|
���|�S)auSerialize ``obj`` to a JSON formatted ``str``.

    If ``skipkeys`` is true then ``dict`` keys that are not basic types
    (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
    instead of raising a ``TypeError``.

    If ``ensure_ascii`` is false, then the return value can contain non-ASCII
    characters if they appear in strings contained in ``obj``. Otherwise, all
    such characters are escaped in JSON strings.

    If ``check_circular`` is false, then the circular reference check
    for container types will be skipped and a circular reference will
    result in an ``OverflowError`` (or worse).

    If ``allow_nan`` is false, then it will be a ``ValueError`` to
    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
    strict compliance of the JSON specification, instead of using the
    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).

    If ``indent`` is a non-negative integer, then JSON array elements and
    object members will be pretty-printed with that indent level. An indent
    level of 0 will only insert newlines. ``None`` is the most compact
    representation.

    If specified, ``separators`` should be an ``(item_separator, key_separator)``
    tuple.  The default is ``(', ', ': ')`` if *indent* is ``None`` and
    ``(',', ': ')`` otherwise.  To get the most compact JSON representation,
    you should specify ``(',', ':')`` to eliminate whitespace.

    ``default(obj)`` is a function that should return a serializable version
    of obj or raise TypeError. The default simply raises TypeError.

    If *sort_keys* is true (default: ``False``), then the output of
    dictionaries will be sorted by key.

    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
    ``.default()`` method to serialize additional types), specify it with
    the ``cls`` kwarg; otherwise ``JSONEncoder`` is used.

    Nr)r�encoder)rr
rrr
rrrrrrrrrr�sD,��������
���)�object_hook�object_pairs_hookcCs�|j}|tjtjf�rdS|tjtjf�r.dS|tj�r<dSt|�dkr�|ds`|dr\dSdS|ds�|d	sx|d
r|dSdSn$t|�d	kr�|ds�dS|ds�dSd
S)Nzutf-32zutf-16z	utf-8-sig�r	rz	utf-16-bez	utf-32-be��z	utf-16-lez	utf-32-lezutf-8)�
startswith�codecs�BOM_UTF32_BE�BOM_UTF32_LE�BOM_UTF16_BE�BOM_UTF16_LE�BOM_UTF8�len)�bZbstartswithrrr�detect_encoding�s$
r-�rr�parse_float�	parse_int�parse_constantr c	Ks"t|��f||||||d�|��S)a�Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
    a JSON document) to a Python object.

    ``object_hook`` is an optional function that will be called with the
    result of any object literal decode (a ``dict``). The return value of
    ``object_hook`` will be used instead of the ``dict``. This feature
    can be used to implement custom decoders (e.g. JSON-RPC class hinting).

    ``object_pairs_hook`` is an optional function that will be called with the
    result of any object literal decoded with an ordered list of pairs.  The
    return value of ``object_pairs_hook`` will be used instead of the ``dict``.
    This feature can be used to implement custom decoders.  If ``object_hook``
    is also defined, the ``object_pairs_hook`` takes priority.

    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
    kwarg; otherwise ``JSONDecoder`` is used.
    r.)r�read)rrrr/r0r1r rrrrrs
��c	Ks&t|t�r"|�d�rRtd|d��n0t|ttf�sBtd|jj����|�	t
|�d�}d|krxddl}|jdt
d	d
�|d=|dkr�|dkr�|dkr�|dkr�|dkr�|dkr�|s�t�	|�S|dkr�t}|dk	r�||d<|dk	r�||d<|dk	r�||d
<|dk	�r||d<|dk	�r||d<|f|��	|�S)a�Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
    containing a JSON document) to a Python object.

    ``object_hook`` is an optional function that will be called with the
    result of any object literal decode (a ``dict``). The return value of
    ``object_hook`` will be used instead of the ``dict``. This feature
    can be used to implement custom decoders (e.g. JSON-RPC class hinting).

    ``object_pairs_hook`` is an optional function that will be called with the
    result of any object literal decoded with an ordered list of pairs.  The
    return value of ``object_pairs_hook`` will be used instead of the ``dict``.
    This feature can be used to implement custom decoders.  If ``object_hook``
    is also defined, the ``object_pairs_hook`` takes priority.

    ``parse_float``, if specified, will be called with the string
    of every JSON float to be decoded. By default this is equivalent to
    float(num_str). This can be used to use another datatype or parser
    for JSON floats (e.g. decimal.Decimal).

    ``parse_int``, if specified, will be called with the string
    of every JSON int to be decoded. By default this is equivalent to
    int(num_str). This can be used to use another datatype or parser
    for JSON integers (e.g. float).

    ``parse_constant``, if specified, will be called with one of the
    following strings: -Infinity, Infinity, NaN.
    This can be used to raise an exception if invalid JSON numbers
    are encountered.

    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
    kwarg; otherwise ``JSONDecoder`` is used.

    The ``encoding`` argument is ignored and deprecated since Python 3.1.
    uz-Unexpected UTF-8 BOM (decode using utf-8-sig)r	z5the JSON object must be str, bytes or bytearray, not �
surrogatepass�encodingNzF'encoding' is ignored and deprecated. It will be removed in Python 3.9r")�
stacklevelrr r/r0r1)�
isinstance�strr$r�bytes�	bytearray�	TypeError�	__class__�__name__�decoder-�warnings�warn�DeprecationWarning�_default_decoderr)	�srrr/r0r1r rr>rrrr+sT$

�������


)�__doc__�__version__�__all__�
__author__�decoderrr�encoderrr%rrrrAr-rrrrrr�<module>sda��
�?�:��PK�
�\l�k�async_case.cpython-38.opt-2.pycnu�[���U

e5d��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd �fdd�	Z�ZS)!�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��+/usr/lib64/python3.8/unittest/async_case.pyr"sz IsolatedAsyncioTestCase.__init__c�sdSrr�rrrr�
asyncSetUp'sz"IsolatedAsyncioTestCase.asyncSetUpc�sdSrrrrrr�
asyncTearDown*sz%IsolatedAsyncioTestCase.asyncTearDowncOs|j|f|�|�dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup-s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp<sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod@sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownCsz%IsolatedAsyncioTestCase._callTearDowncOs|j|f|�|�dSrr)rZfunctionrrrrr�_callCleanupGsz$IsolatedAsyncioTestCase._callCleanupcOs0|||�}|j��}|j�||f�|j�|�Sr)r	�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrJs

z"IsolatedAsyncioTestCase._callAsynccOsB|||�}t�|�r:|j��}|j�||f�|j�|�S|SdSr)�inspectZisawaitabler	rr
r r!r"rrrrRs


z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s�t��|_}|�d�|��IdH}|��|dkr:dS|\}}z |IdH}|��s`|�|�Wqttfk
r|�Yqt	tj
fk
r�}z|��s�|�|�W5d}~XYqXqdSr)�asyncioZQueuer
Z
set_result�getZ	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr$ZqueueZqueryZ	awaitabler#Zexrrr�_asyncioLoopRunner\s 

z*IsolatedAsyncioTestCase._asyncioLoopRunnercCsJt��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)NT)
r&Znew_event_loop�set_event_loopZ	set_debugr	rZcreate_taskr,Z_asyncioCallsTaskr!)r�loopr$rrr�_setupAsyncioLoopos

z)IsolatedAsyncioTestCase._setupAsyncioLoopc	Cs�|j}d|_|j�d�|�|j���z�t�|�}|s@W�vdS|D]}|�	�qD|�tj
||dd���|D]0}|��r|qn|��dk	rn|�
d|��|d��qn|�|���W5t�d�|��XdS)NT)r.Zreturn_exceptionsz(unhandled exception during test shutdown)�message�	exception�task)r	r
r r!�joinr&r-�closeZ	all_tasksZcancelZgatherr(r1Zcall_exception_handlerZshutdown_asyncgens)rr.Z	to_cancelr2rrr�_tearDownAsyncioLoopys2

��

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs(|��zt��|�W�S|��XdSr)r/r5r�run)r�resultrrrr6�szIsolatedAsyncioTestCase.run)r)N)�__name__�
__module__�__qualname__rrrrrrrrrrr,r/r5r6�
__classcell__rrrrrs

"r)r&r%Zcaserrrrrr�<module>sPK�
�\���58.8.mock.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZmZdd�ee�D�Zd	ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�dd�Zdd�Zdd�Zdd�Z dd �Z!d�d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%Gd)d*�d*e&�Z'Gd+d,�d,e&�Z(e(�Z)e)j*Z*e)j+Z,e)j-Z.d-d.d/d0d1d2d3d4hZ/d5d6�Z0Gd7d8�d8e1�Z2d9d:�Z3Gd;d<�d<e&�Z4Gd=d>�d>e&�Z5Gd?d@�d@e5�Z6dAdB�Z7GdCdD�dDe5�Z8GdEdF�dFe8e6�Z9dGdH�Z:dIdJ�Z;GdKdL�dLe&�Z<dMdN�Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@GdUdV�dVe&�ZAdWdX�ZBdYdZ�ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`�eI�K�D��ZLd^�Jdad`�eI�K�D��ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu�ZOdvd�d^�JeHeIeLeMg��K�D�ZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd�d�d�hZVd�d��d�d��d�d��d�d��d��ZWeXeXeXeXd�dddd�d�d	d�dd��
ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]eZe[e\e]d��Z^d�d��Z_Gd�d��d�e5�Z`Gd�d��d�e`e6�ZaGd�d��d�e`�ZbGd�d��d�e`e9�ZcGd�d��d�e5�ZdGd�d��d�e5�ZeGd�d��d�eeebe9�ZfGd�d��d�e&�Zgeg�Zhd�d��ZiGd�d��d�ej�Zkekdd��Zld�d�d��Zmd�d��ZnGd�d��d�e&�Zoepem�epehjq�fZrdasd�d��Ztd�d�d��ZuGd�d��d�e9�Zvd�d��ZwGd�d��d��ZxdS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�sealz1.0�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�%/usr/lib64/python3.8/unittest/mock.py�	<setcomp>(s
rTcCs>t|�rt|t�sdSt|d�r*t|d�}t�|�p<t�|�S)NF�__func__)	�_is_instance_mock�
isinstancer	�hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objrrr�
_is_async_obj0s


r*cCst|dd�rt�|�SdSdS)N�__code__F)r$r%r&��funcrrr�_is_async_func8s
r.cCstt|�t�S�N)�
issubclass�typerr(rrrr!?sr!cCst|t�pt|t�ot|t�Sr/)r"�
BaseExceptionr1r0r(rrr�
_is_exceptionEs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r"�
FunctionTypesr#r5r(rrr�
_extract_mockLsr7cCs�t|t�r|s|j}d}n,t|t�sFz
|j}Wntk
rDYdSX|rVt|d�}n|}z|t�|�fWSt	k
r�YdSXdS)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r"r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectUs

r=FcsNt|||���dkrdS�\}��fdd�}t||�|t|�_�t|�_dS)Ncs�j||�dSr/��bind��self�args�kwargs��sigrr�checksigwsz"_check_signature.<locals>.checksig)r=�_copy_func_detailsr1�_mock_check_sig�
__signature__)r-r5�	skipfirst�instancerFrrDr�_check_signaturers

rLc	Cs:dD]0}zt||t||��Wqtk
r2YqXqdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr$r:)r-�funcopy�	attributerrrrG~s
rGcCs@t|t�rdSt|tttf�r(t|j�St|dd�dk	r<dSdS)NTr9F)r"r1�staticmethod�classmethodr�	_callabler r$r(rrrrX�s

rXcCst|�ttfkSr/)r1�list�tupler(rrr�_is_list�sr[cCsFt|t�st|dd�dk	S|f|jD]}|j�d�dk	r&dSq&dS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.r9NTF)r"r1r$�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
r`cs�t|t�}t|||�}|dkr"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j||�dSr/r>�rBrCrDrrrF�sz _set_signature.<locals>.checksigrT)Z
_checksig_r5zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r"r1r=rGrM�isidentifier�exec�_setup_func)r5�originalrKrJ�resultr-rFr�context�srcrTrrDr�_set_signature�s$


�
rics���_�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}	��fdd�}
d�_d�_d�_t��_t��_t��_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Ncs�j||�Sr/)�assert_called_withra�r5rrrj�sz'_setup_func.<locals>.assert_called_withcs�j||�Sr/)�
assert_calledrarkrrrl�sz"_setup_func.<locals>.assert_calledcs�j||�Sr/)�assert_not_calledrarkrrrm�sz&_setup_func.<locals>.assert_not_calledcs�j||�Sr/)�assert_called_oncerarkrrrn�sz'_setup_func.<locals>.assert_called_oncecs�j||�Sr/)�assert_called_once_withrarkrrro�sz,_setup_func.<locals>.assert_called_once_withcs�j||�Sr/)�assert_has_callsrarkrrrp�sz%_setup_func.<locals>.assert_has_callscs�j||�Sr/)�assert_any_callrarkrrrq�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�k	r6|��dSr/)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer!)�ret�rTr5rrru�sz_setup_func.<locals>.reset_mockFr)r5�called�
call_count�	call_argsrr�call_args_listrsrtrv�side_effect�_mock_childrenrjrorprqrurlrmrnrI�_mock_delegate)rTr5rErjrlrmrnrorprqrurrxrrd�s8rdcsJtjj�_d�_d�_t��_�fdd�}dD]}t�|t||��q.dS)Nrcst�j|�||�Sr/)r$r5)�attrrBrCrkrr�wrapper�sz"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	r%�
coroutines�
_is_coroutine�await_count�
await_argsrr�await_args_listrSr)r5r�rUrrkr�_setup_async_mock�s
r�cCsd|dd�|kS)N�__%s__����r�rrrr�	_is_magicsr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_SentinelObjectz!A unique, named, sentinel object.cCs
||_dSr/r��rArrrrr8sz_SentinelObject.__init__cCs
d|jS�Nzsentinel.%sr��rArrr�__repr__sz_SentinelObject.__repr__cCs
d|jSr�r�r�rrr�
__reduce__sz_SentinelObject.__reduce__N)rMrP�__qualname__rNr8r�r�rrrrr�sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dSr/)�
_sentinelsr�rrrr8#sz_Sentinel.__init__cCs|dkrt�|j�|t|��S)N�	__bases__)r:r��
setdefaultr�r�rrr�__getattr__&sz_Sentinel.__getattr__cCsdS)Nrrr�rrrr�,sz_Sentinel.__reduce__N)rMrPr�rNr8r�r�rrrrr�!sr�rv�_mock_return_valuer}�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�Sr/)rr$)rAr�	_the_namerErrr�_getAs
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dSr/)rr]rS)rA�valuerr�rErrr�_setFsz"_delegating_property.<locals>._set)�_allowed_names�add�property)rr�r�r�rrr�_delegating_property>s

r�c@seZdZdd�Zdd�ZdS)rrcCslt|t�st�||�St|�}t|�}||kr2dStd||d�D]"}||||�}||krDdSqDdS)NFr�T)r"rY�__contains__�len�range)rAr�Z	len_valueZlen_self�iZsub_listrrrr�Ss
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrYr�rrrr�asz_CallList.__repr__N)rMrPr�r�r�rrrrrrQsrrcCs|t|�}t|�sdS|js4|js4|jdk	s4|jdk	r8dS|}|dk	rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentes*��r�c@seZdZdd�Zdd�ZdS)�	_MockItercCst|�|_dSr/)�iterr))rAr)rrrr8�sz_MockIter.__init__cCs
t|j�Sr/)�nextr)r�rrr�__next__�sz_MockIter.__next__N)rMrPr�r8r�rrrrr��sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdSr/rr@rrrr8�sz
Base.__init__)rMrPr�rr�r�r8rrrrr��sr�c@sdeZdZdZdd�ZdLdd�Zd	d
�ZdMdd�ZdNd
d�Zdd�Z	dd�Z
dZee	e
e�Z
edd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdOddd�d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dPd3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dQdCdD�Z)dEdF�Z*dGdH�Z+dRdJdK�Z,dS)Srz A non-callable version of `Mock`c	Os�|f}t|t�s^t�tj�}|j|f|�|�j}dd�|��D�}|r^t	||d�r^t
|f}t|j|d|j
i�}tt|��|�}|S)NcSsg|]}|�d�r|�qS��specr�r�argrrr�
<listcomp>�s
�z+NonCallableMock.__new__.<locals>.<listcomp>rrN)r0r	r'r;rr8Zbind_partialZ	arguments�keysr*�AsyncMockMixinr1rMrN�_safe_super�__new__)	�clsrB�kw�basesrEZ
bound_argsZspec_arg�newrKrrrr��s
�zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<d|
d<|dk	rJ|}d}|
dkrZ|dk	}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|��||||||�dS)Nr�r�r�r�F�_mock_sealedTr~�_mock_wrapsrZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrs�_mock_unsafe)r]�_mock_add_specrr�configure_mockr�rr8)rAr�rr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferCr]rrrr8�sD



�zNonCallableMock.__init__cCs0t|�}d|_d|_d|_d|_t|||�dS)z�
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one.Nr�)r7r�r�r�r�rS)rAr5rUZ
inner_mockrrr�attach_mock�szNonCallableMock.attach_mockcCs|�||�dS�z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r��rAr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_speccCs�d}d}g}t|�D] }t�t||d��r|�|�q|dk	r~t|�s~t|t�rV|}nt|�}t|||�}	|	ot|	d}t|�}|j	}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)
�dirr%r&r$�appendr[r"r1r=r])rAr�r�r�r�r�r�r�r��resr]rrrr��s,
�zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)N�()�r�r�)r�rrvr�_get_child_mock)rArwrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nr�)rrvr�r�)rAr�rrrZ__set_return_values

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jSr/)r�r1r�rrr�	__class__!s
zNonCallableMock.__class__ryrzr{r|rtcCsN|j}|dkr|jS|j}|dk	rJt|�sJt|t�sJt|�sJt|�}||_|Sr/)rr�r}�callabler"r�r3)rA�	delegatedZsfrrrZ__get_side_effect.s��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dSr/)�	_try_iterrr�r})rAr�r�rrrZ__set_side_effect9s
z!NonCallableMock.__set_side_effect)rvr}cCs�|dkrg}t|�|krdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D]"}t|t�sr|tkr�qr|�|�qr|j
}t|�r�||k	r�|�|�dS)z-Restore the mock object to its initial state.NFr)�idr�ryr{rzrrrtr|rsrr�r�r~�valuesr"�
_SpecState�_deletedrur!)rAZvisitedrvr}�childrwrrrruDs,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)aZSet attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)cSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>o�z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�N)�sorted�items�split�popr$rS)rArCr��valrB�finalr)r�rrrr�bs	�
zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)N>r�r�zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r�rrr�r�)r:r��_all_magicsr�r�rr~r^r�r�r$r�r"r�rr�r�rKr�r)rArrfrrrrr�xsF




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|dk	rZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddkr�|d7}||d<d�|�S)Nr�r�r�r5r�)r�z().r)r�r�r�rY�reversedr�r��join)rAZ
_name_listr�Zlast�dotZ_firstrrr�_extract_mock_name�s(


z"NonCallableMock._extract_mock_namecCs^|��}d}|dkrd|}d}|jdk	rDd}|jr8d}||jj}dt|�j||t|�fS)Nr�)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�r�rMr1r�)rArZname_stringZspec_stringrrrr��s 
�zNonCallableMock.__repr__cCsvtst�|�S|jpg}tt|��}t|j�}dd�|j�	�D�}dd�|D�}dd�|D�}t
t||||��S)z8Filter the output of `dir(mock)` to only useful members.cSsg|]\}}|tk	r|�qSr)r�)rZm_nameZm_valuerrrr��s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��s
cSs"g|]}|�d�rt|�r|�qSr)rr�rrrrr��s
�)r
�object�__dir__r�r�r1rYr]r~r�r��set)rAZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tkrt��||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n,|dkr�|�_dSt
�|||��r|�j|<�j�rFt�|��sF����d|��}td|����t��||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�Sr/r�rBr��rerArrr��r�z-NonCallableMock.__setattr__.<locals>.<lambda>r�r�zCannot set )r�r�__setattr__r�r�r]r:�_unsupported_magicsr�r!rSr1�_get_methodr�r~r�r�r#r�)rArr��msg�	mock_namerrrr�s<��

zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS|j�|t�}||jkr\tt|��	|�n|t
krlt|��|tk	r||j|=t
|j|<dSr/)r�r1r]�delattrr~r^�_missingr�r�__delattr__r�r:)rArr)rrrrs

zNonCallableMock.__delattr__cCs|jpd}t|||�Sr4)r��_format_call_signature�rArBrCrrrr�_format_mock_call_signatures
z+NonCallableMock._format_mock_call_signaturercCs.d}|�||�}|j}|j|�}||||fS)Nz.expected %s not found.
Expected: %s
Actual: %s)rr{)rArBrC�action�message�expected_stringr{Z
actual_stringrrr�_format_mock_failure_messages

z,NonCallableMock._format_mock_failure_messagecCsj|s
|jSd}|�dd��d�}|j}|D]:}|�|�}|dksJt|t�rPqfq*t|�}|j}|j}q*|S)aH
        * If call objects are asserted against a method/function like obj.meth1
        then there could be no name for the call object to lookup. Hence just
        return the spec_signature of the method/function being asserted against.
        * If the name is not empty then remove () and split by '.' to get
        list of names to iterate through the children until a potential
        match is found. A child mock is created only during attribute access
        so if we get a _SpecState then no attributes of the spec were accessed
        and can be safely exited.
        Nr�r�r�)r��replacer�r~r^r"r�r7)rArrE�namesZchildrenr�rrr�_get_call_signature_from_name's
z-NonCallableMock._get_call_signature_from_namec
Cs�t|t�r&t|�dkr&|�|d�}n|j}|dk	r�t|�dkrNd}|\}}n
|\}}}z||j||�fWStk
r�}z|�d�WY�Sd}~XYq�Xn|SdS)a
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        r�rNr�)r"rZr�rr�r?�	TypeError�with_traceback)rA�_callrErrBrCrrrr�
_call_matcherHs

"zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j|��f}t|��dS)z/assert that the mock was never called.
        rz9Expected '%s' to not have been called. Called %s times.%sr5N�rzr��_calls_repr�AssertionError�rAr
rrrrmbs
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.r5N)rzr�rr rrrrlls

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)z3assert that the mock was called only once.
        r�z:Expected '%s' to have been called once. Called %s times.%sr5Nrr rrrrnts
��z"NonCallableMock.assert_called_oncecs��jdkr.�����}d}d||f}t|�����fdd�}����f�}���j�}||kr~t|t�rn|nd}t|��|�dS)z�assert that the last call was made with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock.Nznot called.z0expected call not found.
Expected: %s
Actual: %scs�����}|Sr/�r�r
�rBrCrArr�_error_message�sz:NonCallableMock.assert_called_with.<locals>._error_message)r{rrrr"�	Exception)rArBrC�expected�actualZ
error_messager$�causerr#rrj~s
�z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j|��f}t|��|j||�S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�z3Expected '%s' to be called once. Called %s times.%sr5)rzr�rrrj�rArBrCr
rrrro�s
��z'NonCallableMock.assert_called_once_withc		s�fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|���jdd��d
����|�dSt|�}g}|D]2}z|�|�Wq�t	k
r�|�
|�Yq�Xq�|�rtd�jp�dt|�|f�|�dS)a�assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`.csg|]}��|��qSr�r�r�cr�rrr��sz4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r"r%rrrr�	<genexpr>�s
z3NonCallableMock.assert_has_calls.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s��
Expected: ZActual)�prefixr�z@%r does not contain all of %r in its call list, found %r insteadr5)
r�rrrt�formatrr�rstriprY�remover<r�r�rZ)	rA�calls�	any_orderr&r(Z	all_calls�problem�	not_found�kallrr�rrp�sH
��"������z NonCallableMock.assert_has_callscsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)z�assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one.csg|]}��|��qSrr*r+r�rrr��sz3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)rr|r"r%rr�rArBrCr&r'r(rrr�rrq�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdkr"tf|�St|�}t|t�rB|tkrBt}nbt|t�rp|tksd|j	rj||j	krjt}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t
}n
|jd}|jr�d|kr�d|dnd}|��|}t|��|f|�S)aPCreate the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass).r�r�r�rr�r�)r^r]r	r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr\r�r�r:)rAr�r��_type�klassrUrrrrr��s2


��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)z�Renders self.mock_calls as a string.

        Example: "
Calls: [call(1), call(2)]."

        If self.mock_calls is empty, an empty string is returned. The
        output will be truncated if very long.
        r��
z: r�)rtr)rAr0rrrrszNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)r?)-rMrPr�rNr�r8r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr�rvr�r�ryrzr{r|rtZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr}rur�r�r�r�rrrrrrrrmrlrnrjrorprqr�rrrrrr�sp�
-
	�

�

''
!


-'rcCsL|dkr|St|�r|St|�r$|Sz
t|�WStk
rF|YSXdSr/)r3rXr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r<Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nr�)r]r�r<r8r})rAr�r}rvrrr�r�r�r�r�rCrrrr8#s

��zCallableMixin.__init__cOsdSr/rr@rrrrH/szCallableMixin._mock_check_sigcOs$|j||�|j||�|j||�Sr/)rH�_increment_mock_call�
_mock_callr@rrrr94szCallableMixin.__call__cOs|j||�Sr/)�_execute_mock_callr@rrrrB<szCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdk	}|j}|j}|dk}|j	�td||f��|j
}|dk	r�|r�|j�t|||f��|jdk	}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr���twor�r�r�)ryrz�_Callr{r|r�r�r�r�rtr�rs)rArBrCrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrA?s4


z"CallableMixin._increment_mock_callcOs||j}|dk	rPt|�r|�n(t|�s:t|�}t|�rD|�n
|||�}|tk	rP|S|jtk	r`|jS|jdk	rv|j||�S|jSr/)r}r3rXr�rr�rvr�)rArBrC�effectrfrrrrCms 


z CallableMixin._execute_mock_call)
rMrPr�rr8rHr9rBrArCrrrrr<!s�
.r<c@seZdZdZdS)ra�	
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    N�rMrPr�rNrrrrr�srcCs8zt||�WStk
r2t|�t||�YSXdSr/)r$r:�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rMcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rIrM)�targetZ
componentsrLrJrKrrr�	_importer�s

rOc@szeZdZdZgZdd�Zdd�Zdd�Zdd	�Ze	j
d
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr<�getterrUr��new_callabler��createZ	has_localr��autospecrC�additional_patchers)
rArQrUr�r�rSr�rTrRrCrrrr8�s(��z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|���qSr)�copy)r�prrrr��sz_patch.copy.<locals>.<listcomp>)rPrQrUr�r�rSr�rTrRrC�attribute_namerU)rA�patcherrrrrV�s ��z_patch.copycCs2t|t�r|�|�St�|�r(|�|�S|�|�Sr/)r"r1�decorate_classr'r&�decorate_async_callable�decorate_callable�rAr-rrrr9�s




z_patch.__call__cCsNt|�D]@}|�tj�sqt||�}t|d�s0q|��}t||||��q|S�Nr9)r�rr�TEST_PREFIXr$r#rVrS)rAr>r��
attr_valuerYrrrrZs

z_patch.decorate_classc	csrg}t���\}|jD]8}|�|�}|jdk	r8|�|�q|jtkr|�|�q|t	|�7}||fVW5QRXdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextrX�updater�rr�rZ)rA�patchedrB�keywargs�
extra_args�
exit_stack�patchingr�rrr�decoration_helpers




z_patch.decoration_helpercs>t�d�r�j����St�����fdd����g�_�S)Nrcc
s4���||��\}}�||�W5QR�SQRXdSr/�rk�rBrgZnewargsZnewkeywargs�r-rfrArrrf(s�z)_patch.decorate_callable.<locals>.patched�r#rcr�rr]rrnrr\"s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrcc
�s:���||��"\}}�||�IdHW5QR�SQRXdSr/rlrmrnrrrf9s�z/_patch.decorate_async_callable.<locals>.patchedror]rrnrr[3s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
s�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)rQrUrr]r:�KeyErrorr$�	_builtinsr"rrS)rArNrre�localrrr�get_originalDs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|�	�\}}|t
k�r||dk�r|d}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s|dk	�r.|t
k�rtd��t|t��r.d}	|dk�rHt
|��rHt}
nt}
i}|dk	�r`|}
n^|dk	�st|dk	�r�|}|dk	�r�|}t|��r�d|k}
n
t|�}
t
|��r�t}
n
|
�r�t}
|dk	�r�||d	<|dk	�r�||d
<t|
t��rt|
t��r|j�r|j|d<|�|�|
f|�}|	�r�t|��r�|}|dk	�rB|}t|��sZt|��sZt}
|�d�|
f|dd
�|��|_nl|dk	�r�|t
k	�r�td��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#dk	�rpi}|jt
k�r:|||j#<|j$D](}|j!�%|�}|jt
k�r@|�|��q@|WS|WS|j&t'�(���s��YnXdS)zPerform the patch.FNzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer9r�r�rr�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating))r�r�r�rTrCrRrQrNrrsrr"r1r*r	rr[r�rr0rrUrer!r`r�rv�boolr�
temp_original�is_localrarb�_exit_stackrSrXrUrd�__exit__�sys�exc_info)rAr�r�r�rTrCrRrerrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrhrjr�rrr�	__enter__\s�
�








��




�
�


�

��


z_patch.__enter__cGs�|jr$|jtk	r$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdkrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)zUndo the patch.)rNrPrQ�__annotations__rR)rwrvrrSrNrUrrSr#rxry)rAr{rirrrry�s�z_patch.__exit__cCs|��}|j�|�|S)z-Activate a patch, returning any created mock.)r~�_active_patchesr�)rArfrrr�start�sz_patch.startcCs6z|j�|�Wntk
r&YdSX|�ddd�S)zStop an active patch.N)r�r3r<ryr�rrr�stop�s
z_patch.stop)rMrPr�rXr�r8rVr9rZra�contextmanagerrkr\r[rsr~ryr�r�rrrrrP�s 

rPc	sPz��dd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��Sr/�rOr�rNrrr�r�z_get_target.<locals>.<lambda>)�rsplitrr<)rNrUrQrr�r�_get_target
s�r�c

s>t��tkrt��d����fdd�}	t|	||||||||�	S)a
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    z3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�*r�z_patch_object.<locals>.<lambda>)r1�strrrP)
rNrUr�r�rSr�rTrRrCrQrr�r�
_patch_objects ��r�c
s�t��tkr�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)a�Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cst��Sr/r�rr�rrr�Hr�z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Jr�z=Must supply at least one keyword argument with patch.multiplerr�N)	r1r�r<rYr�rPrXrUr�)
rNr�rSr�rTrRrCrQr�rUr�rYZthis_patcherrr�r�_patch_multiple1sH���r�c

Ks$t|�\}}	t||	|||||||�	S)a7
    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with an
    `AsyncMock if the patched object is an async function or a
    `MagicMock` otherwise. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `AsyncMock` is
    used for async functions and `MagicMock` for the rest.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    `patch` takes arbitrary keyword arguments. These will be passed to
    the `Mock` (or `new_callable`) on construction.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    )r�rP)
rNr�r�rSr�rTrRrCrQrUrrrrbsF�rc@sReZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
eZe
ZdS)�_patch_dicta#
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    rFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�re�clear�	_original)rAr�r�r�rCrrrr8�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs&���z�||�W�S���XdSr/)r��
_unpatch_dictr��frArr�_inner�sz$_patch_dict.__call__.<locals>._inner)r"r1rZr)rAr�r�rr�rr9�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sr^)r�r$rrr_r#r�r�r�r�rS)rAr>r�r`Z	decoratorZ	decoratedrrrrZ�s
�z_patch_dict.decorate_classcCs|��|jS)zPatch the dict.)r�r�r�rrrr~�sz_patch_dict.__enter__cCs�|j}t|jt�rt|j�|_|j}|j}z|��}Wn.tk
rdi}|D]}||||<qNYnX||_|rxt	|�z|�
|�Wn*tk
r�|D]}||||<q�YnXdSr/)r�r"r�r�rOr�rVr:r��_clear_dictre)rAr�r�r�rer�rrrr��s&z_patch_dict._patch_dictcCsR|j}|j}t|�z|�|�Wn*tk
rL|D]}||||<q6YnXdSr/)r�r�r�rer:)rAr�rer�rrrr�sz_patch_dict._unpatch_dictcGs|��dS)zUnpatch the dict.F)r�)rArBrrrrysz_patch_dict.__exit__N)rF)
rMrPr�rNr8r9rZr~r�r�ryr�r�rrrrr��s
	
r�cCs>z|��Wn,tk
r8t|�}|D]
}||=q(YnXdSr/)r�r:rY)r�r�r�rrrr�&sr�cCsttj�D]}|��q
dS)z7Stop all active patches. LIFO to unroll nested patches.N)r�rPr�r�)rrrr�_patch_stopall/sr�Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr�r�nrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr�rrrr.Os�__get__�__set__�
__delete__�__reversed__�__missing__r��
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__Z
__setformat__r�r�__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|f|�|�Sr/r�rArBr�r,rr�method`sz_get_method.<locals>.method)rM)rr-r�rr,rr	^sr	cCsh|]}d|�qS)r�r)rr�rrrrfs�
__aenter__�	__aexit__�	__anext__�	__aiter__r�rr8r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
t�|�Sr/)r�__hash__r�rrrr�|r�r�cCs
t�|�Sr/)r�__str__r�rrrr�}r�cCs
t�|�Sr/)r�
__sizeof__r�rrrr�~r�cCs"t|�j�d|���dt|���S)N�/)r1rMr�r�r�rrrr�r�)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__ry�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStS�NT)�__eq__r�r�NotImplemented)�other�ret_valr�rrr��sz_get_eq.<locals>.__eq__r)rAr�rr�r�_get_eq�sr�cs�fdd�}|S)Ncs �jjtk	rtS�|krdStS�NF)�__ne__r�rr�)r�r�rrr��s
z_get_ne.<locals>.__ne__r)rAr�rr�r�_get_ne�sr�cs�fdd�}|S)Ncs �jj}|tkrtg�St|�Sr/)�__iter__r�rr��r�r�rrr��sz_get_iter.<locals>.__iter__r)rAr�rr�r�	_get_iter�sr�cs�fdd�}|S)Ncs(�jj}|tkrttg��Stt|��Sr/)r�r�r�_AsyncIteratorr�r�r�rrr��sz"_get_async_iter.<locals>.__aiter__r)rAr�rr�r�_get_async_iter�sr�)r�r�r�r�cCsbt�|t�}|tk	r||_dSt�|�}|dk	rB||�}||_dSt�|�}|dk	r^||�|_dSr/)�_return_valuesr^rrv�_calculate_return_value�_side_effect_methodsr})r5r�rZfixedZreturn_calculatorrvZ
side_effectorrrr�_set_return_value�s

r�c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|��tt|�j||�|��dSr/)�_mock_set_magicsr�r�r8r�rrrr8�szMagicMixin.__init__cCs�ttB}|}t|dd�dk	rX|�|j�}t�}||}|D]}|t|�jkr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr:r$�intersectionr�rr1r]rrS�
MagicProxy)rAZorig_magicsZthese_magicsZ
remove_magicsr�r=rrrr��szMagicMixin._mock_set_magicsN)rMrPr�r8r�rrrrr��sr�c@seZdZdZddd�ZdS)rz-A version of `MagicMock` that isn't callable.FcCs|�||�|��dSr��r�r�r�rrrr��sz"NonCallableMagicMock.mock_add_specN)F�rMrPr�rNr�rrrrr�src@seZdZdd�ZdS)�AsyncMagicMixincOs&|��tt|�j||�|��dSr/)r�r�r�r8r�rrrr8�szAsyncMagicMixin.__init__N�rMrPr�r8rrrrr��sr�c@seZdZdZddd�ZdS)ra�
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    FcCs|�||�|��dSr�r�r�rrrr�szMagicMock.mock_add_specN)Fr�rrrrrs
rc@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rArr�rrrr8szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rSr�)rAr�r��mrrr�create_mocks�zMagicProxy.create_mockNcCs|��Sr/)r�)rAr)r=rrrr�(szMagicProxy.__get__)N)rMrPr�r8r�r�rrrrr�s	r�cs�eZdZed�Zed�Zed�Z�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ddd�Zdd�Z�fdd�Z�ZS)r�r�r�r�cs\t�j||�tjj|jd<d|jd<d|jd<t�|jd<ttd�}t	j
|_||jd<dS)Nr�rZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r�r+)�superr8r%r�r�r]rrrrr'ZCO_COROUTINE�co_flags)rArBrC�	code_mock�r�rrr81s


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dk	r�t|�rL|�nbt|�s�zt|�}Wnt	k
rxt
�YnXt|�r�|�n&t�|�r�|||�IdH}n
|||�}|t
k	r�|S|jt
k	r�|jS|jdk	r�t�|j�r�|j||�IdHS|j||�S|jS)NTrDr�)rFr�r�r�r�r}r3rXr��
StopIteration�StopAsyncIterationr%r&rr�rvr�)rArBrCrrGrfrrrrCAs6




z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected r5z to have been awaited.N�r�r�rr rrrr�is
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS)z@
        Assert that the mock was awaited exactly once.
        r�r�r5�$ to have been awaited once. Awaited � times.Nr�r rrrr�qs
z"AsyncMockMixin.assert_awaited_oncecsz�jdkr&�����}td|�d������fdd�}����f�}���j�}||krvt|t�rf|nd}t|��|�dS)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr!r"r#rrr$�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r�rrrr"r%)rArBrCr&r$r'r(rr#rr�zs
z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd�d|j�d�}t|��|j||�S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�r�r5r�r�)r�r�rr�r)rrrr��s
z'AsyncMockMixin.assert_awaited_once_withcsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)zU
        Assert the mock has ever been awaited with the specified arguments.
        csg|]}��|��qSrr*r+r�rrr��sz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>Nz%s await not found)rr�r"r%rrr9rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|��d�j���|�dSt|�}g}|D]2}z|�|�Wq�tk
r�|�|�Yq�Xq�|r�tdt	|�f�|�dS)
a�
        Assert the mock has been awaited with the specified calls.
        The :attr:`await_args_list` list is checked for the awaits.

        If `any_order` is False (the default) then the awaits must be
        sequential. There can be extra calls before or after the
        specified awaits.

        If `any_order` is True then the awaits can be in any order, but
        they must all appear in :attr:`await_args_list`.
        csg|]}��|��qSrr*r+r�rrr��sz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r-rrrrr.�s
z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s�r/z	
Actual: z%r not all found in await list)
r�rrr�r1rrYr3r<r�rZ)	rAr4r5r&r(Z
all_awaitsr6r7r8rr�rr��s>������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)z9
        Assert that the mock was never awaited.
        rr�r5z# to not have been awaited. Awaited r�Nr�r rrrr��s
z!AsyncMockMixin.assert_not_awaitedcs&t�j||�d|_d|_t�|_dS)z0
        See :func:`.Mock.reset_mock()`
        rN)r�rur�r�rrr�r@r�rrru�szAsyncMockMixin.reset_mock)F)rMrPr�r�r�r�r�r8rCr�r�r�r�r�r�r�ru�
__classcell__rrr�rr�,s(	
,	r�c@seZdZdZdS)r	aa
    Enhance :class:`Mock` with features allowing to mock
    an async function.

    The :class:`AsyncMock` object will behave so the object is
    recognized as an async function, and the result of a call is an awaitable:

    >>> mock = AsyncMock()
    >>> asyncio.iscoroutinefunction(mock)
    True
    >>> inspect.isawaitable(mock())
    True


    The result of ``mock()`` is an async function which will have the outcome
    of ``side_effect`` or ``return_value``:

    - if ``side_effect`` is a function, the async function will return the
      result of that function,
    - if ``side_effect`` is an exception, the async function will raise the
      exception,
    - if ``side_effect`` is an iterable, the async function will return the
      next value of the iterable, however, if the sequence of result is
      exhausted, ``StopIteration`` is raised immediately,
    - if ``side_effect`` is not defined, the async function will return the
      value defined by ``return_value``, hence, by default, the async function
      returns a new :class:`AsyncMock` object.

    If the outcome of ``side_effect`` or ``return_value`` is an async function,
    the mock async function obtained when the mock object is called will be this
    async function itself (and not an async function returning an async
    function).

    The test author can also specify a wrapped object with ``wraps``. In this
    case, the :class:`Mock` object behavior is the same as with an
    :class:`.Mock` object: the wrapped object may have methods
    defined as async function functions.

    Based on Martin Richard's asynctest project.
    NrHrrrrr	�sr	c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ANYz2A helper object that compares equal to everything.cCsdSr�r�rAr�rrrr�	sz_ANY.__eq__cCsdSr�rr�rrrr�	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�	sz
_ANY.__repr__N)rMrPr�rNr�r�r�rrrrr�	sr�cCs`d|}d}d�dd�|D��}d�dd�|��D��}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�reprr�rrrr�!	sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�r�rrrr�"	s)r�r�)rrBrCrZformatted_argsZargs_stringZ
kwargs_stringrrrr	s
�rc@s�eZdZdZd!dd�Zd"d	d
�Zdd�ZejZd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd �ZdS)#rFa�
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    rr�NFTcCs�d}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|||f�St�||||f�S)Nr�r�r�)r�r"r�rZr�)r�r�rr�rE�	from_kallrBrC�_len�first�secondrrrr�C	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rAr�rr�rEr�rrrr8c	sz_Call.__init__cCsh|tkrdSzt|�}Wntk
r.YdSXd}t|�dkrJ|\}}n
|\}}}t|dd�r|t|dd�r||j|jkr|dSd}|dkr�di}}n�|dkr�|\}}}n�|d	kr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r@|\}
}t|
t��r4|
}t|t��r(|i}}n
d|}}n
|
|}}ndS|�rX||k�rXdS||f||fkS)
NTFr�r�r�rrr�r�)rr�rr$r�r"rZr�)rAr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr�j	sR


�


z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�r�r�r��r�rFrrrrr9�	s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rAr�rrrrr��	s
z_Call.__getattr__cCs|tjkrt�t�||�Sr/)rZr]r:�__getattribute__)rAr�rrrr��	s
z_Call.__getattribute__cOs|�d�||�S)Nr��r�r@rrrr��	sz_Call.countcOs|�d�||�S)N�indexr�r@rrrr��	sz_Call.indexcCs(t|�dkr|\}}n
|\}}}||fS)Nr�)r�rrrr�_get_call_arguments�	s

z_Call._get_call_argumentscCs|��dS�Nr�r�r�rrrrB�	sz
_Call.argscCs|��dS)Nr�r�r�rrrrC�	sz_Call.kwargscCs||js&|jpd}|�d�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|�d�shd|}nd|}t|||�S)Nrr�zcall%sr�zcall.%s)r�r�rr�r)rArrBrCrrrr��	s





z_Call.__repr__cCs4g}|}|dk	r(|jr |�|�|j}qtt|��S)z�For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call.N)r�r�r�rrr�)rAZvalsrJrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rMrPr�rNr�r8r�rr�r9r�r�r�r�r�r�rBrCr�r�rrrrrF0	s*�
 �
7

rF)r�c	Kslt|�rt|�}t|t�}t|�}d|i}|r8d|i}n|dkrDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dkr�d}
|	f|||
|d	�|��}t|t��rt||�}|�rt|�nt||||�|dk	�r,|�s,||j|<|�rV|�sVd
|k�rVt||dd|d�|_t|�D�]}t|��rr�q^zt||�}
Wntk
�r�Y�q^YnXd|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<np|}t|t��r�|j}t|||�}||d
<t�|
��rt	}nt}|f||||d�|��}||j|<t|
||d�t|t��r^t|||��q^|S)aICreate a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.r�r�NTr�zJInstance can not be True when create_autospec is mocking an async functionrr�)r�r�r�rrvr�)rKrtr�r�)r�rr�r�)rJ)r[r1r"r.rerr'Zisdatadescriptor�RuntimeErrorr	rXrr`r�r6rir�rLr~rrvr�r�r$r:r�r5�
_must_skipr%r&rS)r�r�rKr�rtrC�is_typeZ
is_async_funcr}r|r�r5r�rer�r�rJZchild_klassrrrr�	s�




��


�

��
rcCsxt|t�s$|t|di�krdS|j}|jD]H}|j�|t�}|tkrFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    r]F)r"r1r$r�r\r]r^rrVrWr6)r�r�r�r>rfrrrr�w
s


r�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dSr/)r��idsr�r�rKr)rAr�r�r�rr�rKrrrr8�
sz_SpecState.__init__)FNNNFr�rrrrr��
s
�r�cCs"t|t�rt�|�St�|�SdSr/)r"�bytes�io�BytesIO�StringIO)�	read_datarrr�
_to_stream�
s

rr�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd	����fd
d�}tdkr�ddl}ttt|j���tt|j����a|dkr�t	d
t
d�}t	td����j_d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_��j_|�j_����fdd�}||_�|_|S)a�
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read`, `readline` and `readlines` of the
    file handle to return.  This is an empty string by default.
    Ncs$�jjdk	r�jjS�dj||�Sr�)�	readlinesrvra��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs$�jjdk	r�jjS�dj||�Sr�)�readrvrarrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s$��EdH�dj||�VqdSr�)�readlinera)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdk	r�jjVq�dD]
}|Vq dSr�)rrv)�linerrrr
�
sz$mock_open.<locals>._iter_side_effectcs �jjdk	r�jjSt�d�Sr�)rrvr�rrrr�_next_side_effect�
sz$mock_open.<locals>._next_side_effectr�open)rr�r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)rrr}rra)rrrrrr�
reset_data�
s

zmock_open.<locals>.reset_data)r�	file_spec�_iorYrr��
TextIOWrapper�unionrrrr~rv�writer
rrr}r�r�)r5rZ
_read_datar	rrrrr)r
rrrrrr
�
s8"

r
c@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
raW
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    cKs
tf|�Sr/)r)rArCrrrr�szPropertyMock._get_child_mockNcCs|�Sr/r)rAr)Zobj_typerrrr�szPropertyMock.__get__cCs||�dSr/r)rAr)r�rrrr�
szPropertyMock.__set__)N)rMrPr�rNr�r�r�rrrrr�
s
rc	Cs^d|_t|�D]J}zt||�}Wntk
r8YqYnXt|t�sFq|j|krt|�qdS)a�Disable the automatic generation of child mocks.

    Given an input Mock, seals it to ensure no further mocks will be generated
    when accessing an attribute that was not already defined.

    The operation recursively seals the mock passed in, meaning that
    the mock itself, any mocks generated by accessing one of its attributes,
    and all assigned mocks without a name or spec will be sealed.
    TN)r�r�r$r:r"rr�r)r5r�r�rrrrs



rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�z8
    Wraps an iterator in an asynchronous iterator.
    cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r])rArr�rrrr8+s
z_AsyncIterator.__init__cCs|Sr/rr�rrrr�1sz_AsyncIterator.__aiter__c�s*zt|j�WStk
r YnXt�dSr/)r�rr�r�r�rrrr�4s
z_AsyncIterator.__anext__N)rMrPr�rNr8r�r�rrrrr�'sr�)F)F)NFNNN)FFNN)Nr�)y�__all__�__version__r%rarr'r�rz�builtins�typesrrrZ
unittest.utilr�	functoolsrrr�rqr
r�r�r*r.r!r3r7r=rLrGrXr[r`rirdr�r�rr�r�rr�MISSINGr
ZDELETEDr�r�r�rYrrr�r�r�rr�r<rrMrOrPr�r�r�rr�r�r�r�ZmultipleZstopallr_Z
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr	r�r:Z_sync_async_magicsZ
_async_magicsr;r�rr�r�r�r�r�r�r�r�r�r�rr�rr�r�r	r�rrrZrFrrr�r�r1r�r6rrr
rrr�rrrr�<module>s~	



1�	h4<�
�
2�
Mw	���	�
���
	
	�	8+B
�
�
NPK�
�\��O�!�!main.cpython-38.opt-1.pycnu�[���U

e5d�-�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZdd�ZGdd	�d	ej
�Zd
d�Zddd
�ZdS)z
Main program for 2to3.
�)�with_statement�print_functionN�)�refactorc	Cs(|��}|��}tj||||dddd�S)z%Return a unified diff of two strings.z
(original)z(refactored)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filename�r�$/usr/lib64/python3.8/lib2to3/main.py�
diff_textss�rcs>eZdZdZd�fdd�	Zdd�Z�fdd�Zd	d
�Z�ZS)�StdoutRefactoringToola2
    A refactoring tool that can avoid overwriting its input files.
    Prints output to stdout.

    Output files can optionally be written to a different directory and or
    have an extra file suffix appended to their name for use in situations
    where you do not want to replace the input files.
    rc		sP||_||_|r&|�tj�s&|tj7}||_||_||_tt	|��
|||�dS)aF
        Args:
            fixers: A list of fixers to import.
            options: A dict with RefactoringTool configuration.
            explicit: A list of fixers to run even if they are explicit.
            nobackups: If true no backup '.bak' files will be created for those
                files that are being refactored.
            show_diffs: Should diffs of the refactoring be printed to stdout?
            input_base_dir: The base directory for all input files.  This class
                will strip this path prefix off of filenames before substituting
                it with output_dir.  Only meaningful if output_dir is supplied.
                All files processed by refactor() must start with this path.
            output_dir: If supplied, all converted files will be written into
                this directory tree instead of input_base_dir.
            append_suffix: If supplied, all files output by this tool will have
                this appended to their filename.  Useful for changing .py to
                .py3 for example by passing append_suffix='3'.
        N)�	nobackups�
show_diffs�endswith�os�sep�_input_base_dir�_output_dir�_append_suffix�superr�__init__)	�selfZfixers�options�explicitrr�input_base_dir�
output_dir�
append_suffix��	__class__rr
r$s
zStdoutRefactoringTool.__init__cOs*|j�|||f�|jj|f|�|�dS)N)�errors�append�logger�error)r�msg�args�kwargsrrr
�	log_errorAszStdoutRefactoringTool.log_errorc

sz|}|jrH|�|j�r6tj�|j|t|j�d��}ntd||jf��|jrX||j7}||kr�tj�	|�}tj�
|�s�|r�t�|�|�d||�|j
�s2|d}tj�|�r�zt�|�Wn.tk
r�}z|�d|�W5d}~XYnXzt�||�Wn2tk
�r0}z|�d||�W5d}~XYnXtt|�j}	|	||||�|j
�s`t�||�||k�rvt�||�dS)Nz5filename %s does not start with the input_base_dir %szWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)r�
startswithrr�path�join�len�
ValueErrorr�dirname�isdir�makedirs�log_messager�lexists�remove�OSError�renamerr�
write_file�shutilZcopymode)
rZnew_textrZold_text�encodingZ
orig_filenamerZbackup�err�writer rr
r7EsJ
���

� 
z StdoutRefactoringTool.write_filec	Cs�|r|�d|�n�|�d|�|jr�t|||�}zP|jdk	rl|j�"|D]}t|�qHtj��W5QRXn|D]}t|�qpWn$tk
r�t	d|f�YdSXdS)NzNo changes to %sz
Refactored %sz+couldn't encode %s's diff for your terminal)
r2rrZoutput_lock�print�sys�stdout�flush�UnicodeEncodeError�warn)r�old�newrZequalZ
diff_lines�linerrr
�print_outputls$

�z"StdoutRefactoringTool.print_output)rrr)	�__name__�
__module__�__qualname__�__doc__rr)r7rE�
__classcell__rrr r
rs
�'rcCstd|ftjd�dS)NzWARNING: %s��file)r<r=�stderr)r&rrr
rA�srAc
s�tjdd�}|jddddd�|jdd	d
gdd�|jd
dddddd�|jddd
gdd�|jddddd�|jddddd�|jddddd�|jd dd!d�|jd"d#dd$d�|jd%d&dd'd(d�|jd)d*dd+d,d-d.�|jd/d0dd1d�|jd2dd+d,d3d.�d'}i}|�|�\}}|j�r@d4|d5<|j�s:td6�d4|_|j�rZ|j�sZ|�	d7�|j
�rt|j�st|�	d8�|j�s�|j�r�td9�|j�s�|j�r�|�	d:�|j�r�t
d;�t���D]}t
|��q�|�s�d<S|�st
d=tjd>�t
d?tjd>�d@SdA|k�r(d4}|j�r(t
dBtjd>�d@S|j�r8d4|dC<|j�rFtjntj}tjdD|dE�t�dF�}tt����}	t�fdGdH�|jD��}
t�}|j�r�d'}|jD](}
|
dIk�r�d4}n|��dJ|
��q�|�r�|	�|�n|}n
|	�|�}|�|
�}t j!�"|�}|�r0|�#t j$��s0t j!�%|��s0t j!�&|�}|j�rT|�'t j$�}|�(dK|j|�t)t*|�|t*|�|j|j||j|j
dL�}|j+�s�|�r�|�,�nDz|�||j|j-|j.�Wn(tj/k
�r�t
dMtjd>�YdSX|�0�t1t2|j+��S)Nz�Main program.

    Args:
        fixer_pkg: the name of a package where the fixers are located.
        args: optional; a list of command line arguments. If omitted,
              sys.argv[1:] is used.

    Returns a suggested exit status (0, 1, 2).
    z2to3 [options] file|dir ...)Zusagez-dz--doctests_only�
store_truezFix up doctests only)�action�helpz-fz--fixr#z1Each FIX specifies a transformation; default: all)rO�defaultrPz-jz--processesZstorer�intzRun 2to3 concurrently)rOrQ�typerPz-xz--nofixz'Prevent a transformation from being runz-lz--list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-vz	--verbosezMore verbose loggingz
--no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz--nobackupsFz&Don't write backups for modified filesz-oz--output-dir�strrzXPut output files in this directory instead of overwriting the input files.  Requires -n.)rOrSrQrPz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z--add-suffixzuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.T�write_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.rKzUse --help to show usage.��-zCan't write to stdin.rz%(name)s: %(message)s)�format�levelzlib2to3.mainc3s|]}�d|VqdS)�.fix_Nr)�.0�fix��	fixer_pkgrr
�	<genexpr>�szmain.<locals>.<genexpr>�allrZz7Output in %r will mirror the input directory %r layout.)rrrz+Sorry, -j isn't supported on this platform.)3�optparseZOptionParserZ
add_option�
parse_argsrUr;rArrr%Z
add_suffixZno_diffsZ
list_fixesr<rZget_all_fix_namesr=rMr�verbose�logging�DEBUG�INFOZbasicConfigZ	getLogger�setZget_fixers_from_packageZnofixr\�add�union�
differencerr+�commonprefixrrr0r/�rstrip�infor�sortedr"�refactor_stdinZ
doctests_onlyZ	processesZMultiprocessingUnsupportedZ	summarizerR�bool)r^r'�parserro�flagsrZfixnamerYr$Zavail_fixesZunwanted_fixesrZall_presentr\Z	requestedZfixer_namesrZrtrr]r
�main�s�
����
�
�
��
���
��









���
��rs)N)rIZ
__future__rrr=rrrdr8rarrrZMultiprocessRefactoringToolrrArsrrrr
�<module>s	gPK�
�\O��EB1B1__init__.cpython-38.opt-1.pycnu�[���U

e5d	8�
@s�dZdZdddddddgZd	Zd
dlmZmZd
dlmZd
dl	Z	edddddddd�Z
dddddddddd�	dd�Zdddddddddd�	dd�Zeddd�Z
dd�Zddddddd�dd�Zddddddd�dd�ZdS)aJSON (JavaScript Object Notation) <http://json.org> is a subset of
JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
interchange format.

:mod:`json` exposes an API familiar to users of the standard library
:mod:`marshal` and :mod:`pickle` modules.  It is derived from a
version of the externally maintained simplejson library.

Encoding basic Python object hierarchies::

    >>> import json
    >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
    '["foo", {"bar": ["baz", null, 1.0, 2]}]'
    >>> print(json.dumps("\"foo\bar"))
    "\"foo\bar"
    >>> print(json.dumps('\u1234'))
    "\u1234"
    >>> print(json.dumps('\\'))
    "\\"
    >>> print(json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True))
    {"a": 0, "b": 0, "c": 0}
    >>> from io import StringIO
    >>> io = StringIO()
    >>> json.dump(['streaming API'], io)
    >>> io.getvalue()
    '["streaming API"]'

Compact encoding::

    >>> import json
    >>> mydict = {'4': 5, '6': 7}
    >>> json.dumps([1,2,3,mydict], separators=(',', ':'))
    '[1,2,3,{"4":5,"6":7}]'

Pretty printing::

    >>> import json
    >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))
    {
        "4": 5,
        "6": 7
    }

Decoding JSON::

    >>> import json
    >>> obj = ['foo', {'bar': ['baz', None, 1.0, 2]}]
    >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') == obj
    True
    >>> json.loads('"\\"foo\\bar"') == '"foo\x08ar'
    True
    >>> from io import StringIO
    >>> io = StringIO('["streaming API"]')
    >>> json.load(io)[0] == 'streaming API'
    True

Specializing JSON object decoding::

    >>> import json
    >>> def as_complex(dct):
    ...     if '__complex__' in dct:
    ...         return complex(dct['real'], dct['imag'])
    ...     return dct
    ...
    >>> json.loads('{"__complex__": true, "real": 1, "imag": 2}',
    ...     object_hook=as_complex)
    (1+2j)
    >>> from decimal import Decimal
    >>> json.loads('1.1', parse_float=Decimal) == Decimal('1.1')
    True

Specializing JSON object encoding::

    >>> import json
    >>> def encode_complex(obj):
    ...     if isinstance(obj, complex):
    ...         return [obj.real, obj.imag]
    ...     raise TypeError(f'Object of type {obj.__class__.__name__} '
    ...                     f'is not JSON serializable')
    ...
    >>> json.dumps(2 + 1j, default=encode_complex)
    '[2.0, 1.0]'
    >>> json.JSONEncoder(default=encode_complex).encode(2 + 1j)
    '[2.0, 1.0]'
    >>> ''.join(json.JSONEncoder(default=encode_complex).iterencode(2 + 1j))
    '[2.0, 1.0]'


Using json.tool from the shell to validate and pretty-print::

    $ echo '{"json":"obj"}' | python -m json.tool
    {
        "json": "obj"
    }
    $ echo '{ 1.2:3.4}' | python -m json.tool
    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
z2.0.9�dump�dumps�load�loads�JSONDecoder�JSONDecodeError�JSONEncoderzBob Ippolito <bob@redivi.com>�)rr)r�NFT)�skipkeys�ensure_ascii�check_circular�	allow_nan�indent�
separators�default)	r
rrr
�clsrrr�	sort_keysc	Ks�|sD|rD|rD|rD|dkrD|dkrD|dkrD|	dkrD|
sD|sDt�|�}n2|dkrPt}|f|||||||	|
d�|���|�}|D]}
|�|
�qzdS)a�Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
    ``.write()``-supporting file-like object).

    If ``skipkeys`` is true then ``dict`` keys that are not basic types
    (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
    instead of raising a ``TypeError``.

    If ``ensure_ascii`` is false, then the strings written to ``fp`` can
    contain non-ASCII characters if they appear in strings contained in
    ``obj``. Otherwise, all such characters are escaped in JSON strings.

    If ``check_circular`` is false, then the circular reference check
    for container types will be skipped and a circular reference will
    result in an ``OverflowError`` (or worse).

    If ``allow_nan`` is false, then it will be a ``ValueError`` to
    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
    in strict compliance of the JSON specification, instead of using the
    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).

    If ``indent`` is a non-negative integer, then JSON array elements and
    object members will be pretty-printed with that indent level. An indent
    level of 0 will only insert newlines. ``None`` is the most compact
    representation.

    If specified, ``separators`` should be an ``(item_separator, key_separator)``
    tuple.  The default is ``(', ', ': ')`` if *indent* is ``None`` and
    ``(',', ': ')`` otherwise.  To get the most compact JSON representation,
    you should specify ``(',', ':')`` to eliminate whitespace.

    ``default(obj)`` is a function that should return a serializable version
    of obj or raise TypeError. The default simply raises TypeError.

    If *sort_keys* is true (default: ``False``), then the output of
    dictionaries will be sorted by key.

    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
    ``.default()`` method to serialize additional types), specify it with
    the ``cls`` kwarg; otherwise ``JSONEncoder`` is used.

    N�r
rrr
rrrr)�_default_encoder�
iterencoder�write)�obj�fpr
rrr
rrrrr�kw�iterable�chunk�r�%/usr/lib64/python3.8/json/__init__.pyrxsD-�����������c	Kst|sB|rB|rB|rB|dkrB|dkrB|dkrB|dkrB|	sB|
sBt�|�S|dkrNt}|f||||||||	d�|
���|�S)auSerialize ``obj`` to a JSON formatted ``str``.

    If ``skipkeys`` is true then ``dict`` keys that are not basic types
    (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
    instead of raising a ``TypeError``.

    If ``ensure_ascii`` is false, then the return value can contain non-ASCII
    characters if they appear in strings contained in ``obj``. Otherwise, all
    such characters are escaped in JSON strings.

    If ``check_circular`` is false, then the circular reference check
    for container types will be skipped and a circular reference will
    result in an ``OverflowError`` (or worse).

    If ``allow_nan`` is false, then it will be a ``ValueError`` to
    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
    strict compliance of the JSON specification, instead of using the
    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).

    If ``indent`` is a non-negative integer, then JSON array elements and
    object members will be pretty-printed with that indent level. An indent
    level of 0 will only insert newlines. ``None`` is the most compact
    representation.

    If specified, ``separators`` should be an ``(item_separator, key_separator)``
    tuple.  The default is ``(', ', ': ')`` if *indent* is ``None`` and
    ``(',', ': ')`` otherwise.  To get the most compact JSON representation,
    you should specify ``(',', ':')`` to eliminate whitespace.

    ``default(obj)`` is a function that should return a serializable version
    of obj or raise TypeError. The default simply raises TypeError.

    If *sort_keys* is true (default: ``False``), then the output of
    dictionaries will be sorted by key.

    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
    ``.default()`` method to serialize additional types), specify it with
    the ``cls`` kwarg; otherwise ``JSONEncoder`` is used.

    Nr)r�encoder)rr
rrr
rrrrrrrrrr�sD,��������
���)�object_hook�object_pairs_hookcCs�|j}|tjtjf�rdS|tjtjf�r.dS|tj�r<dSt|�dkr�|ds`|dr\dSdS|ds�|d	sx|d
r|dSdSn$t|�d	kr�|ds�dS|ds�dSd
S)Nzutf-32zutf-16z	utf-8-sig�r	rz	utf-16-bez	utf-32-be��z	utf-16-lez	utf-32-lezutf-8)�
startswith�codecs�BOM_UTF32_BE�BOM_UTF32_LE�BOM_UTF16_BE�BOM_UTF16_LE�BOM_UTF8�len)�bZbstartswithrrr�detect_encoding�s$
r-�rr�parse_float�	parse_int�parse_constantr c	Ks"t|��f||||||d�|��S)a�Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
    a JSON document) to a Python object.

    ``object_hook`` is an optional function that will be called with the
    result of any object literal decode (a ``dict``). The return value of
    ``object_hook`` will be used instead of the ``dict``. This feature
    can be used to implement custom decoders (e.g. JSON-RPC class hinting).

    ``object_pairs_hook`` is an optional function that will be called with the
    result of any object literal decoded with an ordered list of pairs.  The
    return value of ``object_pairs_hook`` will be used instead of the ``dict``.
    This feature can be used to implement custom decoders.  If ``object_hook``
    is also defined, the ``object_pairs_hook`` takes priority.

    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
    kwarg; otherwise ``JSONDecoder`` is used.
    r.)r�read)rrrr/r0r1r rrrrrs
��c	Ks&t|t�r"|�d�rRtd|d��n0t|ttf�sBtd|jj����|�	t
|�d�}d|krxddl}|jdt
d	d
�|d=|dkr�|dkr�|dkr�|dkr�|dkr�|dkr�|s�t�	|�S|dkr�t}|dk	r�||d<|dk	r�||d<|dk	r�||d
<|dk	�r||d<|dk	�r||d<|f|��	|�S)a�Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
    containing a JSON document) to a Python object.

    ``object_hook`` is an optional function that will be called with the
    result of any object literal decode (a ``dict``). The return value of
    ``object_hook`` will be used instead of the ``dict``. This feature
    can be used to implement custom decoders (e.g. JSON-RPC class hinting).

    ``object_pairs_hook`` is an optional function that will be called with the
    result of any object literal decoded with an ordered list of pairs.  The
    return value of ``object_pairs_hook`` will be used instead of the ``dict``.
    This feature can be used to implement custom decoders.  If ``object_hook``
    is also defined, the ``object_pairs_hook`` takes priority.

    ``parse_float``, if specified, will be called with the string
    of every JSON float to be decoded. By default this is equivalent to
    float(num_str). This can be used to use another datatype or parser
    for JSON floats (e.g. decimal.Decimal).

    ``parse_int``, if specified, will be called with the string
    of every JSON int to be decoded. By default this is equivalent to
    int(num_str). This can be used to use another datatype or parser
    for JSON integers (e.g. float).

    ``parse_constant``, if specified, will be called with one of the
    following strings: -Infinity, Infinity, NaN.
    This can be used to raise an exception if invalid JSON numbers
    are encountered.

    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
    kwarg; otherwise ``JSONDecoder`` is used.

    The ``encoding`` argument is ignored and deprecated since Python 3.1.
    uz-Unexpected UTF-8 BOM (decode using utf-8-sig)r	z5the JSON object must be str, bytes or bytearray, not �
surrogatepass�encodingNzF'encoding' is ignored and deprecated. It will be removed in Python 3.9r")�
stacklevelrr r/r0r1)�
isinstance�strr$r�bytes�	bytearray�	TypeError�	__class__�__name__�decoder-�warnings�warn�DeprecationWarning�_default_decoderr)	�srrr/r0r1r rr>rrrr+sT$

�������


)�__doc__�__version__�__all__�
__author__�decoderrr�encoderrr%rrrrAr-rrrrrr�<module>sda��
�?�:��PK�
�\l�k�async_case.cpython-38.opt-1.pycnu�[���U

e5d��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd �fdd�	Z�ZS)!�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��+/usr/lib64/python3.8/unittest/async_case.pyr"sz IsolatedAsyncioTestCase.__init__c�sdSrr�rrrr�
asyncSetUp'sz"IsolatedAsyncioTestCase.asyncSetUpc�sdSrrrrrr�
asyncTearDown*sz%IsolatedAsyncioTestCase.asyncTearDowncOs|j|f|�|�dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup-s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp<sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod@sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownCsz%IsolatedAsyncioTestCase._callTearDowncOs|j|f|�|�dSrr)rZfunctionrrrrr�_callCleanupGsz$IsolatedAsyncioTestCase._callCleanupcOs0|||�}|j��}|j�||f�|j�|�Sr)r	�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrJs

z"IsolatedAsyncioTestCase._callAsynccOsB|||�}t�|�r:|j��}|j�||f�|j�|�S|SdSr)�inspectZisawaitabler	rr
r r!r"rrrrRs


z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s�t��|_}|�d�|��IdH}|��|dkr:dS|\}}z |IdH}|��s`|�|�Wqttfk
r|�Yqt	tj
fk
r�}z|��s�|�|�W5d}~XYqXqdSr)�asyncioZQueuer
Z
set_result�getZ	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr$ZqueueZqueryZ	awaitabler#Zexrrr�_asyncioLoopRunner\s 

z*IsolatedAsyncioTestCase._asyncioLoopRunnercCsJt��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)NT)
r&Znew_event_loop�set_event_loopZ	set_debugr	rZcreate_taskr,Z_asyncioCallsTaskr!)r�loopr$rrr�_setupAsyncioLoopos

z)IsolatedAsyncioTestCase._setupAsyncioLoopc	Cs�|j}d|_|j�d�|�|j���z�t�|�}|s@W�vdS|D]}|�	�qD|�tj
||dd���|D]0}|��r|qn|��dk	rn|�
d|��|d��qn|�|���W5t�d�|��XdS)NT)r.Zreturn_exceptionsz(unhandled exception during test shutdown)�message�	exception�task)r	r
r r!�joinr&r-�closeZ	all_tasksZcancelZgatherr(r1Zcall_exception_handlerZshutdown_asyncgens)rr.Z	to_cancelr2rrr�_tearDownAsyncioLoopys2

��

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs(|��zt��|�W�S|��XdSr)r/r5r�run)r�resultrrrr6�szIsolatedAsyncioTestCase.run)r)N)�__name__�
__module__�__qualname__rrrrrrrrrrr,r/r5r6�
__classcell__rrrrrs

"r)r&r%Zcaserrrrrr�<module>sPK�
�\P�<��signals.cpython-38.pycnu�[���U

e5dc	�@sbddlZddlZddlmZdZGdd�de�Ze��Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS�N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.8/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsRt�tj�}||k	r |�||�|jr2|�||�d|_t��D]}|��q@dS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r�rrrr�registerResult*sr cCstt�|d��Sr)�boolr�poprrrr�removeResult-sr#cCs.tdkr*t�tj�}t|�at�tjt�dSr)�_interrupt_handlerrrrr)rrrr�installHandler1sr%cs<�dk	r t���fdd��}|Stdk	r8t�tjtj�dS)Nc
s6t�tj�}t�z�||�W�St�tj|�XdSr)rrr�
removeHandler)�args�kwargs�initial��methodrr�inner;s
zremoveHandler.<locals>.inner)rr$rrr	)r+r,rr*rr&9sr&)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrr r#r$r%r&rrrr�<module>s PK�
�\�J���<�<util.cpython-38.opt-1.pycnu�[���U

e5d�Q�@sdZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZdd	�Zd
d�Zdd
�Zdd�Zdadd�Zdd�Zd*dd�Zdaaadd�Zdd�Zd+dd�Zdd�Zd,d d!�Zd"d#�Z d-d$d%�Z!d.d&d'�Z"Gd(d)�d)�Z#dS)/zudistutils.util

Miscellaneous utility functions -- anything that doesn't fit into
one of the other *util.py modules.
�N)�DistutilsPlatformError)�newer)�spawn)�log)�DistutilsByteCompileErrorc
Cs�tjdkrFdtj��krdSdtj��kr.dSdtj��kr@dStjSdtjkrZtjdStjd	ksnttd
�sttjSt��\}}}}}|���	dd�}|�	d
d�}|�	dd�}|dd�dkr�d||fS|dd�dk�r,|ddk�r�d}dt
|d�d|dd�f}ddd�}|d|tj7}n�|dd�dk�rLd |||fS|dd!�d"k�r�d"}t�
d#tj�}|�|�}|�r�|��}n>|dd!�d$k�r�ddl}ddl}	|�|	j��|||�\}}}d%|||fS)&a�Return a string that identifies the current platform.  This is used mainly to
    distinguish platform-specific build directories and platform-specific built
    distributions.  Typically includes the OS name and version and the
    architecture (as supplied by 'os.uname()'), although the exact information
    included depends on the OS; eg. on Linux, the kernel version isn't
    particularly important.

    Examples of returned values:
       linux-i586
       linux-alpha (?)
       solaris-2.6-sun4u

    Windows will return one of:
       win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
       win32 (all others - specifically, sys.platform is returned)

    For other non-POSIX platforms, currently just returns 'sys.platform'.

    �ntZamd64�	win-amd64z(arm)�	win-arm32z(arm64)z	win-arm64Z_PYTHON_HOST_PLATFORM�posix�uname�/�� �_�-N�Zlinuxz%s-%sZsunosr�5Zsolarisz%d.%s��Z32bitZ64bit)i���l����z.%sZaixz%s-%s.%s��cygwinz[\d.]+�darwinz%s-%s-%s)�os�name�sys�version�lower�platform�environ�hasattrr�replace�int�maxsize�re�compile�ASCII�match�group�_osx_supportZdistutils.sysconfigZget_platform_osxZ	sysconfigZget_config_vars)
ZosnameZhost�releaser�machineZbitnessZrel_re�mr(�	distutils�r-�&/usr/lib64/python3.8/distutils/util.py�get_host_platformsR


 


�
r/cCs8tjdkr.dddd�}|�tj�d��p,t�St�SdS)NrZwin32rr	)Zx86Zx64ZarmZVSCMD_ARG_TGT_ARCH)rr�getrr/)ZTARGET_TO_PLATr-r-r.�get_platformas
�r1cCsztjdkr|S|s|S|ddkr.td|��|ddkrFtd|��|�d�}d|krd|�d�qP|sntjStjj|�S)a�Return 'pathname' as a name that will work on the native filesystem,
    i.e. split it on '/' and put it back together again using the current
    directory separator.  Needed because filenames in the setup script are
    always supplied in Unix style, and have to be converted to the local
    convention before we can actually use them in the filesystem.  Raises
    ValueError on non-Unix-ish systems if 'pathname' either starts or
    ends with a slash.
    rrzpath '%s' cannot be absolute���zpath '%s' cannot end with '/'�.)r�sep�
ValueError�split�remove�curdir�path�join)�pathname�pathsr-r-r.�convert_pathls	

r=cCs�tjdkr<tj�|�s$tj�||�Stj�||dd��SnNtjdkr|tj�|�\}}|ddkrn|dd�}tj�||�Stdtj��dS)a	Return 'pathname' with 'new_root' prepended.  If 'pathname' is
    relative, this is equivalent to "os.path.join(new_root,pathname)".
    Otherwise, it requires making 'pathname' relative and then joining the
    two, which is tricky on DOS/Windows and Mac OS.
    r
�Nrr�\z!nothing known about platform '%s')rrr9�isabsr:�
splitdriver)Znew_rootr;Zdriver9r-r-r.�change_root�s

rBc	CsxtrdStjdkrZdtjkrZz$ddl}|�t���dtjd<Wnttfk
rXYnXdtjkrpt	�tjd<dadS)aLEnsure that 'os.environ' has all the environment variables we
    guarantee that users can use in config files, command-line options,
    etc.  Currently this includes:
      HOME - user's home directory (Unix only)
      PLAT - description of the current platform, including hardware
             and OS (see 'get_platform()')
    Nr
�HOMErrZPLATr>)
�_environ_checkedrrr�pwd�getpwuid�getuid�ImportError�KeyErrorr1)rEr-r-r.�
check_environ�s	
rJc
CsVt�|fdd�}zt�d||�WStk
rP}ztd|��W5d}~XYnXdS)a�Perform shell/Perl-style variable substitution on 'string'.  Every
    occurrence of '$' followed by a name is considered a variable, and
    variable is substituted by the value found in the 'local_vars'
    dictionary, or in 'os.environ' if it's not in 'local_vars'.
    'os.environ' is first checked/augmented to guarantee that it contains
    certain values: see 'check_environ()'.  Raise ValueError for any
    variables not found in either 'local_vars' or 'os.environ'.
    cSs,|�d�}||krt||�Stj|SdS)Nr>)r'�strrr)r&�
local_varsZvar_namer-r-r.�_subst�s
zsubst_vars.<locals>._substz\$([a-zA-Z_][a-zA-Z_0-9]*)zinvalid variable '$%s'N)rJr#�subrIr5)�srLrM�varr-r-r.�
subst_vars�s	rQ�error: cCs|t|�S�N)rK)�exc�prefixr-r-r.�grok_environment_error�srVcCs(t�dtj�at�d�at�d�adS)Nz
[^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")r#r$�string�
whitespace�
_wordchars_re�
_squote_re�
_dquote_rer-r-r-r.�_init_regex�s
r\cCs�tdkrt�|��}g}d}|�r�t�||�}|��}|t|�krZ|�|d|���q�||tjkr�|�|d|��||d��	�}d}n�||dkr�|d|�||dd�}|d}n�||dkr�t
�||�}n*||dkr�t�||�}ntd||��|dk�r t
d||��|��\}}|d|�||d|d�||d�}|��d	}|t|�kr|�|��q�q|S)
aSplit a string up according to Unix shell-like rules for quotes and
    backslashes.  In short: words are delimited by spaces, as long as those
    spaces are not escaped by a backslash, or inside a quoted string.
    Single and double quotes are equivalent, and the quote characters can
    be backslash-escaped.  The backslash is stripped from any two-character
    escape sequence, leaving only the escaped character.  The quote
    characters are stripped from any quoted string.  Returns a list of
    words.
    Nrr?r>�'�"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?)r)rYr\�stripr&�end�len�appendrWrX�lstriprZr[�RuntimeErrorr5�span)rOZwords�posr+r`Zbegr-r-r.�split_quoted�s@

,
rgcCsP|dkr6d|j|f}|dd�dkr6|dd�d}t�|�|sL||�dS)a�Perform some action that affects the outside world (eg.  by
    writing to the filesystem).  Such actions are special because they
    are disabled by the 'dry_run' flag.  This method takes care of all
    that bureaucracy for you; all you have to do is supply the
    function to call and an argument tuple for it (to embody the
    "external action" being performed), and an optional message to
    print.
    Nz%s%r���z,)r�))�__name__r�info)�func�args�msg�verbose�dry_runr-r-r.�executes	
rqcCs2|��}|dkrdS|dkr dStd|f��dS)z�Convert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.
    )�yZyes�t�trueZon�1r>)�nZno�fZfalseZoff�0rzinvalid truth value %rN)rr5)�valr-r-r.�	strtobool2srzr>c	CsTddl}tjrtd��|dkr*do(|dk}|�s@zddlm}	|	d�\}
}Wn.tk
rzddlm}d|d�}
}YnXt�	d|�|s�|
dk	r�t
�|
d	�}
n
t|d	�}
|
�B|
�
d
�|
�
d�tt|��d�|
�
d
|||||f�W5QRXtjg}|�|���|�|�t||d�tt
j|fd||d��nddlm}|D]�}|dd�dk�rj�qP|dk�r�|dk�r�dn|}tjj||d�}ntj�|�}|}|�r�|dt|��|k�r�td||f��|t|�d�}|�r�t
j�||�}t
j� |�}|�rP|�st!||��r>t�	d||�|�sL||||�nt�"d||��qPdS)a~Byte-compile a collection of Python source files to .pyc
    files in a __pycache__ subdirectory.  'py_files' is a list
    of files to compile; any files that don't end in ".py" are silently
    skipped.  'optimize' must be one of the following:
      0 - don't optimize
      1 - normal optimization (like "python -O")
      2 - extra optimization (like "python -OO")
    If 'force' is true, all files are recompiled regardless of
    timestamps.

    The source filename encoded in each bytecode file defaults to the
    filenames listed in 'py_files'; you can modify these with 'prefix' and
    'basedir'.  'prefix' is a string that will be stripped off of each
    source filename, and 'base_dir' is a directory name that will be
    prepended (after 'prefix' is stripped).  You can supply either or both
    (or neither) of 'prefix' and 'base_dir', as you wish.

    If 'dry_run' is true, doesn't actually do anything that would
    affect the filesystem.

    Byte-compilation is either done directly in this interpreter process
    with the standard py_compile module, or indirectly by writing a
    temporary script and executing it.  Normally, you should let
    'byte_compile()' figure out to use direct compilation or not (see
    the source for details).  The 'direct' flag is used by the script
    generated in indirect mode; unless you know what you're doing, leave
    it set to None.
    rNzbyte-compiling is disabled.F)�mkstemp�.py)�mktempz$writing byte-compilation script '%s'�wz2from distutils.util import byte_compile
files = [
z,
z]
z�
byte_compile(files, optimize=%r, force=%r,
             prefix=%r, base_dir=%r,
             verbose=%r, dry_run=0,
             direct=1)
)rpzremoving %s)r$���r
)�optimizationz1invalid prefix: filename %r doesn't start with %rzbyte-compiling %s to %sz%skipping byte-compilation of %s to %s)#�
subprocessr�dont_write_bytecoderZtempfiler{rHr}rrkr�fdopen�open�writer:�map�repr�
executable�extendZ"_optim_args_from_interpreter_flagsrbrrqr7�
py_compiler$�	importlib�util�cache_from_sourcerar5r9�basenamer�debug)Zpy_files�optimizeZforcerUZbase_dirrorpZdirectr�r{Z	script_fdZscript_namer}Zscript�cmdr$�file�opt�cfile�dfileZ
cfile_baser-r-r.�byte_compileBsx$

�
�

���r�cCs|�d�}d}|�|�S)z�Return a version of the string escaped for inclusion in an
    RFC-822 header, by ensuring there are 8 spaces space after each newline.
    �
z	
        )r6r:)�header�linesr4r-r-r.�
rfc822_escape�s
r�cCsV|sdSddlm}m}Gdd�d|�}|dkr8|d�}|||d�}|j|dd	�dS)
aInvoke 2to3 on a list of Python files.
    The files should all come from the build area, as the
    modification is done in-place. To reduce the build time,
    only files modified since the last invocation of this
    function should be passed in the files argument.Nr)�RefactoringTool�get_fixers_from_packagec@s$eZdZdd�Zdd�Zdd�ZdS)z*run_2to3.<locals>.DistutilsRefactoringToolc_stj|f|��dSrS)r�error)�selfrnrm�kwr-r-r.�	log_error�sz4run_2to3.<locals>.DistutilsRefactoringTool.log_errorcWstj|f|��dSrS)rrk�r�rnrmr-r-r.�log_message�sz6run_2to3.<locals>.DistutilsRefactoringTool.log_messagecWstj|f|��dSrS)rr�r�r-r-r.�	log_debug�sz4run_2to3.<locals>.DistutilsRefactoringTool.log_debugN)rj�
__module__�__qualname__r�r�r�r-r-r-r.�DistutilsRefactoringTool�sr�z
lib2to3.fixes)�optionsT)r�)Zlib2to3.refactorr�r�Zrefactor)�files�fixer_namesr��explicitr�r�r��rr-r-r.�run_2to3�s
r�c	Csddlm}ddlm}ddlm}|�}	t��}
t�|�z|	�	�W5t�|
�X|	j
|	jdd�<|r�|��D]}|�
�}|s�qr|	�|�qrg}|	jD]L}
tj�||
�}|tj�|��|tj�||
�|dd�}|dr�|�|�q�tdd	�|D�|||d
�|S)z�Recursively copy a directory, only copying new and changed files,
    running run_2to3 over all newly copied Python modules afterward.

    If you give a template string, it's parsed like a MANIFEST.in.
    r)�mkpath)�	copy_file)�FileListNr>)�updatecSsg|]}|���d�r|�qS)r|)r�endswith)�.0�fnr-r-r.�
<listcomp>sz$copydir_run_2to3.<locals>.<listcomp>)r�r�r�)Zdistutils.dir_utilr�Zdistutils.file_utilr�Zdistutils.filelistr�r�getcwd�chdir�findallZallfilesr��
splitlinesr_Zprocess_template_liner9r:�dirnamerbr�)�src�dest�templater�r�r�r�r�r�Zfilelistr8�lineZcopied�filenameZoutname�resr-r-r.�copydir_run_2to3�s:

�r�c@s$eZdZdZdZdZdZdd�ZdS)�	Mixin2to3z�Mixin class for commands that run 2to3.
    To configure 2to3, setup scripts may either change
    the class variables, or inherit from individual commands
    to override how 2to3 is invoked.NcCst||j|j|j�SrS)r�r�r�r�)r�r�r-r-r.r�-szMixin2to3.run_2to3)rjr�r��__doc__r�r�r�r�r-r-r-r.r�s
r�)rR)Nrr)rrNNr>rN)NNN)NNNN)$r�rr#�importlib.utilr�rWrZdistutils.errorsrZdistutils.dep_utilrZdistutils.spawnrr,rrr/r1r=rBrDrJrQrVrYrZr[r\rgrqrzr�r�r�r�r�r-r-r-r.�<module>sNO
=
�


�
!PK�
�\���58.8.mock.cpython-38.pycnu�[���U

e5d��@s�dZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZmZdd�ee�D�Zd	ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�dd�Zdd�Zdd�Zdd�Z dd �Z!d�d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%Gd)d*�d*e&�Z'Gd+d,�d,e&�Z(e(�Z)e)j*Z*e)j+Z,e)j-Z.d-d.d/d0d1d2d3d4hZ/d5d6�Z0Gd7d8�d8e1�Z2d9d:�Z3Gd;d<�d<e&�Z4Gd=d>�d>e&�Z5Gd?d@�d@e5�Z6dAdB�Z7GdCdD�dDe5�Z8GdEdF�dFe8e6�Z9dGdH�Z:dIdJ�Z;GdKdL�dLe&�Z<dMdN�Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@GdUdV�dVe&�ZAdWdX�ZBdYdZ�ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`�eI�K�D��ZLd^�Jdad`�eI�K�D��ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu�ZOdvd�d^�JeHeIeLeMg��K�D�ZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd�d�d�hZVd�d��d�d��d�d��d�d��d��ZWeXeXeXeXd�dddd�d�d	d�dd��
ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]eZe[e\e]d��Z^d�d��Z_Gd�d��d�e5�Z`Gd�d��d�e`e6�ZaGd�d��d�e`�ZbGd�d��d�e`e9�ZcGd�d��d�e5�ZdGd�d��d�e5�ZeGd�d��d�eeebe9�ZfGd�d��d�e&�Zgeg�Zhd�d��ZiGd�d��d�ej�Zkekdd��Zld�d�d��Zmd�d��ZnGd�d��d�e&�Zoepem�epehjq�fZrdasd�d��Ztd�d�d��ZuGd�d��d�e9�Zvd�d��ZwGd�d��d��ZxdS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�sealz1.0�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�%/usr/lib64/python3.8/unittest/mock.py�	<setcomp>(s
rTcCs>t|�rt|t�sdSt|d�r*t|d�}t�|�p<t�|�S)NF�__func__)	�_is_instance_mock�
isinstancer	�hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objrrr�
_is_async_obj0s


r*cCst|dd�rt�|�SdSdS)N�__code__F)r$r%r&��funcrrr�_is_async_func8s
r.cCstt|�t�S�N)�
issubclass�typerr(rrrr!?sr!cCst|t�pt|t�ot|t�Sr/)r"�
BaseExceptionr1r0r(rrr�
_is_exceptionEs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r"�
FunctionTypesr#r5r(rrr�
_extract_mockLsr7cCs�t|t�r|s|j}d}n,t|t�sFz
|j}Wntk
rDYdSX|rVt|d�}n|}z|t�|�fWSt	k
r�YdSXdS)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r"r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectUs

r=FcsNt|||���dkrdS�\}��fdd�}t||�|t|�_�t|�_dS)Ncs�j||�dSr/��bind��self�args�kwargs��sigrr�checksigwsz"_check_signature.<locals>.checksig)r=�_copy_func_detailsr1�_mock_check_sig�
__signature__)r-r5�	skipfirst�instancerFrrDr�_check_signaturers

rLc	Cs:dD]0}zt||t||��Wqtk
r2YqXqdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr$r:)r-�funcopy�	attributerrrrG~s
rGcCs@t|t�rdSt|tttf�r(t|j�St|dd�dk	r<dSdS)NTr9F)r"r1�staticmethod�classmethodr�	_callabler r$r(rrrrX�s

rXcCst|�ttfkSr/)r1�list�tupler(rrr�_is_list�sr[cCsFt|t�st|dd�dk	S|f|jD]}|j�d�dk	r&dSq&dS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.r9NTF)r"r1r$�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
r`cs�t|t�}t|||�}|dkr"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j||�dSr/r>�rBrCrDrrrF�sz _set_signature.<locals>.checksigrT)Z
_checksig_r5zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r"r1r=rGrM�isidentifier�exec�_setup_func)r5�originalrKrJ�resultr-rFr�context�srcrTrrDr�_set_signature�s$


�
rics���_�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}	��fdd�}
d�_d�_d�_t��_t��_t��_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Ncs�j||�Sr/)�assert_called_withra�r5rrrj�sz'_setup_func.<locals>.assert_called_withcs�j||�Sr/)�
assert_calledrarkrrrl�sz"_setup_func.<locals>.assert_calledcs�j||�Sr/)�assert_not_calledrarkrrrm�sz&_setup_func.<locals>.assert_not_calledcs�j||�Sr/)�assert_called_oncerarkrrrn�sz'_setup_func.<locals>.assert_called_oncecs�j||�Sr/)�assert_called_once_withrarkrrro�sz,_setup_func.<locals>.assert_called_once_withcs�j||�Sr/)�assert_has_callsrarkrrrp�sz%_setup_func.<locals>.assert_has_callscs�j||�Sr/)�assert_any_callrarkrrrq�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�k	r6|��dSr/)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer!)�ret�rTr5rrru�sz_setup_func.<locals>.reset_mockFr)r5�called�
call_count�	call_argsrr�call_args_listrsrtrv�side_effect�_mock_childrenrjrorprqrurlrmrnrI�_mock_delegate)rTr5rErjrlrmrnrorprqrurrxrrd�s8rdcsJtjj�_d�_d�_t��_�fdd�}dD]}t�|t||��q.dS)Nrcst�j|�||�Sr/)r$r5)�attrrBrCrkrr�wrapper�sz"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	r%�
coroutines�
_is_coroutine�await_count�
await_argsrr�await_args_listrSr)r5r�rUrrkr�_setup_async_mock�s
r�cCsd|dd�|kS)N�__%s__����r�rrrr�	_is_magicsr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_SentinelObjectz!A unique, named, sentinel object.cCs
||_dSr/r��rArrrrr8sz_SentinelObject.__init__cCs
d|jS�Nzsentinel.%sr��rArrr�__repr__sz_SentinelObject.__repr__cCs
d|jSr�r�r�rrr�
__reduce__sz_SentinelObject.__reduce__N)rMrP�__qualname__rNr8r�r�rrrrr�sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dSr/)�
_sentinelsr�rrrr8#sz_Sentinel.__init__cCs|dkrt�|j�|t|��S)N�	__bases__)r:r��
setdefaultr�r�rrr�__getattr__&sz_Sentinel.__getattr__cCsdS)Nrrr�rrrr�,sz_Sentinel.__reduce__N)rMrPr�rNr8r�r�rrrrr�!sr�rv�_mock_return_valuer}�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�Sr/)rr$)rAr�	_the_namerErrr�_getAs
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dSr/)rr]rS)rA�valuerr�rErrr�_setFsz"_delegating_property.<locals>._set)�_allowed_names�add�property)rr�r�r�rrr�_delegating_property>s

r�c@seZdZdd�Zdd�ZdS)rrcCslt|t�st�||�St|�}t|�}||kr2dStd||d�D]"}||||�}||krDdSqDdS)NFr�T)r"rY�__contains__�len�range)rAr�Z	len_valueZlen_self�iZsub_listrrrr�Ss
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrYr�rrrr�asz_CallList.__repr__N)rMrPr�r�r�rrrrrrQsrrcCs|t|�}t|�sdS|js4|js4|jdk	s4|jdk	r8dS|}|dk	rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentes*��r�c@seZdZdd�Zdd�ZdS)�	_MockItercCst|�|_dSr/)�iterr))rAr)rrrr8�sz_MockIter.__init__cCs
t|j�Sr/)�nextr)r�rrr�__next__�sz_MockIter.__next__N)rMrPr�r8r�rrrrr��sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdSr/rr@rrrr8�sz
Base.__init__)rMrPr�rr�r�r8rrrrr��sr�c@sdeZdZdZdd�ZdLdd�Zd	d
�ZdMdd�ZdNd
d�Zdd�Z	dd�Z
dZee	e
e�Z
edd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdOddd�d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dPd3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dQdCdD�Z)dEdF�Z*dGdH�Z+dRdJdK�Z,dS)Srz A non-callable version of `Mock`c	Os�|f}t|t�s^t�tj�}|j|f|�|�j}dd�|��D�}|r^t	||d�r^t
|f}t|j|d|j
i�}tt|��|�}|S)NcSsg|]}|�d�r|�qS��specr�r�argrrr�
<listcomp>�s
�z+NonCallableMock.__new__.<locals>.<listcomp>rrN)r0r	r'r;rr8Zbind_partialZ	arguments�keysr*�AsyncMockMixinr1rMrN�_safe_super�__new__)	�clsrB�kw�basesrEZ
bound_argsZspec_arg�newrKrrrr��s
�zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<d|
d<|dk	rJ|}d}|
dkrZ|dk	}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|��||||||�dS)Nr�r�r�r�F�_mock_sealedTr~�_mock_wrapsrZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrs�_mock_unsafe)r]�_mock_add_specrr�configure_mockr�rr8)rAr�rr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferCr]rrrr8�sD



�zNonCallableMock.__init__cCs0t|�}d|_d|_d|_d|_t|||�dS)z�
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one.Nr�)r7r�r�r�r�rS)rAr5rUZ
inner_mockrrr�attach_mock�szNonCallableMock.attach_mockcCs|�||�dS�z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r��rAr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_speccCs�d}d}g}t|�D] }t�t||d��r|�|�q|dk	r~t|�s~t|t�rV|}nt|�}t|||�}	|	ot|	d}t|�}|j	}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)
�dirr%r&r$�appendr[r"r1r=r])rAr�r�r�r�r�r�r�r��resr]rrrr��s,
�zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)N�()�r�r�)r�rrvr�_get_child_mock)rArwrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nr�)rrvr�r�)rAr�rrrZ__set_return_values

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jSr/)r�r1r�rrr�	__class__!s
zNonCallableMock.__class__ryrzr{r|rtcCsN|j}|dkr|jS|j}|dk	rJt|�sJt|t�sJt|�sJt|�}||_|Sr/)rr�r}�callabler"r�r3)rA�	delegatedZsfrrrZ__get_side_effect.s��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dSr/)�	_try_iterrr�r})rAr�r�rrrZ__set_side_effect9s
z!NonCallableMock.__set_side_effect)rvr}cCs�|dkrg}t|�|krdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D]"}t|t�sr|tkr�qr|�|�qr|j
}t|�r�||k	r�|�|�dS)z-Restore the mock object to its initial state.NFr)�idr�ryr{rzrrrtr|rsrr�r�r~�valuesr"�
_SpecState�_deletedrur!)rAZvisitedrvr}�childrwrrrruDs,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)aZSet attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)cSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>o�z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�N)�sorted�items�split�popr$rS)rArCr��valrB�finalr)r�rrrr�bs	�
zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)N>r�r�zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r�rrr�r�)r:r��_all_magicsr�r�rr~r^r�r�r$r�r"r�rr�r�rKr�r)rArrfrrrrr�xsF




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|dk	rZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddkr�|d7}||d<d�|�S)Nr�r�r�r5r�)r�z().r)r�r�r�rY�reversedr�r��join)rAZ
_name_listr�Zlast�dotZ_firstrrr�_extract_mock_name�s(


z"NonCallableMock._extract_mock_namecCs^|��}d}|dkrd|}d}|jdk	rDd}|jr8d}||jj}dt|�j||t|�fS)Nr�)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�r�rMr1r�)rArZname_stringZspec_stringrrrr��s 
�zNonCallableMock.__repr__cCsvtst�|�S|jpg}tt|��}t|j�}dd�|j�	�D�}dd�|D�}dd�|D�}t
t||||��S)z8Filter the output of `dir(mock)` to only useful members.cSsg|]\}}|tk	r|�qSr)r�)rZm_nameZm_valuerrrr��s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��s
cSs"g|]}|�d�rt|�r|�qSr)rr�rrrrr��s
�)r
�object�__dir__r�r�r1rYr]r~r�r��set)rAZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tkrt��||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n,|dkr�|�_dSt
�|||��r|�j|<�j�rFt�|��sF����d|��}td|����t��||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�Sr/r�rBr��rerArrr��r�z-NonCallableMock.__setattr__.<locals>.<lambda>r�r�zCannot set )r�r�__setattr__r�r�r]r:�_unsupported_magicsr�r!rSr1�_get_methodr�r~r�r�r#r�)rArr��msg�	mock_namerrrr�s<��

zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS|j�|t�}||jkr\tt|��	|�n|t
krlt|��|tk	r||j|=t
|j|<dSr/)r�r1r]�delattrr~r^�_missingr�r�__delattr__r�r:)rArr)rrrrs

zNonCallableMock.__delattr__cCs|jpd}t|||�Sr4)r��_format_call_signature�rArBrCrrrr�_format_mock_call_signatures
z+NonCallableMock._format_mock_call_signaturercCs.d}|�||�}|j}|j|�}||||fS)Nz.expected %s not found.
Expected: %s
Actual: %s)rr{)rArBrC�action�message�expected_stringr{Z
actual_stringrrr�_format_mock_failure_messages

z,NonCallableMock._format_mock_failure_messagecCsj|s
|jSd}|�dd��d�}|j}|D]:}|�|�}|dksJt|t�rPqfq*t|�}|j}|j}q*|S)aH
        * If call objects are asserted against a method/function like obj.meth1
        then there could be no name for the call object to lookup. Hence just
        return the spec_signature of the method/function being asserted against.
        * If the name is not empty then remove () and split by '.' to get
        list of names to iterate through the children until a potential
        match is found. A child mock is created only during attribute access
        so if we get a _SpecState then no attributes of the spec were accessed
        and can be safely exited.
        Nr�r�r�)r��replacer�r~r^r"r�r7)rArrE�namesZchildrenr�rrr�_get_call_signature_from_name's
z-NonCallableMock._get_call_signature_from_namec
Cs�t|t�r&t|�dkr&|�|d�}n|j}|dk	r�t|�dkrNd}|\}}n
|\}}}z||j||�fWStk
r�}z|�d�WY�Sd}~XYq�Xn|SdS)a
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        r�rNr�)r"rZr�rr�r?�	TypeError�with_traceback)rA�_callrErrBrCrrrr�
_call_matcherHs

"zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j|��f}t|��dS)z/assert that the mock was never called.
        rz9Expected '%s' to not have been called. Called %s times.%sr5N�rzr��_calls_repr�AssertionError�rAr
rrrrmbs
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.r5N)rzr�rr rrrrlls

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)z3assert that the mock was called only once.
        r�z:Expected '%s' to have been called once. Called %s times.%sr5Nrr rrrrnts
��z"NonCallableMock.assert_called_oncecs��jdkr.�����}d}d||f}t|�����fdd�}����f�}���j�}||kr~t|t�rn|nd}t|��|�dS)z�assert that the last call was made with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock.Nznot called.z0expected call not found.
Expected: %s
Actual: %scs�����}|Sr/�r�r
�rBrCrArr�_error_message�sz:NonCallableMock.assert_called_with.<locals>._error_message)r{rrrr"�	Exception)rArBrC�expected�actualZ
error_messager$�causerr#rrj~s
�z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j|��f}t|��|j||�S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�z3Expected '%s' to be called once. Called %s times.%sr5)rzr�rrrj�rArBrCr
rrrro�s
��z'NonCallableMock.assert_called_once_withc		s�fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|���jdd��d
����|�dSt|�}g}|D]2}z|�|�Wq�t	k
r�|�
|�Yq�Xq�|�rtd�jp�dt|�|f�|�dS)a�assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`.csg|]}��|��qSr�r�r�cr�rrr��sz4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r"r%rrrr�	<genexpr>�s
z3NonCallableMock.assert_has_calls.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s��
Expected: ZActual)�prefixr�z@%r does not contain all of %r in its call list, found %r insteadr5)
r�rrrt�formatrr�rstriprY�remover<r�r�rZ)	rA�calls�	any_orderr&r(Z	all_calls�problem�	not_found�kallrr�rrp�sH
��"������z NonCallableMock.assert_has_callscsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)z�assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one.csg|]}��|��qSrr*r+r�rrr��sz3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)rr|r"r%rr�rArBrCr&r'r(rrr�rrq�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdkr"tf|�St|�}t|t�rB|tkrBt}nbt|t�rp|tksd|j	rj||j	krjt}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t
}n
|jd}|jr�d|kr�d|dnd}|��|}t|��|f|�S)aPCreate the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass).r�r�r�rr�r�)r^r]r	r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr\r�r�r:)rAr�r��_type�klassrUrrrrr��s2


��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)z�Renders self.mock_calls as a string.

        Example: "
Calls: [call(1), call(2)]."

        If self.mock_calls is empty, an empty string is returned. The
        output will be truncated if very long.
        r��
z: r�)rtr)rAr0rrrrszNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)r?)-rMrPr�rNr�r8r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr�rvr�r�ryrzr{r|rtZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr}rur�r�r�r�rrrrrrrrmrlrnrjrorprqr�rrrrrr�sp�
-
	�

�

''
!


-'rcCsL|dkr|St|�r|St|�r$|Sz
t|�WStk
rF|YSXdSr/)r3rXr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r<Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nr�)r]r�r<r8r})rAr�r}rvrrr�r�r�r�r�rCrrrr8#s

��zCallableMixin.__init__cOsdSr/rr@rrrrH/szCallableMixin._mock_check_sigcOs$|j||�|j||�|j||�Sr/)rH�_increment_mock_call�
_mock_callr@rrrr94szCallableMixin.__call__cOs|j||�Sr/)�_execute_mock_callr@rrrrB<szCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdk	}|j}|j}|dk}|j	�td||f��|j
}|dk	r�|r�|j�t|||f��|jdk	}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr���twor�r�r�)ryrz�_Callr{r|r�r�r�r�rtr�rs)rArBrCrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrA?s4


z"CallableMixin._increment_mock_callcOs||j}|dk	rPt|�r|�n(t|�s:t|�}t|�rD|�n
|||�}|tk	rP|S|jtk	r`|jS|jdk	rv|j||�S|jSr/)r}r3rXr�rr�rvr�)rArBrC�effectrfrrrrCms 


z CallableMixin._execute_mock_call)
rMrPr�rr8rHr9rBrArCrrrrr<!s�
.r<c@seZdZdZdS)ra�	
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    N�rMrPr�rNrrrrr�srcCs8zt||�WStk
r2t|�t||�YSXdSr/)r$r:�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rMcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rIrM)�targetZ
componentsrLrJrKrrr�	_importer�s

rOc@szeZdZdZgZdd�Zdd�Zdd�Zdd	�Ze	j
d
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr<�getterrUr��new_callabler��createZ	has_localr��autospecrC�additional_patchers)
rArQrUr�r�rSr�rTrRrCrrrr8�s(��z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|���qSr)�copy)r�prrrr��sz_patch.copy.<locals>.<listcomp>)rPrQrUr�r�rSr�rTrRrC�attribute_namerU)rA�patcherrrrrV�s ��z_patch.copycCs2t|t�r|�|�St�|�r(|�|�S|�|�Sr/)r"r1�decorate_classr'r&�decorate_async_callable�decorate_callable�rAr-rrrr9�s




z_patch.__call__cCsNt|�D]@}|�tj�sqt||�}t|d�s0q|��}t||||��q|S�Nr9)r�rr�TEST_PREFIXr$r#rVrS)rAr>r��
attr_valuerYrrrrZs

z_patch.decorate_classc	csrg}t���\}|jD]8}|�|�}|jdk	r8|�|�q|jtkr|�|�q|t	|�7}||fVW5QRXdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextrX�updater�rr�rZ)rA�patchedrB�keywargs�
extra_args�
exit_stack�patchingr�rrr�decoration_helpers




z_patch.decoration_helpercs>t�d�r�j����St�����fdd����g�_�S)Nrcc
s4���||��\}}�||�W5QR�SQRXdSr/�rk�rBrgZnewargsZnewkeywargs�r-rfrArrrf(s�z)_patch.decorate_callable.<locals>.patched�r#rcr�rr]rrnrr\"s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrcc
�s:���||��"\}}�||�IdHW5QR�SQRXdSr/rlrmrnrrrf9s�z/_patch.decorate_async_callable.<locals>.patchedror]rrnrr[3s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
s�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)rQrUrr]r:�KeyErrorr$�	_builtinsr"rrS)rArNrre�localrrr�get_originalDs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|�	�\}}|t
k�r||dk�r|d}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s|dk	�r.|t
k�rtd��t|t��r.d}	|dk�rHt
|��rHt}
nt}
i}|dk	�r`|}
n^|dk	�st|dk	�r�|}|dk	�r�|}t|��r�d|k}
n
t|�}
t
|��r�t}
n
|
�r�t}
|dk	�r�||d	<|dk	�r�||d
<t|
t��rt|
t��r|j�r|j|d<|�|�|
f|�}|	�r�t|��r�|}|dk	�rB|}t|��sZt|��sZt}
|�d�|
f|dd
�|��|_nl|dk	�r�|t
k	�r�td��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#dk	�rpi}|jt
k�r:|||j#<|j$D](}|j!�%|�}|jt
k�r@|�|��q@|WS|WS|j&t'�(���s��YnXdS)zPerform the patch.FNzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer9r�r�rr�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating))r�r�r�rTrCrRrQrNrrsrr"r1r*r	rr[r�rr0rrUrer!r`r�rv�boolr�
temp_original�is_localrarb�_exit_stackrSrXrUrd�__exit__�sys�exc_info)rAr�r�r�rTrCrRrerrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrhrjr�rrr�	__enter__\s�
�








��




�
�


�

��


z_patch.__enter__cGs�|jr$|jtk	r$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdkrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)zUndo the patch.)rNrPrQ�__annotations__rR)rwrvrrSrNrUrrSr#rxry)rAr{rirrrry�s�z_patch.__exit__cCs|��}|j�|�|S)z-Activate a patch, returning any created mock.)r~�_active_patchesr�)rArfrrr�start�sz_patch.startcCs6z|j�|�Wntk
r&YdSX|�ddd�S)zStop an active patch.N)r�r3r<ryr�rrr�stop�s
z_patch.stop)rMrPr�rXr�r8rVr9rZra�contextmanagerrkr\r[rsr~ryr�r�rrrrrP�s 

rPc	sPz��dd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��Sr/�rOr�rNrrr�r�z_get_target.<locals>.<lambda>)�rsplitrr<)rNrUrQrr�r�_get_target
s�r�c

s>t��tkrt��d����fdd�}	t|	||||||||�	S)a
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    z3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�*r�z_patch_object.<locals>.<lambda>)r1�strrrP)
rNrUr�r�rSr�rTrRrCrQrr�r�
_patch_objects ��r�c
s�t��tkr�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)a�Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cst��Sr/r�rr�rrr�Hr�z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Jr�z=Must supply at least one keyword argument with patch.multiplerr�N)	r1r�r<rYr�rPrXrUr�)
rNr�rSr�rTrRrCrQr�rUr�rYZthis_patcherrr�r�_patch_multiple1sH���r�c

Ks$t|�\}}	t||	|||||||�	S)a7
    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with an
    `AsyncMock if the patched object is an async function or a
    `MagicMock` otherwise. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `AsyncMock` is
    used for async functions and `MagicMock` for the rest.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    `patch` takes arbitrary keyword arguments. These will be passed to
    the `Mock` (or `new_callable`) on construction.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    )r�rP)
rNr�r�rSr�rTrRrCrQrUrrrrbsF�rc@sReZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
eZe
ZdS)�_patch_dicta#
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    rFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�re�clear�	_original)rAr�r�r�rCrrrr8�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs&���z�||�W�S���XdSr/)r��
_unpatch_dictr��frArr�_inner�sz$_patch_dict.__call__.<locals>._inner)r"r1rZr)rAr�r�rr�rr9�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sr^)r�r$rrr_r#r�r�r�r�rS)rAr>r�r`Z	decoratorZ	decoratedrrrrZ�s
�z_patch_dict.decorate_classcCs|��|jS)zPatch the dict.)r�r�r�rrrr~�sz_patch_dict.__enter__cCs�|j}t|jt�rt|j�|_|j}|j}z|��}Wn.tk
rdi}|D]}||||<qNYnX||_|rxt	|�z|�
|�Wn*tk
r�|D]}||||<q�YnXdSr/)r�r"r�r�rOr�rVr:r��_clear_dictre)rAr�r�r�rer�rrrr��s&z_patch_dict._patch_dictcCsR|j}|j}t|�z|�|�Wn*tk
rL|D]}||||<q6YnXdSr/)r�r�r�rer:)rAr�rer�rrrr�sz_patch_dict._unpatch_dictcGs|��dS)zUnpatch the dict.F)r�)rArBrrrrysz_patch_dict.__exit__N)rF)
rMrPr�rNr8r9rZr~r�r�ryr�r�rrrrr��s
	
r�cCs>z|��Wn,tk
r8t|�}|D]
}||=q(YnXdSr/)r�r:rY)r�r�r�rrrr�&sr�cCsttj�D]}|��q
dS)z7Stop all active patches. LIFO to unroll nested patches.N)r�rPr�r�)rrrr�_patch_stopall/sr�Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr�r�nrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr�rrrr.Os�__get__�__set__�
__delete__�__reversed__�__missing__r��
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__Z
__setformat__r�r�__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|f|�|�Sr/r�rArBr�r,rr�method`sz_get_method.<locals>.method)rM)rr-r�rr,rr	^sr	cCsh|]}d|�qS)r�r)rr�rrrrfs�
__aenter__�	__aexit__�	__anext__�	__aiter__r�rr8r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
t�|�Sr/)r�__hash__r�rrrr�|r�r�cCs
t�|�Sr/)r�__str__r�rrrr�}r�cCs
t�|�Sr/)r�
__sizeof__r�rrrr�~r�cCs"t|�j�d|���dt|���S)N�/)r1rMr�r�r�rrrr�r�)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__ry�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStS�NT)�__eq__r�r�NotImplemented)�other�ret_valr�rrr��sz_get_eq.<locals>.__eq__r)rAr�rr�r�_get_eq�sr�cs�fdd�}|S)Ncs �jjtk	rtS�|krdStS�NF)�__ne__r�rr�)r�r�rrr��s
z_get_ne.<locals>.__ne__r)rAr�rr�r�_get_ne�sr�cs�fdd�}|S)Ncs �jj}|tkrtg�St|�Sr/)�__iter__r�rr��r�r�rrr��sz_get_iter.<locals>.__iter__r)rAr�rr�r�	_get_iter�sr�cs�fdd�}|S)Ncs(�jj}|tkrttg��Stt|��Sr/)r�r�r�_AsyncIteratorr�r�r�rrr��sz"_get_async_iter.<locals>.__aiter__r)rAr�rr�r�_get_async_iter�sr�)r�r�r�r�cCsbt�|t�}|tk	r||_dSt�|�}|dk	rB||�}||_dSt�|�}|dk	r^||�|_dSr/)�_return_valuesr^rrv�_calculate_return_value�_side_effect_methodsr})r5r�rZfixedZreturn_calculatorrvZ
side_effectorrrr�_set_return_value�s

r�c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|��tt|�j||�|��dSr/)�_mock_set_magicsr�r�r8r�rrrr8�szMagicMixin.__init__cCs�ttB}|}t|dd�dk	rX|�|j�}t�}||}|D]}|t|�jkr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr:r$�intersectionr�rr1r]rrS�
MagicProxy)rAZorig_magicsZthese_magicsZ
remove_magicsr�r=rrrr��szMagicMixin._mock_set_magicsN)rMrPr�r8r�rrrrr��sr�c@seZdZdZddd�ZdS)rz-A version of `MagicMock` that isn't callable.FcCs|�||�|��dSr��r�r�r�rrrr��sz"NonCallableMagicMock.mock_add_specN)F�rMrPr�rNr�rrrrr�src@seZdZdd�ZdS)�AsyncMagicMixincOs&|��tt|�j||�|��dSr/)r�r�r�r8r�rrrr8�szAsyncMagicMixin.__init__N�rMrPr�r8rrrrr��sr�c@seZdZdZddd�ZdS)ra�
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    FcCs|�||�|��dSr�r�r�rrrr�szMagicMock.mock_add_specN)Fr�rrrrrs
rc@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rArr�rrrr8szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rSr�)rAr�r��mrrr�create_mocks�zMagicProxy.create_mockNcCs|��Sr/)r�)rAr)r=rrrr�(szMagicProxy.__get__)N)rMrPr�r8r�r�rrrrr�s	r�cs�eZdZed�Zed�Zed�Z�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ddd�Zdd�Z�fdd�Z�ZS)r�r�r�r�cs\t�j||�tjj|jd<d|jd<d|jd<t�|jd<ttd�}t	j
|_||jd<dS)Nr�rZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r�r+)�superr8r%r�r�r]rrrrr'ZCO_COROUTINE�co_flags)rArBrC�	code_mock�r�rrr81s


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dk	r�t|�rL|�nbt|�s�zt|�}Wnt	k
rxt
�YnXt|�r�|�n&t�|�r�|||�IdH}n
|||�}|t
k	r�|S|jt
k	r�|jS|jdk	r�t�|j�r�|j||�IdHS|j||�S|jS)NTrDr�)rFr�r�r�r�r}r3rXr��
StopIteration�StopAsyncIterationr%r&rr�rvr�)rArBrCrrGrfrrrrCAs6




z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected r5z to have been awaited.N�r�r�rr rrrr�is
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS)z@
        Assert that the mock was awaited exactly once.
        r�r�r5�$ to have been awaited once. Awaited � times.Nr�r rrrr�qs
z"AsyncMockMixin.assert_awaited_oncecsz�jdkr&�����}td|�d������fdd�}����f�}���j�}||krvt|t�rf|nd}t|��|�dS)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr!r"r#rrr$�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r�rrrr"r%)rArBrCr&r$r'r(rr#rr�zs
z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd�d|j�d�}t|��|j||�S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�r�r5r�r�)r�r�rr�r)rrrr��s
z'AsyncMockMixin.assert_awaited_once_withcsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)zU
        Assert the mock has ever been awaited with the specified arguments.
        csg|]}��|��qSrr*r+r�rrr��sz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>Nz%s await not found)rr�r"r%rrr9rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|��d�j���|�dSt|�}g}|D]2}z|�|�Wq�tk
r�|�|�Yq�Xq�|r�tdt	|�f�|�dS)
a�
        Assert the mock has been awaited with the specified calls.
        The :attr:`await_args_list` list is checked for the awaits.

        If `any_order` is False (the default) then the awaits must be
        sequential. There can be extra calls before or after the
        specified awaits.

        If `any_order` is True then the awaits can be in any order, but
        they must all appear in :attr:`await_args_list`.
        csg|]}��|��qSrr*r+r�rrr��sz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r-rrrrr.�s
z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s�r/z	
Actual: z%r not all found in await list)
r�rrr�r1rrYr3r<r�rZ)	rAr4r5r&r(Z
all_awaitsr6r7r8rr�rr��s>������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)z9
        Assert that the mock was never awaited.
        rr�r5z# to not have been awaited. Awaited r�Nr�r rrrr��s
z!AsyncMockMixin.assert_not_awaitedcs&t�j||�d|_d|_t�|_dS)z0
        See :func:`.Mock.reset_mock()`
        rN)r�rur�r�rrr�r@r�rrru�szAsyncMockMixin.reset_mock)F)rMrPr�r�r�r�r�r8rCr�r�r�r�r�r�r�ru�
__classcell__rrr�rr�,s(	
,	r�c@seZdZdZdS)r	aa
    Enhance :class:`Mock` with features allowing to mock
    an async function.

    The :class:`AsyncMock` object will behave so the object is
    recognized as an async function, and the result of a call is an awaitable:

    >>> mock = AsyncMock()
    >>> asyncio.iscoroutinefunction(mock)
    True
    >>> inspect.isawaitable(mock())
    True


    The result of ``mock()`` is an async function which will have the outcome
    of ``side_effect`` or ``return_value``:

    - if ``side_effect`` is a function, the async function will return the
      result of that function,
    - if ``side_effect`` is an exception, the async function will raise the
      exception,
    - if ``side_effect`` is an iterable, the async function will return the
      next value of the iterable, however, if the sequence of result is
      exhausted, ``StopIteration`` is raised immediately,
    - if ``side_effect`` is not defined, the async function will return the
      value defined by ``return_value``, hence, by default, the async function
      returns a new :class:`AsyncMock` object.

    If the outcome of ``side_effect`` or ``return_value`` is an async function,
    the mock async function obtained when the mock object is called will be this
    async function itself (and not an async function returning an async
    function).

    The test author can also specify a wrapped object with ``wraps``. In this
    case, the :class:`Mock` object behavior is the same as with an
    :class:`.Mock` object: the wrapped object may have methods
    defined as async function functions.

    Based on Martin Richard's asynctest project.
    NrHrrrrr	�sr	c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ANYz2A helper object that compares equal to everything.cCsdSr�r�rAr�rrrr�	sz_ANY.__eq__cCsdSr�rr�rrrr�	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�	sz
_ANY.__repr__N)rMrPr�rNr�r�r�rrrrr�	sr�cCs`d|}d}d�dd�|D��}d�dd�|��D��}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�reprr�rrrr�!	sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�r�rrrr�"	s)r�r�)rrBrCrZformatted_argsZargs_stringZ
kwargs_stringrrrr	s
�rc@s�eZdZdZd!dd�Zd"d	d
�Zdd�ZejZd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd �ZdS)#rFa�
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    rr�NFTcCs�d}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|||f�St�||||f�S)Nr�r�r�)r�r"r�rZr�)r�r�rr�rE�	from_kallrBrC�_len�first�secondrrrr�C	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rAr�rr�rEr�rrrr8c	sz_Call.__init__cCsh|tkrdSzt|�}Wntk
r.YdSXd}t|�dkrJ|\}}n
|\}}}t|dd�r|t|dd�r||j|jkr|dSd}|dkr�di}}n�|dkr�|\}}}n�|d	kr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r@|\}
}t|
t��r4|
}t|t��r(|i}}n
d|}}n
|
|}}ndS|�rX||k�rXdS||f||fkS)
NTFr�r�r�rrr�r�)rr�rr$r�r"rZr�)rAr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr�j	sR


�


z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�r�r�r��r�rFrrrrr9�	s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rAr�rrrrr��	s
z_Call.__getattr__cCs|tjkrt�t�||�Sr/)rZr]r:�__getattribute__)rAr�rrrr��	s
z_Call.__getattribute__cOs|�d�||�S)Nr��r�r@rrrr��	sz_Call.countcOs|�d�||�S)N�indexr�r@rrrr��	sz_Call.indexcCs(t|�dkr|\}}n
|\}}}||fS)Nr�)r�rrrr�_get_call_arguments�	s

z_Call._get_call_argumentscCs|��dS�Nr�r�r�rrrrB�	sz
_Call.argscCs|��dS)Nr�r�r�rrrrC�	sz_Call.kwargscCs||js&|jpd}|�d�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|�d�shd|}nd|}t|||�S)Nrr�zcall%sr�zcall.%s)r�r�rr�r)rArrBrCrrrr��	s





z_Call.__repr__cCs4g}|}|dk	r(|jr |�|�|j}qtt|��S)z�For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call.N)r�r�r�rrr�)rAZvalsrJrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rMrPr�rNr�r8r�rr�r9r�r�r�r�r�r�rBrCr�r�rrrrrF0	s*�
 �
7

rF)r�c	Kslt|�rt|�}t|t�}t|�}d|i}|r8d|i}n|dkrDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dkr�d}
|	f|||
|d	�|��}t|t��rt||�}|�rt|�nt||||�|dk	�r,|�s,||j|<|�rV|�sVd
|k�rVt||dd|d�|_t|�D�]}t|��rr�q^zt||�}
Wntk
�r�Y�q^YnXd|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<np|}t|t��r�|j}t|||�}||d
<t�|
��rt	}nt}|f||||d�|��}||j|<t|
||d�t|t��r^t|||��q^|S)aICreate a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.r�r�NTr�zJInstance can not be True when create_autospec is mocking an async functionrr�)r�r�r�rrvr�)rKrtr�r�)r�rr�r�)rJ)r[r1r"r.rerr'Zisdatadescriptor�RuntimeErrorr	rXrr`r�r6rir�rLr~rrvr�r�r$r:r�r5�
_must_skipr%r&rS)r�r�rKr�rtrC�is_typeZ
is_async_funcr}r|r�r5r�rer�r�rJZchild_klassrrrr�	s�




��


�

��
rcCsxt|t�s$|t|di�krdS|j}|jD]H}|j�|t�}|tkrFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    r]F)r"r1r$r�r\r]r^rrVrWr6)r�r�r�r>rfrrrr�w
s


r�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dSr/)r��idsr�r�rKr)rAr�r�r�rr�rKrrrr8�
sz_SpecState.__init__)FNNNFr�rrrrr��
s
�r�cCs"t|t�rt�|�St�|�SdSr/)r"�bytes�io�BytesIO�StringIO)�	read_datarrr�
_to_stream�
s

rr�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd	����fd
d�}tdkr�ddl}ttt|j���tt|j����a|dkr�t	d
t
d�}t	td����j_d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_��j_|�j_����fdd�}||_�|_|S)a�
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read`, `readline` and `readlines` of the
    file handle to return.  This is an empty string by default.
    Ncs$�jjdk	r�jjS�dj||�Sr�)�	readlinesrvra��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs$�jjdk	r�jjS�dj||�Sr�)�readrvrarrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s$��EdH�dj||�VqdSr�)�readlinera)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdk	r�jjVq�dD]
}|Vq dSr�)rrv)�linerrrr
�
sz$mock_open.<locals>._iter_side_effectcs �jjdk	r�jjSt�d�Sr�)rrvr�rrrr�_next_side_effect�
sz$mock_open.<locals>._next_side_effectr�open)rr�r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)rrr}rra)rrrrrr�
reset_data�
s

zmock_open.<locals>.reset_data)r�	file_spec�_iorYrr��
TextIOWrapper�unionrrrr~rv�writer
rrr}r�r�)r5rZ
_read_datar	rrrrr)r
rrrrrr
�
s8"

r
c@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
raW
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    cKs
tf|�Sr/)r)rArCrrrr�szPropertyMock._get_child_mockNcCs|�Sr/r)rAr)Zobj_typerrrr�szPropertyMock.__get__cCs||�dSr/r)rAr)r�rrrr�
szPropertyMock.__set__)N)rMrPr�rNr�r�r�rrrrr�
s
rc	Cs^d|_t|�D]J}zt||�}Wntk
r8YqYnXt|t�sFq|j|krt|�qdS)a�Disable the automatic generation of child mocks.

    Given an input Mock, seals it to ensure no further mocks will be generated
    when accessing an attribute that was not already defined.

    The operation recursively seals the mock passed in, meaning that
    the mock itself, any mocks generated by accessing one of its attributes,
    and all assigned mocks without a name or spec will be sealed.
    TN)r�r�r$r:r"rr�r)r5r�r�rrrrs



rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�z8
    Wraps an iterator in an asynchronous iterator.
    cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r])rArr�rrrr8+s
z_AsyncIterator.__init__cCs|Sr/rr�rrrr�1sz_AsyncIterator.__aiter__c�s*zt|j�WStk
r YnXt�dSr/)r�rr�r�r�rrrr�4s
z_AsyncIterator.__anext__N)rMrPr�rNr8r�r�rrrrr�'sr�)F)F)NFNNN)FFNN)Nr�)y�__all__�__version__r%rarr'r�rz�builtins�typesrrrZ
unittest.utilr�	functoolsrrr�rqr
r�r�r*r.r!r3r7r=rLrGrXr[r`rirdr�r�rr�r�rr�MISSINGr
ZDELETEDr�r�r�rYrrr�r�r�rr�r<rrMrOrPr�r�r�rr�r�r�r�ZmultipleZstopallr_Z
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr	r�r:Z_sync_async_magicsZ
_async_magicsr;r�rr�r�r�r�r�r�r�r�r�r�rr�rr�r�r	r�rrrZrFrrr�r�r1r�r6rrr
rrr�rrrr�<module>s~	



1�	h4<�
�
2�
Mw	���	�
���
	
	�	8+B
�
�
NPK�
�\-:p_8_8loader.cpython-38.opt-1.pycnu�[���U

e5d�X�@sdZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZm
Z
dZe�dej�ZGdd	�d	ej�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Ze
jdfdd�Zde
jejfdd�Z de
jejfdd�Z!dS) zLoading unittests.�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|��|�dS�N)�
_exception�superr�__init__)�selfZmethod_name�	exception��	__class__��'/usr/lib64/python3.8/unittest/loader.pyrsz_FailedTest.__init__cs*|�jkrtt���|�S�fdd�}|S)Ncs
�j�dSr	)r
r�r
rr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamerr�__getattr__)r
�namerrrrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcCs"d|t��f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&s
�r"cCsdt��f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrr r!rrr�_make_failed_load_tests+s�r#cCst||�}||f�|fSr	)r)�
methodnamerr r!�testrrrr0s
rcCs<t�t|��dd��}||i}tdtjf|�}|||�f�S)NcSsdSr	rrrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r$rr r&�attrsZ	TestClassrrr�_make_skipped_test4s

r,cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r0rrr�_jython_aware_splitext<sr2cs�eZdZdZdZeej�ZdZ	e
jZdZ
�fdd�Zdd�Zdd�d	d
�Zd!dd�Zd"d
d�Zdd�Zd#dd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zd%dd �Z�ZS)&�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r%Ncs tt|���g|_t�|_dSr	)rr3r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|S)z;Return a suite of all test cases contained in testCaseClasszYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr �map)r
�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseTs
z TestLoader.loadTestsFromTestCase��patternc

Os:t|�dksd|kr,t�dt�|�dd�t|�dkrRt|�d}td�|���t|�dkrxt|�d}td�|���g}t|�D]4}t	||�}t
|t�r�t|t
j�r�|�|�|��q�t	|dd�}	|�|�}|	dk	�r6z|	|||�WStk
�r4}
z,t|j|
|j�\}}|j�|�|WY�Sd}
~
XYnX|S)	z>Return a suite of all test cases contained in the given modulerZuse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr9�format�sorted�dir�getattr�
isinstancer)r7rr*�appendr>r �	Exceptionr#rr4)
r
�moduler@�argsZkwsZ	complaint�testsr�objrA�e�
error_case�
error_messagerrr�loadTestsFromModulebs<�


�zTestLoader.loadTestsFromModulecCsX|�d�}d\}}|dkr�|dd�}|r�zd�|�}t|�}Wq�Wq&tk
r�|��}t||j�\}}|s�|j�|�|YSYq&Xq&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
k
�rN}zvt	|	dd�dk	�r|dk	�r|j�|�|WY�DSt|
||jdt�
�f�\}}|j�|�|WY�
SW5d}~XYq�Xq�t|	tj��rj|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|�|
g�Snt|	tj��r�|	St|	��rH|	�}t|tj��r|St|tj��r6|�|g�Std|	|f��ntd	|	��dS)
aSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        �.)NNNr�__path__zFailed to access attribute:
%s���z"calling %s returned %s, not a testz$don't know how to make test from: %s)�split�join�
__import__rrFr"r r4rLrJ�AttributeErrorrrrrK�types�
ModuleTyperUr)r7rr*r>�FunctionTyperr8�callabler9)r
rrN�partsrSrTZ
parts_copy�module_nameZnext_attributerQ�part�parentrR�instr%rrr�loadTestsFromName�s�	

����$

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        csg|]}��|���qSr)rf)�.0r�rNr
rr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrNZsuitesrrhr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)zLReturn a sorted sequence of method names found within testCaseClass
        csZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdkpXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rgr@�ZfullNamerr�	<genexpr>�szKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrJr`rr�testNamePatterns�any)�attrnameZtestFunc�r
r=rlr�shouldIncludeMethod�s
�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrI�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r=rtZtestFnNamesrrsrr:�s
zTestLoader.getTestCaseNames�test*.pycCsJd}|dkr|jdk	r|j}n|dkr.d}|}tj�|�}|tjkrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�npzt	|�Wnt
k
r�d}Y�nJXtj|}|�d�d}	ztj�tj�
|j��}Wn�tk
�r�z
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}|jD]P}|�s||�|��s|�qb|�|j�dtjj��d|_|�|j||dd���qbn*|jtjk�r�td�d�ntd	�|��d�YnX|�r|�s|�|	�|_tj�|�ntj�|�|�r*t
d
|��|�s@t|�||��}|� |�S)a%Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        FNTr�__init__.pyrV)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr/r0�abspath�sys�insert�isdir�isfilerZr[r�modulesrY�dirname�__file__r\�__spec__�loader�submodule_search_locationsrWrnr�replace�sep�extend�_find_tests�builtin_module_namesr9rG� _get_directory_containing_module�removervr )r
�	start_dirr@Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerPZ
the_moduleZtop_part�specr0rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr})
r�r�r/r0r�r��basenamer-rnr�)r
rbrN�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttj�|��}tj�||j�}|�tjjd�}|S)NrV)rr2r/r0�normpath�relpathr�r�)r
r0Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)r[r�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r0r�r@rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jkrD|�|||�\}}|dk	r<|V|sDdStt�|��}|D]t}tj�||�}	|�|	||�\}}|dk	r�|V|rV|�|	�}|j�|�z|�
|	||�EdHW5|j�	|�XqVdS)z/Used by discovery. Yields test suites it loads.rVN)r�r6�_find_test_pathrHr/�listdirr0rZ�add�discardr�)
r
r�r@r~rrPZshould_recurse�pathsr0r�rrrr��s6
��
zTestLoader._find_testsc
Csttj�|�}tj�|��rVt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnht	j
k
r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXtj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r@tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�ntj�|��rl|�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnjt	j
k
�r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXt|dd�}|j�|�z0|j||d�}|dk	�rP|dfW�S|d	fW�S|j�|�XndSdS)
z�Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        )NFFNr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r?r}rAT)r/r0r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr,r r"r4rLr�rJr2�realpathr-r�rrUr�rZr6r�r�)r
r�r@r~r�rrNrRrSrTZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgrArP�packagerrrr��s|

&
�
�
�
�
���
&
�
zTestLoader._find_test_path)N)N)r|N)F)F)rrr�__doc__ro�staticmethodr�
three_way_cmprxrprr8r rrr>rUrfrkr:r�r�r�r�r�r�r�rrrrrr3Bs&
(
N

n
"r3cCs&t�}||_||_||_|r"||_|Sr	)r3rxrorpr )�prefix�	sortUsingr rpr�rrr�_makeLoader�sr�cCst|||d��|�S)N)rp)r�r:)r=r�r�rprrrr:�sr:r%cCst|||��|�Sr	)r�r>)r=r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rU)rNr�r�r rrr�
findTestCasess�r�)NN)"r�r/�rer�rr]rzrCrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr,r2�objectr3ZdefaultTestLoaderr�r�r:r8r�r�rrrr�<module>s</
	�
�PK�
�\ߜ|}�}�mock.cpython-38.opt-2.pycnu�[���U

e5d��@s�dZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZmZdd�ee�D�Zd	ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�dd�Zdd�Zdd�Zdd�Z dd �Z!d�d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%Gd)d*�d*e&�Z'Gd+d,�d,e&�Z(e(�Z)e)j*Z*e)j+Z,e)j-Z.d-d.d/d0d1d2d3d4hZ/d5d6�Z0Gd7d8�d8e1�Z2d9d:�Z3Gd;d<�d<e&�Z4Gd=d>�d>e&�Z5Gd?d@�d@e5�Z6dAdB�Z7GdCdD�dDe5�Z8GdEdF�dFe8e6�Z9dGdH�Z:dIdJ�Z;GdKdL�dLe&�Z<dMdN�Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@GdUdV�dVe&�ZAdWdX�ZBdYdZ�ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`�eI�K�D��ZLd^�Jdad`�eI�K�D��ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu�ZOdvd�d^�JeHeIeLeMg��K�D�ZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd�d�d�hZVd�d��d�d��d�d��d�d��d��ZWeXeXeXeXd�dddd�d�d	d�dd��
ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]eZe[e\e]d��Z^d�d��Z_Gd�d��d�e5�Z`Gd�d��d�e`e6�ZaGd�d��d�e`�ZbGd�d��d�e`e9�ZcGd�d��d�e5�ZdGd�d��d�e5�ZeGd�d��d�eeebe9�ZfGd�d��d�e&�Zgeg�Zhd�d��ZiGd�d��d�ej�Zkekdd��Zld�d�d��Zmd�d��ZnGd�d��d�e&�Zoepem�epehjq�fZrdasd�d��Ztd�d�d��ZuGd�d��d�e9�Zvd�d��ZwGd�d��d��ZxdS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�sealz1.0�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�%/usr/lib64/python3.8/unittest/mock.py�	<setcomp>(s
rTcCs>t|�rt|t�sdSt|d�r*t|d�}t�|�p<t�|�S)NF�__func__)	�_is_instance_mock�
isinstancer	�hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objrrr�
_is_async_obj0s


r*cCst|dd�rt�|�SdSdS)N�__code__F)r$r%r&��funcrrr�_is_async_func8s
r.cCstt|�t�S�N)�
issubclass�typerr(rrrr!?sr!cCst|t�pt|t�ot|t�Sr/)r"�
BaseExceptionr1r0r(rrr�
_is_exceptionEs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r"�
FunctionTypesr#r5r(rrr�
_extract_mockLsr7cCs�t|t�r|s|j}d}n,t|t�sFz
|j}Wntk
rDYdSX|rVt|d�}n|}z|t�|�fWSt	k
r�YdSXdS�NT)
r"r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectUs

r>FcsNt|||���dkrdS�\}��fdd�}t||�|t|�_�t|�_dS)Ncs�j||�dSr/��bind��self�args�kwargs��sigrr�checksigwsz"_check_signature.<locals>.checksig)r>�_copy_func_detailsr1�_mock_check_sig�
__signature__)r-r5�	skipfirst�instancerGrrEr�_check_signaturers

rMc	Cs:dD]0}zt||t||��Wqtk
r2YqXqdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr$r;)r-�funcopy�	attributerrrrH~s
rHcCs@t|t�rdSt|tttf�r(t|j�St|dd�dk	r<dSdS)NTr:F)r"r1�staticmethod�classmethodr�	_callabler r$r(rrrrY�s

rYcCst|�ttfkSr/)r1�list�tupler(rrr�_is_list�sr\cCsFt|t�st|dd�dk	S|f|jD]}|j�d�dk	r&dSq&dS)Nr:TF)r"r1r$�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
racs�t|t�}t|||�}|dkr"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j||�dSr/r?�rCrDrErrrG�sz _set_signature.<locals>.checksigrU)Z
_checksig_r5zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r"r1r>rHrN�isidentifier�exec�_setup_func)r5�originalrLrK�resultr-rGr�context�srcrUrrEr�_set_signature�s$


�
rjcs���_�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}	��fdd�}
d�_d�_d�_t��_t��_t��_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Ncs�j||�Sr/)�assert_called_withrb�r5rrrk�sz'_setup_func.<locals>.assert_called_withcs�j||�Sr/)�
assert_calledrbrlrrrm�sz"_setup_func.<locals>.assert_calledcs�j||�Sr/)�assert_not_calledrbrlrrrn�sz&_setup_func.<locals>.assert_not_calledcs�j||�Sr/)�assert_called_oncerbrlrrro�sz'_setup_func.<locals>.assert_called_oncecs�j||�Sr/)�assert_called_once_withrbrlrrrp�sz,_setup_func.<locals>.assert_called_once_withcs�j||�Sr/)�assert_has_callsrbrlrrrq�sz%_setup_func.<locals>.assert_has_callscs�j||�Sr/)�assert_any_callrbrlrrrr�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�k	r6|��dSr/)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer!)�ret�rUr5rrrv�sz_setup_func.<locals>.reset_mockFr)r5�called�
call_count�	call_argsrs�call_args_listrtrurw�side_effect�_mock_childrenrkrprqrrrvrmrnrorJ�_mock_delegate)rUr5rFrkrmrnrorprqrrrvrryrre�s8recsJtjj�_d�_d�_t��_�fdd�}dD]}t�|t||��q.dS)Nrcst�j|�||�Sr/)r$r5)�attrrCrDrlrr�wrapper�sz"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	r%�
coroutines�
_is_coroutine�await_count�
await_argsrs�await_args_listrTr)r5r�rVrrlr�_setup_async_mock�s
r�cCsd|dd�|kS)N�__%s__����r�rrrr�	_is_magicsr�c@s$eZdZdd�Zdd�Zdd�ZdS)�_SentinelObjectcCs
||_dSr/r��rBrrrrr9sz_SentinelObject.__init__cCs
d|jS�Nzsentinel.%sr��rBrrr�__repr__sz_SentinelObject.__repr__cCs
d|jSr�r�r�rrr�
__reduce__sz_SentinelObject.__reduce__N)rNrQ�__qualname__r9r�r�rrrrr�sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�	_SentinelcCs
i|_dSr/)�
_sentinelsr�rrrr9#sz_Sentinel.__init__cCs|dkrt�|j�|t|��S)N�	__bases__)r;r��
setdefaultr�r�rrr�__getattr__&sz_Sentinel.__getattr__cCsdS)Nrrr�rrrr�,sz_Sentinel.__reduce__N)rNrQr�r9r�r�rrrrr�!sr�rw�_mock_return_valuer~�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�Sr/)r�r$)rBr�	_the_namerFrrr�_getAs
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dSr/)r�r^rT)rB�valuerr�rFrrr�_setFsz"_delegating_property.<locals>._set)�_allowed_names�add�property)rr�r�r�rrr�_delegating_property>s

r�c@seZdZdd�Zdd�ZdS)rscCslt|t�st�||�St|�}t|�}||kr2dStd||d�D]"}||||�}||krDdSqDdS)NFr�T)r"rZ�__contains__�len�range)rBr�Z	len_valueZlen_self�iZsub_listrrrr�Ss
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrZr�rrrr�asz_CallList.__repr__N)rNrQr�r�r�rrrrrsQsrscCs|t|�}t|�sdS|js4|js4|jdk	s4|jdk	r8dS|}|dk	rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentes*��r�c@seZdZdd�Zdd�ZdS)�	_MockItercCst|�|_dSr/)�iterr))rBr)rrrr9�sz_MockIter.__init__cCs
t|j�Sr/)�nextr)r�rrr�__next__�sz_MockIter.__next__N)rNrQr�r9r�rrrrr��sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdSr/rrArrrr9�sz
Base.__init__)rNrQr�rr�r�r9rrrrr��sr�c@s`eZdZdd�ZdKdd�Zdd	�ZdLd
d�ZdMdd
�Zdd�Zdd�Z	dZ
eee	e
�Zedd��Z
ed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdNddd�dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�ZdOd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&d@dA�Z'dPdBdC�Z(dDdE�Z)dFdG�Z*dQdIdJ�Z+dS)Rrc	Os�|f}t|t�s^t�tj�}|j|f|�|�j}dd�|��D�}|r^t	||d�r^t
|f}t|j|d|j
i�}tt|��|�}|S)NcSsg|]}|�d�r|�qS��specr�r�argrrr�
<listcomp>�s
�z+NonCallableMock.__new__.<locals>.<listcomp>rrO)r0r	r'r<rr9Zbind_partialZ	arguments�keysr*�AsyncMockMixinr1rNrO�_safe_super�__new__)	�clsrC�kw�basesrFZ
bound_argsZspec_arg�newrLrrrr��s
�zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<d|
d<|dk	rJ|}d}|
dkrZ|dk	}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|��||||||�dS)Nr�r�r�r�F�_mock_sealedTr�_mock_wrapsr�Z_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrt�_mock_unsafe)r^�_mock_add_specrs�configure_mockr�rr9)rBr�rr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferDr^rrrr9�sD



�zNonCallableMock.__init__cCs0t|�}d|_d|_d|_d|_t|||�dS)Nr�)r7r�r�r�r�rT)rBr5rVZ
inner_mockrrr�attach_mock�szNonCallableMock.attach_mockcCs|�||�dSr/)r��rBr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_speccCs�d}d}g}t|�D] }t�t||d��r|�|�q|dk	r~t|�s~t|t�rV|}nt|�}t|||�}	|	ot|	d}t|�}|j	}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)
�dirr%r&r$�appendr\r"r1r>r^)rBr�r�r�r�r�r�r�r��resr^rrrr��s,
�zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)N�()�r�r�)r�r�rwr�_get_child_mock)rBrxrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nr�)r�rwr�r�)rBr�rrrZ__set_return_values

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jSr/)r�r1r�rrr�	__class__!s
zNonCallableMock.__class__rzr{r|r}rucCsN|j}|dkr|jS|j}|dk	rJt|�sJt|t�sJt|�sJt|�}||_|Sr/)r�r�r~�callabler"r�r3)rB�	delegatedZsfrrrZ__get_side_effect.s��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dSr/)�	_try_iterr�r�r~)rBr�r�rrrZ__set_side_effect9s
z!NonCallableMock.__set_side_effect)rwr~cCs�|dkrg}t|�|krdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D]"}t|t�sr|tkr�qr|�|�qr|j
}t|�r�||k	r�|�|�dS)NFr)�idr�rzr|r{rsrur}rtrr�r�r�valuesr"�
_SpecState�_deletedrvr!)rBZvisitedrwr~�childrxrrrrvDs,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)NcSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>o�z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�)�sorted�items�split�popr$rT)rBrDr��valrC�finalr)r�rrrr�bs	�
zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)N>r�r�zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r�rrr�r�)r;r��_all_magicsr�r�rrr_r�r�r$r�r"r�rr�r�rLr�r)rBrrgrrrrr�xsF




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|dk	rZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddkr�|d7}||d<d�|�S)Nr�r�r�r5r�)r�z().r)r�r�r�rZ�reversedr�r��join)rBZ
_name_listr�Zlast�dotZ_firstrrr�_extract_mock_name�s(


z"NonCallableMock._extract_mock_namecCs^|��}d}|dkrd|}d}|jdk	rDd}|jr8d}||jj}dt|�j||t|�fS)Nr�)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�r�rNr1r�)rBrZname_stringZspec_stringrrrr��s 
�zNonCallableMock.__repr__cCsvtst�|�S|jpg}tt|��}t|j�}dd�|j�	�D�}dd�|D�}dd�|D�}t
t||||��S)NcSsg|]\}}|tk	r|�qSr)r�)rZm_nameZm_valuerrrr��s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��s
cSs"g|]}|�d�rt|�r|�qSr)rr�rrrrr��s
�)r
�object�__dir__r�r�r1rZr^rr�r��set)rBZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tkrt��||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n,|dkr�|�_dSt
�|||��r|�j|<�j�rFt�|��sF����d|��}td|����t��||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�Sr/r�rCr��rfrBrrr��r�z-NonCallableMock.__setattr__.<locals>.<lambda>r�r�zCannot set )r�r�__setattr__r�r�r^r;�_unsupported_magicsr�r!rTr1�_get_methodr�rr�r�r#r�)rBrr��msg�	mock_namerrrr�s<��

zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS|j�|t�}||jkr\tt|��	|�n|t
krlt|��|tk	r||j|=t
|j|<dSr/)r�r1r^�delattrrr_�_missingr�r�__delattr__r�r;)rBrr)rrrrs

zNonCallableMock.__delattr__cCs|jpd}t|||�Sr4)r��_format_call_signature�rBrCrDrrrr�_format_mock_call_signatures
z+NonCallableMock._format_mock_call_signaturercCs.d}|�||�}|j}|j|�}||||fS)Nz.expected %s not found.
Expected: %s
Actual: %s)rr|)rBrCrD�action�message�expected_stringr|Z
actual_stringrrr�_format_mock_failure_messages

z,NonCallableMock._format_mock_failure_messagecCsj|s
|jSd}|�dd��d�}|j}|D]:}|�|�}|dksJt|t�rPqfq*t|�}|j}|j}q*|S)Nr�r�r�)r��replacer�rr_r"r�r7)rBrrF�namesZchildrenr�rrr�_get_call_signature_from_name's
z-NonCallableMock._get_call_signature_from_namec
Cs�t|t�r&t|�dkr&|�|d�}n|j}|dk	r�t|�dkrNd}|\}}n
|\}}}z||j||�fWStk
r�}z|�d�WY�Sd}~XYq�Xn|SdS)Nr�rr�)r"r[r�rr�r@�	TypeError�with_traceback)rB�_callrFrrCrDrrrr�
_call_matcherHs

"zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j|��f}t|��dS)Nrz9Expected '%s' to not have been called. Called %s times.%sr5�r{r��_calls_repr�AssertionError�rBr
rrrrnbs
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)Nrz"Expected '%s' to have been called.r5)r{r�rr rrrrmls

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)Nr�z:Expected '%s' to have been called once. Called %s times.%sr5rr rrrrots
��z"NonCallableMock.assert_called_oncecs��jdkr.�����}d}d||f}t|�����fdd�}����f�}���j�}||kr~t|t�rn|nd}t|��|�dS)Nznot called.z0expected call not found.
Expected: %s
Actual: %scs�����}|Sr/�r�r
�rCrDrBrr�_error_message�sz:NonCallableMock.assert_called_with.<locals>._error_message)r|rrrr"�	Exception)rBrCrD�expected�actualZ
error_messager$�causerr#rrk~s
�z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j|��f}t|��|j||�S)Nr�z3Expected '%s' to be called once. Called %s times.%sr5)r{r�rrrk�rBrCrDr
rrrrp�s
��z'NonCallableMock.assert_called_once_withc		s�fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�dd�|D��}t|�d	t|���jd
d��d����|�dSt|�}g}|D]2}z|�|�Wq�t	k
r�|�
|�Yq�Xq�|�rtd
�jp�dt|�|f�|�dS)Ncsg|]}��|��qSr�r�r�cr�rrr��sz4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r"r%rrrr�	<genexpr>�s
z3NonCallableMock.assert_has_calls.<locals>.<genexpr>c3s|]}��|�VqdSr/r*r+r�rrr.�szCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s��
Expected: ZActual)�prefixr�z@%r does not contain all of %r in its call list, found %r insteadr5)
r�rsru�formatrr�rstriprZ�remover=r�r�r[)	rB�calls�	any_orderr&r(Z	all_calls�problem�	not_found�kallrr�rrq�sH
��"������z NonCallableMock.assert_has_callscsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz3NonCallableMock.assert_any_call.<locals>.<listcomp>z%s call not found)rr}r"r%rr�rBrCrDr&r'r(rrr�rrr�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdkr"tf|�St|�}t|t�rB|tkrBt}nbt|t�rp|tksd|j	rj||j	krjt}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t
}n
|jd}|jr�d|kr�d|dnd}|��|}t|��|f|�S)Nr�r�r�rr�r�)r_r^r	r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr]r�r�r;)rBr�r��_type�klassrVrrrrr��s2


��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)Nr��
z: r�)rur)rBr0rrrrszNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)r?),rNrQr�r�r9r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr�rwr�r�rzr{r|r}ruZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr~rvr�r�r�r�rrrrrrrrnrmrorkrprqrrr�rrrrrr�sn�
-
	�

�

''
!


-'rcCsL|dkr|St|�r|St|�r$|Sz
t|�WStk
rF|YSXdSr/)r3rYr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r<Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nr�)r^r�r<r9r~)rBr�r~rwrrr�r�r�r�r�rDrrrr9#s

��zCallableMixin.__init__cOsdSr/rrArrrrI/szCallableMixin._mock_check_sigcOs$|j||�|j||�|j||�Sr/)rI�_increment_mock_call�
_mock_callrArrrr:4szCallableMixin.__call__cOs|j||�Sr/)�_execute_mock_callrArrrrB<szCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdk	}|j}|j}|dk}|j	�td||f��|j
}|dk	r�|r�|j�t|||f��|jdk	}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr���twor�r�r�)rzr{�_Callr|r}r�r�r�r�rur�rt)rBrCrDrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrA?s4


z"CallableMixin._increment_mock_callcOs||j}|dk	rPt|�r|�n(t|�s:t|�}t|�rD|�n
|||�}|tk	rP|S|jtk	r`|jS|jdk	rv|j||�S|jSr/)r~r3rYr�rr�rwr�)rBrCrD�effectrgrrrrCms 


z CallableMixin._execute_mock_call)
rNrQr�rr9rIr:rBrArCrrrrr<!s�
.r<c@seZdZdS)rN�rNrQr�rrrrr�srcCs8zt||�WStk
r2t|�t||�YSXdSr/)r$r;�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rMcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rIrM)�targetZ
componentsrLrJrKrrr�	_importer�s

rOc@szeZdZdZgZdd�Zdd�Zdd�Zdd	�Ze	j
d
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr=�getterrVr��new_callabler��createZ	has_localr��autospecrD�additional_patchers)
rBrQrVr�r�rSr�rTrRrDrrrr9�s(��z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|���qSr)�copy)r�prrrr��sz_patch.copy.<locals>.<listcomp>)rPrQrVr�r�rSr�rTrRrD�attribute_namerU)rB�patcherrrrrV�s ��z_patch.copycCs2t|t�r|�|�St�|�r(|�|�S|�|�Sr/)r"r1�decorate_classr'r&�decorate_async_callable�decorate_callable�rBr-rrrr:�s




z_patch.__call__cCsNt|�D]@}|�tj�sqt||�}t|d�s0q|��}t||||��q|S�Nr:)r�rr�TEST_PREFIXr$r#rVrT)rBr>r��
attr_valuerYrrrrZs

z_patch.decorate_classc	csrg}t���\}|jD]8}|�|�}|jdk	r8|�|�q|jtkr|�|�q|t	|�7}||fVW5QRXdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextrX�updater�rr�r[)rB�patchedrC�keywargs�
extra_args�
exit_stack�patchingr�rrr�decoration_helpers




z_patch.decoration_helpercs>t�d�r�j����St�����fdd����g�_�S)Nrcc
s4���||��\}}�||�W5QR�SQRXdSr/�rk�rCrgZnewargsZnewkeywargs�r-rfrBrrrf(s�z)_patch.decorate_callable.<locals>.patched�r#rcr�rr]rrnrr\"s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrcc
�s:���||��"\}}�||�IdHW5QR�SQRXdSr/rlrmrnrrrf9s�z/_patch.decorate_async_callable.<locals>.patchedror]rrnrr[3s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
s�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)rQrVrr^r;�KeyErrorr$�	_builtinsr"rrS)rBrNrrf�localrrr�get_originalDs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|�	�\}}|t
k�r||dk�r|d}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s|dk	�r.|t
k�rtd��t|t��r.d}	|dk�rHt
|��rHt}
nt}
i}|dk	�r`|}
n^|dk	�st|dk	�r�|}|dk	�r�|}t|��r�d|k}
n
t|�}
t
|��r�t}
n
|
�r�t}
|dk	�r�||d<|dk	�r�||d	<t|
t��rt|
t��r|j�r|j|d
<|�|�|
f|�}|	�r�t|��r�|}|dk	�rB|}t|��sZt|��sZt}
|�d
�|
f|dd�|��|_nl|dk	�r�|t
k	�r�td
��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#dk	�rpi}|jt
k�r:|||j#<|j$D](}|j!�%|�}|jt
k�r@|�|��q@|WS|WS|j&t'�(���s��YnXdS)NFzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer:r�r�rr�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating))r�r�r�rTrDrRrQrNrrsrr"r1r*r	rr\r�rr0rrVrer!rar�rw�boolr�
temp_original�is_localrarb�_exit_stackrTrXrUrd�__exit__�sys�exc_info)rBr�r�r�rTrDrRrfrrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrhrjr�rrr�	__enter__\s�
�








��




�
�


�

��


z_patch.__enter__cGs�|jr$|jtk	r$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdkrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)N)rOrQrR�__annotations__rS)rwrvrrTrNrVrrSr#rxry)rBr{rirrrry�s�z_patch.__exit__cCs|��}|j�|�|Sr/)r~�_active_patchesr�)rBrgrrr�start�sz_patch.startcCs6z|j�|�Wntk
r&YdSX|�ddd�Sr/)r�r3r=ryr�rrr�stop�s
z_patch.stop)rNrQr�rXr�r9rVr:rZra�contextmanagerrkr\r[rsr~ryr�r�rrrrrP�s 

rPc	sPz��dd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��Sr/�rOr�rNrrr�r�z_get_target.<locals>.<lambda>)�rsplitrr=)rNrVrQrr�r�_get_target
s�r�c

s>t��tkrt��d����fdd�}	t|	||||||||�	S)Nz3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�*r�z_patch_object.<locals>.<lambda>)r1�strrrP)
rNrVr�r�rSr�rTrRrDrQrr�r�
_patch_objects ��r�c
s�t��tkr�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)Ncst��Sr/r�rr�rrr�Hr�z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Jr�z=Must supply at least one keyword argument with patch.multiplerr�)	r1r�r=rZr�rPrXrUr�)
rNr�rSr�rTrRrDrQr�rVr�rYZthis_patcherrr�r�_patch_multiple1sH���r�c

Ks$t|�\}}	t||	|||||||�	Sr/)r�rP)
rNr�r�rSr�rTrRrDrQrVrrrrbsF�rc@sNeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	eZ
e	ZdS)�_patch_dictrFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�re�clear�	_original)rBr�r�r�rDrrrr9�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs&���z�||�W�S���XdSr/)r��
_unpatch_dictr��frBrr�_inner�sz$_patch_dict.__call__.<locals>._inner)r"r1rZr)rBr�r�rr�rr:�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sr^)r�r$rrr_r#r�r�r�r�rT)rBr>r�r`Z	decoratorZ	decoratedrrrrZ�s
�z_patch_dict.decorate_classcCs|��|jSr/)r�r�r�rrrr~�sz_patch_dict.__enter__cCs�|j}t|jt�rt|j�|_|j}|j}z|��}Wn.tk
rdi}|D]}||||<qNYnX||_|rxt	|�z|�
|�Wn*tk
r�|D]}||||<q�YnXdSr/)r�r"r�r�rOr�rVr;r��_clear_dictre)rBr�r�r�rfr�rrrr��s&z_patch_dict._patch_dictcCsR|j}|j}t|�z|�|�Wn*tk
rL|D]}||||<q6YnXdSr/)r�r�r�rer;)rBr�rfr�rrrr�sz_patch_dict._unpatch_dictcGs|��dS�NF)r�)rBrCrrrrysz_patch_dict.__exit__N)rF)rNrQr�r9r:rZr~r�r�ryr�r�rrrrr��s
	
r�cCs>z|��Wn,tk
r8t|�}|D]
}||=q(YnXdSr/)r�r;rZ)r�r�r�rrrr�&sr�cCsttj�D]}|��q
dSr/)r�rPr�r�)rrrr�_patch_stopall/sr�Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr�r�nrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr�rrrr.Os�__get__�__set__�
__delete__�__reversed__�__missing__r��
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__Z
__setformat__r�r�__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)Ncs�|f|�|�Sr/r�rBrCr�r,rr�method`sz_get_method.<locals>.method)rN)rr-r�rr,rr	^sr	cCsh|]}d|�qS)r�r)rr�rrrrfs�
__aenter__�	__aexit__�	__anext__�	__aiter__r�rr9r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
t�|�Sr/)r�__hash__r�rrrr�|r�r�cCs
t�|�Sr/)r�__str__r�rrrr�}r�cCs
t�|�Sr/)r�
__sizeof__r�rrrr�~r�cCs"t|�j�d|���dt|���S)N�/)r1rNr�r�r�rrrr�r�)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__ry�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStSr8)�__eq__r�r�NotImplemented)�other�ret_valr�rrr��sz_get_eq.<locals>.__eq__r)rBr�rr�r�_get_eq�sr�cs�fdd�}|S)Ncs �jjtk	rtS�|krdStSr�)�__ne__r�rr�)r�r�rrr��s
z_get_ne.<locals>.__ne__r)rBr�rr�r�_get_ne�sr�cs�fdd�}|S)Ncs �jj}|tkrtg�St|�Sr/)�__iter__r�rr��r�r�rrr��sz_get_iter.<locals>.__iter__r)rBr�rr�r�	_get_iter�sr�cs�fdd�}|S)Ncs(�jj}|tkrttg��Stt|��Sr/)r�r�r�_AsyncIteratorr�r�r�rrr��sz"_get_async_iter.<locals>.__aiter__r)rBr�rr�r�_get_async_iter�sr�)r�r�r�r�cCsbt�|t�}|tk	r||_dSt�|�}|dk	rB||�}||_dSt�|�}|dk	r^||�|_dSr/)�_return_valuesr_rrw�_calculate_return_value�_side_effect_methodsr~)r5r�rZfixedZreturn_calculatorrwZ
side_effectorrrr�_set_return_value�s

r�c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|��tt|�j||�|��dSr/)�_mock_set_magicsr�r�r9r�rrrr9�szMagicMixin.__init__cCs�ttB}|}t|dd�dk	rX|�|j�}t�}||}|D]}|t|�jkr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr:r$�intersectionr�rr1r^rrT�
MagicProxy)rBZorig_magicsZthese_magicsZ
remove_magicsr�r=rrrr��szMagicMixin._mock_set_magicsN)rNrQr�r9r�rrrrr��sr�c@seZdZddd�ZdS)rFcCs|�||�|��dSr/�r�r�r�rrrr��sz"NonCallableMagicMock.mock_add_specN)F�rNrQr�r�rrrrr�src@seZdZdd�ZdS)�AsyncMagicMixincOs&|��tt|�j||�|��dSr/)r�r�r�r9r�rrrr9�szAsyncMagicMixin.__init__N�rNrQr�r9rrrrr��sr�c@seZdZddd�ZdS)rFcCs|�||�|��dSr/r�r�rrrr�szMagicMock.mock_add_specN)Fr�rrrrrsrc@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rBrr�rrrr9szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rTr�)rBr�r��mrrr�create_mocks�zMagicProxy.create_mockNcCs|��Sr/)r�)rBr)r=rrrr�(szMagicProxy.__get__)N)rNrQr�r9r�r�rrrrr�s	r�cs�eZdZed�Zed�Zed�Z�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ddd�Zdd�Z�fdd�Z�ZS)r�r�r�r�cs\t�j||�tjj|jd<d|jd<d|jd<t�|jd<ttd�}t	j
|_||jd<dS)Nr�rZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r�r+)�superr9r%r�r�r^rsrrr'ZCO_COROUTINE�co_flags)rBrCrD�	code_mock�r�rrr91s


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dk	r�t|�rL|�nbt|�s�zt|�}Wnt	k
rxt
�YnXt|�r�|�n&t�|�r�|||�IdH}n
|||�}|t
k	r�|S|jt
k	r�|jS|jdk	r�t�|j�r�|j||�IdHS|j||�S|jS)NTrDr�)rFr�r�r�r�r~r3rYr��
StopIteration�StopAsyncIterationr%r&rr�rwr�)rBrCrDrrGrgrrrrCAs6




z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)Nr�	Expected r5z to have been awaited.�r�r�rr rrrr�is
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS�Nr�r�r5z$ to have been awaited once. Awaited � times.r�r rrrr�qs
z"AsyncMockMixin.assert_awaited_oncecsz�jdkr&�����}td|�d������fdd�}����f�}���j�}||krvt|t�rf|nd}t|��|�dS)NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr!r"r#rrr$�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r�rrrr"r%)rBrCrDr&r$r'r(rr#rr�zs
z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd�d|j�d�}t|��|j||�Sr�)r�r�rr�r)rrrr��s
z'AsyncMockMixin.assert_awaited_once_withcsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>z%s await not found)rr�r"r%rrr9rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�dd�|D��}t|�d	t|��d
�j���|�dSt|�}g}|D]2}z|�|�Wq�tk
r�|�|�Yq�Xq�|r�tdt	|�f�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r-rrrrr.�s
z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>c3s|]}��|�VqdSr/r*r+r�rrr.�szAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s�r/z	
Actual: z%r not all found in await list)
r�rsr�r1rrZr3r=r�r[)	rBr4r5r&r(Z
all_awaitsr6r7r8rr�rr��s>������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)Nrr�r5z# to not have been awaited. Awaited r�r�r rrrr��s
z!AsyncMockMixin.assert_not_awaitedcs&t�j||�d|_d|_t�|_dS�Nr)r�rvr�r�rsr�rAr�rrrv�szAsyncMockMixin.reset_mock)F)rNrQr�r�r�r�r�r9rCr�r�r�r�r�r�r�rv�
__classcell__rrr�rr�,s(	
,	r�c@seZdZdS)r	NrHrrrrr	�sr	c@s$eZdZdd�Zdd�Zdd�ZdS)�_ANYcCsdSr8r�rBr�rrrr�	sz_ANY.__eq__cCsdSr�rr�rrrr�	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�	sz
_ANY.__repr__N)rNrQr�r�r�r�rrrrr�	sr�cCs`d|}d}d�dd�|D��}d�dd�|��D��}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�reprr�rrrr�!	sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�r�rrrr�"	s)r�r�)rrCrDrZformatted_argsZargs_stringZ
kwargs_stringrrrr	s
�rc@s�eZdZd dd�Zd!dd	�Zd
d�ZejZdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�ZdS)"rFrr�NFTcCs�d}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|||f�St�||||f�S)Nr�r�r�)r�r"r�r[r�)r�r�rr�rE�	from_kallrCrD�_len�first�secondrrrr�C	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rBr�rr�rEr�rrrr9c	sz_Call.__init__cCsh|tkrdSzt|�}Wntk
r.YdSXd}t|�dkrJ|\}}n
|\}}}t|dd�r|t|dd�r||j|jkr|dSd}|dkr�di}}n�|dkr�|\}}}n�|d	kr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r@|\}
}t|
t��r4|
}t|t��r(|i}}n
d|}}n
|
|}}ndS|�rX||k�rXdS||f||fkS)
NTFr�r�r�rrr�r�)rr�rr$r�r"r[r�)rBr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr�j	sR


�


z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�r�r�r��r�rFrrrrr:�	s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rBr�rrrrr��	s
z_Call.__getattr__cCs|tjkrt�t�||�Sr/)r[r^r;�__getattribute__)rBr�rrrr��	s
z_Call.__getattribute__cOs|�d�||�S)Nr��r�rArrrr��	sz_Call.countcOs|�d�||�S)N�indexr�rArrrr��	sz_Call.indexcCs(t|�dkr|\}}n
|\}}}||fS)Nr�)r�rrrr�_get_call_arguments�	s

z_Call._get_call_argumentscCs|��dSr��r�r�rrrrC�	sz
_Call.argscCs|��dS)Nr�r�r�rrrrD�	sz_Call.kwargscCs||js&|jpd}|�d�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|�d�shd|}nd|}t|||�S)Nrr�zcall%sr�zcall.%s)r�r�rr�r)rBrrCrDrrrr��	s





z_Call.__repr__cCs4g}|}|dk	r(|jr |�|�|j}qtt|��Sr/)r�r�r�rsr�)rBZvalsrJrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rNrQr�r�r9r�rr�r:r�r�r�r�r�r�rCrDr�r�rrrrrF0	s(�
 �
7

rF)r�c	Kslt|�rt|�}t|t�}t|�}d|i}|r8d|i}n|dkrDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dkr�d}
|	f|||
|d�|��}t|t��rt||�}|�rt|�nt||||�|dk	�r,|�s,||j|<|�rV|�sVd	|k�rVt||dd
|d�|_t|�D�]}t|��rr�q^zt||�}
Wntk
�r�Y�q^YnXd|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<np|}t|t��r�|j}t|||�}||d<t�|
��rt	}nt}|f||||d
�|��}||j|<t|
||d�t|t��r^t|||��q^|S)Nr�r�Tr�zJInstance can not be True when create_autospec is mocking an async functionrr�)r�r�r�rrwr�)rLrtr�r�)r�rr�r�)rK)r\r1r"r.rerr'Zisdatadescriptor�RuntimeErrorr	rYrrar�r6rjr�rMrrrwr�r�r$r;r�r5�
_must_skipr%r&rT)r�r�rLr�rtrD�is_typeZ
is_async_funcr}r|r�r5r�rfr�r�rKZchild_klassrrrr�	s�




��


�

��
rcCsxt|t�s$|t|di�krdS|j}|jD]H}|j�|t�}|tkrFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)Nr^F)r"r1r$r�r]r^r_rrWrXr6)r�r�r�r>rgrrrr�w
s


r�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dSr/)r��idsr�r�rLr)rBr�r�r�rr�rLrrrr9�
sz_SpecState.__init__)FNNNFr�rrrrr��
s
�r�cCs"t|t�rt�|�St�|�SdSr/)r"�bytes�io�BytesIO�StringIO)�	read_datarrr�
_to_stream�
s

rr�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd����fd	d
�}tdkr�ddl}ttt|j���tt|j����a|dkr�t	dt
d
�}t	td����j_d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_��j_|�j_����fdd�}||_�|_|S)Ncs$�jjdk	r�jjS�dj||�Sr�)�	readlinesrwrb��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs$�jjdk	r�jjS�dj||�Sr�)�readrwrbrrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s$��EdH�dj||�VqdSr�)�readlinerb)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdk	r�jjVq�dD]
}|Vq dSr�)rrw)�linerrrr�
sz$mock_open.<locals>._iter_side_effectcs �jjdk	r�jjSt�d�Sr�)rrwr�rrrr�_next_side_effect�
sz$mock_open.<locals>._next_side_effectr�open)rr�r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)rrr~rrb)r
rrrrr�
reset_data�
s

zmock_open.<locals>.reset_data)r�	file_spec�_iorZrr��
TextIOWrapper�unionrrrr~rw�writer	rrr~r�r�)r5rZ
_read_datarr
rrrr)rr
rrrrr
�
s8"

r
c@s&eZdZdd�Zddd�Zdd�ZdS)	rcKs
tf|�Sr/)r)rBrDrrrr�szPropertyMock._get_child_mockNcCs|�Sr/r)rBr)Zobj_typerrrr�szPropertyMock.__get__cCs||�dSr/r)rBr)r�rrrr�
szPropertyMock.__set__)N)rNrQr�r�r�r�rrrrr�
s	
rc	Cs^d|_t|�D]J}zt||�}Wntk
r8YqYnXt|t�sFq|j|krt|�qdSr8)r�r�r$r;r"rr�r)r5r�r�rrrrs



rc@s$eZdZdd�Zdd�Zdd�ZdS)r�cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r^)rBrr�rrrr9+s
z_AsyncIterator.__init__cCs|Sr/rr�rrrr�1sz_AsyncIterator.__aiter__c�s*zt|j�WStk
r YnXt�dSr/)r�rr�r�r�rrrr�4s
z_AsyncIterator.__anext__N)rNrQr�r9r�r�rrrrr�'sr�)F)F)NFNNN)FFNN)Nr�)y�__all__�__version__r%rar�r'r�rz�builtins�typesrrrZ
unittest.utilr�	functoolsrrr�rqr
r�r�r*r.r!r3r7r>rMrHrYr\rarjrer�r�rr�r�rr�MISSINGr
ZDELETEDr�r�r�rZrsr�r�r�rr�r<rrMrOrPr�r�r�rr�r�r�r�ZmultipleZstopallr_Z
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr	r�r:Z_sync_async_magicsZ
_async_magicsr;r�rr�r�r�r�r�r�r�r�r�r�rr�rr�r�r	r�rrr[rFrrr�r�r1r�r6rrr
rrr�rrrr�<module>s~	



1�	h4<�
�
2�
Mw	���	�
���
	
	�	8+B
�
�
NPK�
�\8O���!�!main.cpython-38.pycnu�[���U

e5d�-�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZdd�ZGdd	�d	ej
�Zd
d�Zddd
�ZdS)z
Main program for 2to3.
�)�with_statement�print_functionN�)�refactorc	Cs(|��}|��}tj||||dddd�S)z%Return a unified diff of two strings.z
(original)z(refactored)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filename�r�$/usr/lib64/python3.8/lib2to3/main.py�
diff_textss�rcs>eZdZdZd�fdd�	Zdd�Z�fdd�Zd	d
�Z�ZS)�StdoutRefactoringToola2
    A refactoring tool that can avoid overwriting its input files.
    Prints output to stdout.

    Output files can optionally be written to a different directory and or
    have an extra file suffix appended to their name for use in situations
    where you do not want to replace the input files.
    rc		sP||_||_|r&|�tj�s&|tj7}||_||_||_tt	|��
|||�dS)aF
        Args:
            fixers: A list of fixers to import.
            options: A dict with RefactoringTool configuration.
            explicit: A list of fixers to run even if they are explicit.
            nobackups: If true no backup '.bak' files will be created for those
                files that are being refactored.
            show_diffs: Should diffs of the refactoring be printed to stdout?
            input_base_dir: The base directory for all input files.  This class
                will strip this path prefix off of filenames before substituting
                it with output_dir.  Only meaningful if output_dir is supplied.
                All files processed by refactor() must start with this path.
            output_dir: If supplied, all converted files will be written into
                this directory tree instead of input_base_dir.
            append_suffix: If supplied, all files output by this tool will have
                this appended to their filename.  Useful for changing .py to
                .py3 for example by passing append_suffix='3'.
        N)�	nobackups�
show_diffs�endswith�os�sep�_input_base_dir�_output_dir�_append_suffix�superr�__init__)	�selfZfixers�options�explicitrr�input_base_dir�
output_dir�
append_suffix��	__class__rr
r$s
zStdoutRefactoringTool.__init__cOs*|j�|||f�|jj|f|�|�dS)N)�errors�append�logger�error)r�msg�args�kwargsrrr
�	log_errorAszStdoutRefactoringTool.log_errorc

sz|}|jrH|�|j�r6tj�|j|t|j�d��}ntd||jf��|jrX||j7}||kr�tj�	|�}tj�
|�s�|r�t�|�|�d||�|j
�s2|d}tj�|�r�zt�|�Wn.tk
r�}z|�d|�W5d}~XYnXzt�||�Wn2tk
�r0}z|�d||�W5d}~XYnXtt|�j}	|	||||�|j
�s`t�||�||k�rvt�||�dS)Nz5filename %s does not start with the input_base_dir %szWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)r�
startswithrr�path�join�len�
ValueErrorr�dirname�isdir�makedirs�log_messager�lexists�remove�OSError�renamerr�
write_file�shutilZcopymode)
rZnew_textrZold_text�encodingZ
orig_filenamerZbackup�err�writer rr
r7EsJ
���

� 
z StdoutRefactoringTool.write_filec	Cs�|r|�d|�n�|�d|�|jr�t|||�}zP|jdk	rl|j�"|D]}t|�qHtj��W5QRXn|D]}t|�qpWn$tk
r�t	d|f�YdSXdS)NzNo changes to %sz
Refactored %sz+couldn't encode %s's diff for your terminal)
r2rrZoutput_lock�print�sys�stdout�flush�UnicodeEncodeError�warn)r�old�newrZequalZ
diff_lines�linerrr
�print_outputls$

�z"StdoutRefactoringTool.print_output)rrr)	�__name__�
__module__�__qualname__�__doc__rr)r7rE�
__classcell__rrr r
rs
�'rcCstd|ftjd�dS)NzWARNING: %s��file)r<r=�stderr)r&rrr
rA�srAc
stjdd�}|jddddd�|jdd	d
gdd�|jd
dddddd�|jddd
gdd�|jddddd�|jddddd�|jddddd�|jd dd!d�|jd"d#dd$d�|jd%d&dd'd(d�|jd)d*dd+d,d-d.�|jd/d0dd1d�|jd2dd+d,d3d.�d'}i}|�|�\}}|j�r@d4|d5<|j�s:td6�d4|_|j�rZ|j�sZ|�	d7�|j
�rt|j�st|�	d8�|j�s�|j�r�td9�|j�s�|j�r�|�	d:�|j�r�t
d;�t���D]}t
|��q�|�s�d<S|�st
d=tjd>�t
d?tjd>�d@SdA|k�r(d4}|j�r(t
dBtjd>�d@S|j�r8d4|dC<|j�rFtjntj}tjdD|dE�t�dF�}tt����}	t�fdGdH�|jD��}
t�}|j�r�d'}|jD](}
|
dIk�r�d4}n|��dJ|
��q�|�r�|	�|�n|}n
|	�|�}|�|
�}t j!�"|�}|�r0|�#t j$��s0t j!�%|��s0t j!�&|�}|j�rT|�'t j$�}|�(dK|j|�t)t*|�|t*|�|j|j||j|j
dL�}|j+�s�|�r�|�,�nTz|�||j|j-|j.�Wn8tj/k
�r�|j.dk�s�t0�t
dMtjd>�YdSX|�1�t2t3|j+��S)Nz�Main program.

    Args:
        fixer_pkg: the name of a package where the fixers are located.
        args: optional; a list of command line arguments. If omitted,
              sys.argv[1:] is used.

    Returns a suggested exit status (0, 1, 2).
    z2to3 [options] file|dir ...)Zusagez-dz--doctests_only�
store_truezFix up doctests only)�action�helpz-fz--fixr#z1Each FIX specifies a transformation; default: all)rO�defaultrPz-jz--processesZstorer�intzRun 2to3 concurrently)rOrQ�typerPz-xz--nofixz'Prevent a transformation from being runz-lz--list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-vz	--verbosezMore verbose loggingz
--no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz--nobackupsFz&Don't write backups for modified filesz-oz--output-dir�strrzXPut output files in this directory instead of overwriting the input files.  Requires -n.)rOrSrQrPz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z--add-suffixzuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.T�write_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.rKzUse --help to show usage.��-zCan't write to stdin.rz%(name)s: %(message)s)�format�levelzlib2to3.mainc3s|]}�d|VqdS)�.fix_Nr)�.0�fix��	fixer_pkgrr
�	<genexpr>�szmain.<locals>.<genexpr>�allrZz7Output in %r will mirror the input directory %r layout.)rrrz+Sorry, -j isn't supported on this platform.)4�optparseZOptionParserZ
add_option�
parse_argsrUr;rArrr%Z
add_suffixZno_diffsZ
list_fixesr<rZget_all_fix_namesr=rMr�verbose�logging�DEBUG�INFOZbasicConfigZ	getLogger�setZget_fixers_from_packageZnofixr\�add�union�
differencerr+�commonprefixrrr0r/�rstrip�infor�sortedr"�refactor_stdinZ
doctests_onlyZ	processesZMultiprocessingUnsupported�AssertionErrorZ	summarizerR�bool)r^r'�parserro�flagsrZfixnamerYr$Zavail_fixesZunwanted_fixesrZall_presentr\Z	requestedZfixer_namesrZrtrr]r
�main�s�
����
�
�
��
���
��









���
��rt)N)rIZ
__future__rrr=rrrdr8rarrrZMultiprocessRefactoringToolrrArtrrrr
�<module>s	gPK�
�\Y'x��main.cpython-38.opt-2.pycnu�[���U

e5d�-�@s|ddlmZmZddlZddlZddlZddlZddlZddlZddl	m
Z
dd�ZGdd�de
j�Z
d	d
�Zd
dd�ZdS)�)�with_statement�print_functionN�)�refactorc	Cs(|��}|��}tj||||dddd�S)Nz
(original)z(refactored)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filename�r�$/usr/lib64/python3.8/lib2to3/main.py�
diff_textss�rcs:eZdZd
�fdd�	Zdd�Z�fdd�Zdd	�Z�ZS)�StdoutRefactoringToolrc		sP||_||_|r&|�tj�s&|tj7}||_||_||_tt	|��
|||�dS�N)�	nobackups�
show_diffs�endswith�os�sep�_input_base_dir�_output_dir�_append_suffix�superr�__init__)	�selfZfixers�options�explicitrr�input_base_dir�
output_dir�
append_suffix��	__class__rr
r$s
zStdoutRefactoringTool.__init__cOs*|j�|||f�|jj|f|�|�dSr)�errors�append�logger�error)r�msg�args�kwargsrrr
�	log_errorAszStdoutRefactoringTool.log_errorc

sz|}|jrH|�|j�r6tj�|j|t|j�d��}ntd||jf��|jrX||j7}||kr�tj�	|�}tj�
|�s�|r�t�|�|�d||�|j
�s2|d}tj�|�r�zt�|�Wn.tk
r�}z|�d|�W5d}~XYnXzt�||�Wn2tk
�r0}z|�d||�W5d}~XYnXtt|�j}	|	||||�|j
�s`t�||�||k�rvt�||�dS)Nz5filename %s does not start with the input_base_dir %szWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)r�
startswithrr�path�join�len�
ValueErrorr�dirname�isdir�makedirs�log_messager�lexists�remove�OSError�renamerr�
write_file�shutilZcopymode)
rZnew_textrZold_text�encodingZ
orig_filenamerZbackup�err�writer!rr
r8EsJ
���

� 
z StdoutRefactoringTool.write_filec	Cs�|r|�d|�n�|�d|�|jr�t|||�}zP|jdk	rl|j�"|D]}t|�qHtj��W5QRXn|D]}t|�qpWn$tk
r�t	d|f�YdSXdS)NzNo changes to %sz
Refactored %sz+couldn't encode %s's diff for your terminal)
r3rrZoutput_lock�print�sys�stdout�flush�UnicodeEncodeError�warn)r�old�newrZequalZ
diff_lines�linerrr
�print_outputls$

�z"StdoutRefactoringTool.print_output)rrr)�__name__�
__module__�__qualname__rr*r8rF�
__classcell__rrr!r
rs�'rcCstd|ftjd�dS)NzWARNING: %s��file)r=r>�stderr)r'rrr
rB�srBc
s�tjdd�}|jddddd�|jdd	d
gdd�|jd
dddddd�|jddd
gdd�|jddddd�|jddddd�|jddddd�|jd dd!d�|jd"d#dd$d�|jd%d&dd'd(d�|jd)d*dd+d,d-d.�|jd/d0dd1d�|jd2dd+d,d3d.�d'}i}|�|�\}}|j�r@d4|d5<|j�s:td6�d4|_|j�rZ|j�sZ|�	d7�|j
�rt|j�st|�	d8�|j�s�|j�r�td9�|j�s�|j�r�|�	d:�|j�r�t
d;�t���D]}t
|��q�|�s�d<S|�st
d=tjd>�t
d?tjd>�d@SdA|k�r(d4}|j�r(t
dBtjd>�d@S|j�r8d4|dC<|j�rFtjntj}tjdD|dE�t�dF�}tt����}	t�fdGdH�|jD��}
t�}|j�r�d'}|jD](}
|
dIk�r�d4}n|��dJ|
��q�|�r�|	�|�n|}n
|	�|�}|�|
�}t j!�"|�}|�r0|�#t j$��s0t j!�%|��s0t j!�&|�}|j�rT|�'t j$�}|�(dK|j|�t)t*|�|t*|�|j|j||j|j
dL�}|j+�s�|�r�|�,�nDz|�||j|j-|j.�Wn(tj/k
�r�t
dMtjd>�YdSX|�0�t1t2|j+��S)NNz2to3 [options] file|dir ...)Zusagez-dz--doctests_only�
store_truezFix up doctests only)�action�helpz-fz--fixr$z1Each FIX specifies a transformation; default: all)rO�defaultrPz-jz--processesZstorer�intzRun 2to3 concurrently)rOrQ�typerPz-xz--nofixz'Prevent a transformation from being runz-lz--list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-vz	--verbosezMore verbose loggingz
--no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz--nobackupsFz&Don't write backups for modified filesz-oz--output-dir�strrzXPut output files in this directory instead of overwriting the input files.  Requires -n.)rOrSrQrPz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z--add-suffixzuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.T�write_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.rKzUse --help to show usage.��-zCan't write to stdin.rz%(name)s: %(message)s)�format�levelzlib2to3.mainc3s|]}�d|VqdS)�.fix_Nr)�.0�fix��	fixer_pkgrr
�	<genexpr>�szmain.<locals>.<genexpr>�allrZz7Output in %r will mirror the input directory %r layout.)rrr z+Sorry, -j isn't supported on this platform.)3�optparseZOptionParserZ
add_option�
parse_argsrUr<rBrrr&Z
add_suffixZno_diffsZ
list_fixesr=rZget_all_fix_namesr>rMr�verbose�logging�DEBUG�INFOZbasicConfigZ	getLogger�setZget_fixers_from_packageZnofixr\�add�union�
differencerr,�commonprefixrrr1r0�rstrip�infor�sortedr#�refactor_stdinZ
doctests_onlyZ	processesZMultiprocessingUnsupportedZ	summarizerR�bool)r^r(�parserro�flagsrZfixnamerYr%Zavail_fixesZunwanted_fixesrZall_presentr\Z	requestedZfixer_namesrZrtrr]r
�main�s�
����
�
�
��
���
��









���
��rs)N)Z
__future__rrr>rrrdr9rarrrZMultiprocessRefactoringToolrrBrsrrrr
�<module>s	gPKX�\_!^+��encoding.cpython-36.opt-1.pycnu�[���3

�Pf��@sjddlZddlZddlZejdfejdfejdfejdfejdfejdfej	dfgZ
ejd	�Zd
d�Z
dS)�N�utf8�utf16zutf16-bezutf16-le�utf32zutf32-bezutf32-lescoding[:=]\s*([-\w.]+)cCs�x0tD](\}}|j|�r|t|�d�j|�SqWxV|jd�dd�D]@}|dd�dkrFtj|�rFtj|�j�djd�}|j|�SqFW|jtj	d��S)	z�Check a bytes string for a BOM to correctly detect the encoding

    Fallback to locale.getpreferredencoding(False) like open() on Python3N�
�r��#�asciiF)
�BOMS�
startswith�len�decode�split�ENCODING_RE�search�groups�locale�getpreferredencoding)�dataZbom�encoding�line�r�/usr/lib/python3.6/encoding.py�auto_decodes
r)�codecsr�re�BOM_UTF8�	BOM_UTF16�BOM_UTF16_BE�BOM_UTF16_LE�	BOM_UTF32�BOM_UTF32_BE�BOM_UTF32_LEr
�compilerrrrrr�<module>s
PKX�\�''logging.cpython-36.pycnu�[���3

�Pf��@sddlmZddlZddlZddlZddlZyddlZWnek
rTddlZYnXddl	m
Z
ddlmZyddl
mZWnek
r�dZYnXej�Zde_ejddd��Zd	d
�ZGdd�dej�Zd
d�ZGdd�dej�ZGdd�dejj�ZGdd�dej�ZdS)�)�absolute_importN)�WINDOWS)�
ensure_dir)�colorama�ccs.tj|7_z
dVWdtj|8_XdS)zv
    A context manager which will cause the log output to be indented for any
    log messages emitted inside it.
    N)�
_log_state�indentation)Znum�r	�/usr/lib/python3.6/logging.py�
indent_logs
rcCsttdd�S)Nrr)�getattrrr	r	r	r
�get_indentation)sr
c@seZdZdd�ZdS)�IndentingFormattercCs,tjj||�}djdd�|jd�D��}|S)z�
        Calls the standard formatter, but will indent all of the log messages
        by our current indentation level.
        �cSsg|]}dt�|�qS)� )r
)�.0�liner	r	r
�
<listcomp>6sz-IndentingFormatter.format.<locals>.<listcomp>T)�logging�	Formatter�format�join�
splitlines)�self�recordZ	formattedr	r	r
r/s
zIndentingFormatter.formatN)�__name__�
__module__�__qualname__rr	r	r	r
r-srcs�fdd�}|S)Ncsdjt��|tjjg�S)Nr)r�listrZStyleZ	RESET_ALL)Zinp)�colorsr	r
�wrapped=sz_color_wrap.<locals>.wrappedr	)rr r	)rr
�_color_wrap<sr!c@sTeZdZer2ejeejj�fej	eejj
�fgZngZddd�Zdd�Z
dd�ZdS)	�ColorizedStreamHandlerNcCs(tjj||�tr$tr$tj|j�|_dS)N)r�
StreamHandler�__init__rr�AnsiToWin32�stream)rr&r	r	r
r$NszColorizedStreamHandler.__init__cCsRtsdSt|jtj�s|jn|jj}t|d�r:|j�r:dStjj	d�dkrNdSdS)NF�isattyTZTERMZANSI)
r�
isinstancer&r%r �hasattrr'�os�environ�get)rZreal_streamr	r	r
�should_colorTsz#ColorizedStreamHandler.should_colorcCsBtjj||�}|j�r>x&|jD]\}}|j|kr||�}PqW|S)N)rr#rr-�COLORS�levelno)rr�msg�levelZcolorr	r	r
ris
zColorizedStreamHandler.format)N)rrrrrZERRORr!ZForeZREDZWARNINGZYELLOWr.r$r-rr	r	r	r
r"Bs
r"c@seZdZdd�ZdS)�BetterRotatingFileHandlercCs ttjj|j��tjjj|�S)N)	rr*�path�dirnameZbaseFilenamer�handlers�RotatingFileHandler�_open)rr	r	r
r7wszBetterRotatingFileHandler._openN)rrrr7r	r	r	r
r2usr2c@seZdZdd�Zdd�ZdS)�MaxLevelFiltercCs
||_dS)N)r1)rr1r	r	r
r$~szMaxLevelFilter.__init__cCs|j|jkS)N)r/r1)rrr	r	r
�filter�szMaxLevelFilter.filterN)rrrr$r9r	r	r	r
r8|sr8)r) Z
__future__r�
contextlibrZlogging.handlersr*Z	threading�ImportErrorZdummy_threadingZ
pip.compatrZ	pip.utilsrZpip._vendorr�	ExceptionZlocalrr�contextmanagerrr
rrr!r#r"r5r6r2�Filterr8r	r	r	r
�<module>s0
3PKX�\a �44filesystem.cpython-36.pycnu�[���3

�Pf��@s(ddlZddlZddlmZdd�ZdS)�N)�get_path_uidcCs�ttd�sdSd}xp||kr�tjj|�rntj�dkr^yt|�}Wntk
rTdSX|dkStj|tj�Sq|tjj	|�}}qWdS)N�geteuidTrF)
�hasattr�os�path�lexistsrr�OSError�access�W_OK�dirname)rZpreviousZpath_uid�r� /usr/lib/python3.6/filesystem.py�check_path_owners

r)rZos.pathZ
pip.compatrrrrrr
�<module>sPKX�\& Z��packaging.cpython-36.pycnu�[���3

�Pf �@s~ddlmZddlmZddlZddlZddlmZddlmZddl	m
Z
ddlmZej
e�Zdd	�Zd
d�Zdd
�ZdS)�)�absolute_import)�
FeedParserN)�
specifiers)�version)�
pkg_resources)�
exceptionscCs>|dkrdStj|�}tjdjtttjdd����}||kS)aG
    Check if the python version in use match the `requires_python` specifier.

    Returns `True` if the version of python in use matches the requirement.
    Returns `False` if the version of python in use does not matches the
    requirement.

    Raises an InvalidSpecifier if `requires_python` have an invalid format.
    NT�.�)	rZSpecifierSetr�parse�join�map�str�sys�version_info)�requires_pythonZrequires_python_specifierZpython_version�r�/usr/lib/python3.6/packaging.py�check_requires_pythons


 rcCs8t|tj�r |jd�r |jd�S|jd�r4|jd�SdS)NZMETADATAzPKG-INFO)�
isinstancerZDistInfoDistributionZhas_metadata�get_metadata)�distrrrr%s



rcCs�t|�}t�}|j|�|j�}|jd�}y8t|�s`tjd|j|dj	t
ttj
dd���f��Wn8tjk
r�}ztjd|j||f�dSd}~XnXdS)NzRequires-Pythonz4%s requires Python '%s' but the running Python is %srr	z7Package %s has an invalid Requires-Python entry %s - %s)rrZfeed�close�getrrZUnsupportedPythonVersionZproject_namerrr
rrrZInvalidSpecifier�loggerZwarning)rZmetadataZfeed_parserZ
pkg_info_dictr�errr�check_dist_requires_python-s"

$r)Z
__future__rZemail.parserrZloggingrZpip._vendor.packagingrrZpip._vendorrZpiprZ	getLogger�__name__rrrrrrrr�<module>s
PKX�\UtFCCglibc.cpython-36.opt-1.pycnu�[���3

�Pf{�@sPddlmZddlZddlZddlZddlZdd�Zdd�Zdd�Zd	d
�Z	dS)�)�absolute_importNcCsPtjd�}y
|j}Wntk
r(dSXtj|_|�}t|t�sL|jd�}|S)z9Returns glibc version string, or None if not using glibc.N�ascii)	�ctypesZCDLL�gnu_get_libc_version�AttributeErrorZc_char_pZrestype�
isinstance�str�decode)Zprocess_namespacer�version_str�r�/usr/lib/python3.6/glibc.py�glibc_version_string	s



r
cCsHtjd|�}|s$tjd|t�dSt|jd��|koFt|jd��|kS)Nz$(?P<major>[0-9]+)\.(?P<minor>[0-9]+)z=Expected glibc version with 2 components major.minor, got: %sF�major�minor)�re�match�warnings�warn�RuntimeWarning�int�group)r
�required_major�
minimum_minor�mrrr�check_glibc_version#s
rcCst�}|dkrdSt|||�S)NF)r
r)rrr
rrr�have_compatible_glibc3srcCs"t�}|dkrtj�Sd|fSdS)NZglibc)r
�platform�libc_ver)Z
glibc_versionrrrrKsr)
Z
__future__rrrrrr
rrrrrrr�<module>sPKX�\���~build.cpython-36.pycnu�[���3

�Pf �@s<ddlmZddlZddlZddlmZGdd�de�ZdS)�)�absolute_importN)�rmtreec@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�BuildDirectoryNcCsL|dkr|dkrd}|dkr<tjjtjdd��}|dkr<d}||_||_dS)NTz
pip-build-)�prefix)�os�path�realpath�tempfileZmkdtemp�name�delete)�selfr
r�r
�/usr/lib/python3.6/build.py�__init__szBuildDirectory.__init__cCsdj|jj|j�S)Nz	<{} {!r}>)�format�	__class__�__name__r
)rr
r
r�__repr__szBuildDirectory.__repr__cCs|jS)N)r
)rr
r
r�	__enter__"szBuildDirectory.__enter__cCs|j�dS)N)�cleanup)r�exc�value�tbr
r
r�__exit__%szBuildDirectory.__exit__cCs|jrt|j�dS)N)rrr
)rr
r
rr(szBuildDirectory.cleanup)NN)r�
__module__�__qualname__rrrrrr
r
r
rr	s

r)	Z
__future__rZos.pathrr	Z	pip.utilsr�objectrr
r
r
r�<module>sPKX�\& Z��packaging.cpython-36.opt-1.pycnu�[���3

�Pf �@s~ddlmZddlmZddlZddlZddlmZddlmZddl	m
Z
ddlmZej
e�Zdd	�Zd
d�Zdd
�ZdS)�)�absolute_import)�
FeedParserN)�
specifiers)�version)�
pkg_resources)�
exceptionscCs>|dkrdStj|�}tjdjtttjdd����}||kS)aG
    Check if the python version in use match the `requires_python` specifier.

    Returns `True` if the version of python in use matches the requirement.
    Returns `False` if the version of python in use does not matches the
    requirement.

    Raises an InvalidSpecifier if `requires_python` have an invalid format.
    NT�.�)	rZSpecifierSetr�parse�join�map�str�sys�version_info)�requires_pythonZrequires_python_specifierZpython_version�r�/usr/lib/python3.6/packaging.py�check_requires_pythons


 rcCs8t|tj�r |jd�r |jd�S|jd�r4|jd�SdS)NZMETADATAzPKG-INFO)�
isinstancerZDistInfoDistributionZhas_metadata�get_metadata)�distrrrr%s



rcCs�t|�}t�}|j|�|j�}|jd�}y8t|�s`tjd|j|dj	t
ttj
dd���f��Wn8tjk
r�}ztjd|j||f�dSd}~XnXdS)NzRequires-Pythonz4%s requires Python '%s' but the running Python is %srr	z7Package %s has an invalid Requires-Python entry %s - %s)rrZfeed�close�getrrZUnsupportedPythonVersionZproject_namerrr
rrrZInvalidSpecifier�loggerZwarning)rZmetadataZfeed_parserZ
pkg_info_dictr�errr�check_dist_requires_python-s"

$r)Z
__future__rZemail.parserrZloggingrZpip._vendor.packagingrrZpip._vendorrZpiprZ	getLogger�__name__rrrrrrrr�<module>s
PKX�\_!^+��encoding.cpython-36.pycnu�[���3

�Pf��@sjddlZddlZddlZejdfejdfejdfejdfejdfejdfej	dfgZ
ejd	�Zd
d�Z
dS)�N�utf8�utf16zutf16-bezutf16-le�utf32zutf32-bezutf32-lescoding[:=]\s*([-\w.]+)cCs�x0tD](\}}|j|�r|t|�d�j|�SqWxV|jd�dd�D]@}|dd�dkrFtj|�rFtj|�j�djd�}|j|�SqFW|jtj	d��S)	z�Check a bytes string for a BOM to correctly detect the encoding

    Fallback to locale.getpreferredencoding(False) like open() on Python3N�
�r��#�asciiF)
�BOMS�
startswith�len�decode�split�ENCODING_RE�search�groups�locale�getpreferredencoding)�dataZbom�encoding�line�r�/usr/lib/python3.6/encoding.py�auto_decodes
r)�codecsr�re�BOM_UTF8�	BOM_UTF16�BOM_UTF16_BE�BOM_UTF16_LE�	BOM_UTF32�BOM_UTF32_BE�BOM_UTF32_LEr
�compilerrrrrr�<module>s
PKY�\:��ggoutdated.cpython-36.opt-1.pycnu�[���3

�Pfe�@s�ddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
mZmZddlmZddlmZmZddlmZmZdd	lmZd
Zeje�ZGdd�de�ZGd
d�de�Z dd�Z!dd�Z"dd�Z#dS)�)�absolute_importN)�lockfile)�version)�
total_seconds�WINDOWS)�PyPI)�USER_CACHE_DIR�running_under_virtualenv)�
ensure_dir�get_installed_version)�check_path_ownerz%Y-%m-%dT%H:%M:%SZc@seZdZdd�Zdd�ZdS)�VirtualenvSelfCheckStatecCs\tjjtjd�|_y&t|j��}tj|�|_	WdQRXWnt
tfk
rVi|_	YnXdS)Nzpip-selfcheck.json)�os�path�join�sys�prefix�statefile_path�open�json�load�state�IOError�
ValueError)�self�	statefile�r�/usr/lib/python3.6/outdated.py�__init__sz!VirtualenvSelfCheckState.__init__c
Cs:t|jd��$}tj|jt�|d�|ddd�WdQRXdS)N�w)�
last_check�pypi_versionT�,�:)�	sort_keys�
separators)r"r#)rrr�dump�strftime�SELFCHECK_DATE_FMT)rr!�current_timerrrr�save$szVirtualenvSelfCheckState.saveN)�__name__�
__module__�__qualname__rr*rrrrr
s
r
c@seZdZdd�Zdd�ZdS)�GlobalSelfCheckStatecCsbtjjtd�|_y,t|j��}tj|�tj	|_
WdQRXWn ttt
fk
r\i|_
YnXdS)Nzselfcheck.json)rrrrrrrrrrrrr�KeyError)rrrrrr3s zGlobalSelfCheckState.__init__cCs�ttjj|j��sdSttjj|j��tj|j��ztjj|j�rft	|j��}t
j|�}WdQRXni}|jt
�|d�|tj<t	|jd��}t
j||ddd�WdQRXWdQRXdS)N)r r!rTr"r#)r$r%)r"r#)rrr�dirnamerr
rZLockFile�existsrrrr'r(rrr&)rr!r)rrrrrr*=s
zGlobalSelfCheckState.saveN)r+r,r-rr*rrrrr.2s
r.cCst�rt�St�SdS)N)r	r
r.rrrr�load_selfcheck_statefileXsr2cCsFddl}y"|jd�}|jd�o*d|jd�kS|jk
r@dSXdS)z�Checks whether pip was installed by pip

    This is used not to display the upgrade message when pip is in fact
    installed by system package manager, such as dnf on Fedora.
    rN�pipZ	INSTALLERF)�
pkg_resourcesZget_distributionZhas_metadataZget_metadata_linesZDistributionNotFound)r4Zdistrrr�pip_installed_by_pip_s

r5c
CsFtd�}|dkrdStj|�}d}�y�t�}tjj�}d|jkrxd|jkrxtjj|jdt�}t	||�dkrx|jd}|dkr�|j
tjdd	id
�}|j
�dd�tt|j�d
�tjd�D�d}|j||�tj|�}||k�r|j|jk�rt��rt�rd}	nd}	tjd|||	�Wn$tk
�r@tjddd�YnXdS)z�Check for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    r3Nr r!���<ZAcceptzapplication/json)ZheaderscSsg|]}tj|�js|�qSr)�packaging_version�parseZ
is_prerelease)�.0�vrrr�
<listcomp>�sz%pip_version_check.<locals>.<listcomp>Zreleases)�key�z
python -m pipz�You are using pip version %s, however version %s is available.
You should consider upgrading via the '%s install --upgrade pip' command.z5There was an error checking the latest version of pipT)�exc_info�i`'i�:	���)rr9r:r2�datetimeZutcnowrZstrptimer(r�getrZpip_json_urlZraise_for_status�sorted�listrr*Zbase_versionr5r�loggerZwarning�	Exception�debug)
ZsessionZinstalled_versionZpip_versionr!rr)r ZrespZremote_versionZpip_cmdrrr�pip_version_checknsL




rJ)$Z
__future__rrCrZloggingZos.pathrrZpip._vendorrZpip._vendor.packagingrr9Z
pip.compatrrZ
pip.modelsrZ
pip.locationsrr	Z	pip.utilsr
rZpip.utils.filesystemrr(Z	getLoggerr+rG�objectr
r.r2r5rJrrrr�<module>s&
&PKY�\UtFCCglibc.cpython-36.pycnu�[���3

�Pf{�@sPddlmZddlZddlZddlZddlZdd�Zdd�Zdd�Zd	d
�Z	dS)�)�absolute_importNcCsPtjd�}y
|j}Wntk
r(dSXtj|_|�}t|t�sL|jd�}|S)z9Returns glibc version string, or None if not using glibc.N�ascii)	�ctypesZCDLL�gnu_get_libc_version�AttributeErrorZc_char_pZrestype�
isinstance�str�decode)Zprocess_namespacer�version_str�r�/usr/lib/python3.6/glibc.py�glibc_version_string	s



r
cCsHtjd|�}|s$tjd|t�dSt|jd��|koFt|jd��|kS)Nz$(?P<major>[0-9]+)\.(?P<minor>[0-9]+)z=Expected glibc version with 2 components major.minor, got: %sF�major�minor)�re�match�warnings�warn�RuntimeWarning�int�group)r
�required_major�
minimum_minor�mrrr�check_glibc_version#s
rcCst�}|dkrdSt|||�S)NF)r
r)rrr
rrr�have_compatible_glibc3srcCs"t�}|dkrtj�Sd|fSdS)NZglibc)r
�platform�libc_ver)Z
glibc_versionrrrrKsr)
Z
__future__rrrrrr
rrrrrrr�<module>sPKY�\��H���hashes.cpython-36.pycnu�[���3

�Pf2�@szddlmZddlZddlmZmZmZddlmZddl	m
Z
mZmZdZ
dddgZGd	d
�d
e�ZGdd�de�ZdS)
�)�absolute_importN)�HashMismatch�HashMissing�InstallationError)�read_chunks)�	iteritems�iterkeys�
itervaluesZsha256Zsha384Zsha512c@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�HasheszaA wrapper that builds multiple hashes at once and checks them against
    known-good values

    NcCs|dkrin||_dS)zo
        :param hashes: A dict of algorithm names pointing to lists of allowed
            hex digests
        N)�_allowed)�self�hashes�r�/usr/lib/python3.6/hashes.py�__init__szHashes.__init__c
Cs�i}xJt|j�D]<}ytj|�||<Wqttfk
rJtd|��YqXqWx(|D] }xt|�D]}|j|�qdWqVWx*t	|�D]\}}|j
�|j|kr�dSq�W|j|�dS)z�Check good hashes against ones built from iterable of chunks of
        data.

        Raise HashMismatch if none match.

        zUnknown hash name: %sN)rr�hashlib�new�
ValueError�	TypeErrorrr	�updater�	hexdigest�_raise)rZchunks�gotsZ	hash_name�chunk�hashZgotrrr�check_against_chunks s
zHashes.check_against_chunkscCst|j|��dS)N)rr)rrrrrr7sz
Hashes._raisecCs|jt|��S)zaCheck good hashes against a file-like object

        Raise HashMismatch if none match.

        )rr)r�filerrr�check_against_file:szHashes.check_against_filec	Cs t|d��}|j|�SQRXdS)N�rb)�openr)r�pathrrrr�check_against_pathBszHashes.check_against_pathcCs
t|j�S)z,Return whether I know any known-good hashes.)�boolr)rrrr�__nonzero__FszHashes.__nonzero__cCs|j�S)N)r#)rrrr�__bool__JszHashes.__bool__)N)�__name__�
__module__�__qualname__�__doc__rrrrr!r#r$rrrrr
s
r
cs(eZdZdZ�fdd�Zdd�Z�ZS)�
MissingHashesz�A workalike for Hashes used when we're missing a hash for a requirement

    It computes the actual hash of the requirement and raises a HashMissing
    exception showing it to the user.

    cstt|�jtgid�dS)z!Don't offer the ``hashes`` kwarg.)r
N)�superr)r�
FAVORITE_HASH)r)�	__class__rrrUszMissingHashes.__init__cCst|tj���dS)N)rr+r)rrrrrr[szMissingHashes._raise)r%r&r'r(rr�
__classcell__rr)r,rr)Nsr))Z
__future__rrZpip.exceptionsrrrZ	pip.utilsrZpip._vendor.sixrrr	r+Z
STRONG_HASHES�objectr
r)rrrr�<module>s
:PKY�\�3L\%\%ui.cpython-36.pycnu�[���3

�PfM-�@s�ddlmZddlmZddlZddlZddlmZmZmZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZdd	lmZmZdd
lmZmZmZddlmZyddlmZWnek
r�dZYnXe
je�Z d
d�Z!e!ee�Z"Gdd�de#�Z$Gdd�de#�Z%Gdd�de#�Z&Gdd�de&e$e%e"�Z'Gdd�de&e$e%ee�Z(e	j)dd��Z*Gdd�de#�Z+Gdd�de#�Z,Gdd �d e#�Z-e	j)d!d"��Z.dS)#�)�absolute_import)�divisionN)�signal�SIGINT�default_int_handler)�WINDOWS)�format_size)�get_indentation)�six)�Bar�IncrementalBar)�WritelnMixin�HIDE_CURSOR�SHOW_CURSOR)�Spinner)�coloramacCs�t|jdd�}|s|St|dtj��t|dtj��g}|tt|dg��7}ytj�j|�j|�Wntk
rv|SX|SdS)N�encodingZ
empty_fillZfill�phases)�getattr�filer
Z	text_type�list�join�encode�UnicodeEncodeError)Z	preferredZfallbackrZ
characters�r�/usr/lib/python3.6/ui.py�_select_progress_classsrcs4eZdZdZ�fdd�Z�fdd�Zdd�Z�ZS)�InterruptibleMixina�
    Helper to ensure that self.finish() gets called on keyboard interrupt.

    This allows downloads to be interrupted without leaving temporary state
    (like hidden cursors) behind.

    This class is similar to the progress library's existing SigIntMixin
    helper, but as of version 1.2, that helper has the following problems:

    1. It calls sys.exit().
    2. It discards the existing SIGINT handler completely.
    3. It leaves its own handler in place even after an uninterrupted finish,
       which will have unexpected delayed effects if the user triggers an
       unrelated keyboard interrupt some time after a progress-displaying
       download has already completed, for example.
    cs4tt|�j||�tt|j�|_|jdkr0t|_dS)z=
        Save the original SIGINT handler for later.
        N)�superr�__init__rr�
handle_sigint�original_handlerr)�self�args�kwargs)�	__class__rrrNs
zInterruptibleMixin.__init__cstt|�j�tt|j�dS)z�
        Restore the original SIGINT handler after finishing.

        This should happen regardless of whether the progress display finishes
        normally, or gets interrupted.
        N)rr�finishrrr!)r")r%rrr&^szInterruptibleMixin.finishcCs|j�|j||�dS)z�
        Call self.finish() before delegating to the original SIGINT handler.

        This handler should only be in place while the progress display is
        active.
        N)r&r!)r"Zsignum�framerrrr hsz InterruptibleMixin.handle_sigint)�__name__�
__module__�__qualname__�__doc__rr&r �
__classcell__rr)r%rr<s
rcsJeZdZ�fdd�Zedd��Zedd��Zedd��Zdd
d�Z�Z	S)
�DownloadProgressMixincs,tt|�j||�dt�d|j|_dS)N� �)rr-rr	�message)r"r#r$)r%rrruszDownloadProgressMixin.__init__cCs
t|j�S)N)r�index)r"rrr�
downloadedysz DownloadProgressMixin.downloadedcCs |jdkrdStd|j�dS)Ngz...�z/s)Zavgr)r"rrr�download_speed}s
z$DownloadProgressMixin.download_speedcCs|jrd|jSdS)Nzeta %s�)ZetaZeta_td)r"rrr�
pretty_eta�s
z DownloadProgressMixin.pretty_etar3ccs*x|D]}|V|j|�qW|j�dS)N)�nextr&)r"�it�n�xrrr�iter�s
zDownloadProgressMixin.iter)r3)
r(r)r*r�propertyr2r4r6r;r,rr)r%rr-ss
r-cseZdZ�fdd�Z�ZS)�WindowsMixincs\tr�jrd�_tt��j||�trXtrXtj�j��_�fdd��j_�fdd��j_	dS)NFcs�jjj�S)N)r�wrapped�isattyr)r"rr�<lambda>�sz'WindowsMixin.__init__.<locals>.<lambda>cs�jjj�S)N)rr>�flushr)r"rrr@�s)
rZhide_cursorrr=rrZAnsiToWin32rr?rA)r"r#r$)r%)r"rr�s
zWindowsMixin.__init__)r(r)r*rr,rr)r%rr=�sr=c@seZdZejZdZdZdS)�DownloadProgressBarz
%(percent)d%%z0%(downloaded)s %(download_speed)s %(pretty_eta)sN)r(r)r*�sys�stdoutrr0�suffixrrrrrB�srBc@s&eZdZejZdZdd�Zdd�ZdS)�DownloadProgressSpinnerz!%(downloaded)s %(download_speed)scCs"t|d�stj|j�|_t|j�S)N�_phaser)�hasattr�	itertools�cyclerrGr7)r"rrr�
next_phase�s
z"DownloadProgressSpinner.next_phasecCsN|j|}|j�}|j|}dj||r*dnd||r6dnd|g�}|j|�dS)Nr5r.)r0rKrErZwriteln)r"r0ZphaserE�linerrr�update�s



zDownloadProgressSpinner.updateN)	r(r)r*rCrDrrErKrMrrrrrF�srFccsRtrdVnB|j�s$tj�tjkr,dVn"|jt�z
dVWd|jt�XdS)N)	rr?�logger�getEffectiveLevel�logging�INFO�writerr)rrrr�
hidden_cursor�s

rSc@s$eZdZdd�Zdd�Zdd�ZdS)�RateLimitercCs||_d|_dS)Nr)�_min_update_interval_seconds�_last_update)r"�min_update_interval_secondsrrrr�szRateLimiter.__init__cCstj�}||j}||jkS)N)�timerVrU)r"ZnowZdeltarrr�ready�s
zRateLimiter.readycCstj�|_dS)N)rXrV)r"rrr�reset�szRateLimiter.resetN)r(r)r*rrYrZrrrrrT�srTc@s.eZdZddd�Zdd�Zdd	�Zd
d�ZdS)
�InteractiveSpinnerN�-\|/��?cCs\||_|dkrtj}||_t|�|_d|_tj|�|_	|jj
dt�|jd�d|_dS)NFr.z ... r)
�_messagerCrD�_filerT�
_rate_limiter�	_finishedrIrJ�_spin_cyclerRr	�_width)r"r0rZ
spin_charsrWrrrr�s
zInteractiveSpinner.__init__cCs^|jst�d|j}|jj|d|j|�|jj|�t|�|_|jj�|jj�dS)N�r.)	ra�AssertionErrorrcr_rR�lenrAr`rZ)r"�statusZbackuprrr�_write	s


zInteractiveSpinner._writecCs,|jr
dS|jj�sdS|jt|j��dS)N)rar`rYrhr7rb)r"rrr�spins

zInteractiveSpinner.spincCs4|jr
dS|j|�|jjd�|jj�d|_dS)N�
T)rarhr_rRrA)r"�final_statusrrrr&s

zInteractiveSpinner.finish)Nr\r])r(r)r*rrhrir&rrrrr[�s


r[c@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)�NonInteractiveSpinner�<cCs$||_d|_t|�|_|jd�dS)NFZstarted)r^rarTr`�_update)r"r0rWrrrr*s
zNonInteractiveSpinner.__init__cCs*|jst�|jj�tjd|j|�dS)Nz%s: %s)rarer`rZrN�infor^)r"rgrrrrn0s
zNonInteractiveSpinner._updatecCs&|jr
dS|jj�sdS|jd�dS)Nzstill running...)rar`rYrn)r"rrrri5s

zNonInteractiveSpinner.spincCs$|jr
dS|jd|f�d|_dS)Nzfinished with status '%s'T)rarn)r"rkrrrr&<szNonInteractiveSpinner.finishN)rm)r(r)r*rrnrir&rrrrrl)s
rlccs�tjj�r"tj�tjkr"t|�}nt|�}y t	tj��|VWdQRXWn>t
k
rj|jd��Yn*tk
r�|jd��YnX|jd�dS)NZcanceled�error�done)
rCrDr?rNrOrPrQr[rlrS�KeyboardInterruptr&�	Exception)r0Zspinnerrrr�open_spinnerCs


rt)/Z
__future__rrrIrCrrrrX�
contextlibrPZ
pip.compatrZ	pip.utilsrZpip.utils.loggingr	Zpip._vendorr
Zpip._vendor.progress.barrrZpip._vendor.progress.helpersr
rrZpip._vendor.progress.spinnerrrrsZ	getLoggerr(rNrZ_BaseBar�objectrr-r=rBrF�contextmanagerrSrTr[rlrtrrrr�<module>sB


7
!0PKY�\2��eappdirs.cpython-36.pycnu�[���3

�Pfk"�@s�dZddlmZddlZddlZddlmZmZddlm	Z	m
Z
dd�Zdd	d
�Zddd
�Z
dd�Zdd�Zdd�Zer�yddlZeZWnek
r�eZYnXdd�ZdS)zd
This code was taken from https://github.com/ActiveState/appdirs and modified
to suit our purposes.
�)�absolute_importN)�WINDOWS�
expanduser)�PY2�	text_typecCs�tr<tjjtd��}tr*t|t�r*t|�}tjj	||d�}n@t
jdkr^td�}tjj	||�}ntj
dtd��}tjj	||�}|S)a5
    Return full path to the user-specific cache dir for this application.

        "appname" is the name of application.

    Typical user cache directories are:
        macOS:      ~/Library/Caches/<AppName>
        Unix:       ~/.cache/<AppName> (XDG default)
        Windows:    C:\Users\<username>\AppData\Local\<AppName>\Cache

    On Windows the only suggestion in the MSDN docs is that local settings go
    in the `CSIDL_LOCAL_APPDATA` directory. This is identical to the
    non-roaming app data dir (the default returned by `user_data_dir`). Apps
    typically put cache data somewhere *under* the given dir here. Some
    examples:
        ...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
        ...\Acme\SuperApp\Cache\1.0

    OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
    �CSIDL_LOCAL_APPDATAZCache�darwinz~/Library/CachesZXDG_CACHE_HOMEz~/.cache)r�os�path�normpath�_get_win_folderr�
isinstancer�_win_path_to_bytes�join�sys�platformr�getenv)�appnamer
�r�/usr/lib/python3.6/appdirs.py�user_cache_dirs
rFcCshtr,|rdpd}tjjtjjt|��|�}n8tjdkrJtjjtd�|�}ntjjtj	dtd��|�}|S)aS
    Return full path to the user-specific data dir for this application.

        "appname" is the name of application.
            If None, just the system directory is returned.
        "roaming" (boolean, default False) can be set True to use the Windows
            roaming appdata directory. That means that for users on a Windows
            network setup for roaming profiles, this user data will be
            sync'd on login. See
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.

    Typical user data directories are:
        macOS:                  ~/Library/Application Support/<AppName>
        Unix:                   ~/.local/share/<AppName>    # or in
                                $XDG_DATA_HOME, if defined
        Win XP (not roaming):   C:\Documents and Settings\<username>\ ...
                                ...Application Data\<AppName>
        Win XP (roaming):       C:\Documents and Settings\<username>\Local ...
                                ...Settings\Application Data\<AppName>
        Win 7  (not roaming):   C:\Users\<username>\AppData\Local\<AppName>
        Win 7  (roaming):       C:\Users\<username>\AppData\Roaming\<AppName>

    For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
    That means, by default "~/.local/share/<AppName>".
    �
CSIDL_APPDATArrz~/Library/Application Support/Z
XDG_DATA_HOMEz~/.local/share)
rr	r
rrrrrrr)r�roaming�constr
rrr�
user_data_dir>s
rTcCsHtrt||d�}n2tjdkr&t|�}ntjdtd��}tjj||�}|S)arReturn full path to the user-specific config dir for this application.

        "appname" is the name of application.
            If None, just the system directory is returned.
        "roaming" (boolean, default True) can be set False to not use the
            Windows roaming appdata directory. That means that for users on a
            Windows network setup for roaming profiles, this user data will be
            sync'd on login. See
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.

    Typical user data directories are:
        macOS:                  same as user_data_dir
        Unix:                   ~/.config/<AppName>
        Win *:                  same as user_data_dir

    For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
    That means, by default "~/.config/<AppName>".
    )rrZXDG_CONFIG_HOMEz	~/.config)	rrrrr	rrr
r)rrr
rrr�user_config_dirjs

rcs�tr&tjjtd��}tjj|��g}nVtjdkrBtjjd��g}n:tjdd�}|rn�fdd�|j	tj
�D�}ng}|jd�|S)	a�Return a list of potential user-shared config dirs for this application.

        "appname" is the name of application.

    Typical user config directories are:
        macOS:      /Library/Application Support/<AppName>/
        Unix:       /etc or $XDG_CONFIG_DIRS[i]/<AppName>/ for each value in
                    $XDG_CONFIG_DIRS
        Win XP:     C:\Documents and Settings\All Users\Application ...
                    ...Data\<AppName>        Vista:      (Fail! "C:\ProgramData" is a hidden *system* directory
                    on Vista.)
        Win 7:      Hidden, but writeable on Win 7:
                    C:\ProgramData\<AppName>    �CSIDL_COMMON_APPDATArz/Library/Application SupportZXDG_CONFIG_DIRSz/etc/xdgcsg|]}tjjt|����qSr)r	r
rr)�.0�x)rrr�
<listcomp>�sz$site_config_dirs.<locals>.<listcomp>z/etc)rr	r
rrrrrr�split�pathsep�append)rr
ZpathlistZxdg_config_dirsr)rr�site_config_dirs�s


r#cCs:ddl}dddd�|}|j|jd�}|j||�\}}|S)z�
    This is a fallback technique at best. I'm not sure if using the
    registry for this guarantees us the correct answer for all CSIDL_*
    names.
    rNZAppDatazCommon AppDataz
Local AppData)rrrz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)�_winreg�OpenKey�HKEY_CURRENT_USERZQueryValueEx)�
csidl_namer$Zshell_folder_name�keyZ	directoryZ_typerrr�_get_win_folder_from_registry�sr)cCs�dddd�|}tjd�}tjjjd|dd|�d}x|D]}t|�dkr:d	}Pq:W|rztjd�}tjjj|j|d�rz|}|jS)
N��#�)rrrirF�T)	�ctypesZcreate_unicode_bufferZwindllZshell32ZSHGetFolderPathW�ordZkernel32ZGetShortPathNameW�value)r'Zcsidl_constZbufZ
has_high_char�cZbuf2rrr�_get_win_folder_with_ctypes�s 


r2c
Cs6x0dD](}y
|j|�Sttfk
r,YqXqW|S)a�Encode Windows paths to bytes. Only used on Python 2.

    Motivation is to be consistent with other operating systems where paths
    are also returned as bytes. This avoids problems mixing bytes and Unicode
    elsewhere in the codebase. For more details and discussion see
    <https://github.com/pypa/pip/issues/3463>.

    If encoding using ASCII and MBCS fails, return the original Unicode path.
    �ASCII�MBCS)r3r4)�encode�UnicodeEncodeError�LookupError)r
�encodingrrrr�s



r)F)T)�__doc__Z
__future__rr	rZ
pip.compatrrZpip._vendor.sixrrrrrr#r)r2r.r�ImportErrorrrrrr�<module>s$0
,
!(
PKY�\ �J��__init__.cpython-36.pycnu�[���3


 \-�@sdZddddgZdS)a�Core XML support for Python.

This package contains four sub-packages:

dom -- The W3C Document Object Model.  This supports DOM Level 1 +
       Namespaces.

parsers -- Python wrappers for XML parsers (currently only supports Expat).

sax -- The Simple API for XML, developed by XML-Dev, led by David
       Megginson and ported to Python by Lars Marius Garshol.  This
       supports the SAX 2 API.

etree -- The ElementTree XML library.  This is a subset of the full
       ElementTree XML release.

ZdomZparsersZsaxZetreeN)�__doc__�__all__�rr�$/usr/lib64/python3.6/xml/__init__.py�<module>sPKY�\:��ggoutdated.cpython-36.pycnu�[���3

�Pfe�@s�ddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
mZmZddlmZddlmZmZddlmZmZdd	lmZd
Zeje�ZGdd�de�ZGd
d�de�Z dd�Z!dd�Z"dd�Z#dS)�)�absolute_importN)�lockfile)�version)�
total_seconds�WINDOWS)�PyPI)�USER_CACHE_DIR�running_under_virtualenv)�
ensure_dir�get_installed_version)�check_path_ownerz%Y-%m-%dT%H:%M:%SZc@seZdZdd�Zdd�ZdS)�VirtualenvSelfCheckStatecCs\tjjtjd�|_y&t|j��}tj|�|_	WdQRXWnt
tfk
rVi|_	YnXdS)Nzpip-selfcheck.json)�os�path�join�sys�prefix�statefile_path�open�json�load�state�IOError�
ValueError)�self�	statefile�r�/usr/lib/python3.6/outdated.py�__init__sz!VirtualenvSelfCheckState.__init__c
Cs:t|jd��$}tj|jt�|d�|ddd�WdQRXdS)N�w)�
last_check�pypi_versionT�,�:)�	sort_keys�
separators)r"r#)rrr�dump�strftime�SELFCHECK_DATE_FMT)rr!�current_timerrrr�save$szVirtualenvSelfCheckState.saveN)�__name__�
__module__�__qualname__rr*rrrrr
s
r
c@seZdZdd�Zdd�ZdS)�GlobalSelfCheckStatecCsbtjjtd�|_y,t|j��}tj|�tj	|_
WdQRXWn ttt
fk
r\i|_
YnXdS)Nzselfcheck.json)rrrrrrrrrrrrr�KeyError)rrrrrr3s zGlobalSelfCheckState.__init__cCs�ttjj|j��sdSttjj|j��tj|j��ztjj|j�rft	|j��}t
j|�}WdQRXni}|jt
�|d�|tj<t	|jd��}t
j||ddd�WdQRXWdQRXdS)N)r r!rTr"r#)r$r%)r"r#)rrr�dirnamerr
rZLockFile�existsrrrr'r(rrr&)rr!r)rrrrrr*=s
zGlobalSelfCheckState.saveN)r+r,r-rr*rrrrr.2s
r.cCst�rt�St�SdS)N)r	r
r.rrrr�load_selfcheck_statefileXsr2cCsFddl}y"|jd�}|jd�o*d|jd�kS|jk
r@dSXdS)z�Checks whether pip was installed by pip

    This is used not to display the upgrade message when pip is in fact
    installed by system package manager, such as dnf on Fedora.
    rN�pipZ	INSTALLERF)�
pkg_resourcesZget_distributionZhas_metadataZget_metadata_linesZDistributionNotFound)r4Zdistrrr�pip_installed_by_pip_s

r5c
CsFtd�}|dkrdStj|�}d}�y�t�}tjj�}d|jkrxd|jkrxtjj|jdt�}t	||�dkrx|jd}|dkr�|j
tjdd	id
�}|j
�dd�tt|j�d
�tjd�D�d}|j||�tj|�}||k�r|j|jk�rt��rt�rd}	nd}	tjd|||	�Wn$tk
�r@tjddd�YnXdS)z�Check for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    r3Nr r!���<ZAcceptzapplication/json)ZheaderscSsg|]}tj|�js|�qSr)�packaging_version�parseZ
is_prerelease)�.0�vrrr�
<listcomp>�sz%pip_version_check.<locals>.<listcomp>Zreleases)�key�z
python -m pipz�You are using pip version %s, however version %s is available.
You should consider upgrading via the '%s install --upgrade pip' command.z5There was an error checking the latest version of pipT)�exc_info�i`'i�:	���)rr9r:r2�datetimeZutcnowrZstrptimer(r�getrZpip_json_urlZraise_for_status�sorted�listrr*Zbase_versionr5r�loggerZwarning�	Exception�debug)
ZsessionZinstalled_versionZpip_versionr!rr)r ZrespZremote_versionZpip_cmdrrr�pip_version_checknsL




rJ)$Z
__future__rrCrZloggingZos.pathrrZpip._vendorrZpip._vendor.packagingrr9Z
pip.compatrrZ
pip.modelsrZ
pip.locationsrr	Z	pip.utilsr
rZpip.utils.filesystemrr(Z	getLoggerr+rG�objectr
r.r2r5rJrrrr�<module>s&
&PKY�\T��44setuptools_build.cpython-36.pycnu�[���3

�Pf�@sdZdS)z�import setuptools, tokenize;__file__=%r;f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))N)ZSETUPTOOLS_SHIM�rr�&/usr/lib/python3.6/setuptools_build.py�<module>sPKY�\��H���hashes.cpython-36.opt-1.pycnu�[���3

�Pf2�@szddlmZddlZddlmZmZmZddlmZddl	m
Z
mZmZdZ
dddgZGd	d
�d
e�ZGdd�de�ZdS)
�)�absolute_importN)�HashMismatch�HashMissing�InstallationError)�read_chunks)�	iteritems�iterkeys�
itervaluesZsha256Zsha384Zsha512c@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�HasheszaA wrapper that builds multiple hashes at once and checks them against
    known-good values

    NcCs|dkrin||_dS)zo
        :param hashes: A dict of algorithm names pointing to lists of allowed
            hex digests
        N)�_allowed)�self�hashes�r�/usr/lib/python3.6/hashes.py�__init__szHashes.__init__c
Cs�i}xJt|j�D]<}ytj|�||<Wqttfk
rJtd|��YqXqWx(|D] }xt|�D]}|j|�qdWqVWx*t	|�D]\}}|j
�|j|kr�dSq�W|j|�dS)z�Check good hashes against ones built from iterable of chunks of
        data.

        Raise HashMismatch if none match.

        zUnknown hash name: %sN)rr�hashlib�new�
ValueError�	TypeErrorrr	�updater�	hexdigest�_raise)rZchunks�gotsZ	hash_name�chunk�hashZgotrrr�check_against_chunks s
zHashes.check_against_chunkscCst|j|��dS)N)rr)rrrrrr7sz
Hashes._raisecCs|jt|��S)zaCheck good hashes against a file-like object

        Raise HashMismatch if none match.

        )rr)r�filerrr�check_against_file:szHashes.check_against_filec	Cs t|d��}|j|�SQRXdS)N�rb)�openr)r�pathrrrr�check_against_pathBszHashes.check_against_pathcCs
t|j�S)z,Return whether I know any known-good hashes.)�boolr)rrrr�__nonzero__FszHashes.__nonzero__cCs|j�S)N)r#)rrrr�__bool__JszHashes.__bool__)N)�__name__�
__module__�__qualname__�__doc__rrrrr!r#r$rrrrr
s
r
cs(eZdZdZ�fdd�Zdd�Z�ZS)�
MissingHashesz�A workalike for Hashes used when we're missing a hash for a requirement

    It computes the actual hash of the requirement and raises a HashMissing
    exception showing it to the user.

    cstt|�jtgid�dS)z!Don't offer the ``hashes`` kwarg.)r
N)�superr)r�
FAVORITE_HASH)r)�	__class__rrrUszMissingHashes.__init__cCst|tj���dS)N)rr+r)rrrrrr[szMissingHashes._raise)r%r&r'r(rr�
__classcell__rr)r,rr)Nsr))Z
__future__rrZpip.exceptionsrrrZ	pip.utilsrZpip._vendor.sixrrr	r+Z
STRONG_HASHES�objectr
r)rrrr�<module>s
:PKY�\�''logging.cpython-36.opt-1.pycnu�[���3

�Pf��@sddlmZddlZddlZddlZddlZyddlZWnek
rTddlZYnXddl	m
Z
ddlmZyddl
mZWnek
r�dZYnXej�Zde_ejddd��Zd	d
�ZGdd�dej�Zd
d�ZGdd�dej�ZGdd�dejj�ZGdd�dej�ZdS)�)�absolute_importN)�WINDOWS)�
ensure_dir)�colorama�ccs.tj|7_z
dVWdtj|8_XdS)zv
    A context manager which will cause the log output to be indented for any
    log messages emitted inside it.
    N)�
_log_state�indentation)Znum�r	�/usr/lib/python3.6/logging.py�
indent_logs
rcCsttdd�S)Nrr)�getattrrr	r	r	r
�get_indentation)sr
c@seZdZdd�ZdS)�IndentingFormattercCs,tjj||�}djdd�|jd�D��}|S)z�
        Calls the standard formatter, but will indent all of the log messages
        by our current indentation level.
        �cSsg|]}dt�|�qS)� )r
)�.0�liner	r	r
�
<listcomp>6sz-IndentingFormatter.format.<locals>.<listcomp>T)�logging�	Formatter�format�join�
splitlines)�self�recordZ	formattedr	r	r
r/s
zIndentingFormatter.formatN)�__name__�
__module__�__qualname__rr	r	r	r
r-srcs�fdd�}|S)Ncsdjt��|tjjg�S)Nr)r�listrZStyleZ	RESET_ALL)Zinp)�colorsr	r
�wrapped=sz_color_wrap.<locals>.wrappedr	)rr r	)rr
�_color_wrap<sr!c@sTeZdZer2ejeejj�fej	eejj
�fgZngZddd�Zdd�Z
dd�ZdS)	�ColorizedStreamHandlerNcCs(tjj||�tr$tr$tj|j�|_dS)N)r�
StreamHandler�__init__rr�AnsiToWin32�stream)rr&r	r	r
r$NszColorizedStreamHandler.__init__cCsRtsdSt|jtj�s|jn|jj}t|d�r:|j�r:dStjj	d�dkrNdSdS)NF�isattyTZTERMZANSI)
r�
isinstancer&r%r �hasattrr'�os�environ�get)rZreal_streamr	r	r
�should_colorTsz#ColorizedStreamHandler.should_colorcCsBtjj||�}|j�r>x&|jD]\}}|j|kr||�}PqW|S)N)rr#rr-�COLORS�levelno)rr�msg�levelZcolorr	r	r
ris
zColorizedStreamHandler.format)N)rrrrrZERRORr!ZForeZREDZWARNINGZYELLOWr.r$r-rr	r	r	r
r"Bs
r"c@seZdZdd�ZdS)�BetterRotatingFileHandlercCs ttjj|j��tjjj|�S)N)	rr*�path�dirnameZbaseFilenamer�handlers�RotatingFileHandler�_open)rr	r	r
r7wszBetterRotatingFileHandler._openN)rrrr7r	r	r	r
r2usr2c@seZdZdd�Zdd�ZdS)�MaxLevelFiltercCs
||_dS)N)r1)rr1r	r	r
r$~szMaxLevelFilter.__init__cCs|j|jkS)N)r/r1)rrr	r	r
�filter�szMaxLevelFilter.filterN)rrrr$r9r	r	r	r
r8|sr8)r) Z
__future__r�
contextlibrZlogging.handlersr*Z	threading�ImportErrorZdummy_threadingZ
pip.compatrZ	pip.utilsrZpip._vendorr�	ExceptionZlocalrr�contextmanagerrr
rrr!r#r"r5r6r2�Filterr8r	r	r	r
�<module>s0
3PKY�\b#�-�� deprecation.cpython-36.opt-1.pycnu�[���3

�Pf��@s�dZddlmZddlZddlZGdd�de�ZGdd�de�ZGdd	�d	e�Z	Gd
d�dee�Z
Gdd
�d
e�Zdaddd�Z
dd�ZdS)zN
A module that implements tooling to enable easy warnings about deprecations.
�)�absolute_importNc@seZdZdS)�PipDeprecationWarningN)�__name__�
__module__�__qualname__�rr�!/usr/lib/python3.6/deprecation.pyr
src@seZdZdS)�PendingN)rrrrrrrr	sr	c@seZdZdS)�RemovedInPip10WarningN)rrrrrrrr
sr
c@seZdZdS)�RemovedInPip11WarningN)rrrrrrrrsrc@seZdZdS)�Python26DeprecationWarningN)rrrrrrrrsrcCsx|dk	r$tdk	rtt||||||�nPt|t�rbtjd�}d|}t|t�rV|j|�qt|j|�nt||||||�dS)Nzpip.deprecationszDEPRECATION: %s)�_warnings_showwarning�
issubclassr�loggingZ	getLoggerr	Zwarning�error)�message�category�filename�lineno�file�lineZloggerZlog_messagerrr�_showwarning$s


rcCs(tjdtdd�tdkr$tjatt_dS)N�defaultT)�append)�warnings�simplefilterrr
�showwarningrrrrr�install_warning_loggerDsr)NN)�__doc__Z
__future__rrr�Warningr�objectr	r
rrr
rrrrrr�<module>s
 PKY�\a �44filesystem.cpython-36.opt-1.pycnu�[���3

�Pf��@s(ddlZddlZddlmZdd�ZdS)�N)�get_path_uidcCs�ttd�sdSd}xp||kr�tjj|�rntj�dkr^yt|�}Wntk
rTdSX|dkStj|tj�Sq|tjj	|�}}qWdS)N�geteuidTrF)
�hasattr�os�path�lexistsrr�OSError�access�W_OK�dirname)rZpreviousZpath_uid�r� /usr/lib/python3.6/filesystem.py�check_path_owners

r)rZos.pathZ
pip.compatrrrrrr
�<module>sPKY�\b#�-��deprecation.cpython-36.pycnu�[���3

�Pf��@s�dZddlmZddlZddlZGdd�de�ZGdd�de�ZGdd	�d	e�Z	Gd
d�dee�Z
Gdd
�d
e�Zdaddd�Z
dd�ZdS)zN
A module that implements tooling to enable easy warnings about deprecations.
�)�absolute_importNc@seZdZdS)�PipDeprecationWarningN)�__name__�
__module__�__qualname__�rr�!/usr/lib/python3.6/deprecation.pyr
src@seZdZdS)�PendingN)rrrrrrrr	sr	c@seZdZdS)�RemovedInPip10WarningN)rrrrrrrr
sr
c@seZdZdS)�RemovedInPip11WarningN)rrrrrrrrsrc@seZdZdS)�Python26DeprecationWarningN)rrrrrrrrsrcCsx|dk	r$tdk	rtt||||||�nPt|t�rbtjd�}d|}t|t�rV|j|�qt|j|�nt||||||�dS)Nzpip.deprecationszDEPRECATION: %s)�_warnings_showwarning�
issubclassr�loggingZ	getLoggerr	Zwarning�error)�message�category�filename�lineno�file�lineZloggerZlog_messagerrr�_showwarning$s


rcCs(tjdtdd�tdkr$tjatt_dS)N�defaultT)�append)�warnings�simplefilterrr
�showwarningrrrrr�install_warning_loggerDsr)NN)�__doc__Z
__future__rrr�Warningr�objectr	r
rrr
rrrrrr�<module>s
 PKY�\ �J��__init__.cpython-36.opt-1.pycnu�[���3


 \-�@sdZddddgZdS)a�Core XML support for Python.

This package contains four sub-packages:

dom -- The W3C Document Object Model.  This supports DOM Level 1 +
       Namespaces.

parsers -- Python wrappers for XML parsers (currently only supports Expat).

sax -- The Simple API for XML, developed by XML-Dev, led by David
       Megginson and ported to Python by Lars Marius Garshol.  This
       supports the SAX 2 API.

etree -- The ElementTree XML library.  This is a subset of the full
       ElementTree XML release.

ZdomZparsersZsaxZetreeN)�__doc__�__all__�rr�$/usr/lib64/python3.6/xml/__init__.py�<module>sPKY�\���~build.cpython-36.opt-1.pycnu�[���3

�Pf �@s<ddlmZddlZddlZddlmZGdd�de�ZdS)�)�absolute_importN)�rmtreec@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�BuildDirectoryNcCsL|dkr|dkrd}|dkr<tjjtjdd��}|dkr<d}||_||_dS)NTz
pip-build-)�prefix)�os�path�realpath�tempfileZmkdtemp�name�delete)�selfr
r�r
�/usr/lib/python3.6/build.py�__init__szBuildDirectory.__init__cCsdj|jj|j�S)Nz	<{} {!r}>)�format�	__class__�__name__r
)rr
r
r�__repr__szBuildDirectory.__repr__cCs|jS)N)r
)rr
r
r�	__enter__"szBuildDirectory.__enter__cCs|j�dS)N)�cleanup)r�exc�value�tbr
r
r�__exit__%szBuildDirectory.__exit__cCs|jrt|j�dS)N)rrr
)rr
r
rr(szBuildDirectory.cleanup)NN)r�
__module__�__qualname__rrrrrr
r
r
rr	s

r)	Z
__future__rZos.pathrr	Z	pip.utilsr�objectrr
r
r
r�<module>sPKY�\T��44%setuptools_build.cpython-36.opt-1.pycnu�[���3

�Pf�@sdZdS)z�import setuptools, tokenize;__file__=%r;f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))N)ZSETUPTOOLS_SHIM�rr�&/usr/lib/python3.6/setuptools_build.py�<module>sPKY�\2��eappdirs.cpython-36.opt-1.pycnu�[���3

�Pfk"�@s�dZddlmZddlZddlZddlmZmZddlm	Z	m
Z
dd�Zdd	d
�Zddd
�Z
dd�Zdd�Zdd�Zer�yddlZeZWnek
r�eZYnXdd�ZdS)zd
This code was taken from https://github.com/ActiveState/appdirs and modified
to suit our purposes.
�)�absolute_importN)�WINDOWS�
expanduser)�PY2�	text_typecCs�tr<tjjtd��}tr*t|t�r*t|�}tjj	||d�}n@t
jdkr^td�}tjj	||�}ntj
dtd��}tjj	||�}|S)a5
    Return full path to the user-specific cache dir for this application.

        "appname" is the name of application.

    Typical user cache directories are:
        macOS:      ~/Library/Caches/<AppName>
        Unix:       ~/.cache/<AppName> (XDG default)
        Windows:    C:\Users\<username>\AppData\Local\<AppName>\Cache

    On Windows the only suggestion in the MSDN docs is that local settings go
    in the `CSIDL_LOCAL_APPDATA` directory. This is identical to the
    non-roaming app data dir (the default returned by `user_data_dir`). Apps
    typically put cache data somewhere *under* the given dir here. Some
    examples:
        ...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
        ...\Acme\SuperApp\Cache\1.0

    OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
    �CSIDL_LOCAL_APPDATAZCache�darwinz~/Library/CachesZXDG_CACHE_HOMEz~/.cache)r�os�path�normpath�_get_win_folderr�
isinstancer�_win_path_to_bytes�join�sys�platformr�getenv)�appnamer
�r�/usr/lib/python3.6/appdirs.py�user_cache_dirs
rFcCshtr,|rdpd}tjjtjjt|��|�}n8tjdkrJtjjtd�|�}ntjjtj	dtd��|�}|S)aS
    Return full path to the user-specific data dir for this application.

        "appname" is the name of application.
            If None, just the system directory is returned.
        "roaming" (boolean, default False) can be set True to use the Windows
            roaming appdata directory. That means that for users on a Windows
            network setup for roaming profiles, this user data will be
            sync'd on login. See
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.

    Typical user data directories are:
        macOS:                  ~/Library/Application Support/<AppName>
        Unix:                   ~/.local/share/<AppName>    # or in
                                $XDG_DATA_HOME, if defined
        Win XP (not roaming):   C:\Documents and Settings\<username>\ ...
                                ...Application Data\<AppName>
        Win XP (roaming):       C:\Documents and Settings\<username>\Local ...
                                ...Settings\Application Data\<AppName>
        Win 7  (not roaming):   C:\Users\<username>\AppData\Local\<AppName>
        Win 7  (roaming):       C:\Users\<username>\AppData\Roaming\<AppName>

    For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
    That means, by default "~/.local/share/<AppName>".
    �
CSIDL_APPDATArrz~/Library/Application Support/Z
XDG_DATA_HOMEz~/.local/share)
rr	r
rrrrrrr)r�roaming�constr
rrr�
user_data_dir>s
rTcCsHtrt||d�}n2tjdkr&t|�}ntjdtd��}tjj||�}|S)arReturn full path to the user-specific config dir for this application.

        "appname" is the name of application.
            If None, just the system directory is returned.
        "roaming" (boolean, default True) can be set False to not use the
            Windows roaming appdata directory. That means that for users on a
            Windows network setup for roaming profiles, this user data will be
            sync'd on login. See
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.

    Typical user data directories are:
        macOS:                  same as user_data_dir
        Unix:                   ~/.config/<AppName>
        Win *:                  same as user_data_dir

    For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
    That means, by default "~/.config/<AppName>".
    )rrZXDG_CONFIG_HOMEz	~/.config)	rrrrr	rrr
r)rrr
rrr�user_config_dirjs

rcs�tr&tjjtd��}tjj|��g}nVtjdkrBtjjd��g}n:tjdd�}|rn�fdd�|j	tj
�D�}ng}|jd�|S)	a�Return a list of potential user-shared config dirs for this application.

        "appname" is the name of application.

    Typical user config directories are:
        macOS:      /Library/Application Support/<AppName>/
        Unix:       /etc or $XDG_CONFIG_DIRS[i]/<AppName>/ for each value in
                    $XDG_CONFIG_DIRS
        Win XP:     C:\Documents and Settings\All Users\Application ...
                    ...Data\<AppName>        Vista:      (Fail! "C:\ProgramData" is a hidden *system* directory
                    on Vista.)
        Win 7:      Hidden, but writeable on Win 7:
                    C:\ProgramData\<AppName>    �CSIDL_COMMON_APPDATArz/Library/Application SupportZXDG_CONFIG_DIRSz/etc/xdgcsg|]}tjjt|����qSr)r	r
rr)�.0�x)rrr�
<listcomp>�sz$site_config_dirs.<locals>.<listcomp>z/etc)rr	r
rrrrrr�split�pathsep�append)rr
ZpathlistZxdg_config_dirsr)rr�site_config_dirs�s


r#cCs:ddl}dddd�|}|j|jd�}|j||�\}}|S)z�
    This is a fallback technique at best. I'm not sure if using the
    registry for this guarantees us the correct answer for all CSIDL_*
    names.
    rNZAppDatazCommon AppDataz
Local AppData)rrrz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)�_winreg�OpenKey�HKEY_CURRENT_USERZQueryValueEx)�
csidl_namer$Zshell_folder_name�keyZ	directoryZ_typerrr�_get_win_folder_from_registry�sr)cCs�dddd�|}tjd�}tjjjd|dd|�d}x|D]}t|�dkr:d	}Pq:W|rztjd�}tjjj|j|d�rz|}|jS)
N��#�)rrrirF�T)	�ctypesZcreate_unicode_bufferZwindllZshell32ZSHGetFolderPathW�ordZkernel32ZGetShortPathNameW�value)r'Zcsidl_constZbufZ
has_high_char�cZbuf2rrr�_get_win_folder_with_ctypes�s 


r2c
Cs6x0dD](}y
|j|�Sttfk
r,YqXqW|S)a�Encode Windows paths to bytes. Only used on Python 2.

    Motivation is to be consistent with other operating systems where paths
    are also returned as bytes. This avoids problems mixing bytes and Unicode
    elsewhere in the codebase. For more details and discussion see
    <https://github.com/pypa/pip/issues/3463>.

    If encoding using ASCII and MBCS fails, return the original Unicode path.
    �ASCII�MBCS)r3r4)�encode�UnicodeEncodeError�LookupError)r
�encodingrrrr�s



r)F)T)�__doc__Z
__future__rr	rZ
pip.compatrrZpip._vendor.sixrrrrrr#r)r2r.r�ImportErrorrrrrr�<module>s$0
,
!(
PKY�\j���!%!%ui.cpython-36.opt-1.pycnu�[���3

�PfM-�@s�ddlmZddlmZddlZddlZddlmZmZmZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZdd	lmZmZdd
lmZmZmZddlmZyddlmZWnek
r�dZYnXe
je�Z d
d�Z!e!ee�Z"Gdd�de#�Z$Gdd�de#�Z%Gdd�de#�Z&Gdd�de&e$e%e"�Z'Gdd�de&e$e%ee�Z(e	j)dd��Z*Gdd�de#�Z+Gdd�de#�Z,Gdd �d e#�Z-e	j)d!d"��Z.dS)#�)�absolute_import)�divisionN)�signal�SIGINT�default_int_handler)�WINDOWS)�format_size)�get_indentation)�six)�Bar�IncrementalBar)�WritelnMixin�HIDE_CURSOR�SHOW_CURSOR)�Spinner)�coloramacCs�t|jdd�}|s|St|dtj��t|dtj��g}|tt|dg��7}ytj�j|�j|�Wntk
rv|SX|SdS)N�encodingZ
empty_fillZfill�phases)�getattr�filer
Z	text_type�list�join�encode�UnicodeEncodeError)Z	preferredZfallbackrZ
characters�r�/usr/lib/python3.6/ui.py�_select_progress_classsrcs4eZdZdZ�fdd�Z�fdd�Zdd�Z�ZS)�InterruptibleMixina�
    Helper to ensure that self.finish() gets called on keyboard interrupt.

    This allows downloads to be interrupted without leaving temporary state
    (like hidden cursors) behind.

    This class is similar to the progress library's existing SigIntMixin
    helper, but as of version 1.2, that helper has the following problems:

    1. It calls sys.exit().
    2. It discards the existing SIGINT handler completely.
    3. It leaves its own handler in place even after an uninterrupted finish,
       which will have unexpected delayed effects if the user triggers an
       unrelated keyboard interrupt some time after a progress-displaying
       download has already completed, for example.
    cs4tt|�j||�tt|j�|_|jdkr0t|_dS)z=
        Save the original SIGINT handler for later.
        N)�superr�__init__rr�
handle_sigint�original_handlerr)�self�args�kwargs)�	__class__rrrNs
zInterruptibleMixin.__init__cstt|�j�tt|j�dS)z�
        Restore the original SIGINT handler after finishing.

        This should happen regardless of whether the progress display finishes
        normally, or gets interrupted.
        N)rr�finishrrr!)r")r%rrr&^szInterruptibleMixin.finishcCs|j�|j||�dS)z�
        Call self.finish() before delegating to the original SIGINT handler.

        This handler should only be in place while the progress display is
        active.
        N)r&r!)r"Zsignum�framerrrr hsz InterruptibleMixin.handle_sigint)�__name__�
__module__�__qualname__�__doc__rr&r �
__classcell__rr)r%rr<s
rcsJeZdZ�fdd�Zedd��Zedd��Zedd��Zdd
d�Z�Z	S)
�DownloadProgressMixincs,tt|�j||�dt�d|j|_dS)N� �)rr-rr	�message)r"r#r$)r%rrruszDownloadProgressMixin.__init__cCs
t|j�S)N)r�index)r"rrr�
downloadedysz DownloadProgressMixin.downloadedcCs |jdkrdStd|j�dS)Ngz...�z/s)Zavgr)r"rrr�download_speed}s
z$DownloadProgressMixin.download_speedcCs|jrd|jSdS)Nzeta %s�)ZetaZeta_td)r"rrr�
pretty_eta�s
z DownloadProgressMixin.pretty_etar3ccs*x|D]}|V|j|�qW|j�dS)N)�nextr&)r"�it�n�xrrr�iter�s
zDownloadProgressMixin.iter)r3)
r(r)r*r�propertyr2r4r6r;r,rr)r%rr-ss
r-cseZdZ�fdd�Z�ZS)�WindowsMixincs\tr�jrd�_tt��j||�trXtrXtj�j��_�fdd��j_�fdd��j_	dS)NFcs�jjj�S)N)r�wrapped�isattyr)r"rr�<lambda>�sz'WindowsMixin.__init__.<locals>.<lambda>cs�jjj�S)N)rr>�flushr)r"rrr@�s)
rZhide_cursorrr=rrZAnsiToWin32rr?rA)r"r#r$)r%)r"rr�s
zWindowsMixin.__init__)r(r)r*rr,rr)r%rr=�sr=c@seZdZejZdZdZdS)�DownloadProgressBarz
%(percent)d%%z0%(downloaded)s %(download_speed)s %(pretty_eta)sN)r(r)r*�sys�stdoutrr0�suffixrrrrrB�srBc@s&eZdZejZdZdd�Zdd�ZdS)�DownloadProgressSpinnerz!%(downloaded)s %(download_speed)scCs"t|d�stj|j�|_t|j�S)N�_phaser)�hasattr�	itertools�cyclerrGr7)r"rrr�
next_phase�s
z"DownloadProgressSpinner.next_phasecCsN|j|}|j�}|j|}dj||r*dnd||r6dnd|g�}|j|�dS)Nr5r.)r0rKrErZwriteln)r"r0ZphaserE�linerrr�update�s



zDownloadProgressSpinner.updateN)	r(r)r*rCrDrrErKrMrrrrrF�srFccsRtrdVnB|j�s$tj�tjkr,dVn"|jt�z
dVWd|jt�XdS)N)	rr?�logger�getEffectiveLevel�logging�INFO�writerr)rrrr�
hidden_cursor�s

rSc@s$eZdZdd�Zdd�Zdd�ZdS)�RateLimitercCs||_d|_dS)Nr)�_min_update_interval_seconds�_last_update)r"�min_update_interval_secondsrrrr�szRateLimiter.__init__cCstj�}||j}||jkS)N)�timerVrU)r"ZnowZdeltarrr�ready�s
zRateLimiter.readycCstj�|_dS)N)rXrV)r"rrr�reset�szRateLimiter.resetN)r(r)r*rrYrZrrrrrT�srTc@s.eZdZddd�Zdd�Zdd	�Zd
d�ZdS)
�InteractiveSpinnerN�-\|/��?cCs\||_|dkrtj}||_t|�|_d|_tj|�|_	|jj
dt�|jd�d|_dS)NFr.z ... r)
�_messagerCrD�_filerT�
_rate_limiter�	_finishedrIrJ�_spin_cyclerRr	�_width)r"r0rZ
spin_charsrWrrrr�s
zInteractiveSpinner.__init__cCsRd|j}|jj|d|j|�|jj|�t|�|_|jj�|jj�dS)N�r.)rcr_rR�lenrAr`rZ)r"�statusZbackuprrr�_write	s


zInteractiveSpinner._writecCs,|jr
dS|jj�sdS|jt|j��dS)N)rar`rYrgr7rb)r"rrr�spins

zInteractiveSpinner.spincCs4|jr
dS|j|�|jjd�|jj�d|_dS)N�
T)rargr_rRrA)r"�final_statusrrrr&s

zInteractiveSpinner.finish)Nr\r])r(r)r*rrgrhr&rrrrr[�s


r[c@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)�NonInteractiveSpinner�<cCs$||_d|_t|�|_|jd�dS)NFZstarted)r^rarTr`�_update)r"r0rWrrrr*s
zNonInteractiveSpinner.__init__cCs|jj�tjd|j|�dS)Nz%s: %s)r`rZrN�infor^)r"rfrrrrm0s
zNonInteractiveSpinner._updatecCs&|jr
dS|jj�sdS|jd�dS)Nzstill running...)rar`rYrm)r"rrrrh5s

zNonInteractiveSpinner.spincCs$|jr
dS|jd|f�d|_dS)Nzfinished with status '%s'T)rarm)r"rjrrrr&<szNonInteractiveSpinner.finishN)rl)r(r)r*rrmrhr&rrrrrk)s
rkccs�tjj�r"tj�tjkr"t|�}nt|�}y t	tj��|VWdQRXWn>t
k
rj|jd��Yn*tk
r�|jd��YnX|jd�dS)NZcanceled�error�done)
rCrDr?rNrOrPrQr[rkrS�KeyboardInterruptr&�	Exception)r0Zspinnerrrr�open_spinnerCs


rs)/Z
__future__rrrIrCrrrrX�
contextlibrPZ
pip.compatrZ	pip.utilsrZpip.utils.loggingr	Zpip._vendorr
Zpip._vendor.progress.barrrZpip._vendor.progress.helpersr
rrZpip._vendor.progress.spinnerrrrrZ	getLoggerr(rNrZ_BaseBar�objectrr-r=rBrF�contextmanagerrSrTr[rkrsrrrr�<module>sB


7
!0PK�"�\7����charset.cpython-38.opt-2.pycnu�[���U

e5d�B�@srddddgZddlmZddlZddlZddlmZddlmZd	Z	d
Z
dZdZd
Z
dZdZe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfde
e
dfe
e
dfe
ddfe
ddfe
ddfe
e
dfee
dfd�Zddddddddddddddddddddddd d
d!�Zd"d#dd$�Zd+d%d�Zd&d�Zd'd�Zd(d)�ZGd*d�d�ZdS),�Charset�	add_alias�add_charset�	add_codec�)�partialN)�errors)�encode_7or8bit�����us-asciizunknown-8bit�)NNN�iso-2022-jp�utf-8)�
iso-8859-1�
iso-8859-2�
iso-8859-3�
iso-8859-4�
iso-8859-9�iso-8859-10�iso-8859-13�iso-8859-14�iso-8859-15�iso-8859-16zwindows-1252Zvisciir
�big5�gb2312�euc-jp�	shift_jisrzkoi8-rrrrrrrrrrrrzks_c_5601-1987rzeuc-kr)�latin_1zlatin-1Zlatin_2zlatin-2Zlatin_3zlatin-3Zlatin_4zlatin-4Zlatin_5zlatin-5Zlatin_6zlatin-6Zlatin_7zlatin-7Zlatin_8zlatin-8Zlatin_9zlatin-9Zlatin_10zlatin-10�cp949�euc_jp�euc_kr�ascii�eucgb2312_cn�big5_tw)rrr
cCs"|tkrtd��|||ft|<dS)Nz!SHORTEST not allowed for body_enc)�SHORTEST�
ValueError�CHARSETS)�charsetZ
header_encZbody_enc�output_charset�r+�%/usr/lib64/python3.8/email/charset.pyrmscCs|t|<dS�N)�ALIASES)�aliasZ	canonicalr+r+r,r�scCs|t|<dSr-)�	CODEC_MAP)r)Z	codecnamer+r+r,r�scCs"|tkr|�dd�S|�|�SdS)Nr#�surrogateescape)�UNKNOWN8BIT�encode)�string�codecr+r+r,�_encode�sr6c@sXeZdZefdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rcCs�z$t|t�r|�d�n
t|d�}Wntk
rBt�|��YnX|��}t�||�|_	t
�|j	ttdf�\}}}|s~|j	}||_
||_t�||�|_t�|j	|j	�|_t�|j|j�|_dS)Nr#)�
isinstance�strr3�UnicodeErrorrZCharsetError�lowerr.�get�
input_charsetr(r&�BASE64�header_encoding�
body_encodingr*r0Zinput_codec�output_codec)�selfr<ZhencZbencZconvr+r+r,�__init__�s,
�
��zCharset.__init__cCs
|j��Sr-)r<r:�rAr+r+r,�__repr__�szCharset.__repr__cCst|�t|���kSr-)r8r:)rA�otherr+r+r,�__eq__�szCharset.__eq__cCs$|jtkrdS|jtkrdStSdS)Nzquoted-printable�base64)r?�QPr=rrCr+r+r,�get_body_encoding�s


zCharset.get_body_encodingcCs|jp
|jSr-)r*r<rCr+r+r,�get_output_charsetszCharset.get_output_charsetcCs6|jpd}t||�}|�|�}|dkr*|S|�||�S)Nr
)r@r6�_get_encoder�
header_encode)rAr4r5�header_bytes�encoder_moduler+r+r,rLs


zCharset.header_encodecCs|jpd}t||�}|�|�}t|j|d�}|��}t|�t}g}	g}
t|�|}|D]�}|
�	|�t
�|
�}
|�t|
|��}||krX|
�
�|	s�|
s�|	�	d�n.|	r�dnd}t
�|
�}t||�}|	�	||��|g}
t|�|}qXt
�|
�}t||�}|	�	||��|	S)Nr
)r)� r)r@r6rKrrLrJ�len�RFC2047_CHROME_LEN�next�append�EMPTYSTRING�join�
header_length�pop)rAr4Z
maxlengthsr5rMrN�encoderr)Zextra�linesZcurrent_line�maxlen�	characterZ	this_lineZlengthZ	separatorZjoined_liner+r+r,�header_encode_lines*s6








zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtj�|�}tj�|�}||krPtjStjSndSdSr-)r>r=�email�
base64mimerH�
quoprimimer&rV)rArMZlen64Zlenqpr+r+r,rKhs


zCharset._get_encodercCs�|s|S|jtkr4t|t�r(|�|j�}tj�|�S|jt	krjt|t�rT|�|j�}|�
d�}tj�|�St|t�r�|�|j��
d�}|SdS)N�latin1r#)r?r=r7r8r3r*r]r^�body_encoderH�decoder_)rAr4r+r+r,raws	





zCharset.body_encodeN)
�__name__�
__module__�__qualname__�DEFAULT_CHARSETrBrDrFrIrJrLr\rKrar+r+r+r,r�s,!>)NNN)�__all__�	functoolsrZemail.base64mimer]Zemail.quoprimimerZemail.encodersrrHr=r&rQrfr2rTr(r.r0rrrr6rr+r+r+r,�<module>s��� ��
	
PK�"�\�إ����message.cpython-38.pycnu�[���U

e5d��@s�dZddgZddlZddlZddlZddlmZmZddlm	Z	ddlm
Z
ddlmZm
Z
dd	lmZdd
lmZejZdZe�d�Zd
d�Zddd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZdS)z8Basic message object for the email package object model.�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�Policy�compat32��charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]cCs4t|��d�\}}}|s$|��dfS|��|��fS)N�;)�str�	partition�strip)�param�a�sep�b�r�%/usr/lib64/python3.8/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}t�|d|d|d�}d||fSz|�d�Wn6tk
r�|d7}t�|dd	�}d||fYSX|s�t�|�r�d
|t�	|�fSd||fSn|SdS)a~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.  If value is a
    three tuple (charset, language, value), it will be encoded according
    to RFC2231 rules.  If it contains non-ascii characters it will likewise
    be encoded according to RFC2231 rules, using the utf-8 charset and
    a null language.
    Nr�*���%s=%s�asciizutf-8�z%s="%s")
�len�
isinstance�tuplerZencode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer%rrr�_formatparam's	
r'cCs�dt|�}g}|dd�dkr�|dd�}|�d�}|dkrp|�dd|�|�dd|�drp|�d|d�}q6|dkr�t|�}|d|�}d|kr�|�d�}|d|�����d||dd���}|�|���||d�}q|S)Nr
rr�"z\"r�=)r�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
(
,r3cCs4t|t�r&|d|dt�|d�fSt�|�SdS)Nrrr)rr r�unquote)r&rrr�
_unquotevalue]s
r5c@s�eZdZdZefdd�Zdd�Zddd	d
�Zdd�Zded
d�Z	dd�Z
dd�Zdd�Zdd�Z
dfdd�Zdgdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zdhd1d2�Zd3d4�Zd5d6�Zdid7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&djdKdL�Z'dkdMdN�Z(dldQdR�Z)dmdSdT�Z*dndUdV�Z+dodWdX�Z,dpdYdZ�Z-d[d\�Z.dqd]d^�Z/drd_d`�Z0dadb�Z1ddcl2m3Z3dS)sra�Basic message object.

    A message object is defined as something that has a bunch of RFC 2822
    headers and a payload.  It may optionally have an envelope header
    (a.k.a. Unix-From or From_ header).  If the message is a container (i.e. a
    multipart or a message/rfc822), then the payload is a list of Message
    objects, otherwise it is a string.

    Message objects implement part of the `mapping' interface, which assumes
    there is exactly one occurrence of the header per message.  Some headers
    do in fact appear multiple times (e.g. Received) and for those headers,
    you must use the explicit API to set or get all the headers.  Not all of
    the mapping methods are implemented.
    cCs:||_g|_d|_d|_d|_d|_|_g|_d|_dS)N�
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr7rrr�__init__xszMessage.__init__cCs|��S)z9Return the entire formatted message as a string.
        )�	as_string�r>rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|��S)a�Return the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  For backward compatibility reasons, if maxheaderlen is
        not specified it defaults to 0, so you must override it explicitly
        if you want a different maxheaderlen.  'policy' is passed to the
        Generator instance used to serialize the message; if it is not
        specified the policy associated with the message instance is used.

        If the message object contains binary data that is not encoded
        according to RFC standards, the non-compliant data will be replaced by
        unicode "unknown character" code points.
        r)�	GeneratorNF)�mangle_from_�maxheaderlenr7��unixfrom)�email.generatorrCr7r�flatten�getvalue)r>rGrEr7rC�fp�grrrr@�s�zMessage.as_stringcCs|��S)z?Return the entire formatted message as a bytes object.
        )�as_bytesrArrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|��S)aJReturn the entire formatted message as a bytes object.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  'policy' is passed to the BytesGenerator instance used to
        serialize the message; if not specified the policy associated with
        the message instance is used.
        r)�BytesGeneratorNF)rDr7rF)rHrOr7rrIrJ)r>rGr7rOrKrLrrrrM�szMessage.as_bytescCst|jt�S)z6Return True if the message consists of multiple parts.)rr:�listrArrr�is_multipart�szMessage.is_multipartcCs
||_dS�N�r9)r>rGrrr�set_unixfrom�szMessage.set_unixfromcCs|jSrRrSrArrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.z|j�|�Wntk
r@td��YnXdS)z�Add the given payload to the current payload.

        The current payload will always be a list of objects after this method
        is called.  If you want to set the payload to a scalar object, use
        set_payload() instead.
        Nz=Attach is not valid on a message with a non-multipart payload)r:r.�AttributeError�	TypeError)r>�payloadrrr�attach�s

zMessage.attachcCs�|��r(|rdS|dkr|jS|j|S|dk	rNt|jt�sNtdt|j���|j}t|�dd����}t|t�r�t	�
|�r�|�dd�}|s�z|�|�
dd�d�}Wq�tk
r�|�dd�}Yq�Xn2|r�z|�d�}Wntk
r�|�d	�}YnX|�s|S|d
k�rt�|�S|dk�rVtd�|����\}}|D]}|j�||��q<|S|d
k�r�t|�}	t�}
ztj|	|
dd�|
��WStjk
�r�|YSXt|t��r�|S|S)aZReturn a reference to the payload.

        The payload will either be a list object or a string.  If you mutate
        the list object, you modify the message's payload in place.  Optional
        i returns that index into the payload.

        Optional decode is a flag indicating whether the payload should be
        decoded or not, according to the Content-Transfer-Encoding header
        (default is False).

        When True and the message is not a multipart, the payload will be
        decoded if this header's value is `quoted-printable' or `base64'.  If
        some other encoding is used, or the header is missing, or if the
        payload has bogus data (i.e. bogus base64 or uuencoded data), the
        payload is returned as-is.

        If the message is a multipart and the decode flag is True, then None
        is returned.
        NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper�replace�raw-unicode-escapezquoted-printable�base64�)z
x-uuencodeZuuencodeZuuezx-uueT)�quiet)rQr:rrPrW�typer�getr-rZ_has_surrogatesr!�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr7Z
handle_defectr�uurJ�Error)r>r2rbrX�cteZbpayloadr&r<ZdefectZin_fileZout_filerrr�get_payload�sV"








zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|�|j�}t|d�rT|�dd�|_n||_|dk	rl|�|�dS)z�Set the payload to the given value.

        Optional charset sets the message's default character set.  See
        set_charset() for details.
        r!NrbrrZ)�hasattrr:r�Charsetr!�output_charsetrb�set_charset)r>rXrrrr�set_payload/s


zMessage.set_payloadcCs|dkr|�d�d|_dSt|t�s.t|�}||_d|krH|�dd�d|krf|jdd|��d�n|�d|���||��kr�|�|j�|_d|k�r|�	�}z||�Wnjt
k
�r|j}|r�z|�d	d
�}Wn tk
r�|�|j
�}YnX|�|�|_|�d|�YnXdS)a�Set the charset of the payload to a given character set.

        charset can be a Charset instance, a string naming a character set, or
        None.  If it is a string it will be converted to a Charset instance.
        If charset is None, the charset parameter will be removed from the
        Content-Type field.  Anything else will generate a TypeError.

        The message will be assumed to be of type text/* encoded with
        charset.input_charset.  It will be converted to charset.output_charset
        and encoded properly, if needed, when generating the plain text
        representation of the message.  MIME headers (MIME-Version,
        Content-Type, Content-Transfer-Encoding) will be added as needed.
        Nr�MIME-Version�1.0�Content-Typer6r
zContent-Transfer-EncodingrrZ)�	del_paramr;rrn�
add_headerZget_output_charset�	set_paramZbody_encoder:Zget_body_encodingrWr!rero)r>rrkrXrrrrpCs:

�
zMessage.set_charsetcCs|jS)zKReturn the Charset instance associated with the message's payload.
        )r;rArrr�get_charsetrszMessage.get_charsetcCs
t|j�S)z9Return the total number of headers, including duplicates.)rr8rArrr�__len__zszMessage.__len__cCs
|�|�S)a-Get a header value.

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, exactly which
        occurrence gets returned is undefined.  Use get_all() to get all
        the values matching a header field name.
        )ra�r>�namerrr�__getitem__~s	zMessage.__getitem__cCsr|j�|�}|rX|��}d}|jD]4\}}|��|kr"|d7}||kr"td�||���q"|j�|j�||��dS)z�Set the value of a header.

        Note: this does not overwrite an existing header with the same field
        name.  Use __delitem__() first to delete any existing headers.
        rrz/There may be at most {} {} headers in a messageN)r7Zheader_max_countr-r8�
ValueError�formatr.�header_store_parse)r>r{�valZ	max_countZlname�found�k�vrrr�__setitem__�s�zMessage.__setitem__cCs@|��}g}|jD]"\}}|��|kr|�||f�q||_dS)zwDelete all occurrences of a header, if present.

        Does not raise an exception if the header is missing.
        N)r-r8r.)r>r{�
newheadersr�r�rrr�__delitem__�szMessage.__delitem__cCs|��dd�|jD�kS)NcSsg|]\}}|���qSr)r-��.0r�r�rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r-r8rzrrr�__contains__�szMessage.__contains__ccs|jD]\}}|VqdSrR�r8)r>Zfieldr&rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)a.Return a list of all the message's header field names.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSrrr�rrrr��sz Message.keys.<locals>.<listcomp>r�rArrr�keys�szMessage.keyscs�fdd��jD�S)a)Return a list of all the message's header values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        csg|]\}}�j�||��qSr�r7�header_fetch_parser�rArrr��s�z"Message.values.<locals>.<listcomp>r�rArrAr�values�s
�zMessage.valuescs�fdd��jD�S)a'Get all the message's header fields and values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cs"g|]\}}|�j�||�f�qSrr�r�rArrr��s�z!Message.items.<locals>.<listcomp>r�rArrAr�items�s
�z
Message.itemscCs:|��}|jD]&\}}|��|kr|j�||�Sq|S)z~Get a header value.

        Like __getitem__() but return failobj instead of None when the field
        is missing.
        )r-r8r7r�)r>r{�failobjr�r�rrrra�s
zMessage.getcCs|j�||f�dS)z�Store name and value in the model without modification.

        This is an "internal" API, intended only for use by a parser.
        N)r8r.)r>r{r&rrr�set_raw�szMessage.set_rawcCst|j���S)z�Return the (name, value) header pairs without modification.

        This is an "internal" API, intended only for use by a generator.
        )�iterr8�copyrArrr�	raw_items�szMessage.raw_itemscCsHg}|��}|jD](\}}|��|kr|�|j�||��q|sD|S|S)aQReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original
        message, and may contain duplicates.  Any fields deleted and
        re-inserted are always appended to the header list.

        If no such fields exist, failobj is returned (defaults to None).
        )r-r8r.r7r�)r>r{r�r�r�r�rrr�get_all�s	zMessage.get_allcKspg}|��D]<\}}|dkr0|�|�dd��q|�t|�dd�|��q|dk	r^|�d|�t�|�||<dS)u�Extended header setting.

        name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.  If a
        parameter value contains non-ASCII characters it can be specified as a
        three-tuple of (charset, language, value), in which case it will be
        encoded according to RFC2231 rules.  Otherwise it will be encoded using
        the utf-8 charset and a language of ''.

        Examples:

        msg.add_header('content-disposition', 'attachment', filename='bud.gif')
        msg.add_header('content-disposition', 'attachment',
                       filename=('utf-8', '', Fußballer.ppt'))
        msg.add_header('content-disposition', 'attachment',
                       filename='Fußballer.ppt'))
        N�_�-r)r�r.r[r'�insert�	SEMISPACErg)r>�_name�_valueZ_params�partsr�r�rrrrvszMessage.add_headercCs\|��}ttt|j��|j�D]0\}\}}|��|kr|j�||�|j|<qXqt|��dS)z�Replace a header.

        Replace the first matching header found in the message, retaining
        header order and case.  If no matching header was found, a KeyError is
        raised.
        N)r-�zip�rangerr8r7r�KeyError)r>r�r�r2r�r�rrr�replace_header!s"zMessage.replace_headercCsHt�}|�d|�}||kr"|��St|�d��}|�d�dkrDdS|S)a0Return the message's content type.

        The returned string is coerced to lower case of the form
        `maintype/subtype'.  If there was no Content-Type header in the
        message, the default type as given by get_default_type() will be
        returned.  Since according to RFC 2045, messages always have a default
        type this will always return a value.

        RFC 2045 defines a message's default type to be text/plain unless it
        appears inside a multipart/digest container, in which case it would be
        message/rfc822.
        �content-typer�/rr6)�objectra�get_default_typerr-r+)r>�missingr&�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|��}|�d�dS)z�Return the message's main content type.

        This is the `maintype' part of the string returned by
        get_content_type().
        r�r�r��split�r>r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|��}|�d�dS)z�Returns the message's sub-content type.

        This is the `subtype' part of the string returned by
        get_content_type().
        r�rr�r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jS)aReturn the `default' content type.

        Most messages have a default content type of text/plain, except for
        messages that are subparts of multipart/digest containers.  Such
        subparts have a default content type of message/rfc822.
        �r=rArrrr�^szMessage.get_default_typecCs
||_dS)z�Set the `default' content type.

        ctype should be either "text/plain" or "message/rfc822", although this
        is not enforced.  The default content type is not stored in the
        Content-Type header.
        Nr�r�rrr�set_default_typegszMessage.set_default_typec		Cs�t�}|�||�}||kr|Sg}t|�D]X}z$|�dd�\}}|��}|��}Wn tk
rr|��}d}YnX|�||f�q*t�|�}|S)Nr)rr)	r�rar3r�rr}r.rZ
decode_params)	r>r��headerr�r&�params�pr{r�rrr�_get_params_preserveps 

zMessage._get_params_preserver�TcCs8t�}|�||�}||kr|S|r0dd�|D�S|SdS)amReturn the message's Content-Type parameters, as a list.

        The elements of the returned list are 2-tuples of key/value pairs, as
        split on the `=' sign.  The left hand side of the `=' is the key,
        while the right hand side is the value.  If there is no `=' sign in
        the parameter the value is the empty string.  The value is as
        described in the get_param() method.

        Optional failobj is the object to return if there is no Content-Type
        header.  Optional header is the header to search instead of
        Content-Type.  If unquote is True, the value is unquoted.
        cSsg|]\}}|t|�f�qSr)r5r�rrrr��sz&Message.get_params.<locals>.<listcomp>N)r�r�)r>r�r�r4r�r�rrr�
get_params�s
zMessage.get_paramscCsN||kr|S|�||�D]0\}}|��|��kr|r@t|�S|Sq|S)a�Return the parameter value if found in the Content-Type header.

        Optional failobj is the object to return if there is no Content-Type
        header, or the Content-Type header has no such parameter.  Optional
        header is the header to search instead of Content-Type.

        Parameter keys are always compared case insensitively.  The return
        value can either be a string, or a 3-tuple if the parameter was RFC
        2231 encoded.  When it's a 3-tuple, the elements of the value are of
        the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
        LANGUAGE can be None, in which case you should consider VALUE to be
        encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
        The parameter value (either the returned string, or the VALUE item in
        the 3-tuple) is always unquoted, unless unquote is set to False.

        If your application doesn't care whether the parameter was RFC 2231
        encoded, it can turn the return value into a string as follows:

            rawparam = msg.get_param('foo')
            param = email.utils.collapse_rfc2231_value(rawparam)

        )r�r-r5)r>rr�r�r4r�r�rrrrc�s
zMessage.get_paramrtrcCs
t|t�s|r|||f}||kr2|��dkr2d}n
|�|�}|j||d�st|s\t|||�}q�t�|t|||�g�}nbd}|j||d�D]N\}	}
d}|	��|��kr�t|||�}nt|	|
|�}|s�|}q�t�||g�}q�||�|�k�r|r�|�	||�n||=|||<dS)a�Set a parameter in the Content-Type header.

        If the parameter already exists in the header, its value will be
        replaced with the new value.

        If header is Content-Type and has not yet been defined for this
        message, it will be set to "text/plain" and the new parameter and
        value will be appended as per RFC 2045.

        An alternate header can be specified in the header argument, and all
        parameters will be quoted as necessary unless requote is False.

        If charset is specified, the parameter will be encoded according to RFC
        2231.  Optional language specifies the RFC 2231 language, defaulting
        to the empty string.  Both charset and language should be strings.
        r�r6)r�r�r�r4N)
rr r-rarcr'r�rgr�r�)r>rr&r��requoterZlanguager[r�Z	old_param�	old_valueZappend_paramrrrrw�s6

��zMessage.set_paramcCs�||krdSd}|j||d�D]@\}}|��|��kr|sHt|||�}qt�|t|||�g�}q||�|�kr|||=|||<dS)a>Remove the given parameter completely from the Content-Type header.

        The header will be re-written in place without the parameter or its
        value. All values will be quoted as necessary unless requote is
        False.  Optional header specifies an alternative to the Content-Type
        header.
        Nrr�)r�r-r'r�rgra)r>rr�r�Z	new_ctyper�r�rrrru�s
�zMessage.del_paramcCs�|�d�dkst�|��dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<|dd�D]\}}|�||||�qhdS)	aKSet the main type and subtype for the Content-Type header.

        type must be a string in the form "maintype/subtype", otherwise a
        ValueError is raised.

        This method replaces the Content-Type header, keeping all the
        parameters in place.  If requote is False, this leaves the existing
        header's quoting as is.  Otherwise, the parameters will be quoted (the
        default).

        An alternative header can be specified in the header argument.  When
        the Content-Type header is set, we'll always also add a MIME-Version
        header.
        r�rr�zmime-versionrsrrNr�)r+r}r-r�rw)r>r`r�r�r�r�r�rrr�set_typeszMessage.set_typecCsDt�}|�d|d�}||kr*|�d|d�}||kr6|St�|���S)a@Return the filename associated with the payload if present.

        The filename is extracted from the Content-Disposition header's
        `filename' parameter, and it is unquoted.  If that header is missing
        the `filename' parameter, this method falls back to looking for the
        `name' parameter.
        �filename�content-dispositionr{r�)r�rcr�collapse_rfc2231_valuer)r>r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|�d|�}||kr|St�|���S)z�Return the boundary associated with the payload if present.

        The boundary is extracted from the Content-Type header's `boundary'
        parameter, and it is unquoted.
        �boundary)r�rcrr��rstrip)r>r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCst�}|�|d�}||kr$t�d��g}d}|D]:\}}|��dkr\|�dd|f�d}q0|�||f�q0|s�|�dd|f�g}|jD]z\}	}
|	��dkr�g}|D].\}}
|
dkr�|�|�q�|�d||
f�q�t�|�}
|�|j	�
|	|
��q�|�|	|
f�q�||_d	S)
a�Set the boundary parameter in Content-Type to 'boundary'.

        This is subtly different than deleting the Content-Type header and
        adding a new one with a new boundary parameter via add_header().  The
        main difference is that using the set_boundary() method preserves the
        order of the Content-Type header in the original message.

        HeaderParseError is raised if the message has no Content-Type header.
        r�zNo Content-Type header foundFr�z"%s"TrrN)r�r�rZHeaderParseErrorr-r.r8r�rgr7r)r>r�r�r�Z	newparamsZfoundpZpkZpvr��hr�r�r�r�rrr�set_boundaryCs2


zMessage.set_boundaryc	Cs�t�}|�d|�}||kr|St|t�rr|dp2d}z|d�d�}t||�}Wn ttfk
rp|d}YnXz|�d�Wntk
r�|YSX|��S)z�Return the charset parameter of the Content-Type header.

        The returned string is always coerced to lower case.  If there is no
        Content-Type header, or if that header has no charset parameter,
        failobj is returned.
        rrzus-asciirr\)	r�rcrr r!rrdrer-)r>r�r�rZpcharsetrMrrr�get_content_charsetqs 

zMessage.get_content_charsetcs�fdd�|��D�S)a�Return a list containing the charset(s) used in this message.

        The returned list of items describes the Content-Type headers'
        charset parameter for this message and all the subparts in its
        payload.

        Each item will either be a string (the value of the charset parameter
        in the Content-Type header of that part) or the value of the
        'failobj' parameter (defaults to None), if the part does not have a
        main MIME type of "text", or the charset is not defined.

        The list will contain one string for each part of the message, plus
        one for the container message (i.e. self), so that a non-multipart
        message will still return a list of length 1.
        csg|]}|����qSr)r�)r��part�r�rrr��sz(Message.get_charsets.<locals>.<listcomp>��walk)r>r�rr�r�get_charsets�szMessage.get_charsetscCs*|�d�}|dkrdSt|�d��}|S)z�Return the message's content-disposition if it exists, or None.

        The return values can be either 'inline', 'attachment' or None
        according to the rfc2183.
        r�Nr)rarr-)r>r&�c_drrr�get_content_disposition�s

zMessage.get_content_dispositionr�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)rtTNrF)r�T)rtT)N)N)N)N)4�__name__�
__module__�__qualname__�__doc__r	r?rBr@rNrMrQrTrUrYrlrqrprxryr|r�r�r�r�r�r�r�rar�r�r�rvr�r�r�r�r�r�r�r�rcrwrur�r�r�r�r�r�r�Zemail.iteratorsr�rrrrrisj


Z
/


				
�
"�
3

 


.


cs�eZdZd2dd�Zd3�fdd�	Zdd�Zd	d
�Zdd�Zd4dd�ZddddhZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd5dd �Zd6d!d"�Zd7d#d$�Zdd%�d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z�ZS)8�MIMEPartNcCs(|dkrddlm}|}t�||�dS)Nr)�default)Zemail.policyr�rr?)r>r7r�rrrr?�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)aReturn the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  maxheaderlen is retained for backward compatibility with the
        base Message class, but defaults to None, meaning that the policy value
        for max_line_length controls the header maximum length.  'policy' is
        passed to the Generator instance used to serialize the message; if it
        is not specified the policy associated with the message instance is
        used.
        N)rEr7)r7Zmax_line_length�superr@)r>rGrEr7��	__class__rrr@�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8�r7)r@r7ZclonerArrrrB�szMIMEPart.__str__cCs |�d�}|dkrdS|jdkS)Nr�F�
attachment)raZcontent_disposition)r>r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|��rdS|���d�\}}|dkrB||kr>|�|�|fVdS|dkrNdS|dkrz|��D]}|�||�EdHq^dSd|kr�|�d�|fVd}|�d�}|r�|��D]}|d|kr�|}q�q�|dkr�|��}|r�|dnd}|dk	�r|�||�EdHdS)Nr��text�	multipart�related�start�
content-idr)r�r�r�r,�
iter_parts�
_find_bodyrcrl)	r>r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_body�r��html�plaincCsBt|�}d}|�||�D]$\}}||kr|}|}|dkrq>q|S)aReturn best candidate mime part for display as 'body' of message.

        Do a depth first search, starting with self, looking for the first part
        matching each of the items in preferencelist, and return the part
        corresponding to the first item that has a match, or None if no items
        have a match.  If 'related' is not included in preferencelist, consider
        the root part of any multipart/related encountered as a candidate
        match.  Ignore parts with 'Content-Disposition: attachment'.
        Nr)rr�)r>r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_body)r�r�)r�r�)r�r�)r��alternativec
cs$|���d�\}}|dks"|dkr&dS|��}z|��}Wntk
rPYdSX|dkr�|dkr�|�d�}|r�d}g}|D]"}|�d�|kr�d	}q||�|�q||r�|EdHdS|�d
�|EdHdSg}	|D]L}|���d�\}}||f|j	k�r|�
��s||	k�r|	�|�q�|Vq�dS)aReturn an iterator over the non-main parts of a multipart.

        Skip the first of each occurrence of text/plain, text/html,
        multipart/related, or multipart/alternative in the multipart (unless
        they have a 'Content-Disposition: attachment' header) and include all
        remaining subparts in the returned iterator.  When applied to a
        multipart/related, return all parts except the root part.  Return an
        empty iterator when applied to a multipart/alternative or a
        non-multipart.
        r�r�r�Nr�r�Fr�Tr)r�r�rlr�rVrcrar.�pop�_body_typesr�)
r>r�r�rXr�r�r�Zattachmentsr��seenrrr�iter_attachmentssD



��
zMIMEPart.iter_attachmentsccs|��dkr|��EdHdS)z~Return an iterator over all immediate subparts of a multipart.

        Return an empty iterator for a non-multipart.
        r�N)r�rlrArrrr�=szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�SrR)r7r��get_content�r>r��args�kwrrrr�EszMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dSrR)r7r��set_contentr�rrrr�JszMIMEPart.set_contentc
Cs�|��dkr6|��}||f}||kr6td�||���g}g}|jD]4\}}|���d�rj|�||f�qD|�||f�qD|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|�d|�dS)Nr�zCannot convert {} to {}�content-r�z
multipart/rtr�)r�r�r}r~r8r-�
startswithr.r`r7r:rw)
r>r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersr{r&r�rrr�_make_multipartOs0
�
zMIMEPart._make_multipartcCs|�dd|�dS)Nr�)r��mixed�r��r>r�rrr�make_relatedjszMIMEPart.make_relatedcCs|�dd|�dS)Nr�)r�r�r�rrr�make_alternativemszMIMEPart.make_alternativecCs|�dd|�dS)Nr�rr�r�rrr�
make_mixedpszMIMEPart.make_mixed)�_dispcOsf|��dks|��|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|�|�dS)Nr�Zmake_r�r�zContent-Disposition)r�r��getattrr`r7r�rY)r>Z_subtyper�r�r�r�rrr�_add_multipartss
�zMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r��r��r>r�r�rrr�add_related}szMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�r�r�rrr�add_alternative�szMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�r�r�rrr�add_attachment�szMIMEPart.add_attachmentcCsg|_d|_dSrR�r8r:rArrr�clear�szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|���d�s||f�qS)r�)r-r�)r��nr�rrrr��s�z*MIMEPart.clear_content.<locals>.<listcomp>rrArrr�
clear_content�szMIMEPart.clear_content)N)FNN)r�)N)N)N)r�r�r�r?r@rBr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�
__classcell__rrr�rr��s2

�7



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)Nrrrs)r�r�r�r�rrr��szEmailMessage.set_content)r�r�r�r�rrrr�rr�s)NT)r��__all__�rerirf�iorrZemailrrZemail._policybaserr	rr;Zemail._encoded_wordsrrnr��compiler#rr'r3r5rr�rrrrr�<module>s6


"N`PK�"�\u�(JLLutils.cpython-38.opt-2.pycnu�[���U

e5d�4�@sfdddddddddd	d
ddd
dgZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	m
Z
ddl	mZmZmZddlmZdZdZdZdZdZe�d�Ze�d�Zdd�Zdd�Zd6d!d�Zd"d�Zd#d$�Zd7d&d�Z d8d'd�Z!d9d(d�Z"d)d
�Z#d*d
�Z$d+d�Z%d,d�Z&d:d-d�Z'e�d.ej(�Z)d/d�Z*d;d2d�Z+d<d4d5�Z,dS)=�collapse_rfc2231_value�
decode_params�decode_rfc2231�encode_rfc2231�
formataddr�
formatdate�format_datetime�getaddresses�
make_msgid�	mktime_tz�	parseaddr�	parsedate�parsedate_tz�parsedate_to_datetime�unquote�N)�quote)�AddressList)r
)rr
�
_parsedate_tz)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]cCs*z|��WdStk
r$YdSXdS)NFT)�encode�UnicodeEncodeError)�s�r�#/usr/lib64/python3.8/email/utils.py�_has_surrogates3s
rcCs|�dd�}|�dd�S)N�utf-8�surrogateescape�replace)r�decode)�stringZoriginal_bytesrrr�	_sanitize@sr"rcCs�|\}}|�d�|r�z|�d�Wn<tk
r`t|t�rFt|�}|�|�}d||fYSXd}t�|�rtd}t�	d|�}d||||fS|S)N�asciiz%s <%s>r�"z\\\g<0>z%s%s%s <%s>)
rr�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�nameZaddressZencoded_nameZquotesrrrrLs 




cCst�|�}t|�}|jS)N)�
COMMASPACE�join�_AddressList�addresslist)Zfieldvalues�all�arrrrns
cCsfddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDec�r���r)�	timetuple�zonerrr�_format_timetuple_and_zoneus&�
��r;FcCsR|dkrt��}|s|r,tj�|tjj�}ntj�|�}|rH|��}d}t||�S)NF)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr~scCsV|��}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}n
|�d�}t||�S)Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)r9�tzinfor=r>r?�
ValueError�strftimer;)rDrC�nowr:rrrr�s

cCs^tt��d�}t��}t�d�}|dkr0d}nd|}|dkrHt��}d|||||f}|S)N�d�@r�.z<%d.%d.%d%s@%s>)�intr<�os�getpid�randomZgetrandbits�socketZgetfqdn)ZidstringZdomainrA�pidZrandintZmsgidrrrr	�s

cCsNt|��^}}|dkr(tj|dd��Stj|dd�dt�tj|d��i�S)Nr3rE��seconds)rr=r>�	timedelta)�dataZdtuple�tzrrrr�s�cCst|�j}|sdS|dS)N)rrr)r/r0)ZaddrZaddrsrrrr�s
cCs`t|�dkr\|�d�r<|�d�r<|dd��dd��dd�S|�d�r\|�d�r\|dd�S|S)	Nr5r$���z\\�\z\"�<�>)�len�
startswith�endswithr)r&rrrr�scCs&|�td�}t|�dkr"dd|fS|S)Nr4)�split�TICKr[)r�partsrrrr�s
cCsDtjj|d|pdd�}|dkr*|dkr*|S|dkr6d}d|||fS)Nrr#)Zsafe�encodingz%s'%s'%s)�urllib�parser)rr+�languagerrrr�sz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Csl|dd�}g}i}|�d�\}}|�||f�|r�|�d�\}}|�d�rRd}nd}t|�}t�|�}|r�|�dd�\}}|dk	r�t|�}|�|g��|||f�q0|�|dt	|�f�q0|�rh|�
�D]�\}}g}d}	|��|D].\}}
}|�rtj
j|
dd	�}
d}	|�|
�q�t	t�|��}|	�rTt|�\}}}|�|||d|ff�q�|�|d|f�q�|S)
Nr�*TFr,�numz"%s"zlatin-1)ra)�pop�appendr]r�rfc2231_continuation�match�grouprL�
setdefaultr�items�sortrbrc�EMPTYSTRINGr.r)
ZparamsZ
new_paramsZrfc2231_paramsr,�valueZencodedZmorfZ
continuationsZextendedrr+rdrrrrsD

r�us-asciicCsnt|t�rt|�dkrt|�S|\}}}|dkr4|}t|d�}zt|||�WStk
rht|�YSXdS)Nr6zraw-unicode-escape)r%�tupler[r�bytesr&�LookupError)rp�errorsZfallback_charsetr+rd�textZrawbytesrrrr9s

rWc	Cs|dkrtj�tjj���S|jdk	r.|��S|��dd�|f}t�|�}t�	|�}z tj
|jd�}t�||j�}Wn�t
k
r�|tjt�|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�t�|tj|�}n
t�|�}YnX|j|d�S)NrWrRr3r)rE)r=rHr>r?r@rEr9r<�mktimerBrT�	tm_gmtoff�tm_zone�AttributeError�gmtime�daylight�tm_isdst�altzone�tznamer)	rDZisdstZtmrSZlocaltmZdeltarVZdstZgmtoffrrrrBSs$


rB)r)NFF)F)NN)NN)rrq)NrW)-�__all__rM�rer<rOrPr=Zurllib.parserbZemail._parseaddrrrr/r
rr
rZ
email.charsetrr-roZUEMPTYSTRINGZCRLFr_�compiler'r)rr"rrr;rrr	rrrrr�ASCIIrirrrBrrrr�<module>sn�



"	



�8�
PK�"�\��|>�,�,charset.cpython-38.pycnu�[���U

e5d�B�@srddddgZddlmZddlZddlZddlmZddlmZd	Z	d
Z
dZdZd
Z
dZdZe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfde
e
dfe
e
dfe
ddfe
ddfe
ddfe
e
dfee
dfd�Zddddddddddddddddddddddd d
d!�Zd"d#dd$�Zd+d%d�Zd&d�Zd'd�Zd(d)�ZGd*d�d�ZdS),�Charset�	add_alias�add_charset�	add_codec�)�partialN)�errors)�encode_7or8bit�����us-asciizunknown-8bit�)NNN�iso-2022-jp�utf-8)�
iso-8859-1�
iso-8859-2�
iso-8859-3�
iso-8859-4�
iso-8859-9�iso-8859-10�iso-8859-13�iso-8859-14�iso-8859-15�iso-8859-16zwindows-1252Zvisciir
�big5�gb2312�euc-jp�	shift_jisrzkoi8-rrrrrrrrrrrrzks_c_5601-1987rzeuc-kr)�latin_1zlatin-1Zlatin_2zlatin-2Zlatin_3zlatin-3Zlatin_4zlatin-4Zlatin_5zlatin-5Zlatin_6zlatin-6Zlatin_7zlatin-7Zlatin_8zlatin-8Zlatin_9zlatin-9Zlatin_10zlatin-10�cp949�euc_jp�euc_kr�ascii�eucgb2312_cn�big5_tw)rrr
cCs"|tkrtd��|||ft|<dS)a>Add character set properties to the global registry.

    charset is the input character set, and must be the canonical name of a
    character set.

    Optional header_enc and body_enc is either Charset.QP for
    quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for
    the shortest of qp or base64 encoding, or None for no encoding.  SHORTEST
    is only valid for header_enc.  It describes how message headers and
    message bodies in the input charset are to be encoded.  Default is no
    encoding.

    Optional output_charset is the character set that the output should be
    in.  Conversions will proceed from input charset, to Unicode, to the
    output charset when the method Charset.convert() is called.  The default
    is to output in the same character set as the input.

    Both input_charset and output_charset must have Unicode codec entries in
    the module's charset-to-codec mapping; use add_codec(charset, codecname)
    to add codecs the module does not know about.  See the codecs module's
    documentation for more information.
    z!SHORTEST not allowed for body_encN)�SHORTEST�
ValueError�CHARSETS)�charsetZ
header_encZbody_enc�output_charset�r+�%/usr/lib64/python3.8/email/charset.pyrmscCs|t|<dS)z�Add a character set alias.

    alias is the alias name, e.g. latin-1
    canonical is the character set's canonical name, e.g. iso-8859-1
    N)�ALIASES)�aliasZ	canonicalr+r+r,r�scCs|t|<dS)a$Add a codec that map characters in the given charset to/from Unicode.

    charset is the canonical name of a character set.  codecname is the name
    of a Python codec, as appropriate for the second argument to the unicode()
    built-in, or to the encode() method of a Unicode string.
    N)�	CODEC_MAP)r)Z	codecnamer+r+r,r�scCs"|tkr|�dd�S|�|�SdS)Nr#�surrogateescape)�UNKNOWN8BIT�encode)�string�codecr+r+r,�_encode�sr5c@s\eZdZdZefdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)ra@	Map character sets to their email properties.

    This class provides information about the requirements imposed on email
    for a specific character set.  It also provides convenience routines for
    converting between character sets, given the availability of the
    applicable codecs.  Given a character set, it will do its best to provide
    information on how to use that character set in an email in an
    RFC-compliant way.

    Certain character sets must be encoded with quoted-printable or base64
    when used in email headers or bodies.  Certain character sets must be
    converted outright, and are not allowed in email.  Instances of this
    module expose the following information about a character set:

    input_charset: The initial character set specified.  Common aliases
                   are converted to their `official' email names (e.g. latin_1
                   is converted to iso-8859-1).  Defaults to 7-bit us-ascii.

    header_encoding: If the character set must be encoded before it can be
                     used in an email header, this attribute will be set to
                     Charset.QP (for quoted-printable), Charset.BASE64 (for
                     base64 encoding), or Charset.SHORTEST for the shortest of
                     QP or BASE64 encoding.  Otherwise, it will be None.

    body_encoding: Same as header_encoding, but describes the encoding for the
                   mail message's body, which indeed may be different than the
                   header encoding.  Charset.SHORTEST is not allowed for
                   body_encoding.

    output_charset: Some character sets must be converted before they can be
                    used in email headers or bodies.  If the input_charset is
                    one of them, this attribute will contain the name of the
                    charset output will be converted to.  Otherwise, it will
                    be None.

    input_codec: The name of the Python codec used to convert the
                 input_charset to Unicode.  If no conversion codec is
                 necessary, this attribute will be None.

    output_codec: The name of the Python codec used to convert Unicode
                  to the output_charset.  If no conversion codec is necessary,
                  this attribute will have the same value as the input_codec.
    cCs�z$t|t�r|�d�n
t|d�}Wntk
rBt�|��YnX|��}t�||�|_	t
�|j	ttdf�\}}}|s~|j	}||_
||_t�||�|_t�|j	|j	�|_t�|j|j�|_dS)Nr#)�
isinstance�strr2�UnicodeErrorrZCharsetError�lowerr-�get�
input_charsetr(r&�BASE64�header_encoding�
body_encodingr*r/Zinput_codec�output_codec)�selfr;ZhencZbencZconvr+r+r,�__init__�s,
�
��zCharset.__init__cCs
|j��S�N)r;r9�r@r+r+r,�__repr__�szCharset.__repr__cCst|�t|���kSrB)r7r9)r@�otherr+r+r,�__eq__�szCharset.__eq__cCs2|jtkst�|jtkrdS|jtkr*dStSdS)aPReturn the content-transfer-encoding used for body encoding.

        This is either the string `quoted-printable' or `base64' depending on
        the encoding used, or it is a function in which case you should call
        the function with a single argument, the Message object being
        encoded.  The function should then set the Content-Transfer-Encoding
        header itself to whatever is appropriate.

        Returns "quoted-printable" if self.body_encoding is QP.
        Returns "base64" if self.body_encoding is BASE64.
        Returns conversion function otherwise.
        zquoted-printable�base64N)r>r&�AssertionError�QPr<rrCr+r+r,�get_body_encoding�s


zCharset.get_body_encodingcCs|jp
|jS)z�Return the output character set.

        This is self.output_charset if that is not None, otherwise it is
        self.input_charset.
        )r*r;rCr+r+r,�get_output_charsetszCharset.get_output_charsetcCs6|jpd}t||�}|�|�}|dkr*|S|�||�S)a�Header-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        this charset's `header_encoding`.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :return: The encoded string, with RFC 2047 chrome.
        r
N)r?r5�_get_encoder�
header_encode)r@r3r4�header_bytes�encoder_moduler+r+r,rMs


zCharset.header_encodecCs|jpd}t||�}|�|�}t|j|d�}|��}t|�t}g}	g}
t|�|}|D]�}|
�	|�t
�|
�}
|�t|
|��}||krX|
�
�|	s�|
s�|	�	d�n.|	r�dnd}t
�|
�}t||�}|	�	||��|g}
t|�|}qXt
�|
�}t||�}|	�	||��|	S)afHeader-encode a string by converting it first to bytes.

        This is similar to `header_encode()` except that the string is fit
        into maximum line lengths as given by the argument.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :param maxlengths: Maximum line length iterator.  Each element
            returned from this iterator will provide the next maximum line
            length.  This parameter is used as an argument to built-in next()
            and should never be exhausted.  The maximum line lengths should
            not count the RFC 2047 chrome.  These line lengths are only a
            hint; the splitter does the best it can.
        :return: Lines of encoded strings, each with RFC 2047 chrome.
        r
)r)N� r)r?r5rLrrMrK�len�RFC2047_CHROME_LEN�next�append�EMPTYSTRING�join�
header_length�pop)r@r3Z
maxlengthsr4rNrO�encoderr)Zextra�linesZcurrent_line�maxlen�	characterZ	this_lineZlengthZ	separatorZjoined_liner+r+r,�header_encode_lines*s6








zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtj�|�}tj�|�}||krPtjStjSndSdSrB)r=r<�email�
base64mimerI�
quoprimimer&rW)r@rNZlen64Zlenqpr+r+r,rLhs


zCharset._get_encodercCs�|s|S|jtkr4t|t�r(|�|j�}tj�|�S|jt	krjt|t�rT|�|j�}|�
d�}tj�|�St|t�r�|�|j��
d�}|SdS)avBody-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        self.body_encoding.  If body_encoding is None, we assume the
        output charset is a 7bit encoding, so re-encoding the decoded
        string using the ascii codec produces the correct string version
        of the content.
        �latin1r#N)r>r<r6r7r2r*r^r_�body_encoderI�decoder`)r@r3r+r+r,rbws	





zCharset.body_encodeN)�__name__�
__module__�__qualname__�__doc__�DEFAULT_CHARSETrArDrFrJrKrMr]rLrbr+r+r+r,r�s+!>)NNN)�__all__�	functoolsrZemail.base64mimer^Zemail.quoprimimerZemail.encodersrrIr<r&rRrhr1rUr(r-r/rrrr5rr+r+r+r,�<module>s��� ��
	
PK�"�\�*�quoprimime.cpython-38.pycnu�[���U

e5d�&�
@sXdZddddddddd	d
g
ZddlZdd
lmZmZmZdZdZdZ	dd�e
d�D�Zedd�Zedd�Z
de�d�e�d�D]Zee�ee<q�deed�<dD]Zee�e
e<q�dd�Zdd�Zdd�Zdd�Zd,dd �Zd!d
�Zd"d	�Zd-d$d�Ze
dd�Zd%D]Zee�ee<�qd&efd'd�Zefd(d�ZeZeZd)d*�Zd+d�Z dS).aFQuoted-printable content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode US ASCII-like 8-bit data called `quoted-printable'.  It is used to
safely encode text that is in a character set similar to the 7-bit US ASCII
character set, but that includes some 8-bit characters that are normally not
allowed in email bodies or headers.

Quoted-printable is very space-inefficient for encoding binary files; use the
email.base64mime module for that instead.

This module provides an interface to encode and decode both headers and bodies
with quoted-printable encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:/From:/Cc: etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character
conversion necessary for proper internationalized headers; it only
does dumb encoding and decoding.  To deal with the various line
wrapping issues, use the email.header module.
�body_decode�body_encode�body_length�decode�decodestring�
header_decode�
header_encode�
header_length�quote�unquote�N)�
ascii_letters�digits�	hexdigits�
�
�cCsg|]}d|�qS)z=%02X�)�.0�crr�(/usr/lib64/python3.8/email/quoprimime.py�
<listcomp>7sr�s-!*+/�ascii�_� s_ !"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~	cCst|�t|kS)z>Return True if the octet should be escaped with header quopri.)�chr�_QUOPRI_HEADER_MAP��octetrrr�header_checkJsrcCst|�t|kS)z<Return True if the octet should be escaped with body quopri.)r�_QUOPRI_BODY_MAPrrrr�
body_checkOsr!cCstdd�|D��S)a:Return a header quoted-printable encoding length.

    Note that this does not include any RFC 2047 chrome added by
    `header_encode()`.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for headers.
    css|]}tt|�VqdS�N)�lenr�rrrrr�	<genexpr>^sz header_length.<locals>.<genexpr>��sum��	bytearrayrrrrTs
cCstdd�|D��S)z�Return a body quoted-printable encoding length.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for bodies.
    css|]}tt|�VqdSr")r#r r$rrrr%hszbody_length.<locals>.<genexpr>r&r(rrrrascCsft|t�st|�}|s&|�|���n<t|d�t|�|krT|d||7<n|�|���dS)N���)�
isinstance�strr�append�lstripr#)�L�s�maxlenZextrarrr�_max_appendks
r2cCstt|dd�d��S)zDTurn a string in the form =AB to the ASCII character with value 0xab���)r�int�r0rrrr
vscCstt|�Sr")�_QUOPRI_MAP�ord)rrrrr	{s�
iso-8859-1cCs$|sdS|�d��t�}d||fS)a�Encode a single header line with quoted-printable (like) encoding.

    Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but
    used specifically for email header fields to allow charsets with mostly 7
    bit characters (and some 8 bit) to remain more or less readable in non-RFC
    2045 aware mail clients.

    charset names the character set to use in the RFC 2046 header.  It
    defaults to iso-8859-1.
    r�latin1z=?%s?q?%s?=)r�	translater)Zheader_bytes�charset�encodedrrrrss
�Lc
Cs�|dkrtd��|s|S|�t�}d|}|d}g}|j}|��D�]}d}t|�d|}	||	kr�||}
||
ddkr�||||
d��|
d}q^||
ddkr�||||
��|
d}q^||||
�d�|
}q^|�rR|ddk�rR||	}|d	k�rt|d�}n(|dk�r,|d|}n|t|d�}|||d�|�qD|||d
��qD|dtk�rz|d�|�|�S)a�Encode with quoted-printable, wrapping at maxlinelen characters.

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.

    Each line will be wrapped at, at most, maxlinelen characters before the
    eol string (maxlinelen defaults to 76 characters, the maximum value
    permitted by RFC 2045).  Long lines will have the 'soft line break'
    quoted-printable character "=" appended to them, so the decoded text will
    be identical to the original text.

    The minimum maxlinelen is 4 to have room for a quoted character ("=XX")
    followed by a soft line break.  Smaller values will generate a
    ValueError.

    �zmaxlinelen must be at least 4�=r3r�r*z 	r4Nr)	�
ValueErrorr<�_QUOPRI_BODY_ENCODE_MAPr-�
splitlinesr#r	�CRLF�join)
ZbodyZ
maxlinelen�eolZ
soft_breakZmaxlinelen1Zencoded_bodyr-�line�startZ	laststart�stopZroom�qrrrr�sD




cCs|s|Sd}|��D]�}|��}|s.||7}qd}t|�}||kr||}|dkrd||7}|d7}nv|d|kr||d7}q:n^|d|kr�||dtkr�||dtkr�|t|||d��7}|d7}n||7}|d7}||kr:||7}q:q|ddk�r|�|��r|d	d�}|S)
z_Decode a quoted-printable string.

    Lines are separated with eol, which defaults to \n.
    rrrAr3rBr4r*rN)rE�rstripr#rr
�endswith)r>rHZdecodedrI�i�nrrrrr�s8
,
cCs|�d�}t|�S)zCTurn a match in the form =AB to the ASCII character with value 0xabr)�groupr
)�matchr0rrr�_unquote_matchs
rScCs |�dd�}tjdt|tjd�S)aDecode a string encoded with RFC 2045 MIME header `Q' encoding.

    This function does not parse a full MIME header value encoded with
    quoted-printable (like =?iso-8859-1?q?Hello_World?=) -- please use
    the high level email.header class for that functionality.
    rrz=[a-fA-F0-9]{2})�flags)�replace�re�subrS�ASCIIr7rrrr#s)r)r:)!�__doc__�__all__rV�stringrr
rrF�NLZEMPTYSTRING�ranger8rr �encoderrr9rr!rrr2r
r	rrDrrrrrSrrrrr�<module>sR�




O0PK�"�\�ͼc9@9@header.cpython-38.pycnu�[���U

e5d&^�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z
e
jZdZd	Z
d
ZdZdZd
ZdZed�Zed�Ze�dejejB�Ze�d�Ze�d�ZejjZdd�Zddd�ZGdd�d�ZGdd�d�Z Gdd�de!�Z"dS)z+Header encoding and decoding functionality.�Header�
decode_header�make_header�N)�HeaderParseError)�charset�
� � z        ��Nz 	�us-asciizutf-8ai
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qQbB])  # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:c	Cs�t|d�rdd�|jD�St�|�s.|dfgSg}|��D]�}t�|�}d}|r:|�d�}|rj|��}d}|r~|�|ddf�|rL|�d��	�}|�d��	�}|�d�}|�|||f�qLq:g}	t
|�D]J\}
}|
dkr�|dr�||
d	dr�||
dd��r�|	�|
d�q�t|	�D]}||=�qg}
|D]�\}}}|dk�rV|
�||f�n�|d
k�r|t
j�|�}|
�||f�n~|dk�r�t|�d}|�r�|d
dd|�7}zt
j�|�}Wn tjk
�r�td��YnX|
�||f�ntd|���q2g}d}}|
D]v\}}t|t��r,t|d�}|dk�r@|}|}nB||k�rb|�||f�|}|}n |dk�rz|t|7}n||7}�q|�||f�|S)a;Decode a message header value without converting charset.

    Returns a list of (string, charset) pairs containing each of the decoded
    parts of the header.  Charset is None for non-encoded parts of the header,
    otherwise a lower-case string containing the name of the character set
    specified in the encoded string.

    header may be a string that may or may not contain RFC2047 encoded words,
    or it may be a Header object.

    An email.errors.HeaderParseError may be raised when certain decoding error
    occurs (e.g. a base64 decoding exception).
    �_chunkscSs(g|] \}}t�|t|��t|�f�qS�)�_charsetZ_encode�str)�.0�stringrrr�$/usr/lib64/python3.8/email/header.py�
<listcomp>Ms�z!decode_header.<locals>.<listcomp>NTrF���q�b�z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
�ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr�AssertionError�
isinstancer�bytes�BSPACE)�headerZwords�line�parts�firstZ	unencodedr�encodingZencodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetrrrr=s|
�




4







cCsFt|||d�}|D].\}}|dk	r4t|t�s4t|�}|�||�q|S)a�Create a Header from a sequence of pairs as returned by decode_header()

    decode_header() takes a header value string and returns a sequence of
    pairs of the format (decoded_string, charset) where charset is the string
    name of the character set.

    This function takes one of those sequence of pairs and returns a Header
    instance.  Optional maxlinelen, header_name, and continuation_ws are as in
    the Header constructor.
    )�
maxlinelen�header_name�continuation_wsN)rr-�Charsetr!)Zdecoded_seqr9r:r;�h�srrrrr�s�c@sJeZdZddd�Zdd�Zdd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)rNr�strictcCs||dkrt}nt|t�s t|�}||_||_g|_|dk	rH|�|||�|dkrTt}||_|dkrjd|_	nt
|�d|_	dS)aDCreate a MIME-compliant header that can contain many character sets.

        Optional s is the initial header value.  If None, the initial header
        value is not set.  You can later append to the header with .append()
        method calls.  s may be a byte string or a Unicode string, but see the
        .append() documentation for semantics.

        Optional charset serves two purposes: it has the same meaning as the
        charset argument to the .append() method.  It also sets the default
        character set for all subsequent .append() calls that omit the charset
        argument.  If charset is not provided in the constructor, the us-ascii
        charset is used both as s's initial charset and as the default for
        subsequent .append() calls.

        The maximum line length can be specified explicitly via maxlinelen. For
        splitting the first line to a shorter value (to account for the field
        header which isn't included in s, e.g. `Subject') pass in the name of
        the field in header_name.  The default maxlinelen is 78 as recommended
        by RFC 2822.

        continuation_ws must be RFC 2822 compliant folding whitespace (usually
        either a space or a hard tab) which will be prepended to continuation
        lines.

        errors is passed through to the .append() call.
        Nrr)�USASCIIr-r<r�_continuation_wsr
r!�
MAXLINELEN�_maxlinelen�
_headerlenr()�selfr>rr9r:r;�errorsrrr�__init__�s
zHeader.__init__c	Cs�|��g}d}d}|jD]�\}}|}|tjkrH|�dd�}|�dd�}|r�|o\|�|d�}|dkr�|dkr�|s�|�t�d}n|dkr�|s�|�t�|o�|�|d�}|}|�|�qt	�
|�S)z&Return the string value of the header.N�ascii�surrogateescape�replacer�Nr���)�
_normalizer
r�UNKNOWN8BIT�encoder)�	_nonctextr!�SPACE�EMPTYSTRING�join)	rEZuchunks�lastcs�	lastspacerrZnextcsZoriginal_bytes�hasspacerrr�__str__�s*


zHeader.__str__cCs|t|�kS�N)r)rE�otherrrr�__eq__sz
Header.__eq__cCs�|dkr|j}nt|t�s"t|�}t|t�sZ|jp4d}|tjkrN|�dd�}n|�||�}|jpbd}|tjkr�z|�||�Wn"t	k
r�|dkr��t
}YnX|j�||f�dS)a.Append a string to the MIME header.

        Optional charset, if given, should be a Charset instance or the name
        of a character set (which will be converted to a Charset instance).  A
        value of None (the default) means that the charset given in the
        constructor is used.

        s may be a byte string or a Unicode string.  If it is a byte string
        (i.e. isinstance(s, str) is false), then charset is the encoding of
        that byte string, and a UnicodeError will be raised if the string
        cannot be decoded with that charset.  If s is a Unicode string, then
        charset is a hint specifying the character set of the characters in
        the string.  In either case, when producing an RFC 2822 compliant
        header using RFC 2047 rules, the string will be encoded using the
        output codec of the charset.  If the string cannot be encoded to the
        output codec, a UnicodeError will be raised.

        Optional `errors' is passed as the errors argument to the decode
        call if s is a byte string.
        NrrI)
rr-r<rZinput_codecrNr)Zoutput_codecrO�UnicodeEncodeError�UTF8r
r!)rEr>rrFZ
input_charsetZoutput_charsetrrrr!	s$






z
Header.appendcCs|��p|dkS)z=True if string s is not a ctext character of RFC822.
        )�(�)�\)r$)rEr>rrrrP4szHeader._nonctext�;, 	rcCs�|��|dkr|j}|dkr"d}t|j||j|�}d}d}}|jD�]\}}	|dk	r�|oh|�|d�}|dkr�|r~|	dkr�|��n|	dkr�|s�|��|o�|�|d�}|	}d}|��}
|
r�|�	d|
d|	�n|�	dd|	�|
dd�D]`}|�
�|	jdk	�r"|�	|jd	|��|	�q�|��}|dt
|�t
|��}
|�	|
||	�q�t
|
�dkrF|�
�qF|j�rx|��|�|�}t�|��r�td
�|���|S)a�Encode a message header into an RFC-compliant format.

        There are many issues involved in converting a given string for use in
        an email header.  Only certain character sets are readable in most
        email clients, and as header strings can only contain a subset of
        7-bit ASCII, care must be taken to properly convert and encode (with
        Base64 or quoted-printable) header strings.  In addition, there is a
        75-character length limit on any given encoded header field, so
        line-wrapping must be performed, even with double-byte character sets.

        Optional maxlinelen specifies the maximum length of each generated
        line, exclusive of the linesep string.  Individual lines may be longer
        than maxlinelen if a folding point cannot be found.  The first line
        will be shorter by the length of the header name plus ": " if a header
        name was specified at Header construction time.  The default value for
        maxlinelen is determined at header construction time.

        Optional splitchars is a string containing characters which should be
        given extra weight by the splitting algorithm during normal header
        wrapping.  This is in very rough support of RFC 2822's `higher level
        syntactic breaks':  split points preceded by a splitchar are preferred
        during line splitting, with the characters preferred in the order in
        which they appear in the string.  Space and tab may be included in the
        string to indicate whether preference should be given to one over the
        other as a split point when other split chars do not appear in the line
        being split.  Splitchars does not affect RFC 2047 encoded lines.

        Optional linesep is a string to be used to separate the lines of
        the value.  The default value is the most useful for typical
        Python applications, but it can be set to \r\n to produce RFC-compliant
        line separators when needed.
        Nri@BrKrLFr
rrz8header value appears to contain an embedded header: {!r})rMrC�_ValueFormatterrDrAr
rP�add_transitionr�feed�newline�header_encodingr r(�_str�_embedded_headerrr�format)rE�
splitcharsr9�linesepZ	formatterrTrVrUrr�linesr1Zsline�fws�valuerrrrO9sZ!�
�

�z
Header.encodecCsxg}d}g}|jD]B\}}||kr.|�|�q|dk	rJ|�t�|�|f�|g}|}q|rn|�t�|�|f�||_dSrX)r
r!rQrS)rEZchunksr8Z
last_chunkrrrrrrM�szHeader._normalize)NNNNrr?)Nr?)r`Nr)
�__name__�
__module__�__qualname__rGrWrZr!rPrOrMrrrrr�s�
/ 
+
Pc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)racCs0||_||_t|�|_||_g|_t|�|_dSrX)�_maxlenrAr(�_continuation_ws_len�_splitchars�_lines�_Accumulator�
_current_line)rEZ	headerlen�maxlenr;rirrrrG�s
z_ValueFormatter.__init__cCs|��|�|j�SrX)rdrSrt)rErjrrrrf�sz_ValueFormatter._strcCs
|�t�SrX)rf�NL�rErrrrW�sz_ValueFormatter.__str__cCsv|j��}|dkr|jj|�t|j�dkrh|j��rV|jrV|jdt|j�7<n|j�t|j��|j��dS)N)rr
rrL)	rvr�pushr(�	is_onlywsrtrr!�reset)rEZend_of_linerrrrd�s
z_ValueFormatter.newlinecCs|j�dd�dS)Nrr
)rvrzryrrrrb�sz_ValueFormatter.add_transitioncCs�|jdkr|�|||j�dS|�||���}z|�d�}Wntk
rRYdSX|dk	rh|�||�z|��}Wntk
r�YdSX|��|j	�
|j|�|D]}|j�
|j|�q�dS�Nr)re�_ascii_splitrsZheader_encode_lines�_maxlengthsr�
IndexError�
_append_chunkrdrvrzrArtr!)rErlrrZ
encoded_linesZ
first_line�	last_liner1rrrrc�s$
z_ValueFormatter.feedccs&|jt|j�V|j|jVqdSrX)rqr(rvrrryrrrr�sz_ValueFormatter._maxlengthscCsft�dtd||�}|dr0dg|dd�<n
|�d�tt|�gd�D]\}}|�||�qLdS)Nz([z]+)rr
r)�rer�FWSr�zip�iterr�)rErlrrir2�partrrrr~�s
z_ValueFormatter._ascii_splitcCs|j�||�t|j�|jk�r|jD]v}t|j��ddd�D]T}|��rn|j|d}|rn|d|krnq�|j|dd}|r@|d|kr@q�q@q&q�q&|j��\}}|jj	dkr�|�
�|s�d}|j�||�dS|j�|�}|j�
t|j��|j�|�dS)NrrrLr)rvrzr(rqrs�range�
part_countr$r�
_initial_sizerd�pop_fromrtr!rr|)rErlrZch�iZprevpartr�Z	remainderrrrr��s.
z_ValueFormatter._append_chunkN)rnrorprGrfrWrdrbrcrr~r�rrrrra�s%racsjeZdZd�fdd�	Zdd�Zddd�Z�fdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
�fdd�Z�ZS)rurcs||_t���dSrX)r��superrG)rEZinitial_size��	__class__rrrGsz_Accumulator.__init__cCs|�||f�dSrX)r!)rErlrrrrrz#sz_Accumulator.pushcCs||d�}g||d�<|SrXr)rEr�Zpoppedrrrr�&sz_Accumulator.pop_fromcs|��dkrdSt���S)Nr)r
r
)r�r�rryr�rrr+sz_Accumulator.popcCstdd�|D�|j�S)Ncss"|]\}}t|�t|�VqdSrX)r(�rrlr�rrr�	<genexpr>1sz'_Accumulator.__len__.<locals>.<genexpr>)�sumr�ryrrr�__len__0s�z_Accumulator.__len__cCst�dd�|D��S)Ncss |]\}}t�||f�VqdSrX�rRrSr�rrrr�5s�z'_Accumulator.__str__.<locals>.<genexpr>r�ryrrrrW4s
�z_Accumulator.__str__NcCs"|dkrg}||dd�<d|_dSr})r�)rEZstartvalrrrr|8sz_Accumulator.resetcCs|jdko|pt|���Sr})r�rr$ryrrrr{>sz_Accumulator.is_onlywscs
t���SrX)r�r�ryr�rrr�Asz_Accumulator.part_count)r)r)N)
rnrorprGrzr�rr�rWr|r{r��
__classcell__rrr�rrus

ru)NNr)#�__doc__�__all__r�r*Zemail.quoprimimer&Zemail.base64mimeZemail.errorsrrrr<rxrQr/ZSPACE8rRrBr�r@r\�compile�VERBOSE�	MULTILINErZfcrergr'Z_max_appendrrrra�listrurrrr�<module>sF�
�

_�
kPK�"�\vd�8'�'�)_header_value_parser.cpython-38.opt-2.pycnu�[���U

e5dϡ�	@s�ddlZddlZddlZddlmZddlmZddlmZ	ddlm
Z
ddlmZed�Z
e
ed�BZed	�Zee
BZeed
�Zeed�Zeed�Bed
�Zee
BZeed
�BZee
BZeed�Zdd�Ze�dejejB�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de�Z$Gd d!�d!e�Z%Gd"d#�d#e�Z&Gd$d%�d%e�Z'Gd&d'�d'e'�Z(Gd(d)�d)e�Z)Gd*d+�d+e�Z*Gd,d-�d-e�Z+Gd.d/�d/e�Z,Gd0d1�d1e�Z-Gd2d3�d3e�Z.Gd4d5�d5e�Z/Gd6d7�d7e�Z0Gd8d9�d9e�Z1Gd:d;�d;e�Z2Gd<d=�d=e�Z3Gd>d?�d?e�Z4Gd@dA�dAe�Z5GdBdC�dCe�Z6GdDdE�dEe�Z7GdFdG�dGe�Z8GdHdI�dIe�Z9GdJdK�dKe!�Z:GdLdM�dMe�Z;GdNdO�dOe�Z<GdPdQ�dQe�Z=GdRdS�dSe�Z>GdTdU�dUe>�Z?GdVdW�dWe�Z@GdXdY�dYe�ZAGdZd[�d[e�ZBGd\d]�d]e�ZCGd^d_�d_e�ZDGd`da�daeD�ZEGdbdc�dceD�ZFGddde�dee�ZGGdfdg�dge�ZHGdhdi�die�ZIGdjdk�dkeI�ZJGdldm�dmeJ�ZKGdndo�doe�ZLGdpdq�dqeM�ZNGdrds�dseN�ZOGdtdu�dueN�ZPGdvdw�dweO�ZQGdxdy�dye
jR�ZSePd
dz�ZTePd{d|�ZUePd}d~�ZVe�d�Wd��Xe
���jYZZe�d��We�[d��Xe����j\Z]e�d��j^Z_e�d��We�[d��Xe����j\Z`e�d��We�[d��Xe����j\Zae�d��We�[d��Xe����j\Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d��Z�d�d„Z�d�dĄZ�d�dƄZ�d�dȄZ�d�dʄZ�d�d̄Z�d�d΄Z�d�dЄZ�d�d҄Z�d�dԄZ�d�dքZ�d�d؄Z�d�dڄZ�d�d܄Z�d�dބZ�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�dS)��N)�	hexdigits)�
itemgetter)�_encoded_words)�errors)�utilsz 	�(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%cCs dt|��dd��dd�dS)N�"�\�\\z\")�str�replace��value�r�2/usr/lib64/python3.8/email/_header_value_parser.py�quote_string`srz�
   =\?            # literal =?
   [^?]*          # charset
   \?             # literal ?
   [qQbB]         # literal 'q' or 'b', case insensitive
   \?             # literal ?
  .*?             # encoded word
  \?=             # literal ?=
cs�eZdZdZdZdZ�fdd�Zdd�Z�fdd�Ze	d	d
��Z
e	dd��Zd
d�Ze	dd��Z
e	dd��Zdd�Zddd�Zddd�Zddd�Z�ZS)�	TokenListNTcst�j||�g|_dS�N)�super�__init__�defects)�self�args�kw��	__class__rrryszTokenList.__init__cCsd�dd�|D��S)N�css|]}t|�VqdSr�r
��.0�xrrr�	<genexpr>~sz$TokenList.__str__.<locals>.<genexpr>��join�rrrr�__str__}szTokenList.__str__csd�|jjt����S�Nz{}({})��formatr�__name__r�__repr__r&rrrr,�s
�zTokenList.__repr__cCsd�dd�|D��S)Nrcss|]}|jr|jVqdSrrr rrrr#�sz"TokenList.value.<locals>.<genexpr>r$r&rrrr�szTokenList.valuecCstdd�|D�|j�S)Ncss|]}|jVqdSr)�all_defectsr rrrr#�sz(TokenList.all_defects.<locals>.<genexpr>)�sumrr&rrrr-�szTokenList.all_defectscCs|d��S�Nr)�startswith_fwsr&rrrr0�szTokenList.startswith_fwscCstdd�|D��S)Ncss|]}|jVqdSr)�
as_ew_allowed)r!�partrrrr#�sz*TokenList.as_ew_allowed.<locals>.<genexpr>)�allr&rrrr1�szTokenList.as_ew_allowedcCsg}|D]}|�|j�q|Sr)�extend�comments)rr5�tokenrrrr5�szTokenList.commentscCst||d�S)N��policy)�_refold_parse_tree�rr8rrr�fold�szTokenList.foldrcCst|j|d��dS)N��indent)�print�ppstr�rr=rrr�pprint�szTokenList.pprintcCsd�|j|d��S)N�
r<)r%�_ppr@rrrr?�szTokenList.ppstrccszd�||jj|j�V|D]4}t|d�s:|d�|�Vq|�|d�EdHq|jrdd�|j�}nd}d�||�VdS)Nz{}{}/{}(rCz*    !! invalid element in token list: {!r}z    z Defects: {}rz{}){})r*rr+�
token_type�hasattrrCr)rr=r6ZextrarrrrC�s�
�
z
TokenList._pp)r)r)r)r+�
__module__�__qualname__rD�syntactic_break�ew_combine_allowedrr'r,�propertyrr-r0r1r5r;rAr?rC�
__classcell__rrrrrss&





rc@s$eZdZedd��Zedd��ZdS)�WhiteSpaceTokenListcCsdS�N� rr&rrrr�szWhiteSpaceTokenList.valuecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)�comment)rD�contentr rrr�
<listcomp>�s
z0WhiteSpaceTokenList.comments.<locals>.<listcomp>rr&rrrr5�szWhiteSpaceTokenList.commentsN)r+rFrGrJrr5rrrrrL�s
rLc@seZdZdZdS)�UnstructuredTokenList�unstructuredN�r+rFrGrDrrrrrR�srRc@seZdZdZdS)�Phrase�phraseNrTrrrrrU�srUc@seZdZdZdS)�WordZwordNrTrrrrrW�srWc@seZdZdZdS)�CFWSList�cfwsNrTrrrrrX�srXc@seZdZdZdS)�Atom�atomNrTrrrrrZ�srZc@seZdZdZdZdS)�Tokenr6FN)r+rFrGrDZencode_as_ewrrrrr\�sr\c@seZdZdZdZdZdZdS)�EncodedWord�encoded-wordN)r+rFrGrD�cte�charset�langrrrrr]�sr]c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�QuotedString�
quoted-stringcCs"|D]}|jdkr|jSqdS�N�bare-quoted-string�rDr�rr"rrrrP�s
zQuotedString.contentcCs>g}|D]*}|jdkr&|�t|��q|�|j�qd�|�S)Nrer)rD�appendr
rr%)r�resr"rrr�quoted_value�s
zQuotedString.quoted_valuecCs"|D]}|jdkr|jSqdSrdrf�rr6rrr�stripped_value�s
zQuotedString.stripped_valueN)r+rFrGrDrJrPrjrlrrrrrb�s

	rbc@s$eZdZdZdd�Zedd��ZdS)�BareQuotedStringrecCstd�dd�|D���S)Nrcss|]}t|�VqdSrrr rrrr#sz+BareQuotedString.__str__.<locals>.<genexpr>)rr%r&rrrr'�szBareQuotedString.__str__cCsd�dd�|D��S)Nrcss|]}t|�VqdSrrr rrrr#sz)BareQuotedString.value.<locals>.<genexpr>r$r&rrrrszBareQuotedString.valueN)r+rFrGrDr'rJrrrrrrm�srmc@s8eZdZdZdd�Zdd�Zedd��Zedd	��Zd
S)�CommentrOcs(d�tdg�fdd��D�dggg��S)Nrrcsg|]}��|��qSr)�quoter r&rrrQsz#Comment.__str__.<locals>.<listcomp>�))r%r.r&rr&rr's��zComment.__str__cCs2|jdkrt|�St|��dd��dd��dd�S)NrOrrrz\(rpz\))rDr
r)rrrrrros
��z
Comment.quotecCsd�dd�|D��S)Nrcss|]}t|�VqdSrrr rrrr#sz"Comment.content.<locals>.<genexpr>r$r&rrrrPszComment.contentcCs|jgSr)rPr&rrrr5szComment.commentsN)	r+rFrGrDr'rorJrPr5rrrrrns
rnc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressListzaddress-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)�address�rDr rrrrQ's
z)AddressList.addresses.<locals>.<listcomp>rr&rrr�	addresses%szAddressList.addressescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS�rrN�rD�	mailboxesr rrrr#+s
�z(AddressList.mailboxes.<locals>.<genexpr>�r.r&rrrrw)s
��zAddressList.mailboxescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdSru�rD�
all_mailboxesr rrrr#0s
�z,AddressList.all_mailboxes.<locals>.<genexpr>rxr&rrrrz.s
��zAddressList.all_mailboxesN)r+rFrGrDrJrtrwrzrrrrrq!s

rqc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressrrcCs|djdkr|djSdS)Nr�group�rD�display_namer&rrrr~8szAddress.display_namecCs4|djdkr|dgS|djdkr*gS|djS�Nr�mailbox�invalid-mailboxrvr&rrrrw=s

zAddress.mailboxescCs:|djdkr|dgS|djdkr0|dgS|djSrryr&rrrrzEs


zAddress.all_mailboxesN)r+rFrGrDrJr~rwrzrrrrr{4s

r{c@s(eZdZdZedd��Zedd��ZdS)�MailboxList�mailbox-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)r�rsr rrrrQSs
z)MailboxList.mailboxes.<locals>.<listcomp>rr&rrrrwQszMailboxList.mailboxescCsdd�|D�S)NcSsg|]}|jdkr|�qS))r�r�rsr rrrrQWs
�z-MailboxList.all_mailboxes.<locals>.<listcomp>rr&rrrrzUszMailboxList.all_mailboxesN�r+rFrGrDrJrwrzrrrrr�Ms

r�c@s(eZdZdZedd��Zedd��ZdS)�	GroupList�
group-listcCs |r|djdkrgS|djS�Nrr�rvr&rrrrw_szGroupList.mailboxescCs |r|djdkrgS|djSr�ryr&rrrrzeszGroupList.all_mailboxesNr�rrrrr�[s

r�c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�Groupr|cCs|djdkrgS|djS�N�r�rvr&rrrrwpszGroup.mailboxescCs|djdkrgS|djSr�ryr&rrrrzvszGroup.all_mailboxescCs
|djSr/)r~r&rrrr~|szGroup.display_nameN)r+rFrGrDrJrwrzr~rrrrr�ls

r�c@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�NameAddr�	name-addrcCst|�dkrdS|djS�N�r)�lenr~r&rrrr~�szNameAddr.display_namecCs
|djS�N�����
local_partr&rrrr��szNameAddr.local_partcCs
|djSr���domainr&rrrr��szNameAddr.domaincCs
|djSr�)�router&rrrr��szNameAddr.routecCs
|djSr���	addr_specr&rrrr��szNameAddr.addr_specN�
r+rFrGrDrJr~r�r�r�r�rrrrr��s



r�c@s@eZdZdZedd��Zedd��Zedd��Zedd	��Zd
S)�	AngleAddrz
angle-addrcCs"|D]}|jdkr|jSqdS�N�	addr-spec)rDr�rgrrrr��s
zAngleAddr.local_partcCs"|D]}|jdkr|jSqdSr��rDr�rgrrrr��s
zAngleAddr.domaincCs"|D]}|jdkr|jSqdS)N�	obs-route)rD�domainsrgrrrr��s
zAngleAddr.routecCs<|D]2}|jdkr|jr"|jSt|j�|jSqdS)Nr�z<>)rDr�r�rrgrrrr��s

zAngleAddr.addr_specN)	r+rFrGrDrJr�r�r�r�rrrrr��s


r�c@seZdZdZedd��ZdS)�ObsRouter�cCsdd�|D�S)NcSsg|]}|jdkr|j�qSr�r�r rrrrQ�s
z$ObsRoute.domains.<locals>.<listcomp>rr&rrrr��szObsRoute.domainsN)r+rFrGrDrJr�rrrrr��sr�c@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�Mailboxr�cCs|djdkr|djSdS�Nrr�r}r&rrrr~�szMailbox.display_namecCs
|djSr/r�r&rrrr��szMailbox.local_partcCs
|djSr/r�r&rrrr��szMailbox.domaincCs|djdkr|djSdSr�)rDr�r&rrrr��sz
Mailbox.routecCs
|djSr/r�r&rrrr��szMailbox.addr_specNr�rrrrr��s



r�c@s,eZdZdZedd��ZeZZZZ	dS)�InvalidMailboxr�cCsdSrrr&rrrr~�szInvalidMailbox.display_nameNr�rrrrr��s
r�cs(eZdZdZdZe�fdd��Z�ZS)�Domainr�Fcsd�t�j���S�Nr�r%rr�splitr&rrrr��sz
Domain.domain)r+rFrGrDr1rJr�rKrrrrr��sr�c@seZdZdZdS)�DotAtom�dot-atomNrTrrrrr��sr�c@seZdZdZdZdS)�DotAtomTextz
dot-atom-textTN�r+rFrGrDr1rrrrr��sr�c@seZdZdZdZdS)�
NoFoldLiteralzno-fold-literalFNr�rrrrr�sr�c@sDeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dS)�AddrSpecr�FcCs
|djSr/r�r&rrrr�
szAddrSpec.local_partcCst|�dkrdS|djS)N�r�)r�r�r&rrrr�szAddrSpec.domaincCs<t|�dkr|djS|dj��|dj|dj��S)Nr�rr�r�)r�r�rstrip�lstripr&rrrrs
zAddrSpec.valuecCsLt|j�}t|�t|t�kr*t|j�}n|j}|jdk	rH|d|jS|S)N�@)�setr�r��
DOT_ATOM_ENDSrr�)rZnamesetZlprrrr�s

zAddrSpec.addr_specN)
r+rFrGrDr1rJr�r�rr�rrrrr�s


r�c@seZdZdZdZdS)�ObsLocalPartzobs-local-partFNr�rrrrr�&sr�cs4eZdZdZdZedd��Ze�fdd��Z�ZS)�DisplayNamezdisplay-nameFcCs�t|�}t|�dkr|jS|djdkr4|�d�n*|ddjdkr^t|ddd��|d<|djdkrv|��n*|ddjdkr�t|ddd��|d<|jS)NrrYr�r�)rr�rrD�pop)rrirrrr~1s
zDisplayName.display_namecs�d}|jrd}n|D]}|jdkrd}qt|�dkr�|r�d}}|djdks`|ddjdkrdd}|djdks�|ddjdkr�d}|t|j�|St�jSdS)	NFTrcrrrYrNr�)rrDr�rr~rr)rror"ZpreZpostrrrrBs
  zDisplayName.value)	r+rFrGrDrIrJr~rrKrrrrr�,s
r�c@s,eZdZdZdZedd��Zedd��ZdS)�	LocalPartz
local-partFcCs&|djdkr|djS|djSdS)Nrrc)rDrjrr&rrrr[s
zLocalPart.valuecCs�tg}t}d}|dtgD]�}|jdkr,q|r\|jdkr\|djdkr\t|dd��|d<t|t�}|r�|jdkr�|djdkr�|�t|dd���n
|�|�|d}|}qt|dd��}|jS)NFrrY�dotr�r�)�DOTrDr�
isinstancerhr)rriZlastZ
last_is_tl�tokZis_tlrrrr�bs(
�
�
zLocalPart.local_partN)r+rFrGrDr1rJrr�rrrrr�Vs
r�cs4eZdZdZdZe�fdd��Zedd��Z�ZS)�
DomainLiteralzdomain-literalFcsd�t�j���Sr�r�r&rrrr�szDomainLiteral.domaincCs"|D]}|jdkr|jSqdS)N�ptextrfrgrrr�ip�s
zDomainLiteral.ip)	r+rFrGrDr1rJr�r�rKrrrrr�zsr�c@seZdZdZdZdZdS)�MIMEVersionzmime-versionN)r+rFrGrD�major�minorrrrrr��sr�c@s4eZdZdZdZdZdZedd��Zedd��Z	dS)	�	Parameter�	parameterF�us-asciicCs|jr|djSdSr�)�	sectioned�numberr&rrr�section_number�szParameter.section_numbercCsf|D]\}|jdkr|jS|jdkr|D]4}|jdkr*|D] }|jdkr<|jSq<q*qdS)Nrrcrer)rDrlrkrrr�param_value�s




zParameter.param_valueN)
r+rFrGrDr��extendedr`rJr�r�rrrrr��s
r�c@seZdZdZdS)�InvalidParameter�invalid-parameterNrTrrrrr��sr�c@seZdZdZedd��ZdS)�	Attribute�	attributecCs$|D]}|j�d�r|jSqdS)N�attrtext)rD�endswithrrkrrrrl�szAttribute.stripped_valueN�r+rFrGrDrJrlrrrrr��sr�c@seZdZdZdZdS)�Section�sectionN)r+rFrGrDr�rrrrr��sr�c@seZdZdZedd��ZdS)�ValuercCs2|d}|jdkr|d}|j�d�r,|jS|jS)NrrYr�)rcr�zextended-attribute)rDr�rlrrkrrrrl�s
�zValue.stripped_valueNr�rrrrr��sr�c@s(eZdZdZdZedd��Zdd�ZdS)�MimeParameters�mime-parametersFc
cs�i}|D]T}|j�d�sq|djdkr*q|dj��}||krHg||<||�|j|f�q|��D�]~\}}t|td�d�}|dd}|j	}|j
s�t|�dkr�|dddkr�|ddj�t
�d��|dd�}g}d}|D]�\}	}
|	|k�r(|
j
�s|
j�t
�d��q�n|
j�t
�d��|d7}|
j}|
j
�r�ztj�|�}Wn&tk
�rttjj|d	d
�}YnRXz|�|d�}Wn"tk
�r�|�dd�}YnXt�|��r�|
j�t
���|�|�q�d
�|�}||fVqfdS)Nr�rr�)�keyr�z.duplicate parameter name; duplicate(s) ignoredz+duplicate parameter name; duplicate ignoredz(inconsistent RFC2231 parameter numberingzlatin-1)�encoding�surrogateescaper�r)rDr�r�striprhr��items�sortedrr`r�r�rr�InvalidHeaderDefectr��urllib�parseZunquote_to_bytes�UnicodeEncodeErrorZunquote�decode�LookupErrorr�_has_surrogates�UndecodableBytesDefectr%)r�paramsr6�name�partsZfirst_paramr`Zvalue_parts�ir��paramrrrrr��s`�

�
�
zMimeParameters.paramscCsTg}|jD].\}}|r.|�d�|t|���q
|�|�q
d�|�}|rPd|SdS)N�{}={}z; rNr)r�rhr*rr%)rr�r�rrrrr's
zMimeParameters.__str__N)r+rFrGrDrHrJr�r'rrrrr��s

Er�c@seZdZdZedd��ZdS)�ParameterizedHeaderValueFcCs&t|�D]}|jdkr|jSqiS)Nr�)�reversedrDr�rkrrrr�-s
zParameterizedHeaderValue.paramsN)r+rFrGrHrJr�rrrrr�'sr�c@seZdZdZdZdZdZdS)�ContentTypezcontent-typeF�textZplainN)r+rFrGrDr1�maintype�subtyperrrrr�5sr�c@seZdZdZdZdZdS)�ContentDispositionzcontent-dispositionFN)r+rFrGrDr1�content_dispositionrrrrr�<sr�c@seZdZdZdZdZdS)�ContentTransferEncodingzcontent-transfer-encodingFZ7bitN)r+rFrGrDr1r_rrrrr�Bsr�c@seZdZdZdZdS)�HeaderLabelzheader-labelFNr�rrrrr�Hsr�c@seZdZdZdZdd�ZdS)�MsgIDzmsg-idFcCst|�|jSr)r
�linesepr:rrrr;Qsz
MsgID.foldN)r+rFrGrDr1r;rrrrr�Msr�c@seZdZdZdS)�	MessageIDz
message-idNrTrrrrr�Vsr�c@seZdZdZdS)�InvalidMessageIDzinvalid-message-idNrTrrrrr�Zsr�c@seZdZdZdS)�Header�headerNrTrrrrr�^sr�csreZdZdZdZdZ�fdd�Z�fdd�Zdd�Ze	dd	��Z
d�fdd�	Zd
d�Ze	dd��Z
dd�Z�ZS)�TerminalTcst��||�}||_g|_|Sr)r�__new__rDr)�clsrrDrrrrr�lszTerminal.__new__csd�|jjt����Sr(r)r&rrrr,rszTerminal.__repr__cCst|jjd|j�dS)N�/)r>rr+rDr&rrrrAuszTerminal.pprintcCs
t|j�Sr)�listrr&rrrr-xszTerminal.all_defectsrc	s2d�||jj|jt���|js"dn
d�|j��gS)Nz
{}{}/{}({}){}rz {})r*rr+rDrr,rr@rrrrC|s�zTerminal._ppcCsdSrrr&rrr�pop_trailing_ws�szTerminal.pop_trailing_wscCsgSrrr&rrrr5�szTerminal.commentscCst|�|jfSr)r
rDr&rrr�__getnewargs__�szTerminal.__getnewargs__)r)r+rFrGr1rIrHr�r,rArJr-rCr�r5rrKrrrrr�fs
	
r�c@s eZdZedd��Zdd�ZdS)�WhiteSpaceTerminalcCsdSrMrr&rrrr�szWhiteSpaceTerminal.valuecCsdS)NTrr&rrrr0�sz!WhiteSpaceTerminal.startswith_fwsN�r+rFrGrJrr0rrrrr�s
rc@s eZdZedd��Zdd�ZdS)�
ValueTerminalcCs|Srrr&rrrr�szValueTerminal.valuecCsdS)NFrr&rrrr0�szValueTerminal.startswith_fwsNrrrrrr�s
rc@s eZdZedd��Zdd�ZdS)�EWWhiteSpaceTerminalcCsdSr�rr&rrrr�szEWWhiteSpaceTerminal.valuecCsdSr�rr&rrrr'�szEWWhiteSpaceTerminal.__str__N)r+rFrGrJrr'rrrrr�s
rc@seZdZdS)�_InvalidEwErrorN)r+rFrGrrrrr�srr��,�list-separatorr�zroute-component-markerz([{}]+)rz[^{}]+z[\x00-\x20\x7F]cCs>t|�}|r|j�t�|��t�|�r:|j�t�d��dS)Nz*Non-ASCII characters found in header token)�_non_printable_finderrrhrZNonPrintableDefectrr�r�)�xtextZnon_printablesrrr�_validate_xtext�s

�r
cCs�t|d�^}}g}d}d}tt|��D]L}||dkrJ|rDd}d}nd}q&|rTd}n|||krdq||�||�q&|d}d�|�d�||d�g|�|fS)Nr�FrTr)�
_wsp_splitter�ranger�rhr%)r�endcharsZfragment�	remainderZvchars�escape�had_qp�posrrr�_get_ptext_to_endchars�s$	rcCs.|��}t|dt|�t|��d�}||fS)N�fws)r�rr�)rZnewvaluerrrr�get_fwssrc
	Cs�t�}|�d�s t�d�|���|dd��dd�^}}||dd�krXt�d�|���d�|�}t|�dkr�|dtkr�|dtkr�|�	d�dkr�|�dd�^}}|d|}t|���dkr�|j
�t�d	��||_
d�|�}zt�d|d�\}}}}	Wn*ttfk
�r*td
�|j
���YnX||_||_|j
�|	�|�r�|dtk�rrt|�\}
}|�|
��qDt|d�^}}t|d�}t|�|�|�d�|�}�qD|�r�|dtk�r�|j
�t�d��||fS)
N�=?z"expected encoded word but found {}r�z?=r�rr�?zwhitespace inside encoded wordz!encoded word format invalid: '{}'�vtextz.missing trailing whitespace after encoded-word)r]�
startswithr�HeaderParseErrorr*r�r%r�r�countrrhr�r_�_ewr��
ValueError�KeyErrorrr`rar4�WSPrrrr
)
rZewr�rZremstr�restr�r`rarr6�charsrrrr�get_encoded_wordsd
��

�
��
�

�




�r!cCsFt�}|�rB|dtkr0t|�\}}|�|�qd}|�d�r�zt|�\}}Wn,tk
rfd}Yn�tjk
rzYnrXd}t	|�dkr�|dj
dkr�|j�t�d��d}|r�t	|�dkr�|d	j
d
kr�t
|dd�|d<|�|�qt|d�^}}|�rt�|��r|�d�^}}t|d�}t|�|�|�d�|�}q|S)
NrTrFr�rz&missing whitespace before encoded wordr����r^rr)rRrrrhrr!rrrr�rDrr�rr�rfc2047_matcher�search�	partitionrr
r%)rrSr6�valid_ewZhave_wsr�rrrrr�get_unstructured?sJ


��


r'cCs*t|d�\}}}t|d�}t|�||fS)Nz()r�)rrr
�rr��_rrr�get_qp_ctext�s
r*cCs*t|d�\}}}t|d�}t|�||fS)Nr
r�)rrr
r(rrr�get_qcontent�s

r+cCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)Nzexpected atext but found '{}'�atext)�_non_atom_end_matcherrrr*r|r�rr
)r�mr,rrr�	get_atext�s�
r/cCsr|ddkrt�d�|���t�}|dd�}|rT|ddkrTt|�\}}|�|�|�rB|ddk�rB|dtkr�t|�\}}n�|dd�dk�r*d}z&t|�\}}|j	�t�
d��d	}Wn"tjk
r�t|�\}}YnX|�r6t|�dk�r6|d
jdk�r6|djd
k�r6t
|d
d�|d
<nt|�\}}|�|�qT|�sb|j	�t�
d��||fS||dd�fS)Nrr
zexpected '"' but found '{}'r�r�rFz!encoded word inside quoted stringTr�rr"r^z"end of header inside quoted string)rrr*rmr+rhrrr!rr�r�rDr)rZbare_quoted_stringr6r&rrr�get_bare_quoted_string�sL�

���

�r0cCs�|r |ddkr t�d�|���t�}|dd�}|r�|ddkr�|dtkr\t|�\}}n&|ddkrvt|�\}}nt|�\}}|�|�q2|s�|j	�t�
d��||fS||dd�fS)Nrrzexpected '(' but found '{}'r�rpzend of header inside comment)rrr*rnrr�get_commentr*rhrr�)rrOr6rrrr1�s&�
�r1cCsPt�}|rH|dtkrH|dtkr0t|�\}}nt|�\}}|�|�q||fSr/)rX�CFWS_LEADERrrr1rh)rrYr6rrr�get_cfws�sr3cCspt�}|r,|dtkr,t|�\}}|�|�t|�\}}|�|�|rh|dtkrht|�\}}|�|�||fSr/)rbr2r3rhr0)rZ
quoted_stringr6rrr�get_quoted_strings


r4cCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���|�d�r�zt	|�\}}Wq�tjk
r�t
|�\}}Yq�Xnt
|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)Nrzexpected atom but found '{}'r)rZr2r3rh�	ATOM_ENDSrrr*rr!r/)rr[r6rrr�get_atoms&
�


r6cCs�t�}|r|dtkr&t�d�|���|rt|dtkrtt|�\}}|�|�|r&|ddkr&|�t�|dd�}q&|dtkr�t�d�d|���||fS)Nrz8expected atom at a start of dot-atom-text but found '{}'rr�r�z4expected atom at end of dot-atom-text but found '{}')r�r5rrr*r/rhr�)rZ
dot_atom_textr6rrr�get_dot_atom_text0s �

�r7cCs�t�}|dtkr(t|�\}}|�|�|�d�rhzt|�\}}Wqttjk
rdt|�\}}YqtXnt|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)Nrr)	r�r2r3rhrr!rrr7)rZdot_atomr6rrr�get_dot_atomCs



r8cCs�|dtkrt|�\}}nd}|s,t�d��|ddkrFt|�\}}n*|dtkrdt�d�|���nt|�\}}|dk	r�|g|dd�<||fS)Nrz5Expected 'atom' or 'quoted-string' but found nothing.r
z1Expected 'atom' or 'quoted-string' but found '{}')r2r3rrr4�SPECIALSr*r6)r�leaderr6rrr�get_word\s"��r;cCs�t�}zt|�\}}|�|�Wn(tjk
rH|j�t�d��YnX|r�|dtkr�|ddkr�|�t�|j�t�	d��|dd�}qJzt|�\}}WnDtjk
r�|dt
kr�t|�\}}|j�t�	d��n�YnX|�|�qJ||fS)Nzphrase does not start with wordrrzperiod in 'phrase'r�zcomment found without atom)rUr;rhrrrr��PHRASE_ENDSr��ObsoleteHeaderDefectr2r3)rrVr6rrr�
get_phrase~s4
�

�
�r>cCsvt�}d}|dtkr"t|�\}}|s6t�d�|���zt|�\}}Wn^tjk
r�zt|�\}}Wn6tjk
r�|ddkr�|dtkr��t	�}YnXYnX|dk	r�|g|dd�<|�
|�|�r4|ddks�|dtk�r4tt|�|�\}}|j
dk�r|j�
t�d��n|j�
t�d��||d<z|j�d�Wn(tk
�rl|j�
t�d��YnX||fS)	Nrz"expected local-part but found '{}'r�invalid-obs-local-partz<local-part is not dot-atom, quoted-string, or obs-local-partz,local-part is not a dot-atom (contains CFWS)�asciiz)local-part contains non-ASCII characters))r�r2r3rrr*r8r;r<rrh�get_obs_local_partr
rDrr�r=r�encoder�ZNonASCIILocalPartDefect)rr�r:r6�obs_local_partrrr�get_local_part�sJ�
 
�
�
�rDcCs�t�}d}|�r(|ddks*|dtk�r(|ddkrj|rL|j�t�d��|�t�d}|dd�}q
nD|ddkr�|�t|dd��|dd�}|j�t�d	��d}q
|r�|d
jdkr�|j�t�d��zt	|�\}}d}Wn4tj
k
�r|dtk�r
�t|�\}}YnX|�|�q
|djdk�sX|djd
k�rj|djdk�rj|j�t�d��|d
jdk�s�|d
jd
k�r�|djdk�r�|j�t�d��|j�r�d|_||fS)NFrrrzinvalid repeated '.'Tr��misplaced-specialz/'\' character outside of quoted-string/ccontentr�r�zmissing '.' between wordsrYz!Invalid leading '.' in local partr"z"Invalid trailing '.' in local partr?)
r�r<rrhrr�r�rrDr;rr2r3)rrCZlast_non_ws_was_dotr6rrrrA�sj 
�
�
�
���
���
�rAcCs@t|d�\}}}t|d�}|r0|j�t�d��t|�||fS)Nz[]r�z(quoted printable found in domain-literal)rrrrhrr=r
)rr�rrrr�	get_dtext�s

�rFcCs,|rdS|�t�d��|�tdd��dS)NFz"end of input inside domain-literal�]�domain-literal-endT)rhrr�r)r�domain_literalrrr�_check_for_early_dl_ends�rJcCsjt�}|dtkr(t|�\}}|�|�|s6t�d��|ddkrRt�d�|���|dd�}t||�rp||fS|�tdd��|dt	kr�t
|�\}}|�|�t|�\}}|�|�t||�r�||fS|dt	kr�t
|�\}}|�|�t||�r�||fS|ddk�rt�d�|���|�tdd	��|dd�}|�rb|dtk�rbt|�\}}|�|�||fS)
Nrzexpected domain-literal�[z6expected '[' at start of domain-literal but found '{}'r�zdomain-literal-startrGz4expected ']' at end of domain-literal but found '{}'rH)r�r2r3rhrrr*rJrrrrF)rrIr6rrr�get_domain_literalsH

�





�
rLcCsrt�}d}|dtkr"t|�\}}|s6t�d�|���|ddkrvt|�\}}|dk	rd|g|dd�<|�|�||fSzt|�\}}Wn"tjk
r�t	|�\}}YnX|r�|ddkr�t�d��|dk	r�|g|dd�<|�|�|�rj|ddk�rj|j
�t�d��|djdk�r*|d|dd�<|�rj|ddk�rj|�t
�t	|d	d��\}}|�|��q*||fS)
Nrzexpected domain but found '{}'rKr�zInvalid Domainrz(domain is not a dot-atom (contains CFWS)r�r�)r�r2r3rrr*rLrhr8r6rr=rDr�)rr�r:r6rrr�
get_domain=sD�



�
rMcCs|t�}t|�\}}|�|�|r,|ddkrF|j�t�d��||fS|�tdd��t|dd��\}}|�|�||fS)Nrr�z#addr-spec local part with no domain�address-at-symbolr�)r�rDrhrrr�rrM)rr�r6rrr�
get_addr_speccs

�
rOcCs�t�}|rj|ddks"|dtkrj|dtkrFt|�\}}|�|�q|ddkr|�t�|dd�}q|rz|ddkr�t�d�|���|�t�t	|dd��\}}|�|�|�r>|ddk�r>|�t�|dd�}|s�q>|dtk�rt|�\}}|�|�|ddkr�|�t�t	|dd��\}}|�|�q�|�sNt�d��|ddk�rlt�d�|���|�t
dd	��||dd�fS)
Nrrr�r�z(expected obs-route domain but found '{}'z%end of header while parsing obs-route�:z4expected ':' marking end of obs-route but found '{}'zend-of-obs-route-marker)r�r2r3rh�
ListSeparatorrrr*�RouteComponentMarkerrMr)rZ	obs_router6rrr�
get_obs_routessF
�





�rScCs�t�}|dtkr(t|�\}}|�|�|r8|ddkrHt�d�|���|�tdd��|dd�}|ddkr�|�tdd��|j�t�	d��|dd�}||fSzt
|�\}}Wnztjk
�r0z"t|�\}}|j�t�d	��Wn(tjk
�rt�d
�|���YnX|�|�t
|�\}}YnX|�|�|�r^|ddk�r^|dd�}n|j�t�	d��|�tdd��|�r�|dtk�r�t|�\}}|�|�||fS)Nr�<z"expected angle-addr but found '{}'zangle-addr-startr��>zangle-addr-endznull addr-spec in angle-addrz*obsolete route specification in angle-addrz.expected addr-spec or obs-route but found '{}'z"missing trailing '>' on angle-addr)
r�r2r3rhrrr*rrr�rOrSr=)rZ
angle_addrr6rrr�get_angle_addr�sT
�
�
�
�



�
rVcCs<t�}t|�\}}|�|dd��|jdd�|_||fSr)r�r>r4r)rr~r6rrr�get_display_name�s
rWcCs�t�}d}|dtkr6t|�\}}|s6t�d�|���|ddkr�|dtkr^t�d�|���t|�\}}|s~t�d�|���|dk	r�|g|ddd�<d}|�|�t	|�\}}|dk	r�|g|dd�<|�|�||fS)Nrz!expected name-addr but found '{}'rT)
r�r2r3rrr*r<rWrhrV)rZ	name_addrr:r6rrr�
get_name_addr�s6���

rXcCs�t�}zt|�\}}WnNtjk
rdzt|�\}}Wn&tjk
r^t�d�|���YnXYnXtdd�|jD��r�d|_|�	|�||fS)Nzexpected mailbox but found '{}'css|]}t|tj�VqdSr)r�rr�r rrrr#s�zget_mailbox.<locals>.<genexpr>r�)
r�rXrrrOr*�anyr-rDrh)rr�r6rrr�get_mailbox�s ��
rZcCsdt�}|r\|d|kr\|dtkrD|�t|dd��|dd�}qt|�\}}|�|�q||fS)NrrEr�)r�r<rhrr>)rr
Zinvalid_mailboxr6rrr�get_invalid_mailboxs�r[cCs�t�}|�r�|ddk�r�zt|�\}}|�|�W�ntjk
�r<d}|dtkr�t|�\}}|rv|ddkr�|�|�|j�t�d��n@t	|d�\}}|dk	r�|g|dd�<|�|�|j�t�
d��nb|ddkr�|j�t�d��nBt	|d�\}}|dk	�r|g|dd�<|�|�|j�t�
d��YnX|�r�|ddk�r�|d}d|_t	|d�\}}|�|�|j�t�
d��|r|ddkr|�t
�|d	d�}q||fS)
Nr�;z,;zempty element in mailbox-listzinvalid mailbox in mailbox-listrr�r�r�)r�rZrhrrr2r3rr=r[r�rDr4rQ)rZmailbox_listr6r:r�rrr�get_mailbox_listsX

�

�
�


�

�
r]cCst�}|s$|j�t�d��||fSd}|r�|dtkr�t|�\}}|sl|j�t�d��|�|�||fS|ddkr�|�|�||fSt|�\}}t|j	�dkr�|dk	r�|�|�|�
|�|j�t�d��||fS|dk	r�|g|dd�<|�|�||fS)Nzend of header before group-listrzend of header in group-listr\zgroup-list with empty entries)r�rrhrr�r2r3r]r�rzr4r=)rZ
group_listr:r6rrr�get_group_listWs>
�
�




�
r^cCs t�}t|�\}}|r"|ddkr2t�d�|���|�|�|�tdd��|dd�}|r�|ddkr�|�tdd��||dd�fSt|�\}}|�|�|s�|j�t�	d��n|ddkr�t�d	�|���|�tdd��|dd�}|�r|dt
k�rt|�\}}|�|�||fS)
NrrPz8expected ':' at end of group display name but found '{}'zgroup-display-name-terminatorr�r\zgroup-terminatorzend of header in groupz)expected ';' at end of group but found {})r�rWrrr*rhrr^rr�r2r3)rr|r6rrr�	get_group|s8�


��
r_cCsxt�}zt|�\}}WnNtjk
rdzt|�\}}Wn&tjk
r^t�d�|���YnXYnX|�|�||fS)Nzexpected address but found '{}')r{r_rrrZr*rh)rrrr6rrr�get_address�s�
r`c
Cs�t�}|�r�zt|�\}}|�|�W�n tjk
�rH}z�d}|dtkr�t|�\}}|rj|ddkr�|�|�|j�t�d��nFt	|d�\}}|dk	r�|g|dd�<|�t
|g��|j�t�d��nh|ddkr�|j�t�d��nHt	|d�\}}|dk	�r|g|dd�<|�t
|g��|j�t�d��W5d}~XYnX|�r�|ddk�r�|dd}d|_t	|d�\}}|�
|�|j�t�d��|r|�tdd��|d	d�}q||fS)
Nrrz"address-list entry with no contentzinvalid address in address-listzempty element in address-listr�r�rr�)rqr`rhrrr2r3rr=r[r{r�rDr4r)rZaddress_listr6�errr:r�rrr�get_address_list�sX


�
�
�

�

�rbcCs�t�}|st�d�|���|ddkr6t�d�|���|�tdd��|dd�}t|�\}}|�|�|rx|ddkr�t�d�|���|�tdd	��||dd�fS)
Nz'expected no-fold-literal but found '{}'rrKz;expected '[' at the start of no-fold-literal but found '{}'zno-fold-literal-startr�rGz9expected ']' at the end of no-fold-literal but found '{}'zno-fold-literal-end)r�rrr*rhrrF)rZno_fold_literalr6rrr�get_no_fold_literal�s.���
��rccCs�t�}|r,|dtkr,t|�\}}|�|�|r<|ddkrLt�d�|���|�tdd��|dd�}zt|�\}}Wn`tjk
r�z"t	|�\}}|j
�t�d��Wn&tjk
r�t�d�|���YnXYnX|�|�|r�|ddk�r@|j
�t�d	��|�r8|dd
k�r8|�td
d��|dd�}||fS|�tdd��|dd�}zt|�\}}Wn�tjk
�rzt
|�\}}Wnrtjk
�r}zPz"t|�\}}|j
�t�d
��Wn(tjk
�r�t�d�|���YnXW5d}~XYnXYnX|�|�|�r6|dd
k�r6|dd�}n|j
�t�d��|�td
d��|�r�|dtk�r�t|�\}}|�|�||fS)NrrTzexpected msg-id but found '{}'zmsg-id-startr�zobsolete id-left in msg-idz4expected dot-atom-text or obs-id-left but found '{}'r�zmsg-id with no id-rightrUz
msg-id-endrNzobsolete id-right in msg-idzFexpected dot-atom-text, no-fold-literal or obs-id-right but found '{}'zmissing trailing '>' on msg-id)r�r2r3rhrrr*rr7rArr=r�rcrM)rZmsg_idr6�errr�
get_msg_ids~
�
�
��

�
�
��"

�
rec
Cs�t�}zt|�\}}|�|�WnLtjk
rl}z,t|�}t|�}|j�t�d�	|���W5d}~XYnX|r�|j�t�d�	|���|S)NzInvalid msg-id: {!r}zUnexpected {!r})
r�rerhrrr'r�rr�r*)rZ
message_idr6Zexrrr�parse_message_idIs�
�rfcCs�t�}|s |j�t�d��|S|dtkrXt|�\}}|�|�|sX|j�t�d��d}|r�|ddkr�|dtkr�||d7}|dd�}q\|��s�|j�t�d�	|���|�t
|d��nt|�|_|�t
|d	��|�r|dtk�rt|�\}}|�|�|�r|ddk�rT|jdk	�r:|j�t�d
��|�rP|�t
|d��|S|�t
dd��|dd�}|�r�|dtk�r�t|�\}}|�|�|�s�|jdk	�r�|j�t�d
��|Sd}|�r�|dtk�r�||d7}|dd�}�q�|���s*|j�t�d�	|���|�t
|d��nt|�|_
|�t
|d	��|�rn|dtk�rnt|�\}}|�|�|�r�|j�t�d
��|�t
|d��|S)Nz%Missing MIME version number (eg: 1.0)rz0Expected MIME version number but found only CFWSrrr�z1Expected MIME major version number but found {!r}r	�digitsz0Incomplete MIME version; found only major numberzversion-separatorz1Expected MIME minor version number but found {!r}z'Excess non-CFWS text after MIME version)r�rrhr�HeaderMissingRequiredValuer2r3�isdigitr�r*r�intr�r�)rZmime_versionr6rgrrr�parse_mime_versiones�
�

�
�


�

�

�


�rkcCsdt�}|r\|ddkr\|dtkrD|�t|dd��|dd�}qt|�\}}|�|�q||fS)Nrr\rEr�)r�r<rhrr>)rZinvalid_parameterr6rrr�get_invalid_parameter�s�rlcCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)Nzexpected ttext but found '{}'�ttext)�_non_token_end_matcherrrr*r|r�rr
)rr.rmrrr�	get_ttext�s	�
rocCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS�Nrzexpected token but found '{}')	r\r2r3rh�
TOKEN_ENDSrrr*ro)rZmtokenr6rrr�	get_token�s	
�

rrcCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)Nz expected attrtext but found {!r}r�)�_non_attribute_end_matcherrrr*r|r�rr
�rr.r�rrr�get_attrtext�s	�
rucCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fSrp)	r�r2r3rh�ATTRIBUTE_ENDSrrr*ru�rr�r6rrr�
get_attribute�s	
�

rxcCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)Nz)expected extended attrtext but found {!r}�extended-attrtext)�#_non_extended_attribute_end_matcherrrr*r|r�rr
rtrrr�get_extended_attrtext	s�
r{cCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fSrp)	r�r2r3rh�EXTENDED_ATTRIBUTE_ENDSrrr*r{rwrrr�get_extended_attribute!	s
�

r}cCs�t�}|r|ddkr&t�d�|���|�tdd��|dd�}|rR|d��sbt�d�|���d}|r�|d��r�||d7}|dd�}qf|ddkr�|dkr�|j�t�d	��t	|�|_
|�t|d
��||fS)Nr�*zExpected section but found {}zsection-markerr�z$Expected section number but found {}r�0z'section number has an invalid leading 0rg)r�rrr*rhrrirZInvalidHeaderErrorrjr�)rr�rgrrr�get_section7	s,	��
�
r�cCs�t�}|st�d��d}|dtkr0t|�\}}|sDt�d�|���|ddkr^t|�\}}nt|�\}}|dk	r�|g|dd�<|�|�||fS)Nz&Expected value but found end of stringrz Expected value but found only {}r
)	r�rrr2r3r*r4r}rh)r�vr:r6rrr�	get_valueU	s"
�
r�cCs�t�}t|�\}}|�|�|r,|ddkrL|j�t�d�|���||fS|ddkr�z t|�\}}d|_|�|�Wntj	k
r�YnX|s�t�	d��|ddkr�|�t
dd��|dd�}d|_|dd	kr�t�	d
��|�t
d	d��|dd�}d}|�r,|dtk�r,t
|�\}}|�|�d}|}|j�rF|�rF|ddk�rFt|�\}}|j}d
}|jdk�r�|�r�|ddk�r�d}n$t|�\}}	|	�r�|	ddk�r�d}n(zt|�\}}	WnYnX|	�s�d}|�r0|j�t�d��|�|�|D](}
|
jdk�rg|
dd�<|
}�q*�q|}nd}|j�t�d��|�r`|ddk�r`d}nt|�\}}|j�r�|jdk�r�|�r�|ddk�r�|�|�|dk	�r�|}||fS|j�t�d��|�s�|j�t�d��|�|�|dk�r�||fSn�|dk	�r@|D]}
|
jdk�r
�q$�q
|
jdk|�|
�|
j|_|ddk�r^t�	d�|���|�t
dd��|dd�}|�r�|ddk�r�t|�\}}|�|�|j|_|�r�|ddk�r�t�	d�|���|�t
dd��|dd�}|dk	�rdt�}|�r^|dtk�rt|�\}}n2|ddk�rDt
dd�}|dd�}nt|�\}}|�|��q�|}nt|�\}}|�|�|dk	�r�|}||fS)Nrr\z)Parameter contains name ({}) but no valuer~TzIncomplete parameterzextended-parameter-markerr��=zParameter not followed by '='�parameter-separatorr
F�'z5Quoted string value for extended parameter is invalidrezZParameter marked as extended but appears to have a quoted string value that is non-encodedzcApparent initial-extended-value but attribute was not marked as extended or was not initial sectionz(Missing required charset/lang delimitersryr�z=Expected RFC2231 char/lang encoding delimiter, but found {!r}zRFC2231-delimiterz;Expected RFC2231 char/lang encoding delimiter, but found {}ZDQUOTE)r�rxrhrrr�r*r�r�rrr�r2r3r4rlr�rur{rDr�rr`rar�rrr+)rr�r6r:rZappendtoZqstringZinner_valueZ
semi_validr�tr�rrr�
get_parameterk	s�
�



�


�


�
�






�
�



r�c
Csjt�}|�rfzt|�\}}|�|�Wn�tjk
r�}z�d}|dtkrVt|�\}}|sp|�|�|WY�xS|ddkr�|dk	r�|�|�|j�t�d��n@t	|�\}}|r�|g|dd�<|�|�|j�t�d�
|���W5d}~XYnX|�rD|ddk�rD|d}d|_t	|�\}}|�|�|j�t�d�
|���|r|�t
dd��|d	d�}q|S)
Nrr\zparameter entry with no contentzinvalid parameter {!r}r�r�z)parameter with invalid trailing text {!r}r�r�)r�r�rhrrr2r3rr�rlr*rDr4r)rZmime_parametersr6rar:r�rrr�parse_mime_parameters�	sJ



�

�

�r�cCs�|rV|ddkrV|dtkr>|�t|dd��|dd�}qt|�\}}|�|�q|s^dS|�tdd��|�t|dd���dS)Nrr\rEr�r�)r<rhrr>r�)Z	tokenlistrr6rrr�_find_mime_parameters-
sr�c
Cs�t�}d}|s$|j�t�d��|Szt|�\}}Wn<tjk
rp|j�t�d�|���t	||�|YSX|�|�|r�|ddkr�|j�t�d��|r�t	||�|S|j
����|_
|�tdd��|dd�}zt|�\}}Wn>tjk
�r*|j�t�d	�|���t	||�|YSX|�|�|j
����|_|�sP|S|dd
k�r�|j�t�d�|���|`
|`t	||�|S|�td
d��|�t|dd���|S)
NFz"Missing content type specificationz(Expected content maintype but found {!r}rr�zInvalid content typezcontent-type-separatorr�z'Expected content subtype but found {!r}r\z<Only parameters are valid after content type, but found {!r}r�)r�rrhrrhrrrr�r*r�rr��lowerr�rr�r�)rZctypeZrecoverr6rrr�parse_content_type_header=
sd
�
�



�

�



��
r�c
Cs�t�}|s |j�t�d��|Szt|�\}}Wn<tjk
rl|j�t�d�|���t	||�|YSX|�|�|j
����|_
|s�|S|ddkr�|j�t�d�|���t	||�|S|�tdd��|�t|dd���|S)NzMissing content dispositionz+Expected content disposition but found {!r}rr\zCOnly parameters are valid after content disposition, but found {!r}r�r�)r�rrhrrhrrrr�r*r�rr�r�r�rr�)rZdisp_headerr6rrr� parse_content_disposition_headerv
s:
�
�



��
r�c
Cs�t�}|s |j�t�d��|Szt|�\}}Wn.tjk
r^|j�t�d�|���YnX|�|�|j	�
���|_|s�|S|r�|j�t�d��|dt
kr�|�t|dd��|dd�}q�t|�\}}|�|�q�|S)Nz!Missing content transfer encodingz1Expected content transfer encoding but found {!r}z*Extra text after content transfer encodingrrEr�)r�rrhrrhrrrr�r*rr�r�r_r<rr>)rZ
cte_headerr6rrr�&parse_content_transfer_encoding_header�
s4
�
�

�r�cCsDd}|r@|dr@|ddtkr@|dd}|ddd�|d<|S)Nrr�)r)�linesZwsprrr�_steal_trailing_WSP_if_exists�
s
r�cCs�|jp
tj}|jrdnd}dg}d}d}d}tdd�}t|�}	|	�r�|	�d�}
|
|kr`|d8}q>t|
�}|
jdkr�t	|�t
@r�d	}z|�|�|}Wn6tk
r�t
d
d�|
jD��r�d}nd}d	}YnX|
jd
kr�t|
|||�q>|�r�|�s�|
j�spd}d}|
j�rp|
j|d�dt|j��}
|j|
k�rpt|
�|t|d�k�r^t|�}|�|�|d|
7<q>t|
d��s�t|
�|	}	nt|||||
j|�}d}q>t|�|t|d�k�r�|d|7<q>|
j�rt|�d|k�rt|�}|�s|
���r|�||�d}q>t|
d��sNt|
�}|
j�sD|d7}|�|�||	}	q>|
j�rn|�sn|	�d|
�d	}q>t|�}|�s�|
���r�|�||�q>|d|7<q>|j�|�|jS)N�utf-8r�rrF�wrap_as_ew_blockedr�r�Tcss|]}t|tj�VqdSr)r�rr�r rrrr#�
s�z%_refold_parse_tree.<locals>.<genexpr>�unknown-8bitr�r7r�rB)Zmax_line_length�sys�maxsize�utf8r�r�r�r
rDr�r9rBr�rYr-�_fold_mime_parametersr1rHr;r�r�r�rhrE�_fold_as_ewrIr0�insertr%)Z
parse_treer8�maxlenr�r��last_ewr�Z
want_encodingZend_ew_not_allowedr�r2�tstrr`Zencoded_part�newlineZnewpartsrrrr9�
s�


�



��
r9cCs�|dk	r<|r<tt|d|d�|��}|dd|�|d<|dtkr�|d}|dd�}t|d�|krz|�t|��|d|7<d}|dtkr�|d}|dd�}|dkr�t|d�n|}|dkr�dn|}	t|	�d}
|
d|kr�t�d��|�r�|t|d�}||
}|dk�r,|�d	�q�|d|�}
tj	|
|	d
�}t|�|}|dk�r�|
dd�}
tj	|
|	d
�}t|�|}�qR|d|7<|t|
�d�}|r�|�d	�t|d�}q�|d|7<|�r�|SdS)Nr�rr�rr�r��z3max_line_length is too small to fit an encoded wordrN)r`)
r
r'rr�rhr�rrrrB)Z	to_encoder�r�r�rIr`Zleading_wspZtrailing_wspZnew_last_ewZ	encode_as�
chrome_lenZremaining_spaceZ
text_spaceZto_encode_wordZencoded_wordZexcessrrrr�1sT��



r�c	Cs�|jD�]�\}}|d���d�s2|dd7<|}d}z|�|�d}Wn0tk
r|d}t�|�rtd}d}nd}YnX|r�tjj	|d	|d
�}	d�
|||	�}
nd�
|t|��}
t|d�t|
�d
|kr�|dd|
|d<qn"t|
�d|k�r
|�
d|
�qd}|d}|rt|�tt|��dt|�}
||
dk�rLd}||
d}}|d|�}tjj	|d	|d
�}	t|	�|k�r��q�|d
8}�q\|�
d�
||||	��d	}|d
7}||d�}|�r|dd7<�qqdS)Nr�r\�strictFTr�r�r�r)Zsaferz
{}*={}''{}r�r�rNr�rz''r��Nz {}*{}*={}{})r�r�r�rBr�rr�r�r�ror*rr�rhr
)r2r�r�r�r�rr`Z
error_handlerZencoding_requiredZ
encoded_valuer�r�Zextra_chromer�Z
splitpointZmaxchars�partialrrrr�rsn


� ��r�)��rer�r��stringr�operatorrZemailrrrrr�rr2r9r5r�r<Z	TSPECIALSrqZ	ASPECIALSrvr|r�compile�VERBOSE�	MULTILINEr#r�rrLrRrUrWrXrZr\r]rbrmrnrqr{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
r�rrrrrr�rQrRr*r%r�rr�matchr-�findallrrnrsrzr
rrr!r'r*r+r/r0r1r3r4r6r7r8r;r>rDrArFrJrLrMrOrSrVrWrXrZr[r]r^r_r`rbrcrerfrkrlrorrrurxr{r}r�r�r�r�r�r�r�r�r�r9r�r�rrrr�<module>Fs,
�C"	
!*$
V	+





����
1C+
"&'/'&).9%7ED49/gAPK�"�\�['ʥ�base64mime.cpython-38.opt-1.pycnu�[���U

e5d�
�@stdZddddddgZddlmZdd	lmZmZd
ZdZdZ	d
Z
dd�Zddd�Zdefdd�Z
dd�ZeZeZdS)a�Base64 content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode arbitrary 8-bit data using the three 8-bit bytes in four 7-bit
characters encoding known as Base64.

It is used in the MIME standards for email to attach images, audio, and text
using some 8-bit character sets to messages.

This module provides an interface to encode and decode both headers and bodies
with Base64 encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:, From:, Cc:, etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character conversion
necessary for proper internationalized headers; it only does dumb encoding and
decoding.  To deal with the various line wrapping issues, use the email.header
module.
�body_decode�body_encode�decode�decodestring�
header_encode�
header_length�)�	b64encode)�
b2a_base64�
a2b_base64z
�
��cCs*tt|�d�\}}|d}|r&|d7}|S)z6Return the length of s when it is encoded with base64.��)�divmod�len)�	bytearrayZgroups_of_3Zleftover�n�r�(/usr/lib64/python3.8/email/base64mime.pyr2s
�
iso-8859-1cCs6|sdSt|t�r|�|�}t|��d�}d||fS)z�Encode a single header line with Base64 encoding in a given charset.

    charset names the character set to use to encode the header.  It defaults
    to iso-8859-1.  Base64 encoding is defined in RFC 2045.
    r�asciiz=?%s?b?%s?=)�
isinstance�str�encoderr)Zheader_bytes�charsetZencodedrrrr=s

�LcCs~|s|Sg}|dd}tdt|�|�D]J}t||||���d�}|�t�rh|tkrh|dd�|}|�|�q(t�|�S)a1Encode a string with base64.

    Each line will be wrapped at, at most, maxlinelen characters (defaults to
    76 characters).

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.
    rrrrN���)	�rangerr	r�endswith�NL�append�EMPTYSTRING�join)�sZ
maxlinelenZeolZencvecZ
max_unencoded�i�encrrrrLs
cCs.|s
t�St|t�r"t|�d��St|�SdS)z�Decode a raw base64 string, returning a bytes object.

    This function does not parse a full MIME header value encoded with
    base64 (like =?iso-8859-1?b?bmloISBuaWgh?=) -- please use the high
    level email.header class for that functionality.
    zraw-unicode-escapeN)�bytesrrr
r)�stringrrrrfs

N)r)�__doc__�__all__�base64rZbinasciir	r
ZCRLFr r"ZMISC_LENrrrrrrrrrr�<module>s&�

PK�"�\E��(�(feedparser.cpython-38.opt-1.pycnu�[���U

e5d�X�@s�dZddgZddlZddlmZddlmZddlmZddl	m
Z
e�d	�Ze�d
�Z
e�d�Ze�d
�Ze�d�Zd
ZdZe�ZGdd�de�ZGdd�d�ZGdd�de�ZdS)aFeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.
�
FeedParser�BytesFeedParser�N)�errors)�compat32)�deque)�StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])��
c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BufferedSubFileakA file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    cCs$tdd�|_t�|_g|_d|_dS)Nr)�newlineF)r�_partialr�_lines�	_eofstack�_closed��self�r�(/usr/lib64/python3.8/email/feedparser.py�__init__5szBufferedSubFile.__init__cCs|j�|�dS�N)r�append)rZpredrrr�push_eof_matcher@sz BufferedSubFile.push_eof_matchercCs
|j��Sr)r�poprrrr�pop_eof_matcherCszBufferedSubFile.pop_eof_matchercCs<|j�d�|�|j���|j�d�|j��d|_dS)NrT)r�seek�	pushlines�	readlines�truncaterrrrr�closeFs

zBufferedSubFile.closecCsL|js|jrdStS|j��}t|j�D]}||�r(|j�|�dSq(|S�Nr)r
r�NeedMoreData�popleft�reversedr�
appendleft)r�lineZateofrrr�readlineNs
zBufferedSubFile.readlinecCs|j�|�dSr)r
r#�rr$rrr�
unreadline`szBufferedSubFile.unreadlinecCsx|j�|�d|kr d|kr dS|j�d�|j��}|j�d�|j��|d�d�sj|j�|���|�|�dS)z$Push some new data into this object.r	�
Nr���)r�writerrr�endswithrr)r�data�partsrrr�pushes

zBufferedSubFile.pushcCs|j�|�dSr)r
�extend)r�linesrrrrzszBufferedSubFile.pushlinescCs|Srrrrrr�__iter__}szBufferedSubFile.__iter__cCs|��}|dkrt�|Sr)r%�
StopIterationr&rrr�__next__�szBufferedSubFile.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrr%r'r.rr1r3rrrrr
-sr
c@s`eZdZdZded�dd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rzA feed-style parser of email.N��policycCs�||_d|_|dkr<|jdkr2ddlm}||_qn|j|_n2||_z||jd�Wntk
rld|_YnXt�|_g|_	|�
�j|_d|_
d|_d|_dS)a_factory is called with no arguments to create a new message obj

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        FNr)�Messager8T)r9�_old_style_factoryZmessage_factoryZ
email.messager:�_factory�	TypeErrorr
�_input�	_msgstack�	_parsegenr3�_parse�_cur�_last�_headersonly)rr<r9r:rrrr�s$

zFeedParser.__init__cCs
d|_dS)NT)rDrrrr�_set_headersonly�szFeedParser._set_headersonlycCs|j�|�|��dS)zPush more data into the parser.N)r>r.�_call_parse�rr,rrr�feed�szFeedParser.feedcCs&z|��Wntk
r YnXdSr)rAr2rrrrrF�szFeedParser._call_parsecCsH|j��|��|��}|��dkrD|��sDt��}|j�	||�|S)z<Parse all remaining data and return the root message object.�	multipart)
r>rrF�_pop_message�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr9�
handle_defect)r�root�defectrrrr�s
�zFeedParser.closecCsn|jr|��}n|j|jd�}|jr<|j��dkr<|�d�|jrR|jd�|�|j�|�||_||_	dS)Nr8zmultipart/digestzmessage/rfc822r))
r;r<r9rB�get_content_typeZset_default_typer?ZattachrrC)r�msgrrr�_new_message�s

zFeedParser._new_messagecCs(|j��}|jr|jd|_nd|_|S)Nr))r?rrB)r�retvalrrrrJ�s

zFeedParser._pop_messageccs|��g}|jD]Z}|tkr&tVqt�|�sbt�|�s^t��}|j�	|j
|�|j�|�qn|�|�q|�
|�|jr�g}|j��}|tkr�tVq�|dkr�q�|�|�q�|j
�t�|��dS|j
��dk�r�|j�tj�|��D]}|tk�rtVq��qq�|��}|j��|j��}|tk�rDtV�q�qD�q|j��}|tk�rjtV�qD�qj�qD|dk�rx�q�|j�|�q�dS|j
��dk�r�|��D] }|tk�r�tV�q��qĐq�|��dS|j
��dk�r�|j
��}|dk�rRt��}|j�	|j
|�g}|jD]$}|tk�r.tV�q|�|��q|j
�t�|��dSt|j
�dd����dk�r�t��}|j�	|j
|�d|}t� d	t�!|�d
�}	d}
g}d}d}
|j��}|tk�r�tV�q�|dk�r�q�|	�|�}|�r�|�"d
��rd}
|�"d�}�q�|
�rr|�r^|d}t#�$|�}|�rP|dt%|�"d���|d<t�|�|j
_&d}
|j�|��q�|j��}|tk�r�tV�qr|	�|�}|�sr|j�|��q��qr|j�|	j�|��D] }|tk�r�tV�q��q�q�|j'��dk�rT|j'j(}|dk�rd|j'_(n:|dk	�r�t#�$|�}|�r�t%|�"d��}|d|�|j'_(nD|j'j)}t*|t��r�t#�$|�}|�r�|dt%|�"d���}||j'_)|j��|��|j
|_'n
|�|��q�|
�r*t�+�}|j�	|j
|�|j
�t�|��g}|jD]}|tk�r�tV�q��q�t�|�|j
_(dS|
�sLt�,�}|j�	|j
|�dS|�rZdg}ng}|jD]$}|tk�r|tV�qd|�|��qd|�r�|d}t-�|�}|�r�|t%|�"d��d�|d<t�|�|j
_(dSg}|jD]$}|tk�r�tV�q�|�|��q�|j
�t�|��dS)Nrzmessage/delivery-status�messagerIzcontent-transfer-encoding�8bit)Z7bitrTZbinaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr)r).rQr>r �headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr9rLrBr'r�_parse_headersrDr%Zset_payload�EMPTYSTRING�joinrOrr@rJrrKZget_boundaryZNoBoundaryInMultipartDefect�str�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�search�len�preamblerC�epilogueZ_payload�
isinstanceZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr$rNr0rRrP�boundaryZ	separatorZ
boundaryreZcapturing_preamblergrVZclose_boundary_seen�moZlastlineZeolmorhrUZpayload�	firstlineZbolmorrrr@�s`

















���
























zFeedParser._parsegenc	CsXd}g}t|�D�]&\}}|ddkrR|sFt�|�}|j�|j|�q|�|�q|rt|jj|j�|��dg}}|�	d�r�|dkr�t
�|�}|r�|dt|�
d���}|j�|�qn<|t|�dkr�|j�|�dSt�|�}|jj�|�q|�d�}|dk�r&t�d�}|jj�|�q|d|�}|g}q|�rT|jj|j�|��dS)Nrrz 	zFrom ��:zMissing header name.)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr9rLrBrZset_rawZheader_source_parse�
startswithrdrerfrcZset_unixfromr>r'ZMisplacedEnvelopeHeaderDefectZdefects�findZInvalidHeaderDefect)	rr0Z
lastheaderZ	lastvalue�linenor$rNrl�irrrrZ�sF








zFeedParser._parse_headers)N)r4r5r6r7rrrErHrFrrQrJr@rZrrrrr�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst��|�dd��dS)N�ascii�surrogateescape)�superrH�decoderG��	__class__rrrHszBytesFeedParser.feed)r4r5r6r7rH�
__classcell__rrryrrs)r7�__all__r`ZemailrZemail._policybaser�collectionsr�iorrarYrjrdZNLCRE_crackrWr[�NL�objectr r
rrrrrr�<module>s(




[PK�"�\{v�?88#_encoded_words.cpython-38.opt-1.pycnu�[���U

e5dL!�@s�dZddlZddlZddlZddlZddlmZmZddlm	Z	ddddd	d
ddgZ
e�e�d
�j
dd��Zdd�ZGdd�de�Ze�Zdeed�<dd�Zdd	�Zdd�Zdd�Zdd
�Zeed�Zdd�Zeed�Zeed�Zddd�ZdS) z� Routines for manipulating RFC2047 encoded words.

This is currently a package-private API, but will be considered for promotion
to a public API if there is demand.

�N)�
ascii_letters�digits)�errors�decode_q�encode_q�decode_b�encode_b�len_q�len_b�decode�encodes=([a-fA-F0-9]{2})cCst�|�d����S)N�)�bytes�fromhex�groupr)�m�r�,/usr/lib64/python3.8/email/_encoded_words.py�<lambda>A�rcCs|�dd�}t|�gfS)N�_� )�replace�_q_byte_subber)�encodedrrrrCsc@s,eZdZde�d�e�d�Zdd�ZdS)�	_QByteMaps-!*+/�asciicCs.||jkrt|�||<nd�|�||<||S)Nz={:02X})�safe�chr�format)�self�keyrrr�__missing__Ms
z_QByteMap.__missing__N)�__name__�
__module__�__qualname__rrrrr"rrrrrIsr�_� cCsd�dd�|D��S)N�css|]}t|VqdS�N)�_q_byte_map��.0�xrrr�	<genexpr>Zszencode_q.<locals>.<genexpr>)�join��bstringrrrrYscCstdd�|D��S)Ncss|]}tt|�VqdSr))�lenr*r+rrrr.]szlen_q.<locals>.<genexpr>)�sumr0rrrr	\scCs�t|�d}|r ddd|�nd}z&tj||dd�|rDt��gngfWStjk
�r�ztj|dd�t��gfWYStjk
r�z,tj|ddd�t��t��gfWYYStjk
r�|t��gfYYYSXYnXYnXdS)N�s===rT)ZvalidateFs==)	r2�base64Z	b64decoderZInvalidBase64PaddingDefect�binascii�ErrorZInvalidBase64CharactersDefectZInvalidBase64LengthDefect)rZpad_errZmissing_paddingrrrrds(��
��cCst�|��d�S)Nr)r5Z	b64encoderr0rrrr�scCs&tt|�d�\}}|d|r dndS)N�r4r)�divmodr2)r1Zgroups_of_3Zleftoverrrrr
�s)�q�bc	
Cs�|�d�\}}}}}|�d�\}}}|��}|�dd�}t||�\}}z|�|�}Wnvtk
r�|�t�	d�
|���|�|d�}YnBtk
r�|�dd�}|��dkr�|�t�d�
|���YnX||||fS)a�Decode encoded word and return (string, charset, lang, defects) tuple.

    An RFC 2047/2243 encoded word has the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' may be omitted but the other parts may not be.

    This function expects exactly such a string (that is, it does not check the
    syntax and may raise errors if the string is not well formed), and returns
    the encoded_string decoded first from its Content Transfer Encoding and
    then from the resulting bytes into unicode using the specified charset.  If
    the cte-decoded string does not successfully decode using the specified
    character set, a defect is added to the defects list and the unknown octets
    are replaced by the unicode 'unknown' character \uFDFF.

    The specified charset and language are returned.  The default for language,
    which is rarely if ever encountered, is the empty string.

    �?�*r�surrogateescapez:Encoded word contains bytes not decodable using {} charset�unknown-8bitz<Unknown charset {} in encoded word; decoded as unknown bytes)
�split�	partition�lowerr�
_cte_decodersr�UnicodeError�appendrZUndecodableBytesDefectr�LookupErrorZCharsetError)	Zewr&�charsetZcteZ
cte_string�langr1Zdefects�stringrrrr�s&���utf-8r(cCs||dkr|�dd�}n
|�|�}|dkrTtd|�}td|�}||dkrPdnd}t||�}|rld|}d	�||||�S)
aEncode string using the CTE encoding that produces the shorter result.

    Produces an RFC 2047/2243 encoded word of the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' is omitted unless the 'lang' parameter is given a value.
    Optional argument charset (defaults to utf-8) specifies the charset to use
    to encode the string to binary before CTE encoding it.  Optional argument
    'encoding' is the cte specifier for the encoding that should be used ('q'
    or 'b'); if it is None (the default) the encoding which produces the
    shortest encoded sequence is used, except that 'q' is preferred if it is up
    to five characters longer.  Optional argument 'lang' (default '') gives the
    RFC 2243 language string to specify in the encoded word.

    r?rr>Nr:r;�r=z=?{}{}?{}?{}?=)r�_cte_encode_length�
_cte_encodersr)rIrG�encodingrHr1ZqlenZblenrrrrr�s
)rJNr()�__doc__�rer5r6�	functoolsrIrrZemailr�__all__�partial�compile�subrr�dictrr*�ordrr	rrr
rCrrMrLrrrrr�<module>sL)��&�+��PK�"�\�Jtu
u
policy.cpython-38.opt-2.pycnu�[���U

e5d�(�@s�ddlZddlZddlmZmZmZmZddlmZddl	m
Z
ddlmZddl
mZddd	d
ddd
dgZe�d�ZeGdd
�d
e��Ze�Ze`ejdd�Zejdd�Zejddd�Zejdd�ZdS)�N)�Policy�Compat32�compat32�_extend_docstrings)�_has_surrogates)�HeaderRegistry)�raw_data_manager)�EmailMessagerrr�EmailPolicy�default�strict�SMTP�HTTPz\n|\rcsleZdZeZdZdZe�Ze	Z
�fdd�Zdd�Zdd�Z
d	d
�Zdd�Zd
d�Zdd�Zddd�Z�ZS)r
F�longcs*d|krt�|dt��t�jf|�dS)N�header_factory)�object�__setattr__r�super�__init__)�self�kw��	__class__��$/usr/lib64/python3.8/email/policy.pyr]szEmailPolicy.__init__cCs|j|jS�N)rZ	max_count)r�namerrr�header_max_countdszEmailPolicy.header_max_countcCs>|d�dd�\}}|�d�d�|dd��}||�d�fS)Nr�:�z 	��
)�split�lstrip�join�rstrip)rZsourcelinesr�valuerrr�header_source_parsevs	zEmailPolicy.header_source_parsecCsVt|d�r$|j��|��kr$||fSt|t�rFt|���dkrFtd��||�||�fS)NrrzDHeader values may not contain linefeed or carriage return characters)	�hasattrr�lower�
isinstance�str�len�
splitlines�
ValueErrorr�rrr&rrr�header_store_parse�s

zEmailPolicy.header_store_parsecCs*t|d�r|Sd�t�|��}|�||�S)Nrr )r(r$�linesep_splitterr"rr/rrr�header_fetch_parse�s	
zEmailPolicy.header_fetch_parsecCs|j||dd�S)NT��
refold_binary)�_foldr/rrr�fold�szEmailPolicy.foldcCs0|j|||jdkd�}|jr dnd}|�|d�S)NZ7bitr3�utf8�ascii�surrogateescape)r5Zcte_typer7�encode)rrr&Zfolded�charsetrrr�fold_binary�szEmailPolicy.fold_binarycs�t|d�r|j|d�S|jr"|jntj�|��}|jdkp�|jdko�|rdt|d�t|�d�kp�t�fdd�|d	d�D��}|s�|r�t	|�r�|�
|d
�|��j|d�S|d|j�|�|jS)Nr)Zpolicy�allrr�c3s|]}t|��kVqdSr)r,)�.0�x��maxlenrr�	<genexpr>�sz$EmailPolicy._fold.<locals>.<genexpr>rr z: )
r(r6�max_line_length�sys�maxsizer-�
refold_sourcer,�anyrrr$�linesep)rrr&r4�linesZrefoldrrArr5�s


 �zEmailPolicy._fold)F)�__name__�
__module__�__qualname__r	Zmessage_factoryr7rGrrrZcontent_managerrrr'r0r2r6r<r5�
__classcell__rrrrr
s=
T)Zraise_on_defectr!)rI)rIrD)r7)�rerEZemail._policybaserrrrZemail.utilsrZemail.headerregistryrZemail.contentmanagerrZ
email.messager	�__all__�compiler1r
rrZclonerr
rZSMTPUTF8rrrr�<module>s2�
@PK�"�\p���&%&%_parseaddr.cpython-38.opt-2.pycnu�[���U

e5dE�@s�ddddgZddlZddlZdZdZdZd	d
ddd
dddddddddddd
dddddddgZd d!d"d#d$d%d&gZddddd'd(d)d'd*d)d+d*d,d+d-�Zd.d�Z	d/d0�Z
d1d�Zd2d�Zd3d�Z
Gd4d5�d5�ZGd6d7�d7e�ZdS)8�	mktime_tz�	parsedate�parsedate_tz�quote�N� �z, ZjanZfebZmarZaprZmayZjunZjulZaug�sep�octZnovZdecZjanuaryZfebruaryZmarchZaprilZjuneZjulyZaugustZ	septemberZoctoberZnovemberZdecemberZmonZtueZwedZthuZfriZsatZsunip���i���i���i����iD���i��)ZUTZUTCZGMT�ZZASTZADTZESTZEDTZCSTZCDTZMSTZMDTZPSTZPDTcCs,t|�}|sdS|ddkr$d|d<t|�S)N�	r)�
_parsedate_tz�tuple)�data�res�r�(/usr/lib64/python3.8/email/_parseaddr.pyr-sc
Cs�|sdS|��}|sdS|d�d�s6|d��tkr>|d=n.|d�d�}|dkrl|d|dd�|d<t|�dkr�|d�d�}t|�dkr�||dd�}t|�dk�r|d}|�d�}|dkr�|�d�}|dkr�|d|�||d�g|dd�<n
|�d	�t|�d
k�rdS|dd
�}|\}}}}}|��}|tk�rb||��}}|tk�rbdSt�	|�d}|dk�r�|d8}|ddk�r�|dd�}|�d�}|dk�r�||}}|ddk�r�|dd�}|d�
��s�||}}|ddk�r|dd�}|�d�}t|�d
k�r,|\}	}
d}n~t|�dk�rF|\}	}
}ndt|�dk�r�d|dk�r�|d�d�}t|�d
k�r�|\}	}
d}nt|�dk�r�|\}	}
}ndSz,t|�}t|�}t|	�}	t|
�}
t|�}Wntk
�r�YdSX|dk�r|dk�r|d7}n|d7}d}|�
�}|tk�r6t|}n>zt|�}Wntk
�rXYnX|dk�rt|�d��rtd}|�r�|dk�r�d}
|}nd}
|
|dd|dd}||||	|
|ddd|g
S)Nr�,���-��+���r���:��0�.�d�Dili�i�<)�split�endswith�lower�	_daynames�rfind�len�find�append�_monthnames�index�isdigit�int�
ValueError�upper�
_timezones�
startswith)r�iZstuff�sZddZmmZyyZtmZtzZthhZtmmZtssZtzoffsetZtzsignrrrr9s�


"














rcCs&t|�}t|t�r|dd�S|SdS)Nr)r�
isinstancer
�r�trrrr�s
cCs<|ddkr"t�|dd�d�St�|�}||dSdS)Nr�)r)�time�mktime�calendarZtimegmr5rrrr�s
cCs|�dd��dd�S)N�\z\\�"z\")�replace)�strrrrr�sc@sxeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dd�Zdd�Zdd�Z
ddd�Zdd�ZdS)�
AddrlistClasscCsZd|_d|_d|_d|_|j|j|_|j|j|j|_|j�dd�|_||_g|_	dS)Nz()<>@,:;."[]rz 	z
rr)
�specials�pos�LWSZCR�FWS�atomendsr=�
phraseends�field�commentlist��selfrFrrr�__init__�szAddrlistClass.__init__cCs�g}|jt|j�kr�|j|j|jdkr\|j|jdkrL|�|j|j�|jd7_q|j|jdkr�|j�|���qq�qt�|�S)Nz

r�()	rAr'rFrBr)rG�
getcomment�EMPTYSTRING�join)rIZwslistrrr�gotonext�szAddrlistClass.gotonextcCs:g}|jt|j�kr6|��}|r*||7}q|�d�q|S)N)rr)rAr'rF�
getaddressr))rI�resultZadrrr�getaddrlist�s
zAddrlistClass.getaddrlistcCs�g|_|��|j}|j}|��}|��g}|jt|j�kr\|rXt�|j�|dfg}�n\|j|jdkr�||_||_|��}t�|j�|fg}�n"|j|jdk�rg}t|j�}|jd7_|jt|j�k�r�|��|j|k�r|j|jdk�r|jd7_�q�||�	�}q�n�|j|jdk�rx|�
�}|j�rft�|�dd�|j�d	|fg}nt�|�|fg}n@|�r�t�|j�|dfg}n"|j|j|jk�r�|jd7_|��|jt|j�k�r�|j|jd
k�r�|jd7_|S)Nrz.@rr�;�<z (r�)r)rGrOrA�
getphraselistr'rF�SPACErN�getaddrspecrP�getrouteaddrr@)rIZoldposZoldcl�plistZ
returnlistZaddrspecZfieldlenZ	routeaddrrrrrPsX

���$zAddrlistClass.getaddresscCs�|j|jdkrdSd}|jd7_|��d}|jt|j�kr�|rT|��d}n~|j|jdkrv|jd7_q�n\|j|jdkr�|jd7_d}n8|j|jdkr�|jd7_n|��}|jd7_q�|��q2|S)	NrTFrr�>�@Tr)rFrArOr'�	getdomainrX)rIZexpectrouteZadlistrrrrYAs.
zAddrlistClass.getrouteaddrcCsTg}|��|jt|j�kr�d}|j|jdkrf|rH|d��sH|��|�d�|jd7_d}nd|j|jdkr�|�dt|����n<|j|j|j	kr�|r�|d��s�|��q�n|�|�
��|��}|r|r|�|�q|jt|j�k�s
|j|jdk�rt�|�S|�d�|jd7_|��|�
�}|�sFtSt�|�|S)	NTrrrFr<z"%s"r\)rOrAr'rF�strip�popr)r�getquoterD�getatomrMrNr])rIZaslistZpreserve_wsZwsZdomainrrrrXas:
$

zAddrlistClass.getaddrspeccCs�g}|jt|j�kr�|j|j|jkr6|jd7_q|j|jdkrX|j�|���q|j|jdkrx|�|���q|j|jdkr�|jd7_|�d�q|j|jdkr�tS|j|j|j	kr�q�q|�|�
��qt�|�S)NrrK�[rr\)rAr'rFrBrGr)rL�getdomainliteralrMrDrarN)rIZsdlistrrrr]�s"zAddrlistClass.getdomainTcCs�|j|j|krdSdg}d}|jd7_|jt|j�kr�|rX|�|j|j�d}np|j|j|krz|jd7_q�nN|r�|j|jdkr�|�|���q,n(|j|jdkr�d}n|�|j|j�|jd7_q,t�|�S)NrFrrKr;T)rFrAr'r)rLrMrN)rIZ	begincharZendcharsZ
allowcommentsZslistrrrr�getdelimited�s(
zAddrlistClass.getdelimitedcCs|�ddd�S)Nr<z"
F�rd�rIrrrr`�szAddrlistClass.getquotecCs|�ddd�S)NrKz)
TrerfrrrrL�szAddrlistClass.getcommentcCsd|�ddd�S)Nz[%s]rbz]
Frerfrrrrc�szAddrlistClass.getdomainliteralNcCsddg}|dkr|j}|jt|j�krZ|j|j|kr8qZn|�|j|j�|jd7_qt�|�S)Nrr)rDrAr'rFr)rMrN)rIrDZatomlistrrrra�szAddrlistClass.getatomcCs�g}|jt|j�kr�|j|j|jkr6|jd7_q|j|jdkrV|�|���q|j|jdkrx|j�|���q|j|j|jkr�q�q|�|�	|j��q|S)Nrr<rK)
rAr'rFrCr)r`rGrLrEra)rIrZrrrrV�szAddrlistClass.getphraselist)T)N)�__name__�
__module__�__qualname__rJrOrRrPrYrXr]rdr`rLrcrarVrrrrr?�s
; &
%
r?c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�AddressListcCs&t�||�|r|��|_ng|_dS�N)r?rJrR�addresslistrHrrrrJ�szAddressList.__init__cCs
t|j�Srk)r'rlrfrrr�__len__szAddressList.__len__cCs>td�}|jdd�|_|jD]}||jkr|j�|�q|Srk�rjrlr)�rI�otherZnewaddr�xrrr�__add__s

zAddressList.__add__cCs&|jD]}||jkr|j�|�q|Srk)rlr)�rIrprqrrr�__iadd__s

zAddressList.__iadd__cCs.td�}|jD]}||jkr|j�|�q|Srkrnrorrr�__sub__s


zAddressList.__sub__cCs&|jD]}||jkr|j�|�q|Srk)rl�removersrrr�__isub__s

zAddressList.__isub__cCs
|j|Srk)rl)rIr+rrr�__getitem__%szAddressList.__getitem__N)
rgrhrirJrmrrrtrurwrxrrrrrj�s	rj)�__all__r8r:rWrMZ
COMMASPACEr*r%r0rrrrrr?rjrrrr�<module>
sb���	w	

/PK�"�\h��A��iterators.cpython-38.opt-1.pycnu�[���U

e5dW�@sLdZdddgZddlZddlmZdd�Zdd	d�Zddd�Zddd
�ZdS)z1Various types of useful iterators and generators.�body_line_iterator�typed_subpart_iterator�walk�N)�StringIOccs.|V|��r*|��D]}|��EdHqdS)z�Walk over the message tree, yielding each subpart.

    The walk is performed in depth-first order.  This method is a
    generator.
    N)�is_multipart�get_payloadr)�self�subpart�r
�'/usr/lib64/python3.8/email/iterators.pyrsFccs6|��D](}|j|d�}t|t�rt|�EdHqdS)z�Iterate over the parts, returning string payloads line-by-line.

    Optional decode (default False) is passed through to .get_payload().
    )�decodeN)rr�
isinstance�strr)�msgrr	Zpayloadr
r
rr"s
�textccs8|��D]*}|��|kr|dks,|��|kr|VqdS)z�Iterate over the subparts with a given MIME type.

    Use `maintype' as the main MIME type to match against; this defaults to
    "text".  Optional `subtype' is the MIME subtype to match against; if
    omitted, only the main type is matched.
    N)rZget_content_maintypeZget_content_subtype)rZmaintypeZsubtyper	r
r
rr-scCs�|dkrtj}d|d}t||��d|d�|rJtd|��|d�n
t|d�|��r||��D]}t|||d|�qddS)	zA handy debugging aidN� ��)�end�filez [%s])r�)�sys�stdout�printZget_content_typeZget_default_typerr�
_structure)r�fp�levelZinclude_defaultZtabr	r
r
rr;s
r)F)rN)NrF)	�__doc__�__all__r�iorrrrrr
r
r
r�<module>s�

PK�"�\�~�z�0�0generator.cpython-38.pycnu�[���U

e5d�N�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZd	Z
d
Ze�d�Ze�dej�ZGd
d�d�ZGdd�de�ZdZGdd�de�Zeeejd��ZdeZejZdS)z:Classes to generate plain text from a message object tree.�	Generator�DecodedGenerator�BytesGenerator�N)�deepcopy)�StringIO�BytesIO)�_has_surrogates�_�
z
\r\n|\r|\nz^From c@s�eZdZdZd'dd�dd�Zdd�Zd(d	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZeZdd�Zdd�Zdd �Zd!d"�Zed)d#d$��Zed%d&��ZdS)*rz�Generates output from a Message object tree.

    This basic generator writes the message to the given file object as plain
    text.
    N��policycCs6|dkr|dkrdn|j}||_||_||_||_dS)a�Create the generator for message flattening.

        outfp is the output file-like object for writing the message to.  It
        must have a write() method.

        Optional mangle_from_ is a flag that, when True (the default if policy
        is not set), escapes From_ lines in the body of the message by putting
        a `>' in front of them.

        Optional maxheaderlen specifies the longest length for a non-continued
        header.  When a header line is longer (in characters, with tabs
        expanded to 8 spaces) than maxheaderlen, the header will split as
        defined in the Header class.  Set maxheaderlen to zero to disable
        header wrapping.  The default is 78, as recommended (but not required)
        by RFC 2822.

        The policy keyword specifies a policy object that controls a number of
        aspects of the generator's operation.  If no policy is specified,
        the policy associated with the Message object passed to the
        flatten method is used.

        NT)�mangle_from_�_fp�
_mangle_from_�maxheaderlenr)�self�outfpr
rr�r�'/usr/lib64/python3.8/email/generator.py�__init__$szGenerator.__init__cCs|j�|�dS�N)r�write�r�srrrrDszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|�|j�|_d|_|�|j�|_|j}|j}zL||_||_|r�|�	�}|s�dt
�t
�
��}|�||j�|�
|�W5||_||_XdS)a�Print the message object tree rooted at msg to the output file
        specified when the Generator instance was created.

        unixfrom is a flag that forces the printing of a Unix From_ delimiter
        before the first object in the message tree.  If the original message
        has no From_ delimiter, a `standard' one is crafted.  By default, this
        is False to inhibit the printing of any From_ delimiter.

        Note that for subobjects, no From_ line is printed.

        linesep specifies the characters used to indicate a new line in
        the output.  The default value is determined by the policy specified
        when the Generator instance was created or, if none was specified,
        from the policy associated with the msg.

        N)�linesep�Zmax_line_length�zFrom nobody )r�clonerr�_NL�_encode�_encoded_NLZ_EMPTY�_encoded_EMPTYZget_unixfrom�time�ctimer�_write)r�msg�unixfromrrZold_gen_policyZold_msg_policyZufromrrr�flattenHs,
zGenerator.flattencCs|j||jd|jd�S)z1Clone this generator with the exact same options.Nr)�	__class__rr)r�fprrrrys
�zGenerator.clonecCst�Sr)r�rrrr�_new_buffer�szGenerator._new_buffercCs|Srrrrrrr�szGenerator._encodecCsT|sdSt�|�}|dd�D]}|�|�|�|j�q|drP|�|d�dS)N���)�NLCRE�splitrr)r�lines�linerrr�_write_lines�s

zGenerator._write_linescCs�|j}z"d|_|��|_}|�|�W5||_|j}|`X|r�t|�}|�d�dkrd|d|d<n|�d|d�|�d|d�t|dd�}|dkr�|�|�n||�|j�	|�
��dS)N�content-transfer-encodingr�Content-Transfer-Encoding�content-type��_write_headers)r�
_munge_cter+�	_dispatchr�getZreplace_header�getattrr6r�getvalue)rr%ZoldfpZ	munge_cteZsfp�methrrrr$�s&zGenerator._writecCst|��}|��}t�||f��dd�}t|d|d�}|dkrh|�dd�}t|d|d�}|dkrh|j}||�dS)N�-r	Z_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer:�
_writeBody)rr%�main�subZspecificr<Zgenericrrrr8�szGenerator._dispatchcCs6|��D]\}}|�|j�||��q|�|j�dSr)�	raw_itemsrrZfoldr�rr%�h�vrrrr6�szGenerator._write_headerscCs�|��}|dkrdSt|t�s.tdt|���t|j�r~|�d�}|dk	r~t|�}|d=|�	||�|��}|d|df|_
|jr�t�
d|�}|�|�dS)Nzstring payload expected: %s�charsetr2r4�>From )�get_payload�
isinstance�str�	TypeError�typer�_payloadZ	get_paramrZset_payloadr7r�fcrerEr1)rr%�payloadrJrrr�_handle_text�s$


�zGenerator._handle_textcCs�g}|��}|dkrg}n(t|t�r2|�|�dSt|t�sB|g}|D]6}|��}|�|�}|j|d|jd�|�	|�
��qF|��}|s�|j�
|�}|�|�}|�|�|jdk	r�|jr�t�d|j�}	n|j}	|�|	�|�|j�|�d||j�|�r|j�|�d��|D],}
|�|jd||j�|j�|
��q|�|jd|d|j�|jdk	�r�|j�r�t�d|j�}n|j}|�|�dS)NF�r&rrKz--r)rLrMrNr�listr+rr'r�appendr;Zget_boundaryr rA�_make_boundaryZset_boundary�preamblerrRrEr1r�pop�epilogue)rr%ZmsgtextsZsubparts�partr�g�boundaryZalltextrYZ	body_partr[rrr�_handle_multipartsJ







zGenerator._handle_multipartcCs0|j}|jdd�|_z|�|�W5||_XdS)Nrr)rrr_)rr%�prrr�_handle_multipart_signed<s
z"Generator._handle_multipart_signedcCs�g}|��D]t}|��}|�|�}|j|d|jd�|��}|�|j�}|rv|d|jkrv|�	|j�
|dd���q|�	|�q|j�|j�
|��dS)NFrUr,)
rLr+rr'rr;r.r r!rWrArr)rr%Zblocksr\rr]�textr/rrr�_handle_message_delivery_statusGs
z)Generator._handle_message_delivery_statuscCs^|��}|�|�}|j}t|t�rD|j|�d�d|jd�|��}n
|�	|�}|j
�|�dS)NrFrU)r+rrQrMrVr'rLrr;rrr)rr%rr]rSrrr�_handle_message\s




zGenerator._handle_messagecCsvt�tj�}dt|d}|dkr(|S|}d}|�dt�|�dtj�}|�	|�sXqr|dt
|�}|d7}q0|S)Nz===============z==rz^--z(--)?$�.r5)�randomZ	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINE�searchrN)�clsrb�tokenr^�bZcounterZcrerrrrXus

zGenerator._make_boundarycCst�||�Sr)rk�compile�ror�flagsrrrrj�szGenerator._compile_re)NN)FN)N)�__name__�
__module__�__qualname__�__doc__rrr'rr+rr1r$r8r6rTrCr_rarcrd�classmethodrXrjrrrrrs.	� 
1'
:csPeZdZdZdd�Zdd�Zdd�Zdd	�Z�fd
d�ZeZ	e
dd
��Z�ZS)ra�Generates a bytes version of a Message object tree.

    Functionally identical to the base Generator except that the output is
    bytes and not string.  When surrogates were used in the input to encode
    bytes, these are decoded back to bytes for output.  If the policy has
    cte_type set to 7bit, then the message is transformed such that the
    non-ASCII bytes are properly content transfer encoded, using the charset
    unknown-8bit.

    The outfp object must accept bytes in its write method.
    cCs|j�|�dd��dS)N�ascii�surrogateescape)rr�encoderrrrr�szBytesGenerator.writecCst�Sr)rr*rrrr+�szBytesGenerator._new_buffercCs
|�d�S�Nrz)r|rrrrr�szBytesGenerator._encodecCs8|��D]\}}|j�|j�||��q|�|j�dSr)rFrrrZfold_binaryrrGrrrr6�szBytesGenerator._write_headerscs\|jdkrdSt|j�rH|jjdksH|jr:t�d|j�|_|�|j�ntt	|��
|�dS)NZ7bitrK)rQrrZcte_typerrRrEr1�superrrT)rr%�r(rrrT�s
zBytesGenerator._handle_textcCst�|�d�|�Sr})rkrrr|rsrrrrj�szBytesGenerator._compile_re)
rurvrwrxrr+rr6rTrCryrj�
__classcell__rrrrr�s
zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s(eZdZdZddd�dd�Zdd�ZdS)	rz�Generates a text representation of a message.

    Like the Generator base class, except that non-text parts are substituted
    with a format string representing the part.
    NrcCs.tj|||||d�|dkr$t|_n||_dS)a�Like Generator.__init__() except that an additional optional
        argument is allowed.

        Walks through all subparts of a message.  If the subpart is of main
        type `text', then it prints the decoded payload of the subpart.

        Otherwise, fmt is a format string that is used instead of the message
        payload.  fmt is expanded with the following keywords (in
        %(keyword)s format):

        type       : Full MIME type of the non-text part
        maintype   : Main MIME type of the non-text part
        subtype    : Sub-MIME type of the non-text part
        filename   : Filename of the non-text part
        description: Description associated with the non-text part
        encoding   : Content transfer encoding of the non-text part

        The default value for fmt is None, meaning

        [Non-text (%(type)s) part of message omitted, filename %(filename)s]
        rN)rr�_FMTri)rrr
rZfmtrrrrr�s�zDecodedGenerator.__init__cCs�|��D]v}|��}|dkr2t|jdd�|d�q|dkr<qt|j|��|��|��|�d�|�dd�|�d	d
�d�|d�qdS)NrbF)�decode)�fileZ	multipartz
[no filename]zContent-Descriptionz[no description]r3z
[no encoding])rP�maintypeZsubtype�filenameZdescription�encoding)	�walkr>�printrLriZget_content_typer?�get_filenamer9)rr%r\r�rrrr8�s(���	�zDecodedGenerator._dispatch)NNN)rurvrwrxrr8rrrrr�s
�r5z%%0%dd)rx�__all__rkrgr"rf�copyr�iorrZemail.utilsrr@�NLrrr-rmrRrrr�r�len�reprrhZ_widthrirXrrrr�<module>s*

t3;PK�"�\{v�?88_encoded_words.cpython-38.pycnu�[���U

e5dL!�@s�dZddlZddlZddlZddlZddlmZmZddlm	Z	ddddd	d
ddgZ
e�e�d
�j
dd��Zdd�ZGdd�de�Ze�Zdeed�<dd�Zdd	�Zdd�Zdd�Zdd
�Zeed�Zdd�Zeed�Zeed�Zddd�ZdS) z� Routines for manipulating RFC2047 encoded words.

This is currently a package-private API, but will be considered for promotion
to a public API if there is demand.

�N)�
ascii_letters�digits)�errors�decode_q�encode_q�decode_b�encode_b�len_q�len_b�decode�encodes=([a-fA-F0-9]{2})cCst�|�d����S)N�)�bytes�fromhex�groupr)�m�r�,/usr/lib64/python3.8/email/_encoded_words.py�<lambda>A�rcCs|�dd�}t|�gfS)N�_� )�replace�_q_byte_subber)�encodedrrrrCsc@s,eZdZde�d�e�d�Zdd�ZdS)�	_QByteMaps-!*+/�asciicCs.||jkrt|�||<nd�|�||<||S)Nz={:02X})�safe�chr�format)�self�keyrrr�__missing__Ms
z_QByteMap.__missing__N)�__name__�
__module__�__qualname__rrrrr"rrrrrIsr�_� cCsd�dd�|D��S)N�css|]}t|VqdS�N)�_q_byte_map��.0�xrrr�	<genexpr>Zszencode_q.<locals>.<genexpr>)�join��bstringrrrrYscCstdd�|D��S)Ncss|]}tt|�VqdSr))�lenr*r+rrrr.]szlen_q.<locals>.<genexpr>)�sumr0rrrr	\scCs�t|�d}|r ddd|�nd}z&tj||dd�|rDt��gngfWStjk
�r�ztj|dd�t��gfWYStjk
r�z,tj|ddd�t��t��gfWYYStjk
r�|t��gfYYYSXYnXYnXdS)N�s===rT)ZvalidateFs==)	r2�base64Z	b64decoderZInvalidBase64PaddingDefect�binascii�ErrorZInvalidBase64CharactersDefectZInvalidBase64LengthDefect)rZpad_errZmissing_paddingrrrrds(��
��cCst�|��d�S)Nr)r5Z	b64encoderr0rrrr�scCs&tt|�d�\}}|d|r dndS)N�r4r)�divmodr2)r1Zgroups_of_3Zleftoverrrrr
�s)�q�bc	
Cs�|�d�\}}}}}|�d�\}}}|��}|�dd�}t||�\}}z|�|�}Wnvtk
r�|�t�	d�
|���|�|d�}YnBtk
r�|�dd�}|��dkr�|�t�d�
|���YnX||||fS)a�Decode encoded word and return (string, charset, lang, defects) tuple.

    An RFC 2047/2243 encoded word has the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' may be omitted but the other parts may not be.

    This function expects exactly such a string (that is, it does not check the
    syntax and may raise errors if the string is not well formed), and returns
    the encoded_string decoded first from its Content Transfer Encoding and
    then from the resulting bytes into unicode using the specified charset.  If
    the cte-decoded string does not successfully decode using the specified
    character set, a defect is added to the defects list and the unknown octets
    are replaced by the unicode 'unknown' character \uFDFF.

    The specified charset and language are returned.  The default for language,
    which is rarely if ever encountered, is the empty string.

    �?�*r�surrogateescapez:Encoded word contains bytes not decodable using {} charset�unknown-8bitz<Unknown charset {} in encoded word; decoded as unknown bytes)
�split�	partition�lowerr�
_cte_decodersr�UnicodeError�appendrZUndecodableBytesDefectr�LookupErrorZCharsetError)	Zewr&�charsetZcteZ
cte_string�langr1Zdefects�stringrrrr�s&���utf-8r(cCs||dkr|�dd�}n
|�|�}|dkrTtd|�}td|�}||dkrPdnd}t||�}|rld|}d	�||||�S)
aEncode string using the CTE encoding that produces the shorter result.

    Produces an RFC 2047/2243 encoded word of the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' is omitted unless the 'lang' parameter is given a value.
    Optional argument charset (defaults to utf-8) specifies the charset to use
    to encode the string to binary before CTE encoding it.  Optional argument
    'encoding' is the cte specifier for the encoding that should be used ('q'
    or 'b'); if it is None (the default) the encoding which produces the
    shortest encoded sequence is used, except that 'q' is preferred if it is up
    to five characters longer.  Optional argument 'lang' (default '') gives the
    RFC 2243 language string to specify in the encoded word.

    r?rr>Nr:r;�r=z=?{}{}?{}?{}?=)r�_cte_encode_length�
_cte_encodersr)rIrG�encodingrHr1ZqlenZblenrrrrr�s
)rJNr()�__doc__�rer5r6�	functoolsrIrrZemailr�__all__�partial�compile�subrr�dictrr*�ordrr	rrr
rCrrMrLrrrrr�<module>sL)��&�+��PK�"�\�.�FSFSmessage.cpython-38.opt-2.pycnu�[���U

e5d��@s�ddgZddlZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZmZddlm
Zdd	lmZejZd
Ze�d�Zdd
�Zddd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZdS)�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�Policy�compat32��charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]cCs4t|��d�\}}}|s$|��dfS|��|��fS)N�;)�str�	partition�strip)�param�a�sep�b�r�%/usr/lib64/python3.8/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}t�|d|d|d�}d||fSz|�d�Wn6tk
r�|d7}t�|dd�}d||fYSX|s�t�|�r�d	|t�	|�fSd||fSn|SdS)
Nr�*���%s=%s�asciizutf-8�z%s="%s")
�len�
isinstance�tuplerZencode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer%rrr�_formatparam's	
r'cCs�dt|�}g}|dd�dkr�|dd�}|�d�}|dkrp|�dd|�|�dd|�drp|�d|d�}q6|dkr�t|�}|d|�}d|kr�|�d�}|d|�����d||dd���}|�|���||d�}q|S)Nr
rr�"z\"r�=)r�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
(
,r3cCs4t|t�r&|d|dt�|d�fSt�|�SdS)Nrrr)rr r�unquote)r&rrr�
_unquotevalue]s
r5c@s�eZdZefdd�Zdd�Zdcdd	�Zd
d�Zdddd
�Zdd�Z	dd�Z
dd�Zdd�Zdedd�Z
dfdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zdgd0d1�Zd2d3�Zd4d5�Zdhd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%didJdK�Z&djdLdM�Z'dkdPdQ�Z(dldRdS�Z)dmdTdU�Z*dndVdW�Z+dodXdY�Z,dZd[�Z-dpd\d]�Z.dqd^d_�Z/d`da�Z0ddbl1m2Z2dS)rrcCs:||_g|_d|_d|_d|_d|_|_g|_d|_dS)N�
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr7rrr�__init__xszMessage.__init__cCs|��S�N)�	as_string�r>rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|��S)Nr)�	GeneratorF)�mangle_from_�maxheaderlenr7��unixfrom)�email.generatorrDr7r�flatten�getvalue)r>rHrFr7rD�fp�grrrrA�s�zMessage.as_stringcCs|��Sr@)�as_bytesrBrrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|��S)Nr)�BytesGeneratorF)rEr7rG)rIrPr7rrJrK)r>rHr7rPrLrMrrrrN�szMessage.as_bytescCst|jt�Sr@)rr:�listrBrrr�is_multipart�szMessage.is_multipartcCs
||_dSr@�r9)r>rHrrr�set_unixfrom�szMessage.set_unixfromcCs|jSr@rSrBrrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.z|j�|�Wntk
r@td��YnXdS)Nz=Attach is not valid on a message with a non-multipart payload)r:r.�AttributeError�	TypeError)r>�payloadrrr�attach�s

zMessage.attachcCs�|��r(|rdS|dkr|jS|j|S|dk	rNt|jt�sNtdt|j���|j}t|�dd����}t|t�r�t	�
|�r�|�dd�}|s�z|�|�
dd�d�}Wq�tk
r�|�dd�}Yq�Xn2|r�z|�d�}Wntk
r�|�d�}YnX|�s|S|d	k�rt�|�S|d
k�rVtd�|����\}}|D]}|j�||��q<|S|dk�r�t|�}	t�}
ztj|	|
d
d�|
��WStjk
�r�|YSXt|t��r�|S|S)NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper�replace�raw-unicode-escapezquoted-printable�base64�)z
x-uuencodeZuuencodeZuuezx-uueT)�quiet)rRr:rrQrW�typer�getr-rZ_has_surrogatesr!�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr7Z
handle_defectr�uurK�Error)r>r2rbrX�cteZbpayloadr&r<ZdefectZin_fileZout_filerrr�get_payload�sV"








zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|�|j�}t|d�rT|�dd�|_n||_|dk	rl|�|�dS)Nr!rbrrZ)�hasattrr:r�Charsetr!�output_charsetrb�set_charset)r>rXrrrr�set_payload/s


zMessage.set_payloadcCs|dkr|�d�d|_dSt|t�s.t|�}||_d|krH|�dd�d|krf|jdd|��d�n|�d|���||��kr�|�|j�|_d|k�r|�	�}z||�Wnjt
k
�r|j}|r�z|�dd	�}Wn tk
r�|�|j
�}YnX|�|�|_|�d|�YnXdS)
Nr�MIME-Version�1.0�Content-Typer6r
zContent-Transfer-EncodingrrZ)�	del_paramr;rrn�
add_headerZget_output_charset�	set_paramZbody_encoder:Zget_body_encodingrWr!rero)r>rrkrXrrrrpCs:

�
zMessage.set_charsetcCs|jSr@)r;rBrrr�get_charsetrszMessage.get_charsetcCs
t|j�Sr@)rr8rBrrr�__len__zszMessage.__len__cCs
|�|�Sr@)ra�r>�namerrr�__getitem__~s	zMessage.__getitem__cCsr|j�|�}|rX|��}d}|jD]4\}}|��|kr"|d7}||kr"td�||���q"|j�|j�||��dS)Nrrz/There may be at most {} {} headers in a message)r7Zheader_max_countr-r8�
ValueError�formatr.�header_store_parse)r>r{�valZ	max_countZlname�found�k�vrrr�__setitem__�s�zMessage.__setitem__cCs@|��}g}|jD]"\}}|��|kr|�||f�q||_dSr@)r-r8r.)r>r{�
newheadersr�r�rrr�__delitem__�szMessage.__delitem__cCs|��dd�|jD�kS)NcSsg|]\}}|���qSr)r-��.0r�r�rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r-r8rzrrr�__contains__�szMessage.__contains__ccs|jD]\}}|VqdSr@�r8)r>Zfieldr&rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)NcSsg|]\}}|�qSrrr�rrrr��sz Message.keys.<locals>.<listcomp>r�rBrrr�keys�szMessage.keyscs�fdd��jD�S)Ncsg|]\}}�j�||��qSr�r7�header_fetch_parser�rBrrr��s�z"Message.values.<locals>.<listcomp>r�rBrrBr�values�s
�zMessage.valuescs�fdd��jD�S)Ncs"g|]\}}|�j�||�f�qSrr�r�rBrrr��s�z!Message.items.<locals>.<listcomp>r�rBrrBr�items�s
�z
Message.itemscCs:|��}|jD]&\}}|��|kr|j�||�Sq|Sr@)r-r8r7r�)r>r{�failobjr�r�rrrra�s
zMessage.getcCs|j�||f�dSr@)r8r.)r>r{r&rrr�set_raw�szMessage.set_rawcCst|j���Sr@)�iterr8�copyrBrrr�	raw_items�szMessage.raw_itemscCsHg}|��}|jD](\}}|��|kr|�|j�||��q|sD|S|Sr@)r-r8r.r7r�)r>r{r�r�r�r�rrr�get_all�s	zMessage.get_allcKspg}|��D]<\}}|dkr0|�|�dd��q|�t|�dd�|��q|dk	r^|�d|�t�|�||<dS)N�_�-r)r�r.r[r'�insert�	SEMISPACErg)r>�_name�_valueZ_params�partsr�r�rrrrvszMessage.add_headercCs\|��}ttt|j��|j�D]0\}\}}|��|kr|j�||�|j|<qXqt|��dSr@)r-�zip�rangerr8r7r�KeyError)r>r�r�r2r�r�rrr�replace_header!s"zMessage.replace_headercCsHt�}|�d|�}||kr"|��St|�d��}|�d�dkrDdS|S)N�content-typer�/rr6)�objectra�get_default_typerr-r+)r>�missingr&�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|��}|�d�dS)Nr�r�r��split�r>r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|��}|�d�dS)Nr�rr�r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jSr@�r=rBrrrr�^szMessage.get_default_typecCs
||_dSr@r�r�rrr�set_default_typegszMessage.set_default_typec		Cs�t�}|�||�}||kr|Sg}t|�D]X}z$|�dd�\}}|��}|��}Wn tk
rr|��}d}YnX|�||f�q*t�|�}|S)Nr)rr)	r�rar3r�rr}r.rZ
decode_params)	r>r��headerr�r&�params�pr{r�rrr�_get_params_preserveps 

zMessage._get_params_preserver�TcCs8t�}|�||�}||kr|S|r0dd�|D�S|SdS)NcSsg|]\}}|t|�f�qSr)r5r�rrrr��sz&Message.get_params.<locals>.<listcomp>)r�r�)r>r�r�r4r�r�rrr�
get_params�s
zMessage.get_paramscCsN||kr|S|�||�D]0\}}|��|��kr|r@t|�S|Sq|Sr@)r�r-r5)r>rr�r�r4r�r�rrrrc�s
zMessage.get_paramrtrcCs
t|t�s|r|||f}||kr2|��dkr2d}n
|�|�}|j||d�st|s\t|||�}q�t�|t|||�g�}nbd}|j||d�D]N\}	}
d}|	��|��kr�t|||�}nt|	|
|�}|s�|}q�t�||g�}q�||�|�k�r|r�|�	||�n||=|||<dS)Nr�r6)r�r�r�r4)
rr r-rarcr'r�rgr�r�)r>rr&r��requoterZlanguager[r�Z	old_param�	old_valueZappend_paramrrrrw�s6

��zMessage.set_paramcCs�||krdSd}|j||d�D]@\}}|��|��kr|sHt|||�}qt�|t|||�g�}q||�|�kr|||=|||<dS)Nrr�)r�r-r'r�rgra)r>rr�r�Z	new_ctyper�r�rrrru�s
�zMessage.del_paramcCs�|�d�dkst�|��dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<|dd�D]\}}|�||||�qhdS)Nr�rr�zmime-versionrsrrr�)r+r}r-r�rw)r>r`r�r�r�r�r�rrr�set_typeszMessage.set_typecCsDt�}|�d|d�}||kr*|�d|d�}||kr6|St�|���S)N�filename�content-dispositionr{r�)r�rcr�collapse_rfc2231_valuer)r>r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|�d|�}||kr|St�|���S)N�boundary)r�rcrr��rstrip)r>r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCst�}|�|d�}||kr$t�d��g}d}|D]:\}}|��dkr\|�dd|f�d}q0|�||f�q0|s�|�dd|f�g}|jD]z\}	}
|	��dkr�g}|D].\}}
|
dkr�|�|�q�|�d||
f�q�t�|�}
|�|j	�
|	|
��q�|�|	|
f�q�||_dS)	Nr�zNo Content-Type header foundFr�z"%s"Trr)r�r�rZHeaderParseErrorr-r.r8r�rgr7r)r>r�r�r�Z	newparamsZfoundpZpkZpvr��hr�r�r�r�rrr�set_boundaryCs2


zMessage.set_boundaryc	Cs�t�}|�d|�}||kr|St|t�rr|dp2d}z|d�d�}t||�}Wn ttfk
rp|d}YnXz|�d�Wntk
r�|YSX|��S)Nrrzus-asciirr\)	r�rcrr r!rrdrer-)r>r�r�rZpcharsetrNrrr�get_content_charsetqs 

zMessage.get_content_charsetcs�fdd�|��D�S)Ncsg|]}|����qSr)r�)r��part�r�rrr��sz(Message.get_charsets.<locals>.<listcomp>��walk)r>r�rr�r�get_charsets�szMessage.get_charsetscCs*|�d�}|dkrdSt|�d��}|S)Nr�r)rarr-)r>r&�c_drrr�get_content_disposition�s

zMessage.get_content_dispositionr�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)rtTNrF)r�T)rtT)N)N)N)N)3�__name__�
__module__�__qualname__r	r?rCrArOrNrRrTrUrYrlrqrprxryr|r�r�r�r�r�r�r�rar�r�r�rvr�r�r�r�r�r�r�r�rcrwrur�r�r�r�r�r�r�Zemail.iteratorsr�rrrrrish


Z
/


				
�
"�
3

 


.


cs�eZdZd2dd�Zd3�fdd�	Zdd�Zd	d
�Zdd�Zd4dd�ZddddhZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd5dd �Zd6d!d"�Zd7d#d$�Zdd%�d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z�ZS)8�MIMEPartNcCs(|dkrddlm}|}t�||�dS)Nr)�default)Zemail.policyr�rr?)r>r7r�rrrr?�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)N)rFr7)r7Zmax_line_length�superrA)r>rHrFr7��	__class__rrrA�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8�r7)rAr7ZclonerBrrrrC�szMIMEPart.__str__cCs |�d�}|dkrdS|jdkS)Nr�F�
attachment)raZcontent_disposition)r>r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|��rdS|���d�\}}|dkrB||kr>|�|�|fVdS|dkrNdS|dkrz|��D]}|�||�EdHq^dSd|kr�|�d�|fVd}|�d�}|r�|��D]}|d|kr�|}q�q�|dkr�|��}|r�|dnd}|dk	�r|�||�EdHdS)Nr��text�	multipart�related�start�
content-idr)r�r�r�r,�
iter_parts�
_find_bodyrcrl)	r>r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_body�r��html�plaincCsBt|�}d}|�||�D]$\}}||kr|}|}|dkrq>q|S)Nr)rr�)r>r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_body)r�r�)r�r�)r�r�)r��alternativec
cs$|���d�\}}|dks"|dkr&dS|��}z|��}Wntk
rPYdSX|dkr�|dkr�|�d�}|r�d}g}|D]"}|�d�|kr�d}q||�|�q||r�|EdHdS|�d	�|EdHdSg}	|D]L}|���d�\}}||f|j	k�r|�
��s||	k�r|	�|�q�|Vq�dS)
Nr�r�r�r�r�Fr�Tr)r�r�rlr�rVrcrar.�pop�_body_typesr�)
r>r�r�rXr�r�r�Zattachmentsr��seenrrr�iter_attachmentssD



��
zMIMEPart.iter_attachmentsccs|��dkr|��EdHdS)Nr�)r�rlrBrrrr�=szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�Sr@)r7r��get_content�r>r��args�kwrrrr�EszMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dSr@)r7r��set_contentr�rrrr�JszMIMEPart.set_contentc
Cs�|��dkr6|��}||f}||kr6td�||���g}g}|jD]4\}}|���d�rj|�||f�qD|�||f�qD|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|�d|�dS)Nr�zCannot convert {} to {}�content-r�z
multipart/rtr�)r�r�r}r~r8r-�
startswithr.r`r7r:rw)
r>r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersr{r&r�rrr�_make_multipartOs0
�
zMIMEPart._make_multipartcCs|�dd|�dS)Nr�)r��mixed�r��r>r�rrr�make_relatedjszMIMEPart.make_relatedcCs|�dd|�dS)Nr�)r�r�r�rrr�make_alternativemszMIMEPart.make_alternativecCs|�dd|�dS)Nr�rr�r�rrr�
make_mixedpszMIMEPart.make_mixed)�_dispcOsf|��dks|��|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|�|�dS)Nr�Zmake_r�r�zContent-Disposition)r�r��getattrr`r7r�rY)r>Z_subtyper�r�r�r�rrr�_add_multipartss
�zMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r��r��r>r�r�rrr�add_related}szMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�r�r�rrr�add_alternative�szMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�r�r�rrr�add_attachment�szMIMEPart.add_attachmentcCsg|_d|_dSr@�r8r:rBrrr�clear�szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|���d�s||f�qS)r�)r-r�)r��nr�rrrr��s�z*MIMEPart.clear_content.<locals>.<listcomp>rrBrrr�
clear_content�szMIMEPart.clear_content)N)FNN)r�)N)N)N)r�r�r�r?rArCr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�
__classcell__rrr�rr��s2

�7



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)Nrrrs)r�r�r�r�rrr��szEmailMessage.set_content)r�r�r�r�rrrr�rr�s)NT)�__all__�rerirf�iorrZemailrrZemail._policybaserr	rr;Zemail._encoded_wordsrrnr��compiler#rr'r3r5rr�rrrrr�<module>s4


"N`PK�"�\V�e�A*A*header.cpython-38.opt-2.pycnu�[���U

e5d&^�@s�dddgZddlZddlZddlZddlZddlmZddlmZ	e	j
Z
dZdZd	Z
d
ZdZdZd
Ze
d�Ze
d�Ze�dejejB�Ze�d�Ze�d�ZejjZdd�Zddd�ZGdd�d�ZGdd�d�ZGdd�de �Z!dS)�Header�
decode_header�make_header�N)�HeaderParseError)�charset�
� � z        ��Nz 	�us-asciizutf-8ai
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qQbB])  # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:c	Cs�t|d�rdd�|jD�St�|�s.|dfgSg}|��D]�}t�|�}d}|r:|�d�}|rj|��}d}|r~|�|ddf�|rL|�d��	�}|�d��	�}|�d�}|�|||f�qLq:g}	t
|�D]J\}
}|
dkr�|dr�||
ddr�||
dd��r�|	�|
d�q�t|	�D]}||=�qg}
|D]�\}}}|dk�rV|
�||f�n�|d	k�r|t
j�|�}|
�||f�n~|d
k�r�t|�d}|�r�|ddd|�7}zt
j�|�}Wn tjk
�r�td
��YnX|
�||f�ntd|���q2g}d}}|
D]v\}}t|t��r,t|d�}|dk�r@|}|}nB||k�rb|�||f�|}|}n |dk�rz|t|7}n||7}�q|�||f�|S)N�_chunkscSs(g|] \}}t�|t|��t|�f�qS�)�_charsetZ_encode�str)�.0�stringrrr�$/usr/lib64/python3.8/email/header.py�
<listcomp>Ms�z!decode_header.<locals>.<listcomp>TrF���q�b�z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
�ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr�AssertionError�
isinstancer�bytes�BSPACE)�headerZwords�line�parts�firstZ	unencodedr�encodingZencodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetrrrr=s|
�




4







cCsFt|||d�}|D].\}}|dk	r4t|t�s4t|�}|�||�q|S)N)�
maxlinelen�header_name�continuation_ws)rr-�Charsetr!)Zdecoded_seqr9r:r;�h�srrrrr�s�c@sJeZdZddd�Zdd�Zdd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)rNr�strictcCs||dkrt}nt|t�s t|�}||_||_g|_|dk	rH|�|||�|dkrTt}||_|dkrjd|_	nt
|�d|_	dS)Nrr)�USASCIIr-r<r�_continuation_wsr
r!�
MAXLINELEN�_maxlinelen�
_headerlenr()�selfr>rr9r:r;�errorsrrr�__init__�s
zHeader.__init__c	Cs�|��g}d}d}|jD]�\}}|}|tjkrH|�dd�}|�dd�}|r�|o\|�|d�}|dkr�|dkr�|s�|�t�d}n|dkr�|s�|�t�|o�|�|d�}|}|�|�qt	�
|�S)N�ascii�surrogateescape�replacer�Nr���)�
_normalizer
r�UNKNOWN8BIT�encoder)�	_nonctextr!�SPACE�EMPTYSTRING�join)	rEZuchunks�lastcs�	lastspacerrZnextcsZoriginal_bytes�hasspacerrr�__str__�s*


zHeader.__str__cCs|t|�kS�N)r)rE�otherrrr�__eq__sz
Header.__eq__cCs�|dkr|j}nt|t�s"t|�}t|t�sZ|jp4d}|tjkrN|�dd�}n|�||�}|jpbd}|tjkr�z|�||�Wn"t	k
r�|dkr��t
}YnX|j�||f�dS)NrrI)
rr-r<rZinput_codecrNr)Zoutput_codecrO�UnicodeEncodeError�UTF8r
r!)rEr>rrFZ
input_charsetZoutput_charsetrrrr!	s$






z
Header.appendcCs|��p|dkS)N)�(�)�\)r$)rEr>rrrrP4szHeader._nonctext�;, 	rcCs�|��|dkr|j}|dkr"d}t|j||j|�}d}d}}|jD�]\}}	|dk	r�|oh|�|d�}|dkr�|r~|	dkr�|��n|	dkr�|s�|��|o�|�|d�}|	}d}|��}
|
r�|�	d|
d|	�n|�	dd|	�|
dd�D]`}|�
�|	jdk	�r"|�	|jd|��|	�q�|��}|dt
|�t
|��}
|�	|
||	�q�t
|
�dkrF|�
�qF|j�rx|��|�|�}t�|��r�td	�|���|S)
Nri@BrKrLFr
rrz8header value appears to contain an embedded header: {!r})rMrC�_ValueFormatterrDrAr
rP�add_transitionr�feed�newline�header_encodingr r(�_str�_embedded_headerrr�format)rE�
splitcharsr9�linesepZ	formatterrTrVrUrr�linesr1Zsline�fws�valuerrrrO9sZ!�
�

�z
Header.encodecCsxg}d}g}|jD]B\}}||kr.|�|�q|dk	rJ|�t�|�|f�|g}|}q|rn|�t�|�|f�||_dSrX)r
r!rQrS)rEZchunksr8Z
last_chunkrrrrrrM�szHeader._normalize)NNNNrr?)Nr?)r`Nr)
�__name__�
__module__�__qualname__rGrWrZr!rPrOrMrrrrr�s�
/ 
+
Pc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)racCs0||_||_t|�|_||_g|_t|�|_dSrX)�_maxlenrAr(�_continuation_ws_len�_splitchars�_lines�_Accumulator�
_current_line)rEZ	headerlen�maxlenr;rirrrrG�s
z_ValueFormatter.__init__cCs|��|�|j�SrX)rdrSrt)rErjrrrrf�sz_ValueFormatter._strcCs
|�t�SrX)rf�NL�rErrrrW�sz_ValueFormatter.__str__cCsv|j��}|dkr|jj|�t|j�dkrh|j��rV|jrV|jdt|j�7<n|j�t|j��|j��dS)N)rr
rrL)	rvr�pushr(�	is_onlywsrtrr!�reset)rEZend_of_linerrrrd�s
z_ValueFormatter.newlinecCs|j�dd�dS)Nrr
)rvrzryrrrrb�sz_ValueFormatter.add_transitioncCs�|jdkr|�|||j�dS|�||���}z|�d�}Wntk
rRYdSX|dk	rh|�||�z|��}Wntk
r�YdSX|��|j	�
|j|�|D]}|j�
|j|�q�dS�Nr)re�_ascii_splitrsZheader_encode_lines�_maxlengthsr�
IndexError�
_append_chunkrdrvrzrArtr!)rErlrrZ
encoded_linesZ
first_line�	last_liner1rrrrc�s$
z_ValueFormatter.feedccs&|jt|j�V|j|jVqdSrX)rqr(rvrrryrrrr�sz_ValueFormatter._maxlengthscCsft�dtd||�}|dr0dg|dd�<n
|�d�tt|�gd�D]\}}|�||�qLdS)Nz([z]+)rr
r)�rer�FWSr�zip�iterr�)rErlrrir2�partrrrr~�s
z_ValueFormatter._ascii_splitcCs|j�||�t|j�|jk�r|jD]v}t|j��ddd�D]T}|��rn|j|d}|rn|d|krnq�|j|dd}|r@|d|kr@q�q@q&q�q&|j��\}}|jj	dkr�|�
�|s�d}|j�||�dS|j�|�}|j�
t|j��|j�|�dS)NrrrLr)rvrzr(rqrs�range�
part_countr$r�
_initial_sizerd�pop_fromrtr!rr|)rErlrZch�iZprevpartr�Z	remainderrrrr��s.
z_ValueFormatter._append_chunkN)rnrorprGrfrWrdrbrcrr~r�rrrrra�s%racsjeZdZd�fdd�	Zdd�Zddd�Z�fdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
�fdd�Z�ZS)rurcs||_t���dSrX)r��superrG)rEZinitial_size��	__class__rrrGsz_Accumulator.__init__cCs|�||f�dSrX)r!)rErlrrrrrz#sz_Accumulator.pushcCs||d�}g||d�<|SrXr)rEr�Zpoppedrrrr�&sz_Accumulator.pop_fromcs|��dkrdSt���S)Nr)r
r
)r�r�rryr�rrr+sz_Accumulator.popcCstdd�|D�|j�S)Ncss"|]\}}t|�t|�VqdSrX)r(�rrlr�rrr�	<genexpr>1sz'_Accumulator.__len__.<locals>.<genexpr>)�sumr�ryrrr�__len__0s�z_Accumulator.__len__cCst�dd�|D��S)Ncss |]\}}t�||f�VqdSrX�rRrSr�rrrr�5s�z'_Accumulator.__str__.<locals>.<genexpr>r�ryrrrrW4s
�z_Accumulator.__str__NcCs"|dkrg}||dd�<d|_dSr})r�)rEZstartvalrrrr|8sz_Accumulator.resetcCs|jdko|pt|���Sr})r�rr$ryrrrr{>sz_Accumulator.is_onlywscs
t���SrX)r�r�ryr�rrr�Asz_Accumulator.part_count)r)r)N)
rnrorprGrzr�rr�rWr|r{r��
__classcell__rrr�rrus

ru)NNr)"�__all__r�r*Zemail.quoprimimer&Zemail.base64mimeZemail.errorsrrrr<rxrQr/ZSPACE8rRrBr�r@r\�compile�VERBOSE�	MULTILINErZfcrergr'Z_max_appendrrrra�listrurrrr�<module>sD�
�

_�
kPK�"�\�f�\\parser.cpython-38.pycnu�[���U

e5d��@s�dZddddddgZddlmZmZdd	lmZmZdd
lm	Z	Gdd�d�Z
Gdd�de
�ZGd
d�d�ZGdd�de�Z
dS)z-A parser of RFC 2822 and MIME email messages.�Parser�HeaderParser�BytesParser�BytesHeaderParser�
FeedParser�BytesFeedParser�)�StringIO�
TextIOWrapper)rr)�compat32c@s0eZdZd
ed�dd�Zddd�Zddd	�ZdS)
rN��policycCs||_||_dS)a�Parser of RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The string must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the string or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        N)�_classr)�selfr
r�r�$/usr/lib64/python3.8/email/parser.py�__init__szParser.__init__FcCs@t|j|jd�}|r|��|�d�}|s,q8|�|�q|��S)a\Create a message structure from the data in a file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        ri )rr
rZ_set_headersonly�readZfeed�close)r�fp�headersonlyZ
feedparser�datarrr�parse)s
zParser.parsecCs|jt|�|d�S)a-Create a message structure from a string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        �r)rr�r�textrrrr�parsestr;szParser.parsestr)N)F)F)�__name__�
__module__�__qualname__r
rrrrrrrrs
c@s eZdZddd�Zddd�ZdS)	rTcCst�||d�S�NT)rr�rrrrrrrHszHeaderParser.parsecCst�||d�Sr)rrrrrrrKszHeaderParser.parsestrN)T)T)rrrrrrrrrrGs
c@s(eZdZdd�Zd	dd�Zd
dd�ZdS)rcOst||�|_dS)a�Parser of binary RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The input must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the input or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.
        N)r�parser)r�args�kwrrrrQszBytesParser.__init__FcCs0t|ddd�}z|j�||�W�S|��XdS)acCreate a message structure from the data in a binary file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        �ascii�surrogateescape)�encoding�errorsN)r	�detachr!rr rrrrcszBytesParser.parsecCs|jddd�}|j�||�S)a2Create a message structure from a byte string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        �ASCIIr%)r')�decoder!rrrrr�
parsebytesrszBytesParser.parsebytesN)F)F)rrrrrr+rrrrrOs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||dd�S�NTr)rrr rrrrszBytesHeaderParser.parsecCstj||dd�Sr,)rr+rrrrr+�szBytesHeaderParser.parsebytesN)T)T)rrrrr+rrrrr~s
N)�__doc__�__all__�iorr	Zemail.feedparserrrZemail._policybaser
rrrrrrrr�<module>s�7/PK�"�\>~�s�
�
parser.cpython-38.opt-2.pycnu�[���U

e5d��@s|ddddddgZddlmZmZddlmZmZdd	lmZGd
d�d�Z	Gdd�de	�Z
Gdd�d�ZGd
d�de�ZdS)�Parser�HeaderParser�BytesParser�BytesHeaderParser�
FeedParser�BytesFeedParser�)�StringIO�
TextIOWrapper)rr)�compat32c@s0eZdZd
ed�dd�Zddd�Zddd	�ZdS)
rN��policycCs||_||_dS�N)�_classr)�selfrr�r�$/usr/lib64/python3.8/email/parser.py�__init__szParser.__init__FcCs@t|j|jd�}|r|��|�d�}|s,q8|�|�q|��S)Nri )rrrZ_set_headersonly�readZfeed�close)r�fp�headersonlyZ
feedparser�datarrr�parse)s
zParser.parsecCs|jt|�|d�S)N�r)rr�r�textrrrr�parsestr;szParser.parsestr)N)F)F)�__name__�
__module__�__qualname__r
rrrrrrrrs
c@s eZdZddd�Zddd�ZdS)	rTcCst�||d�S�NT)rr�rrrrrrrHszHeaderParser.parsecCst�||d�Sr )rrrrrrrKszHeaderParser.parsestrN)T)T)rrrrrrrrrrGs
c@s(eZdZdd�Zd	dd�Zd
dd�ZdS)rcOst||�|_dSr
)r�parser)r�args�kwrrrrQszBytesParser.__init__FcCs0t|ddd�}z|j�||�W�S|��XdS)N�ascii�surrogateescape)�encoding�errors)r	�detachr"rr!rrrrcszBytesParser.parsecCs|jddd�}|j�||�S)N�ASCIIr&)r()�decoder"rrrrr�
parsebytesrszBytesParser.parsebytesN)F)F)rrrrrr,rrrrrOs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||dd�S�NTr)rrr!rrrrszBytesHeaderParser.parsecCstj||dd�Sr-)rr,rrrrr,�szBytesHeaderParser.parsebytesN)T)T)rrrrr,rrrrr~s
N)
�__all__�iorr	Zemail.feedparserrrZemail._policybaser
rrrrrrrr�<module>s�7/PK�"�\����U�U#headerregistry.cpython-38.opt-1.pycnu�[���U

e5dKQ�@szdZddlmZddlmZddlmZddlmZGdd�d�ZGdd	�d	�Z	Gd
d�de
�Zdd
�ZGdd�d�Z
Gdd�de
�ZGdd�d�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGd d!�d!�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'�ZGd(d)�d)�Zeeeeeeeeeeeeeeeeeeeed*�ZGd+d,�d,�Zd-S).a;Representing and manipulating email headers via custom objects.

This module provides an implementation of the HeaderRegistry API.
The implementation is designed to flexibly follow RFC5322 rules.

Eventually HeaderRegistry will be a public API, but it isn't yet,
and will probably change some before that happens.

�)�MappingProxyType)�utils)�errors)�_header_value_parserc@s^eZdZddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCs�d�td||||f��}d|ks(d|kr0td��|dk	r�|s@|rHtd��t�|�\}}|rjtd�||���|jrz|jd�|j}|j	}||_
||_||_dS)	a�Create an object representing a full email address.

        An address can have a 'display_name', a 'username', and a 'domain'.  In
        addition to specifying the username and domain separately, they may be
        specified together by using the addr_spec keyword *instead of* the
        username and domain keywords.  If an addr_spec string is specified it
        must be properly quoted according to RFC 5322 rules; an error will be
        raised if it is not.

        An Address object has display_name, username, domain, and addr_spec
        attributes, all of which are read-only.  The addr_spec and the string
        value of the object are both quoted according to RFC5322 rules, but
        without any Content Transfer Encoding.

        rN�
�
z8invalid arguments; address parts cannot contain CR or LFz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)
�join�filter�
ValueError�	TypeError�parserZ
get_addr_spec�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_specZinputsZa_s�rest�r�,/usr/lib64/python3.8/email/headerregistry.py�__init__s&�
zAddress.__init__cCs|jS�N�r�rrrrr<szAddress.display_namecCs|jSr)rr rrrr@szAddress.usernamecCs|jSr)rr rrrrDszAddress.domaincCsTt|j�}t|�t|tj�kr.t�|j�}n|j}|jrH|d|jS|sPdS|S)z�The addr_spec (username@domain) portion of the address, quoted
        according to RFC 5322 rules, but with no Content Transfer Encoding.
        �@�<>)�setr�lenrZ
DOT_ATOM_ENDS�quote_stringr)r�namesetZlprrrrHs
zAddress.addr_speccCsd�|jj|j|j|j�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrrr rrr�__repr__Xs�zAddress.__repr__cCs^t|j�}t|�t|tj�kr.t�|j�}n|j}|rX|jdkrFdn|j}d�||�S|jS)Nr"rz{} <{}>)r#rr$r�SPECIALSr%rr)rr&�disprrrr�__str__]s
zAddress.__str__cCs8t|�t|�krdS|j|jko6|j|jko6|j|jkS�NF)�typerrr�r�otherrrr�__eq__hs
�
�zAddress.__eq__)rrrN)r(�
__module__�__qualname__r�propertyrrrrr)r,r1rrrrrs
*



rc@sFeZdZddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs||_|rt|�nt�|_dS)aCreate an object representing an address group.

        An address group consists of a display_name followed by colon and a
        list of addresses (see Address) terminated by a semi-colon.  The Group
        is created by specifying a display_name and a possibly empty list of
        Address objects.  A Group can also be used to represent a single
        address that is not in a group, which is convenient when manipulating
        lists that are a combination of Groups and individual Addresses.  In
        this case the display_name should be set to None.  In particular, the
        string representation of a Group whose display_name is None is the same
        as the Address object, if there is one and only one Address object in
        the addresses list.

        N)r�tuple�
_addresses)rr�	addressesrrrrrszGroup.__init__cCs|jSrrr rrrr�szGroup.display_namecCs|jSr)r7r rrrr8�szGroup.addressescCsd�|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rr'r(rr8r rrrr)�s
�zGroup.__repr__cCs�|jdkr&t|j�dkr&t|jd�S|j}|dk	r\t|�}t|�t|tj�kr\t�|�}d�dd�|jD��}|r~d|n|}d�	||�S)N�r�, css|]}t|�VqdSr��str)�.0�xrrr�	<genexpr>�sz Group.__str__.<locals>.<genexpr>� z{}:{};)
rr$r8r<r#rr*r%r
r)rr+r&Zadrstrrrrr,�s
z
Group.__str__cCs,t|�t|�krdS|j|jko*|j|jkSr-)r.rr8r/rrrr1�s

�zGroup.__eq__)NN)
r(r2r3rr4rr8r)r,r1rrrrr5ps


r5c@sTeZdZdZdd�Zdd�Zedd��Zedd	��Zd
d�Z	e
dd
��Zdd�ZdS)�
BaseHeadera|Base class for message headers.

    Implements generic behavior and provides tools for subclasses.

    A subclass must define a classmethod named 'parse' that takes an unfolded
    value string and a dictionary as its arguments.  The dictionary will
    contain one key, 'defects', initialized to an empty list.  After the call
    the dictionary must contain two additional keys: parse_tree, set to the
    parse tree obtained from parsing the header, and 'decoded', set to the
    string value of the idealized representation of the data from the value.
    (That is, encoded words are decoded, and values that have canonical
    representations are so represented.)

    The defects key is intended to collect parsing defects, which the message
    parser will subsequently dispose of as appropriate.  The parser should not,
    insofar as practical, raise any errors.  Defects should be added to the
    list instead.  The standard header parsers register defects for RFC
    compliance issues, for obsolete RFC syntax, and for unrecoverable parsing
    errors.

    The parse method may add additional keys to the dictionary.  In this case
    the subclass must define an 'init' method, which will be passed the
    dictionary as its keyword arguments.  The method should use (usually by
    setting them as the value of similarly named attributes) and remove all the
    extra keys added by its parse method, and then use super to call its parent
    class with the remaining arguments and keywords.

    The subclass should also make sure that a 'max_count' attribute is defined
    that is either None or 1. XXX: need to better define this API.

    cCs\dgi}|�||�t�|d�r4t�|d�|d<t�||d�}|d=|j|f|�|S)N�defects�decoded)�parserZ_has_surrogates�	_sanitizer<�__new__�init)�cls�name�value�kwdsrrrrrF�szBaseHeader.__new__cCs||_||_||_dSr)�_name�_parse_tree�_defects)rrI�
parse_treerBrrrrG�szBaseHeader.initcCs|jSr)rLr rrrrI�szBaseHeader.namecCs
t|j�Sr)r6rNr rrrrB�szBaseHeader.defectscCst|jj|jjt|�f|jfSr)�_reconstruct_headerr'r(�	__bases__r<�__dict__r rrr�
__reduce__�s��zBaseHeader.__reduce__cCst�||�Sr)r<rF)rHrJrrr�_reconstruct�szBaseHeader._reconstructc	Cs`t�t�t�|jd�t�dd�g�g�}|jrH|�t�t�dd�g��|�|j�|j	|d�S)atFold header according to policy.

        The parsed representation of the header is folded according to
        RFC5322 rules, as modified by the policy.  If the parse tree
        contains surrogateescaped bytes, the bytes are CTE encoded using
        the charset 'unknown-8bit".

        Any non-ASCII characters in the parse tree are CTE encoded using
        charset utf-8. XXX: make this a policy setting.

        The returned value is an ASCII-only string possibly containing linesep
        characters, and ending with a linesep character.  The string includes
        the header name and the ': ' separator.

        zheader-name�:z
header-sepr@Zfws)�policy)
rZHeaderZHeaderLabelZ
ValueTerminalrIrM�appendZCFWSListZWhiteSpaceTerminal�fold)rrV�headerrrrrX�s
���zBaseHeader.foldN)
r(r2r3�__doc__rFrGr4rIrBrS�classmethodrTrXrrrrrA�s 




rAcCst||i��|�Sr)r.rT)Zcls_name�basesrJrrrrP
srPc@s&eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs"|�|�|d<t|d�|d<dS)NrOrC)�value_parserr<�rHrJrKrrrrDszUnstructuredHeader.parse)
r(r2r3�	max_count�staticmethodr�get_unstructuredr^r[rDrrrrr]s
r]c@seZdZdZdS)�UniqueUnstructuredHeaderr9N�r(r2r3r`rrrrrcsrccsFeZdZdZdZeej�Ze	dd��Z
�fdd�Zedd��Z
�ZS)	�
DateHeadera�Header whose value consists of a single timestamp.

    Provides an additional attribute, datetime, which is either an aware
    datetime using a timezone, or a naive datetime if the timezone
    in the input string is -0000.  Also accepts a datetime as input.
    The 'value' attribute is the normalized form of the timestamp,
    which means it is the output of format_datetime on the datetime.
    NcCsz|s6|d�t���d|d<d|d<t��|d<dSt|t�rJt�|�}||d<t�	|d�|d<|�
|d�|d<dS)NrB�datetimerrCrO)rWrZHeaderMissingRequiredValuerZ	TokenList�
isinstancer<rZparsedate_to_datetimeZformat_datetimer^r_rrrrD.s

zDateHeader.parsecs|�d�|_t�j||�dS)Nrf)�pop�	_datetime�superrG�r�args�kw�r'rrrG<szDateHeader.initcCs|jSr)rir rrrrf@szDateHeader.datetime)r(r2r3rZr`rarrbr^r[rDrGr4rf�
__classcell__rrrnrres	


rec@seZdZdZdS)�UniqueDateHeaderr9NrdrrrrrpEsrpcsPeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�ZS)�
AddressHeaderNcCst�|�\}}|Sr)rZget_address_list)rJ�address_listrrrr^NszAddressHeader.value_parsercCs�t|t�rV|�|�|d<}g}|jD]"}|�t|jdd�|jD���q&t|j	�}n"t
|d�sf|g}dd�|D�}g}||d<||d<d�d	d�|D��|d
<d|kr�|�|d
�|d<dS)NrOcSs*g|]"}t|jpd|jpd|jp"d��qS)r)rrrr)r=Zmbrrr�
<listcomp>]s
�
�z'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs&g|]}t|d�std|g�n|�qS)r8N)�hasattrr5�r=�itemrrrrsfs��groupsrBr:cSsg|]}t|��qSrr;rvrrrrslsrC)rgr<r^r8rWr5rZ
all_mailboxes�listrrur
)rHrJrKrrrxZaddrrBrrrrDTs*


��
�zAddressHeader.parsecs(t|�d��|_d|_t�j||�dS)Nrx)r6rh�_groupsr7rjrGrkrnrrrGpszAddressHeader.initcCs|jSr)rzr rrrrxuszAddressHeader.groupscCs&|jdkr tdd�|jD��|_|jS)Ncss|]}|jD]
}|VqqdSr)r8)r=�group�addressrrrr?|s�z*AddressHeader.addresses.<locals>.<genexpr>)r7r6rzr rrrr8ys
zAddressHeader.addresses)
r(r2r3r`rar^r[rDrGr4rxr8rorrrnrrqJs


rqc@seZdZdZdS)�UniqueAddressHeaderr9Nrdrrrrr}�sr}c@seZdZedd��ZdS)�SingleAddressHeadercCs(t|j�dkrtd�|j���|jdS)Nr9z9value of single address header {} is not a single addressr)r$r8rrrIr rrrr|�s
�zSingleAddressHeader.addressN)r(r2r3r4r|rrrrr~�sr~c@seZdZdZdS)�UniqueSingleAddressHeaderr9Nrdrrrrr�srcsZeZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�ZS)�MIMEVersionHeaderr9cCs�|�|�|d<}t|�|d<|d�|j�|jdkr<dn|j|d<|j|d<|jdk	rtd�|d|d�|d<nd|d<dS)NrOrCrB�major�minorz{}.{}�version)r^r<�extendrr�r�r�rHrJrKrOrrrrD�s

zMIMEVersionHeader.parsecs6|�d�|_|�d�|_|�d�|_t�j||�dS)Nr�r�r�)rh�_version�_major�_minorrjrGrkrnrrrG�szMIMEVersionHeader.initcCs|jSr)r�r rrrr��szMIMEVersionHeader.majorcCs|jSr)r�r rrrr��szMIMEVersionHeader.minorcCs|jSr)r�r rrrr��szMIMEVersionHeader.version)r(r2r3r`rarZparse_mime_versionr^r[rDrGr4r�r�r�rorrrnrr��s



r�cs8eZdZdZedd��Z�fdd�Zedd��Z�Z	S)�ParameterizedMIMEHeaderr9cCsZ|�|�|d<}t|�|d<|d�|j�|jdkrBi|d<ndd�|jD�|d<dS)NrOrCrB�paramscSs&i|]\}}t�|���t�|��qSr)rrE�lower)r=rIrJrrr�
<dictcomp>�s�z1ParameterizedMIMEHeader.parse.<locals>.<dictcomp>)r^r<r�rr�r�rrrrD�s

�zParameterizedMIMEHeader.parsecs|�d�|_t�j||�dS)Nr�)rh�_paramsrjrGrkrnrrrG�szParameterizedMIMEHeader.initcCs
t|j�Sr)rr�r rrrr��szParameterizedMIMEHeader.params)
r(r2r3r`r[rDrGr4r�rorrrnrr��s
r�csJeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�ZS)	�ContentTypeHeadercs2t�j||�t�|jj�|_t�|jj�|_dSr)	rjrGrrErM�maintype�	_maintype�subtype�_subtyperkrnrrrG�szContentTypeHeader.initcCs|jSr)r�r rrrr��szContentTypeHeader.maintypecCs|jSr)r�r rrrr��szContentTypeHeader.subtypecCs|jd|jS)N�/)r�r�r rrr�content_type�szContentTypeHeader.content_type)
r(r2r3rarZparse_content_type_headerr^rGr4r�r�r�rorrrnrr��s


r�cs2eZdZeej�Z�fdd�Zedd��Z	�Z
S)�ContentDispositionHeadercs2t�j||�|jj}|dkr"|nt�|�|_dSr)rjrGrM�content_dispositionrrE�_content_disposition)rrlrmZcdrnrrrG�szContentDispositionHeader.initcCs|jSr)r�r rrrr��sz,ContentDispositionHeader.content_disposition)r(r2r3rarZ parse_content_disposition_headerr^rGr4r�rorrrnrr��s
r�csBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�ContentTransferEncodingHeaderr9cCs2|�|�|d<}t|�|d<|d�|j�dS�NrOrCrB�r^r<r�rr�rrrrDsz#ContentTransferEncodingHeader.parsecs"t�j||�t�|jj�|_dSr)rjrGrrErM�cte�_cterkrnrrrGsz"ContentTransferEncodingHeader.initcCs|jSr)r�r rrrr�sz!ContentTransferEncodingHeader.cte)r(r2r3r`rarZ&parse_content_transfer_encoding_headerr^r[rDrGr4r�rorrrnrr��s

r�c@s&eZdZdZeej�Zedd��Z	dS)�MessageIDHeaderr9cCs2|�|�|d<}t|�|d<|d�|j�dSr�r�r�rrrrDszMessageIDHeader.parseN)
r(r2r3r`rarZparse_message_idr^r[rDrrrrr�s
r�)Zsubject�datezresent-datez	orig-dateZsenderz
resent-sender�toz	resent-toZccz	resent-ccZbccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-typezcontent-dispositionzcontent-transfer-encodingz
message-idc@s8eZdZdZeedfdd�Zdd�Zdd�Zd	d
�Z	dS)�HeaderRegistryz%A header_factory and header registry.TcCs&i|_||_||_|r"|j�t�dS)a�Create a header_factory that works with the Policy API.

        base_class is the class that will be the last class in the created
        header class's __bases__ list.  default_class is the class that will be
        used if "name" (see __call__) does not appear in the registry.
        use_default_map controls whether or not the default mapping of names to
        specialized classes is copied in to the registry when the factory is
        created.  The default is True.

        N)�registry�
base_class�
default_class�update�_default_header_map)rr�r�Zuse_default_maprrrr9s
zHeaderRegistry.__init__cCs||j|��<dS)zLRegister cls as the specialized class for handling "name" headers.

        N)r�r��rrIrHrrr�map_to_typeKszHeaderRegistry.map_to_typecCs,|j�|��|j�}td|j||jfi�S)N�_)r��getr�r�r.r(r�r�rrr�__getitem__QszHeaderRegistry.__getitem__cCs||||�S)a�Create a header instance for header 'name' from 'value'.

        Creates a header instance by creating a specialized class for parsing
        and representing the specified header by combining the factory
        base_class with a specialized class from the registry or the
        default_class, and passing the name and value to the constructed
        class's constructor.

        r)rrIrJrrr�__call__Us
zHeaderRegistry.__call__N)
r(r2r3rZrAr]rr�r�r�rrrrr�5s�
r�N)rZ�typesrZemailrrrrrr5r<rArPr]rcrerprqr}r~rr�r�r�r�r�r�r�r�rrrr�<module>sX	`6d'7
%�PK�"�\h��A��iterators.cpython-38.pycnu�[���U

e5dW�@sLdZdddgZddlZddlmZdd�Zdd	d�Zddd�Zddd
�ZdS)z1Various types of useful iterators and generators.�body_line_iterator�typed_subpart_iterator�walk�N)�StringIOccs.|V|��r*|��D]}|��EdHqdS)z�Walk over the message tree, yielding each subpart.

    The walk is performed in depth-first order.  This method is a
    generator.
    N)�is_multipart�get_payloadr)�self�subpart�r
�'/usr/lib64/python3.8/email/iterators.pyrsFccs6|��D](}|j|d�}t|t�rt|�EdHqdS)z�Iterate over the parts, returning string payloads line-by-line.

    Optional decode (default False) is passed through to .get_payload().
    )�decodeN)rr�
isinstance�strr)�msgrr	Zpayloadr
r
rr"s
�textccs8|��D]*}|��|kr|dks,|��|kr|VqdS)z�Iterate over the subparts with a given MIME type.

    Use `maintype' as the main MIME type to match against; this defaults to
    "text".  Optional `subtype' is the MIME subtype to match against; if
    omitted, only the main type is matched.
    N)rZget_content_maintypeZget_content_subtype)rZmaintypeZsubtyper	r
r
rr-scCs�|dkrtj}d|d}t||��d|d�|rJtd|��|d�n
t|d�|��r||��D]}t|||d|�qddS)	zA handy debugging aidN� ��)�end�filez [%s])r�)�sys�stdout�printZget_content_typeZget_default_typerr�
_structure)r�fp�levelZinclude_defaultZtabr	r
r
rr;s
r)F)rN)NrF)	�__doc__�__all__r�iorrrrrr
r
r
r�<module>s�

PK�"�\��Zu�)�)feedparser.cpython-38.pycnu�[���U

e5d�X�@s�dZddgZddlZddlmZddlmZddlmZddl	m
Z
e�d	�Ze�d
�Z
e�d�Ze�d
�Ze�d�Zd
ZdZe�ZGdd�de�ZGdd�d�ZGdd�de�ZdS)aFeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.
�
FeedParser�BytesFeedParser�N)�errors)�compat32)�deque)�StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])��
c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BufferedSubFileakA file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    cCs$tdd�|_t�|_g|_d|_dS)Nr)�newlineF)r�_partialr�_lines�	_eofstack�_closed��self�r�(/usr/lib64/python3.8/email/feedparser.py�__init__5szBufferedSubFile.__init__cCs|j�|�dS�N)r�append)rZpredrrr�push_eof_matcher@sz BufferedSubFile.push_eof_matchercCs
|j��Sr)r�poprrrr�pop_eof_matcherCszBufferedSubFile.pop_eof_matchercCs<|j�d�|�|j���|j�d�|j��d|_dS)NrT)r�seek�	pushlines�	readlines�truncaterrrrr�closeFs

zBufferedSubFile.closecCsL|js|jrdStS|j��}t|j�D]}||�r(|j�|�dSq(|S�Nr)r
r�NeedMoreData�popleft�reversedr�
appendleft)r�lineZateofrrr�readlineNs
zBufferedSubFile.readlinecCs|tk	st�|j�|�dSr)r �AssertionErrorr
r#�rr$rrr�
unreadline`szBufferedSubFile.unreadlinecCsx|j�|�d|kr d|kr dS|j�d�|j��}|j�d�|j��|d�d�sj|j�|���|�|�dS)z$Push some new data into this object.r	�
Nr���)r�writerrr�endswithrr)r�data�partsrrr�pushes

zBufferedSubFile.pushcCs|j�|�dSr)r
�extend)r�linesrrrrzszBufferedSubFile.pushlinescCs|Srrrrrr�__iter__}szBufferedSubFile.__iter__cCs|��}|dkrt�|Sr)r%�
StopIterationr'rrr�__next__�szBufferedSubFile.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrr%r(r/rr2r4rrrrr
-sr
c@s`eZdZdZded�dd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rzA feed-style parser of email.N��policycCs�||_d|_|dkr<|jdkr2ddlm}||_qn|j|_n2||_z||jd�Wntk
rld|_YnXt�|_g|_	|�
�j|_d|_
d|_d|_dS)a_factory is called with no arguments to create a new message obj

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        FNr)�Messager9T)r:�_old_style_factoryZmessage_factoryZ
email.messager;�_factory�	TypeErrorr
�_input�	_msgstack�	_parsegenr4�_parse�_cur�_last�_headersonly)rr=r:r;rrrr�s$

zFeedParser.__init__cCs
d|_dS)NT)rErrrr�_set_headersonly�szFeedParser._set_headersonlycCs|j�|�|��dS)zPush more data into the parser.N)r?r/�_call_parse�rr-rrr�feed�szFeedParser.feedcCs&z|��Wntk
r YnXdSr)rBr3rrrrrG�szFeedParser._call_parsecCsR|j��|��|��}|jr$t�|��dkrN|��sNt�	�}|j
�||�|S)z<Parse all remaining data and return the root message object.�	multipart)r?rrG�_pop_messager@r&�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr:�
handle_defect)r�root�defectrrrr�s

�zFeedParser.closecCsn|jr|��}n|j|jd�}|jr<|j��dkr<|�d�|jrR|jd�|�|j�|�||_||_	dS)Nr9zmultipart/digestzmessage/rfc822r*)
r<r=r:rC�get_content_typeZset_default_typer@ZattachrrD)r�msgrrr�_new_message�s

zFeedParser._new_messagecCs(|j��}|jr|jd|_nd|_|S)Nr*)r@rrC)r�retvalrrrrK�s

zFeedParser._pop_messageccs$|��g}|jD]Z}|tkr&tVqt�|�sbt�|�s^t��}|j�	|j
|�|j�|�qn|�|�q|�
|�|jr�g}|j��}|tkr�tVq�|dkr�q�|�|�q�|j
�t�|��dS|j
��dk�r�|j�tj�|��D]}|tk�rtVq��qq�|��}|j��|j��}|tk�rDtV�q�qD�q|j��}|tk�rjtV�qD�qj�qD|dk�rx�q�|j�|�q�dS|j
��dk�r�|��D] }|tk�r�tV�q��qĐq�|��dS|j
��dk�r�|j
��}|dk�rRt��}|j�	|j
|�g}|jD]$}|tk�r.tV�q|�|��q|j
�t�|��dSt|j
�dd����dk�r�t��}|j�	|j
|�d|}t� d	t�!|�d
�}	d}
g}d}d}
|j��}|tk�r�tV�q�|dk�r�q�|	�|�}|�r�|�"d
��rd}
|�"d�}�q�|
�rr|�r^|d}t#�$|�}|�rP|dt%|�"d���|d<t�|�|j
_&d}
|j�|��q�|j��}|tk�r�tV�qr|	�|�}|�sr|j�|��q��qr|j�|	j�|��D] }|tk�r�tV�q��q�q�|j'��dk�rT|j'j(}|dk�rd|j'_(n:|dk	�r�t#�$|�}|�r�t%|�"d��}|d|�|j'_(nD|j'j)}t*|t��r�t#�$|�}|�r�|dt%|�"d���}||j'_)|j��|��|j
|_'n|
�s�t+�|�|��q�|
�r4t�,�}|j�	|j
|�|j
�t�|��g}|jD]}|tk�rtV�q�qt�|�|j
_(dS|
�sVt�-�}|j�	|j
|�dS|�rddg}ng}|jD]$}|tk�r�tV�qn|�|��qn|�r�|d}t.�|�}|�r�|t%|�"d��d�|d<t�|�|j
_(dSg}|jD]$}|tk�rtV�q�|�|��q�|j
�t�|��dS)Nrzmessage/delivery-status�messagerJzcontent-transfer-encoding�8bit)Z7bitrUZbinaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr*r)/rRr?r �headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr:rMrCr(r�_parse_headersrEr%Zset_payload�EMPTYSTRING�joinrPrrArKrrLZget_boundaryZNoBoundaryInMultipartDefect�str�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�search�len�preamblerD�epilogueZ_payload�
isinstancer&ZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr$rOr1rSrQ�boundaryZ	separatorZ
boundaryreZcapturing_preamblerhrWZclose_boundary_seen�moZlastlineZeolmorirVZpayload�	firstlineZbolmorrrrA�sb

















���

























zFeedParser._parsegenc	Csjd}g}t|�D�]8\}}|ddkrR|sFt�|�}|j�|j|�q|�|�q|rt|jj|j�|��dg}}|�	d�r�|dkr�t
�|�}|r�|dt|�
d���}|j�|�qn<|t|�dkr�|j�|�dSt�|�}|jj�|�q|�d�}|dk�r&t�d�}|jj�|�q|dk�s8td��|d|�}|g}q|�rf|jj|j�|��dS)	Nrrz 	zFrom ��:zMissing header name.z3_parse_headers fed line with no : and no leading WS)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr:rMrCrZset_rawZheader_source_parse�
startswithrerfrgrdZset_unixfromr?r(ZMisplacedEnvelopeHeaderDefectZdefects�findZInvalidHeaderDefectr&)	rr1Z
lastheaderZ	lastvalue�linenor$rOrm�irrrr[�sH








zFeedParser._parse_headers)N)r5r6r7r8rrrFrIrGrrRrKrAr[rrrrr�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst��|�dd��dS)N�ascii�surrogateescape)�superrI�decoderH��	__class__rrrIszBytesFeedParser.feed)r5r6r7r8rI�
__classcell__rrrzrrs)r8�__all__raZemailrZemail._policybaser�collectionsr�iorrbrZrkreZNLCRE_crackrXr\�NL�objectr r
rrrrrr�<module>s(




[PK�"�\Ɥ��#_encoded_words.cpython-38.opt-2.pycnu�[���U

e5dL!�@s�ddlZddlZddlZddlZddlmZmZddlmZdddddd	d
dgZ	e�
e�d�jd
d��Z
dd�ZGdd�de�Ze�Zdeed�<dd�Zdd�Zdd�Zdd�Zdd	�Zeed�Zdd
�Zeed�Zeed�Zddd�ZdS)�N)�
ascii_letters�digits)�errors�decode_q�encode_q�decode_b�encode_b�len_q�len_b�decode�encodes=([a-fA-F0-9]{2})cCst�|�d����S)N�)�bytes�fromhex�groupr)�m�r�,/usr/lib64/python3.8/email/_encoded_words.py�<lambda>A�rcCs|�dd�}t|�gfS)N�_� )�replace�_q_byte_subber)�encodedrrrrCsc@s,eZdZde�d�e�d�Zdd�ZdS)�	_QByteMaps-!*+/�asciicCs.||jkrt|�||<nd�|�||<||S)Nz={:02X})�safe�chr�format)�self�keyrrr�__missing__Ms
z_QByteMap.__missing__N)�__name__�
__module__�__qualname__rrrrr"rrrrrIsr�_� cCsd�dd�|D��S)N�css|]}t|VqdS�N)�_q_byte_map��.0�xrrr�	<genexpr>Zszencode_q.<locals>.<genexpr>)�join��bstringrrrrYscCstdd�|D��S)Ncss|]}tt|�VqdSr))�lenr*r+rrrr.]szlen_q.<locals>.<genexpr>)�sumr0rrrr	\scCs�t|�d}|r ddd|�nd}z&tj||dd�|rDt��gngfWStjk
�r�ztj|dd�t��gfWYStjk
r�z,tj|ddd�t��t��gfWYYStjk
r�|t��gfYYYSXYnXYnXdS)N�s===rT)ZvalidateFs==)	r2�base64Z	b64decoderZInvalidBase64PaddingDefect�binascii�ErrorZInvalidBase64CharactersDefectZInvalidBase64LengthDefect)rZpad_errZmissing_paddingrrrrds(��
��cCst�|��d�S)Nr)r5Z	b64encoderr0rrrr�scCs&tt|�d�\}}|d|r dndS)N�r4r)�divmodr2)r1Zgroups_of_3Zleftoverrrrr
�s)�q�bc	
Cs�|�d�\}}}}}|�d�\}}}|��}|�dd�}t||�\}}z|�|�}Wnvtk
r�|�t�	d�
|���|�|d�}YnBtk
r�|�dd�}|��dkr�|�t�d�
|���YnX||||fS)N�?�*r�surrogateescapez:Encoded word contains bytes not decodable using {} charset�unknown-8bitz<Unknown charset {} in encoded word; decoded as unknown bytes)
�split�	partition�lowerr�
_cte_decodersr�UnicodeError�appendrZUndecodableBytesDefectr�LookupErrorZCharsetError)	Zewr&�charsetZcteZ
cte_string�langr1Zdefects�stringrrrr�s&���utf-8r(cCs||dkr|�dd�}n
|�|�}|dkrTtd|�}td|�}||dkrPdnd}t||�}|rld|}d�||||�S)	Nr?rr>r:r;�r=z=?{}{}?{}?{}?=)r�_cte_encode_length�
_cte_encodersr)rIrG�encodingrHr1ZqlenZblenrrrrr�s
)rJNr()�rer5r6�	functoolsrIrrZemailr�__all__�partial�compile�subrr�dictrr*�ordrr	rrr
rCrrMrLrrrrr�<module>*sJ��&�+��PK�"�\o��NNencoders.cpython-38.opt-1.pycnu�[���U

e5d��@sTdZddddgZddlmZddlmZdd	�Zd
d�Z	dd�Z
dd�Zd
d�ZdS)z Encodings and related functions.�encode_7or8bit�
encode_base64�encode_noop�
encode_quopri�)�encodebytes)�encodestringcCst|dd�}|�dd�S)NT)Z	quotetabs� s=20)�
_encodestring�replace)�s�enc�r
�&/usr/lib64/python3.8/email/encoders.py�_qencodesrcCs0|jdd�}tt|�d�}|�|�d|d<dS)zlEncode the message's payload in Base64.

    Also, add an appropriate Content-Transfer-Encoding header.
    T��decode�ascii�base64�Content-Transfer-EncodingN)�get_payload�str�_bencode�set_payload��msg�origZencdatar
r
rrs
cCs*|jdd�}t|�}|�|�d|d<dS)zvEncode the message's payload in quoted-printable.

    Also, add an appropriate Content-Transfer-Encoding header.
    Trzquoted-printablerN)rrrrr
r
rr&s
cCsX|jdd�}|dkr d|d<dSz|�d�Wntk
rJd|d<Yn
Xd|d<dS)z9Set the Content-Transfer-Encoding header to 7bit or 8bit.TrNZ7bitrrZ8bit)rr�UnicodeError)rrr
r
rr2scCsdS)zDo nothing.Nr
)rr
r
rrDsN)
�__doc__�__all__rrr�quoprirr	rrrrrr
r
r
r�<module>s�PK�"�\�f�\\parser.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZddddddgZddlmZmZdd	lmZmZdd
lm	Z	Gdd�d�Z
Gdd�de
�ZGd
d�d�ZGdd�de�Z
dS)z-A parser of RFC 2822 and MIME email messages.�Parser�HeaderParser�BytesParser�BytesHeaderParser�
FeedParser�BytesFeedParser�)�StringIO�
TextIOWrapper)rr)�compat32c@s0eZdZd
ed�dd�Zddd�Zddd	�ZdS)
rN��policycCs||_||_dS)a�Parser of RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The string must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the string or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        N)�_classr)�selfr
r�r�$/usr/lib64/python3.8/email/parser.py�__init__szParser.__init__FcCs@t|j|jd�}|r|��|�d�}|s,q8|�|�q|��S)a\Create a message structure from the data in a file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        ri )rr
rZ_set_headersonly�readZfeed�close)r�fp�headersonlyZ
feedparser�datarrr�parse)s
zParser.parsecCs|jt|�|d�S)a-Create a message structure from a string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        �r)rr�r�textrrrr�parsestr;szParser.parsestr)N)F)F)�__name__�
__module__�__qualname__r
rrrrrrrrs
c@s eZdZddd�Zddd�ZdS)	rTcCst�||d�S�NT)rr�rrrrrrrHszHeaderParser.parsecCst�||d�Sr)rrrrrrrKszHeaderParser.parsestrN)T)T)rrrrrrrrrrGs
c@s(eZdZdd�Zd	dd�Zd
dd�ZdS)rcOst||�|_dS)a�Parser of binary RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The input must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the input or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.
        N)r�parser)r�args�kwrrrrQszBytesParser.__init__FcCs0t|ddd�}z|j�||�W�S|��XdS)acCreate a message structure from the data in a binary file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        �ascii�surrogateescape)�encoding�errorsN)r	�detachr!rr rrrrcszBytesParser.parsecCs|jddd�}|j�||�S)a2Create a message structure from a byte string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        �ASCIIr%)r')�decoder!rrrrr�
parsebytesrszBytesParser.parsebytesN)F)F)rrrrrr+rrrrrOs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||dd�S�NTr)rrr rrrrszBytesHeaderParser.parsecCstj||dd�Sr,)rr+rrrrr+�szBytesHeaderParser.parsebytesN)T)T)rrrrr+rrrrr~s
N)�__doc__�__all__�iorr	Zemail.feedparserrrZemail._policybaser
rrrrrrrr�<module>s�7/PK�"�\FN��H%H%utils.cpython-38.pycnu�[���U

e5d�4�@sjdZddddddddd	d
ddd
ddgZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddl
mZ
ddl
mZddl
mZmZmZddlmZdZdZdZdZdZe�d�Ze�d�Zdd�Zdd �Zd7d"d�Zd#d�Zd$d%�Z d8d'd�Z!d9d(d�Z"d:d)d	�Z#d*d�Z$d+d�Z%d,d�Z&d-d�Z'd;d.d�Z(e�d/ej)�Z*d0d�Z+d<d3d�Z,d=d5d6�Z-dS)>zMiscellaneous utilities.�collapse_rfc2231_value�
decode_params�decode_rfc2231�encode_rfc2231�
formataddr�
formatdate�format_datetime�getaddresses�
make_msgid�	mktime_tz�	parseaddr�	parsedate�parsedate_tz�parsedate_to_datetime�unquote�N)�quote)�AddressList)r
)rr
�
_parsedate_tz)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]cCs*z|��WdStk
r$YdSXdS)z8Return True if s contains surrogate-escaped binary data.FTN)�encode�UnicodeEncodeError)�s�r�#/usr/lib64/python3.8/email/utils.py�_has_surrogates3s
rcCs|�dd�}|�dd�S)N�utf-8�surrogateescape�replace)r�decode)�stringZoriginal_bytesrrr�	_sanitize@sr"rcCs�|\}}|�d�|r�z|�d�Wn<tk
r`t|t�rFt|�}|�|�}d||fYSXd}t�|�rtd}t�	d|�}d||||fS|S)a�The inverse of parseaddr(), this takes a 2-tuple of the form
    (realname, email_address) and returns the string value suitable
    for an RFC 2822 From, To or Cc header.

    If the first element of pair is false, then the second element is
    returned unmodified.

    The optional charset is the character set that is used to encode
    realname in case realname is not ASCII safe.  Can be an instance of str or
    a Charset-like object which has a header_encode method.  Default is
    'utf-8'.
    �asciiz%s <%s>r�"z\\\g<0>z%s%s%s <%s>)
rr�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�nameZaddressZencoded_nameZquotesrrrrLs 




cCst�|�}t|�}|jS)z7Return a list of (REALNAME, EMAIL) for each fieldvalue.)�
COMMASPACE�join�_AddressList�addresslist)Zfieldvalues�all�arrrrns
cCsfddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDec�r���r)�	timetuple�zonerrr�_format_timetuple_and_zoneus&�
��r;FcCsR|dkrt��}|s|r,tj�|tjj�}ntj�|�}|rH|��}d}t||�S)a�Returns a date string as specified by RFC 2822, e.g.:

    Fri, 09 Nov 2001 01:08:47 -0000

    Optional timeval if given is a floating point time value as accepted by
    gmtime() and localtime(), otherwise the current time is used.

    Optional localtime is a flag that when True, interprets timeval, and
    returns a date relative to the local timezone instead of UTC, properly
    taking daylight savings time into account.

    Optional argument usegmt means that the timezone is written out as
    an ascii string, not numeric one (so "GMT" instead of "+0000"). This
    is needed for HTTP, and is only used when localtime==False.
    NF)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr~scCsV|��}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}n
|�d�}t||�S)a$Turn a datetime into a date string as specified in RFC 2822.

    If usegmt is True, dt must be an aware datetime with an offset of zero.  In
    this case 'GMT' will be rendered instead of the normal +0000 required by
    RFC2822.  This is to support HTTP headers involving date stamps.
    Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)r9�tzinfor=r>r?�
ValueError�strftimer;)rDrC�nowr:rrrr�s

cCs^tt��d�}t��}t�d�}|dkr0d}nd|}|dkrHt��}d|||||f}|S)a{Returns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.  Optional domain if given provides the
    portion of the message id after the '@'.  It defaults to the locally
    defined hostname.
    �d�@Nr�.z<%d.%d.%d%s@%s>)�intr<�os�getpid�randomZgetrandbits�socketZgetfqdn)ZidstringZdomainrA�pidZrandintZmsgidrrrr	�s

cCsNt|��^}}|dkr(tj|dd��Stj|dd�dt�tj|d��i�S)Nr3rE��seconds)rr=r>�	timedelta)�dataZdtuple�tzrrrr�s�cCst|�j}|sdS|dS)z�
    Parse addr into its constituent realname and email address parts.

    Return a tuple of realname and email address, unless the parse fails, in
    which case return a 2-tuple of ('', '').
    )rrr)r/r0)ZaddrZaddrsrrrr�s
cCs`t|�dkr\|�d�r<|�d�r<|dd��dd��dd�S|�d�r\|�d�r\|dd�S|S)	zRemove quotes from a string.r5r$���z\\�\z\"�<�>)�len�
startswith�endswithr)r&rrrr�scCs&|�td�}t|�dkr"dd|fS|S)z#Decode string according to RFC 2231r4N)�split�TICKr[)r�partsrrrr�s
cCsDtjj|d|pdd�}|dkr*|dkr*|S|dkr6d}d|||fS)z�Encode string according to RFC 2231.

    If neither charset nor language is given, then s is returned as-is.  If
    charset is given but not language, the string is encoded using the empty
    string for language.
    rr#)Zsafe�encodingNz%s'%s'%s)�urllib�parser)rr+�languagerrrr�sz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Csl|dd�}g}i}|�d�\}}|�||f�|r�|�d�\}}|�d�rRd}nd}t|�}t�|�}|r�|�dd�\}}|dk	r�t|�}|�|g��|||f�q0|�|dt	|�f�q0|�rh|�
�D]�\}}g}d}	|��|D].\}}
}|�rtj
j|
d	d
�}
d}	|�|
�q�t	t�|��}|	�rTt|�\}}}|�|||d|ff�q�|�|d|f�q�|S)zDecode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (param name, string value).
    Nr�*TFr,�numz"%s"zlatin-1)ra)�pop�appendr]r�rfc2231_continuation�match�grouprL�
setdefaultr�items�sortrbrc�EMPTYSTRINGr.r)
ZparamsZ
new_paramsZrfc2231_paramsr,�valueZencodedZmorfZ
continuationsZextendedrr+rdrrrrsD

r�us-asciicCsnt|t�rt|�dkrt|�S|\}}}|dkr4|}t|d�}zt|||�WStk
rht|�YSXdS)Nr6zraw-unicode-escape)r%�tupler[r�bytesr&�LookupError)rp�errorsZfallback_charsetr+rd�textZrawbytesrrrr9s

rWc	Cs|dkrtj�tjj���S|jdk	r.|��S|��dd�|f}t�|�}t�	|�}z tj
|jd�}t�||j�}Wn�t
k
r�|tjt�|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�t�|tj|�}n
t�|�}YnX|j|d�S)a�Return local time as an aware datetime object.

    If called without arguments, return current time.  Otherwise *dt*
    argument should be a datetime instance, and it is converted to the
    local time zone according to the system time zone database.  If *dt* is
    naive (that is, dt.tzinfo is None), it is assumed to be in local time.
    In this case, a positive or zero value for *isdst* causes localtime to
    presume initially that summer time (for example, Daylight Saving Time)
    is or is not (respectively) in effect for the specified time.  A
    negative value for *isdst* causes the localtime() function to attempt
    to divine whether summer time is in effect for the specified time.

    NrWrRr3r)rE)r=rHr>r?r@rEr9r<�mktimerBrT�	tm_gmtoff�tm_zone�AttributeError�gmtime�daylight�tm_isdst�altzone�tznamer)	rDZisdstZtmrSZlocaltmZdeltarVZdstZgmtoffrrrrBSs$


rB)r)NFF)F)NN)NN)rrq)NrW).�__doc__�__all__rM�rer<rOrPr=Zurllib.parserbZemail._parseaddrrrr/r
rr
rZ
email.charsetrr-roZUEMPTYSTRINGZCRLFr_�compiler'r)rr"rrr;rrr	rrrrr�ASCIIrirrrBrrrr�<module>sp�



"	



�8�
PK�"�\�(�%�%policy.cpython-38.pycnu�[���U

e5d�(�@s�dZddlZddlZddlmZmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	d
ddd
ddgZe�d�ZeGdd�de��Ze�Ze`ejdd�Zejdd�Zejddd�Zejdd�ZdS)zcThis will be the home for the policy that hooks in the new
code that adds all the email6 features.
�N)�Policy�Compat32�compat32�_extend_docstrings)�_has_surrogates)�HeaderRegistry)�raw_data_manager)�EmailMessagerrr�EmailPolicy�default�strict�SMTP�HTTPz\n|\rcspeZdZdZeZdZdZe�Z	e
Z�fdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�Zddd�Z�ZS)r
aQ+
    PROVISIONAL

    The API extensions enabled by this policy are currently provisional.
    Refer to the documentation for details.

    This policy adds new header parsing and folding algorithms.  Instead of
    simple strings, headers are custom objects with custom attributes
    depending on the type of the field.  The folding algorithm fully
    implements RFCs 2047 and 5322.

    In addition to the settable attributes listed above that apply to
    all Policies, this policy adds the following additional attributes:

    utf8                -- if False (the default) message headers will be
                           serialized as ASCII, using encoded words to encode
                           any non-ASCII characters in the source strings.  If
                           True, the message headers will be serialized using
                           utf8 and will not contain encoded words (see RFC
                           6532 for more on this serialization format).

    refold_source       -- if the value for a header in the Message object
                           came from the parsing of some source, this attribute
                           indicates whether or not a generator should refold
                           that value when transforming the message back into
                           stream form.  The possible values are:

                           none  -- all source values use original folding
                           long  -- source values that have any line that is
                                    longer than max_line_length will be
                                    refolded
                           all  -- all values are refolded.

                           The default is 'long'.

    header_factory      -- a callable that takes two arguments, 'name' and
                           'value', where 'name' is a header field name and
                           'value' is an unfolded header field value, and
                           returns a string-like object that represents that
                           header.  A default header_factory is provided that
                           understands some of the RFC5322 header field types.
                           (Currently address fields and date fields have
                           special treatment, while all other fields are
                           treated as unstructured.  This list will be
                           completed before the extension is marked stable.)

    content_manager     -- an object with at least two methods: get_content
                           and set_content.  When the get_content or
                           set_content method of a Message object is called,
                           it calls the corresponding method of this object,
                           passing it the message object as its first argument,
                           and any arguments or keywords that were passed to
                           it as additional arguments.  The default
                           content_manager is
                           :data:`~email.contentmanager.raw_data_manager`.

    F�longcs*d|krt�|dt��t�jf|�dS)N�header_factory)�object�__setattr__r�super�__init__)�self�kw��	__class__��$/usr/lib64/python3.8/email/policy.pyr]szEmailPolicy.__init__cCs|j|jS)z�+
        The implementation for this class returns the max_count attribute from
        the specialized header class that would be used to construct a header
        of type 'name'.
        )rZ	max_count)r�namerrr�header_max_countdszEmailPolicy.header_max_countcCs>|d�dd�\}}|�d�d�|dd��}||�d�fS)ac+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.  (This
        is the same as Compat32).

        r�:�z 	�N�
)�split�lstrip�join�rstrip)rZsourcelinesr�valuerrr�header_source_parsevs	zEmailPolicy.header_source_parsecCsVt|d�r$|j��|��kr$||fSt|t�rFt|���dkrFtd��||�||�fS)a�+
        The name is returned unchanged.  If the input value has a 'name'
        attribute and it matches the name ignoring case, the value is returned
        unchanged.  Otherwise the name and value are passed to header_factory
        method, and the resulting custom header object is returned as the
        value.  In this case a ValueError is raised if the input value contains
        CR or LF characters.

        rrzDHeader values may not contain linefeed or carriage return characters)	�hasattrr�lower�
isinstance�str�len�
splitlines�
ValueErrorr�rrr%rrr�header_store_parse�s

zEmailPolicy.header_store_parsecCs*t|d�r|Sd�t�|��}|�||�S)ai+
        If the value has a 'name' attribute, it is returned to unmodified.
        Otherwise the name and the value with any linesep characters removed
        are passed to the header_factory method, and the resulting custom
        header object is returned.  Any surrogateescaped bytes get turned
        into the unicode unknown-character glyph.

        rr)r'r#�linesep_splitterr!rr.rrr�header_fetch_parse�s	
zEmailPolicy.header_fetch_parsecCs|j||dd�S)a+
        Header folding is controlled by the refold_source policy setting.  A
        value is considered to be a 'source value' if and only if it does not
        have a 'name' attribute (having a 'name' attribute means it is a header
        object of some sort).  If a source value needs to be refolded according
        to the policy, it is converted into a custom header object by passing
        the name and the value with any linesep characters removed to the
        header_factory method.  Folding of a custom header object is done by
        calling its fold method with the current policy.

        Source values are split into lines using splitlines.  If the value is
        not to be refolded, the lines are rejoined using the linesep from the
        policy and returned.  The exception is lines containing non-ascii
        binary data.  In that case the value is refolded regardless of the
        refold_source setting, which causes the binary data to be CTE encoded
        using the unknown-8bit charset.

        T��
refold_binary)�_foldr.rrr�fold�szEmailPolicy.foldcCs0|j|||jdkd�}|jr dnd}|�|d�S)a+
        The same as fold if cte_type is 7bit, except that the returned value is
        bytes.

        If cte_type is 8bit, non-ASCII binary data is converted back into
        bytes.  Headers with binary data are not refolded, regardless of the
        refold_header setting, since there is no way to know whether the binary
        data consists of single byte characters or multibyte characters.

        If utf8 is true, headers are encoded to utf8, otherwise to ascii with
        non-ASCII unicode rendered as encoded words.

        Z7bitr2�utf8�ascii�surrogateescape)r4Zcte_typer6�encode)rrr%Zfolded�charsetrrr�fold_binary�szEmailPolicy.fold_binarycs�t|d�r|j|d�S|jr"|jntj�|��}|jdkp�|jdko�|rdt|d�t|�d�kp�t�fdd�|d	d�D��}|s�|r�t	|�r�|�
|d
�|��j|d�S|d|j�|�|jS)Nr)Zpolicy�allrr�c3s|]}t|��kVqdS)N)r+)�.0�x��maxlenrr�	<genexpr>�sz$EmailPolicy._fold.<locals>.<genexpr>rrz: )
r'r5�max_line_length�sys�maxsizer,�
refold_sourcer+�anyrrr#�linesep)rrr%r3�linesZrefoldrr@rr4�s


 �zEmailPolicy._fold)F)�__name__�
__module__�__qualname__�__doc__r	Zmessage_factoryr6rFrrrZcontent_managerrrr&r/r1r5r;r4�
__classcell__rrrrr
s:
T)Zraise_on_defectr )rH)rHrC)r6)rM�rerDZemail._policybaserrrrZemail.utilsrZemail.headerregistryrZemail.contentmanagerrZ
email.messager	�__all__�compiler0r
rrZclonerr
rZSMTPUTF8rrrr�<module>s4�
@PK�"�\�(�%�%policy.cpython-38.opt-1.pycnu�[���U

e5d�(�@s�dZddlZddlZddlmZmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	d
ddd
ddgZe�d�ZeGdd�de��Ze�Ze`ejdd�Zejdd�Zejddd�Zejdd�ZdS)zcThis will be the home for the policy that hooks in the new
code that adds all the email6 features.
�N)�Policy�Compat32�compat32�_extend_docstrings)�_has_surrogates)�HeaderRegistry)�raw_data_manager)�EmailMessagerrr�EmailPolicy�default�strict�SMTP�HTTPz\n|\rcspeZdZdZeZdZdZe�Z	e
Z�fdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�Zddd�Z�ZS)r
aQ+
    PROVISIONAL

    The API extensions enabled by this policy are currently provisional.
    Refer to the documentation for details.

    This policy adds new header parsing and folding algorithms.  Instead of
    simple strings, headers are custom objects with custom attributes
    depending on the type of the field.  The folding algorithm fully
    implements RFCs 2047 and 5322.

    In addition to the settable attributes listed above that apply to
    all Policies, this policy adds the following additional attributes:

    utf8                -- if False (the default) message headers will be
                           serialized as ASCII, using encoded words to encode
                           any non-ASCII characters in the source strings.  If
                           True, the message headers will be serialized using
                           utf8 and will not contain encoded words (see RFC
                           6532 for more on this serialization format).

    refold_source       -- if the value for a header in the Message object
                           came from the parsing of some source, this attribute
                           indicates whether or not a generator should refold
                           that value when transforming the message back into
                           stream form.  The possible values are:

                           none  -- all source values use original folding
                           long  -- source values that have any line that is
                                    longer than max_line_length will be
                                    refolded
                           all  -- all values are refolded.

                           The default is 'long'.

    header_factory      -- a callable that takes two arguments, 'name' and
                           'value', where 'name' is a header field name and
                           'value' is an unfolded header field value, and
                           returns a string-like object that represents that
                           header.  A default header_factory is provided that
                           understands some of the RFC5322 header field types.
                           (Currently address fields and date fields have
                           special treatment, while all other fields are
                           treated as unstructured.  This list will be
                           completed before the extension is marked stable.)

    content_manager     -- an object with at least two methods: get_content
                           and set_content.  When the get_content or
                           set_content method of a Message object is called,
                           it calls the corresponding method of this object,
                           passing it the message object as its first argument,
                           and any arguments or keywords that were passed to
                           it as additional arguments.  The default
                           content_manager is
                           :data:`~email.contentmanager.raw_data_manager`.

    F�longcs*d|krt�|dt��t�jf|�dS)N�header_factory)�object�__setattr__r�super�__init__)�self�kw��	__class__��$/usr/lib64/python3.8/email/policy.pyr]szEmailPolicy.__init__cCs|j|jS)z�+
        The implementation for this class returns the max_count attribute from
        the specialized header class that would be used to construct a header
        of type 'name'.
        )rZ	max_count)r�namerrr�header_max_countdszEmailPolicy.header_max_countcCs>|d�dd�\}}|�d�d�|dd��}||�d�fS)ac+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.  (This
        is the same as Compat32).

        r�:�z 	�N�
)�split�lstrip�join�rstrip)rZsourcelinesr�valuerrr�header_source_parsevs	zEmailPolicy.header_source_parsecCsVt|d�r$|j��|��kr$||fSt|t�rFt|���dkrFtd��||�||�fS)a�+
        The name is returned unchanged.  If the input value has a 'name'
        attribute and it matches the name ignoring case, the value is returned
        unchanged.  Otherwise the name and value are passed to header_factory
        method, and the resulting custom header object is returned as the
        value.  In this case a ValueError is raised if the input value contains
        CR or LF characters.

        rrzDHeader values may not contain linefeed or carriage return characters)	�hasattrr�lower�
isinstance�str�len�
splitlines�
ValueErrorr�rrr%rrr�header_store_parse�s

zEmailPolicy.header_store_parsecCs*t|d�r|Sd�t�|��}|�||�S)ai+
        If the value has a 'name' attribute, it is returned to unmodified.
        Otherwise the name and the value with any linesep characters removed
        are passed to the header_factory method, and the resulting custom
        header object is returned.  Any surrogateescaped bytes get turned
        into the unicode unknown-character glyph.

        rr)r'r#�linesep_splitterr!rr.rrr�header_fetch_parse�s	
zEmailPolicy.header_fetch_parsecCs|j||dd�S)a+
        Header folding is controlled by the refold_source policy setting.  A
        value is considered to be a 'source value' if and only if it does not
        have a 'name' attribute (having a 'name' attribute means it is a header
        object of some sort).  If a source value needs to be refolded according
        to the policy, it is converted into a custom header object by passing
        the name and the value with any linesep characters removed to the
        header_factory method.  Folding of a custom header object is done by
        calling its fold method with the current policy.

        Source values are split into lines using splitlines.  If the value is
        not to be refolded, the lines are rejoined using the linesep from the
        policy and returned.  The exception is lines containing non-ascii
        binary data.  In that case the value is refolded regardless of the
        refold_source setting, which causes the binary data to be CTE encoded
        using the unknown-8bit charset.

        T��
refold_binary)�_foldr.rrr�fold�szEmailPolicy.foldcCs0|j|||jdkd�}|jr dnd}|�|d�S)a+
        The same as fold if cte_type is 7bit, except that the returned value is
        bytes.

        If cte_type is 8bit, non-ASCII binary data is converted back into
        bytes.  Headers with binary data are not refolded, regardless of the
        refold_header setting, since there is no way to know whether the binary
        data consists of single byte characters or multibyte characters.

        If utf8 is true, headers are encoded to utf8, otherwise to ascii with
        non-ASCII unicode rendered as encoded words.

        Z7bitr2�utf8�ascii�surrogateescape)r4Zcte_typer6�encode)rrr%Zfolded�charsetrrr�fold_binary�szEmailPolicy.fold_binarycs�t|d�r|j|d�S|jr"|jntj�|��}|jdkp�|jdko�|rdt|d�t|�d�kp�t�fdd�|d	d�D��}|s�|r�t	|�r�|�
|d
�|��j|d�S|d|j�|�|jS)Nr)Zpolicy�allrr�c3s|]}t|��kVqdS)N)r+)�.0�x��maxlenrr�	<genexpr>�sz$EmailPolicy._fold.<locals>.<genexpr>rrz: )
r'r5�max_line_length�sys�maxsizer,�
refold_sourcer+�anyrrr#�linesep)rrr%r3�linesZrefoldrr@rr4�s


 �zEmailPolicy._fold)F)�__name__�
__module__�__qualname__�__doc__r	Zmessage_factoryr6rFrrrZcontent_managerrrr&r/r1r5r;r4�
__classcell__rrrrr
s:
T)Zraise_on_defectr )rH)rHrC)r6)rM�rerDZemail._policybaserrrrZemail.utilsrZemail.headerregistryrZemail.contentmanagerrZ
email.messager	�__all__�compiler0r
rrZclonerr
rZSMTPUTF8rrrr�<module>s4�
@PK�"�\l��$?8?8#_header_value_parser.cpython-38.pycnu�[���U

e5dϡ�	@s�dZddlZddlZddlZddlmZddlmZddlm	Z
ddlmZddlmZe
d�Zee
d	�BZe
d
�ZeeBZee
d�Zee
d�Zee
d
�Be
d�ZeeBZee
d�BZeeBZee
d�Zdd�Ze�dejejB�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de �Z$Gdd �d e�Z%Gd!d"�d"e�Z&Gd#d$�d$e�Z'Gd%d&�d&e�Z(Gd'd(�d(e(�Z)Gd)d*�d*e �Z*Gd+d,�d,e�Z+Gd-d.�d.e�Z,Gd/d0�d0e�Z-Gd1d2�d2e�Z.Gd3d4�d4e�Z/Gd5d6�d6e�Z0Gd7d8�d8e�Z1Gd9d:�d:e�Z2Gd;d<�d<e�Z3Gd=d>�d>e�Z4Gd?d@�d@e�Z5GdAdB�dBe�Z6GdCdD�dDe�Z7GdEdF�dFe�Z8GdGdH�dHe�Z9GdIdJ�dJe�Z:GdKdL�dLe"�Z;GdMdN�dNe�Z<GdOdP�dPe�Z=GdQdR�dRe�Z>GdSdT�dTe�Z?GdUdV�dVe?�Z@GdWdX�dXe�ZAGdYdZ�dZe�ZBGd[d\�d\e�ZCGd]d^�d^e�ZDGd_d`�d`e�ZEGdadb�dbeE�ZFGdcdd�ddeE�ZGGdedf�dfe�ZHGdgdh�dhe�ZIGdidj�dje�ZJGdkdl�dleJ�ZKGdmdn�dneK�ZLGdodp�dpe�ZMGdqdr�dreN�ZOGdsdt�dteO�ZPGdudv�dveO�ZQGdwdx�dxeP�ZRGdydz�dzejS�ZTeQdd{�ZUeQd|d}�ZVeQd~d�ZWe�d��Xd��Ye���jZZ[e�d��Xe�\d��Ye����j]Z^e�d��j_Z`e�d��Xe�\d��Ye����j]Zae�d��Xe�\d��Ye����j]Zbe�d��Xe�\d��Ye����j]Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d��Z�d�d��Z�d�dÄZ�d�dńZ�d�dDŽZ�d�dɄZ�d�d˄Z�d�d̈́Z�d�dτZ�d�dфZ�d�dӄZ�d�dՄZ�d�dׄZ�d�dلZ�d�dۄZ�d�d݄Z�d�d߄Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�d�d��Z�dS)�alHeader value parser implementing various email-related RFC parsing rules.

The parsing methods defined in this module implement various email related
parsing rules.  Principal among them is RFC 5322, which is the followon
to RFC 2822 and primarily a clarification of the former.  It also implements
RFC 2047 encoded word decoding.

RFC 5322 goes to considerable trouble to maintain backward compatibility with
RFC 822 in the parse phase, while cleaning up the structure on the generation
phase.  This parser supports correct RFC 5322 generation by tagging white space
as folding white space only when folding is allowed in the non-obsolete rule
sets.  Actually, the parser is even more generous when accepting input than RFC
5322 mandates, following the spirit of Postel's Law, which RFC 5322 encourages.
Where possible deviations from the standard are annotated on the 'defects'
attribute of tokens that deviate.

The general structure of the parser follows RFC 5322, and uses its terminology
where there is a direct correspondence.  Where the implementation requires a
somewhat different structure than that used by the formal grammar, new terms
that mimic the closest existing terms are used.  Thus, it really helps to have
a copy of RFC 5322 handy when studying this code.

Input to the parser is a string that has already been unfolded according to
RFC 5322 rules.  According to the RFC this unfolding is the very first step, and
this parser leaves the unfolding step to a higher level message parser, which
will have already detected the line breaks that need unfolding while
determining the beginning and end of each header.

The output of the parser is a TokenList object, which is a list subclass.  A
TokenList is a recursive data structure.  The terminal nodes of the structure
are Terminal objects, which are subclasses of str.  These do not correspond
directly to terminal objects in the formal grammar, but are instead more
practical higher level combinations of true terminals.

All TokenList and Terminal objects have a 'value' attribute, which produces the
semantically meaningful value of that part of the parse subtree.  The value of
all whitespace tokens (no matter how many sub-tokens they may contain) is a
single space, as per the RFC rules.  This includes 'CFWS', which is herein
included in the general class of whitespace tokens.  There is one exception to
the rule that whitespace tokens are collapsed into single spaces in values: in
the value of a 'bare-quoted-string' (a quoted-string with no leading or
trailing whitespace), any whitespace that appeared between the quotation marks
is preserved in the returned value.  Note that in all Terminal strings quoted
pairs are turned into their unquoted values.

All TokenList and Terminal objects also have a string value, which attempts to
be a "canonical" representation of the RFC-compliant form of the substring that
produced the parsed subtree, including minimal use of quoted pair quoting.
Whitespace runs are not collapsed.

Comment tokens also have a 'content' attribute providing the string found
between the parens (including any nested comments) with whitespace preserved.

All TokenList and Terminal objects have a 'defects' attribute which is a
possibly empty list all of the defects found while creating the token.  Defects
may appear on any token in the tree, and a composite list of all defects in the
subtree is available through the 'all_defects' attribute of any node.  (For
Terminal notes x.defects == x.all_defects.)

Each object in a parse tree is called a 'token', and each has a 'token_type'
attribute that gives the name from the RFC 5322 grammar that it represents.
Not all RFC 5322 nodes are produced, and there is one non-RFC 5322 node that
may be produced: 'ptext'.  A 'ptext' is a string of printable ascii characters.
It is returned in place of lists of (ctext/quoted-pair) and
(qtext/quoted-pair).

XXX: provide complete list of token types.
�N)�	hexdigits)�
itemgetter)�_encoded_words)�errors)�utilsz 	�(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%cCs dt|��dd��dd�dS)N�"�\�\\z\")�str�replace��value�r�2/usr/lib64/python3.8/email/_header_value_parser.py�quote_string`srz�
   =\?            # literal =?
   [^?]*          # charset
   \?             # literal ?
   [qQbB]         # literal 'q' or 'b', case insensitive
   \?             # literal ?
  .*?             # encoded word
  \?=             # literal ?=
cs�eZdZdZdZdZ�fdd�Zdd�Z�fdd�Ze	d	d
��Z
e	dd��Zd
d�Ze	dd��Z
e	dd��Zdd�Zddd�Zddd�Zddd�Z�ZS)�	TokenListNTcst�j||�g|_dS�N)�super�__init__�defects)�self�args�kw��	__class__rrryszTokenList.__init__cCsd�dd�|D��S)N�css|]}t|�VqdSr�r
��.0�xrrr�	<genexpr>~sz$TokenList.__str__.<locals>.<genexpr>��join�rrrr�__str__}szTokenList.__str__csd�|jjt����S�Nz{}({})��formatr�__name__r�__repr__r&rrrr,�s
�zTokenList.__repr__cCsd�dd�|D��S)Nrcss|]}|jr|jVqdSrrr rrrr#�sz"TokenList.value.<locals>.<genexpr>r$r&rrrr�szTokenList.valuecCstdd�|D�|j�S)Ncss|]}|jVqdSr)�all_defectsr rrrr#�sz(TokenList.all_defects.<locals>.<genexpr>)�sumrr&rrrr-�szTokenList.all_defectscCs|d��S�Nr)�startswith_fwsr&rrrr0�szTokenList.startswith_fwscCstdd�|D��S)zATrue if all top level tokens of this part may be RFC2047 encoded.css|]}|jVqdSr)�
as_ew_allowed)r!�partrrrr#�sz*TokenList.as_ew_allowed.<locals>.<genexpr>)�allr&rrrr1�szTokenList.as_ew_allowedcCsg}|D]}|�|j�q|Sr)�extend�comments)rr5�tokenrrrr5�szTokenList.commentscCst||d�S)N��policy)�_refold_parse_tree�rr8rrr�fold�szTokenList.foldrcCst|j|d��dS)N��indent)�print�ppstr�rr=rrr�pprint�szTokenList.pprintcCsd�|j|d��S)N�
r<)r%�_ppr@rrrr?�szTokenList.ppstrccszd�||jj|j�V|D]4}t|d�s:|d�|�Vq|�|d�EdHq|jrdd�|j�}nd}d�||�VdS)Nz{}{}/{}(rCz*    !! invalid element in token list: {!r}z    z Defects: {}rz{}){})r*rr+�
token_type�hasattrrCr)rr=r6ZextrarrrrC�s�
�
z
TokenList._pp)r)r)r)r+�
__module__�__qualname__rD�syntactic_break�ew_combine_allowedrr'r,�propertyrr-r0r1r5r;rAr?rC�
__classcell__rrrrrss&





rc@s$eZdZedd��Zedd��ZdS)�WhiteSpaceTokenListcCsdS�N� rr&rrrr�szWhiteSpaceTokenList.valuecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)�comment)rD�contentr rrr�
<listcomp>�s
z0WhiteSpaceTokenList.comments.<locals>.<listcomp>rr&rrrr5�szWhiteSpaceTokenList.commentsN)r+rFrGrJrr5rrrrrL�s
rLc@seZdZdZdS)�UnstructuredTokenList�unstructuredN�r+rFrGrDrrrrrR�srRc@seZdZdZdS)�Phrase�phraseNrTrrrrrU�srUc@seZdZdZdS)�WordZwordNrTrrrrrW�srWc@seZdZdZdS)�CFWSList�cfwsNrTrrrrrX�srXc@seZdZdZdS)�Atom�atomNrTrrrrrZ�srZc@seZdZdZdZdS)�Tokenr6FN)r+rFrGrDZencode_as_ewrrrrr\�sr\c@seZdZdZdZdZdZdS)�EncodedWord�encoded-wordN)r+rFrGrD�cte�charset�langrrrrr]�sr]c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�QuotedString�
quoted-stringcCs"|D]}|jdkr|jSqdS�N�bare-quoted-string�rDr�rr"rrrrP�s
zQuotedString.contentcCs>g}|D]*}|jdkr&|�t|��q|�|j�qd�|�S)Nrer)rD�appendr
rr%)r�resr"rrr�quoted_value�s
zQuotedString.quoted_valuecCs"|D]}|jdkr|jSqdSrdrf�rr6rrr�stripped_value�s
zQuotedString.stripped_valueN)r+rFrGrDrJrPrjrlrrrrrb�s

	rbc@s$eZdZdZdd�Zedd��ZdS)�BareQuotedStringrecCstd�dd�|D���S)Nrcss|]}t|�VqdSrrr rrrr#sz+BareQuotedString.__str__.<locals>.<genexpr>)rr%r&rrrr'�szBareQuotedString.__str__cCsd�dd�|D��S)Nrcss|]}t|�VqdSrrr rrrr#sz)BareQuotedString.value.<locals>.<genexpr>r$r&rrrrszBareQuotedString.valueN)r+rFrGrDr'rJrrrrrrm�srmc@s8eZdZdZdd�Zdd�Zedd��Zedd	��Zd
S)�CommentrOcs(d�tdg�fdd��D�dggg��S)Nrrcsg|]}��|��qSr)�quoter r&rrrQsz#Comment.__str__.<locals>.<listcomp>�))r%r.r&rr&rr's��zComment.__str__cCs2|jdkrt|�St|��dd��dd��dd�S)NrOrrrz\(rpz\))rDr
r)rrrrrros
��z
Comment.quotecCsd�dd�|D��S)Nrcss|]}t|�VqdSrrr rrrr#sz"Comment.content.<locals>.<genexpr>r$r&rrrrPszComment.contentcCs|jgSr)rPr&rrrr5szComment.commentsN)	r+rFrGrDr'rorJrPr5rrrrrns
rnc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressListzaddress-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)�address�rDr rrrrQ's
z)AddressList.addresses.<locals>.<listcomp>rr&rrr�	addresses%szAddressList.addressescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS�rrN�rD�	mailboxesr rrrr#+s
�z(AddressList.mailboxes.<locals>.<genexpr>�r.r&rrrrw)s
��zAddressList.mailboxescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdSru�rD�
all_mailboxesr rrrr#0s
�z,AddressList.all_mailboxes.<locals>.<genexpr>rxr&rrrrz.s
��zAddressList.all_mailboxesN)r+rFrGrDrJrtrwrzrrrrrq!s

rqc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressrrcCs|djdkr|djSdS)Nr�group�rD�display_namer&rrrr~8szAddress.display_namecCs4|djdkr|dgS|djdkr*gS|djS�Nr�mailbox�invalid-mailboxrvr&rrrrw=s

zAddress.mailboxescCs:|djdkr|dgS|djdkr0|dgS|djSrryr&rrrrzEs


zAddress.all_mailboxesN)r+rFrGrDrJr~rwrzrrrrr{4s

r{c@s(eZdZdZedd��Zedd��ZdS)�MailboxList�mailbox-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)r�rsr rrrrQSs
z)MailboxList.mailboxes.<locals>.<listcomp>rr&rrrrwQszMailboxList.mailboxescCsdd�|D�S)NcSsg|]}|jdkr|�qS))r�r�rsr rrrrQWs
�z-MailboxList.all_mailboxes.<locals>.<listcomp>rr&rrrrzUszMailboxList.all_mailboxesN�r+rFrGrDrJrwrzrrrrr�Ms

r�c@s(eZdZdZedd��Zedd��ZdS)�	GroupList�
group-listcCs |r|djdkrgS|djS�Nrr�rvr&rrrrw_szGroupList.mailboxescCs |r|djdkrgS|djSr�ryr&rrrrzeszGroupList.all_mailboxesNr�rrrrr�[s

r�c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�Groupr|cCs|djdkrgS|djS�N�r�rvr&rrrrwpszGroup.mailboxescCs|djdkrgS|djSr�ryr&rrrrzvszGroup.all_mailboxescCs
|djSr/)r~r&rrrr~|szGroup.display_nameN)r+rFrGrDrJrwrzr~rrrrr�ls

r�c@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�NameAddr�	name-addrcCst|�dkrdS|djS�N�r)�lenr~r&rrrr~�szNameAddr.display_namecCs
|djS�N�����
local_partr&rrrr��szNameAddr.local_partcCs
|djSr���domainr&rrrr��szNameAddr.domaincCs
|djSr�)�router&rrrr��szNameAddr.routecCs
|djSr���	addr_specr&rrrr��szNameAddr.addr_specN�
r+rFrGrDrJr~r�r�r�r�rrrrr��s



r�c@s@eZdZdZedd��Zedd��Zedd��Zedd	��Zd
S)�	AngleAddrz
angle-addrcCs"|D]}|jdkr|jSqdS�N�	addr-spec)rDr�rgrrrr��s
zAngleAddr.local_partcCs"|D]}|jdkr|jSqdSr��rDr�rgrrrr��s
zAngleAddr.domaincCs"|D]}|jdkr|jSqdS)N�	obs-route)rD�domainsrgrrrr��s
zAngleAddr.routecCs<|D]2}|jdkr|jr"|jSt|j�|jSqdS)Nr�z<>)rDr�r�rrgrrrr��s

zAngleAddr.addr_specN)	r+rFrGrDrJr�r�r�r�rrrrr��s


r�c@seZdZdZedd��ZdS)�ObsRouter�cCsdd�|D�S)NcSsg|]}|jdkr|j�qSr�r�r rrrrQ�s
z$ObsRoute.domains.<locals>.<listcomp>rr&rrrr��szObsRoute.domainsN)r+rFrGrDrJr�rrrrr��sr�c@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�Mailboxr�cCs|djdkr|djSdS�Nrr�r}r&rrrr~�szMailbox.display_namecCs
|djSr/r�r&rrrr��szMailbox.local_partcCs
|djSr/r�r&rrrr��szMailbox.domaincCs|djdkr|djSdSr�)rDr�r&rrrr��sz
Mailbox.routecCs
|djSr/r�r&rrrr��szMailbox.addr_specNr�rrrrr��s



r�c@s,eZdZdZedd��ZeZZZZ	dS)�InvalidMailboxr�cCsdSrrr&rrrr~�szInvalidMailbox.display_nameNr�rrrrr��s
r�cs(eZdZdZdZe�fdd��Z�ZS)�Domainr�Fcsd�t�j���S�Nr�r%rr�splitr&rrrr��sz
Domain.domain)r+rFrGrDr1rJr�rKrrrrr��sr�c@seZdZdZdS)�DotAtom�dot-atomNrTrrrrr��sr�c@seZdZdZdZdS)�DotAtomTextz
dot-atom-textTN�r+rFrGrDr1rrrrr��sr�c@seZdZdZdZdS)�
NoFoldLiteralzno-fold-literalFNr�rrrrr�sr�c@sDeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dS)�AddrSpecr�FcCs
|djSr/r�r&rrrr�
szAddrSpec.local_partcCst|�dkrdS|djS)N�r�)r�r�r&rrrr�szAddrSpec.domaincCs<t|�dkr|djS|dj��|dj|dj��S)Nr�rr�r�)r�r�rstrip�lstripr&rrrrs
zAddrSpec.valuecCsLt|j�}t|�t|t�kr*t|j�}n|j}|jdk	rH|d|jS|S)N�@)�setr�r��
DOT_ATOM_ENDSrr�)rZnamesetZlprrrr�s

zAddrSpec.addr_specN)
r+rFrGrDr1rJr�r�rr�rrrrr�s


r�c@seZdZdZdZdS)�ObsLocalPartzobs-local-partFNr�rrrrr�&sr�cs4eZdZdZdZedd��Ze�fdd��Z�ZS)�DisplayNamezdisplay-nameFcCs�t|�}t|�dkr|jS|djdkr4|�d�n*|ddjdkr^t|ddd��|d<|djdkrv|��n*|ddjdkr�t|ddd��|d<|jS)NrrYr�r�)rr�rrD�pop)rrirrrr~1s
zDisplayName.display_namecs�d}|jrd}n|D]}|jdkrd}qt|�dkr�|r�d}}|djdks`|ddjdkrdd}|djdks�|ddjdkr�d}|t|j�|St�jSdS)	NFTrcrrrYrNr�)rrDr�rr~rr)rror"ZpreZpostrrrrBs
  zDisplayName.value)	r+rFrGrDrIrJr~rrKrrrrr�,s
r�c@s,eZdZdZdZedd��Zedd��ZdS)�	LocalPartz
local-partFcCs&|djdkr|djS|djSdS)Nrrc)rDrjrr&rrrr[s
zLocalPart.valuecCs�tg}t}d}|dtgD]�}|jdkr,q|r\|jdkr\|djdkr\t|dd��|d<t|t�}|r�|jdkr�|djdkr�|�t|dd���n
|�|�|d}|}qt|dd��}|jS)NFrrY�dotr�r�)�DOTrDr�
isinstancerhr)rriZlastZ
last_is_tl�tokZis_tlrrrr�bs(
�
�
zLocalPart.local_partN)r+rFrGrDr1rJrr�rrrrr�Vs
r�cs4eZdZdZdZe�fdd��Zedd��Z�ZS)�
DomainLiteralzdomain-literalFcsd�t�j���Sr�r�r&rrrr�szDomainLiteral.domaincCs"|D]}|jdkr|jSqdS)N�ptextrfrgrrr�ip�s
zDomainLiteral.ip)	r+rFrGrDr1rJr�r�rKrrrrr�zsr�c@seZdZdZdZdZdS)�MIMEVersionzmime-versionN)r+rFrGrD�major�minorrrrrr��sr�c@s4eZdZdZdZdZdZedd��Zedd��Z	dS)	�	Parameter�	parameterF�us-asciicCs|jr|djSdSr�)�	sectioned�numberr&rrr�section_number�szParameter.section_numbercCsf|D]\}|jdkr|jS|jdkr|D]4}|jdkr*|D] }|jdkr<|jSq<q*qdS)Nrrcrer)rDrlrkrrr�param_value�s




zParameter.param_valueN)
r+rFrGrDr��extendedr`rJr�r�rrrrr��s
r�c@seZdZdZdS)�InvalidParameter�invalid-parameterNrTrrrrr��sr�c@seZdZdZedd��ZdS)�	Attribute�	attributecCs$|D]}|j�d�r|jSqdS)N�attrtext)rD�endswithrrkrrrrl�szAttribute.stripped_valueN�r+rFrGrDrJrlrrrrr��sr�c@seZdZdZdZdS)�Section�sectionN)r+rFrGrDr�rrrrr��sr�c@seZdZdZedd��ZdS)�ValuercCs2|d}|jdkr|d}|j�d�r,|jS|jS)NrrYr�)rcr�zextended-attribute)rDr�rlrrkrrrrl�s
�zValue.stripped_valueNr�rrrrr��sr�c@s(eZdZdZdZedd��Zdd�ZdS)�MimeParameters�mime-parametersFc
cs�i}|D]T}|j�d�sq|djdkr*q|dj��}||krHg||<||�|j|f�q|��D�]~\}}t|td�d�}|dd}|j	}|j
s�t|�dkr�|dddkr�|ddj�t
�d��|dd�}g}d}|D]�\}	}
|	|k�r(|
j
�s|
j�t
�d��q�n|
j�t
�d��|d7}|
j}|
j
�r�ztj�|�}Wn&tk
�rttjj|d	d
�}YnRXz|�|d�}Wn"tk
�r�|�dd�}YnXt�|��r�|
j�t
���|�|�q�d
�|�}||fVqfdS)Nr�rr�)�keyr�z.duplicate parameter name; duplicate(s) ignoredz+duplicate parameter name; duplicate ignoredz(inconsistent RFC2231 parameter numberingzlatin-1)�encoding�surrogateescaper�r)rDr�r�striprhr��items�sortedrr`r�r�rr�InvalidHeaderDefectr��urllib�parseZunquote_to_bytes�UnicodeEncodeErrorZunquote�decode�LookupErrorr�_has_surrogates�UndecodableBytesDefectr%)r�paramsr6�name�partsZfirst_paramr`Zvalue_parts�ir��paramrrrrr��s`�

�
�
zMimeParameters.paramscCsTg}|jD].\}}|r.|�d�|t|���q
|�|�q
d�|�}|rPd|SdS)N�{}={}z; rNr)r�rhr*rr%)rr�r�rrrrr's
zMimeParameters.__str__N)r+rFrGrDrHrJr�r'rrrrr��s

Er�c@seZdZdZedd��ZdS)�ParameterizedHeaderValueFcCs&t|�D]}|jdkr|jSqiS)Nr�)�reversedrDr�rkrrrr�-s
zParameterizedHeaderValue.paramsN)r+rFrGrHrJr�rrrrr�'sr�c@seZdZdZdZdZdZdS)�ContentTypezcontent-typeF�textZplainN)r+rFrGrDr1�maintype�subtyperrrrr�5sr�c@seZdZdZdZdZdS)�ContentDispositionzcontent-dispositionFN)r+rFrGrDr1�content_dispositionrrrrr�<sr�c@seZdZdZdZdZdS)�ContentTransferEncodingzcontent-transfer-encodingFZ7bitN)r+rFrGrDr1r_rrrrr�Bsr�c@seZdZdZdZdS)�HeaderLabelzheader-labelFNr�rrrrr�Hsr�c@seZdZdZdZdd�ZdS)�MsgIDzmsg-idFcCst|�|jSr)r
�linesepr:rrrr;Qsz
MsgID.foldN)r+rFrGrDr1r;rrrrr�Msr�c@seZdZdZdS)�	MessageIDz
message-idNrTrrrrr�Vsr�c@seZdZdZdS)�InvalidMessageIDzinvalid-message-idNrTrrrrr�Zsr�c@seZdZdZdS)�Header�headerNrTrrrrr�^sr�csreZdZdZdZdZ�fdd�Z�fdd�Zdd�Ze	dd	��Z
d�fdd�	Zd
d�Ze	dd��Z
dd�Z�ZS)�TerminalTcst��||�}||_g|_|Sr)r�__new__rDr)�clsrrDrrrrr�lszTerminal.__new__csd�|jjt����Sr(r)r&rrrr,rszTerminal.__repr__cCst|jjd|j�dS)N�/)r>rr+rDr&rrrrAuszTerminal.pprintcCs
t|j�Sr)�listrr&rrrr-xszTerminal.all_defectsrc	s2d�||jj|jt���|js"dn
d�|j��gS)Nz
{}{}/{}({}){}rz {})r*rr+rDrr,rr@rrrrC|s�zTerminal._ppcCsdSrrr&rrr�pop_trailing_ws�szTerminal.pop_trailing_wscCsgSrrr&rrrr5�szTerminal.commentscCst|�|jfSr)r
rDr&rrr�__getnewargs__�szTerminal.__getnewargs__)r)r+rFrGr1rIrHr�r,rArJr-rCr�r5rrKrrrrr�fs
	
r�c@s eZdZedd��Zdd�ZdS)�WhiteSpaceTerminalcCsdSrMrr&rrrr�szWhiteSpaceTerminal.valuecCsdS)NTrr&rrrr0�sz!WhiteSpaceTerminal.startswith_fwsN�r+rFrGrJrr0rrrrr�s
rc@s eZdZedd��Zdd�ZdS)�
ValueTerminalcCs|Srrr&rrrr�szValueTerminal.valuecCsdS)NFrr&rrrr0�szValueTerminal.startswith_fwsNrrrrrr�s
rc@s eZdZedd��Zdd�ZdS)�EWWhiteSpaceTerminalcCsdSr�rr&rrrr�szEWWhiteSpaceTerminal.valuecCsdSr�rr&rrrr'�szEWWhiteSpaceTerminal.__str__N)r+rFrGrJrr'rrrrr�s
rc@seZdZdZdS)�_InvalidEwErrorz1Invalid encoded word found while parsing headers.N)r+rFrG�__doc__rrrrr�srr��,�list-separatorr�zroute-component-markerz([{}]+)rz[^{}]+z[\x00-\x20\x7F]cCs>t|�}|r|j�t�|��t�|�r:|j�t�d��dS)z@If input token contains ASCII non-printables, register a defect.z*Non-ASCII characters found in header tokenN)�_non_printable_finderrrhrZNonPrintableDefectrr�r�)�xtextZnon_printablesrrr�_validate_xtext�s

�rcCs�t|d�^}}g}d}d}tt|��D]L}||dkrJ|rDd}d}nd}q&|rTd}n|||krdq||�||�q&|d}d�|�d�||d�g|�|fS)akScan printables/quoted-pairs until endchars and return unquoted ptext.

    This function turns a run of qcontent, ccontent-without-comments, or
    dtext-with-quoted-printables into a single string by unquoting any
    quoted printables.  It returns the string, the remaining value, and
    a flag that is True iff there were any quoted printables decoded.

    r�FrTrN)�
_wsp_splitter�ranger�rhr%)r�endcharsZfragment�	remainderZvchars�escape�had_qp�posrrr�_get_ptext_to_endchars�s$	rcCs.|��}t|dt|�t|��d�}||fS)z�FWS = 1*WSP

    This isn't the RFC definition.  We're using fws to represent tokens where
    folding can be done, but when we are parsing the *un*folding has already
    been done so we don't need to watch out for CRLF.

    N�fws)r�rr�)rZnewvaluerrrr�get_fwssrc
	Cs�t�}|�d�s t�d�|���|dd��dd�^}}||dd�krXt�d�|���d�|�}t|�dkr�|dtkr�|dtkr�|�	d	�dkr�|�dd�^}}|d|}t|���dkr�|j
�t�d
��||_
d�|�}zt�d|d�\}}}}	Wn*ttfk
�r*td�|j
���YnX||_||_|j
�|	�|�r�|dtk�rrt|�\}
}|�|
��qDt|d�^}}t|d�}t|�|�|�d�|�}�qD|�r�|dtk�r�|j
�t�d
��||fS)zE encoded-word = "=?" charset "?" encoding "?" encoded-text "?="

    �=?z"expected encoded word but found {}r�Nz?=r�rr�?zwhitespace inside encoded wordz!encoded word format invalid: '{}'�vtextz.missing trailing whitespace after encoded-word)r]�
startswithr�HeaderParseErrorr*r�r%r�r�countrrhr�r_�_ewr��
ValueError�KeyErrorrr`rar4�WSPrrrr)
rZewr�rZremstr�restr�r`rarr6�charsrrrr�get_encoded_wordsd
��

�
��
�

�




�r"cCsFt�}|�rB|dtkr0t|�\}}|�|�qd}|�d�r�zt|�\}}Wn,tk
rfd}Yn�tjk
rzYnrXd}t	|�dkr�|dj
dkr�|j�t�d��d}|r�t	|�dkr�|d	j
d
kr�t
|dd�|d<|�|�qt|d�^}}|�rt�|��r|�d�^}}t|d�}t|�|�|�d�|�}q|S)
aOunstructured = (*([FWS] vchar) *WSP) / obs-unstruct
       obs-unstruct = *((*LF *CR *(obs-utext) *LF *CR)) / FWS)
       obs-utext = %d0 / obs-NO-WS-CTL / LF / CR

       obs-NO-WS-CTL is control characters except WSP/CR/LF.

    So, basically, we have printable runs, plus control characters or nulls in
    the obsolete syntax, separated by whitespace.  Since RFC 2047 uses the
    obsolete syntax in its specification, but requires whitespace on either
    side of the encoded words, I can see no reason to need to separate the
    non-printable-non-whitespace from the printable runs if they occur, so we
    parse this into xtext tokens separated by WSP tokens.

    Because an 'unstructured' value must by definition constitute the entire
    value, this 'get' routine does not return a remaining value, only the
    parsed TokenList.

    rTrFr�rz&missing whitespace before encoded wordr����r^rr)rRrrrhrr"rrrr�rDrr�rr�rfc2047_matcher�search�	partitionrrr%)rrSr6�valid_ewZhave_wsr�rrrrr�get_unstructured?sJ


��


r(cCs*t|d�\}}}t|d�}t|�||fS)actext = <printable ascii except \ ( )>

    This is not the RFC ctext, since we are handling nested comments in comment
    and unquoting quoted-pairs here.  We allow anything except the '()'
    characters, but if we find any ASCII other than the RFC defined printable
    ASCII, a NonPrintableDefect is added to the token's defects list.  Since
    quoted pairs are converted to their unquoted values, what is returned is
    a 'ptext' token.  In this case it is a WhiteSpaceTerminal, so it's value
    is ' '.

    z()r�)rrr�rr��_rrr�get_qp_ctext�s
r+cCs*t|d�\}}}t|d�}t|�||fS)aoqcontent = qtext / quoted-pair

    We allow anything except the DQUOTE character, but if we find any ASCII
    other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Any quoted pairs are converted to their
    unquoted values, so what is returned is a 'ptext' token.  In this case it
    is a ValueTerminal.

    r
r�)rrrr)rrr�get_qcontent�s

r,cCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)z�atext = <matches _atext_matcher>

    We allow any non-ATOM_ENDS in atext, but add an InvalidATextDefect to
    the token's defects list if we find non-atext characters.
    zexpected atext but found '{}'N�atext)�_non_atom_end_matcherrrr*r|r�rr)r�mr-rrr�	get_atext�s�
r0cCsr|ddkrt�d�|���t�}|dd�}|rT|ddkrTt|�\}}|�|�|�rB|ddk�rB|dtkr�t|�\}}n�|dd�dk�r*d}z&t|�\}}|j	�t�
d	��d
}Wn"tjk
r�t|�\}}YnX|�r6t|�dk�r6|djdk�r6|d
jdk�r6t
|dd�|d<nt|�\}}|�|�qT|�sb|j	�t�
d��||fS||dd�fS)z�bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE

    A quoted-string without the leading or trailing white space.  Its
    value is the text between the quote marks, with whitespace
    preserved and quoted pairs decoded.
    rr
zexpected '"' but found '{}'r�Nr�rFz!encoded word inside quoted stringTr�rr#r^z"end of header inside quoted string)rrr*rmr,rhrrr"rr�r�rDr)rZbare_quoted_stringr6r'rrr�get_bare_quoted_string�sL�

���

�r1cCs�|r |ddkr t�d�|���t�}|dd�}|r�|ddkr�|dtkr\t|�\}}n&|ddkrvt|�\}}nt|�\}}|�|�q2|s�|j	�t�
d��||fS||dd�fS)z�comment = "(" *([FWS] ccontent) [FWS] ")"
       ccontent = ctext / quoted-pair / comment

    We handle nested comments here, and quoted-pair in our qp-ctext routine.
    rrzexpected '(' but found '{}'r�Nrpzend of header inside comment)rrr*rnrr�get_commentr+rhrr�)rrOr6rrrr2�s&�
�r2cCsPt�}|rH|dtkrH|dtkr0t|�\}}nt|�\}}|�|�q||fS)z,CFWS = (1*([FWS] comment) [FWS]) / FWS

    r)rX�CFWS_LEADERrrr2rh)rrYr6rrr�get_cfws�sr4cCspt�}|r,|dtkr,t|�\}}|�|�t|�\}}|�|�|rh|dtkrht|�\}}|�|�||fS)z�quoted-string = [CFWS] <bare-quoted-string> [CFWS]

    'bare-quoted-string' is an intermediate class defined by this
    parser and not by the RFC grammar.  It is the quoted string
    without any attached CFWS.
    r)rbr3r4rhr1)rZ
quoted_stringr6rrr�get_quoted_strings


r5cCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���|�d�r�zt	|�\}}Wq�tjk
r�t
|�\}}Yq�Xnt
|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)zPatom = [CFWS] 1*atext [CFWS]

    An atom could be an rfc2047 encoded word.
    rzexpected atom but found '{}'r)rZr3r4rh�	ATOM_ENDSrrr*rr"r0)rr[r6rrr�get_atoms&
�


r7cCs�t�}|r|dtkr&t�d�|���|rt|dtkrtt|�\}}|�|�|r&|ddkr&|�t�|dd�}q&|dtkr�t�d�d|���||fS)z( dot-text = 1*atext *("." 1*atext)

    rz8expected atom at a start of dot-atom-text but found '{}'rr�Nr�z4expected atom at end of dot-atom-text but found '{}')r�r6rrr*r0rhr�)rZ
dot_atom_textr6rrr�get_dot_atom_text0s �

�r8cCs�t�}|dtkr(t|�\}}|�|�|�d�rhzt|�\}}Wqttjk
rdt|�\}}YqtXnt|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)z� dot-atom = [CFWS] dot-atom-text [CFWS]

    Any place we can have a dot atom, we could instead have an rfc2047 encoded
    word.
    rr)	r�r3r4rhrr"rrr8)rZdot_atomr6rrr�get_dot_atomCs



r9cCs�|dtkrt|�\}}nd}|s,t�d��|ddkrFt|�\}}n*|dtkrdt�d�|���nt|�\}}|dk	r�|g|dd�<||fS)a�word = atom / quoted-string

    Either atom or quoted-string may start with CFWS.  We have to peel off this
    CFWS first to determine which type of word to parse.  Afterward we splice
    the leading CFWS, if any, into the parsed sub-token.

    If neither an atom or a quoted-string is found before the next special, a
    HeaderParseError is raised.

    The token returned is either an Atom or a QuotedString, as appropriate.
    This means the 'word' level of the formal grammar is not represented in the
    parse tree; this is because having that extra layer when manipulating the
    parse tree is more confusing than it is helpful.

    rNz5Expected 'atom' or 'quoted-string' but found nothing.r
z1Expected 'atom' or 'quoted-string' but found '{}')r3r4rrr5�SPECIALSr*r7)r�leaderr6rrr�get_word\s"��r<cCs�t�}zt|�\}}|�|�Wn(tjk
rH|j�t�d��YnX|r�|dtkr�|ddkr�|�t�|j�t�	d��|dd�}qJzt|�\}}WnDtjk
r�|dt
kr�t|�\}}|j�t�	d��n�YnX|�|�qJ||fS)a� phrase = 1*word / obs-phrase
        obs-phrase = word *(word / "." / CFWS)

    This means a phrase can be a sequence of words, periods, and CFWS in any
    order as long as it starts with at least one word.  If anything other than
    words is detected, an ObsoleteHeaderDefect is added to the token's defect
    list.  We also accept a phrase that starts with CFWS followed by a dot;
    this is registered as an InvalidHeaderDefect, since it is not supported by
    even the obsolete grammar.

    zphrase does not start with wordrrzperiod in 'phrase'r�Nzcomment found without atom)rUr<rhrrrr��PHRASE_ENDSr��ObsoleteHeaderDefectr3r4)rrVr6rrr�
get_phrase~s4
�

�
�r?cCsvt�}d}|dtkr"t|�\}}|s6t�d�|���zt|�\}}Wn^tjk
r�zt|�\}}Wn6tjk
r�|ddkr�|dtkr��t	�}YnXYnX|dk	r�|g|dd�<|�
|�|�r4|ddks�|dtk�r4tt|�|�\}}|j
dk�r|j�
t�d��n|j�
t�d��||d<z|j�d�Wn(tk
�rl|j�
t�d	��YnX||fS)
z= local-part = dot-atom / quoted-string / obs-local-part

    Nrz"expected local-part but found '{}'r�invalid-obs-local-partz<local-part is not dot-atom, quoted-string, or obs-local-partz,local-part is not a dot-atom (contains CFWS)�asciiz)local-part contains non-ASCII characters))r�r3r4rrr*r9r<r=rrh�get_obs_local_partr
rDrr�r>r�encoder�ZNonASCIILocalPartDefect)rr�r;r6�obs_local_partrrr�get_local_part�sJ�
 
�
�
�rEcCs�t�}d}|�r(|ddks*|dtk�r(|ddkrj|rL|j�t�d��|�t�d}|dd�}q
nD|ddkr�|�t|dd	��|dd�}|j�t�d
��d}q
|r�|djdkr�|j�t�d
��zt	|�\}}d}Wn4tj
k
�r|dtk�r
�t|�\}}YnX|�|�q
|djdk�sX|djdk�rj|djdk�rj|j�t�d��|djdk�s�|djdk�r�|djdk�r�|j�t�d��|j�r�d|_||fS)z' obs-local-part = word *("." word)
    Frrrzinvalid repeated '.'Tr�N�misplaced-specialz/'\' character outside of quoted-string/ccontentr�r�zmissing '.' between wordsrYz!Invalid leading '.' in local partr#z"Invalid trailing '.' in local partr@)
r�r=rrhrr�r�rrDr<rr3r4)rrDZlast_non_ws_was_dotr6rrrrB�sj 
�
�
�
���
���
�rBcCs@t|d�\}}}t|d�}|r0|j�t�d��t|�||fS)a dtext = <printable ascii except \ [ ]> / obs-dtext
        obs-dtext = obs-NO-WS-CTL / quoted-pair

    We allow anything except the excluded characters, but if we find any
    ASCII other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Quoted pairs are converted to their
    unquoted values, so what is returned is a ptext token, in this case a
    ValueTerminal.  If there were quoted-printables, an ObsoleteHeaderDefect is
    added to the returned token's defect list.

    z[]r�z(quoted printable found in domain-literal)rrrrhrr>r)rr�rrrr�	get_dtext�s

�rGcCs,|rdS|�t�d��|�tdd��dS)NFz"end of input inside domain-literal�]�domain-literal-endT)rhrr�r)r�domain_literalrrr�_check_for_early_dl_ends�rKcCsjt�}|dtkr(t|�\}}|�|�|s6t�d��|ddkrRt�d�|���|dd�}t||�rp||fS|�tdd��|dt	kr�t
|�\}}|�|�t|�\}}|�|�t||�r�||fS|dt	kr�t
|�\}}|�|�t||�r�||fS|ddk�rt�d	�|���|�tdd
��|dd�}|�rb|dtk�rbt|�\}}|�|�||fS)zB domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]

    rzexpected domain-literal�[z6expected '[' at start of domain-literal but found '{}'r�Nzdomain-literal-startrHz4expected ']' at end of domain-literal but found '{}'rI)r�r3r4rhrrr*rKrrrrG)rrJr6rrr�get_domain_literalsH

�





�
rMcCsrt�}d}|dtkr"t|�\}}|s6t�d�|���|ddkrvt|�\}}|dk	rd|g|dd�<|�|�||fSzt|�\}}Wn"tjk
r�t	|�\}}YnX|r�|ddkr�t�d��|dk	r�|g|dd�<|�|�|�rj|ddk�rj|j
�t�d��|djd	k�r*|d|dd�<|�rj|ddk�rj|�t
�t	|d
d��\}}|�|��q*||fS)z] domain = dot-atom / domain-literal / obs-domain
        obs-domain = atom *("." atom))

    Nrzexpected domain but found '{}'rLr�zInvalid Domainrz(domain is not a dot-atom (contains CFWS)r�r�)r�r3r4rrr*rMrhr9r7rr>rDr�)rr�r;r6rrr�
get_domain=sD�



�
rNcCs|t�}t|�\}}|�|�|r,|ddkrF|j�t�d��||fS|�tdd��t|dd��\}}|�|�||fS)z( addr-spec = local-part "@" domain

    rr�z#addr-spec local part with no domain�address-at-symbolr�N)r�rErhrrr�rrN)rr�r6rrr�
get_addr_speccs

�
rPcCs�t�}|rj|ddks"|dtkrj|dtkrFt|�\}}|�|�q|ddkr|�t�|dd�}q|rz|ddkr�t�d�|���|�t�t	|dd��\}}|�|�|�r>|ddk�r>|�t�|dd�}|s�q>|dtk�rt|�\}}|�|�|ddkr�|�t�t	|dd��\}}|�|�q�|�sNt�d��|ddk�rlt�d	�|���|�t
dd
��||dd�fS)z� obs-route = obs-domain-list ":"
        obs-domain-list = *(CFWS / ",") "@" domain *("," [CFWS] ["@" domain])

        Returns an obs-route token with the appropriate sub-tokens (that is,
        there is no obs-domain-list in the parse tree).
    rrr�Nr�z(expected obs-route domain but found '{}'z%end of header while parsing obs-route�:z4expected ':' marking end of obs-route but found '{}'zend-of-obs-route-marker)r�r3r4rh�
ListSeparatorrrr*�RouteComponentMarkerrNr)rZ	obs_router6rrr�
get_obs_routessF
�





�rTcCs�t�}|dtkr(t|�\}}|�|�|r8|ddkrHt�d�|���|�tdd��|dd�}|ddkr�|�tdd��|j�t�	d	��|dd�}||fSzt
|�\}}Wnztjk
�r0z"t|�\}}|j�t�d
��Wn(tjk
�rt�d�|���YnX|�|�t
|�\}}YnX|�|�|�r^|ddk�r^|dd�}n|j�t�	d��|�tdd��|�r�|dtk�r�t|�\}}|�|�||fS)
z� angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
        obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS]

    r�<z"expected angle-addr but found '{}'zangle-addr-startr�N�>zangle-addr-endznull addr-spec in angle-addrz*obsolete route specification in angle-addrz.expected addr-spec or obs-route but found '{}'z"missing trailing '>' on angle-addr)
r�r3r4rhrrr*rrr�rPrTr>)rZ
angle_addrr6rrr�get_angle_addr�sT
�
�
�
�



�
rWcCs<t�}t|�\}}|�|dd��|jdd�|_||fS)z� display-name = phrase

    Because this is simply a name-rule, we don't return a display-name
    token containing a phrase, but rather a display-name token with
    the content of the phrase.

    N)r�r?r4r)rr~r6rrr�get_display_name�s
rXcCs�t�}d}|dtkr6t|�\}}|s6t�d�|���|ddkr�|dtkr^t�d�|���t|�\}}|s~t�d�|���|dk	r�|g|ddd�<d}|�|�t	|�\}}|dk	r�|g|dd�<|�|�||fS)z, name-addr = [display-name] angle-addr

    Nrz!expected name-addr but found '{}'rU)
r�r3r4rrr*r=rXrhrW)rZ	name_addrr;r6rrr�
get_name_addr�s6���

rYcCs�t�}zt|�\}}WnNtjk
rdzt|�\}}Wn&tjk
r^t�d�|���YnXYnXtdd�|jD��r�d|_|�	|�||fS)z& mailbox = name-addr / addr-spec

    zexpected mailbox but found '{}'css|]}t|tj�VqdSr)r�rr�r rrrr#s�zget_mailbox.<locals>.<genexpr>r�)
r�rYrrrPr*�anyr-rDrh)rr�r6rrr�get_mailbox�s ��
r[cCsdt�}|r\|d|kr\|dtkrD|�t|dd��|dd�}qt|�\}}|�|�q||fS)z� Read everything up to one of the chars in endchars.

    This is outside the formal grammar.  The InvalidMailbox TokenList that is
    returned acts like a Mailbox, but the data attributes are None.

    rrFr�N)r�r=rhrr?)rrZinvalid_mailboxr6rrr�get_invalid_mailboxs�r\cCs�t�}|�r�|ddk�r�zt|�\}}|�|�W�ntjk
�r<d}|dtkr�t|�\}}|rv|ddkr�|�|�|j�t�d��n@t	|d�\}}|dk	r�|g|dd�<|�|�|j�t�
d��nb|ddkr�|j�t�d��nBt	|d�\}}|dk	�r|g|dd�<|�|�|j�t�
d��YnX|�r�|ddk�r�|d}d	|_t	|d�\}}|�|�|j�t�
d��|r|ddkr|�t
�|d
d�}q||fS)aJ mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
        obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])

    For this routine we go outside the formal grammar in order to improve error
    handling.  We recognize the end of the mailbox list only at the end of the
    value or at a ';' (the group terminator).  This is so that we can turn
    invalid mailboxes into InvalidMailbox tokens and continue parsing any
    remaining valid mailboxes.  We also allow all mailbox entries to be null,
    and this condition is handled appropriately at a higher level.

    r�;Nz,;zempty element in mailbox-listzinvalid mailbox in mailbox-listrr�r�r�)r�r[rhrrr3r4rr>r\r�rDr4rR)rZmailbox_listr6r;r�rrr�get_mailbox_listsX

�

�
�


�

�
r^cCst�}|s$|j�t�d��||fSd}|r�|dtkr�t|�\}}|sl|j�t�d��|�|�||fS|ddkr�|�|�||fSt|�\}}t|j	�dkr�|dk	r�|�|�|�
|�|j�t�d��||fS|dk	r�|g|dd�<|�|�||fS)zg group-list = mailbox-list / CFWS / obs-group-list
        obs-group-list = 1*([CFWS] ",") [CFWS]

    zend of header before group-listNrzend of header in group-listr]zgroup-list with empty entries)r�rrhrr�r3r4r^r�rzr4r>)rZ
group_listr;r6rrr�get_group_listWs>
�
�




�
r_cCs t�}t|�\}}|r"|ddkr2t�d�|���|�|�|�tdd��|dd�}|r�|ddkr�|�tdd��||dd�fSt|�\}}|�|�|s�|j�t�	d	��n|ddkr�t�d
�|���|�tdd��|dd�}|�r|dt
k�rt|�\}}|�|�||fS)z7 group = display-name ":" [group-list] ";" [CFWS]

    rrQz8expected ':' at end of group display name but found '{}'zgroup-display-name-terminatorr�Nr]zgroup-terminatorzend of header in groupz)expected ';' at end of group but found {})r�rXrrr*rhrr_rr�r3r4)rr|r6rrr�	get_group|s8�


��
r`cCsxt�}zt|�\}}WnNtjk
rdzt|�\}}Wn&tjk
r^t�d�|���YnXYnX|�|�||fS)a� address = mailbox / group

    Note that counter-intuitively, an address can be either a single address or
    a list of addresses (a group).  This is why the returned Address object has
    a 'mailboxes' attribute which treats a single address as a list of length
    one.  When you need to differentiate between to two cases, extract the single
    element, which is either a mailbox or a group token.

    zexpected address but found '{}')r{r`rrr[r*rh)rrrr6rrr�get_address�s�
rac
Cs�t�}|�r�zt|�\}}|�|�W�n tjk
�rH}z�d}|dtkr�t|�\}}|rj|ddkr�|�|�|j�t�d��nFt	|d�\}}|dk	r�|g|dd�<|�t
|g��|j�t�d��nh|ddkr�|j�t�d��nHt	|d�\}}|dk	�r|g|dd�<|�t
|g��|j�t�d��W5d}~XYnX|�r�|ddk�r�|dd}d|_t	|d�\}}|�
|�|j�t�d��|r|�tdd	��|d
d�}q||fS)a� address_list = (address *("," address)) / obs-addr-list
        obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])

    We depart from the formal grammar here by continuing to parse until the end
    of the input, assuming the input to be entirely composed of an
    address-list.  This is always true in email parsing, and allows us
    to skip invalid addresses to parse additional valid ones.

    Nrrz"address-list entry with no contentzinvalid address in address-listzempty element in address-listr�r�rr�)rqrarhrrr3r4rr>r\r{r�rDr4r)rZaddress_listr6�errr;r�rrr�get_address_list�sX


�
�
�

�

�rccCs�t�}|st�d�|���|ddkr6t�d�|���|�tdd��|dd�}t|�\}}|�|�|rx|ddkr�t�d	�|���|�tdd
��||dd�fS)z& no-fold-literal = "[" *dtext "]"
    z'expected no-fold-literal but found '{}'rrLz;expected '[' at the start of no-fold-literal but found '{}'zno-fold-literal-startr�NrHz9expected ']' at the end of no-fold-literal but found '{}'zno-fold-literal-end)r�rrr*rhrrG)rZno_fold_literalr6rrr�get_no_fold_literal�s.���
��rdcCs�t�}|r,|dtkr,t|�\}}|�|�|r<|ddkrLt�d�|���|�tdd��|dd�}zt|�\}}Wn`tjk
r�z"t	|�\}}|j
�t�d��Wn&tjk
r�t�d�|���YnXYnX|�|�|r�|dd	k�r@|j
�t�d
��|�r8|ddk�r8|�tdd��|dd�}||fS|�td	d
��|dd�}zt|�\}}Wn�tjk
�rzt
|�\}}Wnrtjk
�r}zPz"t|�\}}|j
�t�d��Wn(tjk
�r�t�d�|���YnXW5d}~XYnXYnX|�|�|�r6|ddk�r6|dd�}n|j
�t�d��|�tdd��|�r�|dtk�r�t|�\}}|�|�||fS)z�msg-id = [CFWS] "<" id-left '@' id-right  ">" [CFWS]
       id-left = dot-atom-text / obs-id-left
       id-right = dot-atom-text / no-fold-literal / obs-id-right
       no-fold-literal = "[" *dtext "]"
    rrUzexpected msg-id but found '{}'zmsg-id-startr�Nzobsolete id-left in msg-idz4expected dot-atom-text or obs-id-left but found '{}'r�zmsg-id with no id-rightrVz
msg-id-endrOzobsolete id-right in msg-idzFexpected dot-atom-text, no-fold-literal or obs-id-right but found '{}'zmissing trailing '>' on msg-id)r�r3r4rhrrr*rr8rBrr>r�rdrN)rZmsg_idr6�errr�
get_msg_ids~
�
�
��

�
�
��"

�
rfc
Cs�t�}zt|�\}}|�|�WnLtjk
rl}z,t|�}t|�}|j�t�d�	|���W5d}~XYnX|r�|j�t�d�	|���|S)z2message-id      =   "Message-ID:" msg-id CRLF
    zInvalid msg-id: {!r}NzUnexpected {!r})
r�rfrhrrr(r�rr�r*)rZ
message_idr6Zexrrr�parse_message_idIs�
�rgcCs�t�}|s |j�t�d��|S|dtkrXt|�\}}|�|�|sX|j�t�d��d}|r�|ddkr�|dtkr�||d7}|dd�}q\|��s�|j�t�d�	|���|�t
|d	��nt|�|_|�t
|d
��|�r|dtk�rt|�\}}|�|�|�r|ddk�rT|jdk	�r:|j�t�d��|�rP|�t
|d	��|S|�t
dd��|dd�}|�r�|dtk�r�t|�\}}|�|�|�s�|jdk	�r�|j�t�d��|Sd}|�r�|dtk�r�||d7}|dd�}�q�|���s*|j�t�d
�	|���|�t
|d	��nt|�|_
|�t
|d
��|�rn|dtk�rnt|�\}}|�|�|�r�|j�t�d��|�t
|d	��|S)zE mime-version = [CFWS] 1*digit [CFWS] "." [CFWS] 1*digit [CFWS]

    z%Missing MIME version number (eg: 1.0)rz0Expected MIME version number but found only CFWSrrr�Nz1Expected MIME major version number but found {!r}r
�digitsz0Incomplete MIME version; found only major numberzversion-separatorz1Expected MIME minor version number but found {!r}z'Excess non-CFWS text after MIME version)r�rrhr�HeaderMissingRequiredValuer3r4�isdigitr�r*r�intr�r�)rZmime_versionr6rhrrr�parse_mime_versiones�
�

�
�


�

�

�


�rlcCsdt�}|r\|ddkr\|dtkrD|�t|dd��|dd�}qt|�\}}|�|�q||fS)z� Read everything up to the next ';'.

    This is outside the formal grammar.  The InvalidParameter TokenList that is
    returned acts like a Parameter, but the data attributes are None.

    rr]rFr�N)r�r=rhrr?)rZinvalid_parameterr6rrr�get_invalid_parameter�s�rmcCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)a8ttext = <matches _ttext_matcher>

    We allow any non-TOKEN_ENDS in ttext, but add defects to the token's
    defects list if we find non-ttext characters.  We also register defects for
    *any* non-printables even though the RFC doesn't exclude all of them,
    because we follow the spirit of RFC 5322.

    zexpected ttext but found '{}'N�ttext)�_non_token_end_matcherrrr*r|r�rr)rr/rnrrr�	get_ttext�s	�
rpcCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)z�token = [CFWS] 1*ttext [CFWS]

    The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or
    tspecials.  We also exclude tabs even though the RFC doesn't.

    The RFC implies the CFWS but is not explicit about it in the BNF.

    r�expected token but found '{}')	r\r3r4rh�
TOKEN_ENDSrrr*rp)rZmtokenr6rrr�	get_token�s	
�

rscCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)aQattrtext = 1*(any non-ATTRIBUTE_ENDS character)

    We allow any non-ATTRIBUTE_ENDS in attrtext, but add defects to the
    token's defects list if we find non-attrtext characters.  We also register
    defects for *any* non-printables even though the RFC doesn't exclude all of
    them, because we follow the spirit of RFC 5322.

    z expected attrtext but found {!r}Nr�)�_non_attribute_end_matcherrrr*r|r�rr�rr/r�rrr�get_attrtext�s	�
rvcCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)aH [CFWS] 1*attrtext [CFWS]

    This version of the BNF makes the CFWS explicit, and as usual we use a
    value terminal for the actual run of characters.  The RFC equivalent of
    attrtext is the token characters, with the subtraction of '*', "'", and '%'.
    We include tab in the excluded set just as we do for token.

    rrq)	r�r3r4rh�ATTRIBUTE_ENDSrrr*rv�rr�r6rrr�
get_attribute�s	
�

rycCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)z�attrtext = 1*(any non-ATTRIBUTE_ENDS character plus '%')

    This is a special parsing routine so that we get a value that
    includes % escapes as a single string (which we decode as a single
    string later).

    z)expected extended attrtext but found {!r}N�extended-attrtext)�#_non_extended_attribute_end_matcherrrr*r|r�rrrurrr�get_extended_attrtext	s�
r|cCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)z� [CFWS] 1*extended_attrtext [CFWS]

    This is like the non-extended version except we allow % characters, so that
    we can pick up an encoded value as a single string.

    rrq)	r�r3r4rh�EXTENDED_ATTRIBUTE_ENDSrrr*r|rxrrr�get_extended_attribute!	s
�

r~cCs�t�}|r|ddkr&t�d�|���|�tdd��|dd�}|rR|d��sbt�d�|���d}|r�|d��r�||d7}|dd�}qf|dd	kr�|d	kr�|j�t�d
��t	|�|_
|�t|d��||fS)a6 '*' digits

    The formal BNF is more complicated because leading 0s are not allowed.  We
    check for that and add a defect.  We also assume no CFWS is allowed between
    the '*' and the digits, though the RFC is not crystal clear on that.
    The caller should already have dealt with leading CFWS.

    r�*zExpected section but found {}zsection-markerr�Nz$Expected section number but found {}r�0z'section number has an invalid leading 0rh)r�rrr*rhrrjrZInvalidHeaderErrorrkr�)rr�rhrrr�get_section7	s,	��
�
r�cCs�t�}|st�d��d}|dtkr0t|�\}}|sDt�d�|���|ddkr^t|�\}}nt|�\}}|dk	r�|g|dd�<|�|�||fS)z  quoted-string / attribute

    z&Expected value but found end of stringNrz Expected value but found only {}r
)	r�rrr3r4r*r5r~rh)r�vr;r6rrr�	get_valueU	s"
�
r�cCs�t�}t|�\}}|�|�|r,|ddkrL|j�t�d�|���||fS|ddkr�z t|�\}}d|_|�|�Wntj	k
r�YnX|s�t�	d��|ddkr�|�t
dd��|dd	�}d|_|dd
kr�t�	d��|�t
d
d��|dd	�}d	}|�r,|dtk�r,t
|�\}}|�|�d	}|}|j�rF|�rF|dd
k�rFt|�\}}|j}d}|jdk�r�|�r�|ddk�r�d}n$t|�\}}	|	�r�|	ddk�r�d}n(zt|�\}}	WnYnX|	�s�d}|�r0|j�t�d��|�|�|D](}
|
jdk�rg|
d	d	�<|
}�q*�q|}nd	}|j�t�d��|�r`|ddk�r`d	}nt|�\}}|j�r�|jdk�r�|�r�|ddk�r�|�|�|d	k	�r�|�r�t|��|}||fS|j�t�d��|�s
|j�t�d��|�|�|d	k�r�||fSn�|d	k	�rN|D]}
|
jdk�r�q2�q|
jdk|�|
�|
j|_|ddk�rlt�	d�|���|�t
dd��|dd	�}|�r�|ddk�r�t|�\}}|�|�|j|_|�r�|ddk�r�t�	d�|���|�t
dd��|dd	�}|d	k	�rrt�}|�rl|dtk�r,t|�\}}n2|dd
k�rRt
d
d�}|dd	�}nt|�\}}|�|��q
|}nt|�\}}|�|�|d	k	�r�|�r�t|��|}||fS)aY attribute [section] ["*"] [CFWS] "=" value

    The CFWS is implied by the RFC but not made explicit in the BNF.  This
    simplified form of the BNF from the RFC is made to conform with the RFC BNF
    through some extra checks.  We do it this way because it makes both error
    recovery and working with the resulting parse tree easier.
    rr]z)Parameter contains name ({}) but no valuerTzIncomplete parameterzextended-parameter-markerr�N�=zParameter not followed by '='�parameter-separatorr
F�'z5Quoted string value for extended parameter is invalidrezZParameter marked as extended but appears to have a quoted string value that is non-encodedzcApparent initial-extended-value but attribute was not marked as extended or was not initial sectionz(Missing required charset/lang delimitersrzr�z=Expected RFC2231 char/lang encoding delimiter, but found {!r}zRFC2231-delimiterz;Expected RFC2231 char/lang encoding delimiter, but found {}ZDQUOTE)r�ryrhrrr�r*r�r�rrr�r3r4r5rlr�rvr|rDr��AssertionErrorrr`rar�rrr,)rr�r6r;rZappendtoZqstringZinner_valueZ
semi_validr �tr�rrr�
get_parameterk	s�
�



�


�


�
�






�
�



r�c
Csjt�}|�rfzt|�\}}|�|�Wn�tjk
r�}z�d}|dtkrVt|�\}}|sp|�|�|WY�xS|ddkr�|dk	r�|�|�|j�t�d��n@t	|�\}}|r�|g|dd�<|�|�|j�t�d�
|���W5d}~XYnX|�rD|ddk�rD|d}d|_t	|�\}}|�|�|j�t�d�
|���|r|�t
dd	��|d
d�}q|S)a! parameter *( ";" parameter )

    That BNF is meant to indicate this routine should only be called after
    finding and handling the leading ';'.  There is no corresponding rule in
    the formal RFC grammar, but it is more convenient for us for the set of
    parameters to be treated as its own TokenList.

    This is 'parse' routine because it consumes the remaining value, but it
    would never be called to parse a full header.  Instead it is called to
    parse everything after the non-parameter value of a specific MIME header.

    Nrr]zparameter entry with no contentzinvalid parameter {!r}r�r�z)parameter with invalid trailing text {!r}r�r�)r�r�rhrrr3r4rr�rmr*rDr4r)rZmime_parametersr6rbr;r�rrr�parse_mime_parameters�	sJ



�

�

�r�cCs�|rV|ddkrV|dtkr>|�t|dd��|dd�}qt|�\}}|�|�q|s^dS|�tdd��|�t|dd���dS)zBDo our best to find the parameters in an invalid MIME header

    rr]rFr�Nr�)r=rhrr?r�)Z	tokenlistrr6rrr�_find_mime_parameters-
sr�c
Cs�t�}d}|s$|j�t�d��|Szt|�\}}Wn<tjk
rp|j�t�d�|���t	||�|YSX|�|�|r�|ddkr�|j�t�d��|r�t	||�|S|j
����|_
|�tdd��|dd	�}zt|�\}}Wn>tjk
�r*|j�t�d
�|���t	||�|YSX|�|�|j
����|_|�sP|S|ddk�r�|j�t�d�|���|`
|`t	||�|S|�tdd
��|�t|dd	���|S)z� maintype "/" subtype *( ";" parameter )

    The maintype and substype are tokens.  Theoretically they could
    be checked against the official IANA list + x-token, but we
    don't do that.
    Fz"Missing content type specificationz(Expected content maintype but found {!r}rr�zInvalid content typezcontent-type-separatorr�Nz'Expected content subtype but found {!r}r]z<Only parameters are valid after content type, but found {!r}r�)r�rrhrrirsrr�r*r�rr��lowerr�rr�r�)rZctypeZrecoverr6rrr�parse_content_type_header=
sd
�
�



�

�



��
r�c
Cs�t�}|s |j�t�d��|Szt|�\}}Wn<tjk
rl|j�t�d�|���t	||�|YSX|�|�|j
����|_
|s�|S|ddkr�|j�t�d�|���t	||�|S|�tdd��|�t|dd���|S)	z* disposition-type *( ";" parameter )

    zMissing content dispositionz+Expected content disposition but found {!r}rr]zCOnly parameters are valid after content disposition, but found {!r}r�r�N)r�rrhrrirsrr�r*r�rr�r�r�rr�)rZdisp_headerr6rrr� parse_content_disposition_headerv
s:
�
�



��
r�c
Cs�t�}|s |j�t�d��|Szt|�\}}Wn.tjk
r^|j�t�d�|���YnX|�|�|j	�
���|_|s�|S|r�|j�t�d��|dt
kr�|�t|dd��|dd�}q�t|�\}}|�|�q�|S)z mechanism

    z!Missing content transfer encodingz1Expected content transfer encoding but found {!r}z*Extra text after content transfer encodingrrFr�N)r�rrhrrirsrr�r*rr�r�r_r=rr?)rZ
cte_headerr6rrr�&parse_content_transfer_encoding_header�
s4
�
�

�r�cCsDd}|r@|dr@|ddtkr@|dd}|ddd�|d<|S)Nrr�)r)�linesZwsprrr�_steal_trailing_WSP_if_exists�
s
r�cCs�|jp
tj}|jrdnd}dg}d}d}d}tdd�}t|�}	|	�r�|	�d�}
|
|kr`|d8}q>t|
�}|
jd	kr�t	|�t
@r�d
}z|�|�|}Wn6tk
r�t
dd�|
jD��r�d
}nd}d
}YnX|
jdkr�t|
|||�q>|�r�|�s�|
j�spd}d}|
j�rp|
j|d�dt|j��}
|j|
k�rpt|
�|t|d�k�r^t|�}|�|�|d|
7<q>t|
d��s�t|
�|	}	nt|||||
j|�}d}q>t|�|t|d�k�r�|d|7<q>|
j�rt|�d|k�rt|�}|�s|
���r|�||�d}q>t|
d��sNt|
�}|
j�sD|d7}|�|�||	}	q>|
j�rn|�sn|	�d|
�d
}q>t|�}|�s�|
���r�|�||�q>|d|7<q>|j�|�|jS)zLReturn string of contents of parse_tree folded according to RFC rules.

    �utf-8r�rNrF�wrap_as_ew_blockedr�r�Tcss|]}t|tj�VqdSr)r�rr�r rrrr#�
s�z%_refold_parse_tree.<locals>.<genexpr>�unknown-8bitr�r7r�rC)Zmax_line_length�sys�maxsize�utf8r�r�r�r
rDr�r:rCr�rZr-�_fold_mime_parametersr1rHr;r�r�r�rhrE�_fold_as_ewrIr0�insertr%)Z
parse_treer8�maxlenr�r��last_ewr�Z
want_encodingZend_ew_not_allowedr�r2�tstrr`Zencoded_part�newlineZnewpartsrrrr9�
s�


�



��
r9cCs�|dk	r<|r<tt|d|d�|��}|dd|�|d<|dtkr�|d}|dd�}t|d�|krz|�t|��|d|7<d}|dtkr�|d}|dd�}|dkr�t|d�n|}|dkr�dn|}	t|	�d}
|
d|kr�t�d	��|�r�|t|d�}||
}|dk�r,|�d
�q�|d|�}
tj	|
|	d�}t|�|}|dk�r�|
dd�}
tj	|
|	d�}t|�|}�qR|d|7<|t|
�d�}|r�|�d
�t|d�}q�|d|7<|�r�|SdS)a�Fold string to_encode into lines as encoded word, combining if allowed.
    Return the new value for last_ew, or None if ew_combine_allowed is False.

    If there is already an encoded word in the last line of lines (indicated by
    a non-None value for last_ew) and ew_combine_allowed is true, decode the
    existing ew, combine it with to_encode, and re-encode.  Otherwise, encode
    to_encode.  In either case, split to_encode as necessary so that the
    encoded segments fit within maxlen.

    Nr�rr�rr�r��z3max_line_length is too small to fit an encoded wordrN)r`)
r
r(rr�rhr�rrrrC)Z	to_encoder�r�r�rIr`Zleading_wspZtrailing_wspZnew_last_ewZ	encode_as�
chrome_lenZremaining_spaceZ
text_spaceZto_encode_wordZencoded_wordZexcessrrrr�1sT��



r�c	Cs�|jD�]�\}}|d���d�s2|dd7<|}d}z|�|�d}Wn0tk
r|d}t�|�rtd}d}nd}YnX|r�tjj	|d	|d
�}	d�
|||	�}
nd�
|t|��}
t|d�t|
�d
|kr�|dd|
|d<qn"t|
�d|k�r
|�
d|
�qd}|d}|rt|�tt|��dt|�}
||
dk�rLd}||
d}}|d|�}tjj	|d	|d
�}	t|	�|k�r��q�|d
8}�q\|�
d�
||||	��d	}|d
7}||d�}|�r|dd7<�qqdS)a>Fold TokenList 'part' into the 'lines' list as mime parameters.

    Using the decoded list of parameters and values, format them according to
    the RFC rules, including using RFC2231 encoding if the value cannot be
    expressed in 'encoding' and/or the parameter+value is too long to fit
    within 'maxlen'.

    r�r]�strictFTr�r�r�r)Zsaferz
{}*={}''{}r�r�rNr�rz''r��NNz {}*{}*={}{})r�r�r�rCr�rr�r�r�ror*rr�rhr
)r2r�r�r�r�rr`Z
error_handlerZencoding_requiredZ
encoded_valuer�r�Zextra_chromer�Z
splitpointZmaxchars�partialrrrr�rsn


� ��r�)�r�rer�r��stringr�operatorrZemailrrrrr�rr3r:r6r�r=Z	TSPECIALSrrZ	ASPECIALSrwr}r�compile�VERBOSE�	MULTILINEr$r�rrLrRrUrWrXrZr\r]rbrmrnrqr{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
r�rrrrrr�rRrSr*r%r�rr�matchr.�findallr	rortr{rrrr"r(r+r,r0r1r2r4r5r7r8r9r<r?rErBrGrKrMrNrPrTrWrXrYr[r\r^r_r`rarcrdrfrgrlrmrprsrvryr|r~r�r�r�r�r�r�r�r�r�r9r�r�rrrr�<module>s.E
�C"	
!*$
V	+





����
1C+
"&'/'&).9%7ED49/gAPK�"�\m�`�88)_header_value_parser.cpython-38.opt-1.pycnu�[���U

e5dϡ�	@s�dZddlZddlZddlZddlmZddlmZddlm	Z
ddlmZddlmZe
d�Zee
d	�BZe
d
�ZeeBZee
d�Zee
d�Zee
d
�Be
d�ZeeBZee
d�BZeeBZee
d�Zdd�Ze�dejejB�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de �Z$Gdd �d e�Z%Gd!d"�d"e�Z&Gd#d$�d$e�Z'Gd%d&�d&e�Z(Gd'd(�d(e(�Z)Gd)d*�d*e �Z*Gd+d,�d,e�Z+Gd-d.�d.e�Z,Gd/d0�d0e�Z-Gd1d2�d2e�Z.Gd3d4�d4e�Z/Gd5d6�d6e�Z0Gd7d8�d8e�Z1Gd9d:�d:e�Z2Gd;d<�d<e�Z3Gd=d>�d>e�Z4Gd?d@�d@e�Z5GdAdB�dBe�Z6GdCdD�dDe�Z7GdEdF�dFe�Z8GdGdH�dHe�Z9GdIdJ�dJe�Z:GdKdL�dLe"�Z;GdMdN�dNe�Z<GdOdP�dPe�Z=GdQdR�dRe�Z>GdSdT�dTe�Z?GdUdV�dVe?�Z@GdWdX�dXe�ZAGdYdZ�dZe�ZBGd[d\�d\e�ZCGd]d^�d^e�ZDGd_d`�d`e�ZEGdadb�dbeE�ZFGdcdd�ddeE�ZGGdedf�dfe�ZHGdgdh�dhe�ZIGdidj�dje�ZJGdkdl�dleJ�ZKGdmdn�dneK�ZLGdodp�dpe�ZMGdqdr�dreN�ZOGdsdt�dteO�ZPGdudv�dveO�ZQGdwdx�dxeP�ZRGdydz�dzejS�ZTeQdd{�ZUeQd|d}�ZVeQd~d�ZWe�d��Xd��Ye���jZZ[e�d��Xe�\d��Ye����j]Z^e�d��j_Z`e�d��Xe�\d��Ye����j]Zae�d��Xe�\d��Ye����j]Zbe�d��Xe�\d��Ye����j]Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d��Z�d�d��Z�d�dÄZ�d�dńZ�d�dDŽZ�d�dɄZ�d�d˄Z�d�d̈́Z�d�dτZ�d�dфZ�d�dӄZ�d�dՄZ�d�dׄZ�d�dلZ�d�dۄZ�d�d݄Z�d�d߄Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�d�d��Z�dS)�alHeader value parser implementing various email-related RFC parsing rules.

The parsing methods defined in this module implement various email related
parsing rules.  Principal among them is RFC 5322, which is the followon
to RFC 2822 and primarily a clarification of the former.  It also implements
RFC 2047 encoded word decoding.

RFC 5322 goes to considerable trouble to maintain backward compatibility with
RFC 822 in the parse phase, while cleaning up the structure on the generation
phase.  This parser supports correct RFC 5322 generation by tagging white space
as folding white space only when folding is allowed in the non-obsolete rule
sets.  Actually, the parser is even more generous when accepting input than RFC
5322 mandates, following the spirit of Postel's Law, which RFC 5322 encourages.
Where possible deviations from the standard are annotated on the 'defects'
attribute of tokens that deviate.

The general structure of the parser follows RFC 5322, and uses its terminology
where there is a direct correspondence.  Where the implementation requires a
somewhat different structure than that used by the formal grammar, new terms
that mimic the closest existing terms are used.  Thus, it really helps to have
a copy of RFC 5322 handy when studying this code.

Input to the parser is a string that has already been unfolded according to
RFC 5322 rules.  According to the RFC this unfolding is the very first step, and
this parser leaves the unfolding step to a higher level message parser, which
will have already detected the line breaks that need unfolding while
determining the beginning and end of each header.

The output of the parser is a TokenList object, which is a list subclass.  A
TokenList is a recursive data structure.  The terminal nodes of the structure
are Terminal objects, which are subclasses of str.  These do not correspond
directly to terminal objects in the formal grammar, but are instead more
practical higher level combinations of true terminals.

All TokenList and Terminal objects have a 'value' attribute, which produces the
semantically meaningful value of that part of the parse subtree.  The value of
all whitespace tokens (no matter how many sub-tokens they may contain) is a
single space, as per the RFC rules.  This includes 'CFWS', which is herein
included in the general class of whitespace tokens.  There is one exception to
the rule that whitespace tokens are collapsed into single spaces in values: in
the value of a 'bare-quoted-string' (a quoted-string with no leading or
trailing whitespace), any whitespace that appeared between the quotation marks
is preserved in the returned value.  Note that in all Terminal strings quoted
pairs are turned into their unquoted values.

All TokenList and Terminal objects also have a string value, which attempts to
be a "canonical" representation of the RFC-compliant form of the substring that
produced the parsed subtree, including minimal use of quoted pair quoting.
Whitespace runs are not collapsed.

Comment tokens also have a 'content' attribute providing the string found
between the parens (including any nested comments) with whitespace preserved.

All TokenList and Terminal objects have a 'defects' attribute which is a
possibly empty list all of the defects found while creating the token.  Defects
may appear on any token in the tree, and a composite list of all defects in the
subtree is available through the 'all_defects' attribute of any node.  (For
Terminal notes x.defects == x.all_defects.)

Each object in a parse tree is called a 'token', and each has a 'token_type'
attribute that gives the name from the RFC 5322 grammar that it represents.
Not all RFC 5322 nodes are produced, and there is one non-RFC 5322 node that
may be produced: 'ptext'.  A 'ptext' is a string of printable ascii characters.
It is returned in place of lists of (ctext/quoted-pair) and
(qtext/quoted-pair).

XXX: provide complete list of token types.
�N)�	hexdigits)�
itemgetter)�_encoded_words)�errors)�utilsz 	�(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%cCs dt|��dd��dd�dS)N�"�\�\\z\")�str�replace��value�r�2/usr/lib64/python3.8/email/_header_value_parser.py�quote_string`srz�
   =\?            # literal =?
   [^?]*          # charset
   \?             # literal ?
   [qQbB]         # literal 'q' or 'b', case insensitive
   \?             # literal ?
  .*?             # encoded word
  \?=             # literal ?=
cs�eZdZdZdZdZ�fdd�Zdd�Z�fdd�Ze	d	d
��Z
e	dd��Zd
d�Ze	dd��Z
e	dd��Zdd�Zddd�Zddd�Zddd�Z�ZS)�	TokenListNTcst�j||�g|_dS�N)�super�__init__�defects)�self�args�kw��	__class__rrryszTokenList.__init__cCsd�dd�|D��S)N�css|]}t|�VqdSr�r
��.0�xrrr�	<genexpr>~sz$TokenList.__str__.<locals>.<genexpr>��join�rrrr�__str__}szTokenList.__str__csd�|jjt����S�Nz{}({})��formatr�__name__r�__repr__r&rrrr,�s
�zTokenList.__repr__cCsd�dd�|D��S)Nrcss|]}|jr|jVqdSrrr rrrr#�sz"TokenList.value.<locals>.<genexpr>r$r&rrrr�szTokenList.valuecCstdd�|D�|j�S)Ncss|]}|jVqdSr)�all_defectsr rrrr#�sz(TokenList.all_defects.<locals>.<genexpr>)�sumrr&rrrr-�szTokenList.all_defectscCs|d��S�Nr)�startswith_fwsr&rrrr0�szTokenList.startswith_fwscCstdd�|D��S)zATrue if all top level tokens of this part may be RFC2047 encoded.css|]}|jVqdSr)�
as_ew_allowed)r!�partrrrr#�sz*TokenList.as_ew_allowed.<locals>.<genexpr>)�allr&rrrr1�szTokenList.as_ew_allowedcCsg}|D]}|�|j�q|Sr)�extend�comments)rr5�tokenrrrr5�szTokenList.commentscCst||d�S)N��policy)�_refold_parse_tree�rr8rrr�fold�szTokenList.foldrcCst|j|d��dS)N��indent)�print�ppstr�rr=rrr�pprint�szTokenList.pprintcCsd�|j|d��S)N�
r<)r%�_ppr@rrrr?�szTokenList.ppstrccszd�||jj|j�V|D]4}t|d�s:|d�|�Vq|�|d�EdHq|jrdd�|j�}nd}d�||�VdS)Nz{}{}/{}(rCz*    !! invalid element in token list: {!r}z    z Defects: {}rz{}){})r*rr+�
token_type�hasattrrCr)rr=r6ZextrarrrrC�s�
�
z
TokenList._pp)r)r)r)r+�
__module__�__qualname__rD�syntactic_break�ew_combine_allowedrr'r,�propertyrr-r0r1r5r;rAr?rC�
__classcell__rrrrrss&





rc@s$eZdZedd��Zedd��ZdS)�WhiteSpaceTokenListcCsdS�N� rr&rrrr�szWhiteSpaceTokenList.valuecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)�comment)rD�contentr rrr�
<listcomp>�s
z0WhiteSpaceTokenList.comments.<locals>.<listcomp>rr&rrrr5�szWhiteSpaceTokenList.commentsN)r+rFrGrJrr5rrrrrL�s
rLc@seZdZdZdS)�UnstructuredTokenList�unstructuredN�r+rFrGrDrrrrrR�srRc@seZdZdZdS)�Phrase�phraseNrTrrrrrU�srUc@seZdZdZdS)�WordZwordNrTrrrrrW�srWc@seZdZdZdS)�CFWSList�cfwsNrTrrrrrX�srXc@seZdZdZdS)�Atom�atomNrTrrrrrZ�srZc@seZdZdZdZdS)�Tokenr6FN)r+rFrGrDZencode_as_ewrrrrr\�sr\c@seZdZdZdZdZdZdS)�EncodedWord�encoded-wordN)r+rFrGrD�cte�charset�langrrrrr]�sr]c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�QuotedString�
quoted-stringcCs"|D]}|jdkr|jSqdS�N�bare-quoted-string�rDr�rr"rrrrP�s
zQuotedString.contentcCs>g}|D]*}|jdkr&|�t|��q|�|j�qd�|�S)Nrer)rD�appendr
rr%)r�resr"rrr�quoted_value�s
zQuotedString.quoted_valuecCs"|D]}|jdkr|jSqdSrdrf�rr6rrr�stripped_value�s
zQuotedString.stripped_valueN)r+rFrGrDrJrPrjrlrrrrrb�s

	rbc@s$eZdZdZdd�Zedd��ZdS)�BareQuotedStringrecCstd�dd�|D���S)Nrcss|]}t|�VqdSrrr rrrr#sz+BareQuotedString.__str__.<locals>.<genexpr>)rr%r&rrrr'�szBareQuotedString.__str__cCsd�dd�|D��S)Nrcss|]}t|�VqdSrrr rrrr#sz)BareQuotedString.value.<locals>.<genexpr>r$r&rrrrszBareQuotedString.valueN)r+rFrGrDr'rJrrrrrrm�srmc@s8eZdZdZdd�Zdd�Zedd��Zedd	��Zd
S)�CommentrOcs(d�tdg�fdd��D�dggg��S)Nrrcsg|]}��|��qSr)�quoter r&rrrQsz#Comment.__str__.<locals>.<listcomp>�))r%r.r&rr&rr's��zComment.__str__cCs2|jdkrt|�St|��dd��dd��dd�S)NrOrrrz\(rpz\))rDr
r)rrrrrros
��z
Comment.quotecCsd�dd�|D��S)Nrcss|]}t|�VqdSrrr rrrr#sz"Comment.content.<locals>.<genexpr>r$r&rrrrPszComment.contentcCs|jgSr)rPr&rrrr5szComment.commentsN)	r+rFrGrDr'rorJrPr5rrrrrns
rnc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressListzaddress-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)�address�rDr rrrrQ's
z)AddressList.addresses.<locals>.<listcomp>rr&rrr�	addresses%szAddressList.addressescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS�rrN�rD�	mailboxesr rrrr#+s
�z(AddressList.mailboxes.<locals>.<genexpr>�r.r&rrrrw)s
��zAddressList.mailboxescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdSru�rD�
all_mailboxesr rrrr#0s
�z,AddressList.all_mailboxes.<locals>.<genexpr>rxr&rrrrz.s
��zAddressList.all_mailboxesN)r+rFrGrDrJrtrwrzrrrrrq!s

rqc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressrrcCs|djdkr|djSdS)Nr�group�rD�display_namer&rrrr~8szAddress.display_namecCs4|djdkr|dgS|djdkr*gS|djS�Nr�mailbox�invalid-mailboxrvr&rrrrw=s

zAddress.mailboxescCs:|djdkr|dgS|djdkr0|dgS|djSrryr&rrrrzEs


zAddress.all_mailboxesN)r+rFrGrDrJr~rwrzrrrrr{4s

r{c@s(eZdZdZedd��Zedd��ZdS)�MailboxList�mailbox-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)r�rsr rrrrQSs
z)MailboxList.mailboxes.<locals>.<listcomp>rr&rrrrwQszMailboxList.mailboxescCsdd�|D�S)NcSsg|]}|jdkr|�qS))r�r�rsr rrrrQWs
�z-MailboxList.all_mailboxes.<locals>.<listcomp>rr&rrrrzUszMailboxList.all_mailboxesN�r+rFrGrDrJrwrzrrrrr�Ms

r�c@s(eZdZdZedd��Zedd��ZdS)�	GroupList�
group-listcCs |r|djdkrgS|djS�Nrr�rvr&rrrrw_szGroupList.mailboxescCs |r|djdkrgS|djSr�ryr&rrrrzeszGroupList.all_mailboxesNr�rrrrr�[s

r�c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�Groupr|cCs|djdkrgS|djS�N�r�rvr&rrrrwpszGroup.mailboxescCs|djdkrgS|djSr�ryr&rrrrzvszGroup.all_mailboxescCs
|djSr/)r~r&rrrr~|szGroup.display_nameN)r+rFrGrDrJrwrzr~rrrrr�ls

r�c@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�NameAddr�	name-addrcCst|�dkrdS|djS�N�r)�lenr~r&rrrr~�szNameAddr.display_namecCs
|djS�N�����
local_partr&rrrr��szNameAddr.local_partcCs
|djSr���domainr&rrrr��szNameAddr.domaincCs
|djSr�)�router&rrrr��szNameAddr.routecCs
|djSr���	addr_specr&rrrr��szNameAddr.addr_specN�
r+rFrGrDrJr~r�r�r�r�rrrrr��s



r�c@s@eZdZdZedd��Zedd��Zedd��Zedd	��Zd
S)�	AngleAddrz
angle-addrcCs"|D]}|jdkr|jSqdS�N�	addr-spec)rDr�rgrrrr��s
zAngleAddr.local_partcCs"|D]}|jdkr|jSqdSr��rDr�rgrrrr��s
zAngleAddr.domaincCs"|D]}|jdkr|jSqdS)N�	obs-route)rD�domainsrgrrrr��s
zAngleAddr.routecCs<|D]2}|jdkr|jr"|jSt|j�|jSqdS)Nr�z<>)rDr�r�rrgrrrr��s

zAngleAddr.addr_specN)	r+rFrGrDrJr�r�r�r�rrrrr��s


r�c@seZdZdZedd��ZdS)�ObsRouter�cCsdd�|D�S)NcSsg|]}|jdkr|j�qSr�r�r rrrrQ�s
z$ObsRoute.domains.<locals>.<listcomp>rr&rrrr��szObsRoute.domainsN)r+rFrGrDrJr�rrrrr��sr�c@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�Mailboxr�cCs|djdkr|djSdS�Nrr�r}r&rrrr~�szMailbox.display_namecCs
|djSr/r�r&rrrr��szMailbox.local_partcCs
|djSr/r�r&rrrr��szMailbox.domaincCs|djdkr|djSdSr�)rDr�r&rrrr��sz
Mailbox.routecCs
|djSr/r�r&rrrr��szMailbox.addr_specNr�rrrrr��s



r�c@s,eZdZdZedd��ZeZZZZ	dS)�InvalidMailboxr�cCsdSrrr&rrrr~�szInvalidMailbox.display_nameNr�rrrrr��s
r�cs(eZdZdZdZe�fdd��Z�ZS)�Domainr�Fcsd�t�j���S�Nr�r%rr�splitr&rrrr��sz
Domain.domain)r+rFrGrDr1rJr�rKrrrrr��sr�c@seZdZdZdS)�DotAtom�dot-atomNrTrrrrr��sr�c@seZdZdZdZdS)�DotAtomTextz
dot-atom-textTN�r+rFrGrDr1rrrrr��sr�c@seZdZdZdZdS)�
NoFoldLiteralzno-fold-literalFNr�rrrrr�sr�c@sDeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dS)�AddrSpecr�FcCs
|djSr/r�r&rrrr�
szAddrSpec.local_partcCst|�dkrdS|djS)N�r�)r�r�r&rrrr�szAddrSpec.domaincCs<t|�dkr|djS|dj��|dj|dj��S)Nr�rr�r�)r�r�rstrip�lstripr&rrrrs
zAddrSpec.valuecCsLt|j�}t|�t|t�kr*t|j�}n|j}|jdk	rH|d|jS|S)N�@)�setr�r��
DOT_ATOM_ENDSrr�)rZnamesetZlprrrr�s

zAddrSpec.addr_specN)
r+rFrGrDr1rJr�r�rr�rrrrr�s


r�c@seZdZdZdZdS)�ObsLocalPartzobs-local-partFNr�rrrrr�&sr�cs4eZdZdZdZedd��Ze�fdd��Z�ZS)�DisplayNamezdisplay-nameFcCs�t|�}t|�dkr|jS|djdkr4|�d�n*|ddjdkr^t|ddd��|d<|djdkrv|��n*|ddjdkr�t|ddd��|d<|jS)NrrYr�r�)rr�rrD�pop)rrirrrr~1s
zDisplayName.display_namecs�d}|jrd}n|D]}|jdkrd}qt|�dkr�|r�d}}|djdks`|ddjdkrdd}|djdks�|ddjdkr�d}|t|j�|St�jSdS)	NFTrcrrrYrNr�)rrDr�rr~rr)rror"ZpreZpostrrrrBs
  zDisplayName.value)	r+rFrGrDrIrJr~rrKrrrrr�,s
r�c@s,eZdZdZdZedd��Zedd��ZdS)�	LocalPartz
local-partFcCs&|djdkr|djS|djSdS)Nrrc)rDrjrr&rrrr[s
zLocalPart.valuecCs�tg}t}d}|dtgD]�}|jdkr,q|r\|jdkr\|djdkr\t|dd��|d<t|t�}|r�|jdkr�|djdkr�|�t|dd���n
|�|�|d}|}qt|dd��}|jS)NFrrY�dotr�r�)�DOTrDr�
isinstancerhr)rriZlastZ
last_is_tl�tokZis_tlrrrr�bs(
�
�
zLocalPart.local_partN)r+rFrGrDr1rJrr�rrrrr�Vs
r�cs4eZdZdZdZe�fdd��Zedd��Z�ZS)�
DomainLiteralzdomain-literalFcsd�t�j���Sr�r�r&rrrr�szDomainLiteral.domaincCs"|D]}|jdkr|jSqdS)N�ptextrfrgrrr�ip�s
zDomainLiteral.ip)	r+rFrGrDr1rJr�r�rKrrrrr�zsr�c@seZdZdZdZdZdS)�MIMEVersionzmime-versionN)r+rFrGrD�major�minorrrrrr��sr�c@s4eZdZdZdZdZdZedd��Zedd��Z	dS)	�	Parameter�	parameterF�us-asciicCs|jr|djSdSr�)�	sectioned�numberr&rrr�section_number�szParameter.section_numbercCsf|D]\}|jdkr|jS|jdkr|D]4}|jdkr*|D] }|jdkr<|jSq<q*qdS)Nrrcrer)rDrlrkrrr�param_value�s




zParameter.param_valueN)
r+rFrGrDr��extendedr`rJr�r�rrrrr��s
r�c@seZdZdZdS)�InvalidParameter�invalid-parameterNrTrrrrr��sr�c@seZdZdZedd��ZdS)�	Attribute�	attributecCs$|D]}|j�d�r|jSqdS)N�attrtext)rD�endswithrrkrrrrl�szAttribute.stripped_valueN�r+rFrGrDrJrlrrrrr��sr�c@seZdZdZdZdS)�Section�sectionN)r+rFrGrDr�rrrrr��sr�c@seZdZdZedd��ZdS)�ValuercCs2|d}|jdkr|d}|j�d�r,|jS|jS)NrrYr�)rcr�zextended-attribute)rDr�rlrrkrrrrl�s
�zValue.stripped_valueNr�rrrrr��sr�c@s(eZdZdZdZedd��Zdd�ZdS)�MimeParameters�mime-parametersFc
cs�i}|D]T}|j�d�sq|djdkr*q|dj��}||krHg||<||�|j|f�q|��D�]~\}}t|td�d�}|dd}|j	}|j
s�t|�dkr�|dddkr�|ddj�t
�d��|dd�}g}d}|D]�\}	}
|	|k�r(|
j
�s|
j�t
�d��q�n|
j�t
�d��|d7}|
j}|
j
�r�ztj�|�}Wn&tk
�rttjj|d	d
�}YnRXz|�|d�}Wn"tk
�r�|�dd�}YnXt�|��r�|
j�t
���|�|�q�d
�|�}||fVqfdS)Nr�rr�)�keyr�z.duplicate parameter name; duplicate(s) ignoredz+duplicate parameter name; duplicate ignoredz(inconsistent RFC2231 parameter numberingzlatin-1)�encoding�surrogateescaper�r)rDr�r�striprhr��items�sortedrr`r�r�rr�InvalidHeaderDefectr��urllib�parseZunquote_to_bytes�UnicodeEncodeErrorZunquote�decode�LookupErrorr�_has_surrogates�UndecodableBytesDefectr%)r�paramsr6�name�partsZfirst_paramr`Zvalue_parts�ir��paramrrrrr��s`�

�
�
zMimeParameters.paramscCsTg}|jD].\}}|r.|�d�|t|���q
|�|�q
d�|�}|rPd|SdS)N�{}={}z; rNr)r�rhr*rr%)rr�r�rrrrr's
zMimeParameters.__str__N)r+rFrGrDrHrJr�r'rrrrr��s

Er�c@seZdZdZedd��ZdS)�ParameterizedHeaderValueFcCs&t|�D]}|jdkr|jSqiS)Nr�)�reversedrDr�rkrrrr�-s
zParameterizedHeaderValue.paramsN)r+rFrGrHrJr�rrrrr�'sr�c@seZdZdZdZdZdZdS)�ContentTypezcontent-typeF�textZplainN)r+rFrGrDr1�maintype�subtyperrrrr�5sr�c@seZdZdZdZdZdS)�ContentDispositionzcontent-dispositionFN)r+rFrGrDr1�content_dispositionrrrrr�<sr�c@seZdZdZdZdZdS)�ContentTransferEncodingzcontent-transfer-encodingFZ7bitN)r+rFrGrDr1r_rrrrr�Bsr�c@seZdZdZdZdS)�HeaderLabelzheader-labelFNr�rrrrr�Hsr�c@seZdZdZdZdd�ZdS)�MsgIDzmsg-idFcCst|�|jSr)r
�linesepr:rrrr;Qsz
MsgID.foldN)r+rFrGrDr1r;rrrrr�Msr�c@seZdZdZdS)�	MessageIDz
message-idNrTrrrrr�Vsr�c@seZdZdZdS)�InvalidMessageIDzinvalid-message-idNrTrrrrr�Zsr�c@seZdZdZdS)�Header�headerNrTrrrrr�^sr�csreZdZdZdZdZ�fdd�Z�fdd�Zdd�Ze	dd	��Z
d�fdd�	Zd
d�Ze	dd��Z
dd�Z�ZS)�TerminalTcst��||�}||_g|_|Sr)r�__new__rDr)�clsrrDrrrrr�lszTerminal.__new__csd�|jjt����Sr(r)r&rrrr,rszTerminal.__repr__cCst|jjd|j�dS)N�/)r>rr+rDr&rrrrAuszTerminal.pprintcCs
t|j�Sr)�listrr&rrrr-xszTerminal.all_defectsrc	s2d�||jj|jt���|js"dn
d�|j��gS)Nz
{}{}/{}({}){}rz {})r*rr+rDrr,rr@rrrrC|s�zTerminal._ppcCsdSrrr&rrr�pop_trailing_ws�szTerminal.pop_trailing_wscCsgSrrr&rrrr5�szTerminal.commentscCst|�|jfSr)r
rDr&rrr�__getnewargs__�szTerminal.__getnewargs__)r)r+rFrGr1rIrHr�r,rArJr-rCr�r5rrKrrrrr�fs
	
r�c@s eZdZedd��Zdd�ZdS)�WhiteSpaceTerminalcCsdSrMrr&rrrr�szWhiteSpaceTerminal.valuecCsdS)NTrr&rrrr0�sz!WhiteSpaceTerminal.startswith_fwsN�r+rFrGrJrr0rrrrr�s
rc@s eZdZedd��Zdd�ZdS)�
ValueTerminalcCs|Srrr&rrrr�szValueTerminal.valuecCsdS)NFrr&rrrr0�szValueTerminal.startswith_fwsNrrrrrr�s
rc@s eZdZedd��Zdd�ZdS)�EWWhiteSpaceTerminalcCsdSr�rr&rrrr�szEWWhiteSpaceTerminal.valuecCsdSr�rr&rrrr'�szEWWhiteSpaceTerminal.__str__N)r+rFrGrJrr'rrrrr�s
rc@seZdZdZdS)�_InvalidEwErrorz1Invalid encoded word found while parsing headers.N)r+rFrG�__doc__rrrrr�srr��,�list-separatorr�zroute-component-markerz([{}]+)rz[^{}]+z[\x00-\x20\x7F]cCs>t|�}|r|j�t�|��t�|�r:|j�t�d��dS)z@If input token contains ASCII non-printables, register a defect.z*Non-ASCII characters found in header tokenN)�_non_printable_finderrrhrZNonPrintableDefectrr�r�)�xtextZnon_printablesrrr�_validate_xtext�s

�rcCs�t|d�^}}g}d}d}tt|��D]L}||dkrJ|rDd}d}nd}q&|rTd}n|||krdq||�||�q&|d}d�|�d�||d�g|�|fS)akScan printables/quoted-pairs until endchars and return unquoted ptext.

    This function turns a run of qcontent, ccontent-without-comments, or
    dtext-with-quoted-printables into a single string by unquoting any
    quoted printables.  It returns the string, the remaining value, and
    a flag that is True iff there were any quoted printables decoded.

    r�FrTrN)�
_wsp_splitter�ranger�rhr%)r�endcharsZfragment�	remainderZvchars�escape�had_qp�posrrr�_get_ptext_to_endchars�s$	rcCs.|��}t|dt|�t|��d�}||fS)z�FWS = 1*WSP

    This isn't the RFC definition.  We're using fws to represent tokens where
    folding can be done, but when we are parsing the *un*folding has already
    been done so we don't need to watch out for CRLF.

    N�fws)r�rr�)rZnewvaluerrrr�get_fwssrc
	Cs�t�}|�d�s t�d�|���|dd��dd�^}}||dd�krXt�d�|���d�|�}t|�dkr�|dtkr�|dtkr�|�	d	�dkr�|�dd�^}}|d|}t|���dkr�|j
�t�d
��||_
d�|�}zt�d|d�\}}}}	Wn*ttfk
�r*td�|j
���YnX||_||_|j
�|	�|�r�|dtk�rrt|�\}
}|�|
��qDt|d�^}}t|d�}t|�|�|�d�|�}�qD|�r�|dtk�r�|j
�t�d
��||fS)zE encoded-word = "=?" charset "?" encoding "?" encoded-text "?="

    �=?z"expected encoded word but found {}r�Nz?=r�rr�?zwhitespace inside encoded wordz!encoded word format invalid: '{}'�vtextz.missing trailing whitespace after encoded-word)r]�
startswithr�HeaderParseErrorr*r�r%r�r�countrrhr�r_�_ewr��
ValueError�KeyErrorrr`rar4�WSPrrrr)
rZewr�rZremstr�restr�r`rarr6�charsrrrr�get_encoded_wordsd
��

�
��
�

�




�r"cCsFt�}|�rB|dtkr0t|�\}}|�|�qd}|�d�r�zt|�\}}Wn,tk
rfd}Yn�tjk
rzYnrXd}t	|�dkr�|dj
dkr�|j�t�d��d}|r�t	|�dkr�|d	j
d
kr�t
|dd�|d<|�|�qt|d�^}}|�rt�|��r|�d�^}}t|d�}t|�|�|�d�|�}q|S)
aOunstructured = (*([FWS] vchar) *WSP) / obs-unstruct
       obs-unstruct = *((*LF *CR *(obs-utext) *LF *CR)) / FWS)
       obs-utext = %d0 / obs-NO-WS-CTL / LF / CR

       obs-NO-WS-CTL is control characters except WSP/CR/LF.

    So, basically, we have printable runs, plus control characters or nulls in
    the obsolete syntax, separated by whitespace.  Since RFC 2047 uses the
    obsolete syntax in its specification, but requires whitespace on either
    side of the encoded words, I can see no reason to need to separate the
    non-printable-non-whitespace from the printable runs if they occur, so we
    parse this into xtext tokens separated by WSP tokens.

    Because an 'unstructured' value must by definition constitute the entire
    value, this 'get' routine does not return a remaining value, only the
    parsed TokenList.

    rTrFr�rz&missing whitespace before encoded wordr����r^rr)rRrrrhrr"rrrr�rDrr�rr�rfc2047_matcher�search�	partitionrrr%)rrSr6�valid_ewZhave_wsr�rrrrr�get_unstructured?sJ


��


r(cCs*t|d�\}}}t|d�}t|�||fS)actext = <printable ascii except \ ( )>

    This is not the RFC ctext, since we are handling nested comments in comment
    and unquoting quoted-pairs here.  We allow anything except the '()'
    characters, but if we find any ASCII other than the RFC defined printable
    ASCII, a NonPrintableDefect is added to the token's defects list.  Since
    quoted pairs are converted to their unquoted values, what is returned is
    a 'ptext' token.  In this case it is a WhiteSpaceTerminal, so it's value
    is ' '.

    z()r�)rrr�rr��_rrr�get_qp_ctext�s
r+cCs*t|d�\}}}t|d�}t|�||fS)aoqcontent = qtext / quoted-pair

    We allow anything except the DQUOTE character, but if we find any ASCII
    other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Any quoted pairs are converted to their
    unquoted values, so what is returned is a 'ptext' token.  In this case it
    is a ValueTerminal.

    r
r�)rrrr)rrr�get_qcontent�s

r,cCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)z�atext = <matches _atext_matcher>

    We allow any non-ATOM_ENDS in atext, but add an InvalidATextDefect to
    the token's defects list if we find non-atext characters.
    zexpected atext but found '{}'N�atext)�_non_atom_end_matcherrrr*r|r�rr)r�mr-rrr�	get_atext�s�
r0cCsr|ddkrt�d�|���t�}|dd�}|rT|ddkrTt|�\}}|�|�|�rB|ddk�rB|dtkr�t|�\}}n�|dd�dk�r*d}z&t|�\}}|j	�t�
d	��d
}Wn"tjk
r�t|�\}}YnX|�r6t|�dk�r6|djdk�r6|d
jdk�r6t
|dd�|d<nt|�\}}|�|�qT|�sb|j	�t�
d��||fS||dd�fS)z�bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE

    A quoted-string without the leading or trailing white space.  Its
    value is the text between the quote marks, with whitespace
    preserved and quoted pairs decoded.
    rr
zexpected '"' but found '{}'r�Nr�rFz!encoded word inside quoted stringTr�rr#r^z"end of header inside quoted string)rrr*rmr,rhrrr"rr�r�rDr)rZbare_quoted_stringr6r'rrr�get_bare_quoted_string�sL�

���

�r1cCs�|r |ddkr t�d�|���t�}|dd�}|r�|ddkr�|dtkr\t|�\}}n&|ddkrvt|�\}}nt|�\}}|�|�q2|s�|j	�t�
d��||fS||dd�fS)z�comment = "(" *([FWS] ccontent) [FWS] ")"
       ccontent = ctext / quoted-pair / comment

    We handle nested comments here, and quoted-pair in our qp-ctext routine.
    rrzexpected '(' but found '{}'r�Nrpzend of header inside comment)rrr*rnrr�get_commentr+rhrr�)rrOr6rrrr2�s&�
�r2cCsPt�}|rH|dtkrH|dtkr0t|�\}}nt|�\}}|�|�q||fS)z,CFWS = (1*([FWS] comment) [FWS]) / FWS

    r)rX�CFWS_LEADERrrr2rh)rrYr6rrr�get_cfws�sr4cCspt�}|r,|dtkr,t|�\}}|�|�t|�\}}|�|�|rh|dtkrht|�\}}|�|�||fS)z�quoted-string = [CFWS] <bare-quoted-string> [CFWS]

    'bare-quoted-string' is an intermediate class defined by this
    parser and not by the RFC grammar.  It is the quoted string
    without any attached CFWS.
    r)rbr3r4rhr1)rZ
quoted_stringr6rrr�get_quoted_strings


r5cCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���|�d�r�zt	|�\}}Wq�tjk
r�t
|�\}}Yq�Xnt
|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)zPatom = [CFWS] 1*atext [CFWS]

    An atom could be an rfc2047 encoded word.
    rzexpected atom but found '{}'r)rZr3r4rh�	ATOM_ENDSrrr*rr"r0)rr[r6rrr�get_atoms&
�


r7cCs�t�}|r|dtkr&t�d�|���|rt|dtkrtt|�\}}|�|�|r&|ddkr&|�t�|dd�}q&|dtkr�t�d�d|���||fS)z( dot-text = 1*atext *("." 1*atext)

    rz8expected atom at a start of dot-atom-text but found '{}'rr�Nr�z4expected atom at end of dot-atom-text but found '{}')r�r6rrr*r0rhr�)rZ
dot_atom_textr6rrr�get_dot_atom_text0s �

�r8cCs�t�}|dtkr(t|�\}}|�|�|�d�rhzt|�\}}Wqttjk
rdt|�\}}YqtXnt|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)z� dot-atom = [CFWS] dot-atom-text [CFWS]

    Any place we can have a dot atom, we could instead have an rfc2047 encoded
    word.
    rr)	r�r3r4rhrr"rrr8)rZdot_atomr6rrr�get_dot_atomCs



r9cCs�|dtkrt|�\}}nd}|s,t�d��|ddkrFt|�\}}n*|dtkrdt�d�|���nt|�\}}|dk	r�|g|dd�<||fS)a�word = atom / quoted-string

    Either atom or quoted-string may start with CFWS.  We have to peel off this
    CFWS first to determine which type of word to parse.  Afterward we splice
    the leading CFWS, if any, into the parsed sub-token.

    If neither an atom or a quoted-string is found before the next special, a
    HeaderParseError is raised.

    The token returned is either an Atom or a QuotedString, as appropriate.
    This means the 'word' level of the formal grammar is not represented in the
    parse tree; this is because having that extra layer when manipulating the
    parse tree is more confusing than it is helpful.

    rNz5Expected 'atom' or 'quoted-string' but found nothing.r
z1Expected 'atom' or 'quoted-string' but found '{}')r3r4rrr5�SPECIALSr*r7)r�leaderr6rrr�get_word\s"��r<cCs�t�}zt|�\}}|�|�Wn(tjk
rH|j�t�d��YnX|r�|dtkr�|ddkr�|�t�|j�t�	d��|dd�}qJzt|�\}}WnDtjk
r�|dt
kr�t|�\}}|j�t�	d��n�YnX|�|�qJ||fS)a� phrase = 1*word / obs-phrase
        obs-phrase = word *(word / "." / CFWS)

    This means a phrase can be a sequence of words, periods, and CFWS in any
    order as long as it starts with at least one word.  If anything other than
    words is detected, an ObsoleteHeaderDefect is added to the token's defect
    list.  We also accept a phrase that starts with CFWS followed by a dot;
    this is registered as an InvalidHeaderDefect, since it is not supported by
    even the obsolete grammar.

    zphrase does not start with wordrrzperiod in 'phrase'r�Nzcomment found without atom)rUr<rhrrrr��PHRASE_ENDSr��ObsoleteHeaderDefectr3r4)rrVr6rrr�
get_phrase~s4
�

�
�r?cCsvt�}d}|dtkr"t|�\}}|s6t�d�|���zt|�\}}Wn^tjk
r�zt|�\}}Wn6tjk
r�|ddkr�|dtkr��t	�}YnXYnX|dk	r�|g|dd�<|�
|�|�r4|ddks�|dtk�r4tt|�|�\}}|j
dk�r|j�
t�d��n|j�
t�d��||d<z|j�d�Wn(tk
�rl|j�
t�d	��YnX||fS)
z= local-part = dot-atom / quoted-string / obs-local-part

    Nrz"expected local-part but found '{}'r�invalid-obs-local-partz<local-part is not dot-atom, quoted-string, or obs-local-partz,local-part is not a dot-atom (contains CFWS)�asciiz)local-part contains non-ASCII characters))r�r3r4rrr*r9r<r=rrh�get_obs_local_partr
rDrr�r>r�encoder�ZNonASCIILocalPartDefect)rr�r;r6�obs_local_partrrr�get_local_part�sJ�
 
�
�
�rEcCs�t�}d}|�r(|ddks*|dtk�r(|ddkrj|rL|j�t�d��|�t�d}|dd�}q
nD|ddkr�|�t|dd	��|dd�}|j�t�d
��d}q
|r�|djdkr�|j�t�d
��zt	|�\}}d}Wn4tj
k
�r|dtk�r
�t|�\}}YnX|�|�q
|djdk�sX|djdk�rj|djdk�rj|j�t�d��|djdk�s�|djdk�r�|djdk�r�|j�t�d��|j�r�d|_||fS)z' obs-local-part = word *("." word)
    Frrrzinvalid repeated '.'Tr�N�misplaced-specialz/'\' character outside of quoted-string/ccontentr�r�zmissing '.' between wordsrYz!Invalid leading '.' in local partr#z"Invalid trailing '.' in local partr@)
r�r=rrhrr�r�rrDr<rr3r4)rrDZlast_non_ws_was_dotr6rrrrB�sj 
�
�
�
���
���
�rBcCs@t|d�\}}}t|d�}|r0|j�t�d��t|�||fS)a dtext = <printable ascii except \ [ ]> / obs-dtext
        obs-dtext = obs-NO-WS-CTL / quoted-pair

    We allow anything except the excluded characters, but if we find any
    ASCII other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Quoted pairs are converted to their
    unquoted values, so what is returned is a ptext token, in this case a
    ValueTerminal.  If there were quoted-printables, an ObsoleteHeaderDefect is
    added to the returned token's defect list.

    z[]r�z(quoted printable found in domain-literal)rrrrhrr>r)rr�rrrr�	get_dtext�s

�rGcCs,|rdS|�t�d��|�tdd��dS)NFz"end of input inside domain-literal�]�domain-literal-endT)rhrr�r)r�domain_literalrrr�_check_for_early_dl_ends�rKcCsjt�}|dtkr(t|�\}}|�|�|s6t�d��|ddkrRt�d�|���|dd�}t||�rp||fS|�tdd��|dt	kr�t
|�\}}|�|�t|�\}}|�|�t||�r�||fS|dt	kr�t
|�\}}|�|�t||�r�||fS|ddk�rt�d	�|���|�tdd
��|dd�}|�rb|dtk�rbt|�\}}|�|�||fS)zB domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]

    rzexpected domain-literal�[z6expected '[' at start of domain-literal but found '{}'r�Nzdomain-literal-startrHz4expected ']' at end of domain-literal but found '{}'rI)r�r3r4rhrrr*rKrrrrG)rrJr6rrr�get_domain_literalsH

�





�
rMcCsrt�}d}|dtkr"t|�\}}|s6t�d�|���|ddkrvt|�\}}|dk	rd|g|dd�<|�|�||fSzt|�\}}Wn"tjk
r�t	|�\}}YnX|r�|ddkr�t�d��|dk	r�|g|dd�<|�|�|�rj|ddk�rj|j
�t�d��|djd	k�r*|d|dd�<|�rj|ddk�rj|�t
�t	|d
d��\}}|�|��q*||fS)z] domain = dot-atom / domain-literal / obs-domain
        obs-domain = atom *("." atom))

    Nrzexpected domain but found '{}'rLr�zInvalid Domainrz(domain is not a dot-atom (contains CFWS)r�r�)r�r3r4rrr*rMrhr9r7rr>rDr�)rr�r;r6rrr�
get_domain=sD�



�
rNcCs|t�}t|�\}}|�|�|r,|ddkrF|j�t�d��||fS|�tdd��t|dd��\}}|�|�||fS)z( addr-spec = local-part "@" domain

    rr�z#addr-spec local part with no domain�address-at-symbolr�N)r�rErhrrr�rrN)rr�r6rrr�
get_addr_speccs

�
rPcCs�t�}|rj|ddks"|dtkrj|dtkrFt|�\}}|�|�q|ddkr|�t�|dd�}q|rz|ddkr�t�d�|���|�t�t	|dd��\}}|�|�|�r>|ddk�r>|�t�|dd�}|s�q>|dtk�rt|�\}}|�|�|ddkr�|�t�t	|dd��\}}|�|�q�|�sNt�d��|ddk�rlt�d	�|���|�t
dd
��||dd�fS)z� obs-route = obs-domain-list ":"
        obs-domain-list = *(CFWS / ",") "@" domain *("," [CFWS] ["@" domain])

        Returns an obs-route token with the appropriate sub-tokens (that is,
        there is no obs-domain-list in the parse tree).
    rrr�Nr�z(expected obs-route domain but found '{}'z%end of header while parsing obs-route�:z4expected ':' marking end of obs-route but found '{}'zend-of-obs-route-marker)r�r3r4rh�
ListSeparatorrrr*�RouteComponentMarkerrNr)rZ	obs_router6rrr�
get_obs_routessF
�





�rTcCs�t�}|dtkr(t|�\}}|�|�|r8|ddkrHt�d�|���|�tdd��|dd�}|ddkr�|�tdd��|j�t�	d	��|dd�}||fSzt
|�\}}Wnztjk
�r0z"t|�\}}|j�t�d
��Wn(tjk
�rt�d�|���YnX|�|�t
|�\}}YnX|�|�|�r^|ddk�r^|dd�}n|j�t�	d��|�tdd��|�r�|dtk�r�t|�\}}|�|�||fS)
z� angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
        obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS]

    r�<z"expected angle-addr but found '{}'zangle-addr-startr�N�>zangle-addr-endznull addr-spec in angle-addrz*obsolete route specification in angle-addrz.expected addr-spec or obs-route but found '{}'z"missing trailing '>' on angle-addr)
r�r3r4rhrrr*rrr�rPrTr>)rZ
angle_addrr6rrr�get_angle_addr�sT
�
�
�
�



�
rWcCs<t�}t|�\}}|�|dd��|jdd�|_||fS)z� display-name = phrase

    Because this is simply a name-rule, we don't return a display-name
    token containing a phrase, but rather a display-name token with
    the content of the phrase.

    N)r�r?r4r)rr~r6rrr�get_display_name�s
rXcCs�t�}d}|dtkr6t|�\}}|s6t�d�|���|ddkr�|dtkr^t�d�|���t|�\}}|s~t�d�|���|dk	r�|g|ddd�<d}|�|�t	|�\}}|dk	r�|g|dd�<|�|�||fS)z, name-addr = [display-name] angle-addr

    Nrz!expected name-addr but found '{}'rU)
r�r3r4rrr*r=rXrhrW)rZ	name_addrr;r6rrr�
get_name_addr�s6���

rYcCs�t�}zt|�\}}WnNtjk
rdzt|�\}}Wn&tjk
r^t�d�|���YnXYnXtdd�|jD��r�d|_|�	|�||fS)z& mailbox = name-addr / addr-spec

    zexpected mailbox but found '{}'css|]}t|tj�VqdSr)r�rr�r rrrr#s�zget_mailbox.<locals>.<genexpr>r�)
r�rYrrrPr*�anyr-rDrh)rr�r6rrr�get_mailbox�s ��
r[cCsdt�}|r\|d|kr\|dtkrD|�t|dd��|dd�}qt|�\}}|�|�q||fS)z� Read everything up to one of the chars in endchars.

    This is outside the formal grammar.  The InvalidMailbox TokenList that is
    returned acts like a Mailbox, but the data attributes are None.

    rrFr�N)r�r=rhrr?)rrZinvalid_mailboxr6rrr�get_invalid_mailboxs�r\cCs�t�}|�r�|ddk�r�zt|�\}}|�|�W�ntjk
�r<d}|dtkr�t|�\}}|rv|ddkr�|�|�|j�t�d��n@t	|d�\}}|dk	r�|g|dd�<|�|�|j�t�
d��nb|ddkr�|j�t�d��nBt	|d�\}}|dk	�r|g|dd�<|�|�|j�t�
d��YnX|�r�|ddk�r�|d}d	|_t	|d�\}}|�|�|j�t�
d��|r|ddkr|�t
�|d
d�}q||fS)aJ mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
        obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])

    For this routine we go outside the formal grammar in order to improve error
    handling.  We recognize the end of the mailbox list only at the end of the
    value or at a ';' (the group terminator).  This is so that we can turn
    invalid mailboxes into InvalidMailbox tokens and continue parsing any
    remaining valid mailboxes.  We also allow all mailbox entries to be null,
    and this condition is handled appropriately at a higher level.

    r�;Nz,;zempty element in mailbox-listzinvalid mailbox in mailbox-listrr�r�r�)r�r[rhrrr3r4rr>r\r�rDr4rR)rZmailbox_listr6r;r�rrr�get_mailbox_listsX

�

�
�


�

�
r^cCst�}|s$|j�t�d��||fSd}|r�|dtkr�t|�\}}|sl|j�t�d��|�|�||fS|ddkr�|�|�||fSt|�\}}t|j	�dkr�|dk	r�|�|�|�
|�|j�t�d��||fS|dk	r�|g|dd�<|�|�||fS)zg group-list = mailbox-list / CFWS / obs-group-list
        obs-group-list = 1*([CFWS] ",") [CFWS]

    zend of header before group-listNrzend of header in group-listr]zgroup-list with empty entries)r�rrhrr�r3r4r^r�rzr4r>)rZ
group_listr;r6rrr�get_group_listWs>
�
�




�
r_cCs t�}t|�\}}|r"|ddkr2t�d�|���|�|�|�tdd��|dd�}|r�|ddkr�|�tdd��||dd�fSt|�\}}|�|�|s�|j�t�	d	��n|ddkr�t�d
�|���|�tdd��|dd�}|�r|dt
k�rt|�\}}|�|�||fS)z7 group = display-name ":" [group-list] ";" [CFWS]

    rrQz8expected ':' at end of group display name but found '{}'zgroup-display-name-terminatorr�Nr]zgroup-terminatorzend of header in groupz)expected ';' at end of group but found {})r�rXrrr*rhrr_rr�r3r4)rr|r6rrr�	get_group|s8�


��
r`cCsxt�}zt|�\}}WnNtjk
rdzt|�\}}Wn&tjk
r^t�d�|���YnXYnX|�|�||fS)a� address = mailbox / group

    Note that counter-intuitively, an address can be either a single address or
    a list of addresses (a group).  This is why the returned Address object has
    a 'mailboxes' attribute which treats a single address as a list of length
    one.  When you need to differentiate between to two cases, extract the single
    element, which is either a mailbox or a group token.

    zexpected address but found '{}')r{r`rrr[r*rh)rrrr6rrr�get_address�s�
rac
Cs�t�}|�r�zt|�\}}|�|�W�n tjk
�rH}z�d}|dtkr�t|�\}}|rj|ddkr�|�|�|j�t�d��nFt	|d�\}}|dk	r�|g|dd�<|�t
|g��|j�t�d��nh|ddkr�|j�t�d��nHt	|d�\}}|dk	�r|g|dd�<|�t
|g��|j�t�d��W5d}~XYnX|�r�|ddk�r�|dd}d|_t	|d�\}}|�
|�|j�t�d��|r|�tdd	��|d
d�}q||fS)a� address_list = (address *("," address)) / obs-addr-list
        obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])

    We depart from the formal grammar here by continuing to parse until the end
    of the input, assuming the input to be entirely composed of an
    address-list.  This is always true in email parsing, and allows us
    to skip invalid addresses to parse additional valid ones.

    Nrrz"address-list entry with no contentzinvalid address in address-listzempty element in address-listr�r�rr�)rqrarhrrr3r4rr>r\r{r�rDr4r)rZaddress_listr6�errr;r�rrr�get_address_list�sX


�
�
�

�

�rccCs�t�}|st�d�|���|ddkr6t�d�|���|�tdd��|dd�}t|�\}}|�|�|rx|ddkr�t�d	�|���|�tdd
��||dd�fS)z& no-fold-literal = "[" *dtext "]"
    z'expected no-fold-literal but found '{}'rrLz;expected '[' at the start of no-fold-literal but found '{}'zno-fold-literal-startr�NrHz9expected ']' at the end of no-fold-literal but found '{}'zno-fold-literal-end)r�rrr*rhrrG)rZno_fold_literalr6rrr�get_no_fold_literal�s.���
��rdcCs�t�}|r,|dtkr,t|�\}}|�|�|r<|ddkrLt�d�|���|�tdd��|dd�}zt|�\}}Wn`tjk
r�z"t	|�\}}|j
�t�d��Wn&tjk
r�t�d�|���YnXYnX|�|�|r�|dd	k�r@|j
�t�d
��|�r8|ddk�r8|�tdd��|dd�}||fS|�td	d
��|dd�}zt|�\}}Wn�tjk
�rzt
|�\}}Wnrtjk
�r}zPz"t|�\}}|j
�t�d��Wn(tjk
�r�t�d�|���YnXW5d}~XYnXYnX|�|�|�r6|ddk�r6|dd�}n|j
�t�d��|�tdd��|�r�|dtk�r�t|�\}}|�|�||fS)z�msg-id = [CFWS] "<" id-left '@' id-right  ">" [CFWS]
       id-left = dot-atom-text / obs-id-left
       id-right = dot-atom-text / no-fold-literal / obs-id-right
       no-fold-literal = "[" *dtext "]"
    rrUzexpected msg-id but found '{}'zmsg-id-startr�Nzobsolete id-left in msg-idz4expected dot-atom-text or obs-id-left but found '{}'r�zmsg-id with no id-rightrVz
msg-id-endrOzobsolete id-right in msg-idzFexpected dot-atom-text, no-fold-literal or obs-id-right but found '{}'zmissing trailing '>' on msg-id)r�r3r4rhrrr*rr8rBrr>r�rdrN)rZmsg_idr6�errr�
get_msg_ids~
�
�
��

�
�
��"

�
rfc
Cs�t�}zt|�\}}|�|�WnLtjk
rl}z,t|�}t|�}|j�t�d�	|���W5d}~XYnX|r�|j�t�d�	|���|S)z2message-id      =   "Message-ID:" msg-id CRLF
    zInvalid msg-id: {!r}NzUnexpected {!r})
r�rfrhrrr(r�rr�r*)rZ
message_idr6Zexrrr�parse_message_idIs�
�rgcCs�t�}|s |j�t�d��|S|dtkrXt|�\}}|�|�|sX|j�t�d��d}|r�|ddkr�|dtkr�||d7}|dd�}q\|��s�|j�t�d�	|���|�t
|d	��nt|�|_|�t
|d
��|�r|dtk�rt|�\}}|�|�|�r|ddk�rT|jdk	�r:|j�t�d��|�rP|�t
|d	��|S|�t
dd��|dd�}|�r�|dtk�r�t|�\}}|�|�|�s�|jdk	�r�|j�t�d��|Sd}|�r�|dtk�r�||d7}|dd�}�q�|���s*|j�t�d
�	|���|�t
|d	��nt|�|_
|�t
|d
��|�rn|dtk�rnt|�\}}|�|�|�r�|j�t�d��|�t
|d	��|S)zE mime-version = [CFWS] 1*digit [CFWS] "." [CFWS] 1*digit [CFWS]

    z%Missing MIME version number (eg: 1.0)rz0Expected MIME version number but found only CFWSrrr�Nz1Expected MIME major version number but found {!r}r
�digitsz0Incomplete MIME version; found only major numberzversion-separatorz1Expected MIME minor version number but found {!r}z'Excess non-CFWS text after MIME version)r�rrhr�HeaderMissingRequiredValuer3r4�isdigitr�r*r�intr�r�)rZmime_versionr6rhrrr�parse_mime_versiones�
�

�
�


�

�

�


�rlcCsdt�}|r\|ddkr\|dtkrD|�t|dd��|dd�}qt|�\}}|�|�q||fS)z� Read everything up to the next ';'.

    This is outside the formal grammar.  The InvalidParameter TokenList that is
    returned acts like a Parameter, but the data attributes are None.

    rr]rFr�N)r�r=rhrr?)rZinvalid_parameterr6rrr�get_invalid_parameter�s�rmcCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)a8ttext = <matches _ttext_matcher>

    We allow any non-TOKEN_ENDS in ttext, but add defects to the token's
    defects list if we find non-ttext characters.  We also register defects for
    *any* non-printables even though the RFC doesn't exclude all of them,
    because we follow the spirit of RFC 5322.

    zexpected ttext but found '{}'N�ttext)�_non_token_end_matcherrrr*r|r�rr)rr/rnrrr�	get_ttext�s	�
rpcCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)z�token = [CFWS] 1*ttext [CFWS]

    The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or
    tspecials.  We also exclude tabs even though the RFC doesn't.

    The RFC implies the CFWS but is not explicit about it in the BNF.

    r�expected token but found '{}')	r\r3r4rh�
TOKEN_ENDSrrr*rp)rZmtokenr6rrr�	get_token�s	
�

rscCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)aQattrtext = 1*(any non-ATTRIBUTE_ENDS character)

    We allow any non-ATTRIBUTE_ENDS in attrtext, but add defects to the
    token's defects list if we find non-attrtext characters.  We also register
    defects for *any* non-printables even though the RFC doesn't exclude all of
    them, because we follow the spirit of RFC 5322.

    z expected attrtext but found {!r}Nr�)�_non_attribute_end_matcherrrr*r|r�rr�rr/r�rrr�get_attrtext�s	�
rvcCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)aH [CFWS] 1*attrtext [CFWS]

    This version of the BNF makes the CFWS explicit, and as usual we use a
    value terminal for the actual run of characters.  The RFC equivalent of
    attrtext is the token characters, with the subtraction of '*', "'", and '%'.
    We include tab in the excluded set just as we do for token.

    rrq)	r�r3r4rh�ATTRIBUTE_ENDSrrr*rv�rr�r6rrr�
get_attribute�s	
�

rycCsNt|�}|st�d�|���|��}|t|�d�}t|d�}t|�||fS)z�attrtext = 1*(any non-ATTRIBUTE_ENDS character plus '%')

    This is a special parsing routine so that we get a value that
    includes % escapes as a single string (which we decode as a single
    string later).

    z)expected extended attrtext but found {!r}N�extended-attrtext)�#_non_extended_attribute_end_matcherrrr*r|r�rrrurrr�get_extended_attrtext	s�
r|cCs�t�}|r,|dtkr,t|�\}}|�|�|rL|dtkrLt�d�|���t|�\}}|�|�|r�|dtkr�t|�\}}|�|�||fS)z� [CFWS] 1*extended_attrtext [CFWS]

    This is like the non-extended version except we allow % characters, so that
    we can pick up an encoded value as a single string.

    rrq)	r�r3r4rh�EXTENDED_ATTRIBUTE_ENDSrrr*r|rxrrr�get_extended_attribute!	s
�

r~cCs�t�}|r|ddkr&t�d�|���|�tdd��|dd�}|rR|d��sbt�d�|���d}|r�|d��r�||d7}|dd�}qf|dd	kr�|d	kr�|j�t�d
��t	|�|_
|�t|d��||fS)a6 '*' digits

    The formal BNF is more complicated because leading 0s are not allowed.  We
    check for that and add a defect.  We also assume no CFWS is allowed between
    the '*' and the digits, though the RFC is not crystal clear on that.
    The caller should already have dealt with leading CFWS.

    r�*zExpected section but found {}zsection-markerr�Nz$Expected section number but found {}r�0z'section number has an invalid leading 0rh)r�rrr*rhrrjrZInvalidHeaderErrorrkr�)rr�rhrrr�get_section7	s,	��
�
r�cCs�t�}|st�d��d}|dtkr0t|�\}}|sDt�d�|���|ddkr^t|�\}}nt|�\}}|dk	r�|g|dd�<|�|�||fS)z  quoted-string / attribute

    z&Expected value but found end of stringNrz Expected value but found only {}r
)	r�rrr3r4r*r5r~rh)r�vr;r6rrr�	get_valueU	s"
�
r�cCs�t�}t|�\}}|�|�|r,|ddkrL|j�t�d�|���||fS|ddkr�z t|�\}}d|_|�|�Wntj	k
r�YnX|s�t�	d��|ddkr�|�t
dd��|dd	�}d|_|dd
kr�t�	d��|�t
d
d��|dd	�}d	}|�r,|dtk�r,t
|�\}}|�|�d	}|}|j�rF|�rF|dd
k�rFt|�\}}|j}d}|jdk�r�|�r�|ddk�r�d}n$t|�\}}	|	�r�|	ddk�r�d}n(zt|�\}}	WnYnX|	�s�d}|�r0|j�t�d��|�|�|D](}
|
jdk�rg|
d	d	�<|
}�q*�q|}nd	}|j�t�d��|�r`|ddk�r`d	}nt|�\}}|j�r�|jdk�r�|�r�|ddk�r�|�|�|d	k	�r�|}||fS|j�t�d��|�s�|j�t�d��|�|�|d	k�r�||fSn�|d	k	�r@|D]}
|
jdk�r
�q$�q
|
jdk|�|
�|
j|_|ddk�r^t�	d�|���|�t
dd��|dd	�}|�r�|ddk�r�t|�\}}|�|�|j|_|�r�|ddk�r�t�	d�|���|�t
dd��|dd	�}|d	k	�rdt�}|�r^|dtk�rt|�\}}n2|dd
k�rDt
d
d�}|dd	�}nt|�\}}|�|��q�|}nt|�\}}|�|�|d	k	�r�|}||fS)aY attribute [section] ["*"] [CFWS] "=" value

    The CFWS is implied by the RFC but not made explicit in the BNF.  This
    simplified form of the BNF from the RFC is made to conform with the RFC BNF
    through some extra checks.  We do it this way because it makes both error
    recovery and working with the resulting parse tree easier.
    rr]z)Parameter contains name ({}) but no valuerTzIncomplete parameterzextended-parameter-markerr�N�=zParameter not followed by '='�parameter-separatorr
F�'z5Quoted string value for extended parameter is invalidrezZParameter marked as extended but appears to have a quoted string value that is non-encodedzcApparent initial-extended-value but attribute was not marked as extended or was not initial sectionz(Missing required charset/lang delimitersrzr�z=Expected RFC2231 char/lang encoding delimiter, but found {!r}zRFC2231-delimiterz;Expected RFC2231 char/lang encoding delimiter, but found {}ZDQUOTE)r�ryrhrrr�r*r�r�rrr�r3r4r5rlr�rvr|rDr�rr`rar�rrr,)rr�r6r;rZappendtoZqstringZinner_valueZ
semi_validr �tr�rrr�
get_parameterk	s�
�



�


�


�
�






�
�



r�c
Csjt�}|�rfzt|�\}}|�|�Wn�tjk
r�}z�d}|dtkrVt|�\}}|sp|�|�|WY�xS|ddkr�|dk	r�|�|�|j�t�d��n@t	|�\}}|r�|g|dd�<|�|�|j�t�d�
|���W5d}~XYnX|�rD|ddk�rD|d}d|_t	|�\}}|�|�|j�t�d�
|���|r|�t
dd	��|d
d�}q|S)a! parameter *( ";" parameter )

    That BNF is meant to indicate this routine should only be called after
    finding and handling the leading ';'.  There is no corresponding rule in
    the formal RFC grammar, but it is more convenient for us for the set of
    parameters to be treated as its own TokenList.

    This is 'parse' routine because it consumes the remaining value, but it
    would never be called to parse a full header.  Instead it is called to
    parse everything after the non-parameter value of a specific MIME header.

    Nrr]zparameter entry with no contentzinvalid parameter {!r}r�r�z)parameter with invalid trailing text {!r}r�r�)r�r�rhrrr3r4rr�rmr*rDr4r)rZmime_parametersr6rbr;r�rrr�parse_mime_parameters�	sJ



�

�

�r�cCs�|rV|ddkrV|dtkr>|�t|dd��|dd�}qt|�\}}|�|�q|s^dS|�tdd��|�t|dd���dS)zBDo our best to find the parameters in an invalid MIME header

    rr]rFr�Nr�)r=rhrr?r�)Z	tokenlistrr6rrr�_find_mime_parameters-
sr�c
Cs�t�}d}|s$|j�t�d��|Szt|�\}}Wn<tjk
rp|j�t�d�|���t	||�|YSX|�|�|r�|ddkr�|j�t�d��|r�t	||�|S|j
����|_
|�tdd��|dd	�}zt|�\}}Wn>tjk
�r*|j�t�d
�|���t	||�|YSX|�|�|j
����|_|�sP|S|ddk�r�|j�t�d�|���|`
|`t	||�|S|�tdd
��|�t|dd	���|S)z� maintype "/" subtype *( ";" parameter )

    The maintype and substype are tokens.  Theoretically they could
    be checked against the official IANA list + x-token, but we
    don't do that.
    Fz"Missing content type specificationz(Expected content maintype but found {!r}rr�zInvalid content typezcontent-type-separatorr�Nz'Expected content subtype but found {!r}r]z<Only parameters are valid after content type, but found {!r}r�)r�rrhrrirsrr�r*r�rr��lowerr�rr�r�)rZctypeZrecoverr6rrr�parse_content_type_header=
sd
�
�



�

�



��
r�c
Cs�t�}|s |j�t�d��|Szt|�\}}Wn<tjk
rl|j�t�d�|���t	||�|YSX|�|�|j
����|_
|s�|S|ddkr�|j�t�d�|���t	||�|S|�tdd��|�t|dd���|S)	z* disposition-type *( ";" parameter )

    zMissing content dispositionz+Expected content disposition but found {!r}rr]zCOnly parameters are valid after content disposition, but found {!r}r�r�N)r�rrhrrirsrr�r*r�rr�r�r�rr�)rZdisp_headerr6rrr� parse_content_disposition_headerv
s:
�
�



��
r�c
Cs�t�}|s |j�t�d��|Szt|�\}}Wn.tjk
r^|j�t�d�|���YnX|�|�|j	�
���|_|s�|S|r�|j�t�d��|dt
kr�|�t|dd��|dd�}q�t|�\}}|�|�q�|S)z mechanism

    z!Missing content transfer encodingz1Expected content transfer encoding but found {!r}z*Extra text after content transfer encodingrrFr�N)r�rrhrrirsrr�r*rr�r�r_r=rr?)rZ
cte_headerr6rrr�&parse_content_transfer_encoding_header�
s4
�
�

�r�cCsDd}|r@|dr@|ddtkr@|dd}|ddd�|d<|S)Nrr�)r)�linesZwsprrr�_steal_trailing_WSP_if_exists�
s
r�cCs�|jp
tj}|jrdnd}dg}d}d}d}tdd�}t|�}	|	�r�|	�d�}
|
|kr`|d8}q>t|
�}|
jd	kr�t	|�t
@r�d
}z|�|�|}Wn6tk
r�t
dd�|
jD��r�d
}nd}d
}YnX|
jdkr�t|
|||�q>|�r�|�s�|
j�spd}d}|
j�rp|
j|d�dt|j��}
|j|
k�rpt|
�|t|d�k�r^t|�}|�|�|d|
7<q>t|
d��s�t|
�|	}	nt|||||
j|�}d}q>t|�|t|d�k�r�|d|7<q>|
j�rt|�d|k�rt|�}|�s|
���r|�||�d}q>t|
d��sNt|
�}|
j�sD|d7}|�|�||	}	q>|
j�rn|�sn|	�d|
�d
}q>t|�}|�s�|
���r�|�||�q>|d|7<q>|j�|�|jS)zLReturn string of contents of parse_tree folded according to RFC rules.

    �utf-8r�rNrF�wrap_as_ew_blockedr�r�Tcss|]}t|tj�VqdSr)r�rr�r rrrr#�
s�z%_refold_parse_tree.<locals>.<genexpr>�unknown-8bitr�r7r�rC)Zmax_line_length�sys�maxsize�utf8r�r�r�r
rDr�r:rCr�rZr-�_fold_mime_parametersr1rHr;r�r�r�rhrE�_fold_as_ewrIr0�insertr%)Z
parse_treer8�maxlenr�r��last_ewr�Z
want_encodingZend_ew_not_allowedr�r2�tstrr`Zencoded_part�newlineZnewpartsrrrr9�
s�


�



��
r9cCs�|dk	r<|r<tt|d|d�|��}|dd|�|d<|dtkr�|d}|dd�}t|d�|krz|�t|��|d|7<d}|dtkr�|d}|dd�}|dkr�t|d�n|}|dkr�dn|}	t|	�d}
|
d|kr�t�d	��|�r�|t|d�}||
}|dk�r,|�d
�q�|d|�}
tj	|
|	d�}t|�|}|dk�r�|
dd�}
tj	|
|	d�}t|�|}�qR|d|7<|t|
�d�}|r�|�d
�t|d�}q�|d|7<|�r�|SdS)a�Fold string to_encode into lines as encoded word, combining if allowed.
    Return the new value for last_ew, or None if ew_combine_allowed is False.

    If there is already an encoded word in the last line of lines (indicated by
    a non-None value for last_ew) and ew_combine_allowed is true, decode the
    existing ew, combine it with to_encode, and re-encode.  Otherwise, encode
    to_encode.  In either case, split to_encode as necessary so that the
    encoded segments fit within maxlen.

    Nr�rr�rr�r��z3max_line_length is too small to fit an encoded wordrN)r`)
r
r(rr�rhr�rrrrC)Z	to_encoder�r�r�rIr`Zleading_wspZtrailing_wspZnew_last_ewZ	encode_as�
chrome_lenZremaining_spaceZ
text_spaceZto_encode_wordZencoded_wordZexcessrrrr�1sT��



r�c	Cs�|jD�]�\}}|d���d�s2|dd7<|}d}z|�|�d}Wn0tk
r|d}t�|�rtd}d}nd}YnX|r�tjj	|d	|d
�}	d�
|||	�}
nd�
|t|��}
t|d�t|
�d
|kr�|dd|
|d<qn"t|
�d|k�r
|�
d|
�qd}|d}|rt|�tt|��dt|�}
||
dk�rLd}||
d}}|d|�}tjj	|d	|d
�}	t|	�|k�r��q�|d
8}�q\|�
d�
||||	��d	}|d
7}||d�}|�r|dd7<�qqdS)a>Fold TokenList 'part' into the 'lines' list as mime parameters.

    Using the decoded list of parameters and values, format them according to
    the RFC rules, including using RFC2231 encoding if the value cannot be
    expressed in 'encoding' and/or the parameter+value is too long to fit
    within 'maxlen'.

    r�r]�strictFTr�r�r�r)Zsaferz
{}*={}''{}r�r�rNr�rz''r��NNz {}*{}*={}{})r�r�r�rCr�rr�r�r�ror*rr�rhr
)r2r�r�r�r�rr`Z
error_handlerZencoding_requiredZ
encoded_valuer�r�Zextra_chromer�Z
splitpointZmaxchars�partialrrrr�rsn


� ��r�)�r�rer�r��stringr�operatorrZemailrrrrr�rr3r:r6r�r=Z	TSPECIALSrrZ	ASPECIALSrwr}r�compile�VERBOSE�	MULTILINEr$r�rrLrRrUrWrXrZr\r]rbrmrnrqr{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
r�rrrrrr�rRrSr*r%r�rr�matchr.�findallr	rortr{rrrr"r(r+r,r0r1r2r4r5r7r8r9r<r?rErBrGrKrMrNrPrTrWrXrYr[r\r^r_r`rarcrdrfrgrlrmrprsrvryr|r~r�r�r�r�r�r�r�r�r�r9r�r�rrrr�<module>s.E
�C"	
!*$
V	+





����
1C+
"&'/'&).9%7ED49/gAPK�"�\�ˠ��base64mime.cpython-38.opt-2.pycnu�[���U

e5d�
�@spddddddgZddlmZddlmZmZd	Zd
ZdZdZ	d
d�Z
ddd�Zdefdd�Zdd�Z
e
Ze
ZdS)�body_decode�body_encode�decode�decodestring�
header_encode�
header_length�)�	b64encode)�
b2a_base64�
a2b_base64z
�
��cCs*tt|�d�\}}|d}|r&|d7}|S)N��)�divmod�len)�	bytearrayZgroups_of_3Zleftover�n�r�(/usr/lib64/python3.8/email/base64mime.pyr2s
�
iso-8859-1cCs6|sdSt|t�r|�|�}t|��d�}d||fS)Nr�asciiz=?%s?b?%s?=)�
isinstance�str�encoderr)Zheader_bytes�charsetZencodedrrrr=s

�LcCs~|s|Sg}|dd}tdt|�|�D]J}t||||���d�}|�t�rh|tkrh|dd�|}|�|�q(t�|�S)Nrrrr���)	�rangerr	r�endswith�NL�append�EMPTYSTRING�join)�sZ
maxlinelenZeolZencvecZ
max_unencoded�i�encrrrrLs
cCs.|s
t�St|t�r"t|�d��St|�SdS)Nzraw-unicode-escape)�bytesrrr
r)�stringrrrrfs

N)r)�__all__�base64rZbinasciir	r
ZCRLFr r"ZMISC_LENrrrrrrrrrr�<module>s$�

PK�"�\o��NNencoders.cpython-38.pycnu�[���U

e5d��@sTdZddddgZddlmZddlmZdd	�Zd
d�Z	dd�Z
dd�Zd
d�ZdS)z Encodings and related functions.�encode_7or8bit�
encode_base64�encode_noop�
encode_quopri�)�encodebytes)�encodestringcCst|dd�}|�dd�S)NT)Z	quotetabs� s=20)�
_encodestring�replace)�s�enc�r
�&/usr/lib64/python3.8/email/encoders.py�_qencodesrcCs0|jdd�}tt|�d�}|�|�d|d<dS)zlEncode the message's payload in Base64.

    Also, add an appropriate Content-Transfer-Encoding header.
    T��decode�ascii�base64�Content-Transfer-EncodingN)�get_payload�str�_bencode�set_payload��msg�origZencdatar
r
rrs
cCs*|jdd�}t|�}|�|�d|d<dS)zvEncode the message's payload in quoted-printable.

    Also, add an appropriate Content-Transfer-Encoding header.
    Trzquoted-printablerN)rrrrr
r
rr&s
cCsX|jdd�}|dkr d|d<dSz|�d�Wntk
rJd|d<Yn
Xd|d<dS)z9Set the Content-Transfer-Encoding header to 7bit or 8bit.TrNZ7bitrrZ8bit)rr�UnicodeError)rrr
r
rr2scCsdS)zDo nothing.Nr
)rr
r
rrDsN)
�__doc__�__all__rrr�quoprirr	rrrrrr
r
r
r�<module>s�PK�"�\��\w`` _policybase.cpython-38.opt-2.pycnu�[���U

e5d�:�@s�ddlZddlmZddlmZddlmZdddgZGdd	�d	�Zd
d�Z	dd
�Z
Gdd�deejd�Ze
Gdd�de��Z
e
�ZdS)�N)�header)�charset)�_has_surrogates�Policy�Compat32�compat32cs<eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Z�ZS)�_PolicyBasecsH|��D]:\}}t||�r.tt|��||�qtd�||jj���qdS�Nz*{!r} is an invalid keyword argument for {})	�items�hasattr�superr�__setattr__�	TypeError�format�	__class__�__name__)�self�kw�name�value�r��)/usr/lib64/python3.8/email/_policybase.py�__init__)s
��z_PolicyBase.__init__cCs*dd�|j��D�}d�|jjd�|��S)NcSsg|]\}}d�||��qS)z{}={!r})r)�.0rrrrr�
<listcomp>8s�z(_PolicyBase.__repr__.<locals>.<listcomp>z{}({})z, )�__dict__r
rrr�join)r�argsrrr�__repr__7s�z_PolicyBase.__repr__cKsr|j�|j�}|j��D]\}}t�|||�q|��D]4\}}t||�s^td�||jj	���t�|||�q8|Sr	)
r�__new__rr
�objectr
rrrr)rrZ	newpolicy�attrrrrr�clone<s
��z_PolicyBase.clonecCs,t||�rd}nd}t|�|jj|���dS)Nz'{!r} object attribute {!r} is read-onlyz!{!r} object has no attribute {!r})r�AttributeErrorrrr)rrr�msgrrrr
Ns
z_PolicyBase.__setattr__cCs|jf|j�S�N)r#r)r�otherrrr�__add__Usz_PolicyBase.__add__)	r�
__module__�__qualname__rrr#r
r(�
__classcell__rrrrrs
rcCs,|�dd�d}|�dd�d}|d|S)N�
�r)�rsplit�split)�docZ	added_docrrr�_append_doc^sr1cCs�|jr(|j�d�r(t|jdj|j�|_|j��D]V\}}|jr2|j�d�r2dd�|jD�D]*}tt||�d�}|r\t||j�|_q2q\q2|S)N�+rcss |]}|��D]
}|VqqdSr&)�mro)r�base�crrr�	<genexpr>hs
z%_extend_docstrings.<locals>.<genexpr>�__doc__)r7�
startswithr1�	__bases__rr
�getattr)�clsrr"r5r0rrr�_extend_docstringscsr<c@s�eZdZdZdZdZdZdZdZdd�Z	dd	�Z
d
d�Zej
dd
��Zej
dd��Zej
dd��Zej
dd��Zej
dd��ZdS)rFr,Z8bit�NNcCs|jr
|�|�||�dSr&)�raise_on_defect�register_defect�r�objZdefectrrr�
handle_defect�szPolicy.handle_defectcCs|j�|�dSr&)Zdefects�appendr@rrrr?�szPolicy.register_defectcCsdSr&r)rrrrr�header_max_count�szPolicy.header_max_countcCst�dSr&��NotImplementedError)r�sourcelinesrrr�header_source_parse�szPolicy.header_source_parsecCst�dSr&rE�rrrrrr�header_store_parse�szPolicy.header_store_parsecCst�dSr&rErIrrr�header_fetch_parse�s	zPolicy.header_fetch_parsecCst�dSr&rErIrrr�fold�s
zPolicy.foldcCst�dSr&rErIrrr�fold_binaryszPolicy.fold_binary)rr)r*r>�linesep�cte_type�max_line_length�mangle_from_Zmessage_factoryrBr?rD�abc�abstractmethodrHrJrKrLrMrrrrrps&2

	



)�	metaclassc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)rTcCs0t|t�s|St|�r(tj|tj|d�S|SdS)N�r�header_name)�
isinstance�strrr�Header�_charset�UNKNOWN8BITrIrrr�_sanitize_headers

�zCompat32._sanitize_headercCs>|d�dd�\}}|�d�d�|dd��}||�d�fS)Nr�:r-z 	�z
)r/�lstripr�rstrip)rrGrrrrrrH%szCompat32.header_source_parsecCs||fSr&rrIrrrrJ1szCompat32.header_store_parsecCs|�||�Sr&)r\rIrrrrK7szCompat32.header_fetch_parsecCs|j||dd�S)NT��sanitize)�_foldrIrrrrL>sz
Compat32.foldcCs"|j|||jdkd�}|�dd�S)NZ7bitra�ascii�surrogateescape)rcrO�encode)rrrZfoldedrrrrMHs	zCompat32.fold_binarycCs�g}|�d|�t|t�r\t|�rL|r<tj|tj|d�}qZ|�|�d}q`tj||d�}n|}|dk	r�d}|jdk	r||j}|�|j	|j
|d��|�|j
�d�|�S)Nz%s: rU)rVr)rN�
maxlinelenr^)rCrWrXrrrYrZr[rPrfrNr)rrrrb�parts�hrgrrrrcTs(
�


zCompat32._foldN)rr)r*rQr\rHrJrKrLrMrcrrrrrs
)rRZemailrrrZZemail.utilsr�__all__rr1r<�ABCMetarrrrrrr�<module>s�L
 fPK�"�\�>rx�,�,charset.cpython-38.opt-1.pycnu�[���U

e5d�B�@srddddgZddlmZddlZddlZddlmZddlmZd	Z	d
Z
dZdZd
Z
dZdZe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfde
e
dfe
e
dfe
ddfe
ddfe
ddfe
e
dfee
dfd�Zddddddddddddddddddddddd d
d!�Zd"d#dd$�Zd+d%d�Zd&d�Zd'd�Zd(d)�ZGd*d�d�ZdS),�Charset�	add_alias�add_charset�	add_codec�)�partialN)�errors)�encode_7or8bit�����us-asciizunknown-8bit�)NNN�iso-2022-jp�utf-8)�
iso-8859-1�
iso-8859-2�
iso-8859-3�
iso-8859-4�
iso-8859-9�iso-8859-10�iso-8859-13�iso-8859-14�iso-8859-15�iso-8859-16zwindows-1252Zvisciir
�big5�gb2312�euc-jp�	shift_jisrzkoi8-rrrrrrrrrrrrzks_c_5601-1987rzeuc-kr)�latin_1zlatin-1Zlatin_2zlatin-2Zlatin_3zlatin-3Zlatin_4zlatin-4Zlatin_5zlatin-5Zlatin_6zlatin-6Zlatin_7zlatin-7Zlatin_8zlatin-8Zlatin_9zlatin-9Zlatin_10zlatin-10�cp949�euc_jp�euc_kr�ascii�eucgb2312_cn�big5_tw)rrr
cCs"|tkrtd��|||ft|<dS)a>Add character set properties to the global registry.

    charset is the input character set, and must be the canonical name of a
    character set.

    Optional header_enc and body_enc is either Charset.QP for
    quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for
    the shortest of qp or base64 encoding, or None for no encoding.  SHORTEST
    is only valid for header_enc.  It describes how message headers and
    message bodies in the input charset are to be encoded.  Default is no
    encoding.

    Optional output_charset is the character set that the output should be
    in.  Conversions will proceed from input charset, to Unicode, to the
    output charset when the method Charset.convert() is called.  The default
    is to output in the same character set as the input.

    Both input_charset and output_charset must have Unicode codec entries in
    the module's charset-to-codec mapping; use add_codec(charset, codecname)
    to add codecs the module does not know about.  See the codecs module's
    documentation for more information.
    z!SHORTEST not allowed for body_encN)�SHORTEST�
ValueError�CHARSETS)�charsetZ
header_encZbody_enc�output_charset�r+�%/usr/lib64/python3.8/email/charset.pyrmscCs|t|<dS)z�Add a character set alias.

    alias is the alias name, e.g. latin-1
    canonical is the character set's canonical name, e.g. iso-8859-1
    N)�ALIASES)�aliasZ	canonicalr+r+r,r�scCs|t|<dS)a$Add a codec that map characters in the given charset to/from Unicode.

    charset is the canonical name of a character set.  codecname is the name
    of a Python codec, as appropriate for the second argument to the unicode()
    built-in, or to the encode() method of a Unicode string.
    N)�	CODEC_MAP)r)Z	codecnamer+r+r,r�scCs"|tkr|�dd�S|�|�SdS)Nr#�surrogateescape)�UNKNOWN8BIT�encode)�string�codecr+r+r,�_encode�sr5c@s\eZdZdZefdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)ra@	Map character sets to their email properties.

    This class provides information about the requirements imposed on email
    for a specific character set.  It also provides convenience routines for
    converting between character sets, given the availability of the
    applicable codecs.  Given a character set, it will do its best to provide
    information on how to use that character set in an email in an
    RFC-compliant way.

    Certain character sets must be encoded with quoted-printable or base64
    when used in email headers or bodies.  Certain character sets must be
    converted outright, and are not allowed in email.  Instances of this
    module expose the following information about a character set:

    input_charset: The initial character set specified.  Common aliases
                   are converted to their `official' email names (e.g. latin_1
                   is converted to iso-8859-1).  Defaults to 7-bit us-ascii.

    header_encoding: If the character set must be encoded before it can be
                     used in an email header, this attribute will be set to
                     Charset.QP (for quoted-printable), Charset.BASE64 (for
                     base64 encoding), or Charset.SHORTEST for the shortest of
                     QP or BASE64 encoding.  Otherwise, it will be None.

    body_encoding: Same as header_encoding, but describes the encoding for the
                   mail message's body, which indeed may be different than the
                   header encoding.  Charset.SHORTEST is not allowed for
                   body_encoding.

    output_charset: Some character sets must be converted before they can be
                    used in email headers or bodies.  If the input_charset is
                    one of them, this attribute will contain the name of the
                    charset output will be converted to.  Otherwise, it will
                    be None.

    input_codec: The name of the Python codec used to convert the
                 input_charset to Unicode.  If no conversion codec is
                 necessary, this attribute will be None.

    output_codec: The name of the Python codec used to convert Unicode
                  to the output_charset.  If no conversion codec is necessary,
                  this attribute will have the same value as the input_codec.
    cCs�z$t|t�r|�d�n
t|d�}Wntk
rBt�|��YnX|��}t�||�|_	t
�|j	ttdf�\}}}|s~|j	}||_
||_t�||�|_t�|j	|j	�|_t�|j|j�|_dS)Nr#)�
isinstance�strr2�UnicodeErrorrZCharsetError�lowerr-�get�
input_charsetr(r&�BASE64�header_encoding�
body_encodingr*r/Zinput_codec�output_codec)�selfr;ZhencZbencZconvr+r+r,�__init__�s,
�
��zCharset.__init__cCs
|j��S�N)r;r9�r@r+r+r,�__repr__�szCharset.__repr__cCst|�t|���kSrB)r7r9)r@�otherr+r+r,�__eq__�szCharset.__eq__cCs$|jtkrdS|jtkrdStSdS)aPReturn the content-transfer-encoding used for body encoding.

        This is either the string `quoted-printable' or `base64' depending on
        the encoding used, or it is a function in which case you should call
        the function with a single argument, the Message object being
        encoded.  The function should then set the Content-Transfer-Encoding
        header itself to whatever is appropriate.

        Returns "quoted-printable" if self.body_encoding is QP.
        Returns "base64" if self.body_encoding is BASE64.
        Returns conversion function otherwise.
        zquoted-printable�base64N)r>�QPr<rrCr+r+r,�get_body_encoding�s


zCharset.get_body_encodingcCs|jp
|jS)z�Return the output character set.

        This is self.output_charset if that is not None, otherwise it is
        self.input_charset.
        )r*r;rCr+r+r,�get_output_charsetszCharset.get_output_charsetcCs6|jpd}t||�}|�|�}|dkr*|S|�||�S)a�Header-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        this charset's `header_encoding`.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :return: The encoded string, with RFC 2047 chrome.
        r
N)r?r5�_get_encoder�
header_encode)r@r3r4�header_bytes�encoder_moduler+r+r,rLs


zCharset.header_encodecCs|jpd}t||�}|�|�}t|j|d�}|��}t|�t}g}	g}
t|�|}|D]�}|
�	|�t
�|
�}
|�t|
|��}||krX|
�
�|	s�|
s�|	�	d�n.|	r�dnd}t
�|
�}t||�}|	�	||��|g}
t|�|}qXt
�|
�}t||�}|	�	||��|	S)afHeader-encode a string by converting it first to bytes.

        This is similar to `header_encode()` except that the string is fit
        into maximum line lengths as given by the argument.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :param maxlengths: Maximum line length iterator.  Each element
            returned from this iterator will provide the next maximum line
            length.  This parameter is used as an argument to built-in next()
            and should never be exhausted.  The maximum line lengths should
            not count the RFC 2047 chrome.  These line lengths are only a
            hint; the splitter does the best it can.
        :return: Lines of encoded strings, each with RFC 2047 chrome.
        r
)r)N� r)r?r5rKrrLrJ�len�RFC2047_CHROME_LEN�next�append�EMPTYSTRING�join�
header_length�pop)r@r3Z
maxlengthsr4rMrN�encoderr)Zextra�linesZcurrent_line�maxlen�	characterZ	this_lineZlengthZ	separatorZjoined_liner+r+r,�header_encode_lines*s6








zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtj�|�}tj�|�}||krPtjStjSndSdSrB)r=r<�email�
base64mimerH�
quoprimimer&rV)r@rMZlen64Zlenqpr+r+r,rKhs


zCharset._get_encodercCs�|s|S|jtkr4t|t�r(|�|j�}tj�|�S|jt	krjt|t�rT|�|j�}|�
d�}tj�|�St|t�r�|�|j��
d�}|SdS)avBody-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        self.body_encoding.  If body_encoding is None, we assume the
        output charset is a 7bit encoding, so re-encoding the decoded
        string using the ascii codec produces the correct string version
        of the content.
        �latin1r#N)r>r<r6r7r2r*r]r^�body_encoderH�decoder_)r@r3r+r+r,raws	





zCharset.body_encodeN)�__name__�
__module__�__qualname__�__doc__�DEFAULT_CHARSETrArDrFrIrJrLr\rKrar+r+r+r,r�s+!>)NNN)�__all__�	functoolsrZemail.base64mimer]Zemail.quoprimimerZemail.encodersrrHr<r&rQrgr1rTr(r-r/rrrr5rr+r+r+r,�<module>s��� ��
	
PK�"�\P�"�{"{"generator.cpython-38.opt-2.pycnu�[���U

e5d�N�@s�dddgZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZdZd	Z
e�d
�Ze�dej�ZGdd�d�ZGd
d�de�ZdZGdd�de�Zeeejd��ZdeZejZdS)�	Generator�DecodedGenerator�BytesGenerator�N)�deepcopy)�StringIO�BytesIO)�_has_surrogates�_�
z
\r\n|\r|\nz^From c@s�eZdZd&dd�dd�Zdd�Zd'dd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
e
Zdd�Zdd�Zdd�Zd d!�Zed(d"d#��Zed$d%��ZdS))rN��policycCs6|dkr|dkrdn|j}||_||_||_||_dS)NT)�mangle_from_�_fp�
_mangle_from_�maxheaderlenr)�self�outfpr
rr�r�'/usr/lib64/python3.8/email/generator.py�__init__$szGenerator.__init__cCs|j�|�dS�N)r�write�r�srrrrDszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|�|j�|_d|_|�|j�|_|j}|j}zL||_||_|r�|�	�}|s�dt
�t
�
��}|�||j�|�
|�W5||_||_XdS)N)�linesep�Zmax_line_length�zFrom nobody )r�clonerr�_NL�_encode�_encoded_NLZ_EMPTY�_encoded_EMPTYZget_unixfrom�time�ctimer�_write)r�msg�unixfromrrZold_gen_policyZold_msg_policyZufromrrr�flattenHs,
zGenerator.flattencCs|j||jd|jd�S�Nr)�	__class__rr)r�fprrrrys
�zGenerator.clonecCst�Sr)r�rrrr�_new_buffer�szGenerator._new_buffercCs|Srrrrrrr�szGenerator._encodecCsT|sdSt�|�}|dd�D]}|�|�|�|j�q|drP|�|d�dS)N���)�NLCRE�splitrr)r�lines�linerrr�_write_lines�s

zGenerator._write_linescCs�|j}z"d|_|��|_}|�|�W5||_|j}|`X|r�t|�}|�d�dkrd|d|d<n|�d|d�|�d|d�t|dd�}|dkr�|�|�n||�|j�	|�
��dS)N�content-transfer-encodingr�Content-Transfer-Encoding�content-type��_write_headers)r�
_munge_cter,�	_dispatchr�getZreplace_header�getattrr7r�getvalue)rr%ZoldfpZ	munge_cteZsfp�methrrrr$�s&zGenerator._writecCst|��}|��}t�||f��dd�}t|d|d�}|dkrh|�dd�}t|d|d�}|dkrh|j}||�dS)N�-r	Z_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer;�
_writeBody)rr%�main�subZspecificr=Zgenericrrrr9�szGenerator._dispatchcCs6|��D]\}}|�|j�||��q|�|j�dSr)�	raw_itemsrrZfoldr�rr%�h�vrrrr7�szGenerator._write_headerscCs�|��}|dkrdSt|t�s.tdt|���t|j�r~|�d�}|dk	r~t|�}|d=|�	||�|��}|d|df|_
|jr�t�
d|�}|�|�dS)Nzstring payload expected: %s�charsetr3r5�>From )�get_payload�
isinstance�str�	TypeError�typer�_payloadZ	get_paramrZset_payloadr8r�fcrerFr2)rr%�payloadrKrrr�_handle_text�s$


�zGenerator._handle_textcCs�g}|��}|dkrg}n(t|t�r2|�|�dSt|t�sB|g}|D]6}|��}|�|�}|j|d|jd�|�	|�
��qF|��}|s�|j�
|�}|�|�}|�|�|jdk	r�|jr�t�d|j�}	n|j}	|�|	�|�|j�|�d||j�|�r|j�|�d��|D],}
|�|jd||j�|j�|
��q|�|jd|d|j�|jdk	�r�|j�r�t�d|j�}n|j}|�|�dS)NF�r&rrLz--r)rMrNrOr�listr,rr'r�appendr<Zget_boundaryr rB�_make_boundaryZset_boundary�preamblerrSrFr2r�pop�epilogue)rr%ZmsgtextsZsubparts�partr�g�boundaryZalltextrZZ	body_partr\rrr�_handle_multipartsJ







zGenerator._handle_multipartcCs0|j}|jdd�|_z|�|�W5||_XdS)Nrr)rrr`)rr%�prrr�_handle_multipart_signed<s
z"Generator._handle_multipart_signedcCs�g}|��D]t}|��}|�|�}|j|d|jd�|��}|�|j�}|rv|d|jkrv|�	|j�
|dd���q|�	|�q|j�|j�
|��dS)NFrVr-)
rMr,rr'rr<r/r r!rXrBrr)rr%Zblocksr]rr^�textr0rrr�_handle_message_delivery_statusGs
z)Generator._handle_message_delivery_statuscCs^|��}|�|�}|j}t|t�rD|j|�d�d|jd�|��}n
|�	|�}|j
�|�dS)NrFrV)r,rrRrNrWr'rMrr<rrr)rr%rr^rTrrr�_handle_message\s




zGenerator._handle_messagecCsvt�tj�}dt|d}|dkr(|S|}d}|�dt�|�dtj�}|�	|�sXqr|dt
|�}|d7}q0|S)Nz===============z==rz^--z(--)?$�.r6)�randomZ	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINE�searchrO)�clsrc�tokenr_�bZcounterZcrerrrrYus

zGenerator._make_boundarycCst�||�Sr)rl�compile�rpr�flagsrrrrk�szGenerator._compile_re)NN)FN)N)�__name__�
__module__�__qualname__rrr'rr,rr2r$r9r7rUrDr`rbrdre�classmethodrYrkrrrrrs,
� 
1'
:csLeZdZdd�Zdd�Zdd�Zdd�Z�fd	d
�ZeZe	dd��Z
�ZS)
rcCs|j�|�dd��dS)N�ascii�surrogateescape)rr�encoderrrrr�szBytesGenerator.writecCst�Sr)rr+rrrr,�szBytesGenerator._new_buffercCs
|�d�S�Nrz)r|rrrrr�szBytesGenerator._encodecCs8|��D]\}}|j�|j�||��q|�|j�dSr)rGrrrZfold_binaryrrHrrrr7�szBytesGenerator._write_headerscs\|jdkrdSt|j�rH|jjdksH|jr:t�d|j�|_|�|j�ntt	|��
|�dS)NZ7bitrL)rRrrZcte_typerrSrFr2�superrrU)rr%�r)rrrU�s
zBytesGenerator._handle_textcCst�|�d�|�Sr})rlrsr|rtrrrrk�szBytesGenerator._compile_re)rvrwrxrr,rr7rUrDryrk�
__classcell__rrrrr�s

zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s$eZdZddd�dd�Zdd�ZdS)rNrcCs.tj|||||d�|dkr$t|_n||_dSr()rr�_FMTrj)rrr
rZfmtrrrrr�s�zDecodedGenerator.__init__cCs�|��D]v}|��}|dkr2t|jdd�|d�q|dkr<qt|j|��|��|��|�d�|�dd�|�d	d
�d�|d�qdS)NrcF)�decode)�fileZ	multipartz
[no filename]zContent-Descriptionz[no description]r4z
[no encoding])rQ�maintypeZsubtype�filenameZdescription�encoding)	�walkr?�printrMrjZget_content_typer@�get_filenamer:)rr%r]r�rrrr9�s(���	�zDecodedGenerator._dispatch)NNN)rvrwrxrr9rrrrr�s�r6z%%0%dd)�__all__rlrhr"rg�copyr�iorrZemail.utilsrrA�NLrsr.rnrSrrr�r�len�reprriZ_widthrjrYrrrr�<module>s(

t3;PK�"�\~ov�VVheaderregistry.cpython-38.pycnu�[���U

e5dKQ�@szdZddlmZddlmZddlmZddlmZGdd�d�ZGdd	�d	�Z	Gd
d�de
�Zdd
�ZGdd�d�Z
Gdd�de
�ZGdd�d�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGd d!�d!�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'�ZGd(d)�d)�Zeeeeeeeeeeeeeeeeeeeed*�ZGd+d,�d,�Zd-S).a;Representing and manipulating email headers via custom objects.

This module provides an implementation of the HeaderRegistry API.
The implementation is designed to flexibly follow RFC5322 rules.

Eventually HeaderRegistry will be a public API, but it isn't yet,
and will probably change some before that happens.

�)�MappingProxyType)�utils)�errors)�_header_value_parserc@s^eZdZddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCs�d�td||||f��}d|ks(d|kr0td��|dk	r�|s@|rHtd��t�|�\}}|rjtd�||���|jrz|jd�|j}|j	}||_
||_||_dS)	a�Create an object representing a full email address.

        An address can have a 'display_name', a 'username', and a 'domain'.  In
        addition to specifying the username and domain separately, they may be
        specified together by using the addr_spec keyword *instead of* the
        username and domain keywords.  If an addr_spec string is specified it
        must be properly quoted according to RFC 5322 rules; an error will be
        raised if it is not.

        An Address object has display_name, username, domain, and addr_spec
        attributes, all of which are read-only.  The addr_spec and the string
        value of the object are both quoted according to RFC5322 rules, but
        without any Content Transfer Encoding.

        rN�
�
z8invalid arguments; address parts cannot contain CR or LFz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)
�join�filter�
ValueError�	TypeError�parserZ
get_addr_spec�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_specZinputsZa_s�rest�r�,/usr/lib64/python3.8/email/headerregistry.py�__init__s&�
zAddress.__init__cCs|jS�N�r�rrrrr<szAddress.display_namecCs|jSr)rr rrrr@szAddress.usernamecCs|jSr)rr rrrrDszAddress.domaincCsTt|j�}t|�t|tj�kr.t�|j�}n|j}|jrH|d|jS|sPdS|S)z�The addr_spec (username@domain) portion of the address, quoted
        according to RFC 5322 rules, but with no Content Transfer Encoding.
        �@�<>)�setr�lenrZ
DOT_ATOM_ENDS�quote_stringr)r�namesetZlprrrrHs
zAddress.addr_speccCsd�|jj|j|j|j�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrrr rrr�__repr__Xs�zAddress.__repr__cCs^t|j�}t|�t|tj�kr.t�|j�}n|j}|rX|jdkrFdn|j}d�||�S|jS)Nr"rz{} <{}>)r#rr$r�SPECIALSr%rr)rr&�disprrrr�__str__]s
zAddress.__str__cCs8t|�t|�krdS|j|jko6|j|jko6|j|jkS�NF)�typerrr�r�otherrrr�__eq__hs
�
�zAddress.__eq__)rrrN)r(�
__module__�__qualname__r�propertyrrrrr)r,r1rrrrrs
*



rc@sFeZdZddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs||_|rt|�nt�|_dS)aCreate an object representing an address group.

        An address group consists of a display_name followed by colon and a
        list of addresses (see Address) terminated by a semi-colon.  The Group
        is created by specifying a display_name and a possibly empty list of
        Address objects.  A Group can also be used to represent a single
        address that is not in a group, which is convenient when manipulating
        lists that are a combination of Groups and individual Addresses.  In
        this case the display_name should be set to None.  In particular, the
        string representation of a Group whose display_name is None is the same
        as the Address object, if there is one and only one Address object in
        the addresses list.

        N)r�tuple�
_addresses)rr�	addressesrrrrrszGroup.__init__cCs|jSrrr rrrr�szGroup.display_namecCs|jSr)r7r rrrr8�szGroup.addressescCsd�|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rr'r(rr8r rrrr)�s
�zGroup.__repr__cCs�|jdkr&t|j�dkr&t|jd�S|j}|dk	r\t|�}t|�t|tj�kr\t�|�}d�dd�|jD��}|r~d|n|}d�	||�S)N�r�, css|]}t|�VqdSr��str)�.0�xrrr�	<genexpr>�sz Group.__str__.<locals>.<genexpr>� z{}:{};)
rr$r8r<r#rr*r%r
r)rr+r&Zadrstrrrrr,�s
z
Group.__str__cCs,t|�t|�krdS|j|jko*|j|jkSr-)r.rr8r/rrrr1�s

�zGroup.__eq__)NN)
r(r2r3rr4rr8r)r,r1rrrrr5ps


r5c@sTeZdZdZdd�Zdd�Zedd��Zedd	��Zd
d�Z	e
dd
��Zdd�ZdS)�
BaseHeadera|Base class for message headers.

    Implements generic behavior and provides tools for subclasses.

    A subclass must define a classmethod named 'parse' that takes an unfolded
    value string and a dictionary as its arguments.  The dictionary will
    contain one key, 'defects', initialized to an empty list.  After the call
    the dictionary must contain two additional keys: parse_tree, set to the
    parse tree obtained from parsing the header, and 'decoded', set to the
    string value of the idealized representation of the data from the value.
    (That is, encoded words are decoded, and values that have canonical
    representations are so represented.)

    The defects key is intended to collect parsing defects, which the message
    parser will subsequently dispose of as appropriate.  The parser should not,
    insofar as practical, raise any errors.  Defects should be added to the
    list instead.  The standard header parsers register defects for RFC
    compliance issues, for obsolete RFC syntax, and for unrecoverable parsing
    errors.

    The parse method may add additional keys to the dictionary.  In this case
    the subclass must define an 'init' method, which will be passed the
    dictionary as its keyword arguments.  The method should use (usually by
    setting them as the value of similarly named attributes) and remove all the
    extra keys added by its parse method, and then use super to call its parent
    class with the remaining arguments and keywords.

    The subclass should also make sure that a 'max_count' attribute is defined
    that is either None or 1. XXX: need to better define this API.

    cCs\dgi}|�||�t�|d�r4t�|d�|d<t�||d�}|d=|j|f|�|S)N�defects�decoded)�parserZ_has_surrogates�	_sanitizer<�__new__�init)�cls�name�value�kwdsrrrrrF�szBaseHeader.__new__cCs||_||_||_dSr)�_name�_parse_tree�_defects)rrI�
parse_treerBrrrrG�szBaseHeader.initcCs|jSr)rLr rrrrI�szBaseHeader.namecCs
t|j�Sr)r6rNr rrrrB�szBaseHeader.defectscCst|jj|jjt|�f|jfSr)�_reconstruct_headerr'r(�	__bases__r<�__dict__r rrr�
__reduce__�s��zBaseHeader.__reduce__cCst�||�Sr)r<rF)rHrJrrr�_reconstruct�szBaseHeader._reconstructc	Cs`t�t�t�|jd�t�dd�g�g�}|jrH|�t�t�dd�g��|�|j�|j	|d�S)atFold header according to policy.

        The parsed representation of the header is folded according to
        RFC5322 rules, as modified by the policy.  If the parse tree
        contains surrogateescaped bytes, the bytes are CTE encoded using
        the charset 'unknown-8bit".

        Any non-ASCII characters in the parse tree are CTE encoded using
        charset utf-8. XXX: make this a policy setting.

        The returned value is an ASCII-only string possibly containing linesep
        characters, and ending with a linesep character.  The string includes
        the header name and the ': ' separator.

        zheader-name�:z
header-sepr@Zfws)�policy)
rZHeaderZHeaderLabelZ
ValueTerminalrIrM�appendZCFWSListZWhiteSpaceTerminal�fold)rrV�headerrrrrX�s
���zBaseHeader.foldN)
r(r2r3�__doc__rFrGr4rIrBrS�classmethodrTrXrrrrrA�s 




rAcCst||i��|�Sr)r.rT)Zcls_name�basesrJrrrrP
srPc@s&eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs"|�|�|d<t|d�|d<dS)NrOrC)�value_parserr<�rHrJrKrrrrDszUnstructuredHeader.parse)
r(r2r3�	max_count�staticmethodr�get_unstructuredr^r[rDrrrrr]s
r]c@seZdZdZdS)�UniqueUnstructuredHeaderr9N�r(r2r3r`rrrrrcsrccsFeZdZdZdZeej�Ze	dd��Z
�fdd�Zedd��Z
�ZS)	�
DateHeadera�Header whose value consists of a single timestamp.

    Provides an additional attribute, datetime, which is either an aware
    datetime using a timezone, or a naive datetime if the timezone
    in the input string is -0000.  Also accepts a datetime as input.
    The 'value' attribute is the normalized form of the timestamp,
    which means it is the output of format_datetime on the datetime.
    NcCsz|s6|d�t���d|d<d|d<t��|d<dSt|t�rJt�|�}||d<t�	|d�|d<|�
|d�|d<dS)NrB�datetimerrCrO)rWrZHeaderMissingRequiredValuerZ	TokenList�
isinstancer<rZparsedate_to_datetimeZformat_datetimer^r_rrrrD.s

zDateHeader.parsecs|�d�|_t�j||�dS)Nrf)�pop�	_datetime�superrG�r�args�kw�r'rrrG<szDateHeader.initcCs|jSr)rir rrrrf@szDateHeader.datetime)r(r2r3rZr`rarrbr^r[rDrGr4rf�
__classcell__rrrnrres	


rec@seZdZdZdS)�UniqueDateHeaderr9NrdrrrrrpEsrpcsPeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�ZS)�
AddressHeaderNcCst�|�\}}|rtd��|S)Nzthis should not happen)rZget_address_list�AssertionError)rJ�address_listrrrr^NszAddressHeader.value_parsercCs�t|t�rV|�|�|d<}g}|jD]"}|�t|jdd�|jD���q&t|j	�}n"t
|d�sf|g}dd�|D�}g}||d<||d<d�d	d�|D��|d
<d|kr�|�|d
�|d<dS)NrOcSs*g|]"}t|jpd|jpd|jp"d��qS)r)rrrr)r=Zmbrrr�
<listcomp>]s
�
�z'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs&g|]}t|d�std|g�n|�qS)r8N)�hasattrr5�r=�itemrrrrtfs��groupsrBr:cSsg|]}t|��qSrr;rwrrrrtlsrC)rgr<r^r8rWr5rZ
all_mailboxes�listrrvr
)rHrJrKrsryZaddrrBrrrrDTs*


��
�zAddressHeader.parsecs(t|�d��|_d|_t�j||�dS)Nry)r6rh�_groupsr7rjrGrkrnrrrGpszAddressHeader.initcCs|jSr)r{r rrrryuszAddressHeader.groupscCs&|jdkr tdd�|jD��|_|jS)Ncss|]}|jD]
}|VqqdSr)r8)r=�group�addressrrrr?|s�z*AddressHeader.addresses.<locals>.<genexpr>)r7r6r{r rrrr8ys
zAddressHeader.addresses)
r(r2r3r`rar^r[rDrGr4ryr8rorrrnrrqJs


rqc@seZdZdZdS)�UniqueAddressHeaderr9Nrdrrrrr~�sr~c@seZdZedd��ZdS)�SingleAddressHeadercCs(t|j�dkrtd�|j���|jdS)Nr9z9value of single address header {} is not a single addressr)r$r8rrrIr rrrr}�s
�zSingleAddressHeader.addressN)r(r2r3r4r}rrrrr�src@seZdZdZdS)�UniqueSingleAddressHeaderr9Nrdrrrrr��sr�csZeZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�ZS)�MIMEVersionHeaderr9cCs�|�|�|d<}t|�|d<|d�|j�|jdkr<dn|j|d<|j|d<|jdk	rtd�|d|d�|d<nd|d<dS)NrOrCrB�major�minorz{}.{}�version)r^r<�extendrr�r�r�rHrJrKrOrrrrD�s

zMIMEVersionHeader.parsecs6|�d�|_|�d�|_|�d�|_t�j||�dS)Nr�r�r�)rh�_version�_major�_minorrjrGrkrnrrrG�szMIMEVersionHeader.initcCs|jSr)r�r rrrr��szMIMEVersionHeader.majorcCs|jSr)r�r rrrr��szMIMEVersionHeader.minorcCs|jSr)r�r rrrr��szMIMEVersionHeader.version)r(r2r3r`rarZparse_mime_versionr^r[rDrGr4r�r�r�rorrrnrr��s



r�cs8eZdZdZedd��Z�fdd�Zedd��Z�Z	S)�ParameterizedMIMEHeaderr9cCsZ|�|�|d<}t|�|d<|d�|j�|jdkrBi|d<ndd�|jD�|d<dS)NrOrCrB�paramscSs&i|]\}}t�|���t�|��qSr)rrE�lower)r=rIrJrrr�
<dictcomp>�s�z1ParameterizedMIMEHeader.parse.<locals>.<dictcomp>)r^r<r�rr�r�rrrrD�s

�zParameterizedMIMEHeader.parsecs|�d�|_t�j||�dS)Nr�)rh�_paramsrjrGrkrnrrrG�szParameterizedMIMEHeader.initcCs
t|j�Sr)rr�r rrrr��szParameterizedMIMEHeader.params)
r(r2r3r`r[rDrGr4r�rorrrnrr��s
r�csJeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�ZS)	�ContentTypeHeadercs2t�j||�t�|jj�|_t�|jj�|_dSr)	rjrGrrErM�maintype�	_maintype�subtype�_subtyperkrnrrrG�szContentTypeHeader.initcCs|jSr)r�r rrrr��szContentTypeHeader.maintypecCs|jSr)r�r rrrr��szContentTypeHeader.subtypecCs|jd|jS)N�/)r�r�r rrr�content_type�szContentTypeHeader.content_type)
r(r2r3rarZparse_content_type_headerr^rGr4r�r�r�rorrrnrr��s


r�cs2eZdZeej�Z�fdd�Zedd��Z	�Z
S)�ContentDispositionHeadercs2t�j||�|jj}|dkr"|nt�|�|_dSr)rjrGrM�content_dispositionrrE�_content_disposition)rrlrmZcdrnrrrG�szContentDispositionHeader.initcCs|jSr)r�r rrrr��sz,ContentDispositionHeader.content_disposition)r(r2r3rarZ parse_content_disposition_headerr^rGr4r�rorrrnrr��s
r�csBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�ContentTransferEncodingHeaderr9cCs2|�|�|d<}t|�|d<|d�|j�dS�NrOrCrB�r^r<r�rr�rrrrDsz#ContentTransferEncodingHeader.parsecs"t�j||�t�|jj�|_dSr)rjrGrrErM�cte�_cterkrnrrrGsz"ContentTransferEncodingHeader.initcCs|jSr)r�r rrrr�sz!ContentTransferEncodingHeader.cte)r(r2r3r`rarZ&parse_content_transfer_encoding_headerr^r[rDrGr4r�rorrrnrr��s

r�c@s&eZdZdZeej�Zedd��Z	dS)�MessageIDHeaderr9cCs2|�|�|d<}t|�|d<|d�|j�dSr�r�r�rrrrDszMessageIDHeader.parseN)
r(r2r3r`rarZparse_message_idr^r[rDrrrrr�s
r�)Zsubject�datezresent-datez	orig-dateZsenderz
resent-sender�toz	resent-toZccz	resent-ccZbccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-typezcontent-dispositionzcontent-transfer-encodingz
message-idc@s8eZdZdZeedfdd�Zdd�Zdd�Zd	d
�Z	dS)�HeaderRegistryz%A header_factory and header registry.TcCs&i|_||_||_|r"|j�t�dS)a�Create a header_factory that works with the Policy API.

        base_class is the class that will be the last class in the created
        header class's __bases__ list.  default_class is the class that will be
        used if "name" (see __call__) does not appear in the registry.
        use_default_map controls whether or not the default mapping of names to
        specialized classes is copied in to the registry when the factory is
        created.  The default is True.

        N)�registry�
base_class�
default_class�update�_default_header_map)rr�r�Zuse_default_maprrrr9s
zHeaderRegistry.__init__cCs||j|��<dS)zLRegister cls as the specialized class for handling "name" headers.

        N)r�r��rrIrHrrr�map_to_typeKszHeaderRegistry.map_to_typecCs,|j�|��|j�}td|j||jfi�S)N�_)r��getr�r�r.r(r�r�rrr�__getitem__QszHeaderRegistry.__getitem__cCs||||�S)a�Create a header instance for header 'name' from 'value'.

        Creates a header instance by creating a specialized class for parsing
        and representing the specified header by combining the factory
        base_class with a specialized class from the registry or the
        default_class, and passing the name and value to the constructed
        class's constructor.

        r)rrIrJrrr�__call__Us
zHeaderRegistry.__call__N)
r(r2r3rZrAr]rr�r�r�rrrrr�5s�
r�N)rZ�typesrZemailrrrrrr5r<rArPr]rcrerprqr~rr�r�r�r�r�r�r�r�r�rrrr�<module>sX	`6d'7
%�PK�"�\�iterators.cpython-38.opt-2.pycnu�[���U

e5dW�@sHdddgZddlZddlmZdd�Zd
dd�Zdd
d�Zddd�ZdS)�body_line_iterator�typed_subpart_iterator�walk�N)�StringIOccs.|V|��r*|��D]}|��EdHqdS�N)�is_multipart�get_payloadr)�self�subpart�r�'/usr/lib64/python3.8/email/iterators.pyrsFccs6|��D](}|j|d�}t|t�rt|�EdHqdS)N)�decode)rr�
isinstance�strr)�msgr
r
Zpayloadrrrr"s
�textccs8|��D]*}|��|kr|dks,|��|kr|VqdSr)rZget_content_maintypeZget_content_subtype)rZmaintypeZsubtyper
rrrr-scCs�|dkrtj}d|d}t||��d|d�|rJtd|��|d�n
t|d�|��r||��D]}t|||d|�qddS)N� ��)�end�filez [%s])r�)�sys�stdout�printZget_content_typeZget_default_typerr�
_structure)r�fp�levelZinclude_defaultZtabr
rrrr;s
r)F)rN)NrF)�__all__r�iorrrrrrrrr�<module>s�

PK�"�\4��#ooquoprimime.cpython-38.opt-2.pycnu�[���U

e5d�&�
@sTdddddddddd	g
Zd
dlZd
dlmZmZmZd
ZdZdZdd�e	d�D�Z
e
dd�Ze
dd�Zde�
d�e�
d�D]Zee�ee<q�deed�<dD]Zee�ee<q�dd�Zdd�Zdd�Zdd�Zd+dd�Zd d	�Zd!d�Zd,d#d�Zedd�Zd$D]Zee�ee<�q
d%efd&d�Zefd'd�ZeZeZd(d)�Zd*d�ZdS)-�body_decode�body_encode�body_length�decode�decodestring�
header_decode�
header_encode�
header_length�quote�unquote�N)�
ascii_letters�digits�	hexdigits�
�
�cCsg|]}d|�qS)z=%02X�)�.0�crr�(/usr/lib64/python3.8/email/quoprimime.py�
<listcomp>7sr�s-!*+/�ascii�_� s_ !"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~	cCst|�t|kS�N)�chr�_QUOPRI_HEADER_MAP��octetrrr�header_checkJsr cCst|�t|kSr)r�_QUOPRI_BODY_MAPrrrr�
body_checkOsr"cCstdd�|D��S)Ncss|]}tt|�VqdSr)�lenr�rrrrr�	<genexpr>^sz header_length.<locals>.<genexpr>��sum��	bytearrayrrrrTs
cCstdd�|D��S)Ncss|]}tt|�VqdSr)r#r!r$rrrr%hszbody_length.<locals>.<genexpr>r&r(rrrrascCsft|t�st|�}|s&|�|���n<t|d�t|�|krT|d||7<n|�|���dS)N���)�
isinstance�strr�append�lstripr#)�L�s�maxlenZextrarrr�_max_appendks
r2cCstt|dd�d��S)N���)r�int�r0rrrr
vscCstt|�Sr)�_QUOPRI_MAP�ord)rrrrr	{s�
iso-8859-1cCs$|sdS|�d��t�}d||fS)Nr�latin1z=?%s?q?%s?=)r�	translater)Zheader_bytes�charset�encodedrrrrss
�Lc
Cs�|dkrtd��|s|S|�t�}d|}|d}g}|j}|��D�]}d}t|�d|}	||	kr�||}
||
ddkr�||||
d��|
d}q^||
ddkr�||||
��|
d}q^||||
�d�|
}q^|�rR|ddk�rR||	}|d	k�rt|d�}n(|dk�r,|d|}n|t|d�}|||d�|�qD|||d��qD|dtk�rz|d
�|�|�S)N�zmaxlinelen must be at least 4�=r3r�r*z 	r4r)	�
ValueErrorr<�_QUOPRI_BODY_ENCODE_MAPr-�
splitlinesr#r	�CRLF�join)
ZbodyZ
maxlinelen�eolZ
soft_breakZmaxlinelen1Zencoded_bodyr-�line�startZ	laststart�stopZroom�qrrrr�sD




cCs|s|Sd}|��D]�}|��}|s.||7}qd}t|�}||kr||}|dkrd||7}|d7}nv|d|kr||d7}q:n^|d|kr�||dtkr�||dtkr�|t|||d��7}|d7}n||7}|d7}||kr:||7}q:q|ddk�r|�|��r|dd�}|S)	NrrrAr3rBr4r*r)rE�rstripr#rr
�endswith)r>rHZdecodedrI�i�nrrrrr�s8
,
cCs|�d�}t|�S)Nr)�groupr
)�matchr0rrr�_unquote_matchs
rScCs |�dd�}tjdt|tjd�S)Nrrz=[a-fA-F0-9]{2})�flags)�replace�re�subrS�ASCIIr7rrrr#s)r)r:) �__all__rV�stringrr
rrF�NLZEMPTYSTRING�ranger8rr!�encoderrr9r r"rrr2r
r	rrDrrrrrSrrrrr�<module>sP�




O0PK�"�\@��}"}"feedparser.cpython-38.opt-2.pycnu�[���U

e5d�X�@s�ddgZddlZddlmZddlmZddlmZddlm	Z	e�
d�Ze�
d	�Ze�
d
�Z
e�
d	�Ze�
d�ZdZd
Ze�ZGdd�de�ZGdd�d�ZGdd�de�ZdS)�
FeedParser�BytesFeedParser�N)�errors)�compat32)�deque)�StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])��
c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�BufferedSubFilecCs$tdd�|_t�|_g|_d|_dS)Nr)�newlineF)r�_partialr�_lines�	_eofstack�_closed��self�r�(/usr/lib64/python3.8/email/feedparser.py�__init__5szBufferedSubFile.__init__cCs|j�|�dS�N)r�append)rZpredrrr�push_eof_matcher@sz BufferedSubFile.push_eof_matchercCs
|j��Sr)r�poprrrr�pop_eof_matcherCszBufferedSubFile.pop_eof_matchercCs<|j�d�|�|j���|j�d�|j��d|_dS)NrT)r�seek�	pushlines�	readlines�truncaterrrrr�closeFs

zBufferedSubFile.closecCsL|js|jrdStS|j��}t|j�D]}||�r(|j�|�dSq(|S�Nr)r
r�NeedMoreData�popleft�reversedr�
appendleft)r�lineZateofrrr�readlineNs
zBufferedSubFile.readlinecCs|j�|�dSr)r
r#�rr$rrr�
unreadline`szBufferedSubFile.unreadlinecCsx|j�|�d|kr d|kr dS|j�d�|j��}|j�d�|j��|d�d�sj|j�|���|�|�dS)Nr	�
r���)r�writerrr�endswithrr)r�data�partsrrr�pushes

zBufferedSubFile.pushcCs|j�|�dSr)r
�extend)r�linesrrrrzszBufferedSubFile.pushlinescCs|Srrrrrr�__iter__}szBufferedSubFile.__iter__cCs|��}|dkrt�|Sr)r%�
StopIterationr&rrr�__next__�szBufferedSubFile.__next__N)
�__name__�
__module__�__qualname__rrrrr%r'r.rr1r3rrrrr
-sr
c@s\eZdZded�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)rN��policycCs�||_d|_|dkr<|jdkr2ddlm}||_qn|j|_n2||_z||jd�Wntk
rld|_YnXt�|_g|_	|�
�j|_d|_
d|_d|_dS)NFr)�Messager7T)r8�_old_style_factoryZmessage_factoryZ
email.messager9�_factory�	TypeErrorr
�_input�	_msgstack�	_parsegenr3�_parse�_cur�_last�_headersonly)rr;r8r9rrrr�s$

zFeedParser.__init__cCs
d|_dS)NT)rCrrrr�_set_headersonly�szFeedParser._set_headersonlycCs|j�|�|��dSr)r=r.�_call_parse�rr,rrr�feed�szFeedParser.feedcCs&z|��Wntk
r YnXdSr)r@r2rrrrrE�szFeedParser._call_parsecCsH|j��|��|��}|��dkrD|��sDt��}|j�	||�|S)N�	multipart)
r=rrE�_pop_message�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr8�
handle_defect)r�root�defectrrrr�s
�zFeedParser.closecCsn|jr|��}n|j|jd�}|jr<|j��dkr<|�d�|jrR|jd�|�|j�|�||_||_	dS)Nr7zmultipart/digestzmessage/rfc822r))
r:r;r8rA�get_content_typeZset_default_typer>ZattachrrB)r�msgrrr�_new_message�s

zFeedParser._new_messagecCs(|j��}|jr|jd|_nd|_|S)Nr))r>rrA)r�retvalrrrrI�s

zFeedParser._pop_messageccs|��g}|jD]Z}|tkr&tVqt�|�sbt�|�s^t��}|j�	|j
|�|j�|�qn|�|�q|�
|�|jr�g}|j��}|tkr�tVq�|dkr�q�|�|�q�|j
�t�|��dS|j
��dk�r�|j�tj�|��D]}|tk�rtVq��qq�|��}|j��|j��}|tk�rDtV�q�qD�q|j��}|tk�rjtV�qD�qj�qD|dk�rx�q�|j�|�q�dS|j
��dk�r�|��D] }|tk�r�tV�q��qĐq�|��dS|j
��dk�r�|j
��}|dk�rRt��}|j�	|j
|�g}|jD]$}|tk�r.tV�q|�|��q|j
�t�|��dSt|j
�dd����dk�r�t��}|j�	|j
|�d|}t� d	t�!|�d
�}	d}
g}d}d}
|j��}|tk�r�tV�q�|dk�r�q�|	�|�}|�r�|�"d
��rd}
|�"d�}�q�|
�rr|�r^|d}t#�$|�}|�rP|dt%|�"d���|d<t�|�|j
_&d}
|j�|��q�|j��}|tk�r�tV�qr|	�|�}|�sr|j�|��q��qr|j�|	j�|��D] }|tk�r�tV�q��q�q�|j'��dk�rT|j'j(}|dk�rd|j'_(n:|dk	�r�t#�$|�}|�r�t%|�"d��}|d|�|j'_(nD|j'j)}t*|t��r�t#�$|�}|�r�|dt%|�"d���}||j'_)|j��|��|j
|_'n
|�|��q�|
�r*t�+�}|j�	|j
|�|j
�t�|��g}|jD]}|tk�r�tV�q��q�t�|�|j
_(dS|
�sLt�,�}|j�	|j
|�dS|�rZdg}ng}|jD]$}|tk�r|tV�qd|�|��qd|�r�|d}t-�|�}|�r�|t%|�"d��d�|d<t�|�|j
_(dSg}|jD]$}|tk�r�tV�q�|�|��q�|j
�t�|��dS)Nrzmessage/delivery-status�messagerHzcontent-transfer-encoding�8bit)Z7bitrSZbinaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr)r).rPr=r �headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr8rKrAr'r�_parse_headersrCr%Zset_payload�EMPTYSTRING�joinrNrr?rIrrJZget_boundaryZNoBoundaryInMultipartDefect�str�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�search�len�preamblerB�epilogueZ_payload�
isinstanceZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr$rMr0rQrO�boundaryZ	separatorZ
boundaryreZcapturing_preamblerfrUZclose_boundary_seen�moZlastlineZeolmorgrTZpayload�	firstlineZbolmorrrr?�s`

















���
























zFeedParser._parsegenc	CsXd}g}t|�D�]&\}}|ddkrR|sFt�|�}|j�|j|�q|�|�q|rt|jj|j�|��dg}}|�	d�r�|dkr�t
�|�}|r�|dt|�
d���}|j�|�qn<|t|�dkr�|j�|�dSt�|�}|jj�|�q|�d�}|dk�r&t�d�}|jj�|�q|d|�}|g}q|�rT|jj|j�|��dS)Nrrz 	zFrom ��:zMissing header name.)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr8rKrArZset_rawZheader_source_parse�
startswithrcrdrerbZset_unixfromr=r'ZMisplacedEnvelopeHeaderDefectZdefects�findZInvalidHeaderDefect)	rr0Z
lastheaderZ	lastvalue�linenor$rMrk�irrrrY�sF








zFeedParser._parse_headers)N)
r4r5r6rrrDrGrErrPrIr?rYrrrrr�s

~cseZdZ�fdd�Z�ZS)rcst��|�dd��dS)N�ascii�surrogateescape)�superrG�decoderF��	__class__rrrGszBytesFeedParser.feed)r4r5r6rG�
__classcell__rrrxrrs)�__all__r_ZemailrZemail._policybaser�collectionsr�iorr`rXrircZNLCRE_crackrVrZ�NL�objectr r
rrrrrr�<module>s&




[PK�"�\��-���errors.cpython-38.opt-1.pycnu�[���U

e5d�
�@s8dZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�Z	Gdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�Zd'S)(a�distutils.errors

Provides exceptions used by the Distutils modules.  Note that Distutils
modules may raise standard exceptions; in particular, SystemExit is
usually raised for errors that are obviously the end-user's fault
(eg. bad command-line arguments).

This module is safe to use in "from ... import *" mode; it only exports
symbols whose names start with "Distutils" and end with "Error".c@seZdZdZdS)�DistutilsErrorzThe root of all Distutils evil.N��__name__�
__module__�__qualname__�__doc__�rr�(/usr/lib64/python3.8/distutils/errors.pyrsrc@seZdZdZdS)�DistutilsModuleErrorz�Unable to load an expected module, or to find an expected class
    within some module (in particular, command modules and classes).Nrrrrrr	sr	c@seZdZdZdS)�DistutilsClassErrorz�Some command class (or possibly distribution class, if anyone
    feels a need to subclass Distribution) is found not to be holding
    up its end of the bargain, ie. implementing some part of the
    "command "interface.Nrrrrrr
sr
c@seZdZdZdS)�DistutilsGetoptErrorz7The option table provided to 'fancy_getopt()' is bogus.Nrrrrrrsrc@seZdZdZdS)�DistutilsArgErrorzaRaised by fancy_getopt in response to getopt.error -- ie. an
    error in the command line usage.Nrrrrrrsrc@seZdZdZdS)�DistutilsFileErrorz�Any problems in the filesystem: expected file not found, etc.
    Typically this is for problems that we detect before OSError
    could be raised.Nrrrrrr
$sr
c@seZdZdZdS)�DistutilsOptionErrora�Syntactic/semantic errors in command options, such as use of
    mutually conflicting options, or inconsistent options,
    badly-spelled values, etc.  No distinction is made between option
    values originating in the setup script, the command line, config
    files, or what-have-you -- but if we *know* something originated in
    the setup script, we'll raise DistutilsSetupError instead.Nrrrrrr*src@seZdZdZdS)�DistutilsSetupErrorzqFor errors that can be definitely blamed on the setup script,
    such as invalid keyword arguments to 'setup()'.Nrrrrrr3src@seZdZdZdS)�DistutilsPlatformErrorz�We don't know how to do something on the current platform (but
    we do know how to do it on some platform) -- eg. trying to compile
    C files on a platform not supported by a CCompiler subclass.Nrrrrrr8src@seZdZdZdS)�DistutilsExecErrorz`Any problems executing an external program (such as the C
    compiler, when compiling C files).Nrrrrrr>src@seZdZdZdS)�DistutilsInternalErrorzoInternal inconsistencies or impossibilities (obviously, this
    should never be seen if the code is working!).NrrrrrrCsrc@seZdZdZdS)�DistutilsTemplateErrorz%Syntax error in a file list template.NrrrrrrHsrc@seZdZdZdS)�DistutilsByteCompileErrorzByte compile error.NrrrrrrKsrc@seZdZdZdS)�CCompilerErrorz#Some compile/link operation failed.NrrrrrrOsrc@seZdZdZdS)�PreprocessErrorz.Failure to preprocess one or more C/C++ files.NrrrrrrRsrc@seZdZdZdS)�CompileErrorz2Failure to compile one or more C/C++ source files.NrrrrrrUsrc@seZdZdZdS)�LibErrorzKFailure to create a static library from one or more C/C++ object
    files.NrrrrrrXsrc@seZdZdZdS)�	LinkErrorz]Failure to link one or more C/C++ object files into an executable
    or shared library file.Nrrrrrr\src@seZdZdZdS)�UnknownFileErrorz(Attempt to process an unknown file type.Nrrrrrr`srN)r�	Exceptionrr	r
rrr
rrrrrrrrrrrrrrrrr�<module>s&
	PK�"�\�إ����message.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZddgZddlZddlZddlZddlmZmZddlm	Z	ddlm
Z
ddlmZm
Z
dd	lmZdd
lmZejZdZe�d�Zd
d�Zddd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZdS)z8Basic message object for the email package object model.�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�Policy�compat32��charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]cCs4t|��d�\}}}|s$|��dfS|��|��fS)N�;)�str�	partition�strip)�param�a�sep�b�r�%/usr/lib64/python3.8/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}t�|d|d|d�}d||fSz|�d�Wn6tk
r�|d7}t�|dd	�}d||fYSX|s�t�|�r�d
|t�	|�fSd||fSn|SdS)a~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.  If value is a
    three tuple (charset, language, value), it will be encoded according
    to RFC2231 rules.  If it contains non-ascii characters it will likewise
    be encoded according to RFC2231 rules, using the utf-8 charset and
    a null language.
    Nr�*���%s=%s�asciizutf-8�z%s="%s")
�len�
isinstance�tuplerZencode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer%rrr�_formatparam's	
r'cCs�dt|�}g}|dd�dkr�|dd�}|�d�}|dkrp|�dd|�|�dd|�drp|�d|d�}q6|dkr�t|�}|d|�}d|kr�|�d�}|d|�����d||dd���}|�|���||d�}q|S)Nr
rr�"z\"r�=)r�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
(
,r3cCs4t|t�r&|d|dt�|d�fSt�|�SdS)Nrrr)rr r�unquote)r&rrr�
_unquotevalue]s
r5c@s�eZdZdZefdd�Zdd�Zddd	d
�Zdd�Zded
d�Z	dd�Z
dd�Zdd�Zdd�Z
dfdd�Zdgdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zdhd1d2�Zd3d4�Zd5d6�Zdid7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&djdKdL�Z'dkdMdN�Z(dldQdR�Z)dmdSdT�Z*dndUdV�Z+dodWdX�Z,dpdYdZ�Z-d[d\�Z.dqd]d^�Z/drd_d`�Z0dadb�Z1ddcl2m3Z3dS)sra�Basic message object.

    A message object is defined as something that has a bunch of RFC 2822
    headers and a payload.  It may optionally have an envelope header
    (a.k.a. Unix-From or From_ header).  If the message is a container (i.e. a
    multipart or a message/rfc822), then the payload is a list of Message
    objects, otherwise it is a string.

    Message objects implement part of the `mapping' interface, which assumes
    there is exactly one occurrence of the header per message.  Some headers
    do in fact appear multiple times (e.g. Received) and for those headers,
    you must use the explicit API to set or get all the headers.  Not all of
    the mapping methods are implemented.
    cCs:||_g|_d|_d|_d|_d|_|_g|_d|_dS)N�
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr7rrr�__init__xszMessage.__init__cCs|��S)z9Return the entire formatted message as a string.
        )�	as_string�r>rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|��S)a�Return the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  For backward compatibility reasons, if maxheaderlen is
        not specified it defaults to 0, so you must override it explicitly
        if you want a different maxheaderlen.  'policy' is passed to the
        Generator instance used to serialize the message; if it is not
        specified the policy associated with the message instance is used.

        If the message object contains binary data that is not encoded
        according to RFC standards, the non-compliant data will be replaced by
        unicode "unknown character" code points.
        r)�	GeneratorNF)�mangle_from_�maxheaderlenr7��unixfrom)�email.generatorrCr7r�flatten�getvalue)r>rGrEr7rC�fp�grrrr@�s�zMessage.as_stringcCs|��S)z?Return the entire formatted message as a bytes object.
        )�as_bytesrArrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|��S)aJReturn the entire formatted message as a bytes object.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  'policy' is passed to the BytesGenerator instance used to
        serialize the message; if not specified the policy associated with
        the message instance is used.
        r)�BytesGeneratorNF)rDr7rF)rHrOr7rrIrJ)r>rGr7rOrKrLrrrrM�szMessage.as_bytescCst|jt�S)z6Return True if the message consists of multiple parts.)rr:�listrArrr�is_multipart�szMessage.is_multipartcCs
||_dS�N�r9)r>rGrrr�set_unixfrom�szMessage.set_unixfromcCs|jSrRrSrArrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.z|j�|�Wntk
r@td��YnXdS)z�Add the given payload to the current payload.

        The current payload will always be a list of objects after this method
        is called.  If you want to set the payload to a scalar object, use
        set_payload() instead.
        Nz=Attach is not valid on a message with a non-multipart payload)r:r.�AttributeError�	TypeError)r>�payloadrrr�attach�s

zMessage.attachcCs�|��r(|rdS|dkr|jS|j|S|dk	rNt|jt�sNtdt|j���|j}t|�dd����}t|t�r�t	�
|�r�|�dd�}|s�z|�|�
dd�d�}Wq�tk
r�|�dd�}Yq�Xn2|r�z|�d�}Wntk
r�|�d	�}YnX|�s|S|d
k�rt�|�S|dk�rVtd�|����\}}|D]}|j�||��q<|S|d
k�r�t|�}	t�}
ztj|	|
dd�|
��WStjk
�r�|YSXt|t��r�|S|S)aZReturn a reference to the payload.

        The payload will either be a list object or a string.  If you mutate
        the list object, you modify the message's payload in place.  Optional
        i returns that index into the payload.

        Optional decode is a flag indicating whether the payload should be
        decoded or not, according to the Content-Transfer-Encoding header
        (default is False).

        When True and the message is not a multipart, the payload will be
        decoded if this header's value is `quoted-printable' or `base64'.  If
        some other encoding is used, or the header is missing, or if the
        payload has bogus data (i.e. bogus base64 or uuencoded data), the
        payload is returned as-is.

        If the message is a multipart and the decode flag is True, then None
        is returned.
        NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper�replace�raw-unicode-escapezquoted-printable�base64�)z
x-uuencodeZuuencodeZuuezx-uueT)�quiet)rQr:rrPrW�typer�getr-rZ_has_surrogatesr!�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr7Z
handle_defectr�uurJ�Error)r>r2rbrX�cteZbpayloadr&r<ZdefectZin_fileZout_filerrr�get_payload�sV"








zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|�|j�}t|d�rT|�dd�|_n||_|dk	rl|�|�dS)z�Set the payload to the given value.

        Optional charset sets the message's default character set.  See
        set_charset() for details.
        r!NrbrrZ)�hasattrr:r�Charsetr!�output_charsetrb�set_charset)r>rXrrrr�set_payload/s


zMessage.set_payloadcCs|dkr|�d�d|_dSt|t�s.t|�}||_d|krH|�dd�d|krf|jdd|��d�n|�d|���||��kr�|�|j�|_d|k�r|�	�}z||�Wnjt
k
�r|j}|r�z|�d	d
�}Wn tk
r�|�|j
�}YnX|�|�|_|�d|�YnXdS)a�Set the charset of the payload to a given character set.

        charset can be a Charset instance, a string naming a character set, or
        None.  If it is a string it will be converted to a Charset instance.
        If charset is None, the charset parameter will be removed from the
        Content-Type field.  Anything else will generate a TypeError.

        The message will be assumed to be of type text/* encoded with
        charset.input_charset.  It will be converted to charset.output_charset
        and encoded properly, if needed, when generating the plain text
        representation of the message.  MIME headers (MIME-Version,
        Content-Type, Content-Transfer-Encoding) will be added as needed.
        Nr�MIME-Version�1.0�Content-Typer6r
zContent-Transfer-EncodingrrZ)�	del_paramr;rrn�
add_headerZget_output_charset�	set_paramZbody_encoder:Zget_body_encodingrWr!rero)r>rrkrXrrrrpCs:

�
zMessage.set_charsetcCs|jS)zKReturn the Charset instance associated with the message's payload.
        )r;rArrr�get_charsetrszMessage.get_charsetcCs
t|j�S)z9Return the total number of headers, including duplicates.)rr8rArrr�__len__zszMessage.__len__cCs
|�|�S)a-Get a header value.

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, exactly which
        occurrence gets returned is undefined.  Use get_all() to get all
        the values matching a header field name.
        )ra�r>�namerrr�__getitem__~s	zMessage.__getitem__cCsr|j�|�}|rX|��}d}|jD]4\}}|��|kr"|d7}||kr"td�||���q"|j�|j�||��dS)z�Set the value of a header.

        Note: this does not overwrite an existing header with the same field
        name.  Use __delitem__() first to delete any existing headers.
        rrz/There may be at most {} {} headers in a messageN)r7Zheader_max_countr-r8�
ValueError�formatr.�header_store_parse)r>r{�valZ	max_countZlname�found�k�vrrr�__setitem__�s�zMessage.__setitem__cCs@|��}g}|jD]"\}}|��|kr|�||f�q||_dS)zwDelete all occurrences of a header, if present.

        Does not raise an exception if the header is missing.
        N)r-r8r.)r>r{�
newheadersr�r�rrr�__delitem__�szMessage.__delitem__cCs|��dd�|jD�kS)NcSsg|]\}}|���qSr)r-��.0r�r�rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r-r8rzrrr�__contains__�szMessage.__contains__ccs|jD]\}}|VqdSrR�r8)r>Zfieldr&rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)a.Return a list of all the message's header field names.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSrrr�rrrr��sz Message.keys.<locals>.<listcomp>r�rArrr�keys�szMessage.keyscs�fdd��jD�S)a)Return a list of all the message's header values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        csg|]\}}�j�||��qSr�r7�header_fetch_parser�rArrr��s�z"Message.values.<locals>.<listcomp>r�rArrAr�values�s
�zMessage.valuescs�fdd��jD�S)a'Get all the message's header fields and values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cs"g|]\}}|�j�||�f�qSrr�r�rArrr��s�z!Message.items.<locals>.<listcomp>r�rArrAr�items�s
�z
Message.itemscCs:|��}|jD]&\}}|��|kr|j�||�Sq|S)z~Get a header value.

        Like __getitem__() but return failobj instead of None when the field
        is missing.
        )r-r8r7r�)r>r{�failobjr�r�rrrra�s
zMessage.getcCs|j�||f�dS)z�Store name and value in the model without modification.

        This is an "internal" API, intended only for use by a parser.
        N)r8r.)r>r{r&rrr�set_raw�szMessage.set_rawcCst|j���S)z�Return the (name, value) header pairs without modification.

        This is an "internal" API, intended only for use by a generator.
        )�iterr8�copyrArrr�	raw_items�szMessage.raw_itemscCsHg}|��}|jD](\}}|��|kr|�|j�||��q|sD|S|S)aQReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original
        message, and may contain duplicates.  Any fields deleted and
        re-inserted are always appended to the header list.

        If no such fields exist, failobj is returned (defaults to None).
        )r-r8r.r7r�)r>r{r�r�r�r�rrr�get_all�s	zMessage.get_allcKspg}|��D]<\}}|dkr0|�|�dd��q|�t|�dd�|��q|dk	r^|�d|�t�|�||<dS)u�Extended header setting.

        name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.  If a
        parameter value contains non-ASCII characters it can be specified as a
        three-tuple of (charset, language, value), in which case it will be
        encoded according to RFC2231 rules.  Otherwise it will be encoded using
        the utf-8 charset and a language of ''.

        Examples:

        msg.add_header('content-disposition', 'attachment', filename='bud.gif')
        msg.add_header('content-disposition', 'attachment',
                       filename=('utf-8', '', Fußballer.ppt'))
        msg.add_header('content-disposition', 'attachment',
                       filename='Fußballer.ppt'))
        N�_�-r)r�r.r[r'�insert�	SEMISPACErg)r>�_name�_valueZ_params�partsr�r�rrrrvszMessage.add_headercCs\|��}ttt|j��|j�D]0\}\}}|��|kr|j�||�|j|<qXqt|��dS)z�Replace a header.

        Replace the first matching header found in the message, retaining
        header order and case.  If no matching header was found, a KeyError is
        raised.
        N)r-�zip�rangerr8r7r�KeyError)r>r�r�r2r�r�rrr�replace_header!s"zMessage.replace_headercCsHt�}|�d|�}||kr"|��St|�d��}|�d�dkrDdS|S)a0Return the message's content type.

        The returned string is coerced to lower case of the form
        `maintype/subtype'.  If there was no Content-Type header in the
        message, the default type as given by get_default_type() will be
        returned.  Since according to RFC 2045, messages always have a default
        type this will always return a value.

        RFC 2045 defines a message's default type to be text/plain unless it
        appears inside a multipart/digest container, in which case it would be
        message/rfc822.
        �content-typer�/rr6)�objectra�get_default_typerr-r+)r>�missingr&�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|��}|�d�dS)z�Return the message's main content type.

        This is the `maintype' part of the string returned by
        get_content_type().
        r�r�r��split�r>r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|��}|�d�dS)z�Returns the message's sub-content type.

        This is the `subtype' part of the string returned by
        get_content_type().
        r�rr�r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jS)aReturn the `default' content type.

        Most messages have a default content type of text/plain, except for
        messages that are subparts of multipart/digest containers.  Such
        subparts have a default content type of message/rfc822.
        �r=rArrrr�^szMessage.get_default_typecCs
||_dS)z�Set the `default' content type.

        ctype should be either "text/plain" or "message/rfc822", although this
        is not enforced.  The default content type is not stored in the
        Content-Type header.
        Nr�r�rrr�set_default_typegszMessage.set_default_typec		Cs�t�}|�||�}||kr|Sg}t|�D]X}z$|�dd�\}}|��}|��}Wn tk
rr|��}d}YnX|�||f�q*t�|�}|S)Nr)rr)	r�rar3r�rr}r.rZ
decode_params)	r>r��headerr�r&�params�pr{r�rrr�_get_params_preserveps 

zMessage._get_params_preserver�TcCs8t�}|�||�}||kr|S|r0dd�|D�S|SdS)amReturn the message's Content-Type parameters, as a list.

        The elements of the returned list are 2-tuples of key/value pairs, as
        split on the `=' sign.  The left hand side of the `=' is the key,
        while the right hand side is the value.  If there is no `=' sign in
        the parameter the value is the empty string.  The value is as
        described in the get_param() method.

        Optional failobj is the object to return if there is no Content-Type
        header.  Optional header is the header to search instead of
        Content-Type.  If unquote is True, the value is unquoted.
        cSsg|]\}}|t|�f�qSr)r5r�rrrr��sz&Message.get_params.<locals>.<listcomp>N)r�r�)r>r�r�r4r�r�rrr�
get_params�s
zMessage.get_paramscCsN||kr|S|�||�D]0\}}|��|��kr|r@t|�S|Sq|S)a�Return the parameter value if found in the Content-Type header.

        Optional failobj is the object to return if there is no Content-Type
        header, or the Content-Type header has no such parameter.  Optional
        header is the header to search instead of Content-Type.

        Parameter keys are always compared case insensitively.  The return
        value can either be a string, or a 3-tuple if the parameter was RFC
        2231 encoded.  When it's a 3-tuple, the elements of the value are of
        the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
        LANGUAGE can be None, in which case you should consider VALUE to be
        encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
        The parameter value (either the returned string, or the VALUE item in
        the 3-tuple) is always unquoted, unless unquote is set to False.

        If your application doesn't care whether the parameter was RFC 2231
        encoded, it can turn the return value into a string as follows:

            rawparam = msg.get_param('foo')
            param = email.utils.collapse_rfc2231_value(rawparam)

        )r�r-r5)r>rr�r�r4r�r�rrrrc�s
zMessage.get_paramrtrcCs
t|t�s|r|||f}||kr2|��dkr2d}n
|�|�}|j||d�st|s\t|||�}q�t�|t|||�g�}nbd}|j||d�D]N\}	}
d}|	��|��kr�t|||�}nt|	|
|�}|s�|}q�t�||g�}q�||�|�k�r|r�|�	||�n||=|||<dS)a�Set a parameter in the Content-Type header.

        If the parameter already exists in the header, its value will be
        replaced with the new value.

        If header is Content-Type and has not yet been defined for this
        message, it will be set to "text/plain" and the new parameter and
        value will be appended as per RFC 2045.

        An alternate header can be specified in the header argument, and all
        parameters will be quoted as necessary unless requote is False.

        If charset is specified, the parameter will be encoded according to RFC
        2231.  Optional language specifies the RFC 2231 language, defaulting
        to the empty string.  Both charset and language should be strings.
        r�r6)r�r�r�r4N)
rr r-rarcr'r�rgr�r�)r>rr&r��requoterZlanguager[r�Z	old_param�	old_valueZappend_paramrrrrw�s6

��zMessage.set_paramcCs�||krdSd}|j||d�D]@\}}|��|��kr|sHt|||�}qt�|t|||�g�}q||�|�kr|||=|||<dS)a>Remove the given parameter completely from the Content-Type header.

        The header will be re-written in place without the parameter or its
        value. All values will be quoted as necessary unless requote is
        False.  Optional header specifies an alternative to the Content-Type
        header.
        Nrr�)r�r-r'r�rgra)r>rr�r�Z	new_ctyper�r�rrrru�s
�zMessage.del_paramcCs�|�d�dkst�|��dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<|dd�D]\}}|�||||�qhdS)	aKSet the main type and subtype for the Content-Type header.

        type must be a string in the form "maintype/subtype", otherwise a
        ValueError is raised.

        This method replaces the Content-Type header, keeping all the
        parameters in place.  If requote is False, this leaves the existing
        header's quoting as is.  Otherwise, the parameters will be quoted (the
        default).

        An alternative header can be specified in the header argument.  When
        the Content-Type header is set, we'll always also add a MIME-Version
        header.
        r�rr�zmime-versionrsrrNr�)r+r}r-r�rw)r>r`r�r�r�r�r�rrr�set_typeszMessage.set_typecCsDt�}|�d|d�}||kr*|�d|d�}||kr6|St�|���S)a@Return the filename associated with the payload if present.

        The filename is extracted from the Content-Disposition header's
        `filename' parameter, and it is unquoted.  If that header is missing
        the `filename' parameter, this method falls back to looking for the
        `name' parameter.
        �filename�content-dispositionr{r�)r�rcr�collapse_rfc2231_valuer)r>r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|�d|�}||kr|St�|���S)z�Return the boundary associated with the payload if present.

        The boundary is extracted from the Content-Type header's `boundary'
        parameter, and it is unquoted.
        �boundary)r�rcrr��rstrip)r>r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCst�}|�|d�}||kr$t�d��g}d}|D]:\}}|��dkr\|�dd|f�d}q0|�||f�q0|s�|�dd|f�g}|jD]z\}	}
|	��dkr�g}|D].\}}
|
dkr�|�|�q�|�d||
f�q�t�|�}
|�|j	�
|	|
��q�|�|	|
f�q�||_d	S)
a�Set the boundary parameter in Content-Type to 'boundary'.

        This is subtly different than deleting the Content-Type header and
        adding a new one with a new boundary parameter via add_header().  The
        main difference is that using the set_boundary() method preserves the
        order of the Content-Type header in the original message.

        HeaderParseError is raised if the message has no Content-Type header.
        r�zNo Content-Type header foundFr�z"%s"TrrN)r�r�rZHeaderParseErrorr-r.r8r�rgr7r)r>r�r�r�Z	newparamsZfoundpZpkZpvr��hr�r�r�r�rrr�set_boundaryCs2


zMessage.set_boundaryc	Cs�t�}|�d|�}||kr|St|t�rr|dp2d}z|d�d�}t||�}Wn ttfk
rp|d}YnXz|�d�Wntk
r�|YSX|��S)z�Return the charset parameter of the Content-Type header.

        The returned string is always coerced to lower case.  If there is no
        Content-Type header, or if that header has no charset parameter,
        failobj is returned.
        rrzus-asciirr\)	r�rcrr r!rrdrer-)r>r�r�rZpcharsetrMrrr�get_content_charsetqs 

zMessage.get_content_charsetcs�fdd�|��D�S)a�Return a list containing the charset(s) used in this message.

        The returned list of items describes the Content-Type headers'
        charset parameter for this message and all the subparts in its
        payload.

        Each item will either be a string (the value of the charset parameter
        in the Content-Type header of that part) or the value of the
        'failobj' parameter (defaults to None), if the part does not have a
        main MIME type of "text", or the charset is not defined.

        The list will contain one string for each part of the message, plus
        one for the container message (i.e. self), so that a non-multipart
        message will still return a list of length 1.
        csg|]}|����qSr)r�)r��part�r�rrr��sz(Message.get_charsets.<locals>.<listcomp>��walk)r>r�rr�r�get_charsets�szMessage.get_charsetscCs*|�d�}|dkrdSt|�d��}|S)z�Return the message's content-disposition if it exists, or None.

        The return values can be either 'inline', 'attachment' or None
        according to the rfc2183.
        r�Nr)rarr-)r>r&�c_drrr�get_content_disposition�s

zMessage.get_content_dispositionr�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)rtTNrF)r�T)rtT)N)N)N)N)4�__name__�
__module__�__qualname__�__doc__r	r?rBr@rNrMrQrTrUrYrlrqrprxryr|r�r�r�r�r�r�r�rar�r�r�rvr�r�r�r�r�r�r�r�rcrwrur�r�r�r�r�r�r�Zemail.iteratorsr�rrrrrisj


Z
/


				
�
"�
3

 


.


cs�eZdZd2dd�Zd3�fdd�	Zdd�Zd	d
�Zdd�Zd4dd�ZddddhZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd5dd �Zd6d!d"�Zd7d#d$�Zdd%�d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z�ZS)8�MIMEPartNcCs(|dkrddlm}|}t�||�dS)Nr)�default)Zemail.policyr�rr?)r>r7r�rrrr?�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)aReturn the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  maxheaderlen is retained for backward compatibility with the
        base Message class, but defaults to None, meaning that the policy value
        for max_line_length controls the header maximum length.  'policy' is
        passed to the Generator instance used to serialize the message; if it
        is not specified the policy associated with the message instance is
        used.
        N)rEr7)r7Zmax_line_length�superr@)r>rGrEr7��	__class__rrr@�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8�r7)r@r7ZclonerArrrrB�szMIMEPart.__str__cCs |�d�}|dkrdS|jdkS)Nr�F�
attachment)raZcontent_disposition)r>r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|��rdS|���d�\}}|dkrB||kr>|�|�|fVdS|dkrNdS|dkrz|��D]}|�||�EdHq^dSd|kr�|�d�|fVd}|�d�}|r�|��D]}|d|kr�|}q�q�|dkr�|��}|r�|dnd}|dk	�r|�||�EdHdS)Nr��text�	multipart�related�start�
content-idr)r�r�r�r,�
iter_parts�
_find_bodyrcrl)	r>r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_body�r��html�plaincCsBt|�}d}|�||�D]$\}}||kr|}|}|dkrq>q|S)aReturn best candidate mime part for display as 'body' of message.

        Do a depth first search, starting with self, looking for the first part
        matching each of the items in preferencelist, and return the part
        corresponding to the first item that has a match, or None if no items
        have a match.  If 'related' is not included in preferencelist, consider
        the root part of any multipart/related encountered as a candidate
        match.  Ignore parts with 'Content-Disposition: attachment'.
        Nr)rr�)r>r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_body)r�r�)r�r�)r�r�)r��alternativec
cs$|���d�\}}|dks"|dkr&dS|��}z|��}Wntk
rPYdSX|dkr�|dkr�|�d�}|r�d}g}|D]"}|�d�|kr�d	}q||�|�q||r�|EdHdS|�d
�|EdHdSg}	|D]L}|���d�\}}||f|j	k�r|�
��s||	k�r|	�|�q�|Vq�dS)aReturn an iterator over the non-main parts of a multipart.

        Skip the first of each occurrence of text/plain, text/html,
        multipart/related, or multipart/alternative in the multipart (unless
        they have a 'Content-Disposition: attachment' header) and include all
        remaining subparts in the returned iterator.  When applied to a
        multipart/related, return all parts except the root part.  Return an
        empty iterator when applied to a multipart/alternative or a
        non-multipart.
        r�r�r�Nr�r�Fr�Tr)r�r�rlr�rVrcrar.�pop�_body_typesr�)
r>r�r�rXr�r�r�Zattachmentsr��seenrrr�iter_attachmentssD



��
zMIMEPart.iter_attachmentsccs|��dkr|��EdHdS)z~Return an iterator over all immediate subparts of a multipart.

        Return an empty iterator for a non-multipart.
        r�N)r�rlrArrrr�=szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�SrR)r7r��get_content�r>r��args�kwrrrr�EszMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dSrR)r7r��set_contentr�rrrr�JszMIMEPart.set_contentc
Cs�|��dkr6|��}||f}||kr6td�||���g}g}|jD]4\}}|���d�rj|�||f�qD|�||f�qD|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|�d|�dS)Nr�zCannot convert {} to {}�content-r�z
multipart/rtr�)r�r�r}r~r8r-�
startswithr.r`r7r:rw)
r>r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersr{r&r�rrr�_make_multipartOs0
�
zMIMEPart._make_multipartcCs|�dd|�dS)Nr�)r��mixed�r��r>r�rrr�make_relatedjszMIMEPart.make_relatedcCs|�dd|�dS)Nr�)r�r�r�rrr�make_alternativemszMIMEPart.make_alternativecCs|�dd|�dS)Nr�rr�r�rrr�
make_mixedpszMIMEPart.make_mixed)�_dispcOsf|��dks|��|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|�|�dS)Nr�Zmake_r�r�zContent-Disposition)r�r��getattrr`r7r�rY)r>Z_subtyper�r�r�r�rrr�_add_multipartss
�zMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r��r��r>r�r�rrr�add_related}szMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�r�r�rrr�add_alternative�szMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�r�r�rrr�add_attachment�szMIMEPart.add_attachmentcCsg|_d|_dSrR�r8r:rArrr�clear�szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|���d�s||f�qS)r�)r-r�)r��nr�rrrr��s�z*MIMEPart.clear_content.<locals>.<listcomp>rrArrr�
clear_content�szMIMEPart.clear_content)N)FNN)r�)N)N)N)r�r�r�r?r@rBr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�
__classcell__rrr�rr��s2

�7



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)Nrrrs)r�r�r�r�rrr��szEmailMessage.set_content)r�r�r�r�rrrr�rr�s)NT)r��__all__�rerirf�iorrZemailrrZemail._policybaserr	rr;Zemail._encoded_wordsrrnr��compiler#rr'r3r5rr�rrrrr�<module>s6


"N`PK�"�\o��c��contentmanager.cpython-38.pycnu�[���U

e5d�)�@s.ddlZddlZddlZddlZddlmZGdd�d�Ze�Zd%dd�Ze�	de�d	d
�Z
d��D]Ze�	ee
�qfdd
�Z
d��D]Ze�	dee
�q�dd�Ze�	de�dd�Zdd�Zdd�Zdd�Zd&dd�Ze�ee�d'd d!�Ze�ejje�d(d#d$�ZeeefD]Ze�ee��qdS))�N)�
quoprimimec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContentManagercCsi|_i|_dS�N)�get_handlers�set_handlers)�self�r�,/usr/lib64/python3.8/email/contentmanager.py�__init__	szContentManager.__init__cCs||j|<dSr)r)r�key�handlerrrr	�add_get_handler
szContentManager.add_get_handlercOs||��}||jkr(|j||f|�|�S|��}||jkrP|j||f|�|�Sd|jkrp|jd|f|�|�St|��dS)N�)Zget_content_typer�get_content_maintype�KeyError)r�msg�args�kwZcontent_type�maintyperrr	�get_contents


zContentManager.get_contentcCs||j|<dSr)r)rZtypekeyrrrr	�add_set_handlerszContentManager.add_set_handlercOs>|��dkrtd��|�||�}|��|||f|�|�dS)NZ	multipartz"set_content not valid on multipart)r�	TypeError�_find_set_handlerZ
clear_content)rr�objrrrrrr	�set_contents
zContentManager.set_contentc	Cs�d}t|�jD]�}||jkr*|j|S|j}t|dd�}|rNd�||f�n|}|dkr^|}||jkrv|j|S||jkr�|j|S|j}||jkr|j|Sqd|jkr�|jdSt|��dS)N�
__module__r�.)�type�__mro__r�__qualname__�getattr�join�__name__r)	rrrZfull_path_for_error�typZqname�modname�	full_path�namerrr	r's&





z ContentManager._find_set_handlerN)	r"rrr
r
rrrrrrrr	rs	r�replacecCs&|jdd�}|�dd�}|j||d�S)NT��decode�charset�ASCII)�errors)�get_payloadZ	get_paramr))rr,Zcontentr*rrr	�get_text_content@sr.�textcCs|jdd�S)NTr(�r-�rrrr	�get_non_text_contentGsr2zaudio image video applicationcCs
|�d�S�Nrr0r1rrr	�get_message_contentMsr4zrfc822 external-bodyzmessage/cCst|�d��Sr3)�bytesr-r1rrr	�%get_and_fixup_unknown_message_contentSsr6�messagec
s�d�||f�|d<|r�t|dd�s<|j��fdd�|D�}z(|D]}|jrV|jd�|||j<qBWn@tjjk
r�}ztd�	|j
|jd���|�W5d}~XYnXdS)	N�/zContent-Typerr&csg|]}�j��|g���qSr)Zheader_factoryZheader_source_parse)�.0�header�Zmprr	�
<listcomp>ds�z _prepare_set.<locals>.<listcomp>zInvalid header: {})�policy)r!�hasattrr=Zdefectsr&�emailr,ZHeaderDefect�
ValueError�formatZfold)rr�subtype�headersr:�excrr;r	�_prepare_set_s$
�
��rEcCsx|dkr|dk	rd}|dk	r$||d<|dk	r>|jd|ddd�|dk	rN||d<|dk	rt|��D]\}}|�||�q^dS)NZ
attachmentzContent-Disposition�filenameT)r:r'z
Content-ID)�	set_param�items)r�dispositionrF�cid�paramsr�valuerrr	�
_finalize_setps�rMcCsVg}|dd}tdt|�|�D]*}||||�}|�t�|��d��q d�|�S)N��r�asciir)�range�len�append�binascii�
b2a_base64r)r!)�data�max_line_lengthZ
encoded_linesZunencoded_bytes_per_line�iZthislinerrr	�_encode_base64�srYcs�|�|���}|j�d���fdd�}dd�}|dkr�tdd�|D�dd	�|jkr�zd
||��d�fWStk
rzYnX|jdkr�d||��dd�fS||dd
��}t�	|�d�|j�}t
�|�}	t|�t|	�kr�d}nd}t|�d
kr�||fS|d
k�r||��d�}
nj|dk�r,||��dd�}
nN|dk�rPt�	||��d�|j�}
n*|dk�rlt
||�|j�}
ntd�|���||
fS)NrPcs��|��Sr�r!��lines��lineseprr	�
embedded_body��z#_encode_text.<locals>.embedded_bodycSsd�|�dS)N�
rZr[rrr	�normal_body�r`z!_encode_text.<locals>.normal_bodycss|]}t|�VqdSr)rR)r9�xrrr	�	<genexpr>�sz_encode_text.<locals>.<genexpr>r)�default�7bit�8bit�surrogateescape�
zlatin-1�base64�quoted-printablez$Unknown content transfer encoding {})�encode�
splitlinesr^�maxrWr)�UnicodeDecodeErrorZcte_typerZbody_encoderTrUrRrYr@rA)�stringr*�cter=r\r_rbZsniffZsniff_qpZsniff_base64rVrr]r	�_encode_text�sD
�



�
rr�plain�utf-8c
Csdt|d||	�t||||j�\}}
|�|
�|jdtjj�||�dd�||d<t	|||||�dS)Nr/r*T)r'�Content-Transfer-Encoding)
rErrr=�set_payloadrGr?r*ZALIASES�getrM)rrprBr*rqrIrFrJrKrCZpayloadrrr	�set_text_content�s
�rx�rfc822c		Cs�|dkrtd��|dkr@|dkr.td�|���|dkr:dn|}n0|dkrd|dkr^td	�|���d
}n|dkrpd
}t|d||�|�|g�||d<t|||||�dS)
N�partialz4message/partial is not supported for Message objectsry)Nrfrg�binaryz*message/rfc822 parts do not support cte={}rgz
external-body)Nrfz1message/external-body parts do not support cte={}rfr7ru)r@rArErvrM)	rr7rBrqrIrFrJrKrCrrr	�set_message_content�s(��r|rjc

Cs�t||||	�|dkr(t||jjd�}nN|dkrNtj|dddd�}|�d�}n(|dkrb|�d�n|d	krv|�dd
�}|�|�||d<t	|||||�dS)Nrj)rWrkFT)�istextr:Z	quotetabsrPrf)rgr{rhru)
rErYr=rWrTZb2a_qpr)rlrvrM)
rrVrrBrqrIrFrJrKrCrrr	�set_bytes_content�s
r~)r')rsrtNNNNNN)ryNNNNNN)rjNNNNN)rTZ
email.charsetr?Z
email.messageZemail.errorsrrZraw_data_managerr.r
r2�splitrr4rBr6rErMrYrrrxr�strr|r7ZMessager~r5�	bytearray�
memoryviewr#rrrr	�<module>s^6
�	'�
�
�
PK�"�\FN��H%H%utils.cpython-38.opt-1.pycnu�[���U

e5d�4�@sjdZddddddddd	d
ddd
ddgZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddl
mZ
ddl
mZddl
mZmZmZddlmZdZdZdZdZdZe�d�Ze�d�Zdd�Zdd �Zd7d"d�Zd#d�Zd$d%�Z d8d'd�Z!d9d(d�Z"d:d)d	�Z#d*d�Z$d+d�Z%d,d�Z&d-d�Z'd;d.d�Z(e�d/ej)�Z*d0d�Z+d<d3d�Z,d=d5d6�Z-dS)>zMiscellaneous utilities.�collapse_rfc2231_value�
decode_params�decode_rfc2231�encode_rfc2231�
formataddr�
formatdate�format_datetime�getaddresses�
make_msgid�	mktime_tz�	parseaddr�	parsedate�parsedate_tz�parsedate_to_datetime�unquote�N)�quote)�AddressList)r
)rr
�
_parsedate_tz)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]cCs*z|��WdStk
r$YdSXdS)z8Return True if s contains surrogate-escaped binary data.FTN)�encode�UnicodeEncodeError)�s�r�#/usr/lib64/python3.8/email/utils.py�_has_surrogates3s
rcCs|�dd�}|�dd�S)N�utf-8�surrogateescape�replace)r�decode)�stringZoriginal_bytesrrr�	_sanitize@sr"rcCs�|\}}|�d�|r�z|�d�Wn<tk
r`t|t�rFt|�}|�|�}d||fYSXd}t�|�rtd}t�	d|�}d||||fS|S)a�The inverse of parseaddr(), this takes a 2-tuple of the form
    (realname, email_address) and returns the string value suitable
    for an RFC 2822 From, To or Cc header.

    If the first element of pair is false, then the second element is
    returned unmodified.

    The optional charset is the character set that is used to encode
    realname in case realname is not ASCII safe.  Can be an instance of str or
    a Charset-like object which has a header_encode method.  Default is
    'utf-8'.
    �asciiz%s <%s>r�"z\\\g<0>z%s%s%s <%s>)
rr�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�nameZaddressZencoded_nameZquotesrrrrLs 




cCst�|�}t|�}|jS)z7Return a list of (REALNAME, EMAIL) for each fieldvalue.)�
COMMASPACE�join�_AddressList�addresslist)Zfieldvalues�all�arrrrns
cCsfddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDec�r���r)�	timetuple�zonerrr�_format_timetuple_and_zoneus&�
��r;FcCsR|dkrt��}|s|r,tj�|tjj�}ntj�|�}|rH|��}d}t||�S)a�Returns a date string as specified by RFC 2822, e.g.:

    Fri, 09 Nov 2001 01:08:47 -0000

    Optional timeval if given is a floating point time value as accepted by
    gmtime() and localtime(), otherwise the current time is used.

    Optional localtime is a flag that when True, interprets timeval, and
    returns a date relative to the local timezone instead of UTC, properly
    taking daylight savings time into account.

    Optional argument usegmt means that the timezone is written out as
    an ascii string, not numeric one (so "GMT" instead of "+0000"). This
    is needed for HTTP, and is only used when localtime==False.
    NF)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr~scCsV|��}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}n
|�d�}t||�S)a$Turn a datetime into a date string as specified in RFC 2822.

    If usegmt is True, dt must be an aware datetime with an offset of zero.  In
    this case 'GMT' will be rendered instead of the normal +0000 required by
    RFC2822.  This is to support HTTP headers involving date stamps.
    Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)r9�tzinfor=r>r?�
ValueError�strftimer;)rDrC�nowr:rrrr�s

cCs^tt��d�}t��}t�d�}|dkr0d}nd|}|dkrHt��}d|||||f}|S)a{Returns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.  Optional domain if given provides the
    portion of the message id after the '@'.  It defaults to the locally
    defined hostname.
    �d�@Nr�.z<%d.%d.%d%s@%s>)�intr<�os�getpid�randomZgetrandbits�socketZgetfqdn)ZidstringZdomainrA�pidZrandintZmsgidrrrr	�s

cCsNt|��^}}|dkr(tj|dd��Stj|dd�dt�tj|d��i�S)Nr3rE��seconds)rr=r>�	timedelta)�dataZdtuple�tzrrrr�s�cCst|�j}|sdS|dS)z�
    Parse addr into its constituent realname and email address parts.

    Return a tuple of realname and email address, unless the parse fails, in
    which case return a 2-tuple of ('', '').
    )rrr)r/r0)ZaddrZaddrsrrrr�s
cCs`t|�dkr\|�d�r<|�d�r<|dd��dd��dd�S|�d�r\|�d�r\|dd�S|S)	zRemove quotes from a string.r5r$���z\\�\z\"�<�>)�len�
startswith�endswithr)r&rrrr�scCs&|�td�}t|�dkr"dd|fS|S)z#Decode string according to RFC 2231r4N)�split�TICKr[)r�partsrrrr�s
cCsDtjj|d|pdd�}|dkr*|dkr*|S|dkr6d}d|||fS)z�Encode string according to RFC 2231.

    If neither charset nor language is given, then s is returned as-is.  If
    charset is given but not language, the string is encoded using the empty
    string for language.
    rr#)Zsafe�encodingNz%s'%s'%s)�urllib�parser)rr+�languagerrrr�sz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Csl|dd�}g}i}|�d�\}}|�||f�|r�|�d�\}}|�d�rRd}nd}t|�}t�|�}|r�|�dd�\}}|dk	r�t|�}|�|g��|||f�q0|�|dt	|�f�q0|�rh|�
�D]�\}}g}d}	|��|D].\}}
}|�rtj
j|
d	d
�}
d}	|�|
�q�t	t�|��}|	�rTt|�\}}}|�|||d|ff�q�|�|d|f�q�|S)zDecode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (param name, string value).
    Nr�*TFr,�numz"%s"zlatin-1)ra)�pop�appendr]r�rfc2231_continuation�match�grouprL�
setdefaultr�items�sortrbrc�EMPTYSTRINGr.r)
ZparamsZ
new_paramsZrfc2231_paramsr,�valueZencodedZmorfZ
continuationsZextendedrr+rdrrrrsD

r�us-asciicCsnt|t�rt|�dkrt|�S|\}}}|dkr4|}t|d�}zt|||�WStk
rht|�YSXdS)Nr6zraw-unicode-escape)r%�tupler[r�bytesr&�LookupError)rp�errorsZfallback_charsetr+rd�textZrawbytesrrrr9s

rWc	Cs|dkrtj�tjj���S|jdk	r.|��S|��dd�|f}t�|�}t�	|�}z tj
|jd�}t�||j�}Wn�t
k
r�|tjt�|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�t�|tj|�}n
t�|�}YnX|j|d�S)a�Return local time as an aware datetime object.

    If called without arguments, return current time.  Otherwise *dt*
    argument should be a datetime instance, and it is converted to the
    local time zone according to the system time zone database.  If *dt* is
    naive (that is, dt.tzinfo is None), it is assumed to be in local time.
    In this case, a positive or zero value for *isdst* causes localtime to
    presume initially that summer time (for example, Daylight Saving Time)
    is or is not (respectively) in effect for the specified time.  A
    negative value for *isdst* causes the localtime() function to attempt
    to divine whether summer time is in effect for the specified time.

    NrWrRr3r)rE)r=rHr>r?r@rEr9r<�mktimerBrT�	tm_gmtoff�tm_zone�AttributeError�gmtime�daylight�tm_isdst�altzone�tznamer)	rDZisdstZtmrSZlocaltmZdeltarVZdstZgmtoffrrrrBSs$


rB)r)NFF)F)NN)NN)rrq)NrW).�__doc__�__all__rM�rer<rOrPr=Zurllib.parserbZemail._parseaddrrrr/r
rr
rZ
email.charsetrr-roZUEMPTYSTRINGZCRLFr_�compiler'r)rr"rrr;rrr	rrrrr�ASCIIrirrrBrrrr�<module>sp�



"	



�8�
PK�"�\o��c��#contentmanager.cpython-38.opt-2.pycnu�[���U

e5d�)�@s.ddlZddlZddlZddlZddlmZGdd�d�Ze�Zd%dd�Ze�	de�d	d
�Z
d��D]Ze�	ee
�qfdd
�Z
d��D]Ze�	dee
�q�dd�Ze�	de�dd�Zdd�Zdd�Zdd�Zd&dd�Ze�ee�d'd d!�Ze�ejje�d(d#d$�ZeeefD]Ze�ee��qdS))�N)�
quoprimimec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContentManagercCsi|_i|_dS�N)�get_handlers�set_handlers)�self�r�,/usr/lib64/python3.8/email/contentmanager.py�__init__	szContentManager.__init__cCs||j|<dSr)r)r�key�handlerrrr	�add_get_handler
szContentManager.add_get_handlercOs||��}||jkr(|j||f|�|�S|��}||jkrP|j||f|�|�Sd|jkrp|jd|f|�|�St|��dS)N�)Zget_content_typer�get_content_maintype�KeyError)r�msg�args�kwZcontent_type�maintyperrr	�get_contents


zContentManager.get_contentcCs||j|<dSr)r)rZtypekeyrrrr	�add_set_handlerszContentManager.add_set_handlercOs>|��dkrtd��|�||�}|��|||f|�|�dS)NZ	multipartz"set_content not valid on multipart)r�	TypeError�_find_set_handlerZ
clear_content)rr�objrrrrrr	�set_contents
zContentManager.set_contentc	Cs�d}t|�jD]�}||jkr*|j|S|j}t|dd�}|rNd�||f�n|}|dkr^|}||jkrv|j|S||jkr�|j|S|j}||jkr|j|Sqd|jkr�|jdSt|��dS)N�
__module__r�.)�type�__mro__r�__qualname__�getattr�join�__name__r)	rrrZfull_path_for_error�typZqname�modname�	full_path�namerrr	r's&





z ContentManager._find_set_handlerN)	r"rrr
r
rrrrrrrr	rs	r�replacecCs&|jdd�}|�dd�}|j||d�S)NT��decode�charset�ASCII)�errors)�get_payloadZ	get_paramr))rr,Zcontentr*rrr	�get_text_content@sr.�textcCs|jdd�S)NTr(�r-�rrrr	�get_non_text_contentGsr2zaudio image video applicationcCs
|�d�S�Nrr0r1rrr	�get_message_contentMsr4zrfc822 external-bodyzmessage/cCst|�d��Sr3)�bytesr-r1rrr	�%get_and_fixup_unknown_message_contentSsr6�messagec
s�d�||f�|d<|r�t|dd�s<|j��fdd�|D�}z(|D]}|jrV|jd�|||j<qBWn@tjjk
r�}ztd�	|j
|jd���|�W5d}~XYnXdS)	N�/zContent-Typerr&csg|]}�j��|g���qSr)Zheader_factoryZheader_source_parse)�.0�header�Zmprr	�
<listcomp>ds�z _prepare_set.<locals>.<listcomp>zInvalid header: {})�policy)r!�hasattrr=Zdefectsr&�emailr,ZHeaderDefect�
ValueError�formatZfold)rr�subtype�headersr:�excrr;r	�_prepare_set_s$
�
��rEcCsx|dkr|dk	rd}|dk	r$||d<|dk	r>|jd|ddd�|dk	rN||d<|dk	rt|��D]\}}|�||�q^dS)NZ
attachmentzContent-Disposition�filenameT)r:r'z
Content-ID)�	set_param�items)r�dispositionrF�cid�paramsr�valuerrr	�
_finalize_setps�rMcCsVg}|dd}tdt|�|�D]*}||||�}|�t�|��d��q d�|�S)N��r�asciir)�range�len�append�binascii�
b2a_base64r)r!)�data�max_line_lengthZ
encoded_linesZunencoded_bytes_per_line�iZthislinerrr	�_encode_base64�srYcs�|�|���}|j�d���fdd�}dd�}|dkr�tdd�|D�dd	�|jkr�zd
||��d�fWStk
rzYnX|jdkr�d||��dd�fS||dd
��}t�	|�d�|j�}t
�|�}	t|�t|	�kr�d}nd}t|�d
kr�||fS|d
k�r||��d�}
nj|dk�r,||��dd�}
nN|dk�rPt�	||��d�|j�}
n*|dk�rlt
||�|j�}
ntd�|���||
fS)NrPcs��|��Sr�r!��lines��lineseprr	�
embedded_body��z#_encode_text.<locals>.embedded_bodycSsd�|�dS)N�
rZr[rrr	�normal_body�r`z!_encode_text.<locals>.normal_bodycss|]}t|�VqdSr)rR)r9�xrrr	�	<genexpr>�sz_encode_text.<locals>.<genexpr>r)�default�7bit�8bit�surrogateescape�
zlatin-1�base64�quoted-printablez$Unknown content transfer encoding {})�encode�
splitlinesr^�maxrWr)�UnicodeDecodeErrorZcte_typerZbody_encoderTrUrRrYr@rA)�stringr*�cter=r\r_rbZsniffZsniff_qpZsniff_base64rVrr]r	�_encode_text�sD
�



�
rr�plain�utf-8c
Csdt|d||	�t||||j�\}}
|�|
�|jdtjj�||�dd�||d<t	|||||�dS)Nr/r*T)r'�Content-Transfer-Encoding)
rErrr=�set_payloadrGr?r*ZALIASES�getrM)rrprBr*rqrIrFrJrKrCZpayloadrrr	�set_text_content�s
�rx�rfc822c		Cs�|dkrtd��|dkr@|dkr.td�|���|dkr:dn|}n0|dkrd|dkr^td	�|���d
}n|dkrpd
}t|d||�|�|g�||d<t|||||�dS)
N�partialz4message/partial is not supported for Message objectsry)Nrfrg�binaryz*message/rfc822 parts do not support cte={}rgz
external-body)Nrfz1message/external-body parts do not support cte={}rfr7ru)r@rArErvrM)	rr7rBrqrIrFrJrKrCrrr	�set_message_content�s(��r|rjc

Cs�t||||	�|dkr(t||jjd�}nN|dkrNtj|dddd�}|�d�}n(|dkrb|�d�n|d	krv|�dd
�}|�|�||d<t	|||||�dS)Nrj)rWrkFT)�istextr:Z	quotetabsrPrf)rgr{rhru)
rErYr=rWrTZb2a_qpr)rlrvrM)
rrVrrBrqrIrFrJrKrCrrr	�set_bytes_content�s
r~)r')rsrtNNNNNN)ryNNNNNN)rjNNNNN)rTZ
email.charsetr?Z
email.messageZemail.errorsrrZraw_data_managerr.r
r2�splitrr4rBr6rErMrYrrrxr�strr|r7ZMessager~r5�	bytearray�
memoryviewr#rrrr	�<module>s^6
�	'�
�
�
PK�"�\#jq�0�0_parseaddr.cpython-38.pycnu�[���U

e5dE�@s�dZddddgZddlZddlZdZdZd	Zd
ddd
dddddddddddddddddddd gZd!d"d#d$d%d&d'gZddddd(d)d*d(d+d*d,d+d-d,d.�Z	d/d�Z
d0d1�Zd2d�Zd3d�Z
d4d�ZGd5d6�d6�ZGd7d8�d8e�ZdS)9zcEmail address parsing code.

Lifted directly from rfc822.py.  This should eventually be rewritten.
�	mktime_tz�	parsedate�parsedate_tz�quote�N� �z, ZjanZfebZmarZaprZmayZjunZjulZaug�sep�octZnovZdecZjanuaryZfebruaryZmarchZaprilZjuneZjulyZaugustZ	septemberZoctoberZnovemberZdecemberZmonZtueZwedZthuZfriZsatZsunip���i���i���i����iD���i��)ZUTZUTCZGMT�ZZASTZADTZESTZEDTZCSTZCDTZMSTZMDTZPSTZPDTcCs,t|�}|sdS|ddkr$d|d<t|�S)zQConvert a date string to a time tuple.

    Accounts for military timezones.
    N�	r)�
_parsedate_tz�tuple)�data�res�r�(/usr/lib64/python3.8/email/_parseaddr.pyr-sc
Cs�|sdS|��}|sdS|d�d�s6|d��tkr>|d=n.|d�d�}|dkrl|d|dd�|d<t|�dkr�|d�d�}t|�dkr�||dd�}t|�dk�r|d}|�d�}|d	kr�|�d�}|dkr�|d|�||d�g|dd�<n
|�d
�t|�dk�rdS|dd�}|\}}}}}|��}|tk�rb||��}}|tk�rbdSt�	|�d}|dk�r�|d8}|d	dk�r�|dd	�}|�d
�}|dk�r�||}}|d	dk�r�|dd	�}|d�
��s�||}}|d	dk�r|dd	�}|�d
�}t|�dk�r,|\}	}
d}n~t|�dk�rF|\}	}
}ndt|�dk�r�d|dk�r�|d�d�}t|�dk�r�|\}	}
d}nt|�dk�r�|\}	}
}ndSz,t|�}t|�}t|	�}	t|
�}
t|�}Wntk
�r�YdSX|dk�r|dk�r|d7}n|d7}d}|�
�}|tk�r6t|}n>zt|�}Wntk
�rXYnX|dk�rt|�d��rtd}|�r�|dk�r�d	}
|}nd}
|
|dd|dd}||||	|
|ddd	|g
S)a�Convert date to extended time tuple.

    The last (additional) element is the time zone offset in seconds, except if
    the timezone was specified as -0000.  In that case the last element is
    None.  This indicates a UTC timestamp that explicitly declaims knowledge of
    the source timezone, as opposed to a +0000 timestamp that indicates the
    source timezone really was UTC.

    Nr�,���-��+���r���:��0�.�d�Dili�i�<)�split�endswith�lower�	_daynames�rfind�len�find�append�_monthnames�index�isdigit�int�
ValueError�upper�
_timezones�
startswith)r�iZstuff�sZddZmmZyyZtmZtzZthhZtmmZtssZtzoffsetZtzsignrrrr9s�


"














rcCs&t|�}t|t�r|dd�S|SdS)z&Convert a time string to a time tuple.Nr)r�
isinstancer
�r�trrrr�s
cCs<|ddkr"t�|dd�d�St�|�}||dSdS)zETurn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.rN�)r)�time�mktime�calendarZtimegmr5rrrr�s
cCs|�dd��dd�S)z�Prepare string to be used in a quoted string.

    Turns backslash and double quote characters into quoted pairs.  These
    are the only characters that need to be quoted inside a quoted string.
    Does not add the surrounding double quotes.
    �\z\\�"z\")�replace)�strrrrr�sc@s|eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zddd�Zdd�ZdS) �
AddrlistClassaAddress parser class by Ben Escoto.

    To understand what this class does, it helps to have a copy of RFC 2822 in
    front of you.

    Note: this class interface is deprecated and may be removed in the future.
    Use email.utils.AddressList instead.
    cCsZd|_d|_d|_d|_|j|j|_|j|j|j|_|j�dd�|_||_g|_	dS)z�Initialize a new instance.

        `field' is an unparsed address header field, containing
        one or more addresses.
        z()<>@,:;."[]rz 	z
rrN)
�specials�pos�LWSZCR�FWS�atomendsr=�
phraseends�field�commentlist��selfrFrrr�__init__�szAddrlistClass.__init__cCs�g}|jt|j�kr�|j|j|jdkr\|j|jdkrL|�|j|j�|jd7_q|j|jdkr�|j�|���qq�qt�|�S)z&Skip white space and extract comments.z

r�()	rAr'rFrBr)rG�
getcomment�EMPTYSTRING�join)rIZwslistrrr�gotonext�szAddrlistClass.gotonextcCs:g}|jt|j�kr6|��}|r*||7}q|�d�q|S)zVParse all addresses.

        Returns a list containing all of the addresses.
        )rr)rAr'rF�
getaddressr))rI�resultZadrrr�getaddrlist�s
zAddrlistClass.getaddrlistcCs�g|_|��|j}|j}|��}|��g}|jt|j�kr\|rXt�|j�|dfg}�n\|j|jdkr�||_||_|��}t�|j�|fg}�n"|j|jdk�rg}t|j�}|jd7_|jt|j�k�r�|��|j|k�r|j|jdk�r|jd7_�q�||�	�}q�n�|j|jdk�rx|�
�}|j�rft�|�dd�|j�d	|fg}nt�|�|fg}n@|�r�t�|j�|dfg}n"|j|j|jk�r�|jd7_|��|jt|j�k�r�|j|jd
k�r�|jd7_|S)zParse the next address.rz.@rr�;�<z (r�)r)rGrOrA�
getphraselistr'rF�SPACErN�getaddrspecrP�getrouteaddrr@)rIZoldposZoldcl�plistZ
returnlistZaddrspecZfieldlenZ	routeaddrrrrrPsX

���$zAddrlistClass.getaddresscCs�|j|jdkrdSd}|jd7_|��d}|jt|j�kr�|rT|��d}n~|j|jdkrv|jd7_q�n\|j|jdkr�|jd7_d}n8|j|jd	kr�|jd7_n|��}|jd7_q�|��q2|S)
z�Parse a route address (Return-path value).

        This method just skips all the route stuff and returns the addrspec.
        rTNFrr�>�@Tr)rFrArOr'�	getdomainrX)rIZexpectrouteZadlistrrrrYAs.
zAddrlistClass.getrouteaddrcCsTg}|��|jt|j�kr�d}|j|jdkrf|rH|d��sH|��|�d�|jd7_d}nd|j|jdkr�|�dt|����n<|j|j|j	kr�|r�|d��s�|��q�n|�|�
��|��}|r|r|�|�q|jt|j�k�s
|j|jdk�rt�|�S|�d�|jd7_|��|�
�}|�sFtSt�|�|S)	zParse an RFC 2822 addr-spec.TrrrFr<z"%s"r\)rOrAr'rF�strip�popr)r�getquoterD�getatomrMrNr])rIZaslistZpreserve_wsZwsZdomainrrrrXas:
$

zAddrlistClass.getaddrspeccCs�g}|jt|j�kr�|j|j|jkr6|jd7_q|j|jdkrX|j�|���q|j|jdkrx|�|���q|j|jdkr�|jd7_|�d�q|j|jdkr�tS|j|j|j	kr�q�q|�|�
��qt�|�S)z-Get the complete domain name from an address.rrK�[rr\)rAr'rFrBrGr)rL�getdomainliteralrMrDrarN)rIZsdlistrrrr]�s"zAddrlistClass.getdomainTcCs�|j|j|krdSdg}d}|jd7_|jt|j�kr�|rX|�|j|j�d}np|j|j|krz|jd7_q�nN|r�|j|jdkr�|�|���q,n(|j|jdkr�d}n|�|j|j�|jd7_q,t�|�S)a�Parse a header fragment delimited by special characters.

        `beginchar' is the start character for the fragment.
        If self is not looking at an instance of `beginchar' then
        getdelimited returns the empty string.

        `endchars' is a sequence of allowable end-delimiting characters.
        Parsing stops when one of these is encountered.

        If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed
        within the parsed fragment.
        rFrrKr;T)rFrAr'r)rLrMrN)rIZ	begincharZendcharsZ
allowcommentsZslistrrrr�getdelimited�s(
zAddrlistClass.getdelimitedcCs|�ddd�S)z1Get a quote-delimited fragment from self's field.r<z"
F�rd�rIrrrr`�szAddrlistClass.getquotecCs|�ddd�S)z7Get a parenthesis-delimited fragment from self's field.rKz)
TrerfrrrrL�szAddrlistClass.getcommentcCsd|�ddd�S)z!Parse an RFC 2822 domain-literal.z[%s]rbz]
Frerfrrrrc�szAddrlistClass.getdomainliteralNcCsddg}|dkr|j}|jt|j�krZ|j|j|kr8qZn|�|j|j�|jd7_qt�|�S)aParse an RFC 2822 atom.

        Optional atomends specifies a different set of end token delimiters
        (the default is to use self.atomends).  This is used e.g. in
        getphraselist() since phrase endings must not include the `.' (which
        is legal in phrases).rNr)rDrAr'rFr)rMrN)rIrDZatomlistrrrra�szAddrlistClass.getatomcCs�g}|jt|j�kr�|j|j|jkr6|jd7_q|j|jdkrV|�|���q|j|jdkrx|j�|���q|j|j|jkr�q�q|�|�	|j��q|S)z�Parse a sequence of RFC 2822 phrases.

        A phrase is a sequence of words, which are in turn either RFC 2822
        atoms or quoted-strings.  Phrases are canonicalized by squeezing all
        runs of continuous whitespace into one space.
        rr<rK)
rAr'rFrCr)r`rGrLrEra)rIrZrrrrV�szAddrlistClass.getphraselist)T)N)�__name__�
__module__�__qualname__�__doc__rJrOrRrPrYrXr]rdr`rLrcrarVrrrrr?�s	; &
%
r?c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�AddressListz@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs&t�||�|r|��|_ng|_dS�N)r?rJrR�addresslistrHrrrrJ�szAddressList.__init__cCs
t|j�Srl)r'rmrfrrr�__len__szAddressList.__len__cCs>td�}|jdd�|_|jD]}||jkr|j�|�q|Srl�rkrmr)�rI�otherZnewaddr�xrrr�__add__s

zAddressList.__add__cCs&|jD]}||jkr|j�|�q|Srl)rmr)�rIrqrrrrr�__iadd__s

zAddressList.__iadd__cCs.td�}|jD]}||jkr|j�|�q|Srlrorprrr�__sub__s


zAddressList.__sub__cCs&|jD]}||jkr|j�|�q|Srl)rm�removertrrr�__isub__s

zAddressList.__isub__cCs
|j|Srl)rm)rIr+rrr�__getitem__%szAddressList.__getitem__N)rgrhrirjrJrnrsrurvrxryrrrrrk�s	rk)rj�__all__r8r:rWrMZ
COMMASPACEr*r%r0rrrrrr?rkrrrr�<module>sd���	w	

/PK�"�\�*���encoders.cpython-38.opt-2.pycnu�[���U

e5d��@sPddddgZddlmZddlmZdd�Zd	d�Zd
d�Z	dd�Z
dd�Zd
S)�encode_7or8bit�
encode_base64�encode_noop�
encode_quopri�)�encodebytes)�encodestringcCst|dd�}|�dd�S)NT)Z	quotetabs� s=20)�
_encodestring�replace)�s�enc�r
�&/usr/lib64/python3.8/email/encoders.py�_qencodesrcCs0|jdd�}tt|�d�}|�|�d|d<dS)NT��decode�ascii�base64�Content-Transfer-Encoding)�get_payload�str�_bencode�set_payload��msg�origZencdatar
r
rrs
cCs*|jdd�}t|�}|�|�d|d<dS)NTrzquoted-printabler)rrrrr
r
rr&s
cCsX|jdd�}|dkr d|d<dSz|�d�Wntk
rJd|d<Yn
Xd|d<dS)NTrZ7bitrrZ8bit)rr�UnicodeError)rrr
r
rr2scCsdS)Nr
)rr
r
rrDsN)�__all__rrr�quoprirr	rrrrrr
r
r
r�<module>s�PK�"�\�.]��9�9 _policybase.cpython-38.opt-1.pycnu�[���U

e5d�:�@s�dZddlZddlmZddlmZddlmZdddgZGd	d
�d
�Z	dd�Z
d
d�ZGdd�de	ejd�Z
eGdd�de
��Ze�ZdS)zwPolicy framework for the email package.

Allows fine grained feature control of how the package parses and emits data.
�N)�header)�charset)�_has_surrogates�Policy�Compat32�compat32cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�_PolicyBasea�Policy Object basic framework.

    This class is useless unless subclassed.  A subclass should define
    class attributes with defaults for any values that are to be
    managed by the Policy object.  The constructor will then allow
    non-default values to be set for these attributes at instance
    creation time.  The instance will be callable, taking these same
    attributes keyword arguments, and returning a new instance
    identical to the called instance except for those values changed
    by the keyword arguments.  Instances may be added, yielding new
    instances with any non-default values from the right hand
    operand overriding those in the left hand operand.  That is,

        A + B == A(<non-default values of B>)

    The repr of an instance can be used to reconstruct the object
    if and only if the repr of the values can be used to reconstruct
    those values.

    csH|��D]:\}}t||�r.tt|��||�qtd�||jj���qdS)z�Create new Policy, possibly overriding some defaults.

        See class docstring for a list of overridable attributes.

        �*{!r} is an invalid keyword argument for {}N)	�items�hasattr�superr�__setattr__�	TypeError�format�	__class__�__name__)�self�kw�name�value�r��)/usr/lib64/python3.8/email/_policybase.py�__init__)s
��z_PolicyBase.__init__cCs*dd�|j��D�}d�|jjd�|��S)NcSsg|]\}}d�||��qS)z{}={!r})r)�.0rrrrr�
<listcomp>8s�z(_PolicyBase.__repr__.<locals>.<listcomp>z{}({})z, )�__dict__r
rrr�join)r�argsrrr�__repr__7s�z_PolicyBase.__repr__cKsr|j�|j�}|j��D]\}}t�|||�q|��D]4\}}t||�s^td�||jj	���t�|||�q8|S)z�Return a new instance with specified attributes changed.

        The new instance has the same attribute values as the current object,
        except for the changes passed in as keyword arguments.

        r	)
r�__new__rr
�objectr
rrrr)rrZ	newpolicy�attrrrrr�clone<s
��z_PolicyBase.clonecCs,t||�rd}nd}t|�|jj|���dS)Nz'{!r} object attribute {!r} is read-onlyz!{!r} object has no attribute {!r})r�AttributeErrorrrr)rrr�msgrrrr
Ns
z_PolicyBase.__setattr__cCs|jf|j�S)z�Non-default values from right operand override those from left.

        The object returned is a new instance of the subclass.

        )r#r)r�otherrrr�__add__Usz_PolicyBase.__add__)
r�
__module__�__qualname__�__doc__rrr#r
r'�
__classcell__rrrrrsrcCs,|�dd�d}|�dd�d}|d|S)N�
�r)�rsplit�split)�docZ	added_docrrr�_append_doc^sr1cCs�|jr(|j�d�r(t|jdj|j�|_|j��D]V\}}|jr2|j�d�r2dd�|jD�D]*}tt||�d�}|r\t||j�|_q2q\q2|S)N�+rcss |]}|��D]
}|VqqdS)N)�mro)r�base�crrr�	<genexpr>hs
z%_extend_docstrings.<locals>.<genexpr>r*)r*�
startswithr1�	__bases__rr
�getattr)�clsrr"r5r0rrr�_extend_docstringscsr;c@s�eZdZdZdZdZdZdZdZdZ	dd�Z
d	d
�Zdd�Ze
jd
d��Ze
jdd��Ze
jdd��Ze
jdd��Ze
jdd��ZdS)raI	Controls for how messages are interpreted and formatted.

    Most of the classes and many of the methods in the email package accept
    Policy objects as parameters.  A Policy object contains a set of values and
    functions that control how input is interpreted and how output is rendered.
    For example, the parameter 'raise_on_defect' controls whether or not an RFC
    violation results in an error being raised or not, while 'max_line_length'
    controls the maximum length of output lines when a Message is serialized.

    Any valid attribute may be overridden when a Policy is created by passing
    it as a keyword argument to the constructor.  Policy objects are immutable,
    but a new Policy object can be created with only certain values changed by
    calling the Policy instance with keyword arguments.  Policy objects can
    also be added, producing a new Policy object in which the non-default
    attributes set in the right hand operand overwrite those specified in the
    left operand.

    Settable attributes:

    raise_on_defect     -- If true, then defects should be raised as errors.
                           Default: False.

    linesep             -- string containing the value to use as separation
                           between output lines.  Default '\n'.

    cte_type            -- Type of allowed content transfer encodings

                           7bit  -- ASCII only
                           8bit  -- Content-Transfer-Encoding: 8bit is allowed

                           Default: 8bit.  Also controls the disposition of
                           (RFC invalid) binary data in headers; see the
                           documentation of the binary_fold method.

    max_line_length     -- maximum length of lines, excluding 'linesep',
                           during serialization.  None or 0 means no line
                           wrapping is done.  Default is 78.

    mangle_from_        -- a flag that, when True escapes From_ lines in the
                           body of the message by putting a `>' in front of
                           them. This is used when the message is being
                           serialized by a generator. Default: True.

    message_factory     -- the class to use to create new message objects.
                           If the value is None, the default is Message.

    Fr,Z8bit�NNcCs|jr
|�|�||�dS)aZBased on policy, either raise defect or call register_defect.

            handle_defect(obj, defect)

        defect should be a Defect subclass, but in any case must be an
        Exception subclass.  obj is the object on which the defect should be
        registered if it is not raised.  If the raise_on_defect is True, the
        defect is raised as an error, otherwise the object and the defect are
        passed to register_defect.

        This method is intended to be called by parsers that discover defects.
        The email package parsers always call it with Defect instances.

        N)�raise_on_defect�register_defect�r�objZdefectrrr�
handle_defect�szPolicy.handle_defectcCs|j�|�dS)a�Record 'defect' on 'obj'.

        Called by handle_defect if raise_on_defect is False.  This method is
        part of the Policy API so that Policy subclasses can implement custom
        defect handling.  The default implementation calls the append method of
        the defects attribute of obj.  The objects used by the email package by
        default that get passed to this method will always have a defects
        attribute with an append method.

        N)Zdefects�appendr?rrrr>�szPolicy.register_defectcCsdS)a[Return the maximum allowed number of headers named 'name'.

        Called when a header is added to a Message object.  If the returned
        value is not 0 or None, and there are already a number of headers with
        the name 'name' equal to the value returned, a ValueError is raised.

        Because the default behavior of Message's __setitem__ is to append the
        value to the list of headers, it is easy to create duplicate headers
        without realizing it.  This method allows certain headers to be limited
        in the number of instances of that header that may be added to a
        Message programmatically.  (The limit is not observed by the parser,
        which will faithfully produce as many headers as exist in the message
        being parsed.)

        The default implementation returns None for all header names.
        Nr)rrrrr�header_max_count�szPolicy.header_max_countcCst�dS)aZGiven a list of linesep terminated strings constituting the lines of
        a single header, return the (name, value) tuple that should be stored
        in the model.  The input lines should retain their terminating linesep
        characters.  The lines passed in by the email package may contain
        surrogateescaped binary data.
        N��NotImplementedError)r�sourcelinesrrr�header_source_parse�szPolicy.header_source_parsecCst�dS)z�Given the header name and the value provided by the application
        program, return the (name, value) that should be stored in the model.
        NrD�rrrrrr�header_store_parse�szPolicy.header_store_parsecCst�dS)awGiven the header name and the value from the model, return the value
        to be returned to the application program that is requesting that
        header.  The value passed in by the email package may contain
        surrogateescaped binary data if the lines were parsed by a BytesParser.
        The returned value should not contain any surrogateescaped data.

        NrDrHrrr�header_fetch_parse�s	zPolicy.header_fetch_parsecCst�dS)a�Given the header name and the value from the model, return a string
        containing linesep characters that implement the folding of the header
        according to the policy controls.  The value passed in by the email
        package may contain surrogateescaped binary data if the lines were
        parsed by a BytesParser.  The returned value should not contain any
        surrogateescaped data.

        NrDrHrrr�fold�s
zPolicy.foldcCst�dS)a%Given the header name and the value from the model, return binary
        data containing linesep characters that implement the folding of the
        header according to the policy controls.  The value passed in by the
        email package may contain surrogateescaped binary data.

        NrDrHrrr�fold_binaryszPolicy.fold_binary)rr(r)r*r=�linesep�cte_type�max_line_length�mangle_from_Zmessage_factoryrAr>rC�abc�abstractmethodrGrIrJrKrLrrrrrps(0

	



)�	metaclassc@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)rz�+
    This particular policy is the backward compatibility Policy.  It
    replicates the behavior of the email package version 5.1.
    TcCs0t|t�s|St|�r(tj|tj|d�S|SdS)N�r�header_name)�
isinstance�strrr�Header�_charset�UNKNOWN8BITrHrrr�_sanitize_headers

�zCompat32._sanitize_headercCs>|d�dd�\}}|�d�d�|dd��}||�d�fS)a:+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.

        r�:r-z 	�Nz
)r/�lstripr�rstrip)rrFrrrrrrG%szCompat32.header_source_parsecCs||fS)z>+
        The name and value are returned unmodified.
        rrHrrrrI1szCompat32.header_store_parsecCs|�||�S)z�+
        If the value contains binary data, it is converted into a Header object
        using the unknown-8bit charset.  Otherwise it is returned unmodified.
        )r[rHrrrrJ7szCompat32.header_fetch_parsecCs|j||dd�S)a+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  Non-ASCII binary data are CTE encoded using the
        unknown-8bit charset.

        T��sanitize)�_foldrHrrrrK>sz
Compat32.foldcCs"|j|||jdkd�}|�dd�S)a�+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  If cte_type is 7bit, non-ascii binary data is CTE
        encoded using the unknown-8bit charset.  Otherwise the original source
        header is used, with its existing line breaks and/or binary data.

        Z7bitr`�ascii�surrogateescape)rbrN�encode)rrrZfoldedrrrrLHs	zCompat32.fold_binarycCs�g}|�d|�t|t�r\t|�rL|r<tj|tj|d�}qZ|�|�d}q`tj||d�}n|}|dk	r�d}|jdk	r||j}|�|j	|j
|d��|�|j
�d�|�S)Nz%s: rT)rUr)rM�
maxlinelenr])rBrVrWrrrXrYrZrOrerMr)rrrra�parts�hrfrrrrbTs(
�


zCompat32._foldN)rr(r)r*rPr[rGrIrJrKrLrbrrrrrs
)r*rQZemailrrrYZemail.utilsr�__all__rr1r;�ABCMetarrrrrrr�<module>s �L
 fPK�"�\�~�z�0�0generator.cpython-38.opt-1.pycnu�[���U

e5d�N�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZd	Z
d
Ze�d�Ze�dej�ZGd
d�d�ZGdd�de�ZdZGdd�de�Zeeejd��ZdeZejZdS)z:Classes to generate plain text from a message object tree.�	Generator�DecodedGenerator�BytesGenerator�N)�deepcopy)�StringIO�BytesIO)�_has_surrogates�_�
z
\r\n|\r|\nz^From c@s�eZdZdZd'dd�dd�Zdd�Zd(d	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZeZdd�Zdd�Zdd �Zd!d"�Zed)d#d$��Zed%d&��ZdS)*rz�Generates output from a Message object tree.

    This basic generator writes the message to the given file object as plain
    text.
    N��policycCs6|dkr|dkrdn|j}||_||_||_||_dS)a�Create the generator for message flattening.

        outfp is the output file-like object for writing the message to.  It
        must have a write() method.

        Optional mangle_from_ is a flag that, when True (the default if policy
        is not set), escapes From_ lines in the body of the message by putting
        a `>' in front of them.

        Optional maxheaderlen specifies the longest length for a non-continued
        header.  When a header line is longer (in characters, with tabs
        expanded to 8 spaces) than maxheaderlen, the header will split as
        defined in the Header class.  Set maxheaderlen to zero to disable
        header wrapping.  The default is 78, as recommended (but not required)
        by RFC 2822.

        The policy keyword specifies a policy object that controls a number of
        aspects of the generator's operation.  If no policy is specified,
        the policy associated with the Message object passed to the
        flatten method is used.

        NT)�mangle_from_�_fp�
_mangle_from_�maxheaderlenr)�self�outfpr
rr�r�'/usr/lib64/python3.8/email/generator.py�__init__$szGenerator.__init__cCs|j�|�dS�N)r�write�r�srrrrDszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|�|j�|_d|_|�|j�|_|j}|j}zL||_||_|r�|�	�}|s�dt
�t
�
��}|�||j�|�
|�W5||_||_XdS)a�Print the message object tree rooted at msg to the output file
        specified when the Generator instance was created.

        unixfrom is a flag that forces the printing of a Unix From_ delimiter
        before the first object in the message tree.  If the original message
        has no From_ delimiter, a `standard' one is crafted.  By default, this
        is False to inhibit the printing of any From_ delimiter.

        Note that for subobjects, no From_ line is printed.

        linesep specifies the characters used to indicate a new line in
        the output.  The default value is determined by the policy specified
        when the Generator instance was created or, if none was specified,
        from the policy associated with the msg.

        N)�linesep�Zmax_line_length�zFrom nobody )r�clonerr�_NL�_encode�_encoded_NLZ_EMPTY�_encoded_EMPTYZget_unixfrom�time�ctimer�_write)r�msg�unixfromrrZold_gen_policyZold_msg_policyZufromrrr�flattenHs,
zGenerator.flattencCs|j||jd|jd�S)z1Clone this generator with the exact same options.Nr)�	__class__rr)r�fprrrrys
�zGenerator.clonecCst�Sr)r�rrrr�_new_buffer�szGenerator._new_buffercCs|Srrrrrrr�szGenerator._encodecCsT|sdSt�|�}|dd�D]}|�|�|�|j�q|drP|�|d�dS)N���)�NLCRE�splitrr)r�lines�linerrr�_write_lines�s

zGenerator._write_linescCs�|j}z"d|_|��|_}|�|�W5||_|j}|`X|r�t|�}|�d�dkrd|d|d<n|�d|d�|�d|d�t|dd�}|dkr�|�|�n||�|j�	|�
��dS)N�content-transfer-encodingr�Content-Transfer-Encoding�content-type��_write_headers)r�
_munge_cter+�	_dispatchr�getZreplace_header�getattrr6r�getvalue)rr%ZoldfpZ	munge_cteZsfp�methrrrr$�s&zGenerator._writecCst|��}|��}t�||f��dd�}t|d|d�}|dkrh|�dd�}t|d|d�}|dkrh|j}||�dS)N�-r	Z_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer:�
_writeBody)rr%�main�subZspecificr<Zgenericrrrr8�szGenerator._dispatchcCs6|��D]\}}|�|j�||��q|�|j�dSr)�	raw_itemsrrZfoldr�rr%�h�vrrrr6�szGenerator._write_headerscCs�|��}|dkrdSt|t�s.tdt|���t|j�r~|�d�}|dk	r~t|�}|d=|�	||�|��}|d|df|_
|jr�t�
d|�}|�|�dS)Nzstring payload expected: %s�charsetr2r4�>From )�get_payload�
isinstance�str�	TypeError�typer�_payloadZ	get_paramrZset_payloadr7r�fcrerEr1)rr%�payloadrJrrr�_handle_text�s$


�zGenerator._handle_textcCs�g}|��}|dkrg}n(t|t�r2|�|�dSt|t�sB|g}|D]6}|��}|�|�}|j|d|jd�|�	|�
��qF|��}|s�|j�
|�}|�|�}|�|�|jdk	r�|jr�t�d|j�}	n|j}	|�|	�|�|j�|�d||j�|�r|j�|�d��|D],}
|�|jd||j�|j�|
��q|�|jd|d|j�|jdk	�r�|j�r�t�d|j�}n|j}|�|�dS)NF�r&rrKz--r)rLrMrNr�listr+rr'r�appendr;Zget_boundaryr rA�_make_boundaryZset_boundary�preamblerrRrEr1r�pop�epilogue)rr%ZmsgtextsZsubparts�partr�g�boundaryZalltextrYZ	body_partr[rrr�_handle_multipartsJ







zGenerator._handle_multipartcCs0|j}|jdd�|_z|�|�W5||_XdS)Nrr)rrr_)rr%�prrr�_handle_multipart_signed<s
z"Generator._handle_multipart_signedcCs�g}|��D]t}|��}|�|�}|j|d|jd�|��}|�|j�}|rv|d|jkrv|�	|j�
|dd���q|�	|�q|j�|j�
|��dS)NFrUr,)
rLr+rr'rr;r.r r!rWrArr)rr%Zblocksr\rr]�textr/rrr�_handle_message_delivery_statusGs
z)Generator._handle_message_delivery_statuscCs^|��}|�|�}|j}t|t�rD|j|�d�d|jd�|��}n
|�	|�}|j
�|�dS)NrFrU)r+rrQrMrVr'rLrr;rrr)rr%rr]rSrrr�_handle_message\s




zGenerator._handle_messagecCsvt�tj�}dt|d}|dkr(|S|}d}|�dt�|�dtj�}|�	|�sXqr|dt
|�}|d7}q0|S)Nz===============z==rz^--z(--)?$�.r5)�randomZ	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINE�searchrN)�clsrb�tokenr^�bZcounterZcrerrrrXus

zGenerator._make_boundarycCst�||�Sr)rk�compile�ror�flagsrrrrj�szGenerator._compile_re)NN)FN)N)�__name__�
__module__�__qualname__�__doc__rrr'rr+rr1r$r8r6rTrCr_rarcrd�classmethodrXrjrrrrrs.	� 
1'
:csPeZdZdZdd�Zdd�Zdd�Zdd	�Z�fd
d�ZeZ	e
dd
��Z�ZS)ra�Generates a bytes version of a Message object tree.

    Functionally identical to the base Generator except that the output is
    bytes and not string.  When surrogates were used in the input to encode
    bytes, these are decoded back to bytes for output.  If the policy has
    cte_type set to 7bit, then the message is transformed such that the
    non-ASCII bytes are properly content transfer encoded, using the charset
    unknown-8bit.

    The outfp object must accept bytes in its write method.
    cCs|j�|�dd��dS)N�ascii�surrogateescape)rr�encoderrrrr�szBytesGenerator.writecCst�Sr)rr*rrrr+�szBytesGenerator._new_buffercCs
|�d�S�Nrz)r|rrrrr�szBytesGenerator._encodecCs8|��D]\}}|j�|j�||��q|�|j�dSr)rFrrrZfold_binaryrrGrrrr6�szBytesGenerator._write_headerscs\|jdkrdSt|j�rH|jjdksH|jr:t�d|j�|_|�|j�ntt	|��
|�dS)NZ7bitrK)rQrrZcte_typerrRrEr1�superrrT)rr%�r(rrrT�s
zBytesGenerator._handle_textcCst�|�d�|�Sr})rkrrr|rsrrrrj�szBytesGenerator._compile_re)
rurvrwrxrr+rr6rTrCryrj�
__classcell__rrrrr�s
zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s(eZdZdZddd�dd�Zdd�ZdS)	rz�Generates a text representation of a message.

    Like the Generator base class, except that non-text parts are substituted
    with a format string representing the part.
    NrcCs.tj|||||d�|dkr$t|_n||_dS)a�Like Generator.__init__() except that an additional optional
        argument is allowed.

        Walks through all subparts of a message.  If the subpart is of main
        type `text', then it prints the decoded payload of the subpart.

        Otherwise, fmt is a format string that is used instead of the message
        payload.  fmt is expanded with the following keywords (in
        %(keyword)s format):

        type       : Full MIME type of the non-text part
        maintype   : Main MIME type of the non-text part
        subtype    : Sub-MIME type of the non-text part
        filename   : Filename of the non-text part
        description: Description associated with the non-text part
        encoding   : Content transfer encoding of the non-text part

        The default value for fmt is None, meaning

        [Non-text (%(type)s) part of message omitted, filename %(filename)s]
        rN)rr�_FMTri)rrr
rZfmtrrrrr�s�zDecodedGenerator.__init__cCs�|��D]v}|��}|dkr2t|jdd�|d�q|dkr<qt|j|��|��|��|�d�|�dd�|�d	d
�d�|d�qdS)NrbF)�decode)�fileZ	multipartz
[no filename]zContent-Descriptionz[no description]r3z
[no encoding])rP�maintypeZsubtype�filenameZdescription�encoding)	�walkr>�printrLriZget_content_typer?�get_filenamer9)rr%r\r�rrrr8�s(���	�zDecodedGenerator._dispatch)NNN)rurvrwrxrr8rrrrr�s
�r5z%%0%dd)rx�__all__rkrgr"rf�copyr�iorrZemail.utilsrr@�NLrrr-rmrRrrr�r�len�reprrhZ_widthrirXrrrr�<module>s*

t3;PK�"�\#jq�0�0_parseaddr.cpython-38.opt-1.pycnu�[���U

e5dE�@s�dZddddgZddlZddlZdZdZd	Zd
ddd
dddddddddddddddddddd gZd!d"d#d$d%d&d'gZddddd(d)d*d(d+d*d,d+d-d,d.�Z	d/d�Z
d0d1�Zd2d�Zd3d�Z
d4d�ZGd5d6�d6�ZGd7d8�d8e�ZdS)9zcEmail address parsing code.

Lifted directly from rfc822.py.  This should eventually be rewritten.
�	mktime_tz�	parsedate�parsedate_tz�quote�N� �z, ZjanZfebZmarZaprZmayZjunZjulZaug�sep�octZnovZdecZjanuaryZfebruaryZmarchZaprilZjuneZjulyZaugustZ	septemberZoctoberZnovemberZdecemberZmonZtueZwedZthuZfriZsatZsunip���i���i���i����iD���i��)ZUTZUTCZGMT�ZZASTZADTZESTZEDTZCSTZCDTZMSTZMDTZPSTZPDTcCs,t|�}|sdS|ddkr$d|d<t|�S)zQConvert a date string to a time tuple.

    Accounts for military timezones.
    N�	r)�
_parsedate_tz�tuple)�data�res�r�(/usr/lib64/python3.8/email/_parseaddr.pyr-sc
Cs�|sdS|��}|sdS|d�d�s6|d��tkr>|d=n.|d�d�}|dkrl|d|dd�|d<t|�dkr�|d�d�}t|�dkr�||dd�}t|�dk�r|d}|�d�}|d	kr�|�d�}|dkr�|d|�||d�g|dd�<n
|�d
�t|�dk�rdS|dd�}|\}}}}}|��}|tk�rb||��}}|tk�rbdSt�	|�d}|dk�r�|d8}|d	dk�r�|dd	�}|�d
�}|dk�r�||}}|d	dk�r�|dd	�}|d�
��s�||}}|d	dk�r|dd	�}|�d
�}t|�dk�r,|\}	}
d}n~t|�dk�rF|\}	}
}ndt|�dk�r�d|dk�r�|d�d�}t|�dk�r�|\}	}
d}nt|�dk�r�|\}	}
}ndSz,t|�}t|�}t|	�}	t|
�}
t|�}Wntk
�r�YdSX|dk�r|dk�r|d7}n|d7}d}|�
�}|tk�r6t|}n>zt|�}Wntk
�rXYnX|dk�rt|�d��rtd}|�r�|dk�r�d	}
|}nd}
|
|dd|dd}||||	|
|ddd	|g
S)a�Convert date to extended time tuple.

    The last (additional) element is the time zone offset in seconds, except if
    the timezone was specified as -0000.  In that case the last element is
    None.  This indicates a UTC timestamp that explicitly declaims knowledge of
    the source timezone, as opposed to a +0000 timestamp that indicates the
    source timezone really was UTC.

    Nr�,���-��+���r���:��0�.�d�Dili�i�<)�split�endswith�lower�	_daynames�rfind�len�find�append�_monthnames�index�isdigit�int�
ValueError�upper�
_timezones�
startswith)r�iZstuff�sZddZmmZyyZtmZtzZthhZtmmZtssZtzoffsetZtzsignrrrr9s�


"














rcCs&t|�}t|t�r|dd�S|SdS)z&Convert a time string to a time tuple.Nr)r�
isinstancer
�r�trrrr�s
cCs<|ddkr"t�|dd�d�St�|�}||dSdS)zETurn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.rN�)r)�time�mktime�calendarZtimegmr5rrrr�s
cCs|�dd��dd�S)z�Prepare string to be used in a quoted string.

    Turns backslash and double quote characters into quoted pairs.  These
    are the only characters that need to be quoted inside a quoted string.
    Does not add the surrounding double quotes.
    �\z\\�"z\")�replace)�strrrrr�sc@s|eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zddd�Zdd�ZdS) �
AddrlistClassaAddress parser class by Ben Escoto.

    To understand what this class does, it helps to have a copy of RFC 2822 in
    front of you.

    Note: this class interface is deprecated and may be removed in the future.
    Use email.utils.AddressList instead.
    cCsZd|_d|_d|_d|_|j|j|_|j|j|j|_|j�dd�|_||_g|_	dS)z�Initialize a new instance.

        `field' is an unparsed address header field, containing
        one or more addresses.
        z()<>@,:;."[]rz 	z
rrN)
�specials�pos�LWSZCR�FWS�atomendsr=�
phraseends�field�commentlist��selfrFrrr�__init__�szAddrlistClass.__init__cCs�g}|jt|j�kr�|j|j|jdkr\|j|jdkrL|�|j|j�|jd7_q|j|jdkr�|j�|���qq�qt�|�S)z&Skip white space and extract comments.z

r�()	rAr'rFrBr)rG�
getcomment�EMPTYSTRING�join)rIZwslistrrr�gotonext�szAddrlistClass.gotonextcCs:g}|jt|j�kr6|��}|r*||7}q|�d�q|S)zVParse all addresses.

        Returns a list containing all of the addresses.
        )rr)rAr'rF�
getaddressr))rI�resultZadrrr�getaddrlist�s
zAddrlistClass.getaddrlistcCs�g|_|��|j}|j}|��}|��g}|jt|j�kr\|rXt�|j�|dfg}�n\|j|jdkr�||_||_|��}t�|j�|fg}�n"|j|jdk�rg}t|j�}|jd7_|jt|j�k�r�|��|j|k�r|j|jdk�r|jd7_�q�||�	�}q�n�|j|jdk�rx|�
�}|j�rft�|�dd�|j�d	|fg}nt�|�|fg}n@|�r�t�|j�|dfg}n"|j|j|jk�r�|jd7_|��|jt|j�k�r�|j|jd
k�r�|jd7_|S)zParse the next address.rz.@rr�;�<z (r�)r)rGrOrA�
getphraselistr'rF�SPACErN�getaddrspecrP�getrouteaddrr@)rIZoldposZoldcl�plistZ
returnlistZaddrspecZfieldlenZ	routeaddrrrrrPsX

���$zAddrlistClass.getaddresscCs�|j|jdkrdSd}|jd7_|��d}|jt|j�kr�|rT|��d}n~|j|jdkrv|jd7_q�n\|j|jdkr�|jd7_d}n8|j|jd	kr�|jd7_n|��}|jd7_q�|��q2|S)
z�Parse a route address (Return-path value).

        This method just skips all the route stuff and returns the addrspec.
        rTNFrr�>�@Tr)rFrArOr'�	getdomainrX)rIZexpectrouteZadlistrrrrYAs.
zAddrlistClass.getrouteaddrcCsTg}|��|jt|j�kr�d}|j|jdkrf|rH|d��sH|��|�d�|jd7_d}nd|j|jdkr�|�dt|����n<|j|j|j	kr�|r�|d��s�|��q�n|�|�
��|��}|r|r|�|�q|jt|j�k�s
|j|jdk�rt�|�S|�d�|jd7_|��|�
�}|�sFtSt�|�|S)	zParse an RFC 2822 addr-spec.TrrrFr<z"%s"r\)rOrAr'rF�strip�popr)r�getquoterD�getatomrMrNr])rIZaslistZpreserve_wsZwsZdomainrrrrXas:
$

zAddrlistClass.getaddrspeccCs�g}|jt|j�kr�|j|j|jkr6|jd7_q|j|jdkrX|j�|���q|j|jdkrx|�|���q|j|jdkr�|jd7_|�d�q|j|jdkr�tS|j|j|j	kr�q�q|�|�
��qt�|�S)z-Get the complete domain name from an address.rrK�[rr\)rAr'rFrBrGr)rL�getdomainliteralrMrDrarN)rIZsdlistrrrr]�s"zAddrlistClass.getdomainTcCs�|j|j|krdSdg}d}|jd7_|jt|j�kr�|rX|�|j|j�d}np|j|j|krz|jd7_q�nN|r�|j|jdkr�|�|���q,n(|j|jdkr�d}n|�|j|j�|jd7_q,t�|�S)a�Parse a header fragment delimited by special characters.

        `beginchar' is the start character for the fragment.
        If self is not looking at an instance of `beginchar' then
        getdelimited returns the empty string.

        `endchars' is a sequence of allowable end-delimiting characters.
        Parsing stops when one of these is encountered.

        If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed
        within the parsed fragment.
        rFrrKr;T)rFrAr'r)rLrMrN)rIZ	begincharZendcharsZ
allowcommentsZslistrrrr�getdelimited�s(
zAddrlistClass.getdelimitedcCs|�ddd�S)z1Get a quote-delimited fragment from self's field.r<z"
F�rd�rIrrrr`�szAddrlistClass.getquotecCs|�ddd�S)z7Get a parenthesis-delimited fragment from self's field.rKz)
TrerfrrrrL�szAddrlistClass.getcommentcCsd|�ddd�S)z!Parse an RFC 2822 domain-literal.z[%s]rbz]
Frerfrrrrc�szAddrlistClass.getdomainliteralNcCsddg}|dkr|j}|jt|j�krZ|j|j|kr8qZn|�|j|j�|jd7_qt�|�S)aParse an RFC 2822 atom.

        Optional atomends specifies a different set of end token delimiters
        (the default is to use self.atomends).  This is used e.g. in
        getphraselist() since phrase endings must not include the `.' (which
        is legal in phrases).rNr)rDrAr'rFr)rMrN)rIrDZatomlistrrrra�szAddrlistClass.getatomcCs�g}|jt|j�kr�|j|j|jkr6|jd7_q|j|jdkrV|�|���q|j|jdkrx|j�|���q|j|j|jkr�q�q|�|�	|j��q|S)z�Parse a sequence of RFC 2822 phrases.

        A phrase is a sequence of words, which are in turn either RFC 2822
        atoms or quoted-strings.  Phrases are canonicalized by squeezing all
        runs of continuous whitespace into one space.
        rr<rK)
rAr'rFrCr)r`rGrLrEra)rIrZrrrrV�szAddrlistClass.getphraselist)T)N)�__name__�
__module__�__qualname__�__doc__rJrOrRrPrYrXr]rdr`rLrcrarVrrrrr?�s	; &
%
r?c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�AddressListz@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs&t�||�|r|��|_ng|_dS�N)r?rJrR�addresslistrHrrrrJ�szAddressList.__init__cCs
t|j�Srl)r'rmrfrrr�__len__szAddressList.__len__cCs>td�}|jdd�|_|jD]}||jkr|j�|�q|Srl�rkrmr)�rI�otherZnewaddr�xrrr�__add__s

zAddressList.__add__cCs&|jD]}||jkr|j�|�q|Srl)rmr)�rIrqrrrrr�__iadd__s

zAddressList.__iadd__cCs.td�}|jD]}||jkr|j�|�q|Srlrorprrr�__sub__s


zAddressList.__sub__cCs&|jD]}||jkr|j�|�q|Srl)rm�removertrrr�__isub__s

zAddressList.__isub__cCs
|j|Srl)rm)rIr+rrr�__getitem__%szAddressList.__getitem__N)rgrhrirjrJrnrsrurvrxryrrrrrk�s	rk)rj�__all__r8r:rWrMZ
COMMASPACEr*r%r0rrrrrr?rkrrrr�<module>sd���	w	

/PK�"�\)Z��g?g?#headerregistry.cpython-38.opt-2.pycnu�[���U

e5dKQ�@svddlmZddlmZddlmZddlmZGdd�d�ZGdd�d�ZGd	d
�d
e	�Z
dd�ZGd
d�d�ZGdd�de�Z
Gdd�d�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd �d �ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&�ZGd'd(�d(�Ze
eeeeeeeeeeeeeeeeeeed)�ZGd*d+�d+�Zd,S)-�)�MappingProxyType)�utils)�errors)�_header_value_parserc@s^eZdZddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCs�d�td||||f��}d|ks(d|kr0td��|dk	r�|s@|rHtd��t�|�\}}|rjtd�||���|jrz|jd�|j}|j	}||_
||_||_dS)Nr�
�
z8invalid arguments; address parts cannot contain CR or LFz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)
�join�filter�
ValueError�	TypeError�parserZ
get_addr_spec�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_specZinputsZa_s�rest�r�,/usr/lib64/python3.8/email/headerregistry.py�__init__s&�
zAddress.__init__cCs|jS�N�r�rrrrr<szAddress.display_namecCs|jSr)rr rrrr@szAddress.usernamecCs|jSr)rr rrrrDszAddress.domaincCsTt|j�}t|�t|tj�kr.t�|j�}n|j}|jrH|d|jS|sPdS|S)N�@�<>)�setr�lenrZ
DOT_ATOM_ENDS�quote_stringr)r�namesetZlprrrrHs
zAddress.addr_speccCsd�|jj|j|j|j�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrrr rrr�__repr__Xs�zAddress.__repr__cCs^t|j�}t|�t|tj�kr.t�|j�}n|j}|rX|jdkrFdn|j}d�||�S|jS)Nr"rz{} <{}>)r#rr$r�SPECIALSr%rr)rr&�disprrrr�__str__]s
zAddress.__str__cCs8t|�t|�krdS|j|jko6|j|jko6|j|jkS�NF)�typerrr�r�otherrrr�__eq__hs
�
�zAddress.__eq__)rrrN)r(�
__module__�__qualname__r�propertyrrrrr)r,r1rrrrrs
*



rc@sFeZdZddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs||_|rt|�nt�|_dSr)r�tuple�
_addresses)rr�	addressesrrrrrszGroup.__init__cCs|jSrrr rrrr�szGroup.display_namecCs|jSr)r7r rrrr8�szGroup.addressescCsd�|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rr'r(rr8r rrrr)�s
�zGroup.__repr__cCs�|jdkr&t|j�dkr&t|jd�S|j}|dk	r\t|�}t|�t|tj�kr\t�|�}d�dd�|jD��}|r~d|n|}d�	||�S)N�r�, css|]}t|�VqdSr��str)�.0�xrrr�	<genexpr>�sz Group.__str__.<locals>.<genexpr>� z{}:{};)
rr$r8r<r#rr*r%r
r)rr+r&Zadrstrrrrr,�s
z
Group.__str__cCs,t|�t|�krdS|j|jko*|j|jkSr-)r.rr8r/rrrr1�s

�zGroup.__eq__)NN)
r(r2r3rr4rr8r)r,r1rrrrr5ps


r5c@sPeZdZdd�Zdd�Zedd��Zedd��Zd	d
�Ze	dd��Z
d
d�ZdS)�
BaseHeadercCs\dgi}|�||�t�|d�r4t�|d�|d<t�||d�}|d=|j|f|�|S)N�defects�decoded)�parserZ_has_surrogates�	_sanitizer<�__new__�init)�cls�name�value�kwdsrrrrrF�szBaseHeader.__new__cCs||_||_||_dSr)�_name�_parse_tree�_defects)rrI�
parse_treerBrrrrG�szBaseHeader.initcCs|jSr)rLr rrrrI�szBaseHeader.namecCs
t|j�Sr)r6rNr rrrrB�szBaseHeader.defectscCst|jj|jjt|�f|jfSr)�_reconstruct_headerr'r(�	__bases__r<�__dict__r rrr�
__reduce__�s��zBaseHeader.__reduce__cCst�||�Sr)r<rF)rHrJrrr�_reconstruct�szBaseHeader._reconstructc	Cs`t�t�t�|jd�t�dd�g�g�}|jrH|�t�t�dd�g��|�|j�|j	|d�S)Nzheader-name�:z
header-sepr@Zfws)�policy)
rZHeaderZHeaderLabelZ
ValueTerminalrIrM�appendZCFWSListZWhiteSpaceTerminal�fold)rrV�headerrrrrX�s
���zBaseHeader.foldN)r(r2r3rFrGr4rIrBrS�classmethodrTrXrrrrrA�s"




rAcCst||i��|�Sr)r.rT)Zcls_name�basesrJrrrrP
srPc@s&eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs"|�|�|d<t|d�|d<dS)NrOrC)�value_parserr<�rHrJrKrrrrDszUnstructuredHeader.parse)
r(r2r3�	max_count�staticmethodr�get_unstructuredr]rZrDrrrrr\s
r\c@seZdZdZdS)�UniqueUnstructuredHeaderr9N�r(r2r3r_rrrrrbsrbcsBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�
DateHeaderNcCsz|s6|d�t���d|d<d|d<t��|d<dSt|t�rJt�|�}||d<t�	|d�|d<|�
|d�|d<dS)NrB�datetimerrCrO)rWrZHeaderMissingRequiredValuerZ	TokenList�
isinstancer<rZparsedate_to_datetimeZformat_datetimer]r^rrrrD.s

zDateHeader.parsecs|�d�|_t�j||�dS)Nre)�pop�	_datetime�superrG�r�args�kw�r'rrrG<szDateHeader.initcCs|jSr)rhr rrrre@szDateHeader.datetime)r(r2r3r_r`rrar]rZrDrGr4re�
__classcell__rrrmrrds


rdc@seZdZdZdS)�UniqueDateHeaderr9NrcrrrrroEsrocsPeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�ZS)�
AddressHeaderNcCst�|�\}}|Sr)rZget_address_list)rJ�address_listrrrr]NszAddressHeader.value_parsercCs�t|t�rV|�|�|d<}g}|jD]"}|�t|jdd�|jD���q&t|j	�}n"t
|d�sf|g}dd�|D�}g}||d<||d<d�d	d�|D��|d
<d|kr�|�|d
�|d<dS)NrOcSs*g|]"}t|jpd|jpd|jp"d��qS)r)rrrr)r=Zmbrrr�
<listcomp>]s
�
�z'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs&g|]}t|d�std|g�n|�qS)r8N)�hasattrr5�r=�itemrrrrrfs��groupsrBr:cSsg|]}t|��qSrr;rurrrrrlsrC)rfr<r]r8rWr5rZ
all_mailboxes�listrrtr
)rHrJrKrqrwZaddrrBrrrrDTs*


��
�zAddressHeader.parsecs(t|�d��|_d|_t�j||�dS)Nrw)r6rg�_groupsr7rirGrjrmrrrGpszAddressHeader.initcCs|jSr)ryr rrrrwuszAddressHeader.groupscCs&|jdkr tdd�|jD��|_|jS)Ncss|]}|jD]
}|VqqdSr)r8)r=�group�addressrrrr?|s�z*AddressHeader.addresses.<locals>.<genexpr>)r7r6ryr rrrr8ys
zAddressHeader.addresses)
r(r2r3r_r`r]rZrDrGr4rwr8rnrrrmrrpJs


rpc@seZdZdZdS)�UniqueAddressHeaderr9Nrcrrrrr|�sr|c@seZdZedd��ZdS)�SingleAddressHeadercCs(t|j�dkrtd�|j���|jdS)Nr9z9value of single address header {} is not a single addressr)r$r8rrrIr rrrr{�s
�zSingleAddressHeader.addressN)r(r2r3r4r{rrrrr}�sr}c@seZdZdZdS)�UniqueSingleAddressHeaderr9Nrcrrrrr~�sr~csZeZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�ZS)�MIMEVersionHeaderr9cCs�|�|�|d<}t|�|d<|d�|j�|jdkr<dn|j|d<|j|d<|jdk	rtd�|d|d�|d<nd|d<dS)NrOrCrB�major�minorz{}.{}�version)r]r<�extendrr�r�r�rHrJrKrOrrrrD�s

zMIMEVersionHeader.parsecs6|�d�|_|�d�|_|�d�|_t�j||�dS)Nr�r�r�)rg�_version�_major�_minorrirGrjrmrrrG�szMIMEVersionHeader.initcCs|jSr)r�r rrrr��szMIMEVersionHeader.majorcCs|jSr)r�r rrrr��szMIMEVersionHeader.minorcCs|jSr)r�r rrrr��szMIMEVersionHeader.version)r(r2r3r_r`rZparse_mime_versionr]rZrDrGr4r�r�r�rnrrrmrr�s



rcs8eZdZdZedd��Z�fdd�Zedd��Z�Z	S)�ParameterizedMIMEHeaderr9cCsZ|�|�|d<}t|�|d<|d�|j�|jdkrBi|d<ndd�|jD�|d<dS)NrOrCrB�paramscSs&i|]\}}t�|���t�|��qSr)rrE�lower)r=rIrJrrr�
<dictcomp>�s�z1ParameterizedMIMEHeader.parse.<locals>.<dictcomp>)r]r<r�rr�r�rrrrD�s

�zParameterizedMIMEHeader.parsecs|�d�|_t�j||�dS)Nr�)rg�_paramsrirGrjrmrrrG�szParameterizedMIMEHeader.initcCs
t|j�Sr)rr�r rrrr��szParameterizedMIMEHeader.params)
r(r2r3r_rZrDrGr4r�rnrrrmrr��s
r�csJeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�ZS)	�ContentTypeHeadercs2t�j||�t�|jj�|_t�|jj�|_dSr)	rirGrrErM�maintype�	_maintype�subtype�_subtyperjrmrrrG�szContentTypeHeader.initcCs|jSr)r�r rrrr��szContentTypeHeader.maintypecCs|jSr)r�r rrrr��szContentTypeHeader.subtypecCs|jd|jS)N�/)r�r�r rrr�content_type�szContentTypeHeader.content_type)
r(r2r3r`rZparse_content_type_headerr]rGr4r�r�r�rnrrrmrr��s


r�cs2eZdZeej�Z�fdd�Zedd��Z	�Z
S)�ContentDispositionHeadercs2t�j||�|jj}|dkr"|nt�|�|_dSr)rirGrM�content_dispositionrrE�_content_disposition)rrkrlZcdrmrrrG�szContentDispositionHeader.initcCs|jSr)r�r rrrr��sz,ContentDispositionHeader.content_disposition)r(r2r3r`rZ parse_content_disposition_headerr]rGr4r�rnrrrmrr��s
r�csBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�ContentTransferEncodingHeaderr9cCs2|�|�|d<}t|�|d<|d�|j�dS�NrOrCrB�r]r<r�rr�rrrrDsz#ContentTransferEncodingHeader.parsecs"t�j||�t�|jj�|_dSr)rirGrrErM�cte�_cterjrmrrrGsz"ContentTransferEncodingHeader.initcCs|jSr)r�r rrrr�sz!ContentTransferEncodingHeader.cte)r(r2r3r_r`rZ&parse_content_transfer_encoding_headerr]rZrDrGr4r�rnrrrmrr��s

r�c@s&eZdZdZeej�Zedd��Z	dS)�MessageIDHeaderr9cCs2|�|�|d<}t|�|d<|d�|j�dSr�r�r�rrrrDszMessageIDHeader.parseN)
r(r2r3r_r`rZparse_message_idr]rZrDrrrrr�s
r�)Zsubject�datezresent-datez	orig-dateZsenderz
resent-sender�toz	resent-toZccz	resent-ccZbccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-typezcontent-dispositionzcontent-transfer-encodingz
message-idc@s4eZdZeedfdd�Zdd�Zdd�Zdd	�Zd
S)�HeaderRegistryTcCs&i|_||_||_|r"|j�t�dSr)�registry�
base_class�
default_class�update�_default_header_map)rr�r�Zuse_default_maprrrr9s
zHeaderRegistry.__init__cCs||j|��<dSr)r�r��rrIrHrrr�map_to_typeKszHeaderRegistry.map_to_typecCs,|j�|��|j�}td|j||jfi�S)N�_)r��getr�r�r.r(r�r�rrr�__getitem__QszHeaderRegistry.__getitem__cCs||||�Srr)rrIrJrrr�__call__Us
zHeaderRegistry.__call__N)	r(r2r3rAr\rr�r�r�rrrrr�5s�
r�N)�typesrZemailrrrrrr5r<rArPr\rbrdrorpr|r}r~rr�r�r�r�r�r�r�rrrr�<module>
sV`6d'7
%�PK�"�\�ͼc9@9@header.cpython-38.opt-1.pycnu�[���U

e5d&^�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z
e
jZdZd	Z
d
ZdZdZd
ZdZed�Zed�Ze�dejejB�Ze�d�Ze�d�ZejjZdd�Zddd�ZGdd�d�ZGdd�d�Z Gdd�de!�Z"dS)z+Header encoding and decoding functionality.�Header�
decode_header�make_header�N)�HeaderParseError)�charset�
� � z        ��Nz 	�us-asciizutf-8ai
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qQbB])  # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:c	Cs�t|d�rdd�|jD�St�|�s.|dfgSg}|��D]�}t�|�}d}|r:|�d�}|rj|��}d}|r~|�|ddf�|rL|�d��	�}|�d��	�}|�d�}|�|||f�qLq:g}	t
|�D]J\}
}|
dkr�|dr�||
d	dr�||
dd��r�|	�|
d�q�t|	�D]}||=�qg}
|D]�\}}}|dk�rV|
�||f�n�|d
k�r|t
j�|�}|
�||f�n~|dk�r�t|�d}|�r�|d
dd|�7}zt
j�|�}Wn tjk
�r�td��YnX|
�||f�ntd|���q2g}d}}|
D]v\}}t|t��r,t|d�}|dk�r@|}|}nB||k�rb|�||f�|}|}n |dk�rz|t|7}n||7}�q|�||f�|S)a;Decode a message header value without converting charset.

    Returns a list of (string, charset) pairs containing each of the decoded
    parts of the header.  Charset is None for non-encoded parts of the header,
    otherwise a lower-case string containing the name of the character set
    specified in the encoded string.

    header may be a string that may or may not contain RFC2047 encoded words,
    or it may be a Header object.

    An email.errors.HeaderParseError may be raised when certain decoding error
    occurs (e.g. a base64 decoding exception).
    �_chunkscSs(g|] \}}t�|t|��t|�f�qS�)�_charsetZ_encode�str)�.0�stringrrr�$/usr/lib64/python3.8/email/header.py�
<listcomp>Ms�z!decode_header.<locals>.<listcomp>NTrF���q�b�z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
�ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr�AssertionError�
isinstancer�bytes�BSPACE)�headerZwords�line�parts�firstZ	unencodedr�encodingZencodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetrrrr=s|
�




4







cCsFt|||d�}|D].\}}|dk	r4t|t�s4t|�}|�||�q|S)a�Create a Header from a sequence of pairs as returned by decode_header()

    decode_header() takes a header value string and returns a sequence of
    pairs of the format (decoded_string, charset) where charset is the string
    name of the character set.

    This function takes one of those sequence of pairs and returns a Header
    instance.  Optional maxlinelen, header_name, and continuation_ws are as in
    the Header constructor.
    )�
maxlinelen�header_name�continuation_wsN)rr-�Charsetr!)Zdecoded_seqr9r:r;�h�srrrrr�s�c@sJeZdZddd�Zdd�Zdd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)rNr�strictcCs||dkrt}nt|t�s t|�}||_||_g|_|dk	rH|�|||�|dkrTt}||_|dkrjd|_	nt
|�d|_	dS)aDCreate a MIME-compliant header that can contain many character sets.

        Optional s is the initial header value.  If None, the initial header
        value is not set.  You can later append to the header with .append()
        method calls.  s may be a byte string or a Unicode string, but see the
        .append() documentation for semantics.

        Optional charset serves two purposes: it has the same meaning as the
        charset argument to the .append() method.  It also sets the default
        character set for all subsequent .append() calls that omit the charset
        argument.  If charset is not provided in the constructor, the us-ascii
        charset is used both as s's initial charset and as the default for
        subsequent .append() calls.

        The maximum line length can be specified explicitly via maxlinelen. For
        splitting the first line to a shorter value (to account for the field
        header which isn't included in s, e.g. `Subject') pass in the name of
        the field in header_name.  The default maxlinelen is 78 as recommended
        by RFC 2822.

        continuation_ws must be RFC 2822 compliant folding whitespace (usually
        either a space or a hard tab) which will be prepended to continuation
        lines.

        errors is passed through to the .append() call.
        Nrr)�USASCIIr-r<r�_continuation_wsr
r!�
MAXLINELEN�_maxlinelen�
_headerlenr()�selfr>rr9r:r;�errorsrrr�__init__�s
zHeader.__init__c	Cs�|��g}d}d}|jD]�\}}|}|tjkrH|�dd�}|�dd�}|r�|o\|�|d�}|dkr�|dkr�|s�|�t�d}n|dkr�|s�|�t�|o�|�|d�}|}|�|�qt	�
|�S)z&Return the string value of the header.N�ascii�surrogateescape�replacer�Nr���)�
_normalizer
r�UNKNOWN8BIT�encoder)�	_nonctextr!�SPACE�EMPTYSTRING�join)	rEZuchunks�lastcs�	lastspacerrZnextcsZoriginal_bytes�hasspacerrr�__str__�s*


zHeader.__str__cCs|t|�kS�N)r)rE�otherrrr�__eq__sz
Header.__eq__cCs�|dkr|j}nt|t�s"t|�}t|t�sZ|jp4d}|tjkrN|�dd�}n|�||�}|jpbd}|tjkr�z|�||�Wn"t	k
r�|dkr��t
}YnX|j�||f�dS)a.Append a string to the MIME header.

        Optional charset, if given, should be a Charset instance or the name
        of a character set (which will be converted to a Charset instance).  A
        value of None (the default) means that the charset given in the
        constructor is used.

        s may be a byte string or a Unicode string.  If it is a byte string
        (i.e. isinstance(s, str) is false), then charset is the encoding of
        that byte string, and a UnicodeError will be raised if the string
        cannot be decoded with that charset.  If s is a Unicode string, then
        charset is a hint specifying the character set of the characters in
        the string.  In either case, when producing an RFC 2822 compliant
        header using RFC 2047 rules, the string will be encoded using the
        output codec of the charset.  If the string cannot be encoded to the
        output codec, a UnicodeError will be raised.

        Optional `errors' is passed as the errors argument to the decode
        call if s is a byte string.
        NrrI)
rr-r<rZinput_codecrNr)Zoutput_codecrO�UnicodeEncodeError�UTF8r
r!)rEr>rrFZ
input_charsetZoutput_charsetrrrr!	s$






z
Header.appendcCs|��p|dkS)z=True if string s is not a ctext character of RFC822.
        )�(�)�\)r$)rEr>rrrrP4szHeader._nonctext�;, 	rcCs�|��|dkr|j}|dkr"d}t|j||j|�}d}d}}|jD�]\}}	|dk	r�|oh|�|d�}|dkr�|r~|	dkr�|��n|	dkr�|s�|��|o�|�|d�}|	}d}|��}
|
r�|�	d|
d|	�n|�	dd|	�|
dd�D]`}|�
�|	jdk	�r"|�	|jd	|��|	�q�|��}|dt
|�t
|��}
|�	|
||	�q�t
|
�dkrF|�
�qF|j�rx|��|�|�}t�|��r�td
�|���|S)a�Encode a message header into an RFC-compliant format.

        There are many issues involved in converting a given string for use in
        an email header.  Only certain character sets are readable in most
        email clients, and as header strings can only contain a subset of
        7-bit ASCII, care must be taken to properly convert and encode (with
        Base64 or quoted-printable) header strings.  In addition, there is a
        75-character length limit on any given encoded header field, so
        line-wrapping must be performed, even with double-byte character sets.

        Optional maxlinelen specifies the maximum length of each generated
        line, exclusive of the linesep string.  Individual lines may be longer
        than maxlinelen if a folding point cannot be found.  The first line
        will be shorter by the length of the header name plus ": " if a header
        name was specified at Header construction time.  The default value for
        maxlinelen is determined at header construction time.

        Optional splitchars is a string containing characters which should be
        given extra weight by the splitting algorithm during normal header
        wrapping.  This is in very rough support of RFC 2822's `higher level
        syntactic breaks':  split points preceded by a splitchar are preferred
        during line splitting, with the characters preferred in the order in
        which they appear in the string.  Space and tab may be included in the
        string to indicate whether preference should be given to one over the
        other as a split point when other split chars do not appear in the line
        being split.  Splitchars does not affect RFC 2047 encoded lines.

        Optional linesep is a string to be used to separate the lines of
        the value.  The default value is the most useful for typical
        Python applications, but it can be set to \r\n to produce RFC-compliant
        line separators when needed.
        Nri@BrKrLFr
rrz8header value appears to contain an embedded header: {!r})rMrC�_ValueFormatterrDrAr
rP�add_transitionr�feed�newline�header_encodingr r(�_str�_embedded_headerrr�format)rE�
splitcharsr9�linesepZ	formatterrTrVrUrr�linesr1Zsline�fws�valuerrrrO9sZ!�
�

�z
Header.encodecCsxg}d}g}|jD]B\}}||kr.|�|�q|dk	rJ|�t�|�|f�|g}|}q|rn|�t�|�|f�||_dSrX)r
r!rQrS)rEZchunksr8Z
last_chunkrrrrrrM�szHeader._normalize)NNNNrr?)Nr?)r`Nr)
�__name__�
__module__�__qualname__rGrWrZr!rPrOrMrrrrr�s�
/ 
+
Pc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)racCs0||_||_t|�|_||_g|_t|�|_dSrX)�_maxlenrAr(�_continuation_ws_len�_splitchars�_lines�_Accumulator�
_current_line)rEZ	headerlen�maxlenr;rirrrrG�s
z_ValueFormatter.__init__cCs|��|�|j�SrX)rdrSrt)rErjrrrrf�sz_ValueFormatter._strcCs
|�t�SrX)rf�NL�rErrrrW�sz_ValueFormatter.__str__cCsv|j��}|dkr|jj|�t|j�dkrh|j��rV|jrV|jdt|j�7<n|j�t|j��|j��dS)N)rr
rrL)	rvr�pushr(�	is_onlywsrtrr!�reset)rEZend_of_linerrrrd�s
z_ValueFormatter.newlinecCs|j�dd�dS)Nrr
)rvrzryrrrrb�sz_ValueFormatter.add_transitioncCs�|jdkr|�|||j�dS|�||���}z|�d�}Wntk
rRYdSX|dk	rh|�||�z|��}Wntk
r�YdSX|��|j	�
|j|�|D]}|j�
|j|�q�dS�Nr)re�_ascii_splitrsZheader_encode_lines�_maxlengthsr�
IndexError�
_append_chunkrdrvrzrArtr!)rErlrrZ
encoded_linesZ
first_line�	last_liner1rrrrc�s$
z_ValueFormatter.feedccs&|jt|j�V|j|jVqdSrX)rqr(rvrrryrrrr�sz_ValueFormatter._maxlengthscCsft�dtd||�}|dr0dg|dd�<n
|�d�tt|�gd�D]\}}|�||�qLdS)Nz([z]+)rr
r)�rer�FWSr�zip�iterr�)rErlrrir2�partrrrr~�s
z_ValueFormatter._ascii_splitcCs|j�||�t|j�|jk�r|jD]v}t|j��ddd�D]T}|��rn|j|d}|rn|d|krnq�|j|dd}|r@|d|kr@q�q@q&q�q&|j��\}}|jj	dkr�|�
�|s�d}|j�||�dS|j�|�}|j�
t|j��|j�|�dS)NrrrLr)rvrzr(rqrs�range�
part_countr$r�
_initial_sizerd�pop_fromrtr!rr|)rErlrZch�iZprevpartr�Z	remainderrrrr��s.
z_ValueFormatter._append_chunkN)rnrorprGrfrWrdrbrcrr~r�rrrrra�s%racsjeZdZd�fdd�	Zdd�Zddd�Z�fdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
�fdd�Z�ZS)rurcs||_t���dSrX)r��superrG)rEZinitial_size��	__class__rrrGsz_Accumulator.__init__cCs|�||f�dSrX)r!)rErlrrrrrz#sz_Accumulator.pushcCs||d�}g||d�<|SrXr)rEr�Zpoppedrrrr�&sz_Accumulator.pop_fromcs|��dkrdSt���S)Nr)r
r
)r�r�rryr�rrr+sz_Accumulator.popcCstdd�|D�|j�S)Ncss"|]\}}t|�t|�VqdSrX)r(�rrlr�rrr�	<genexpr>1sz'_Accumulator.__len__.<locals>.<genexpr>)�sumr�ryrrr�__len__0s�z_Accumulator.__len__cCst�dd�|D��S)Ncss |]\}}t�||f�VqdSrX�rRrSr�rrrr�5s�z'_Accumulator.__str__.<locals>.<genexpr>r�ryrrrrW4s
�z_Accumulator.__str__NcCs"|dkrg}||dd�<d|_dSr})r�)rEZstartvalrrrr|8sz_Accumulator.resetcCs|jdko|pt|���Sr})r�rr$ryrrrr{>sz_Accumulator.is_onlywscs
t���SrX)r�r�ryr�rrr�Asz_Accumulator.part_count)r)r)N)
rnrorprGrzr�rr�rWr|r{r��
__classcell__rrr�rrus

ru)NNr)#�__doc__�__all__r�r*Zemail.quoprimimer&Zemail.base64mimeZemail.errorsrrrr<rxrQr/ZSPACE8rRrBr�r@r\�compile�VERBOSE�	MULTILINErZfcrergr'Z_max_appendrrrra�listrurrrr�<module>sF�
�

_�
kPK�"�\�['ʥ�base64mime.cpython-38.pycnu�[���U

e5d�
�@stdZddddddgZddlmZdd	lmZmZd
ZdZdZ	d
Z
dd�Zddd�Zdefdd�Z
dd�ZeZeZdS)a�Base64 content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode arbitrary 8-bit data using the three 8-bit bytes in four 7-bit
characters encoding known as Base64.

It is used in the MIME standards for email to attach images, audio, and text
using some 8-bit character sets to messages.

This module provides an interface to encode and decode both headers and bodies
with Base64 encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:, From:, Cc:, etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character conversion
necessary for proper internationalized headers; it only does dumb encoding and
decoding.  To deal with the various line wrapping issues, use the email.header
module.
�body_decode�body_encode�decode�decodestring�
header_encode�
header_length�)�	b64encode)�
b2a_base64�
a2b_base64z
�
��cCs*tt|�d�\}}|d}|r&|d7}|S)z6Return the length of s when it is encoded with base64.��)�divmod�len)�	bytearrayZgroups_of_3Zleftover�n�r�(/usr/lib64/python3.8/email/base64mime.pyr2s
�
iso-8859-1cCs6|sdSt|t�r|�|�}t|��d�}d||fS)z�Encode a single header line with Base64 encoding in a given charset.

    charset names the character set to use to encode the header.  It defaults
    to iso-8859-1.  Base64 encoding is defined in RFC 2045.
    r�asciiz=?%s?b?%s?=)�
isinstance�str�encoderr)Zheader_bytes�charsetZencodedrrrr=s

�LcCs~|s|Sg}|dd}tdt|�|�D]J}t||||���d�}|�t�rh|tkrh|dd�|}|�|�q(t�|�S)a1Encode a string with base64.

    Each line will be wrapped at, at most, maxlinelen characters (defaults to
    76 characters).

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.
    rrrrN���)	�rangerr	r�endswith�NL�append�EMPTYSTRING�join)�sZ
maxlinelenZeolZencvecZ
max_unencoded�i�encrrrrLs
cCs.|s
t�St|t�r"t|�d��St|�SdS)z�Decode a raw base64 string, returning a bytes object.

    This function does not parse a full MIME header value encoded with
    base64 (like =?iso-8859-1?b?bmloISBuaWgh?=) -- please use the high
    level email.header class for that functionality.
    zraw-unicode-escapeN)�bytesrrr
r)�stringrrrrfs

N)r)�__doc__�__all__�base64rZbinasciir	r
ZCRLFr r"ZMISC_LENrrrrrrrrrr�<module>s&�

PK�"�\o��c��#contentmanager.cpython-38.opt-1.pycnu�[���U

e5d�)�@s.ddlZddlZddlZddlZddlmZGdd�d�Ze�Zd%dd�Ze�	de�d	d
�Z
d��D]Ze�	ee
�qfdd
�Z
d��D]Ze�	dee
�q�dd�Ze�	de�dd�Zdd�Zdd�Zdd�Zd&dd�Ze�ee�d'd d!�Ze�ejje�d(d#d$�ZeeefD]Ze�ee��qdS))�N)�
quoprimimec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContentManagercCsi|_i|_dS�N)�get_handlers�set_handlers)�self�r�,/usr/lib64/python3.8/email/contentmanager.py�__init__	szContentManager.__init__cCs||j|<dSr)r)r�key�handlerrrr	�add_get_handler
szContentManager.add_get_handlercOs||��}||jkr(|j||f|�|�S|��}||jkrP|j||f|�|�Sd|jkrp|jd|f|�|�St|��dS)N�)Zget_content_typer�get_content_maintype�KeyError)r�msg�args�kwZcontent_type�maintyperrr	�get_contents


zContentManager.get_contentcCs||j|<dSr)r)rZtypekeyrrrr	�add_set_handlerszContentManager.add_set_handlercOs>|��dkrtd��|�||�}|��|||f|�|�dS)NZ	multipartz"set_content not valid on multipart)r�	TypeError�_find_set_handlerZ
clear_content)rr�objrrrrrr	�set_contents
zContentManager.set_contentc	Cs�d}t|�jD]�}||jkr*|j|S|j}t|dd�}|rNd�||f�n|}|dkr^|}||jkrv|j|S||jkr�|j|S|j}||jkr|j|Sqd|jkr�|jdSt|��dS)N�
__module__r�.)�type�__mro__r�__qualname__�getattr�join�__name__r)	rrrZfull_path_for_error�typZqname�modname�	full_path�namerrr	r's&





z ContentManager._find_set_handlerN)	r"rrr
r
rrrrrrrr	rs	r�replacecCs&|jdd�}|�dd�}|j||d�S)NT��decode�charset�ASCII)�errors)�get_payloadZ	get_paramr))rr,Zcontentr*rrr	�get_text_content@sr.�textcCs|jdd�S)NTr(�r-�rrrr	�get_non_text_contentGsr2zaudio image video applicationcCs
|�d�S�Nrr0r1rrr	�get_message_contentMsr4zrfc822 external-bodyzmessage/cCst|�d��Sr3)�bytesr-r1rrr	�%get_and_fixup_unknown_message_contentSsr6�messagec
s�d�||f�|d<|r�t|dd�s<|j��fdd�|D�}z(|D]}|jrV|jd�|||j<qBWn@tjjk
r�}ztd�	|j
|jd���|�W5d}~XYnXdS)	N�/zContent-Typerr&csg|]}�j��|g���qSr)Zheader_factoryZheader_source_parse)�.0�header�Zmprr	�
<listcomp>ds�z _prepare_set.<locals>.<listcomp>zInvalid header: {})�policy)r!�hasattrr=Zdefectsr&�emailr,ZHeaderDefect�
ValueError�formatZfold)rr�subtype�headersr:�excrr;r	�_prepare_set_s$
�
��rEcCsx|dkr|dk	rd}|dk	r$||d<|dk	r>|jd|ddd�|dk	rN||d<|dk	rt|��D]\}}|�||�q^dS)NZ
attachmentzContent-Disposition�filenameT)r:r'z
Content-ID)�	set_param�items)r�dispositionrF�cid�paramsr�valuerrr	�
_finalize_setps�rMcCsVg}|dd}tdt|�|�D]*}||||�}|�t�|��d��q d�|�S)N��r�asciir)�range�len�append�binascii�
b2a_base64r)r!)�data�max_line_lengthZ
encoded_linesZunencoded_bytes_per_line�iZthislinerrr	�_encode_base64�srYcs�|�|���}|j�d���fdd�}dd�}|dkr�tdd�|D�dd	�|jkr�zd
||��d�fWStk
rzYnX|jdkr�d||��dd�fS||dd
��}t�	|�d�|j�}t
�|�}	t|�t|	�kr�d}nd}t|�d
kr�||fS|d
k�r||��d�}
nj|dk�r,||��dd�}
nN|dk�rPt�	||��d�|j�}
n*|dk�rlt
||�|j�}
ntd�|���||
fS)NrPcs��|��Sr�r!��lines��lineseprr	�
embedded_body��z#_encode_text.<locals>.embedded_bodycSsd�|�dS)N�
rZr[rrr	�normal_body�r`z!_encode_text.<locals>.normal_bodycss|]}t|�VqdSr)rR)r9�xrrr	�	<genexpr>�sz_encode_text.<locals>.<genexpr>r)�default�7bit�8bit�surrogateescape�
zlatin-1�base64�quoted-printablez$Unknown content transfer encoding {})�encode�
splitlinesr^�maxrWr)�UnicodeDecodeErrorZcte_typerZbody_encoderTrUrRrYr@rA)�stringr*�cter=r\r_rbZsniffZsniff_qpZsniff_base64rVrr]r	�_encode_text�sD
�



�
rr�plain�utf-8c
Csdt|d||	�t||||j�\}}
|�|
�|jdtjj�||�dd�||d<t	|||||�dS)Nr/r*T)r'�Content-Transfer-Encoding)
rErrr=�set_payloadrGr?r*ZALIASES�getrM)rrprBr*rqrIrFrJrKrCZpayloadrrr	�set_text_content�s
�rx�rfc822c		Cs�|dkrtd��|dkr@|dkr.td�|���|dkr:dn|}n0|dkrd|dkr^td	�|���d
}n|dkrpd
}t|d||�|�|g�||d<t|||||�dS)
N�partialz4message/partial is not supported for Message objectsry)Nrfrg�binaryz*message/rfc822 parts do not support cte={}rgz
external-body)Nrfz1message/external-body parts do not support cte={}rfr7ru)r@rArErvrM)	rr7rBrqrIrFrJrKrCrrr	�set_message_content�s(��r|rjc

Cs�t||||	�|dkr(t||jjd�}nN|dkrNtj|dddd�}|�d�}n(|dkrb|�d�n|d	krv|�dd
�}|�|�||d<t	|||||�dS)Nrj)rWrkFT)�istextr:Z	quotetabsrPrf)rgr{rhru)
rErYr=rWrTZb2a_qpr)rlrvrM)
rrVrrBrqrIrFrJrKrCrrr	�set_bytes_content�s
r~)r')rsrtNNNNNN)ryNNNNNN)rjNNNNN)rTZ
email.charsetr?Z
email.messageZemail.errorsrrZraw_data_managerr.r
r2�splitrr4rBr6rErMrYrrrxr�strr|r7ZMessager~r5�	bytearray�
memoryviewr#rrrr	�<module>s^6
�	'�
�
�
PK�"�\��-���errors.cpython-38.pycnu�[���U

e5d�
�@s8dZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�Z	Gdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�Zd'S)(a�distutils.errors

Provides exceptions used by the Distutils modules.  Note that Distutils
modules may raise standard exceptions; in particular, SystemExit is
usually raised for errors that are obviously the end-user's fault
(eg. bad command-line arguments).

This module is safe to use in "from ... import *" mode; it only exports
symbols whose names start with "Distutils" and end with "Error".c@seZdZdZdS)�DistutilsErrorzThe root of all Distutils evil.N��__name__�
__module__�__qualname__�__doc__�rr�(/usr/lib64/python3.8/distutils/errors.pyrsrc@seZdZdZdS)�DistutilsModuleErrorz�Unable to load an expected module, or to find an expected class
    within some module (in particular, command modules and classes).Nrrrrrr	sr	c@seZdZdZdS)�DistutilsClassErrorz�Some command class (or possibly distribution class, if anyone
    feels a need to subclass Distribution) is found not to be holding
    up its end of the bargain, ie. implementing some part of the
    "command "interface.Nrrrrrr
sr
c@seZdZdZdS)�DistutilsGetoptErrorz7The option table provided to 'fancy_getopt()' is bogus.Nrrrrrrsrc@seZdZdZdS)�DistutilsArgErrorzaRaised by fancy_getopt in response to getopt.error -- ie. an
    error in the command line usage.Nrrrrrrsrc@seZdZdZdS)�DistutilsFileErrorz�Any problems in the filesystem: expected file not found, etc.
    Typically this is for problems that we detect before OSError
    could be raised.Nrrrrrr
$sr
c@seZdZdZdS)�DistutilsOptionErrora�Syntactic/semantic errors in command options, such as use of
    mutually conflicting options, or inconsistent options,
    badly-spelled values, etc.  No distinction is made between option
    values originating in the setup script, the command line, config
    files, or what-have-you -- but if we *know* something originated in
    the setup script, we'll raise DistutilsSetupError instead.Nrrrrrr*src@seZdZdZdS)�DistutilsSetupErrorzqFor errors that can be definitely blamed on the setup script,
    such as invalid keyword arguments to 'setup()'.Nrrrrrr3src@seZdZdZdS)�DistutilsPlatformErrorz�We don't know how to do something on the current platform (but
    we do know how to do it on some platform) -- eg. trying to compile
    C files on a platform not supported by a CCompiler subclass.Nrrrrrr8src@seZdZdZdS)�DistutilsExecErrorz`Any problems executing an external program (such as the C
    compiler, when compiling C files).Nrrrrrr>src@seZdZdZdS)�DistutilsInternalErrorzoInternal inconsistencies or impossibilities (obviously, this
    should never be seen if the code is working!).NrrrrrrCsrc@seZdZdZdS)�DistutilsTemplateErrorz%Syntax error in a file list template.NrrrrrrHsrc@seZdZdZdS)�DistutilsByteCompileErrorzByte compile error.NrrrrrrKsrc@seZdZdZdS)�CCompilerErrorz#Some compile/link operation failed.NrrrrrrOsrc@seZdZdZdS)�PreprocessErrorz.Failure to preprocess one or more C/C++ files.NrrrrrrRsrc@seZdZdZdS)�CompileErrorz2Failure to compile one or more C/C++ source files.NrrrrrrUsrc@seZdZdZdS)�LibErrorzKFailure to create a static library from one or more C/C++ object
    files.NrrrrrrXsrc@seZdZdZdS)�	LinkErrorz]Failure to link one or more C/C++ object files into an executable
    or shared library file.Nrrrrrr\src@seZdZdZdS)�UnknownFileErrorz(Attempt to process an unknown file type.Nrrrrrr`srN)r�	Exceptionrr	r
rrr
rrrrrrrrrrrrrrrrr�<module>s&
	PK�"�\�*�quoprimime.cpython-38.opt-1.pycnu�[���U

e5d�&�
@sXdZddddddddd	d
g
ZddlZdd
lmZmZmZdZdZdZ	dd�e
d�D�Zedd�Zedd�Z
de�d�e�d�D]Zee�ee<q�deed�<dD]Zee�e
e<q�dd�Zdd�Zdd�Zdd�Zd,dd �Zd!d
�Zd"d	�Zd-d$d�Ze
dd�Zd%D]Zee�ee<�qd&efd'd�Zefd(d�ZeZeZd)d*�Zd+d�Z dS).aFQuoted-printable content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode US ASCII-like 8-bit data called `quoted-printable'.  It is used to
safely encode text that is in a character set similar to the 7-bit US ASCII
character set, but that includes some 8-bit characters that are normally not
allowed in email bodies or headers.

Quoted-printable is very space-inefficient for encoding binary files; use the
email.base64mime module for that instead.

This module provides an interface to encode and decode both headers and bodies
with quoted-printable encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:/From:/Cc: etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character
conversion necessary for proper internationalized headers; it only
does dumb encoding and decoding.  To deal with the various line
wrapping issues, use the email.header module.
�body_decode�body_encode�body_length�decode�decodestring�
header_decode�
header_encode�
header_length�quote�unquote�N)�
ascii_letters�digits�	hexdigits�
�
�cCsg|]}d|�qS)z=%02X�)�.0�crr�(/usr/lib64/python3.8/email/quoprimime.py�
<listcomp>7sr�s-!*+/�ascii�_� s_ !"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~	cCst|�t|kS)z>Return True if the octet should be escaped with header quopri.)�chr�_QUOPRI_HEADER_MAP��octetrrr�header_checkJsrcCst|�t|kS)z<Return True if the octet should be escaped with body quopri.)r�_QUOPRI_BODY_MAPrrrr�
body_checkOsr!cCstdd�|D��S)a:Return a header quoted-printable encoding length.

    Note that this does not include any RFC 2047 chrome added by
    `header_encode()`.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for headers.
    css|]}tt|�VqdS�N)�lenr�rrrrr�	<genexpr>^sz header_length.<locals>.<genexpr>��sum��	bytearrayrrrrTs
cCstdd�|D��S)z�Return a body quoted-printable encoding length.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for bodies.
    css|]}tt|�VqdSr")r#r r$rrrr%hszbody_length.<locals>.<genexpr>r&r(rrrrascCsft|t�st|�}|s&|�|���n<t|d�t|�|krT|d||7<n|�|���dS)N���)�
isinstance�strr�append�lstripr#)�L�s�maxlenZextrarrr�_max_appendks
r2cCstt|dd�d��S)zDTurn a string in the form =AB to the ASCII character with value 0xab���)r�int�r0rrrr
vscCstt|�Sr")�_QUOPRI_MAP�ord)rrrrr	{s�
iso-8859-1cCs$|sdS|�d��t�}d||fS)a�Encode a single header line with quoted-printable (like) encoding.

    Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but
    used specifically for email header fields to allow charsets with mostly 7
    bit characters (and some 8 bit) to remain more or less readable in non-RFC
    2045 aware mail clients.

    charset names the character set to use in the RFC 2046 header.  It
    defaults to iso-8859-1.
    r�latin1z=?%s?q?%s?=)r�	translater)Zheader_bytes�charset�encodedrrrrss
�Lc
Cs�|dkrtd��|s|S|�t�}d|}|d}g}|j}|��D�]}d}t|�d|}	||	kr�||}
||
ddkr�||||
d��|
d}q^||
ddkr�||||
��|
d}q^||||
�d�|
}q^|�rR|ddk�rR||	}|d	k�rt|d�}n(|dk�r,|d|}n|t|d�}|||d�|�qD|||d
��qD|dtk�rz|d�|�|�S)a�Encode with quoted-printable, wrapping at maxlinelen characters.

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.

    Each line will be wrapped at, at most, maxlinelen characters before the
    eol string (maxlinelen defaults to 76 characters, the maximum value
    permitted by RFC 2045).  Long lines will have the 'soft line break'
    quoted-printable character "=" appended to them, so the decoded text will
    be identical to the original text.

    The minimum maxlinelen is 4 to have room for a quoted character ("=XX")
    followed by a soft line break.  Smaller values will generate a
    ValueError.

    �zmaxlinelen must be at least 4�=r3r�r*z 	r4Nr)	�
ValueErrorr<�_QUOPRI_BODY_ENCODE_MAPr-�
splitlinesr#r	�CRLF�join)
ZbodyZ
maxlinelen�eolZ
soft_breakZmaxlinelen1Zencoded_bodyr-�line�startZ	laststart�stopZroom�qrrrr�sD




cCs|s|Sd}|��D]�}|��}|s.||7}qd}t|�}||kr||}|dkrd||7}|d7}nv|d|kr||d7}q:n^|d|kr�||dtkr�||dtkr�|t|||d��7}|d7}n||7}|d7}||kr:||7}q:q|ddk�r|�|��r|d	d�}|S)
z_Decode a quoted-printable string.

    Lines are separated with eol, which defaults to \n.
    rrrAr3rBr4r*rN)rE�rstripr#rr
�endswith)r>rHZdecodedrI�i�nrrrrr�s8
,
cCs|�d�}t|�S)zCTurn a match in the form =AB to the ASCII character with value 0xabr)�groupr
)�matchr0rrr�_unquote_matchs
rScCs |�dd�}tjdt|tjd�S)aDecode a string encoded with RFC 2045 MIME header `Q' encoding.

    This function does not parse a full MIME header value encoded with
    quoted-printable (like =?iso-8859-1?q?Hello_World?=) -- please use
    the high level email.header class for that functionality.
    rrz=[a-fA-F0-9]{2})�flags)�replace�re�subrS�ASCIIr7rrrr#s)r)r:)!�__doc__�__all__rV�stringrr
rrF�NLZEMPTYSTRING�ranger8rr �encoderrr9rr!rrr2r
r	rrDrrrrrSrrrrr�<module>sR�




O0PK�"�\�w��
�
errors.cpython-38.opt-2.pycnu�[���U

e5d�
�@s4Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�Z	Gdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�Zd&S)'c@seZdZdS)�DistutilsErrorN��__name__�
__module__�__qualname__�rr�(/usr/lib64/python3.8/distutils/errors.pyrsrc@seZdZdS)�DistutilsModuleErrorNrrrrrrsrc@seZdZdS)�DistutilsClassErrorNrrrrrr	sr	c@seZdZdS)�DistutilsGetoptErrorNrrrrrr
sr
c@seZdZdS)�DistutilsArgErrorNrrrrrrsrc@seZdZdS)�DistutilsFileErrorNrrrrrr$src@seZdZdS)�DistutilsOptionErrorNrrrrrr
*sr
c@seZdZdS)�DistutilsSetupErrorNrrrrrr3src@seZdZdS)�DistutilsPlatformErrorNrrrrrr8src@seZdZdS)�DistutilsExecErrorNrrrrrr>src@seZdZdS)�DistutilsInternalErrorNrrrrrrCsrc@seZdZdS)�DistutilsTemplateErrorNrrrrrrHsrc@seZdZdS)�DistutilsByteCompileErrorNrrrrrrKsrc@seZdZdS)�CCompilerErrorNrrrrrrOsrc@seZdZdS)�PreprocessErrorNrrrrrrRsrc@seZdZdS)�CompileErrorNrrrrrrUsrc@seZdZdS)�LibErrorNrrrrrrXsrc@seZdZdS)�	LinkErrorNrrrrrr\src@seZdZdS)�UnknownFileErrorNrrrrrr`srN)�	Exceptionrrr	r
rrr
rrrrrrrrrrrrrrrr�<module>s$	PK�"�\�.]��9�9_policybase.cpython-38.pycnu�[���U

e5d�:�@s�dZddlZddlmZddlmZddlmZdddgZGd	d
�d
�Z	dd�Z
d
d�ZGdd�de	ejd�Z
eGdd�de
��Ze�ZdS)zwPolicy framework for the email package.

Allows fine grained feature control of how the package parses and emits data.
�N)�header)�charset)�_has_surrogates�Policy�Compat32�compat32cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�_PolicyBasea�Policy Object basic framework.

    This class is useless unless subclassed.  A subclass should define
    class attributes with defaults for any values that are to be
    managed by the Policy object.  The constructor will then allow
    non-default values to be set for these attributes at instance
    creation time.  The instance will be callable, taking these same
    attributes keyword arguments, and returning a new instance
    identical to the called instance except for those values changed
    by the keyword arguments.  Instances may be added, yielding new
    instances with any non-default values from the right hand
    operand overriding those in the left hand operand.  That is,

        A + B == A(<non-default values of B>)

    The repr of an instance can be used to reconstruct the object
    if and only if the repr of the values can be used to reconstruct
    those values.

    csH|��D]:\}}t||�r.tt|��||�qtd�||jj���qdS)z�Create new Policy, possibly overriding some defaults.

        See class docstring for a list of overridable attributes.

        �*{!r} is an invalid keyword argument for {}N)	�items�hasattr�superr�__setattr__�	TypeError�format�	__class__�__name__)�self�kw�name�value�r��)/usr/lib64/python3.8/email/_policybase.py�__init__)s
��z_PolicyBase.__init__cCs*dd�|j��D�}d�|jjd�|��S)NcSsg|]\}}d�||��qS)z{}={!r})r)�.0rrrrr�
<listcomp>8s�z(_PolicyBase.__repr__.<locals>.<listcomp>z{}({})z, )�__dict__r
rrr�join)r�argsrrr�__repr__7s�z_PolicyBase.__repr__cKsr|j�|j�}|j��D]\}}t�|||�q|��D]4\}}t||�s^td�||jj	���t�|||�q8|S)z�Return a new instance with specified attributes changed.

        The new instance has the same attribute values as the current object,
        except for the changes passed in as keyword arguments.

        r	)
r�__new__rr
�objectr
rrrr)rrZ	newpolicy�attrrrrr�clone<s
��z_PolicyBase.clonecCs,t||�rd}nd}t|�|jj|���dS)Nz'{!r} object attribute {!r} is read-onlyz!{!r} object has no attribute {!r})r�AttributeErrorrrr)rrr�msgrrrr
Ns
z_PolicyBase.__setattr__cCs|jf|j�S)z�Non-default values from right operand override those from left.

        The object returned is a new instance of the subclass.

        )r#r)r�otherrrr�__add__Usz_PolicyBase.__add__)
r�
__module__�__qualname__�__doc__rrr#r
r'�
__classcell__rrrrrsrcCs,|�dd�d}|�dd�d}|d|S)N�
�r)�rsplit�split)�docZ	added_docrrr�_append_doc^sr1cCs�|jr(|j�d�r(t|jdj|j�|_|j��D]V\}}|jr2|j�d�r2dd�|jD�D]*}tt||�d�}|r\t||j�|_q2q\q2|S)N�+rcss |]}|��D]
}|VqqdS)N)�mro)r�base�crrr�	<genexpr>hs
z%_extend_docstrings.<locals>.<genexpr>r*)r*�
startswithr1�	__bases__rr
�getattr)�clsrr"r5r0rrr�_extend_docstringscsr;c@s�eZdZdZdZdZdZdZdZdZ	dd�Z
d	d
�Zdd�Ze
jd
d��Ze
jdd��Ze
jdd��Ze
jdd��Ze
jdd��ZdS)raI	Controls for how messages are interpreted and formatted.

    Most of the classes and many of the methods in the email package accept
    Policy objects as parameters.  A Policy object contains a set of values and
    functions that control how input is interpreted and how output is rendered.
    For example, the parameter 'raise_on_defect' controls whether or not an RFC
    violation results in an error being raised or not, while 'max_line_length'
    controls the maximum length of output lines when a Message is serialized.

    Any valid attribute may be overridden when a Policy is created by passing
    it as a keyword argument to the constructor.  Policy objects are immutable,
    but a new Policy object can be created with only certain values changed by
    calling the Policy instance with keyword arguments.  Policy objects can
    also be added, producing a new Policy object in which the non-default
    attributes set in the right hand operand overwrite those specified in the
    left operand.

    Settable attributes:

    raise_on_defect     -- If true, then defects should be raised as errors.
                           Default: False.

    linesep             -- string containing the value to use as separation
                           between output lines.  Default '\n'.

    cte_type            -- Type of allowed content transfer encodings

                           7bit  -- ASCII only
                           8bit  -- Content-Transfer-Encoding: 8bit is allowed

                           Default: 8bit.  Also controls the disposition of
                           (RFC invalid) binary data in headers; see the
                           documentation of the binary_fold method.

    max_line_length     -- maximum length of lines, excluding 'linesep',
                           during serialization.  None or 0 means no line
                           wrapping is done.  Default is 78.

    mangle_from_        -- a flag that, when True escapes From_ lines in the
                           body of the message by putting a `>' in front of
                           them. This is used when the message is being
                           serialized by a generator. Default: True.

    message_factory     -- the class to use to create new message objects.
                           If the value is None, the default is Message.

    Fr,Z8bit�NNcCs|jr
|�|�||�dS)aZBased on policy, either raise defect or call register_defect.

            handle_defect(obj, defect)

        defect should be a Defect subclass, but in any case must be an
        Exception subclass.  obj is the object on which the defect should be
        registered if it is not raised.  If the raise_on_defect is True, the
        defect is raised as an error, otherwise the object and the defect are
        passed to register_defect.

        This method is intended to be called by parsers that discover defects.
        The email package parsers always call it with Defect instances.

        N)�raise_on_defect�register_defect�r�objZdefectrrr�
handle_defect�szPolicy.handle_defectcCs|j�|�dS)a�Record 'defect' on 'obj'.

        Called by handle_defect if raise_on_defect is False.  This method is
        part of the Policy API so that Policy subclasses can implement custom
        defect handling.  The default implementation calls the append method of
        the defects attribute of obj.  The objects used by the email package by
        default that get passed to this method will always have a defects
        attribute with an append method.

        N)Zdefects�appendr?rrrr>�szPolicy.register_defectcCsdS)a[Return the maximum allowed number of headers named 'name'.

        Called when a header is added to a Message object.  If the returned
        value is not 0 or None, and there are already a number of headers with
        the name 'name' equal to the value returned, a ValueError is raised.

        Because the default behavior of Message's __setitem__ is to append the
        value to the list of headers, it is easy to create duplicate headers
        without realizing it.  This method allows certain headers to be limited
        in the number of instances of that header that may be added to a
        Message programmatically.  (The limit is not observed by the parser,
        which will faithfully produce as many headers as exist in the message
        being parsed.)

        The default implementation returns None for all header names.
        Nr)rrrrr�header_max_count�szPolicy.header_max_countcCst�dS)aZGiven a list of linesep terminated strings constituting the lines of
        a single header, return the (name, value) tuple that should be stored
        in the model.  The input lines should retain their terminating linesep
        characters.  The lines passed in by the email package may contain
        surrogateescaped binary data.
        N��NotImplementedError)r�sourcelinesrrr�header_source_parse�szPolicy.header_source_parsecCst�dS)z�Given the header name and the value provided by the application
        program, return the (name, value) that should be stored in the model.
        NrD�rrrrrr�header_store_parse�szPolicy.header_store_parsecCst�dS)awGiven the header name and the value from the model, return the value
        to be returned to the application program that is requesting that
        header.  The value passed in by the email package may contain
        surrogateescaped binary data if the lines were parsed by a BytesParser.
        The returned value should not contain any surrogateescaped data.

        NrDrHrrr�header_fetch_parse�s	zPolicy.header_fetch_parsecCst�dS)a�Given the header name and the value from the model, return a string
        containing linesep characters that implement the folding of the header
        according to the policy controls.  The value passed in by the email
        package may contain surrogateescaped binary data if the lines were
        parsed by a BytesParser.  The returned value should not contain any
        surrogateescaped data.

        NrDrHrrr�fold�s
zPolicy.foldcCst�dS)a%Given the header name and the value from the model, return binary
        data containing linesep characters that implement the folding of the
        header according to the policy controls.  The value passed in by the
        email package may contain surrogateescaped binary data.

        NrDrHrrr�fold_binaryszPolicy.fold_binary)rr(r)r*r=�linesep�cte_type�max_line_length�mangle_from_Zmessage_factoryrAr>rC�abc�abstractmethodrGrIrJrKrLrrrrrps(0

	



)�	metaclassc@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)rz�+
    This particular policy is the backward compatibility Policy.  It
    replicates the behavior of the email package version 5.1.
    TcCs0t|t�s|St|�r(tj|tj|d�S|SdS)N�r�header_name)�
isinstance�strrr�Header�_charset�UNKNOWN8BITrHrrr�_sanitize_headers

�zCompat32._sanitize_headercCs>|d�dd�\}}|�d�d�|dd��}||�d�fS)a:+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.

        r�:r-z 	�Nz
)r/�lstripr�rstrip)rrFrrrrrrG%szCompat32.header_source_parsecCs||fS)z>+
        The name and value are returned unmodified.
        rrHrrrrI1szCompat32.header_store_parsecCs|�||�S)z�+
        If the value contains binary data, it is converted into a Header object
        using the unknown-8bit charset.  Otherwise it is returned unmodified.
        )r[rHrrrrJ7szCompat32.header_fetch_parsecCs|j||dd�S)a+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  Non-ASCII binary data are CTE encoded using the
        unknown-8bit charset.

        T��sanitize)�_foldrHrrrrK>sz
Compat32.foldcCs"|j|||jdkd�}|�dd�S)a�+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  If cte_type is 7bit, non-ascii binary data is CTE
        encoded using the unknown-8bit charset.  Otherwise the original source
        header is used, with its existing line breaks and/or binary data.

        Z7bitr`�ascii�surrogateescape)rbrN�encode)rrrZfoldedrrrrLHs	zCompat32.fold_binarycCs�g}|�d|�t|t�r\t|�rL|r<tj|tj|d�}qZ|�|�d}q`tj||d�}n|}|dk	r�d}|jdk	r||j}|�|j	|j
|d��|�|j
�d�|�S)Nz%s: rT)rUr)rM�
maxlinelenr])rBrVrWrrrXrYrZrOrerMr)rrrra�parts�hrfrrrrbTs(
�


zCompat32._foldN)rr(r)r*rPr[rGrIrJrKrLrbrrrrrs
)r*rQZemailrrrYZemail.utilsr�__all__rr1r;�ABCMetarrrrrrr�<module>s �L
 fPK�&�\/?d�//fixer_util.cpython-36.opt-1.pycnu�[���3


 \g;�
@s�dZddlmZddlmZmZddlmZddl	m
Z
dd�Zdd	�Zd
d�Z
dd
�ZdWdd�Zdd�Zdd�Zdd�Ze�e
�fdd�ZdXdd�Zdd�Zdd�ZdYdd �Zd!d"�ZdZd#d$�Zd[d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2d3d4d5d6d7d8d9d:h
Z d;d<�Z!d=a"d>a#d?a$d@a%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)dIdJ�Z*dKdL�Z+dMdN�Z,dOdP�Z-ej.ej/hZ0d\dQdR�Z1ej/ej.ej2hZ3dSdT�Z4d]dUdV�Z5dS)^z1Utility functions, node construction macros, etc.�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�*/usr/lib64/python3.6/lib2to3/fixer_util.py�
KeywordArgsrcCsttjd�S)N�()rr�LPARrrrr
�LParensrcCsttjd�S)N�))rr�RPARrrrr
�RParensrcCsHt|t�s|g}t|t�s&d|_|g}ttj|ttjddd�g|�S)zBuild an assignment statement� r)�prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

rNcCsttj||d�S)zReturn a NAME leaf)r)rr�NAME)�namerrrr
�Name$srcCs|ttjt�|g�gS)zA node tuple for obj.attr)rr�trailer�Dot)�obj�attrrrr
�Attr(sr$cCsttjd�S)zA comma leaf�,)rr�COMMArrrr
�Comma,sr'cCsttjd�S)zA period (.) leaf�.)rr�DOTrrrr
r!0sr!cCs4ttj|j�|j�g�}|r0|jdttj|��|S)z-A parenthesised argument list, used by Call()r)rrr �clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr/cCs&ttj|t|�g�}|dk	r"||_|S)zA function callN)rr�powerr/r)Z	func_namer-rr.rrr
�Call;sr1cCsttjd�S)zA newline literal�
)rr�NEWLINErrrr
�NewlineBsr4cCsttjd�S)zA blank line�)rrr3rrrr
�	BlankLineFsr6cCsttj||d�S)N)r)rr�NUMBER)�nrrrr
�NumberJsr9cCs"ttjttjd�|ttjd�g�S)zA numeric or string subscript�[�])rrr rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMsr>cCsttj||d�S)z
A string leaf)r)rr�STRING)�stringrrrr
�StringSsrAc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|jttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)zuA list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
    r5r�for�in�ifr:r;)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr<r=)	Zxp�fp�itZtestZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs$
rIcCsZx|D]}|j�qWttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)zO Return an import statement in the form:
        from package import name_leafs�fromr)r�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos

rQc	Cs�|dj�}|jtjkr"|j�}nttj|j�g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|dj�||dj�g�g|�}|j	|_	|S)	zfReturns an import statement and calls a method
    of the module:

    import module
    module.name()r"�aftercSsg|]}|j��qSr)r*)�.0r8rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r*�typerr,rr0r$rr r)r.�results�namesr"Z
newarglistrR�newrrr
�
ImportAndCall�s
DrZcCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)z(Does the node represent a tuple literal?T�rUr�rr)rrrOrr�lenrr)r.rrr
�is_tuple�s
r^cCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)z'Does the node represent a list literal?rrUr:r;���r_)rrr]rOrr)r.rrr
�is_list�s
r`cCsttjt�|t�g�S)N)rrrrr)r.rrr
�parenthesize�sra�sortedr�set�any�all�tuple�sum�min�max�	enumerateccs(t||�}x|r"|Vt||�}qWdS)alFollow an attribute chain.

    If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
    use this to iterate over all objects in the chain. Iteration is
    terminated by getattr(x, attr) is None.

    Args:
        obj: the starting object
        attr: the name of the chaining attribute

    Yields:
        Each successive object in the chain.
    N)�getattr)r"r#�nextrrr
�
attr_chain�s
rmzefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     z�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
z`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
FcCsrts&tjt�atjt�atjt�adatttg}x<t|t|d��D](\}}i}|j||�rB|d|krBdSqBWdS)a Returns true if node is in an environment where all that is required
        of it is being iterable (ie, it doesn't matter if it returns a list
        or an iterator).
        See test_map_nochange in test_fixers.py for some examples and tests.
        T�parentr.F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprm�match)r.Zpatterns�patternrnrWrrr
�in_special_context�s



rvcCs�|j}|dk	r|jtjkrdS|j}|jtjtjfkr:dS|jtjkrX|j	d|krXdS|jtj
ks�|jtjkr�|dk	r�|jtjks�|j	d|kr�dSdS)zG
    Check that something isn't an attribute or function name etc.
    NFrUT)
Zprev_siblingrVrr)rnr�funcdef�classdef�	expr_stmtrOZ
parametersZ
typedargslistr&)r.�prevrnrrr
�is_probably_builtin�sr{cCsNxH|dk	rH|jtjkr@t|j�dkr@|jd}|jtjkr@|jS|j}qWdS)zFind the indentation of *node*.Nr\rr5)	rVr�suiter]rOr�INDENTrrn)r.�indentrrr
�find_indentations


rcCs>|jtjkr|S|j�}|jd}|_ttj|g�}||_|S)N)rVrr|r*rnr)r.rnr|rrr
�
make_suitesr�cCs(x"|jtjkr"|j}|std��qW|S)zFind the top level namespace.z,root found before file_input node was found.)rVrZ
file_inputrn�
ValueError)r.rrr
�	find_root&s
r�cCst|t|�|�}t|�S)z� Returns true if name is imported from package at the
        top level of the tree which node belongs to.
        To cover the case of an import like 'import foo', use
        None for the package and 'foo' for the name. )�find_bindingr��bool)�packagerr.Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfkS)z0Returns true if the node is an import statement.)rVr�import_namerN)r.rrr
�	is_import7sr�cCs4dd�}t|�}t|||�r dSd}}xTt|j�D]F\}}||�sFq4x(t|j|d��D]\}}||�sZPqZW||}Pq4W|dkr�xDt|j�D]6\}}|jtjkr�|jr�|jdjtjkr�|d}Pq�W|dkr�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|j|t	tj|
��dS)	z\ Works like `does_tree_import` but adds an import statement
        if it was not imported. cSs |jtjko|jot|jd�S)NrU)rVr�simple_stmtrOr�)r.rrr
�is_import_stmt>sz$touch_import.<locals>.is_import_stmtNrUrrKr)r)r�r�rjrOrVrr�rr?rr�rrrQr4r+)r�rr.r��rootZ
insert_pos�offset�idxZnode2�import_rOrrr
�touch_import;s4

r�cCs��x�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n4|jtjtjfkr�t|t|jd	�|�}|r�|}�n|jtj	k�rt|t|jd�|�}|r�|}nXx�t
|jdd��D]@\}}|jtjko�|j
dkr�t|t|j|d�|�}|r�|}q�Wnx|jtk�r6|jdj
|k�r6|}nTt|||��rJ|}n@|jtjk�rft|||�}n$|jtjk�r�t||jd��r�|}|r
|�s�|St|�r
|Sq
WdS)
z� Returns the node which binds variable name, otherwise None.
        If optional argument package is supplied, only imports will
        be returned.
        See test cases for examples.Nrr\r[�:�rUr_r_)rOrVrZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrjr�COLONr�	_def_syms�_is_import_bindingr�ryr�)rr.r��childZretr8�iZkidrrr
r�isH
r�cCsX|g}xL|rR|j�}|jdkr6|jtkr6|j|j�q|jtjkr|j|kr|SqWdS)N�)�poprV�_block_syms�extendrOrrr)rr.Znodesrrr
r��sr�cCs�|jtjkr�|r�|jd}|jtjkrvx�|jD]@}|jtjkrV|jdj|krp|Sq0|jtjkr0|j|kr0|Sq0WnL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd�j�|kr�dS|jd}|�rtd|��rdS|jtj
k�r.t||��r.|S|jtjk�rf|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)z� Will reuturn node if node will import name, or node
        will import * from package.  None is returned otherwise.
        See test cases for examples. rr\Nr[�asr_)rVrr�rOZdotted_as_namesZdotted_as_namerrrrN�str�stripr�rMZimport_as_name�STAR)r.rr�rPr�Zlastr8rrr
r��s@




r�)N)NN)N)N)N)N)N)6�__doc__Zpgen2rZpytreerrZpygramrrr5rrrrrrr$r'r!r/r1r4r6r9r>rArIrQrZr^r`raZconsuming_callsrmrprqrrrorvr{rr�r�r�r�r�rxrwr�r�r r�r�r�rrrr
�<module>sZ





		-
*
PK�&�\��2!2!main.cpython-36.opt-1.pycnu�[���3


 \�-�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZdd�ZGdd	�d	ej
�Zd
d�Zddd
�ZdS)z
Main program for 2to3.
�)�with_statement�print_functionN�)�refactorc	Cs(|j�}|j�}tj||||dddd�S)z%Return a unified diff of two strings.z
(original)z(refactored)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filename�r�$/usr/lib64/python3.6/lib2to3/main.py�
diff_textss
rcs>eZdZdZd�fdd�	Zdd�Z�fdd�Zd	d
�Z�ZS)�StdoutRefactoringToola2
    A refactoring tool that can avoid overwriting its input files.
    Prints output to stdout.

    Output files can optionally be written to a different directory and or
    have an extra file suffix appended to their name for use in situations
    where you do not want to replace the input files.
    rc		sR||_||_|r(|jtj�r(|tj7}||_||_||_tt	|�j
|||�dS)aF
        Args:
            fixers: A list of fixers to import.
            options: A dict with RefactoringTool configuration.
            explicit: A list of fixers to run even if they are explicit.
            nobackups: If true no backup '.bak' files will be created for those
                files that are being refactored.
            show_diffs: Should diffs of the refactoring be printed to stdout?
            input_base_dir: The base directory for all input files.  This class
                will strip this path prefix off of filenames before substituting
                it with output_dir.  Only meaningful if output_dir is supplied.
                All files processed by refactor() must start with this path.
            output_dir: If supplied, all converted files will be written into
                this directory tree instead of input_base_dir.
            append_suffix: If supplied, all files output by this tool will have
                this appended to their filename.  Useful for changing .py to
                .py3 for example by passing append_suffix='3'.
        N)�	nobackups�
show_diffs�endswith�os�sep�_input_base_dir�_output_dir�_append_suffix�superr�__init__)	�selfZfixers�options�explicitrr�input_base_dir�
output_dir�
append_suffix)�	__class__rr
r$s
zStdoutRefactoringTool.__init__cOs*|jj|||f�|jj|f|�|�dS)N)�errors�append�logger�error)r�msg�args�kwargsrrr
�	log_errorAszStdoutRefactoringTool.log_errorc
!s||}|jrH|j|j�r6tjj|j|t|j�d��}ntd||jf��|jrX||j7}||kr�tjj	|�}tjj
|�r�|r�tj|�|jd||�|j
�s4|d}tjj|�r�ytj|�Wn.tk
r�}z|jd|�WYdd}~XnXytj||�Wn2tk
�r2}z|jd||�WYdd}~XnXtt|�j}	|	||||�|j
�sbtj||�||k�rxtj||�dS)Nz5filename %s does not start with the input_base_dir %szWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)r�
startswithrr�path�join�len�
ValueErrorr�dirname�isdir�makedirs�log_messager�lexists�remove�OSError�renamerr�
write_file�shutilZcopymode)
rZnew_textrZold_text�encodingZ
orig_filenamerZbackup�err�write)r rr
r6Es@


 
z StdoutRefactoringTool.write_filecCs�|r|jd|�n�|jd|�|jr�t|||�}yX|jdk	rp|j�&x|D]}t|�qJWtjj�WdQRXnx|D]}t|�qvWWn"tk
r�t	d|f�dSXdS)NzNo changes to %sz
Refactored %sz+couldn't encode %s's diff for your terminal)
r1rrZoutput_lock�print�sys�stdout�flush�UnicodeEncodeError�warn)r�old�newrZequalZ
diff_lines�linerrr
�print_outputls"



z"StdoutRefactoringTool.print_output)rrr)	�__name__�
__module__�__qualname__�__doc__rr(r6rD�
__classcell__rr)r r
rs
'rcCstd|ftjd�dS)NzWARNING: %s)�file)r;r<�stderr)r%rrr
r@�sr@cstjdd�}|jddddd�|jdd	d
gdd�|jd
dddddd�|jddd
gdd�|jddddd�|jddddd�|jddddd�|jd dd!d�|jd"d#dd$d�|jd%d&dd'd(d�|jd)d*dd+d,d-d.�|jd/d0dd1d�|jd2dd+d,d3d.�d'}i}|j|�\}}|j�r@d4|d5<|j�s:td6�d4|_|j�r\|j�r\|j	d7�|j
�rx|j�rx|j	d8�|j�r�|j�r�td9�|j�r�|j�r�|j	d:�|j�r�t
d;�xtj��D]}t
|��q�W|�s�d<S|�st
d=tjd>�t
d?tjd>�d@SdA|k�r4d4}|j�r4t
dBtjd>�d@S|j�rDd4|dC<|j�rRtjntj}tjdD|dE�tjdF�}ttj���}	t�fdGdH�|jD��}
t�}|j�r�d'}x2|jD](}
|
dIk�r�d4}n|j�dJ|
��q�W|�r�|	j|�n|}n
|	j|�}|j|
�}t j!j"|�}|�rD|j#t j$��rDt j!j%|��rDt j!j&|�}|j�rh|j't j$�}|j(dK|j|�t)t*|�|t*|�|j|j||j|j
dL�}|j+�s�|�r�|j,�nBy|j||j|j-|j.�Wn&tj/k
�r�t
dMtjd>�dSX|j0�t1t2|j+��S)Nz�Main program.

    Args:
        fixer_pkg: the name of a package where the fixers are located.
        args: optional; a list of command line arguments. If omitted,
              sys.argv[1:] is used.

    Returns a suggested exit status (0, 1, 2).
    z2to3 [options] file|dir ...)Zusagez-dz--doctests_only�
store_truezFix up doctests only)�action�helpz-fz--fixr"z1Each FIX specifies a transformation; default: all)rM�defaultrNz-jz--processesZstorer�intzRun 2to3 concurrently)rMrO�typerNz-xz--nofixz'Prevent a transformation from being runz-lz--list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-vz	--verbosezMore verbose loggingz
--no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz--nobackupsFz&Don't write backups for modified filesz-oz--output-dir�strrzXPut output files in this directory instead of overwriting the input files.  Requires -n.)rMrQrOrNz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z--add-suffixzuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.T�write_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.)rJzUse --help to show usage.��-zCan't write to stdin.rz%(name)s: %(message)s)�format�levelzlib2to3.mainc3s|]}�d|VqdS)z.fix_Nr)�.0�fix)�	fixer_pkgrr
�	<genexpr>�szmain.<locals>.<genexpr>�allz.fix_z7Output in %r will mirror the input directory %r layout.)rrrz+Sorry, -j isn't supported on this platform.)3�optparseZOptionParserZ
add_option�
parse_argsrSr:r@rrr$Z
add_suffixZno_diffsZ
list_fixesr;rZget_all_fix_namesr<rKr�verbose�logging�DEBUG�INFOZbasicConfigZ	getLogger�setZget_fixers_from_packageZnofixrY�add�union�
differencerr*�commonprefixrrr/r.�rstrip�infor�sortedr!�refactor_stdinZ
doctests_onlyZ	processesZMultiprocessingUnsupportedZ	summarizerP�bool)rZr&�parserrk�flagsrZfixnamerWr#Zavail_fixesZunwanted_fixesrZall_presentrYZ	requestedZfixer_namesrZrtr)rZr
�main�s�




















ro)N)rHZ
__future__rrr<rrr`r7r]rrrZMultiprocessRefactoringToolrr@rorrrr
�<module>s	gPK�&�\�K,#
#
 btm_matcher.cpython-36.opt-2.pycnu�[���3


 \��@shdZddlZddlZddlmZddlmZddlmZGdd�de	�Z
Gd	d
�d
e	�Ziadd�Z
dS)
z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@seZdZej�Zdd�ZdS)�BMNodecCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content)�self�r�+/usr/lib64/python3.6/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__�	itertoolsrrrrrrrsrc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
BottomMatchercCs0t�|_t�|_|jg|_g|_tjd�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�loggingZ	getLoggerZlogger)rrrrrs

zBottomMatcher.__init__cCsL|jj|�t|j�}|j�}|j||jd�}x|D]}|jj|�q4WdS)N)�start)r	�appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr�	add_fixer%s

zBottomMatcher.add_fixercCs�|s
|gSt|dt�rhg}xF|dD]:}|j||d�}x&|D]}|j|j|dd�|��q>Wq&W|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)Nr)rr)�
isinstance�tupler�extendrr)r�patternrr�alternativeZ	end_nodes�endZ	next_noderrrr1s"
"zBottomMatcher.addc	Cs0|j}tt�}�x|D�]}|}�x|�r&d|_x,|jD]"}t|tj�r8|jdkr8d|_Pq8W|j	dkrp|j}n|j	}||j
kr�|j
|}x�|jD]"}||kr�g||<||j|�q�Wnd|j}|j
dk	r�|j
jr�P||j
k�r|j
|}x2|jD](}||j�k�rg||<||j|�q�W|j
}q$WqW|S)NT�;Fr)rr�listZwas_checkedZchildrenr!rZLeaf�value�typerr	r�parent�keys)	rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenrrrr�runSs>





zBottomMatcher.runcs*td��fdd���|j�td�dS)Nz
digraph g{cs^xX|jj�D]J}|j|}td|j|jt|�t|j�f�|dkrNt|j��|�qWdS)Nz%d -> %d [label=%s] //%sr)rr,�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode)�
print_noderrr1�s

z*BottomMatcher.print_ac.<locals>.print_node�})r.r)rr)r1r�print_ac�s
zBottomMatcher.print_acN)rrrrr rr-r3rrrrrs
"=rcCsHts<ddlm}x*|jj�D]\}}t|�tkr|t|<qWtj||�S)Nr)�python_symbols)�_type_reprsZpygramr4�__dict__�itemsr*�int�
setdefault)Ztype_numr4�name�valrrrr/�sr/)�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr5r/rrrr�<module>s	PK�&�\/?d�//fixer_util.cpython-36.pycnu�[���3


 \g;�
@s�dZddlmZddlmZmZddlmZddl	m
Z
dd�Zdd	�Zd
d�Z
dd
�ZdWdd�Zdd�Zdd�Zdd�Ze�e
�fdd�ZdXdd�Zdd�Zdd�ZdYdd �Zd!d"�ZdZd#d$�Zd[d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2d3d4d5d6d7d8d9d:h
Z d;d<�Z!d=a"d>a#d?a$d@a%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)dIdJ�Z*dKdL�Z+dMdN�Z,dOdP�Z-ej.ej/hZ0d\dQdR�Z1ej/ej.ej2hZ3dSdT�Z4d]dUdV�Z5dS)^z1Utility functions, node construction macros, etc.�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�*/usr/lib64/python3.6/lib2to3/fixer_util.py�
KeywordArgsrcCsttjd�S)N�()rr�LPARrrrr
�LParensrcCsttjd�S)N�))rr�RPARrrrr
�RParensrcCsHt|t�s|g}t|t�s&d|_|g}ttj|ttjddd�g|�S)zBuild an assignment statement� r)�prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

rNcCsttj||d�S)zReturn a NAME leaf)r)rr�NAME)�namerrrr
�Name$srcCs|ttjt�|g�gS)zA node tuple for obj.attr)rr�trailer�Dot)�obj�attrrrr
�Attr(sr$cCsttjd�S)zA comma leaf�,)rr�COMMArrrr
�Comma,sr'cCsttjd�S)zA period (.) leaf�.)rr�DOTrrrr
r!0sr!cCs4ttj|j�|j�g�}|r0|jdttj|��|S)z-A parenthesised argument list, used by Call()r)rrr �clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr/cCs&ttj|t|�g�}|dk	r"||_|S)zA function callN)rr�powerr/r)Z	func_namer-rr.rrr
�Call;sr1cCsttjd�S)zA newline literal�
)rr�NEWLINErrrr
�NewlineBsr4cCsttjd�S)zA blank line�)rrr3rrrr
�	BlankLineFsr6cCsttj||d�S)N)r)rr�NUMBER)�nrrrr
�NumberJsr9cCs"ttjttjd�|ttjd�g�S)zA numeric or string subscript�[�])rrr rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMsr>cCsttj||d�S)z
A string leaf)r)rr�STRING)�stringrrrr
�StringSsrAc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|jttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)zuA list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
    r5r�for�in�ifr:r;)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr<r=)	Zxp�fp�itZtestZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs$
rIcCsZx|D]}|j�qWttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)zO Return an import statement in the form:
        from package import name_leafs�fromr)r�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos

rQc	Cs�|dj�}|jtjkr"|j�}nttj|j�g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|dj�||dj�g�g|�}|j	|_	|S)	zfReturns an import statement and calls a method
    of the module:

    import module
    module.name()r"�aftercSsg|]}|j��qSr)r*)�.0r8rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r*�typerr,rr0r$rr r)r.�results�namesr"Z
newarglistrR�newrrr
�
ImportAndCall�s
DrZcCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)z(Does the node represent a tuple literal?T�rUr�rr)rrrOrr�lenrr)r.rrr
�is_tuple�s
r^cCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)z'Does the node represent a list literal?rrUr:r;���r_)rrr]rOrr)r.rrr
�is_list�s
r`cCsttjt�|t�g�S)N)rrrrr)r.rrr
�parenthesize�sra�sortedr�set�any�all�tuple�sum�min�max�	enumerateccs(t||�}x|r"|Vt||�}qWdS)alFollow an attribute chain.

    If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
    use this to iterate over all objects in the chain. Iteration is
    terminated by getattr(x, attr) is None.

    Args:
        obj: the starting object
        attr: the name of the chaining attribute

    Yields:
        Each successive object in the chain.
    N)�getattr)r"r#�nextrrr
�
attr_chain�s
rmzefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     z�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
z`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
FcCsrts&tjt�atjt�atjt�adatttg}x<t|t|d��D](\}}i}|j||�rB|d|krBdSqBWdS)a Returns true if node is in an environment where all that is required
        of it is being iterable (ie, it doesn't matter if it returns a list
        or an iterator).
        See test_map_nochange in test_fixers.py for some examples and tests.
        T�parentr.F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprm�match)r.Zpatterns�patternrnrWrrr
�in_special_context�s



rvcCs�|j}|dk	r|jtjkrdS|j}|jtjtjfkr:dS|jtjkrX|j	d|krXdS|jtj
ks�|jtjkr�|dk	r�|jtjks�|j	d|kr�dSdS)zG
    Check that something isn't an attribute or function name etc.
    NFrUT)
Zprev_siblingrVrr)rnr�funcdef�classdef�	expr_stmtrOZ
parametersZ
typedargslistr&)r.�prevrnrrr
�is_probably_builtin�sr{cCsNxH|dk	rH|jtjkr@t|j�dkr@|jd}|jtjkr@|jS|j}qWdS)zFind the indentation of *node*.Nr\rr5)	rVr�suiter]rOr�INDENTrrn)r.�indentrrr
�find_indentations


rcCs>|jtjkr|S|j�}|jd}|_ttj|g�}||_|S)N)rVrr|r*rnr)r.rnr|rrr
�
make_suitesr�cCs(x"|jtjkr"|j}|std��qW|S)zFind the top level namespace.z,root found before file_input node was found.)rVrZ
file_inputrn�
ValueError)r.rrr
�	find_root&s
r�cCst|t|�|�}t|�S)z� Returns true if name is imported from package at the
        top level of the tree which node belongs to.
        To cover the case of an import like 'import foo', use
        None for the package and 'foo' for the name. )�find_bindingr��bool)�packagerr.Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfkS)z0Returns true if the node is an import statement.)rVr�import_namerN)r.rrr
�	is_import7sr�cCs4dd�}t|�}t|||�r dSd}}xTt|j�D]F\}}||�sFq4x(t|j|d��D]\}}||�sZPqZW||}Pq4W|dkr�xDt|j�D]6\}}|jtjkr�|jr�|jdjtjkr�|d}Pq�W|dkr�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|j|t	tj|
��dS)	z\ Works like `does_tree_import` but adds an import statement
        if it was not imported. cSs |jtjko|jot|jd�S)NrU)rVr�simple_stmtrOr�)r.rrr
�is_import_stmt>sz$touch_import.<locals>.is_import_stmtNrUrrKr)r)r�r�rjrOrVrr�rr?rr�rrrQr4r+)r�rr.r��rootZ
insert_pos�offset�idxZnode2�import_rOrrr
�touch_import;s4

r�cCs��x�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n4|jtjtjfkr�t|t|jd	�|�}|r�|}�n|jtj	k�rt|t|jd�|�}|r�|}nXx�t
|jdd��D]@\}}|jtjko�|j
dkr�t|t|j|d�|�}|r�|}q�Wnx|jtk�r6|jdj
|k�r6|}nTt|||��rJ|}n@|jtjk�rft|||�}n$|jtjk�r�t||jd��r�|}|r
|�s�|St|�r
|Sq
WdS)
z� Returns the node which binds variable name, otherwise None.
        If optional argument package is supplied, only imports will
        be returned.
        See test cases for examples.Nrr\r[�:�rUr_r_)rOrVrZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrjr�COLONr�	_def_syms�_is_import_bindingr�ryr�)rr.r��childZretr8�iZkidrrr
r�isH
r�cCsX|g}xL|rR|j�}|jdkr6|jtkr6|j|j�q|jtjkr|j|kr|SqWdS)N�)�poprV�_block_syms�extendrOrrr)rr.Znodesrrr
r��sr�cCs�|jtjkr�|r�|jd}|jtjkrvx�|jD]@}|jtjkrV|jdj|krp|Sq0|jtjkr0|j|kr0|Sq0WnL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd�j�|kr�dS|jd}|�rtd|��rdS|jtj
k�r.t||��r.|S|jtjk�rf|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)z� Will reuturn node if node will import name, or node
        will import * from package.  None is returned otherwise.
        See test cases for examples. rr\Nr[�asr_)rVrr�rOZdotted_as_namesZdotted_as_namerrrrN�str�stripr�rMZimport_as_name�STAR)r.rr�rPr�Zlastr8rrr
r��s@




r�)N)NN)N)N)N)N)N)6�__doc__Zpgen2rZpytreerrZpygramrrr5rrrrrrr$r'r!r/r1r4r6r9r>rArIrQrZr^r`raZconsuming_callsrmrprqrrrorvr{rr�r�r�r�r�rxrwr�r�r r�r�r�rrrr
�<module>sZ





		-
*
PK�&�\�Zr~��__main__.cpython-36.opt-2.pycnu�[���3


 \C�@s&ddlZddlmZejed��dS)�N�)�mainz
lib2to3.fixes)�sysr�exit�rr�(/usr/lib64/python3.6/lib2to3/__main__.py�<module>sPK�&�\0'?QQrefactor.cpython-36.opt-1.pycnu�[���3


 \=m�@s<dZdZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZdd	lmZd&dd�ZGd
d�de�Zdd�Zdd�Zdd�Zdd�Zejd'kr�ddlZejZdd�Z dd�Z!neZeZ eZ!dd�Z"Gdd�de�Z#Gd d!�d!e$�Z%Gd"d#�d#e�Z&Gd$d%�d%e%�Z'dS)(z�Refactoring framework.

Used as a main program, this can refactor any number of files and/or
recursively descend down directories.  Imported as a module, this
provides infrastructure to write your own refactoring tool.
z#Guido van Rossum <guido@python.org>�N)�chain�)�driver�tokenize�token)�	find_root)�pytree�pygram)�btm_matcherTcCstt|ggdg�}tjj|j�}g}xLttj|��D]:}|jd�r2|jd�r2|rZ|dd�}|j	|dd��q2W|S)zEReturn a sorted list of all available fix names in the given package.�*�fix_z.py�N����)
�
__import__�os�path�dirname�__file__�sorted�listdir�
startswith�endswith�append)Z	fixer_pkgZ
remove_prefixZpkgZ	fixer_dirZ	fix_names�name�r�(/usr/lib64/python3.6/lib2to3/refactor.py�get_all_fix_namessrc@seZdZdS)�
_EveryNodeN)�__name__�
__module__�__qualname__rrrrr+srcCs�t|tjtjf�r(|jdkr t�|jhSt|tj�rH|jrDt|j�St�t|tj	�r�t
�}x*|jD] }x|D]}|jt|��qlWqbW|Std|��dS)zf Accepts a pytree Pattern Node and returns a set
        of the pattern types which will match first. Nz$Oh no! I don't understand pattern %s)
�
isinstancerZNodePatternZLeafPattern�typerZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update�	Exception)Zpat�r�p�xrrrr$/s


r$cCs�tjt�}g}x�|D]|}|jrjyt|j�}Wntk
rJ|j|�Yq�XxB|D]}||j|�qRWq|jdk	r�||jj|�q|j|�qWx,tt	j
jj�t	j
j
�D]}||j|�q�Wt|�S)z^ Accepts a list of fixers and returns a dictionary
        of head node type --> fixer list.  N)�collections�defaultdict�list�patternr$rrZ_accept_typerr	�python_grammarZ
symbol2number�values�tokens�extend�dict)Z
fixer_listZ
head_nodesZevery�fixerZheadsZ	node_typerrr�_get_headnode_dictKs"



r5cs�fdd�t�d�D�S)zN
    Return the fully qualified names for fixers in the package pkg_name.
    csg|]}�d|�qS)�.r)�.0�fix_name)�pkg_namerr�
<listcomp>hsz+get_fixers_from_package.<locals>.<listcomp>F)r)r9r)r9r�get_fixers_from_packageds
r;cCs|S)Nr)�objrrr�	_identityksr=rcCs|jdd�S)Nz
�
)�replace)�inputrrr�_from_system_newlinesrsrAcCs tjdkr|jdtj�S|SdS)Nr>)r�linesepr?)r@rrr�_to_system_newlinests
rCcsTd}tjtj|�j���fdd�}ttjtjtj	h�}t
�}y�x�|�\}}||krVq@q@|tjkrl|rfPd}q@|tjko||dk�r,|�\}}|tjks�|dkr�P|�\}}|tjks�|dkr�P|�\}}|tj
kr�|dkr�|�\}}xJ|tjk�r(|j|�|�\}}|tj
k�s|d	k�rP|�\}}q�Wq@Pq@WWntk
�rJYnXt|�S)
NFcst��}|d|dfS)Nrr)�next)�tok)�genrr�advance�sz(_detect_future_features.<locals>.advanceT�fromZ
__future__�import�(�,)r�generate_tokens�io�StringIO�readline�	frozensetr�NEWLINE�NL�COMMENTr%�STRING�NAME�OP�add�
StopIteration)�sourceZhave_docstringrG�ignore�features�tp�valuer)rFr�_detect_future_featuressD








r^c@seZdZdZdS)�
FixerErrorzA fixer could not be loaded.N)rr r!�__doc__rrrrr_�sr_c@s�eZdZddd�ZdZdZd4dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zd7dd�Zdd�Zd8dd�Zdd�Zd d!�Zd9d"d#�Zd:d$d%�Zd&Zd'Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS);�RefactoringToolF)�print_function�write_unchanged_filesZFixrNcCs2||_|pg|_|jj�|_|dk	r0|jj|�|jdrDtj|_ntj	|_|jj
d�|_g|_t
jd�|_g|_d|_tj|jtj|jd�|_|j�\|_|_g|_tj�|_g|_g|_xXt|j|j�D]F}|j r�|jj!|�q�||jkr�|jj"|�q�||jkr�|jj"|�q�Wt#|j�|_$t#|j�|_%dS)z�Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: a dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
        NrbrcraF)�convert�logger)&�fixers�explicit�_default_options�copy�optionsr&r	�!python_grammar_no_print_statement�grammarr/�getrc�errors�loggingZ	getLoggerre�	fixer_log�wroterZDriverrrd�
get_fixers�	pre_order�
post_order�files�bmZ
BottomMatcher�BMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr5�bmi_pre_order_heads�bmi_post_order_heads)�selfZfixer_namesrjrgr4rrr�__init__�s<





zRefactoringTool.__init__cCs\g}g}�x&|jD�]}t|iidg�}|jdd�d}|j|j�rV|t|j�d�}|jd�}|jdjdd�|D��}yt	||�}Wn$t
k
r�td	||f��YnX||j|j
�}	|	jr�|jd
k	r�||jkr�|jd|�q|jd|�|	jd
k�r|j|	�q|	jdk�r |j|	�qtd|	j��qWtjd�}
|j|
d�|j|
d�||fS)aInspects the options to load the requested patterns and handlers.

        Returns:
          (pre_order, post_order), where pre_order is the list of fixers that
          want a pre-order AST traversal, and post_order is the list that want
          post-order traversal.
        rr6rN�_�cSsg|]}|j��qSr)�title)r7r)rrrr:�sz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order)�key���)rfr�rsplitr�FILE_PREFIX�len�split�CLASS_PREFIX�join�getattr�AttributeErrorr_rjrprg�log_message�	log_debug�orderr�operator�
attrgetter�sort)rzZpre_order_fixersZpost_order_fixersZfix_mod_path�modr8�parts�
class_nameZ	fix_classr4Zkey_funcrrrrr�s8


zRefactoringTool.get_fixerscOs�dS)zCalled when an error occurs.Nr)rz�msg�args�kwdsrrr�	log_errorszRefactoringTool.log_errorcGs|r||}|jj|�dS)zHook to log a message.N)re�info)rzr�r�rrrr�szRefactoringTool.log_messagecGs|r||}|jj|�dS)N)re�debug)rzr�r�rrrr�szRefactoringTool.log_debugcCsdS)zTCalled with the old version, new version, and filename of a
        refactored file.Nr)rz�old_text�new_text�filename�equalrrr�print_outputszRefactoringTool.print_outputcCs<x6|D].}tjj|�r&|j|||�q|j|||�qWdS)z)Refactor a list of files and directories.N)rr�isdir�refactor_dir�
refactor_file)rz�items�write�
doctests_onlyZdir_or_filerrr�refactor#s
zRefactoringTool.refactorc
Cs�tjd}x�tj|�D]�\}}}|jd|�|j�|j�xH|D]@}|jd�rBtjj|�d|krBtjj||�}	|j	|	||�qBWdd�|D�|dd�<qWdS)z�Descends down a directory and refactor every Python file found.

        Python files are assumed to have a .py extension.

        Files and subdirectories starting with '.' are skipped.
        �pyzDescending into %sr6rcSsg|]}|jd�s|�qS)r6)r)r7Zdnrrrr:>sz0RefactoringTool.refactor_dir.<locals>.<listcomp>N)
r�extsep�walkr�r�rr�splitextr�r�)
rzZdir_namer�r�Zpy_ext�dirpathZdirnames�	filenamesr�fullnamerrrr�,s

zRefactoringTool.refactor_dircCs�yt|d�}Wn.tk
r<}z|jd||�dSd}~XnXztj|j�d}Wd|j�Xt|d|d��}t|j	��|fSQRXdS)zG
        Do our best to decode a Python source file correctly.
        �rbzCan't open %s: %sNrr()�encoding)NN)
�open�OSErrorr�r�detect_encodingrO�close�_open_with_encodingrA�read)rzr��f�errr�rrr�_read_python_source@s
z#RefactoringTool._read_python_sourcecCs�|j|�\}}|dkrdS|d7}|rn|jd|�|j||�}|jsL||kr`|j|||||�q�|jd|�nH|j||�}|js�|r�|jr�|jt|�dd�|||d�n|jd|�dS)	zRefactors a file.Nr>zRefactoring doctests in %szNo doctest changes in %sr)r�r�zNo changes in %sr�)r�r��refactor_docstringrc�processed_file�refactor_string�was_changed�str)rzr�r�r�r@r��output�treerrrr�PszRefactoringTool.refactor_filecCs�t|�}d|krtj|j_zJy|jj|�}Wn4tk
r`}z|jd||jj	|�dSd}~XnXWd|j|j_X||_
|jd|�|j||�|S)aFRefactor a given input string.

        Args:
            data: a string holding the code to be refactored.
            name: a human-readable name for use in error/log messages.

        Returns:
            An AST corresponding to the refactored input stream; None if
            there were errors during the parse.
        rbzCan't parse %s: %s: %sNzRefactoring %s)
r^r	rkrrlZparse_stringr'r��	__class__r�future_featuresr��
refactor_tree)rz�datarr[r�r�rrrr�gs
zRefactoringTool.refactor_stringcCs�tjj�}|rN|jd�|j|d�}|js2||krB|j|d|�q�|jd�n:|j|d�}|jsj|r~|jr~|jt	|�d|�n
|jd�dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
�sys�stdinr�r�r�rcr�r�r�r�)rzr�r@r�r�rrr�refactor_stdin�s

zRefactoringTool.refactor_stdinc
Cs�x"t|j|j�D]}|j||�qW|j|j|j��|j|j|j��|jj|j	��}�xvt
|j���rАx`|jjD�]R}||ko�||rv||j
tjjdd�|jr�||j
tjjd��x
t||�D�]�}|||kr�||j|�yt|�Wntk
�rw�YnX|j�r(||jk�r(q�|j|�}|r�|j||�}|dk	r�|j|�x,|j�D] }|j�spg|_|jj|��q^W|jj|j	��}x2|D]*}	|	|k�r�g||	<||	j||	��q�Wq�WqvWq\Wx$t|j|j�D]}|j||��q�W|jS)a�Refactors a parse tree (modifying the tree in place).

        For compatible patterns the bottom matcher module is
        used. Otherwise the tree is traversed node-to-node for
        matches.

        Args:
            tree: a pytree.Node instance representing the root of the tree
                  to be refactored.
            name: a human-readable name for this tree.

        Returns:
            True if the tree was modified, False otherwise.
        T)r�reverse)rN)rrsrtZ
start_tree�traverse_byrxryrwZrunZleaves�anyr0rfr�rZBaseZdepthZkeep_line_orderZ
get_linenor-�remover�
ValueErrorZfixers_applied�match�	transformr?rr2Zfinish_treer�)
rzr�rr4Z	match_set�node�results�newZnew_matchesZfxrrrrr��sJ



$zRefactoringTool.refactor_treecCs^|sdSxP|D]H}xB||jD]4}|j|�}|r|j||�}|dk	r|j|�|}qWqWdS)aTraverse an AST, applying a set of fixers to each node.

        This is a helper method for refactor_tree().

        Args:
            fixers: a list of fixer instances.
            traversal: a generator that yields AST nodes.

        Returns:
            None
        N)r#r�r�r?)rzrfZ	traversalr�r4r�r�rrrr��s


zRefactoringTool.traverse_bycCs�|jj|�|dkr.|j|�d}|dkr.dS||k}|j||||�|r`|jd|�|js`dS|rv|j||||�n|jd|�dS)zR
        Called when a file has been refactored and there may be changes.
        NrzNo changes to %szNot writing changes to %s)rurr�r�r�rc�
write_file)rzr�r�r�r�r�r�rrrr��szRefactoringTool.processed_filec%Cs�yt|d|d�}Wn.tk
r@}z|jd||�dSd}~XnXzHy|jt|��Wn0tk
r�}z|jd||�WYdd}~XnXWd|j�X|jd|�d|_dS)z�Writes a string to a file.

        It first shows a unified diff between the old text and the new text, and
        then rewrites the file; the latter is only done if the write option is
        set.
        �w)r�zCan't create %s: %sNzCan't write %s: %szWrote changes to %sT)r�r�r�r�rCr�r�rq)rzr�r�r�r�r�r�rrrr�
s$
zRefactoringTool.write_filez>>> z... c
Csg}d}d}d}d}x�|jdd�D]�}|d7}|j�j|j�r�|dk	r\|j|j||||��|}|g}|j|j�}	|d|	�}q"|dk	r�|j||j�s�|||jj�dkr�|j	|�q"|dk	r�|j|j||||��d}d}|j	|�q"W|dk	�r|j|j||||��dj
|�S)a�Refactors a docstring, looking for doctests.

        This returns a modified version of the input string.  It looks
        for doctests, which start with a ">>>" prompt, and may be
        continued with "..." prompts, as long as the "..." is indented
        the same as the ">>>".

        (Unfortunately we can't use the doctest module's parser,
        since, like most parsers, it is not geared towards preserving
        the original source.)
        NrT)�keependsrr>r})�
splitlines�lstripr�PS1r2�refactor_doctest�find�PS2�rstriprr�)
rzr@r��result�blockZblock_lineno�indent�lineno�line�irrrr�%s:



z"RefactoringTool.refactor_docstringc
sy�j||��}Wndtk
rv}zH�jjtj�rRx|D]}�jd|jd��q8W�jd|||j	j
|�|Sd}~XnX�j||��r
t|�j
dd�}|d|d�||dd�}	}|djd�s�|dd7<��j|jd�g}|�r
|��fd	d
�|D�7}|S)
z�Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).

        z
Source: %sr>z+Can't parse docstring in %s line %s: %s: %sNT)r�rrcsg|]}��j|�qSr)r�)r7r�)r�rzrrr:jsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>r�r�)�parse_blockr'reZisEnabledForro�DEBUGr�r�r�r�rr�r�r�rr��pop)
rzr�r�r�r�r�r�r�r�Zclippedr)r�rzrr�Ps$
"z RefactoringTool.refactor_doctestcCs�|jrd}nd}|js$|jd|�n&|jd|�x|jD]}|j|�q8W|jrt|jd�x|jD]}|j|�qbW|jr�t|j�dkr�|jd�n|jdt|j��x&|jD]\}}}|j|f|�|�q�WdS)	N�werez
need to bezNo files %s modified.zFiles that %s modified:z$Warnings/messages while refactoring:rzThere was 1 error:zThere were %d errors:)rqrur�rprnr�)rzr��file�messager�r�r�rrr�	summarizems$
zRefactoringTool.summarizecCs"|jj|j|||��}t�|_|S)z�Parses a block into a tree.

        This is necessary to get correct line number / offset information
        in the parser diagnostics and embedded into the parse tree.
        )rZparse_tokens�	wrap_toksrPr�)rzr�r�r�r�rrrr��szRefactoringTool.parse_blockccshtj|j||�j�}xN|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqWdS)z;Wraps a tokenize stream to systematically modify start/end.rN)rrL�	gen_lines�__next__)rzr�r�r�r1r#r]Zline0Zcol0Zline1Zcol1Z	line_textrrrr��s
zRefactoringTool.wrap_toksccs�||j}||j}|}xV|D]N}|j|�r@|t|�d�Vn(||j�dkrXdVntd||f��|}qWx
dVqrWdS)z�Generates lines as expected by tokenize from a list of lines.

        This strips the first len(indent + self.PS1) characters off each line.
        Nr>zline=%r, prefix=%rr})r�r�rr�r��AssertionError)rzr�r��prefix1Zprefix2�prefixr�rrrr��s



zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rr r!rhr�r�r{rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrra�s:
4(
	


O

+
rac@seZdZdS)�MultiprocessingUnsupportedN)rr r!rrrrr��sr�csBeZdZ�fdd�Zd�fdd�	Z�fdd�Z�fd	d
�Z�ZS)�MultiprocessRefactoringToolcs"tt|�j||�d|_d|_dS)N)�superr�r{�queue�output_lock)rzr��kwargs)r�rrr{�sz$MultiprocessRefactoringTool.__init__Frcs|dkrtt��j|||�Syddl�Wntk
r@t�YnX�jdk	rTtd���j��_�j	��_
��fdd�t|�D�}z.x|D]}|j�q�Wtt��j|||�Wd�jj
�xt|�D]}�jjd�q�Wx|D]}|j�r�|j
�q�Wd�_XdS)Nrrz already doing multiple processescsg|]}�j�jd��qS))�target)ZProcess�_child)r7r�)�multiprocessingrzrrr:�sz8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)r�r�r�r��ImportErrorr�r��RuntimeErrorZ
JoinableQueueZLockr��range�startr��putZis_alive)rzr�r�r�Z
num_processesZ	processesr)r�)r�)r�rzrr��s2









z$MultiprocessRefactoringTool.refactorc
sR|jj�}xB|dk	rL|\}}ztt|�j||�Wd|jj�X|jj�}qWdS)N)r�rmr�r�r�Z	task_done)rzZtaskr�r�)r�rrr��s


z"MultiprocessRefactoringTool._childcs2|jdk	r|jj||f�ntt|�j||�SdS)N)r�r�r�r�r�)rzr�r�)r�rrr��s

z)MultiprocessRefactoringTool.refactor_file)FFr)rr r!r{r�r�r��
__classcell__rr)r�rr��s
r�)T)rr)(r`�
__author__rr�ror�r+rM�	itertoolsrZpgen2rrrZ
fixer_utilrr}rr	r
rvrr'rr$r5r;r=�version_info�codecsr�r�rArCr^r_�objectrar�r�rrrr�<module>	sF



(	PK�&�\f<�Q��pygram.cpython-36.opt-1.pycnu�[���3


 \��@s�dZddlZddlmZddlmZddlmZejjejj	e
�d�Zejjejj	e
�d�ZGd	d
�d
e
�Zejde�Zee�Zej�Zejd=ejde�Zee�ZdS)
z&Export the Python grammar and symbols.�N�)�token)�driver)�pytreezGrammar.txtzPatternGrammar.txtc@seZdZdd�ZdS)�SymbolscCs(x"|jj�D]\}}t|||�qWdS)z�Initializer.

        Creates an attribute for each grammar symbol (nonterminal),
        whose value is the symbol's type (an int >= 256).
        N)Z
symbol2number�items�setattr)�selfZgrammar�nameZsymbol�r�&/usr/lib64/python3.6/lib2to3/pygram.py�__init__szSymbols.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrZlib2to3�print)�__doc__�osZpgen2rr�r�path�join�dirname�__file__Z
_GRAMMAR_FILEZ_PATTERN_GRAMMAR_FILE�objectrZload_packaged_grammarZpython_grammarZpython_symbols�copyZ!python_grammar_no_print_statement�keywordsZpattern_grammarZpattern_symbolsrrrr�<module>sPK�&�\�	�EFF btm_matcher.cpython-36.opt-1.pycnu�[���3


 \��@sldZdZddlZddlZddlmZddlmZddlm	Z	Gdd	�d	e
�ZGd
d�de
�Zia
dd
�ZdS)a�A bottom-up tree matching algorithm implementation meant to speed
up 2to3's matching process. After the tree patterns are reduced to
their rarest linear path, a linear Aho-Corasick automaton is
created. The linear automaton traverses the linear paths from the
leaves to the root of the AST and returns a set of nodes for further
matching. This reduces significantly the number of candidate nodes.z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@s eZdZdZej�Zdd�ZdS)�BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content)�self�r�+/usr/lib64/python3.6/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__�__doc__�	itertoolsrrrrrrrsrc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
BottomMatcherzgThe main matcher class. After instantiating the patterns should
    be added using the add_fixer methodcCs0t�|_t�|_|jg|_g|_tjd�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�loggingZ	getLoggerZlogger)rrrrrs

zBottomMatcher.__init__cCsL|jj|�t|j�}|j�}|j||jd�}x|D]}|jj|�q4WdS)z�Reduces a fixer's pattern tree to a linear path and adds it
        to the matcher(a common Aho-Corasick automaton). The fixer is
        appended on the matching states and called when they are
        reached)�startN)r	�appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr�	add_fixer%s

zBottomMatcher.add_fixercCs�|s
|gSt|dt�rhg}xF|dD]:}|j||d�}x&|D]}|j|j|dd�|��q>Wq&W|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)z5Recursively adds a linear pattern to the AC automatonr)rrN)�
isinstance�tupler�extendrr)r�patternrr �alternativeZ	end_nodes�endZ	next_noderrrr1s"
"zBottomMatcher.addc	Cs0|j}tt�}�x|D�]}|}�x|�r&d|_x,|jD]"}t|tj�r8|jdkr8d|_Pq8W|j	dkrp|j}n|j	}||j
kr�|j
|}x�|jD]"}||kr�g||<||j|�q�Wnd|j}|j
dk	r�|j
jr�P||j
k�r|j
|}x2|jD](}||j�k�rg||<||j|�q�W|j
}q$WqW|S)auThe main interface with the bottom matcher. The tree is
        traversed from the bottom using the constructed
        automaton. Nodes are only checked once as the tree is
        retraversed. When the automaton fails, we give it one more
        shot(in case the above tree matches as a whole with the
        rejected leaf), then we break for the next leaf. There is the
        special case of multiple arguments(see code comments) where we
        recheck the nodes

        Args:
           The leaves of the AST tree to be matched

        Returns:
           A dictionary of node matches with fixers as the keys
        T�;FrN)rr�listZwas_checkedZchildrenr"rZLeaf�value�typerr	r�parent�keys)	rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenrrrr�runSs>





zBottomMatcher.runcs*td��fdd���|j�td�dS)z<Prints a graphviz diagram of the BM automaton(for debugging)z
digraph g{cs^xX|jj�D]J}|j|}td|j|jt|�t|j�f�|dkrNt|j��|�qWdS)Nz%d -> %d [label=%s] //%sr)rr-�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode)�
print_noderrr2�s

z*BottomMatcher.print_ac.<locals>.print_node�}N)r/r)rr)r2r�print_ac�s
zBottomMatcher.print_acN)	rrrrrr!rr.r4rrrrrs"=rcCsHts<ddlm}x*|jj�D]\}}t|�tkr|t|<qWtj||�S)Nr)�python_symbols)�_type_reprsZpygramr5�__dict__�itemsr+�int�
setdefault)Ztype_numr5�name�valrrrr0�sr0)r�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr6r0rrrr�<module>s	PK�&�\�"��&�&fixer_util.cpython-36.opt-2.pycnu�[���3


 \g;�
@s�ddlmZddlmZmZddlmZddlm	Z	dd�Z
dd�Zd	d
�Zdd�Z
dVdd�Zdd�Zdd�Zdd�Ze�e�fdd�ZdWdd�Zdd�Zdd�ZdXdd�Zd d!�ZdYd"d#�ZdZd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1d2d3d4d5d6d7d8d9h
Zd:d;�Z d<a!d=a"d>a#d?a$d@dA�Z%dBdC�Z&dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,ej-ej.hZ/d[dPdQ�Z0ej.ej-ej1hZ2dRdS�Z3d\dTdU�Z4d
S)]�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�*/usr/lib64/python3.6/lib2to3/fixer_util.py�
KeywordArgsrcCsttjd�S)N�()rr�LPARrrrr
�LParensrcCsttjd�S)N�))rr�RPARrrrr
�RParensrcCsHt|t�s|g}t|t�s&d|_|g}ttj|ttjddd�g|�S)N� r)�prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

rNcCsttj||d�S)N)r)rr�NAME)�namerrrr
�Name$srcCs|ttjt�|g�gS)N)rr�trailer�Dot)�obj�attrrrr
�Attr(sr$cCsttjd�S)N�,)rr�COMMArrrr
�Comma,sr'cCsttjd�S)N�.)rr�DOTrrrr
r!0sr!cCs4ttj|j�|j�g�}|r0|jdttj|��|S)Nr)rrr �clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr/cCs&ttj|t|�g�}|dk	r"||_|S)N)rr�powerr/r)Z	func_namer-rr.rrr
�Call;sr1cCsttjd�S)N�
)rr�NEWLINErrrr
�NewlineBsr4cCsttjd�S)N�)rrr3rrrr
�	BlankLineFsr6cCsttj||d�S)N)r)rr�NUMBER)�nrrrr
�NumberJsr9cCs"ttjttjd�|ttjd�g�S)N�[�])rrr rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMsr>cCsttj||d�S)N)r)rr�STRING)�stringrrrr
�StringSsrAc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|jttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)Nr5r�for�in�ifr:r;)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr<r=)	Zxp�fp�itZtestZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs$
rIcCsZx|D]}|j�qWttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)N�fromr)r�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos

rQc	Cs�|dj�}|jtjkr"|j�}nttj|j�g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|dj�||dj�g�g|�}|j	|_	|S)	Nr"�aftercSsg|]}|j��qSr)r*)�.0r8rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r*�typerr,rr0r$rr r)r.�results�namesr"Z
newarglistrR�newrrr
�
ImportAndCall�s
DrZcCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)NT�rUr�rr)rrrOrr�lenrr)r.rrr
�is_tuple�s
r^cCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)NrrUr:r;���r_)rrr]rOrr)r.rrr
�is_list�s
r`cCsttjt�|t�g�S)N)rrrrr)r.rrr
�parenthesize�sra�sortedr�set�any�all�tuple�sum�min�max�	enumerateccs(t||�}x|r"|Vt||�}qWdS)N)�getattr)r"r#�nextrrr
�
attr_chain�s
rmzefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     z�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
z`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
FcCsrts&tjt�atjt�atjt�adatttg}x<t|t|d��D](\}}i}|j||�rB|d|krBdSqBWdS)NT�parentr.F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprm�match)r.Zpatterns�patternrnrWrrr
�in_special_context�s



rvcCs�|j}|dk	r|jtjkrdS|j}|jtjtjfkr:dS|jtjkrX|j	d|krXdS|jtj
ks�|jtjkr�|dk	r�|jtjks�|j	d|kr�dSdS)NFrUT)
Zprev_siblingrVrr)rnr�funcdef�classdef�	expr_stmtrOZ
parametersZ
typedargslistr&)r.�prevrnrrr
�is_probably_builtin�sr{cCsNxH|dk	rH|jtjkr@t|j�dkr@|jd}|jtjkr@|jS|j}qWdS)Nr\rr5)	rVr�suiter]rOr�INDENTrrn)r.�indentrrr
�find_indentations


rcCs>|jtjkr|S|j�}|jd}|_ttj|g�}||_|S)N)rVrr|r*rnr)r.rnr|rrr
�
make_suitesr�cCs(x"|jtjkr"|j}|std��qW|S)Nz,root found before file_input node was found.)rVrZ
file_inputrn�
ValueError)r.rrr
�	find_root&s
r�cCst|t|�|�}t|�S)N)�find_bindingr��bool)�packagerr.Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfkS)N)rVr�import_namerN)r.rrr
�	is_import7sr�cCs4dd�}t|�}t|||�r dSd}}xTt|j�D]F\}}||�sFq4x(t|j|d��D]\}}||�sZPqZW||}Pq4W|dkr�xDt|j�D]6\}}|jtjkr�|jr�|jdjtjkr�|d}Pq�W|dkr�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|j|t	tj|
��dS)NcSs |jtjko|jot|jd�S)NrU)rVr�simple_stmtrOr�)r.rrr
�is_import_stmt>sz$touch_import.<locals>.is_import_stmtrUrrKr)r)r�r�rjrOrVrr�rr?rr�rrrQr4r+)r�rr.r��rootZ
insert_pos�offset�idxZnode2�import_rOrrr
�touch_import;s4

r�cCs��x�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n4|jtjtjfkr�t|t|jd�|�}|r�|}�n|jtj	k�rt|t|jd�|�}|r�|}nXx�t
|jdd��D]@\}}|jtjko�|j
dkr�t|t|j|d�|�}|r�|}q�Wnx|jtk�r6|jdj
|k�r6|}nTt|||��rJ|}n@|jtjk�rft|||�}n$|jtjk�r�t||jd��r�|}|r
|�s�|St|�r
|Sq
WdS)	Nrr\r[�:�rUr_r_)rOrVrZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrjr�COLONr�	_def_syms�_is_import_bindingr�ryr�)rr.r��childZretr8�iZkidrrr
r�isH
r�cCsX|g}xL|rR|j�}|jdkr6|jtkr6|j|j�q|jtjkr|j|kr|SqWdS)N�)�poprV�_block_syms�extendrOrrr)rr.Znodesrrr
r��sr�cCs�|jtjkr�|r�|jd}|jtjkrvx�|jD]@}|jtjkrV|jdj|krp|Sq0|jtjkr0|j|kr0|Sq0WnL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd�j�|kr�dS|jd}|�rtd|��rdS|jtj
k�r.t||��r.|S|jtjk�rf|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)Nrr\r[�asr_)rVrr�rOZdotted_as_namesZdotted_as_namerrrrN�str�stripr�rMZimport_as_name�STAR)r.rr�rPr�Zlastr8rrr
r��s@




r�)N)NN)N)N)N)N)N)5Zpgen2rZpytreerrZpygramrrr5rrrrrrr$r'r!r/r1r4r6r9r>rArIrQrZr^r`raZconsuming_callsrmrprqrrrorvr{rr�r�r�r�r�rxrwr�r�r r�r�r�rrrr
�<module>sX





		-
*
PK�&�\�ѝbtm_utils.cpython-36.opt-2.pycnu�[���3


 \�&�@sxddlmZddlmZmZddlmZmZeZeZ	ej
ZeZdZ
dZdZGdd�de�Zdd	d
�Zdd�Zd
d�ZdS)�)�pytree)�grammar�token)�pattern_symbols�python_symbols��c@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�MinNodeNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfr
r�r�)/usr/lib64/python3.6/lib2to3/btm_utils.py�__init__szMinNode.__init__cCst|j�dt|j�S)N� )�strr
r)rrrr�__repr__szMinNode.__repr__cCs�|}g}x�|r�|jtkr`|jj|�t|j�t|j�krTt|j�g}g|_|j}q
n|j}d}P|jtkr�|j	j|�t|j	�t|j�kr�t
|j	�}g|_	|j}q
n|j}d}P|jtjkr�|j
r�|j|j
�n|j|j�|j}q
W|S)N)r
�TYPE_ALTERNATIVESr�append�lenr�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s8



zMinNode.leaf_to_rootcCs&x |j�D]}|j�}|r
|Sq
WdS)N)�leavesr")r�lr!rrr�get_linear_subpatternKszMinNode.get_linear_subpatternccs.x|jD]}|j�EdHqW|js*|VdS)N)rr#)r�childrrrr#`szMinNode.leaves)NN)�__name__�
__module__�__qualname__rrr"r%r#rrrrr	s

	*r	Nc
Cs�d}|jtjkr|jd}|jtjkr�t|j�dkrFt|jd|�}nJttd�}x>|jD]4}|jj	|�drnqXt||�}|dk	rX|jj
|�qXW�n|jtjk�rt|j�dkr�ttd�}x(|jD]}t||�}|r�|jj
|�q�W|js�d}nt|jd|�}�n�|jtj
k�r�t|jdtj��rH|jdjdk�rHt|jd|�St|jdtj��rn|jdjdk�s�t|j�dk�r�t|jdd��r�|jdjdk�r�dSd}d}d}d	}d}	d	}
xn|jD]d}|jtjk�r�d	}|}n*|jtjk�r�d}|}	n|jtjk�r|}t|d��r�|jd
k�r�d}
�q�W|
�rb|jd}t|d��rl|jdk�rl|jd}n
|jd}|jtjk�r�|jdk�r�ttd�}n4tt|j��r�ttt|j�d�}nttt|j�d�}n\|jtjk�r|jjd
�}|tk�r�tt|d�}nttj|d�}n|jtjk�r$t||�}|�rZ|	jdjdk�rBd}n|	jdjdk�rVnt�|�r�|dk	�r�x8|jdd�D]&}t||�}|dk	�rz|jj
|��qzW|�r�||_|S)N�r)r
r�(�[�valueTF�=r�any�')r
r�*�+���)r
�symsZMatcherrZAlternativesr�reduce_treer	r�indexrZAlternativerZUnit�
isinstancerZLeafr-�hasattrZDetailsZRepeaterrr�TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r rZnew_noder&Zreducedr
Zdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr5gs�











r5cs�t|t�s|St|�dkr"|dSg}g}dddddg�g}d�xl|D]d}tt|d	d
���rFtt|�fdd
���r~|j|�qFtt|�fdd
���r�|j|�qF|j|�qFW|r�|}n|r�|}n|r�|}t|td
�S)Nrr*�in�for�if�not�Nonez[]().,:cSst|�tkS)N)r
r)�xrrr�<lambda>�sz/get_characteristic_subpattern.<locals>.<lambda>cst|t�o|�kS)N)r7r)rE)�common_charsrrrFscst|t�o|�kS)N)r7r)rE)�common_namesrrrFs)�key)r7�listrr/�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rGrHrr�s2

rccs<x6|D].}t|ttf�r*t||�EdHq||�VqWdS)N)r7rJrrK)ZsequenceZ	test_funcrErrrrKs
rKr3������)N)�rZpgen2rrZpygramrrr4r;Zopmapr>rr9rr�objectr	r5rrKrrrr�<module>sW
%PK�&�\`l��:�:pytree.cpython-36.opt-2.pycnu�[���3


 \�m�@s�dZddlZddlZddlmZdZiadd�ZGdd�de�Z	Gd	d
�d
e	�Z
Gdd�de	�Zd
d�ZGdd�de�Z
Gdd�de
�ZGdd�de
�ZGdd�de
�ZGdd�de
�Zdd�ZdS)z#Guido van Rossum <guido@python.org>�N)�StringIOi���cCsHts<ddlm}x*|jj�D]\}}t|�tkr|t|<qWtj||�S)N�)�python_symbols)�_type_reprsZpygramr�__dict__�items�type�int�
setdefault)Ztype_numr�name�val�r
�&/usr/lib64/python3.6/lib2to3/pytree.py�	type_reprsrc@s�eZdZdZdZfZdZdZdd�Zdd�Z	dZ
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd �Zejd%kr�d#d$�ZdS)&�BaseNFcOs
tj|�S)N)�object�__new__)�cls�args�kwdsr
r
rr2szBase.__new__cCs|j|jk	rtS|j|�S)N)�	__class__�NotImplemented�_eq)�self�otherr
r
r�__eq__7szBase.__eq__cCst�dS)N)�NotImplementedError)rrr
r
rrCs	zBase._eqcCst�dS)N)r)rr
r
r�cloneNsz
Base.clonecCst�dS)N)r)rr
r
r�
post_orderVszBase.post_ordercCst�dS)N)r)rr
r
r�	pre_order^szBase.pre_ordercCs�t|t�s|g}g}d}x:|jjD].}||krF|dk	r@|j|�d}q"|j|�q"W|jj�||j_x|D]}|j|_qlWd|_dS)NFT)�
isinstance�list�parent�children�extend�append�changed)r�newZ
l_children�found�ch�xr
r
r�replacefs



zBase.replacecCs.|}x"t|t�s&|jsdS|jd}qW|jS)Nr)r �Leafr#�lineno)r�noder
r
r�
get_lineno}szBase.get_linenocCs|jr|jj�d|_dS)NT)r"r&�was_changed)rr
r
rr&�s
zBase.changedcCsJ|jrFx>t|jj�D].\}}||kr|jj�|jj|=d|_|SqWdS)N)r"�	enumerater#r&)r�ir.r
r
r�remove�s

zBase.removecCsZ|jdkrdSxFt|jj�D]6\}}||kry|jj|dStk
rPdSXqWdS)Nr)r"r1r#�
IndexError)rr2�childr
r
r�next_sibling�s
zBase.next_siblingcCsP|jdkrdSx<t|jj�D],\}}||kr|dkr8dS|jj|dSqWdS)Nrr)r"r1r#)rr2r5r
r
r�prev_sibling�s
zBase.prev_siblingccs"x|jD]}|j�EdHqWdS)N)r#�leaves)rr5r
r
rr8�szBase.leavescCs|jdkrdSd|jj�S)Nrr)r"�depth)rr
r
rr9�s
z
Base.depthcCs|j}|dkrdS|jS)N�)r6�prefix)rZnext_sibr
r
r�
get_suffix�szBase.get_suffix�rcCst|�jd�S)N�ascii)�str�encode)rr
r
r�__str__�szBase.__str__)r=r)�__name__�
__module__�__qualname__rr"r#r0Zwas_checkedrr�__hash__rrrrr+r/r&r3�propertyr6r7r8r9r<�sys�version_inforAr
r
r
rr s.
	


rc@s�eZdZddd�Zdd�Zdd�Zejdkr0eZd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zee
e�Zdd�Zdd�Zdd�ZdS)�NodeNcCsR||_t|�|_x|jD]
}||_qW|dk	r4||_|rH|dd�|_nd|_dS)N)rr!r#r"r;�fixers_applied)rrr#�contextr;rJr)r
r
r�__init__�s


z
Node.__init__cCsd|jjt|j�|jfS)Nz
%s(%s, %r))rrBrrr#)rr
r
r�__repr__�sz
Node.__repr__cCsdjtt|j��S)Nr:)�join�mapr?r#)rr
r
r�__unicode__�szNode.__unicode__r=rcCs|j|jf|j|jfkS)N)rr#)rrr
r
rr�szNode._eqcCst|jdd�|jD�|jd�S)NcSsg|]}|j��qSr
)r)�.0r)r
r
r�
<listcomp>szNode.clone.<locals>.<listcomp>)rJ)rIrr#rJ)rr
r
rrsz
Node.cloneccs(x|jD]}|j�EdHqW|VdS)N)r#r)rr5r
r
rrszNode.post_orderccs(|Vx|jD]}|j�EdHqWdS)N)r#r)rr5r
r
rr
szNode.pre_ordercCs|js
dS|jdjS)Nr:r)r#r;)rr
r
r�_prefix_getterszNode._prefix_gettercCs|jr||jd_dS)Nr)r#r;)rr;r
r
r�_prefix_setterszNode._prefix_settercCs(||_d|j|_||j|<|j�dS)N)r"r#r&)rr2r5r
r
r�	set_child!s
zNode.set_childcCs ||_|jj||�|j�dS)N)r"r#�insertr&)rr2r5r
r
r�insert_child+szNode.insert_childcCs||_|jj|�|j�dS)N)r"r#r%r&)rr5r
r
r�append_child4szNode.append_child)NNN)r=r)rBrCrDrLrMrPrGrHrArrrrrSrTrFr;rUrWrXr
r
r
rrI�s"



	rIc@s�eZdZdZdZdZddgfdd�Zdd�Zdd	�Ze	j
dkrBeZdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zeee�ZdS)r,r:rNcCsF|dk	r|\|_\|_|_||_||_|dk	r4||_|dd�|_dS)N)�_prefixr-�columnr�valuerJ)rrr[rKr;rJr
r
rrLGsz
Leaf.__init__cCsd|jj|j|jfS)Nz
%s(%r, %r))rrBrr[)rr
r
rrMZsz
Leaf.__repr__cCs|jt|j�S)N)r;r?r[)rr
r
rrP`szLeaf.__unicode__r=cCs|j|jf|j|jfkS)N)rr[)rrr
r
rrkszLeaf._eqcCs$t|j|j|j|j|jff|jd�S)N)rJ)r,rr[r;r-rZrJ)rr
r
rros
z
Leaf.cloneccs
|VdS)Nr
)rr
r
rr8uszLeaf.leavesccs
|VdS)Nr
)rr
r
rrxszLeaf.post_orderccs
|VdS)Nr
)rr
r
rr|szLeaf.pre_ordercCs|jS)N)rY)rr
r
rrS�szLeaf._prefix_gettercCs|j�||_dS)N)r&rY)rr;r
r
rrT�szLeaf._prefix_setter)r=r)rBrCrDrYr-rZrLrMrPrGrHrArrr8rrrSrTrFr;r
r
r
rr,>s$
r,cCsN|\}}}}|s||jkr<t|�dkr.|dSt|||d�St|||d�SdS)Nrr)rK)Z
number2symbol�lenrIr,)ZgrZraw_noderr[rKr#r
r
r�convert�sr]c@sLeZdZdZdZdZdd�Zdd�Zdd�Zddd	�Z	dd
d�Z
dd
�ZdS)�BasePatternNcOs
tj|�S)N)rr)rrrr
r
rr�szBasePattern.__new__cCsLt|j�|j|jg}x|r.|ddkr.|d=qWd|jjdjtt|��fS)Nrz%s(%s)z, ���r_)	rr�contentrrrBrNrO�repr)rrr
r
rrM�s
zBasePattern.__repr__cCs|S)Nr
)rr
r
r�optimize�szBasePattern.optimizecCsn|jdk	r|j|jkrdS|jdk	rRd}|dk	r4i}|j||�sDdS|rR|j|�|dk	rj|jrj|||j<dS)NFT)rr`�	_submatch�updater)rr.�results�rr
r
r�match�s


zBasePattern.matchcCs t|�dkrdS|j|d|�S)NrFr)r\rg)r�nodesrer
r
r�	match_seq�szBasePattern.match_seqccs&i}|r"|j|d|�r"d|fVdS)Nrr)rg)rrhrfr
r
r�generate_matches�szBasePattern.generate_matches)N)N)rBrCrDrr`rrrMrbrgrirjr
r
r
rr^�s


r^c@s*eZdZddd�Zd	dd�Zd
dd�ZdS)�LeafPatternNcCs&|dk	r|dk	r||_||_||_dS)N)rr`r)rrr`rr
r
rrL�s
zLeafPattern.__init__cCst|t�sdStj|||�S)NF)r r,r^rg)rr.rer
r
rrgs
zLeafPattern.matchcCs|j|jkS)N)r`r[)rr.rer
r
rrcs
zLeafPattern._submatch)NNN)N)N)rBrCrDrLrgrcr
r
r
rrk�s

rkc@s$eZdZdZddd�Zddd�ZdS)	�NodePatternFNcCsT|dk	r|dk	r>t|�}x$t|�D]\}}t|t�r"d|_q"W||_||_||_dS)NT)r!r1r �WildcardPattern�	wildcardsrr`r)rrr`rr2�itemr
r
rrL%s

zNodePattern.__init__cCs�|jrJx>t|j|j�D],\}}|t|j�kr|dk	r>|j|�dSqWdSt|j�t|j�krbdSx*t|j|j�D]\}}|j||�srdSqrWdS)NTF)rnrjr`r#r\rd�ziprg)rr.re�crf�
subpatternr5r
r
rrcBs

zNodePattern._submatch)NNN)N)rBrCrDrnrLrcr
r
r
rrl!s
rlc@sZeZdZddedfdd�Zdd�Zddd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)rmNrcCs@|dk	r$ttt|��}x|D]}qW||_||_||_||_dS)N)�tuplerOr`�min�maxr)rr`rtrur�altr
r
rrLls
zWildcardPattern.__init__cCs�d}|jdk	r<t|j�dkr<t|jd�dkr<|jdd}|jdkr�|jdkr�|jdkrft|jd�S|dk	r�|j|jkr�|j�S|jdkr�t|t�r�|jdkr�|j|jkr�t|j|j|j|j|j|j�S|S)Nrr)r)	r`r\rtrurlrrbr rm)rrrr
r
rrb�s 
 


zWildcardPattern.optimizecCs|j|g|�S)N)ri)rr.rer
r
rrg�szWildcardPattern.matchcCsRxL|j|�D]>\}}|t|�kr|dk	rF|j|�|jrFt|�||j<dSqWdS)NTF)rjr\rdrr!)rrhrerqrfr
r
rri�s
zWildcardPattern.match_seqccs:|jdkrXxJt|jdtt|�|j��D]*}i}|jrH|d|�||j<||fVq(Wn�|jdkrp|j|�Vn�ttd�r�tj	}t
�t_	z�y@x:|j|d�D]*\}}|jr�|d|�||j<||fVq�WWnRtk
�rx:|j
|�D],\}}|j�r
|d|�||j<||fVq�WYnXWdttd��r4|t_	XdS)NrZ	bare_name�getrefcountr)r`�rangertr\rur�_bare_name_matches�hasattrrG�stderrr�_recursive_matches�RuntimeError�_iterative_matches)rrh�countrfZsave_stderrr
r
rrj�s.
"

z WildcardPattern.generate_matchesccst|�}d|jkrdifVg}x>|jD]4}x.t||�D] \}}||fV|j||f�q8Wq(Wx�|�rg}x�|D]�\}}	||krr||jkrrxn|jD]d}x^t|||d��D]H\}
}|
dkr�i}|j|	�|j|�||
|fV|j||
|f�q�Wq�WqrW|}qbWdS)Nr)r\rtr`rjr%rurd)rrhZnodelenrervrqrfZnew_results�c0�r0�c1�r1r
r
rr~�s*




z"WildcardPattern._iterative_matchescCsxd}i}d}t|�}xH|r\||kr\d}x0|jD]&}|dj|||�r0|d7}d}Pq0WqW|d|�||j<||fS)NrFTr)r\r`rgr)rrhrrf�doneruZleafr
r
rry�s
z"WildcardPattern._bare_name_matchesc	cs�||jkrdifV||jkr�xr|jD]h}xbt||�D]T\}}xJ|j||d�|d�D].\}}i}|j|�|j|�|||fVqXWq6Wq&WdS)Nrr)rtrur`rjr|rd)	rrhrrvr�r�r�r�rfr
r
rr|s


"

z"WildcardPattern._recursive_matches)N)N)rBrCrD�HUGErLrbrgrirjr~ryr|r
r
r
rrm^s#

-rmc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�NegatedPatternNcCs|dk	r||_dS)N)r`)rr`r
r
rrLs	zNegatedPattern.__init__cCsdS)NFr
)rr.r
r
rrg)szNegatedPattern.matchcCst|�dkS)Nr)r\)rrhr
r
rri-szNegatedPattern.match_seqccsL|jdkr"t|�dkrHdifVn&x|jj|�D]
\}}dSWdifVdS)Nr)r`r\rj)rrhrqrfr
r
rrj1s
zNegatedPattern.generate_matches)N)rBrCrDrLrgrirjr
r
r
rr�s

r�c	cs�|sdifVn�|d|dd�}}xl|j|�D]^\}}|sJ||fVq2xDt|||d��D].\}}i}|j|�|j|�|||fVq^Wq2WdS)Nrr)rjrd)	Zpatternsrh�p�restr�r�r�r�rfr
r
rrj=s


rj)�
__author__rG�warnings�iorr�rrrrrIr,r]r^rkrlrmr�rjr
r
r
r�<module>
s$
1nNV,==#PK�&�\�O���pygram.cpython-36.opt-2.pycnu�[���3


 \��@s�ddlZddlmZddlmZddlmZejjejje	�d�Z
ejjejje	�d�ZGdd	�d	e�Z
ejd
e
�Ze
e�Zej�Zejd=ejd
e�Ze
e�ZdS)�N�)�token)�driver)�pytreezGrammar.txtzPatternGrammar.txtc@seZdZdd�ZdS)�SymbolscCs(x"|jj�D]\}}t|||�qWdS)N)Z
symbol2number�items�setattr)�selfZgrammar�nameZsymbol�r�&/usr/lib64/python3.6/lib2to3/pygram.py�__init__szSymbols.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrZlib2to3�print)�osZpgen2rr�r�path�join�dirname�__file__Z
_GRAMMAR_FILEZ_PATTERN_GRAMMAR_FILE�objectrZload_packaged_grammarZpython_grammarZpython_symbols�copyZ!python_grammar_no_print_statement�keywordsZpattern_grammarZpattern_symbolsrrrr�<module>sPK�&�\vá�FAFArefactor.cpython-36.opt-2.pycnu�[���3


 \=m�@s8dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZddlmZmZddlmZd%d
d�ZGdd
�d
e�Zdd�Zdd�Zdd�Zdd�Zejd&kr�ddlZejZdd�Zdd�Z neZeZeZ dd�Z!Gdd�de�Z"Gdd �d e#�Z$Gd!d"�d"e�Z%Gd#d$�d$e$�Z&dS)'z#Guido van Rossum <guido@python.org>�N)�chain�)�driver�tokenize�token)�	find_root)�pytree�pygram)�btm_matcherTcCstt|ggdg�}tjj|j�}g}xLttj|��D]:}|jd�r2|jd�r2|rZ|dd�}|j	|dd��q2W|S)N�*�fix_z.py�����)
�
__import__�os�path�dirname�__file__�sorted�listdir�
startswith�endswith�append)Z	fixer_pkgZ
remove_prefixZpkgZ	fixer_dirZ	fix_names�name�r�(/usr/lib64/python3.6/lib2to3/refactor.py�get_all_fix_namessrc@seZdZdS)�
_EveryNodeN)�__name__�
__module__�__qualname__rrrrr+srcCs�t|tjtjf�r(|jdkr t�|jhSt|tj�rH|jrDt|j�St�t|tj	�r�t
�}x*|jD] }x|D]}|jt|��qlWqbW|Std|��dS)Nz$Oh no! I don't understand pattern %s)
�
isinstancerZNodePatternZLeafPattern�typerZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update�	Exception)Zpat�r�p�xrrrr$/s


r$cCs�tjt�}g}x�|D]|}|jrjyt|j�}Wntk
rJ|j|�Yq�XxB|D]}||j|�qRWq|jdk	r�||jj|�q|j|�qWx,tt	j
jj�t	j
j
�D]}||j|�q�Wt|�S)N)�collections�defaultdict�list�patternr$rrZ_accept_typerr	�python_grammarZ
symbol2number�values�tokens�extend�dict)Z
fixer_listZ
head_nodesZevery�fixerZheadsZ	node_typerrr�_get_headnode_dictKs"



r5cs�fdd�t�d�D�S)Ncsg|]}�d|�qS)�.r)�.0�fix_name)�pkg_namerr�
<listcomp>hsz+get_fixers_from_package.<locals>.<listcomp>F)r)r9r)r9r�get_fixers_from_packageds
r;cCs|S)Nr)�objrrr�	_identityksr=rcCs|jdd�S)Nz
�
)�replace)�inputrrr�_from_system_newlinesrsrAcCs tjdkr|jdtj�S|SdS)Nr>)r�linesepr?)r@rrr�_to_system_newlinests
rCcsTd}tjtj|�j���fdd�}ttjtjtj	h�}t
�}y�x�|�\}}||krVq@q@|tjkrl|rfPd}q@|tjko||dk�r,|�\}}|tjks�|dkr�P|�\}}|tjks�|dkr�P|�\}}|tj
kr�|dkr�|�\}}xJ|tjk�r(|j|�|�\}}|tj
k�s|d	k�rP|�\}}q�Wq@Pq@WWntk
�rJYnXt|�S)
NFcst��}|d|dfS)Nrr)�next)�tok)�genrr�advance�sz(_detect_future_features.<locals>.advanceT�fromZ
__future__�import�(�,)r�generate_tokens�io�StringIO�readline�	frozensetr�NEWLINE�NL�COMMENTr%�STRING�NAME�OP�add�
StopIteration)�sourceZhave_docstringrG�ignore�features�tp�valuer)rFr�_detect_future_featuressD








r^c@seZdZdS)�
FixerErrorN)rr r!rrrrr_�sr_c@s�eZdZddd�ZdZdZd4dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zd7dd�Zdd�Zd8dd�Zdd�Zd d!�Zd9d"d#�Zd:d$d%�Zd&Zd'Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS);�RefactoringToolF)�print_function�write_unchanged_filesZFixrNcCs2||_|pg|_|jj�|_|dk	r0|jj|�|jdrDtj|_ntj	|_|jj
d�|_g|_t
jd�|_g|_d|_tj|jtj|jd�|_|j�\|_|_g|_tj�|_g|_g|_xXt|j|j�D]F}|j r�|jj!|�q�||jkr�|jj"|�q�||jkr�|jj"|�q�Wt#|j�|_$t#|j�|_%dS)Nrarbr`F)�convert�logger)&�fixers�explicit�_default_options�copy�optionsr&r	�!python_grammar_no_print_statement�grammarr/�getrb�errors�loggingZ	getLoggerrd�	fixer_log�wroterZDriverrrc�
get_fixers�	pre_order�
post_order�files�bmZ
BottomMatcher�BMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr5�bmi_pre_order_heads�bmi_post_order_heads)�selfZfixer_namesrirfr4rrr�__init__�s<





zRefactoringTool.__init__cCs\g}g}�x&|jD�]}t|iidg�}|jdd�d}|j|j�rV|t|j�d�}|jd�}|jdjdd�|D��}yt	||�}Wn$t
k
r�td||f��YnX||j|j
�}	|	jr�|jd	k	r�||jkr�|jd
|�q|jd|�|	jdk�r|j|	�q|	jd
k�r |j|	�qtd|	j��qWtjd�}
|j|
d�|j|
d�||fS)Nrr6r�_�cSsg|]}|j��qSr)�title)r7r)rrrr:�sz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order)�key���)rer�rsplitr�FILE_PREFIX�len�split�CLASS_PREFIX�join�getattr�AttributeErrorr_rirorf�log_message�	log_debug�orderr�operator�
attrgetter�sort)ryZpre_order_fixersZpost_order_fixersZfix_mod_path�modr8�parts�
class_nameZ	fix_classr4Zkey_funcrrrrq�s8


zRefactoringTool.get_fixerscOs�dS)Nr)ry�msg�args�kwdsrrr�	log_errorszRefactoringTool.log_errorcGs|r||}|jj|�dS)N)rd�info)ryr�r�rrrr�szRefactoringTool.log_messagecGs|r||}|jj|�dS)N)rd�debug)ryr�r�rrrr�szRefactoringTool.log_debugcCsdS)Nr)ry�old_text�new_text�filename�equalrrr�print_outputszRefactoringTool.print_outputcCs<x6|D].}tjj|�r&|j|||�q|j|||�qWdS)N)rr�isdir�refactor_dir�
refactor_file)ry�items�write�
doctests_onlyZdir_or_filerrr�refactor#s
zRefactoringTool.refactorc
Cs�tjd}x�tj|�D]�\}}}|jd|�|j�|j�xH|D]@}|jd�rBtjj|�d|krBtjj||�}	|j	|	||�qBWdd�|D�|dd�<qWdS)N�pyzDescending into %sr6rcSsg|]}|jd�s|�qS)r6)r)r7Zdnrrrr:>sz0RefactoringTool.refactor_dir.<locals>.<listcomp>)
r�extsep�walkr�r�rr�splitextr�r�)
ryZdir_namer�r�Zpy_ext�dirpathZdirnames�	filenamesr�fullnamerrrr�,s

zRefactoringTool.refactor_dircCs�yt|d�}Wn.tk
r<}z|jd||�dSd}~XnXztj|j�d}Wd|j�Xt|d|d��}t|j	��|fSQRXdS)N�rbzCan't open %s: %srr()�encoding)NN)
�open�OSErrorr�r�detect_encodingrO�close�_open_with_encodingrA�read)ryr��f�errr�rrr�_read_python_source@s
z#RefactoringTool._read_python_sourcecCs�|j|�\}}|dkrdS|d7}|rn|jd|�|j||�}|jsL||kr`|j|||||�q�|jd|�nH|j||�}|js�|r�|jr�|jt|�dd�|||d�n|jd|�dS)Nr>zRefactoring doctests in %szNo doctest changes in %sr)r�r�zNo changes in %sr)r�r��refactor_docstringrb�processed_file�refactor_string�was_changed�str)ryr�r�r�r@r��output�treerrrr�PszRefactoringTool.refactor_filecCs�t|�}d|krtj|j_zJy|jj|�}Wn4tk
r`}z|jd||jj	|�dSd}~XnXWd|j|j_X||_
|jd|�|j||�|S)NrazCan't parse %s: %s: %szRefactoring %s)
r^r	rjrrkZparse_stringr'r��	__class__r�future_featuresr��
refactor_tree)ry�datarr[r�r�rrrr�gs
zRefactoringTool.refactor_stringcCs�tjj�}|rN|jd�|j|d�}|js2||krB|j|d|�q�|jd�n:|j|d�}|jsj|r~|jr~|jt	|�d|�n
|jd�dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
�sys�stdinr�r�r�rbr�r�r�r�)ryr�r@r�r�rrr�refactor_stdin�s

zRefactoringTool.refactor_stdinc
Cs�x"t|j|j�D]}|j||�qW|j|j|j��|j|j|j��|jj|j	��}�xvt
|j���rАx`|jjD�]R}||ko�||rv||j
tjjdd�|jr�||j
tjjd��x
t||�D�]�}|||kr�||j|�yt|�Wntk
�rw�YnX|j�r(||jk�r(q�|j|�}|r�|j||�}|dk	r�|j|�x,|j�D] }|j�spg|_|jj|��q^W|jj|j	��}x2|D]*}	|	|k�r�g||	<||	j||	��q�Wq�WqvWq\Wx$t|j|j�D]}|j||��q�W|jS)NT)r~�reverse)r~)rrrrsZ
start_tree�traverse_byrwrxrvZrunZleaves�anyr0rer�rZBaseZdepthZkeep_line_orderZ
get_linenor-�remover�
ValueErrorZfixers_applied�match�	transformr?rr2Zfinish_treer�)
ryr�rr4Z	match_set�node�results�newZnew_matchesZfxrrrrr��sJ



$zRefactoringTool.refactor_treecCs^|sdSxP|D]H}xB||jD]4}|j|�}|r|j||�}|dk	r|j|�|}qWqWdS)N)r#r�r�r?)ryreZ	traversalr�r4r�r�rrrr��s


zRefactoringTool.traverse_bycCs�|jj|�|dkr.|j|�d}|dkr.dS||k}|j||||�|r`|jd|�|js`dS|rv|j||||�n|jd|�dS)NrzNo changes to %szNot writing changes to %s)rtrr�r�r�rb�
write_file)ryr�r�r�r�r�r�rrrr��szRefactoringTool.processed_filec%Cs�yt|d|d�}Wn.tk
r@}z|jd||�dSd}~XnXzHy|jt|��Wn0tk
r�}z|jd||�WYdd}~XnXWd|j�X|jd|�d|_dS)N�w)r�zCan't create %s: %szCan't write %s: %szWrote changes to %sT)r�r�r�r�rCr�r�rp)ryr�r�r�r�r�r�rrrr�
s$
zRefactoringTool.write_filez>>> z... c
Csg}d}d}d}d}x�|jdd�D]�}|d7}|j�j|j�r�|dk	r\|j|j||||��|}|g}|j|j�}	|d|	�}q"|dk	r�|j||j�s�|||jj�dkr�|j	|�q"|dk	r�|j|j||||��d}d}|j	|�q"W|dk	�r|j|j||||��dj
|�S)NrT)�keependsrr>r|)�
splitlines�lstripr�PS1r2�refactor_doctest�find�PS2�rstriprr�)
ryr@r��result�blockZblock_lineno�indent�lineno�line�irrrr�%s:



z"RefactoringTool.refactor_docstringc
sy�j||��}Wndtk
rv}zH�jjtj�rRx|D]}�jd|jd��q8W�jd|||j	j
|�|Sd}~XnX�j||��r
t|�j
dd�}|d|d�||dd�}	}|d
jd�s�|dd7<��j|jd�g}|�r
|��fdd	�|D�7}|S)Nz
Source: %sr>z+Can't parse docstring in %s line %s: %s: %sT)r�rrcsg|]}��j|�qSr)r�)r7r�)r�ryrrr:jsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>rr)�parse_blockr'rdZisEnabledForrn�DEBUGr�r�r�r�rr�r�r�rr��pop)
ryr�r�r�r�r�r�r�r�Zclippedr)r�ryrr�Ps$
"z RefactoringTool.refactor_doctestcCs�|jrd}nd}|js$|jd|�n&|jd|�x|jD]}|j|�q8W|jrt|jd�x|jD]}|j|�qbW|jr�t|j�dkr�|jd�n|jdt|j��x&|jD]\}}}|j|f|�|�q�WdS)	N�werez
need to bezNo files %s modified.zFiles that %s modified:z$Warnings/messages while refactoring:rzThere was 1 error:zThere were %d errors:)rprtr�rormr�)ryr��file�messager�r�r�rrr�	summarizems$
zRefactoringTool.summarizecCs"|jj|j|||��}t�|_|S)N)rZparse_tokens�	wrap_toksrPr�)ryr�r�r�r�rrrr��szRefactoringTool.parse_blockccshtj|j||�j�}xN|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqWdS)Nr)rrL�	gen_lines�__next__)ryr�r�r�r1r#r]Zline0Zcol0Zline1Zcol1Z	line_textrrrr��s
zRefactoringTool.wrap_toksccs�||j}||j}|}xV|D]N}|j|�r@|t|�d�Vn(||j�dkrXdVntd||f��|}qWx
dVqrWdS)Nr>zline=%r, prefix=%rr|)r�r�rr�r��AssertionError)ryr�r��prefix1Zprefix2�prefixr�rrrr��s



zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rr r!rgr�r�rzrqr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr`�s:
4(
	


O

+
r`c@seZdZdS)�MultiprocessingUnsupportedN)rr r!rrrrr��sr�csBeZdZ�fdd�Zd�fdd�	Z�fdd�Z�fd	d
�Z�ZS)�MultiprocessRefactoringToolcs"tt|�j||�d|_d|_dS)N)�superr�rz�queue�output_lock)ryr��kwargs)r�rrrz�sz$MultiprocessRefactoringTool.__init__Frcs|dkrtt��j|||�Syddl�Wntk
r@t�YnX�jdk	rTtd���j��_�j	��_
��fdd�t|�D�}z.x|D]}|j�q�Wtt��j|||�Wd�jj
�xt|�D]}�jjd�q�Wx|D]}|j�r�|j
�q�Wd�_XdS)Nrrz already doing multiple processescsg|]}�j�jd��qS))�target)ZProcess�_child)r7r�)�multiprocessingryrrr:�sz8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)r�r�r�r��ImportErrorr�r��RuntimeErrorZ
JoinableQueueZLockr��range�startr��putZis_alive)ryr�r�r�Z
num_processesZ	processesr)r�)r�)r�ryrr��s2









z$MultiprocessRefactoringTool.refactorc
sR|jj�}xB|dk	rL|\}}ztt|�j||�Wd|jj�X|jj�}qWdS)N)r�rlr�r�r�Z	task_done)ryZtaskr�r�)r�rrr��s


z"MultiprocessRefactoringTool._childcs2|jdk	r|jj||f�ntt|�j||�SdS)N)r�r�r�r�r�)ryr�r�)r�rrr��s

z)MultiprocessRefactoringTool.refactor_file)FFr)rr r!rzr�r�r��
__classcell__rr)r�rr��s
r�)T)rr)'�
__author__rr�rnr�r+rM�	itertoolsrZpgen2rrrZ
fixer_utilrr|rr	r
rurr'rr$r5r;r=�version_info�codecsr�r�rArCr^r_�objectr`r�r�rrrr�<module>sD



(	PK�&�\�Zr~��__main__.cpython-36.pycnu�[���3


 \C�@s&ddlZddlmZejed��dS)�N�)�mainz
lib2to3.fixes)�sysr�exit�rr�(/usr/lib64/python3.6/lib2to3/__main__.py�<module>sPK�&�\))]QQfixer_base.cpython-36.opt-1.pycnu�[���3


 \"�@sTdZddlZddlmZddlmZddlmZGdd�de�Z	Gd	d
�d
e	�Z
dS)z2Base class for fixers (optional, but recommended).�N�)�PatternCompiler)�pygram)�does_tree_importc@s�eZdZdZdZdZdZdZdZe	j
d�Ze�Z
dZdZdZdZdZdZejZdd�Zd	d
�Zdd�Zd
d�Zdd�Zddd�Zdd�Zddd�Zdd�Zdd�Z dd�Z!dS) �BaseFixaOptional base class for fixers.

    The subclass name must be FixFooBar where FooBar is the result of
    removing underscores and capitalizing the words of the fix name.
    For example, the class name for a fixer named 'has_key' should be
    FixHasKey.
    NrZpostF�cCs||_||_|j�dS)aInitializer.  Subclass may override.

        Args:
            options: a dict containing the options passed to RefactoringTool
            that could be used to customize the fixer through the command line.
            log: a list to append warnings and other messages to.
        N)�options�log�compile_pattern)�selfrr	�r�*/usr/lib64/python3.6/lib2to3/fixer_base.py�__init__/szBaseFix.__init__cCs,|jdk	r(t�}|j|jdd�\|_|_dS)z�Compiles self.PATTERN into self.pattern.

        Subclass may override if it doesn't want to use
        self.{pattern,PATTERN} in .match().
        NT)Z	with_tree)�PATTERNrr
�pattern�pattern_tree)r�PCrrr
r
;s
zBaseFix.compile_patterncCs
||_dS)zOSet the filename.

        The main refactoring tool should call this.
        N)�filename)rrrrr
�set_filenameFszBaseFix.set_filenamecCsd|i}|jj||�o|S)aReturns match for a given parse tree node.

        Should return a true or false object (not necessarily a bool).
        It may return a non-empty dict of matching sub-nodes as
        returned by a matching pattern.

        Subclass may override.
        �node)r�match)rr�resultsrrr
rMs	z
BaseFix.matchcCs
t��dS)a�Returns the transformation for a given parse tree node.

        Args:
          node: the root of the parse tree that matched the fixer.
          results: a dict mapping symbolic names to part of the match.

        Returns:
          None, or a node that is a modified copy of the
          argument node.  The node argument may also be modified in-place to
          effect the same change.

        Subclass *must* override.
        N)�NotImplementedError)rrrrrr
�	transformYszBaseFix.transform�xxx_todo_changemecCs6|}x ||jkr$|tt|j��}qW|jj|�|S)z�Return a string suitable for use as an identifier

        The new name is guaranteed not to conflict with other identifiers.
        )�
used_names�str�next�numbers�add)r�template�namerrr
�new_nameis
zBaseFix.new_namecCs.|jrd|_|jjd|j�|jj|�dS)NFz### In file %s ###)�	first_logr	�appendr)r�messagerrr
�log_messagetszBaseFix.log_messagecCs>|j�}|j�}d|_d}|j|||f�|r:|j|�dS)aWarn the user that a given chunk of code is not valid Python 3,
        but that it cannot be converted automatically.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        �zLine %d: could not convert: %sN)�
get_linenoZclone�prefixr&)rr�reason�linenoZ
for_output�msgrrr
�cannot_convertzszBaseFix.cannot_convertcCs|j�}|jd||f�dS)z�Used for warning the user about possible uncertainty in the
        translation.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        zLine %d: %sN)r(r&)rrr*r+rrr
�warning�szBaseFix.warningcCs(|j|_|j|�tjd�|_d|_dS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the start of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        rTN)rr�	itertools�countrr#)r�treerrrr
�
start_tree�s
zBaseFix.start_treecCsdS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the conclusion of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        Nr)rr1rrrr
�finish_tree�szBaseFix.finish_tree)r)N)"�__name__�
__module__�__qualname__�__doc__rrrrrr/r0r�setr�orderZexplicitZ	run_orderZ_accept_typeZkeep_line_orderZ
BM_compatiblerZpython_symbolsZsymsrr
rrrr"r&r-r.r2r3rrrr
rs4



rcs,eZdZdZdZ�fdd�Zdd�Z�ZS)�ConditionalFixz@ Base class for fixers which not execute if an import is found. Ncstt|�j|�d|_dS)N)�superr:r2�_should_skip)r�args)�	__class__rr
r2�szConditionalFix.start_treecCsJ|jdk	r|jS|jjd�}|d}dj|dd��}t|||�|_|jS)N�.r���r@)r<�skip_on�split�joinr)rrZpkgr!rrr
�should_skip�s
zConditionalFix.should_skip)r4r5r6r7rAr2rD�
__classcell__rr)r>r
r:�sr:)r7r/Zpatcomprr'rZ
fixer_utilr�objectrr:rrrr
�<module>sPK�&�\7`4��btm_utils.cpython-36.pycnu�[���3


 \�&�@s|dZddlmZddlmZmZddlmZmZeZ	eZ
ejZeZ
dZdZdZGdd�de�Zdd
d�Zdd
�Zdd�Zd	S)z0Utility functions used by the btm_matcher module�)�pytree)�grammar�token)�pattern_symbols�python_symbols��c@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�MinNodez�This class serves as an intermediate representation of the
    pattern tree during the conversion to sets of leaf-to-root
    subpatternsNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfr
r�r�)/usr/lib64/python3.6/lib2to3/btm_utils.py�__init__szMinNode.__init__cCst|j�dt|j�S)N� )�strr
r)rrrr�__repr__szMinNode.__repr__cCs�|}g}x�|r�|jtkr`|jj|�t|j�t|j�krTt|j�g}g|_|j}q
n|j}d}P|jtkr�|j	j|�t|j	�t|j�kr�t
|j	�}g|_	|j}q
n|j}d}P|jtjkr�|j
r�|j|j
�n|j|j�|j}q
W|S)z�Internal method. Returns a characteristic path of the
        pattern tree. This method must be run for all leaves until the
        linear subpatterns are merged into a singleN)r
�TYPE_ALTERNATIVESr�append�lenr�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s8



zMinNode.leaf_to_rootcCs&x |j�D]}|j�}|r
|Sq
WdS)a�Drives the leaf_to_root method. The reason that
        leaf_to_root must be run multiple times is because we need to
        reject 'group' matches; for example the alternative form
        (a | b c) creates a group [b c] that needs to be matched. Since
        matching multiple linear patterns overcomes the automaton's
        capabilities, leaf_to_root merges each group into a single
        choice based on 'characteristic'ity,

        i.e. (a|b c) -> (a|b) if b more characteristic than c

        Returns: The most 'characteristic'(as defined by
          get_characteristic_subpattern) path for the compiled pattern
          tree.
        N)�leavesr")r�lr!rrr�get_linear_subpatternKszMinNode.get_linear_subpatternccs.x|jD]}|j�EdHqW|js*|VdS)z-Generator that returns the leaves of the treeN)rr#)r�childrrrr#`szMinNode.leaves)NN)	�__name__�
__module__�__qualname__�__doc__rrr"r%r#rrrrr	s
	*r	Nc
Cs�d}|jtjkr|jd}|jtjkr�t|j�dkrFt|jd|�}nJttd�}x>|jD]4}|jj	|�drnqXt||�}|dk	rX|jj
|�qXW�n|jtjk�rt|j�dkr�ttd�}x(|jD]}t||�}|r�|jj
|�q�W|js�d}nt|jd|�}�n�|jtj
k�r�t|jdtj��rH|jdjdk�rHt|jd|�St|jdtj��rn|jdjdk�s�t|j�dk�r�t|jdd��r�|jdjdk�r�dSd	}d}d}d
}d}	d
}
xn|jD]d}|jtjk�r�d
}|}n*|jtjk�r�d	}|}	n|jtjk�r|}t|d��r�|jdk�r�d	}
�q�W|
�rb|jd}t|d��rl|jdk�rl|jd}n
|jd}|jtjk�r�|jd
k�r�ttd�}n4tt|j��r�ttt|j�d�}nttt|j�d�}n\|jtjk�r|jjd�}|tk�r�tt|d�}nttj|d�}n|jtjk�r$t||�}|�rZ|	jdjdk�rBd}n|	jdjdk�rVnt�|�r�|dk	�r�x8|jdd�D]&}t||�}|dk	�rz|jj
|��qzW|�r�||_|S)z�
    Internal function. Reduces a compiled pattern tree to an
    intermediate representation suitable for feeding the
    automaton. This also trims off any optional pattern elements(like
    [a], a*).
    N�r)r
r�(�[�valueTF�=r�any�')r
r�*�+���)r
�symsZMatcherrZAlternativesr�reduce_treer	r�indexrZAlternativerZUnit�
isinstancerZLeafr.�hasattrZDetailsZRepeaterrr�TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r rZnew_noder&Zreducedr
Zdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr6gs�











r6cs�t|t�s|St|�dkr"|dSg}g}dddddg�g}d�xl|D]d}tt|d	d
���rFtt|�fdd
���r~|j|�qFtt|�fdd
���r�|j|�qF|j|�qFW|r�|}n|r�|}n|r�|}t|td
�S)z�Picks the most characteristic from a list of linear patterns
    Current order used is:
    names > common_names > common_chars
    rr+�in�for�if�not�Nonez[]().,:cSst|�tkS)N)r
r)�xrrr�<lambda>�sz/get_characteristic_subpattern.<locals>.<lambda>cst|t�o|�kS)N)r8r)rF)�common_charsrrrGscst|t�o|�kS)N)r8r)rF)�common_namesrrrGs)�key)r8�listrr0�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rHrIrr�s2

rccs<x6|D].}t|ttf�r*t||�EdHq||�VqWdS)zPTests test_func on all items of sequence and items of included
    sub-iterablesN)r8rKrrL)ZsequenceZ	test_funcrFrrrrLs
rLr4������)N)r*�rZpgen2rrZpygramrrr5r<Zopmapr?rr:rr�objectr	r6rrLrrrr�<module>sW
%PK�&�\4�P�T!T!main.cpython-36.pycnu�[���3


 \�-�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZdd�ZGdd	�d	ej
�Zd
d�Zddd
�ZdS)z
Main program for 2to3.
�)�with_statement�print_functionN�)�refactorc	Cs(|j�}|j�}tj||||dddd�S)z%Return a unified diff of two strings.z
(original)z(refactored)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filename�r�$/usr/lib64/python3.6/lib2to3/main.py�
diff_textss
rcs>eZdZdZd�fdd�	Zdd�Z�fdd�Zd	d
�Z�ZS)�StdoutRefactoringToola2
    A refactoring tool that can avoid overwriting its input files.
    Prints output to stdout.

    Output files can optionally be written to a different directory and or
    have an extra file suffix appended to their name for use in situations
    where you do not want to replace the input files.
    rc		sR||_||_|r(|jtj�r(|tj7}||_||_||_tt	|�j
|||�dS)aF
        Args:
            fixers: A list of fixers to import.
            options: A dict with RefactoringTool configuration.
            explicit: A list of fixers to run even if they are explicit.
            nobackups: If true no backup '.bak' files will be created for those
                files that are being refactored.
            show_diffs: Should diffs of the refactoring be printed to stdout?
            input_base_dir: The base directory for all input files.  This class
                will strip this path prefix off of filenames before substituting
                it with output_dir.  Only meaningful if output_dir is supplied.
                All files processed by refactor() must start with this path.
            output_dir: If supplied, all converted files will be written into
                this directory tree instead of input_base_dir.
            append_suffix: If supplied, all files output by this tool will have
                this appended to their filename.  Useful for changing .py to
                .py3 for example by passing append_suffix='3'.
        N)�	nobackups�
show_diffs�endswith�os�sep�_input_base_dir�_output_dir�_append_suffix�superr�__init__)	�selfZfixers�options�explicitrr�input_base_dir�
output_dir�
append_suffix)�	__class__rr
r$s
zStdoutRefactoringTool.__init__cOs*|jj|||f�|jj|f|�|�dS)N)�errors�append�logger�error)r�msg�args�kwargsrrr
�	log_errorAszStdoutRefactoringTool.log_errorc
!s||}|jrH|j|j�r6tjj|j|t|j�d��}ntd||jf��|jrX||j7}||kr�tjj	|�}tjj
|�r�|r�tj|�|jd||�|j
�s4|d}tjj|�r�ytj|�Wn.tk
r�}z|jd|�WYdd}~XnXytj||�Wn2tk
�r2}z|jd||�WYdd}~XnXtt|�j}	|	||||�|j
�sbtj||�||k�rxtj||�dS)Nz5filename %s does not start with the input_base_dir %szWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)r�
startswithrr�path�join�len�
ValueErrorr�dirname�isdir�makedirs�log_messager�lexists�remove�OSError�renamerr�
write_file�shutilZcopymode)
rZnew_textrZold_text�encodingZ
orig_filenamerZbackup�err�write)r rr
r6Es@


 
z StdoutRefactoringTool.write_filecCs�|r|jd|�n�|jd|�|jr�t|||�}yX|jdk	rp|j�&x|D]}t|�qJWtjj�WdQRXnx|D]}t|�qvWWn"tk
r�t	d|f�dSXdS)NzNo changes to %sz
Refactored %sz+couldn't encode %s's diff for your terminal)
r1rrZoutput_lock�print�sys�stdout�flush�UnicodeEncodeError�warn)r�old�newrZequalZ
diff_lines�linerrr
�print_outputls"



z"StdoutRefactoringTool.print_output)rrr)	�__name__�
__module__�__qualname__�__doc__rr(r6rD�
__classcell__rr)r r
rs
'rcCstd|ftjd�dS)NzWARNING: %s)�file)r;r<�stderr)r%rrr
r@�sr@cstjdd�}|jddddd�|jdd	d
gdd�|jd
dddddd�|jddd
gdd�|jddddd�|jddddd�|jddddd�|jd dd!d�|jd"d#dd$d�|jd%d&dd'd(d�|jd)d*dd+d,d-d.�|jd/d0dd1d�|jd2dd+d,d3d.�d'}i}|j|�\}}|j�r@d4|d5<|j�s:td6�d4|_|j�r\|j�r\|j	d7�|j
�rx|j�rx|j	d8�|j�r�|j�r�td9�|j�r�|j�r�|j	d:�|j�r�t
d;�xtj��D]}t
|��q�W|�s�d<S|�st
d=tjd>�t
d?tjd>�d@SdA|k�r4d4}|j�r4t
dBtjd>�d@S|j�rDd4|dC<|j�rRtjntj}tjdD|dE�tjdF�}ttj���}	t�fdGdH�|jD��}
t�}|j�r�d'}x2|jD](}
|
dIk�r�d4}n|j�dJ|
��q�W|�r�|	j|�n|}n
|	j|�}|j|
�}t j!j"|�}|�rD|j#t j$��rDt j!j%|��rDt j!j&|�}|j�rh|j't j$�}|j(dK|j|�t)t*|�|t*|�|j|j||j|j
dL�}|j+�s|�r�|j,�nRy|j||j|j-|j.�Wn6tj/k
�r�|j.dk�s�t0�t
dMtjd>�dSX|j1�t2t3|j+��S)Nz�Main program.

    Args:
        fixer_pkg: the name of a package where the fixers are located.
        args: optional; a list of command line arguments. If omitted,
              sys.argv[1:] is used.

    Returns a suggested exit status (0, 1, 2).
    z2to3 [options] file|dir ...)Zusagez-dz--doctests_only�
store_truezFix up doctests only)�action�helpz-fz--fixr"z1Each FIX specifies a transformation; default: all)rM�defaultrNz-jz--processesZstorer�intzRun 2to3 concurrently)rMrO�typerNz-xz--nofixz'Prevent a transformation from being runz-lz--list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-vz	--verbosezMore verbose loggingz
--no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz--nobackupsFz&Don't write backups for modified filesz-oz--output-dir�strrzXPut output files in this directory instead of overwriting the input files.  Requires -n.)rMrQrOrNz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z--add-suffixzuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.T�write_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.)rJzUse --help to show usage.��-zCan't write to stdin.rz%(name)s: %(message)s)�format�levelzlib2to3.mainc3s|]}�d|VqdS)z.fix_Nr)�.0�fix)�	fixer_pkgrr
�	<genexpr>�szmain.<locals>.<genexpr>�allz.fix_z7Output in %r will mirror the input directory %r layout.)rrrz+Sorry, -j isn't supported on this platform.)4�optparseZOptionParserZ
add_option�
parse_argsrSr:r@rrr$Z
add_suffixZno_diffsZ
list_fixesr;rZget_all_fix_namesr<rKr�verbose�logging�DEBUG�INFOZbasicConfigZ	getLogger�setZget_fixers_from_packageZnofixrY�add�union�
differencerr*�commonprefixrrr/r.�rstrip�infor�sortedr!�refactor_stdinZ
doctests_onlyZ	processesZMultiprocessingUnsupported�AssertionErrorZ	summarizerP�bool)rZr&�parserrk�flagsrZfixnamerWr#Zavail_fixesZunwanted_fixesrZall_presentrYZ	requestedZfixer_namesrZrtr)rZr
�main�s�




















rp)N)rHZ
__future__rrr<rrr`r7r]rrrZMultiprocessRefactoringToolrr@rprrrr
�<module>s	gPK�&�\Q��_�_pytree.cpython-36.opt-1.pycnu�[���3


 \�m�@s�dZdZddlZddlZddlmZdZiadd�ZGdd	�d	e	�Z
Gd
d�de
�ZGdd
�d
e
�Zdd�Z
Gdd�de	�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�ZdS)z�
Python parse tree definitions.

This is a very concrete parse tree; we need to keep every token and
even the comments and whitespace between tokens.

There's also a pattern matching implementation here.
z#Guido van Rossum <guido@python.org>�N)�StringIOi���cCsHts<ddlm}x*|jj�D]\}}t|�tkr|t|<qWtj||�S)N�)�python_symbols)�_type_reprsZpygramr�__dict__�items�type�int�
setdefault)Ztype_numr�name�val�r
�&/usr/lib64/python3.6/lib2to3/pytree.py�	type_reprsrc@s�eZdZdZdZdZfZdZdZdd�Z	dd�Z
dZdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zd d!�Zejd&kr�d$d%�ZdS)'�Basez�
    Abstract base class for Node and Leaf.

    This provides some default functionality and boilerplate using the
    template pattern.

    A node may be a subnode of at most one parent.
    NFcOs
tj|�S)z7Constructor that prevents Base from being instantiated.)�object�__new__)�cls�args�kwdsr
r
rr2szBase.__new__cCs|j|jk	rtS|j|�S)zW
        Compare two nodes for equality.

        This calls the method _eq().
        )�	__class__�NotImplemented�_eq)�self�otherr
r
r�__eq__7szBase.__eq__cCst�dS)a_
        Compare two nodes for equality.

        This is called by __eq__ and __ne__.  It is only called if the two nodes
        have the same type.  This must be implemented by the concrete subclass.
        Nodes should be considered equal if they have the same structure,
        ignoring the prefix string and other context information.
        N)�NotImplementedError)rrr
r
rrCs	zBase._eqcCst�dS)zr
        Return a cloned (deep) copy of self.

        This must be implemented by the concrete subclass.
        N)r)rr
r
r�cloneNsz
Base.clonecCst�dS)zx
        Return a post-order iterator for the tree.

        This must be implemented by the concrete subclass.
        N)r)rr
r
r�
post_orderVszBase.post_ordercCst�dS)zw
        Return a pre-order iterator for the tree.

        This must be implemented by the concrete subclass.
        N)r)rr
r
r�	pre_order^szBase.pre_ordercCs�t|t�s|g}g}d}x:|jjD].}||krF|dk	r@|j|�d}q"|j|�q"W|jj�||j_x|D]}|j|_qlWd|_dS)z/Replace this node with a new one in the parent.FNT)�
isinstance�list�parent�children�extend�append�changed)r�newZ
l_children�found�ch�xr
r
r�replacefs



zBase.replacecCs.|}x"t|t�s&|jsdS|jd}qW|jS)z9Return the line number which generated the invocant node.Nr)r �Leafr#�lineno)r�noder
r
r�
get_lineno}szBase.get_linenocCs|jr|jj�d|_dS)NT)r"r&�was_changed)rr
r
rr&�s
zBase.changedcCsJ|jrFx>t|jj�D].\}}||kr|jj�|jj|=d|_|SqWdS)z�
        Remove the node from the tree. Returns the position of the node in its
        parent's children before it was removed.
        N)r"�	enumerater#r&)r�ir.r
r
r�remove�s

zBase.removecCsZ|jdkrdSxFt|jj�D]6\}}||kry|jj|dStk
rPdSXqWdS)z�
        The node immediately following the invocant in their parent's children
        list. If the invocant does not have a next sibling, it is None
        Nr)r"r1r#�
IndexError)rr2�childr
r
r�next_sibling�s
zBase.next_siblingcCsP|jdkrdSx<t|jj�D],\}}||kr|dkr8dS|jj|dSqWdS)z�
        The node immediately preceding the invocant in their parent's children
        list. If the invocant does not have a previous sibling, it is None.
        Nrr)r"r1r#)rr2r5r
r
r�prev_sibling�s
zBase.prev_siblingccs"x|jD]}|j�EdHqWdS)N)r#�leaves)rr5r
r
rr8�szBase.leavescCs|jdkrdSd|jj�S)Nrr)r"�depth)rr
r
rr9�s
z
Base.depthcCs|j}|dkrdS|jS)z�
        Return the string immediately following the invocant node. This is
        effectively equivalent to node.next_sibling.prefix
        N�)r6�prefix)rZnext_sibr
r
r�
get_suffix�szBase.get_suffix�rcCst|�jd�S)N�ascii)�str�encode)rr
r
r�__str__�szBase.__str__)r=r)�__name__�
__module__�__qualname__�__doc__rr"r#r0Zwas_checkedrr�__hash__rrrrr+r/r&r3�propertyr6r7r8r9r<�sys�version_inforAr
r
r
rr s0	
	


rc@s�eZdZdZddd�Zdd�Zdd�Zejdkr4eZ	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zeee�Zdd�Zdd�Zdd�ZdS)�Nodez+Concrete implementation for interior nodes.NcCsR||_t|�|_x|jD]
}||_qW|dk	r4||_|rH|dd�|_nd|_dS)z�
        Initializer.

        Takes a type constant (a symbol number >= 256), a sequence of
        child nodes, and an optional context keyword argument.

        As a side effect, the parent pointers of the children are updated.
        N)rr!r#r"r;�fixers_applied)rrr#�contextr;rKr)r
r
r�__init__�s


z
Node.__init__cCsd|jjt|j�|jfS)z)Return a canonical string representation.z
%s(%s, %r))rrBrrr#)rr
r
r�__repr__�sz
Node.__repr__cCsdjtt|j��S)zk
        Return a pretty string representation.

        This reproduces the input source exactly.
        r:)�join�mapr?r#)rr
r
r�__unicode__�szNode.__unicode__r=rcCs|j|jf|j|jfkS)zCompare two nodes for equality.)rr#)rrr
r
rr�szNode._eqcCst|jdd�|jD�|jd�S)z$Return a cloned (deep) copy of self.cSsg|]}|j��qSr
)r)�.0r)r
r
r�
<listcomp>szNode.clone.<locals>.<listcomp>)rK)rJrr#rK)rr
r
rrsz
Node.cloneccs(x|jD]}|j�EdHqW|VdS)z*Return a post-order iterator for the tree.N)r#r)rr5r
r
rrszNode.post_orderccs(|Vx|jD]}|j�EdHqWdS)z)Return a pre-order iterator for the tree.N)r#r)rr5r
r
rr
szNode.pre_ordercCs|js
dS|jdjS)zO
        The whitespace and comments preceding this node in the input.
        r:r)r#r;)rr
r
r�_prefix_getterszNode._prefix_gettercCs|jr||jd_dS)Nr)r#r;)rr;r
r
r�_prefix_setterszNode._prefix_settercCs(||_d|j|_||j|<|j�dS)z�
        Equivalent to 'node.children[i] = child'. This method also sets the
        child's parent attribute appropriately.
        N)r"r#r&)rr2r5r
r
r�	set_child!s
zNode.set_childcCs ||_|jj||�|j�dS)z�
        Equivalent to 'node.children.insert(i, child)'. This method also sets
        the child's parent attribute appropriately.
        N)r"r#�insertr&)rr2r5r
r
r�insert_child+szNode.insert_childcCs||_|jj|�|j�dS)z�
        Equivalent to 'node.children.append(child)'. This method also sets the
        child's parent attribute appropriately.
        N)r"r#r%r&)rr5r
r
r�append_child4szNode.append_child)NNN)r=r)rBrCrDrErMrNrQrHrIrArrrrrTrUrGr;rVrXrYr
r
r
rrJ�s$



	rJc@s�eZdZdZdZdZdZddgfdd�Zdd�Zd	d
�Z	e
jdkrFe	Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zeee�ZdS)r,z'Concrete implementation for leaf nodes.r:rNcCsF|dk	r|\|_\|_|_||_||_|dk	r4||_|dd�|_dS)z�
        Initializer.

        Takes a type constant (a token number < 256), a string value, and an
        optional context keyword argument.
        N)�_prefixr-�columnr�valuerK)rrr\rLr;rKr
r
rrMGsz
Leaf.__init__cCsd|jj|j|jfS)z)Return a canonical string representation.z
%s(%r, %r))rrBrr\)rr
r
rrNZsz
Leaf.__repr__cCs|jt|j�S)zk
        Return a pretty string representation.

        This reproduces the input source exactly.
        )r;r?r\)rr
r
rrQ`szLeaf.__unicode__r=cCs|j|jf|j|jfkS)zCompare two nodes for equality.)rr\)rrr
r
rrkszLeaf._eqcCs$t|j|j|j|j|jff|jd�S)z$Return a cloned (deep) copy of self.)rK)r,rr\r;r-r[rK)rr
r
rros
z
Leaf.cloneccs
|VdS)Nr
)rr
r
rr8uszLeaf.leavesccs
|VdS)z*Return a post-order iterator for the tree.Nr
)rr
r
rrxszLeaf.post_orderccs
|VdS)z)Return a pre-order iterator for the tree.Nr
)rr
r
rr|szLeaf.pre_ordercCs|jS)zP
        The whitespace and comments preceding this token in the input.
        )rZ)rr
r
rrT�szLeaf._prefix_gettercCs|j�||_dS)N)r&rZ)rr;r
r
rrU�szLeaf._prefix_setter)r=r)rBrCrDrErZr-r[rMrNrQrHrIrArrr8rrrTrUrGr;r
r
r
rr,>s&
r,cCsN|\}}}}|s||jkr<t|�dkr.|dSt|||d�St|||d�SdS)z�
    Convert raw node information to a Node or Leaf instance.

    This is passed to the parser driver which calls it whenever a reduction of a
    grammar rule produces a new complete node, so that the tree is build
    strictly bottom-up.
    rr)rLN)Z
number2symbol�lenrJr,)ZgrZraw_noderr\rLr#r
r
r�convert�sr^c@sPeZdZdZdZdZdZdd�Zdd�Zdd�Z	dd	d
�Z
ddd�Zd
d�ZdS)�BasePatterna�
    A pattern is a tree matching pattern.

    It looks for a specific node type (token or symbol), and
    optionally for a specific content.

    This is an abstract base class.  There are three concrete
    subclasses:

    - LeafPattern matches a single leaf node;
    - NodePattern matches a single node (usually non-leaf);
    - WildcardPattern matches a sequence of nodes of variable length.
    NcOs
tj|�S)z>Constructor that prevents BasePattern from being instantiated.)rr)rrrr
r
rr�szBasePattern.__new__cCsLt|j�|j|jg}x|r.|ddkr.|d=qWd|jjdjtt|��fS)Nrz%s(%s)z, ���r`)	rr�contentrrrBrOrP�repr)rrr
r
rrN�s
zBasePattern.__repr__cCs|S)z�
        A subclass can define this as a hook for optimizations.

        Returns either self or another node with the same effect.
        r
)rr
r
r�optimize�szBasePattern.optimizecCsn|jdk	r|j|jkrdS|jdk	rRd}|dk	r4i}|j||�sDdS|rR|j|�|dk	rj|jrj|||j<dS)a#
        Does this pattern exactly match a node?

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        Default implementation for non-wildcard patterns.
        NFT)rra�	_submatch�updater)rr.�results�rr
r
r�match�s


zBasePattern.matchcCs t|�dkrdS|j|d|�S)z�
        Does this pattern exactly match a sequence of nodes?

        Default implementation for non-wildcard patterns.
        rFr)r]rh)r�nodesrfr
r
r�	match_seq�szBasePattern.match_seqccs&i}|r"|j|d|�r"d|fVdS)z}
        Generator yielding all matches for this pattern.

        Default implementation for non-wildcard patterns.
        rrN)rh)rrirgr
r
r�generate_matches�szBasePattern.generate_matches)N)N)
rBrCrDrErrarrrNrcrhrjrkr
r
r
rr_�s


r_c@s*eZdZddd�Zd	dd�Zd
dd�ZdS)�LeafPatternNcCs&|dk	r|dk	r||_||_||_dS)ap
        Initializer.  Takes optional type, content, and name.

        The type, if given must be a token type (< 256).  If not given,
        this matches any *leaf* node; the content may still be required.

        The content, if given, must be a string.

        If a name is given, the matching node is stored in the results
        dict under that key.
        N)rrar)rrrarr
r
rrM�s
zLeafPattern.__init__cCst|t�sdStj|||�S)z*Override match() to insist on a leaf node.F)r r,r_rh)rr.rfr
r
rrhs
zLeafPattern.matchcCs|j|jkS)a�
        Match the pattern's content to the node's children.

        This assumes the node type matches and self.content is not None.

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        When returning False, the results dict may still be updated.
        )rar\)rr.rfr
r
rrds
zLeafPattern._submatch)NNN)N)N)rBrCrDrMrhrdr
r
r
rrl�s

rlc@s$eZdZdZddd�Zddd�ZdS)	�NodePatternFNcCsT|dk	r|dk	r>t|�}x$t|�D]\}}t|t�r"d|_q"W||_||_||_dS)ad
        Initializer.  Takes optional type, content, and name.

        The type, if given, must be a symbol type (>= 256).  If the
        type is None this matches *any* single node (leaf or not),
        except if content is not None, in which it only matches
        non-leaf nodes that also match the content pattern.

        The content, if not None, must be a sequence of Patterns that
        must match the node's children exactly.  If the content is
        given, the type must not be None.

        If a name is given, the matching node is stored in the results
        dict under that key.
        NT)r!r1r �WildcardPattern�	wildcardsrrar)rrrarr2�itemr
r
rrM%s

zNodePattern.__init__cCs�|jrJx>t|j|j�D],\}}|t|j�kr|dk	r>|j|�dSqWdSt|j�t|j�krbdSx*t|j|j�D]\}}|j||�srdSqrWdS)a�
        Match the pattern's content to the node's children.

        This assumes the node type matches and self.content is not None.

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        When returning False, the results dict may still be updated.
        NTF)rorkrar#r]re�ziprh)rr.rf�crg�
subpatternr5r
r
rrdBs

zNodePattern._submatch)NNN)N)rBrCrDrorMrdr
r
r
rrm!s
rmc@s^eZdZdZddedfdd�Zdd�Zddd	�Zdd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)rna
    A wildcard pattern can match zero or more nodes.

    This has all the flexibility needed to implement patterns like:

    .*      .+      .?      .{m,n}
    (a b c | d e | f)
    (...)*  (...)+  (...)?  (...){m,n}

    except it always uses non-greedy matching.
    NrcCs@|dk	r$ttt|��}x|D]}qW||_||_||_||_dS)a�
        Initializer.

        Args:
            content: optional sequence of subsequences of patterns;
                     if absent, matches one node;
                     if present, each subsequence is an alternative [*]
            min: optional minimum number of times to match, default 0
            max: optional maximum number of times to match, default HUGE
            name: optional name assigned to this match

        [*] Thus, if content is [[a, b, c], [d, e], [f, g, h]] this is
            equivalent to (a b c | d e | f g h); if content is None,
            this is equivalent to '.' in regular expression terms.
            The min and max parameters work as follows:
                min=0, max=maxint: .*
                min=1, max=maxint: .+
                min=0, max=1: .?
                min=1, max=1: .
            If content is not None, replace the dot with the parenthesized
            list of alternatives, e.g. (a b c | d e | f g h)*
        N)�tuplerPra�min�maxr)rrarurvr�altr
r
rrMls
zWildcardPattern.__init__cCs�d}|jdk	r<t|j�dkr<t|jd�dkr<|jdd}|jdkr�|jdkr�|jdkrft|jd�S|dk	r�|j|jkr�|j�S|jdkr�t|t�r�|jdkr�|j|jkr�t|j|j|j|j|j|j�S|S)z+Optimize certain stacked wildcard patterns.Nrr)r)	rar]rurvrmrrcr rn)rrsr
r
rrc�s 
 


zWildcardPattern.optimizecCs|j|g|�S)z'Does this pattern exactly match a node?)rj)rr.rfr
r
rrh�szWildcardPattern.matchcCsRxL|j|�D]>\}}|t|�kr|dk	rF|j|�|jrFt|�||j<dSqWdS)z4Does this pattern exactly match a sequence of nodes?NTF)rkr]rerr!)rrirfrrrgr
r
rrj�s
zWildcardPattern.match_seqccs:|jdkrXxJt|jdtt|�|j��D]*}i}|jrH|d|�||j<||fVq(Wn�|jdkrp|j|�Vn�ttd�r�tj	}t
�t_	z�y@x:|j|d�D]*\}}|jr�|d|�||j<||fVq�WWnRtk
�rx:|j
|�D],\}}|j�r
|d|�||j<||fVq�WYnXWdttd��r4|t_	XdS)a"
        Generator yielding matches for a sequence of nodes.

        Args:
            nodes: sequence of nodes

        Yields:
            (count, results) tuples where:
            count: the match comprises nodes[:count];
            results: dict containing named submatches.
        NrZ	bare_name�getrefcountr)ra�rangerur]rvr�_bare_name_matches�hasattrrH�stderrr�_recursive_matches�RuntimeError�_iterative_matches)rri�countrgZsave_stderrr
r
rrk�s.
"

z WildcardPattern.generate_matchesccst|�}d|jkrdifVg}x>|jD]4}x.t||�D] \}}||fV|j||f�q8Wq(Wx�|�rg}x�|D]�\}}	||krr||jkrrxn|jD]d}x^t|||d��D]H\}
}|
dkr�i}|j|	�|j|�||
|fV|j||
|f�q�Wq�WqrW|}qbWdS)z(Helper to iteratively yield the matches.rN)r]rurarkr%rvre)rriZnodelenrfrwrrrgZnew_results�c0�r0�c1�r1r
r
rr�s*




z"WildcardPattern._iterative_matchescCsxd}i}d}t|�}xH|r\||kr\d}x0|jD]&}|dj|||�r0|d7}d}Pq0WqW|d|�||j<||fS)z(Special optimized matcher for bare_name.rFTrN)r]rarhr)rrir�rg�donervZleafr
r
rrz�s
z"WildcardPattern._bare_name_matchesc	cs�||jkrdifV||jkr�xr|jD]h}xbt||�D]T\}}xJ|j||d�|d�D].\}}i}|j|�|j|�|||fVqXWq6Wq&WdS)z(Helper to recursively yield the matches.rNr)rurvrarkr}re)	rrir�rwr�r�r�r�rgr
r
rr}s


"

z"WildcardPattern._recursive_matches)N)N)
rBrCrDrE�HUGErMrcrhrjrkrrzr}r
r
r
rrn^s#

-rnc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�NegatedPatternNcCs|dk	r||_dS)a
        Initializer.

        The argument is either a pattern or None.  If it is None, this
        only matches an empty sequence (effectively '$' in regex
        lingo).  If it is not None, this matches whenever the argument
        pattern doesn't have any matches.
        N)ra)rrar
r
rrMs	zNegatedPattern.__init__cCsdS)NFr
)rr.r
r
rrh)szNegatedPattern.matchcCst|�dkS)Nr)r])rrir
r
rrj-szNegatedPattern.match_seqccsL|jdkr"t|�dkrHdifVn&x|jj|�D]
\}}dSWdifVdS)Nr)rar]rk)rrirrrgr
r
rrk1s
zNegatedPattern.generate_matches)N)rBrCrDrMrhrjrkr
r
r
rr�s

r�c	cs�|sdifVn�|d|dd�}}xl|j|�D]^\}}|sJ||fVq2xDt|||d��D].\}}i}|j|�|j|�|||fVq^Wq2WdS)aR
    Generator yielding matches for a sequence of patterns and nodes.

    Args:
        patterns: a sequence of patterns
        nodes: a sequence of nodes

    Yields:
        (count, results) tuples where:
        count: the entire sequence of patterns matches nodes[:count];
        results: dict containing named submatches.
        rrN)rkre)	Zpatternsri�p�restr�r�r�r�rgr
r
rrk=s


rk)rE�
__author__rH�warnings�iorr�rrrrrJr,r^r_rlrmrnr�rkr
r
r
r�<module>s&
1nNV,==#PK�&�\7`4��btm_utils.cpython-36.opt-1.pycnu�[���3


 \�&�@s|dZddlmZddlmZmZddlmZmZeZ	eZ
ejZeZ
dZdZdZGdd�de�Zdd
d�Zdd
�Zdd�Zd	S)z0Utility functions used by the btm_matcher module�)�pytree)�grammar�token)�pattern_symbols�python_symbols��c@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�MinNodez�This class serves as an intermediate representation of the
    pattern tree during the conversion to sets of leaf-to-root
    subpatternsNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfr
r�r�)/usr/lib64/python3.6/lib2to3/btm_utils.py�__init__szMinNode.__init__cCst|j�dt|j�S)N� )�strr
r)rrrr�__repr__szMinNode.__repr__cCs�|}g}x�|r�|jtkr`|jj|�t|j�t|j�krTt|j�g}g|_|j}q
n|j}d}P|jtkr�|j	j|�t|j	�t|j�kr�t
|j	�}g|_	|j}q
n|j}d}P|jtjkr�|j
r�|j|j
�n|j|j�|j}q
W|S)z�Internal method. Returns a characteristic path of the
        pattern tree. This method must be run for all leaves until the
        linear subpatterns are merged into a singleN)r
�TYPE_ALTERNATIVESr�append�lenr�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s8



zMinNode.leaf_to_rootcCs&x |j�D]}|j�}|r
|Sq
WdS)a�Drives the leaf_to_root method. The reason that
        leaf_to_root must be run multiple times is because we need to
        reject 'group' matches; for example the alternative form
        (a | b c) creates a group [b c] that needs to be matched. Since
        matching multiple linear patterns overcomes the automaton's
        capabilities, leaf_to_root merges each group into a single
        choice based on 'characteristic'ity,

        i.e. (a|b c) -> (a|b) if b more characteristic than c

        Returns: The most 'characteristic'(as defined by
          get_characteristic_subpattern) path for the compiled pattern
          tree.
        N)�leavesr")r�lr!rrr�get_linear_subpatternKszMinNode.get_linear_subpatternccs.x|jD]}|j�EdHqW|js*|VdS)z-Generator that returns the leaves of the treeN)rr#)r�childrrrr#`szMinNode.leaves)NN)	�__name__�
__module__�__qualname__�__doc__rrr"r%r#rrrrr	s
	*r	Nc
Cs�d}|jtjkr|jd}|jtjkr�t|j�dkrFt|jd|�}nJttd�}x>|jD]4}|jj	|�drnqXt||�}|dk	rX|jj
|�qXW�n|jtjk�rt|j�dkr�ttd�}x(|jD]}t||�}|r�|jj
|�q�W|js�d}nt|jd|�}�n�|jtj
k�r�t|jdtj��rH|jdjdk�rHt|jd|�St|jdtj��rn|jdjdk�s�t|j�dk�r�t|jdd��r�|jdjdk�r�dSd	}d}d}d
}d}	d
}
xn|jD]d}|jtjk�r�d
}|}n*|jtjk�r�d	}|}	n|jtjk�r|}t|d��r�|jdk�r�d	}
�q�W|
�rb|jd}t|d��rl|jdk�rl|jd}n
|jd}|jtjk�r�|jd
k�r�ttd�}n4tt|j��r�ttt|j�d�}nttt|j�d�}n\|jtjk�r|jjd�}|tk�r�tt|d�}nttj|d�}n|jtjk�r$t||�}|�rZ|	jdjdk�rBd}n|	jdjdk�rVnt�|�r�|dk	�r�x8|jdd�D]&}t||�}|dk	�rz|jj
|��qzW|�r�||_|S)z�
    Internal function. Reduces a compiled pattern tree to an
    intermediate representation suitable for feeding the
    automaton. This also trims off any optional pattern elements(like
    [a], a*).
    N�r)r
r�(�[�valueTF�=r�any�')r
r�*�+���)r
�symsZMatcherrZAlternativesr�reduce_treer	r�indexrZAlternativerZUnit�
isinstancerZLeafr.�hasattrZDetailsZRepeaterrr�TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r rZnew_noder&Zreducedr
Zdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr6gs�











r6cs�t|t�s|St|�dkr"|dSg}g}dddddg�g}d�xl|D]d}tt|d	d
���rFtt|�fdd
���r~|j|�qFtt|�fdd
���r�|j|�qF|j|�qFW|r�|}n|r�|}n|r�|}t|td
�S)z�Picks the most characteristic from a list of linear patterns
    Current order used is:
    names > common_names > common_chars
    rr+�in�for�if�not�Nonez[]().,:cSst|�tkS)N)r
r)�xrrr�<lambda>�sz/get_characteristic_subpattern.<locals>.<lambda>cst|t�o|�kS)N)r8r)rF)�common_charsrrrGscst|t�o|�kS)N)r8r)rF)�common_namesrrrGs)�key)r8�listrr0�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rHrIrr�s2

rccs<x6|D].}t|ttf�r*t||�EdHq||�VqWdS)zPTests test_func on all items of sequence and items of included
    sub-iterablesN)r8rKrrL)ZsequenceZ	test_funcrFrrrrLs
rLr4������)N)r*�rZpgen2rrZpygramrrr5r<Zopmapr?rr:rr�objectr	r6rrLrrrr�<module>sW
%PK�&�\))]QQfixer_base.cpython-36.pycnu�[���3


 \"�@sTdZddlZddlmZddlmZddlmZGdd�de�Z	Gd	d
�d
e	�Z
dS)z2Base class for fixers (optional, but recommended).�N�)�PatternCompiler)�pygram)�does_tree_importc@s�eZdZdZdZdZdZdZdZe	j
d�Ze�Z
dZdZdZdZdZdZejZdd�Zd	d
�Zdd�Zd
d�Zdd�Zddd�Zdd�Zddd�Zdd�Zdd�Z dd�Z!dS) �BaseFixaOptional base class for fixers.

    The subclass name must be FixFooBar where FooBar is the result of
    removing underscores and capitalizing the words of the fix name.
    For example, the class name for a fixer named 'has_key' should be
    FixHasKey.
    NrZpostF�cCs||_||_|j�dS)aInitializer.  Subclass may override.

        Args:
            options: a dict containing the options passed to RefactoringTool
            that could be used to customize the fixer through the command line.
            log: a list to append warnings and other messages to.
        N)�options�log�compile_pattern)�selfrr	�r�*/usr/lib64/python3.6/lib2to3/fixer_base.py�__init__/szBaseFix.__init__cCs,|jdk	r(t�}|j|jdd�\|_|_dS)z�Compiles self.PATTERN into self.pattern.

        Subclass may override if it doesn't want to use
        self.{pattern,PATTERN} in .match().
        NT)Z	with_tree)�PATTERNrr
�pattern�pattern_tree)r�PCrrr
r
;s
zBaseFix.compile_patterncCs
||_dS)zOSet the filename.

        The main refactoring tool should call this.
        N)�filename)rrrrr
�set_filenameFszBaseFix.set_filenamecCsd|i}|jj||�o|S)aReturns match for a given parse tree node.

        Should return a true or false object (not necessarily a bool).
        It may return a non-empty dict of matching sub-nodes as
        returned by a matching pattern.

        Subclass may override.
        �node)r�match)rr�resultsrrr
rMs	z
BaseFix.matchcCs
t��dS)a�Returns the transformation for a given parse tree node.

        Args:
          node: the root of the parse tree that matched the fixer.
          results: a dict mapping symbolic names to part of the match.

        Returns:
          None, or a node that is a modified copy of the
          argument node.  The node argument may also be modified in-place to
          effect the same change.

        Subclass *must* override.
        N)�NotImplementedError)rrrrrr
�	transformYszBaseFix.transform�xxx_todo_changemecCs6|}x ||jkr$|tt|j��}qW|jj|�|S)z�Return a string suitable for use as an identifier

        The new name is guaranteed not to conflict with other identifiers.
        )�
used_names�str�next�numbers�add)r�template�namerrr
�new_nameis
zBaseFix.new_namecCs.|jrd|_|jjd|j�|jj|�dS)NFz### In file %s ###)�	first_logr	�appendr)r�messagerrr
�log_messagetszBaseFix.log_messagecCs>|j�}|j�}d|_d}|j|||f�|r:|j|�dS)aWarn the user that a given chunk of code is not valid Python 3,
        but that it cannot be converted automatically.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        �zLine %d: could not convert: %sN)�
get_linenoZclone�prefixr&)rr�reason�linenoZ
for_output�msgrrr
�cannot_convertzszBaseFix.cannot_convertcCs|j�}|jd||f�dS)z�Used for warning the user about possible uncertainty in the
        translation.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        zLine %d: %sN)r(r&)rrr*r+rrr
�warning�szBaseFix.warningcCs(|j|_|j|�tjd�|_d|_dS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the start of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        rTN)rr�	itertools�countrr#)r�treerrrr
�
start_tree�s
zBaseFix.start_treecCsdS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the conclusion of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        Nr)rr1rrrr
�finish_tree�szBaseFix.finish_tree)r)N)"�__name__�
__module__�__qualname__�__doc__rrrrrr/r0r�setr�orderZexplicitZ	run_orderZ_accept_typeZkeep_line_orderZ
BM_compatiblerZpython_symbolsZsymsrr
rrrr"r&r-r.r2r3rrrr
rs4



rcs,eZdZdZdZ�fdd�Zdd�Z�ZS)�ConditionalFixz@ Base class for fixers which not execute if an import is found. Ncstt|�j|�d|_dS)N)�superr:r2�_should_skip)r�args)�	__class__rr
r2�szConditionalFix.start_treecCsJ|jdk	r|jS|jjd�}|d}dj|dd��}t|||�|_|jS)N�.r���r@)r<�skip_on�split�joinr)rrZpkgr!rrr
�should_skip�s
zConditionalFix.should_skip)r4r5r6r7rAr2rD�
__classcell__rr)r>r
r:�sr:)r7r/Zpatcomprr'rZ
fixer_utilr�objectrr:rrrr
�<module>sPK�&�\f<�Q��pygram.cpython-36.pycnu�[���3


 \��@s�dZddlZddlmZddlmZddlmZejjejj	e
�d�Zejjejj	e
�d�ZGd	d
�d
e
�Zejde�Zee�Zej�Zejd=ejde�Zee�ZdS)
z&Export the Python grammar and symbols.�N�)�token)�driver)�pytreezGrammar.txtzPatternGrammar.txtc@seZdZdd�ZdS)�SymbolscCs(x"|jj�D]\}}t|||�qWdS)z�Initializer.

        Creates an attribute for each grammar symbol (nonterminal),
        whose value is the symbol's type (an int >= 256).
        N)Z
symbol2number�items�setattr)�selfZgrammar�nameZsymbol�r�&/usr/lib64/python3.6/lib2to3/pygram.py�__init__szSymbols.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrZlib2to3�print)�__doc__�osZpgen2rr�r�path�join�dirname�__file__Z
_GRAMMAR_FILEZ_PATTERN_GRAMMAR_FILE�objectrZload_packaged_grammarZpython_grammarZpython_symbols�copyZ!python_grammar_no_print_statement�keywordsZpattern_grammarZpattern_symbolsrrrr�<module>sPK�&�\\�!Y��patcomp.cpython-36.opt-1.pycnu�[���3


 \��@s�dZdZddlZddlmZmZmZmZmZm	Z	ddl
mZddl
mZGdd	�d	e
�Zd
d�ZGdd
�d
e�Zejejejdd�Zdd�Zdd�Zdd�ZdS)z�Pattern compiler.

The grammar is taken from PatternGrammar.txt.

The compiler compiles a pattern to a pytree.*Pattern instance.
z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�'/usr/lib64/python3.6/lib2to3/patcomp.pyrsrc	csPtjtjtjh}tjtj|�j�}x(|D] }|\}}}}}||kr(|Vq(WdS)z6Tokenizes a string suppressing significant whitespace.N)	r�NEWLINE�INDENT�DEDENTr�generate_tokens�io�StringIO�readline)	�input�skip�tokensZ	quintuple�type�value�start�endZ	line_textrrr�tokenize_wrappers
rc@s:eZdZd
dd�Zddd�Zdd�Zdd	d
�Zdd�ZdS)�PatternCompilerNcCsZ|dkrtj|_tj|_ntj|�|_tj|j�|_tj|_	tj
|_tj|jt
d�|_dS)z^Initializer.

        Takes an optional alternative filename for the pattern grammar.
        N)Zconvert)r
Zpattern_grammarrZpattern_symbols�symsrZload_grammarZSymbolsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__(s
zPatternCompiler.__init__FcCsnt|�}y|jj||d�}Wn0tjk
rL}ztt|���WYdd}~XnX|r`|j|�|fS|j|�SdS)z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)rrZparse_tokensrZ
ParseErrorr�str�compile_node)r$rr&Z	with_treer�root�errr�compile_pattern7szPatternCompiler.compile_patternc
sV|j�jjkr|jd}|j�jjkrz�fdd�|jddd�D�}t|�dkrX|dStjdd�|D�ddd�}|j�S|j�jj	krʇfd	d�|jD�}t|�dkr�|dStj|gddd�}|j�S|j�jj
kr��j|jdd��}tj|�}|j�Sd}|j}t|�d
k�r>|djt
jk�r>|dj}|dd�}d}t|�dk�rx|dj�jjk�rx|d
}|dd�}�j||�}|dk	�r>|j}	|	d}
|
jt
jk�r�d}tj}nX|
jt
jk�r�d}tj}n>|
jt
jk�r�j|	d�}}t|	�dk�r�j|	d
�}n|dk�s"|dk�r>|j�}tj|gg||d�}|dk	�rN||_|j�S)zXCompiles a node, recursively.

        This is one big switch on the node type.
        rcsg|]}�j|��qSr)r()�.0�ch)r$rr�
<listcomp>Osz0PatternCompiler.compile_node.<locals>.<listcomp>N�rcSsg|]
}|g�qSrr)r,�arrrr.Rs)�min�maxcsg|]}�j|��qSr)r()r,r-)r$rrr.Vs�����r5r5)rr!ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�get_int�name)
r$�nodeZalts�pZunits�patternr@�nodes�repeatr6Zchildr1r2r)r$rr(Cs^

 
"

zPatternCompiler.compile_nodecCs@|d}|jtjkr4ttj|j��}tjt	|�|�S|jtj
kr�|j}|j�r�|tkrbt
d|��|dd�rvt
d��tjt|�S|dkr�d}n,|jd�s�t|j|d�}|dkr�t
d|��|dd�r�|j|djd�g}nd}tj||�SnH|jdk�r|j|d�S|jd	k�r<|j|d�}tj|ggddd
�SdS)NrzInvalid token: %rrzCan't have details for token�any�_zInvalid symbol: %r�(�[)r1r2)rr�STRINGr'rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr"r(r6ZNodePatternr8)r$rDrErArrZcontent�
subpatternrrrr:�s8
zPatternCompiler.compile_basiccCs
t|j�S)N)�intr)r$rArrrr?�szPatternCompiler.get_int)N)FF)N)rr
rr%r+r(r:r?rrrrr &s


G
#r )rLrJ�NUMBERZTOKENcCs.|dj�rtjS|tjkr&tj|SdSdS)Nr)�isalpharrLrZopmap)rrrrrK�s


rKcCs>|\}}}}|s||jkr*tj|||d�Stj|||d�SdS)z9Converts raw node information to a Node or Leaf instance.)�contextN)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrrUr6rrrr#�sr#cCst�j|�S)N)r r+)rCrrrr+�sr+)�__doc__�
__author__rZpgen2rrrrrr�r	r
�	Exceptionrr�objectr rLrJrSrNrKr#r+rrrr�<module>	s  
		PK�&�\�Zr~��__main__.cpython-36.opt-1.pycnu�[���3


 \C�@s&ddlZddlmZejed��dS)�N�)�mainz
lib2to3.fixes)�sysr�exit�rr�(/usr/lib64/python3.6/lib2to3/__main__.py�<module>sPK�&�\�	�EFFbtm_matcher.cpython-36.pycnu�[���3


 \��@sldZdZddlZddlZddlmZddlmZddlm	Z	Gdd	�d	e
�ZGd
d�de
�Zia
dd
�ZdS)a�A bottom-up tree matching algorithm implementation meant to speed
up 2to3's matching process. After the tree patterns are reduced to
their rarest linear path, a linear Aho-Corasick automaton is
created. The linear automaton traverses the linear paths from the
leaves to the root of the AST and returns a set of nodes for further
matching. This reduces significantly the number of candidate nodes.z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@s eZdZdZej�Zdd�ZdS)�BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content)�self�r�+/usr/lib64/python3.6/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__�__doc__�	itertoolsrrrrrrrsrc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
BottomMatcherzgThe main matcher class. After instantiating the patterns should
    be added using the add_fixer methodcCs0t�|_t�|_|jg|_g|_tjd�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�loggingZ	getLoggerZlogger)rrrrrs

zBottomMatcher.__init__cCsL|jj|�t|j�}|j�}|j||jd�}x|D]}|jj|�q4WdS)z�Reduces a fixer's pattern tree to a linear path and adds it
        to the matcher(a common Aho-Corasick automaton). The fixer is
        appended on the matching states and called when they are
        reached)�startN)r	�appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr�	add_fixer%s

zBottomMatcher.add_fixercCs�|s
|gSt|dt�rhg}xF|dD]:}|j||d�}x&|D]}|j|j|dd�|��q>Wq&W|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)z5Recursively adds a linear pattern to the AC automatonr)rrN)�
isinstance�tupler�extendrr)r�patternrr �alternativeZ	end_nodes�endZ	next_noderrrr1s"
"zBottomMatcher.addc	Cs0|j}tt�}�x|D�]}|}�x|�r&d|_x,|jD]"}t|tj�r8|jdkr8d|_Pq8W|j	dkrp|j}n|j	}||j
kr�|j
|}x�|jD]"}||kr�g||<||j|�q�Wnd|j}|j
dk	r�|j
jr�P||j
k�r|j
|}x2|jD](}||j�k�rg||<||j|�q�W|j
}q$WqW|S)auThe main interface with the bottom matcher. The tree is
        traversed from the bottom using the constructed
        automaton. Nodes are only checked once as the tree is
        retraversed. When the automaton fails, we give it one more
        shot(in case the above tree matches as a whole with the
        rejected leaf), then we break for the next leaf. There is the
        special case of multiple arguments(see code comments) where we
        recheck the nodes

        Args:
           The leaves of the AST tree to be matched

        Returns:
           A dictionary of node matches with fixers as the keys
        T�;FrN)rr�listZwas_checkedZchildrenr"rZLeaf�value�typerr	r�parent�keys)	rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenrrrr�runSs>





zBottomMatcher.runcs*td��fdd���|j�td�dS)z<Prints a graphviz diagram of the BM automaton(for debugging)z
digraph g{cs^xX|jj�D]J}|j|}td|j|jt|�t|j�f�|dkrNt|j��|�qWdS)Nz%d -> %d [label=%s] //%sr)rr-�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode)�
print_noderrr2�s

z*BottomMatcher.print_ac.<locals>.print_node�}N)r/r)rr)r2r�print_ac�s
zBottomMatcher.print_acN)	rrrrrr!rr.r4rrrrrs"=rcCsHts<ddlm}x*|jj�D]\}}t|�tkr|t|<qWtj||�S)Nr)�python_symbols)�_type_reprsZpygramr5�__dict__�itemsr+�int�
setdefault)Ztype_numr5�name�valrrrr0�sr0)r�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr6r0rrrr�<module>s	PK�&�\����patcomp.cpython-36.opt-2.pycnu�[���3


 \��@s�dZddlZddlmZmZmZmZmZmZddl	m
Z
ddl	mZGdd�de�Z
d	d
�ZGdd�de�Zejejejdd
�Zdd�Zdd�Zdd�ZdS)z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�'/usr/lib64/python3.6/lib2to3/patcomp.pyrsrc	csPtjtjtjh}tjtj|�j�}x(|D] }|\}}}}}||kr(|Vq(WdS)N)	r�NEWLINE�INDENT�DEDENTr�generate_tokens�io�StringIO�readline)	�input�skip�tokensZ	quintuple�type�value�start�endZ	line_textrrr�tokenize_wrappers
rc@s:eZdZd
dd�Zddd�Zdd�Zdd	d
�Zdd�ZdS)�PatternCompilerNcCsZ|dkrtj|_tj|_ntj|�|_tj|j�|_tj|_	tj
|_tj|jt
d�|_dS)N)Zconvert)r
Zpattern_grammarrZpattern_symbols�symsrZload_grammarZSymbolsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__(s
zPatternCompiler.__init__FcCsnt|�}y|jj||d�}Wn0tjk
rL}ztt|���WYdd}~XnX|r`|j|�|fS|j|�SdS)N)�debug)rrZparse_tokensrZ
ParseErrorr�str�compile_node)r$rr&Z	with_treer�root�errr�compile_pattern7szPatternCompiler.compile_patternc
sV|j�jjkr|jd}|j�jjkrz�fdd�|jddd�D�}t|�dkrX|dStjdd�|D�ddd�}|j�S|j�jj	krʇfdd�|jD�}t|�dkr�|dStj|gddd�}|j�S|j�jj
kr��j|jdd��}tj|�}|j�Sd}|j}t|�d	k�r>|djt
jk�r>|dj}|dd�}d}t|�dk�rx|dj�jjk�rx|d}|dd
�}�j||�}|dk	�r>|j}	|	d}
|
jt
jk�r�d}tj}nX|
jt
jk�r�d}tj}n>|
jt
jk�r�j|	d�}}t|	�d
k�r�j|	d	�}n|dk�s"|dk�r>|j�}tj|gg||d�}|dk	�rN||_|j�S)Nrcsg|]}�j|��qSr)r()�.0�ch)r$rr�
<listcomp>Osz0PatternCompiler.compile_node.<locals>.<listcomp>�rcSsg|]
}|g�qSrr)r,�arrrr.Rs)�min�maxcsg|]}�j|��qSr)r()r,r-)r$rrr.Vs�����r5r5)rr!ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�get_int�name)
r$�nodeZalts�pZunits�patternr@�nodes�repeatr6Zchildr1r2r)r$rr(Cs^

 
"

zPatternCompiler.compile_nodecCs@|d}|jtjkr4ttj|j��}tjt	|�|�S|jtj
kr�|j}|j�r�|tkrbt
d|��|dd�rvt
d��tjt|�S|dkr�d}n,|jd�s�t|j|d�}|dkr�t
d|��|dd�r�|j|djd�g}nd}tj||�SnH|jdk�r|j|d�S|jd	k�r<|j|d�}tj|ggddd
�SdS)NrzInvalid token: %rrzCan't have details for token�any�_zInvalid symbol: %r�(�[)r1r2)rr�STRINGr'rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr"r(r6ZNodePatternr8)r$rDrErArrZcontent�
subpatternrrrr:�s8
zPatternCompiler.compile_basiccCs
t|j�S)N)�intr)r$rArrrr?�szPatternCompiler.get_int)N)FF)N)rr
rr%r+r(r:r?rrrrr &s


G
#r )rLrJ�NUMBERZTOKENcCs.|dj�rtjS|tjkr&tj|SdSdS)Nr)�isalpharrLrZopmap)rrrrrK�s


rKcCs>|\}}}}|s||jkr*tj|||d�Stj|||d�SdS)N)�context)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrrUr6rrrr#�sr#cCst�j|�S)N)r r+)rCrrrr+�sr+)�
__author__rZpgen2rrrrrr�r	r
�	Exceptionrr�objectr rLrJrSrNrKr#r+rrrr�<module>s 
		PK�&�\�sdr0b0bpytree.cpython-36.pycnu�[���3


 \�m�@s�dZdZddlZddlZddlmZdZiadd�ZGdd	�d	e	�Z
Gd
d�de
�ZGdd
�d
e
�Zdd�Z
Gdd�de	�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�ZdS)z�
Python parse tree definitions.

This is a very concrete parse tree; we need to keep every token and
even the comments and whitespace between tokens.

There's also a pattern matching implementation here.
z#Guido van Rossum <guido@python.org>�N)�StringIOi���cCsHts<ddlm}x*|jj�D]\}}t|�tkr|t|<qWtj||�S)N�)�python_symbols)�_type_reprsZpygramr�__dict__�items�type�int�
setdefault)Ztype_numr�name�val�r
�&/usr/lib64/python3.6/lib2to3/pytree.py�	type_reprsrc@s�eZdZdZdZdZfZdZdZdd�Z	dd�Z
dZdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zd d!�Zejd&kr�d$d%�ZdS)'�Basez�
    Abstract base class for Node and Leaf.

    This provides some default functionality and boilerplate using the
    template pattern.

    A node may be a subnode of at most one parent.
    NFcOs|tk	std��tj|�S)z7Constructor that prevents Base from being instantiated.zCannot instantiate Base)r�AssertionError�object�__new__)�cls�args�kwdsr
r
rr2szBase.__new__cCs|j|jk	rtS|j|�S)zW
        Compare two nodes for equality.

        This calls the method _eq().
        )�	__class__�NotImplemented�_eq)�self�otherr
r
r�__eq__7szBase.__eq__cCst�dS)a_
        Compare two nodes for equality.

        This is called by __eq__ and __ne__.  It is only called if the two nodes
        have the same type.  This must be implemented by the concrete subclass.
        Nodes should be considered equal if they have the same structure,
        ignoring the prefix string and other context information.
        N)�NotImplementedError)rrr
r
rrCs	zBase._eqcCst�dS)zr
        Return a cloned (deep) copy of self.

        This must be implemented by the concrete subclass.
        N)r)rr
r
r�cloneNsz
Base.clonecCst�dS)zx
        Return a post-order iterator for the tree.

        This must be implemented by the concrete subclass.
        N)r)rr
r
r�
post_orderVszBase.post_ordercCst�dS)zw
        Return a pre-order iterator for the tree.

        This must be implemented by the concrete subclass.
        N)r)rr
r
r�	pre_order^szBase.pre_ordercCs�|jdk	stt|���|dk	s"t�t|t�s2|g}g}d}xR|jjD]F}||kr�|sht|jj||f��|dk	rz|j|�d}qD|j|�qDW|s�t|j||f��|jj�||j_x|D]}|j|_q�Wd|_dS)z/Replace this node with a new one in the parent.NFT)	�parentr�str�
isinstance�list�children�extend�append�changed)r�newZ
l_children�found�ch�xr
r
r�replacefs&



zBase.replacecCs.|}x"t|t�s&|jsdS|jd}qW|jS)z9Return the line number which generated the invocant node.Nr)r#�Leafr%�lineno)r�noder
r
r�
get_lineno}szBase.get_linenocCs|jr|jj�d|_dS)NT)r!r(�was_changed)rr
r
rr(�s
zBase.changedcCsJ|jrFx>t|jj�D].\}}||kr|jj�|jj|=d|_|SqWdS)z�
        Remove the node from the tree. Returns the position of the node in its
        parent's children before it was removed.
        N)r!�	enumerater%r()r�ir0r
r
r�remove�s

zBase.removecCsZ|jdkrdSxFt|jj�D]6\}}||kry|jj|dStk
rPdSXqWdS)z�
        The node immediately following the invocant in their parent's children
        list. If the invocant does not have a next sibling, it is None
        Nr)r!r3r%�
IndexError)rr4�childr
r
r�next_sibling�s
zBase.next_siblingcCsP|jdkrdSx<t|jj�D],\}}||kr|dkr8dS|jj|dSqWdS)z�
        The node immediately preceding the invocant in their parent's children
        list. If the invocant does not have a previous sibling, it is None.
        Nrr)r!r3r%)rr4r7r
r
r�prev_sibling�s
zBase.prev_siblingccs"x|jD]}|j�EdHqWdS)N)r%�leaves)rr7r
r
rr:�szBase.leavescCs|jdkrdSd|jj�S)Nrr)r!�depth)rr
r
rr;�s
z
Base.depthcCs|j}|dkrdS|jS)z�
        Return the string immediately following the invocant node. This is
        effectively equivalent to node.next_sibling.prefix
        N�)r8�prefix)rZnext_sibr
r
r�
get_suffix�szBase.get_suffix�rcCst|�jd�S)N�ascii)r"�encode)rr
r
r�__str__�szBase.__str__)r?r)�__name__�
__module__�__qualname__�__doc__rr!r%r2Zwas_checkedrr�__hash__rrrr r-r1r(r5�propertyr8r9r:r;r>�sys�version_inforBr
r
r
rr s0	
	


rc@s�eZdZdZddd�Zdd�Zdd�Zejdkr4eZ	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zeee�Zdd�Zdd�Zdd�ZdS)�Nodez+Concrete implementation for interior nodes.NcCsx|dkst|��||_t|�|_x*|jD] }|jdksBtt|���||_q(W|dk	rZ||_|rn|dd�|_nd|_dS)z�
        Initializer.

        Takes a type constant (a symbol number >= 256), a sequence of
        child nodes, and an optional context keyword argument.

        As a side effect, the parent pointers of the children are updated.
        �N)rrr$r%r!�reprr=�fixers_applied)rrr%�contextr=rNr+r
r
r�__init__�s

z
Node.__init__cCsd|jjt|j�|jfS)z)Return a canonical string representation.z
%s(%s, %r))rrCrrr%)rr
r
r�__repr__�sz
Node.__repr__cCsdjtt|j��S)zk
        Return a pretty string representation.

        This reproduces the input source exactly.
        r<)�join�mapr"r%)rr
r
r�__unicode__�szNode.__unicode__r?rcCs|j|jf|j|jfkS)zCompare two nodes for equality.)rr%)rrr
r
rr�szNode._eqcCst|jdd�|jD�|jd�S)z$Return a cloned (deep) copy of self.cSsg|]}|j��qSr
)r)�.0r+r
r
r�
<listcomp>szNode.clone.<locals>.<listcomp>)rN)rKrr%rN)rr
r
rrsz
Node.cloneccs(x|jD]}|j�EdHqW|VdS)z*Return a post-order iterator for the tree.N)r%r)rr7r
r
rrszNode.post_orderccs(|Vx|jD]}|j�EdHqWdS)z)Return a pre-order iterator for the tree.N)r%r )rr7r
r
rr 
szNode.pre_ordercCs|js
dS|jdjS)zO
        The whitespace and comments preceding this node in the input.
        r<r)r%r=)rr
r
r�_prefix_getterszNode._prefix_gettercCs|jr||jd_dS)Nr)r%r=)rr=r
r
r�_prefix_setterszNode._prefix_settercCs(||_d|j|_||j|<|j�dS)z�
        Equivalent to 'node.children[i] = child'. This method also sets the
        child's parent attribute appropriately.
        N)r!r%r()rr4r7r
r
r�	set_child!s
zNode.set_childcCs ||_|jj||�|j�dS)z�
        Equivalent to 'node.children.insert(i, child)'. This method also sets
        the child's parent attribute appropriately.
        N)r!r%�insertr()rr4r7r
r
r�insert_child+szNode.insert_childcCs||_|jj|�|j�dS)z�
        Equivalent to 'node.children.append(child)'. This method also sets the
        child's parent attribute appropriately.
        N)r!r%r'r()rr7r
r
r�append_child4szNode.append_child)NNN)r?r)rCrDrErFrPrQrTrIrJrBrrrr rWrXrHr=rYr[r\r
r
r
rrK�s$



	rKc@s�eZdZdZdZdZdZddgfdd�Zdd�Zd	d
�Z	e
jdkrFe	Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zeee�ZdS)r.z'Concrete implementation for leaf nodes.r<rNcCsfd|kodkns t|��|dk	r:|\|_\|_|_||_||_|dk	rT||_|dd�|_dS)z�
        Initializer.

        Takes a type constant (a token number < 256), a string value, and an
        optional context keyword argument.
        rrLN)r�_prefixr/�columnr�valuerN)rrr_rOr=rNr
r
rrPGs
 z
Leaf.__init__cCsd|jj|j|jfS)z)Return a canonical string representation.z
%s(%r, %r))rrCrr_)rr
r
rrQZsz
Leaf.__repr__cCs|jt|j�S)zk
        Return a pretty string representation.

        This reproduces the input source exactly.
        )r=r"r_)rr
r
rrT`szLeaf.__unicode__r?cCs|j|jf|j|jfkS)zCompare two nodes for equality.)rr_)rrr
r
rrkszLeaf._eqcCs$t|j|j|j|j|jff|jd�S)z$Return a cloned (deep) copy of self.)rN)r.rr_r=r/r^rN)rr
r
rros
z
Leaf.cloneccs
|VdS)Nr
)rr
r
rr:uszLeaf.leavesccs
|VdS)z*Return a post-order iterator for the tree.Nr
)rr
r
rrxszLeaf.post_orderccs
|VdS)z)Return a pre-order iterator for the tree.Nr
)rr
r
rr |szLeaf.pre_ordercCs|jS)zP
        The whitespace and comments preceding this token in the input.
        )r])rr
r
rrW�szLeaf._prefix_gettercCs|j�||_dS)N)r(r])rr=r
r
rrX�szLeaf._prefix_setter)r?r)rCrDrErFr]r/r^rPrQrTrIrJrBrrr:rr rWrXrHr=r
r
r
rr.>s&
r.cCsN|\}}}}|s||jkr<t|�dkr.|dSt|||d�St|||d�SdS)z�
    Convert raw node information to a Node or Leaf instance.

    This is passed to the parser driver which calls it whenever a reduction of a
    grammar rule produces a new complete node, so that the tree is build
    strictly bottom-up.
    rr)rON)Z
number2symbol�lenrKr.)ZgrZraw_noderr_rOr%r
r
r�convert�srac@sPeZdZdZdZdZdZdd�Zdd�Zdd�Z	dd	d
�Z
ddd�Zd
d�ZdS)�BasePatterna�
    A pattern is a tree matching pattern.

    It looks for a specific node type (token or symbol), and
    optionally for a specific content.

    This is an abstract base class.  There are three concrete
    subclasses:

    - LeafPattern matches a single leaf node;
    - NodePattern matches a single node (usually non-leaf);
    - WildcardPattern matches a sequence of nodes of variable length.
    NcOs|tk	std��tj|�S)z>Constructor that prevents BasePattern from being instantiated.zCannot instantiate BasePattern)rbrrr)rrrr
r
rr�szBasePattern.__new__cCsLt|j�|j|jg}x|r.|ddkr.|d=qWd|jjdjtt|��fS)Nrz%s(%s)z, ���rc)	rr�contentrrrCrRrSrM)rrr
r
rrQ�s
zBasePattern.__repr__cCs|S)z�
        A subclass can define this as a hook for optimizations.

        Returns either self or another node with the same effect.
        r
)rr
r
r�optimize�szBasePattern.optimizecCsn|jdk	r|j|jkrdS|jdk	rRd}|dk	r4i}|j||�sDdS|rR|j|�|dk	rj|jrj|||j<dS)a#
        Does this pattern exactly match a node?

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        Default implementation for non-wildcard patterns.
        NFT)rrd�	_submatch�updater)rr0�results�rr
r
r�match�s


zBasePattern.matchcCs t|�dkrdS|j|d|�S)z�
        Does this pattern exactly match a sequence of nodes?

        Default implementation for non-wildcard patterns.
        rFr)r`rj)r�nodesrhr
r
r�	match_seq�szBasePattern.match_seqccs&i}|r"|j|d|�r"d|fVdS)z}
        Generator yielding all matches for this pattern.

        Default implementation for non-wildcard patterns.
        rrN)rj)rrkrir
r
r�generate_matches�szBasePattern.generate_matches)N)N)
rCrDrErFrrdrrrQrerjrlrmr
r
r
rrb�s


rbc@s*eZdZddd�Zd	dd�Zd
dd�ZdS)�LeafPatternNcCs\|dk	r(d|kodkns(t|��|dk	rFt|t�sFtt|���||_||_||_dS)ap
        Initializer.  Takes optional type, content, and name.

        The type, if given must be a token type (< 256).  If not given,
        this matches any *leaf* node; the content may still be required.

        The content, if given, must be a string.

        If a name is given, the matching node is stored in the results
        dict under that key.
        NrrL)rr#r"rMrrdr)rrrdrr
r
rrP�s zLeafPattern.__init__cCst|t�sdStj|||�S)z*Override match() to insist on a leaf node.F)r#r.rbrj)rr0rhr
r
rrjs
zLeafPattern.matchcCs|j|jkS)a�
        Match the pattern's content to the node's children.

        This assumes the node type matches and self.content is not None.

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        When returning False, the results dict may still be updated.
        )rdr_)rr0rhr
r
rrfs
zLeafPattern._submatch)NNN)N)N)rCrDrErPrjrfr
r
r
rrn�s

rnc@s$eZdZdZddd�Zddd�ZdS)	�NodePatternFNcCs�|dk	r|dkst|��|dk	r|t|t�s8tt|���t|�}x:t|�D].\}}t|t�sht||f��t|t�rJd|_qJW||_	||_
||_dS)ad
        Initializer.  Takes optional type, content, and name.

        The type, if given, must be a symbol type (>= 256).  If the
        type is None this matches *any* single node (leaf or not),
        except if content is not None, in which it only matches
        non-leaf nodes that also match the content pattern.

        The content, if not None, must be a sequence of Patterns that
        must match the node's children exactly.  If the content is
        given, the type must not be None.

        If a name is given, the matching node is stored in the results
        dict under that key.
        NrLT)rr#r"rMr$r3rb�WildcardPattern�	wildcardsrrdr)rrrdrr4�itemr
r
rrP%s

zNodePattern.__init__cCs�|jrJx>t|j|j�D],\}}|t|j�kr|dk	r>|j|�dSqWdSt|j�t|j�krbdSx*t|j|j�D]\}}|j||�srdSqrWdS)a�
        Match the pattern's content to the node's children.

        This assumes the node type matches and self.content is not None.

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        When returning False, the results dict may still be updated.
        NTF)rqrmrdr%r`rg�ziprj)rr0rh�cri�
subpatternr7r
r
rrfBs

zNodePattern._submatch)NNN)N)rCrDrErqrPrfr
r
r
rro!s
roc@s^eZdZdZddedfdd�Zdd�Zddd	�Zdd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)rpa
    A wildcard pattern can match zero or more nodes.

    This has all the flexibility needed to implement patterns like:

    .*      .+      .?      .{m,n}
    (a b c | d e | f)
    (...)*  (...)+  (...)?  (...){m,n}

    except it always uses non-greedy matching.
    NrcCs�d|ko|kotkns.t||f��|dk	rzttt|��}t|�sXtt|���x |D]}t|�s^tt|���q^W||_||_||_||_	dS)a�
        Initializer.

        Args:
            content: optional sequence of subsequences of patterns;
                     if absent, matches one node;
                     if present, each subsequence is an alternative [*]
            min: optional minimum number of times to match, default 0
            max: optional maximum number of times to match, default HUGE
            name: optional name assigned to this match

        [*] Thus, if content is [[a, b, c], [d, e], [f, g, h]] this is
            equivalent to (a b c | d e | f g h); if content is None,
            this is equivalent to '.' in regular expression terms.
            The min and max parameters work as follows:
                min=0, max=maxint: .*
                min=1, max=maxint: .+
                min=0, max=1: .?
                min=1, max=1: .
            If content is not None, replace the dot with the parenthesized
            list of alternatives, e.g. (a b c | d e | f g h)*
        rN)
�HUGEr�tuplerSr`rMrd�min�maxr)rrdrxryr�altr
r
rrPls.
zWildcardPattern.__init__cCs�d}|jdk	r<t|j�dkr<t|jd�dkr<|jdd}|jdkr�|jdkr�|jdkrft|jd�S|dk	r�|j|jkr�|j�S|jdkr�t|t�r�|jdkr�|j|jkr�t|j|j|j|j|j|j�S|S)z+Optimize certain stacked wildcard patterns.Nrr)r)	rdr`rxryrorrer#rp)rrur
r
rre�s 
 


zWildcardPattern.optimizecCs|j|g|�S)z'Does this pattern exactly match a node?)rl)rr0rhr
r
rrj�szWildcardPattern.matchcCsRxL|j|�D]>\}}|t|�kr|dk	rF|j|�|jrFt|�||j<dSqWdS)z4Does this pattern exactly match a sequence of nodes?NTF)rmr`rgrr$)rrkrhrtrir
r
rrl�s
zWildcardPattern.match_seqccs:|jdkrXxJt|jdtt|�|j��D]*}i}|jrH|d|�||j<||fVq(Wn�|jdkrp|j|�Vn�ttd�r�tj	}t
�t_	z�y@x:|j|d�D]*\}}|jr�|d|�||j<||fVq�WWnRtk
�rx:|j
|�D],\}}|j�r
|d|�||j<||fVq�WYnXWdttd��r4|t_	XdS)a"
        Generator yielding matches for a sequence of nodes.

        Args:
            nodes: sequence of nodes

        Yields:
            (count, results) tuples where:
            count: the match comprises nodes[:count];
            results: dict containing named submatches.
        NrZ	bare_name�getrefcountr)rd�rangerxr`ryr�_bare_name_matches�hasattrrI�stderrr�_recursive_matches�RuntimeError�_iterative_matches)rrk�countriZsave_stderrr
r
rrm�s.
"

z WildcardPattern.generate_matchesccst|�}d|jkrdifVg}x>|jD]4}x.t||�D] \}}||fV|j||f�q8Wq(Wx�|�rg}x�|D]�\}}	||krr||jkrrxn|jD]d}x^t|||d��D]H\}
}|
dkr�i}|j|	�|j|�||
|fV|j||
|f�q�Wq�WqrW|}qbWdS)z(Helper to iteratively yield the matches.rN)r`rxrdrmr'ryrg)rrkZnodelenrhrzrtriZnew_results�c0�r0�c1�r1r
r
rr��s*




z"WildcardPattern._iterative_matchescCsxd}i}d}t|�}xH|r\||kr\d}x0|jD]&}|dj|||�r0|d7}d}Pq0WqW|d|�||j<||fS)z(Special optimized matcher for bare_name.rFTrN)r`rdrjr)rrkr�ri�doneryZleafr
r
rr}�s
z"WildcardPattern._bare_name_matchesc	cs�|jdk	st�||jkr"difV||jkr�xr|jD]h}xbt||�D]T\}}xJ|j||d�|d�D].\}}i}|j|�|j|�|||fVqfWqDWq4WdS)z(Helper to recursively yield the matches.Nrr)rdrrxryrmr�rg)	rrkr�rzr�r�r�r�rir
r
rr�s


"

z"WildcardPattern._recursive_matches)N)N)
rCrDrErFrvrPrerjrlrmr�r}r�r
r
r
rrp^s#

-rpc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�NegatedPatternNcCs(|dk	rt|t�stt|���||_dS)a
        Initializer.

        The argument is either a pattern or None.  If it is None, this
        only matches an empty sequence (effectively '$' in regex
        lingo).  If it is not None, this matches whenever the argument
        pattern doesn't have any matches.
        N)r#rbrrMrd)rrdr
r
rrPs	zNegatedPattern.__init__cCsdS)NFr
)rr0r
r
rrj)szNegatedPattern.matchcCst|�dkS)Nr)r`)rrkr
r
rrl-szNegatedPattern.match_seqccsL|jdkr"t|�dkrHdifVn&x|jj|�D]
\}}dSWdifVdS)Nr)rdr`rm)rrkrtrir
r
rrm1s
zNegatedPattern.generate_matches)N)rCrDrErPrjrlrmr
r
r
rr�s

r�c	cs�|sdifVn�|d|dd�}}xl|j|�D]^\}}|sJ||fVq2xDt|||d��D].\}}i}|j|�|j|�|||fVq^Wq2WdS)aR
    Generator yielding matches for a sequence of patterns and nodes.

    Args:
        patterns: a sequence of patterns
        nodes: a sequence of nodes

    Yields:
        (count, results) tuples where:
        count: the entire sequence of patterns matches nodes[:count];
        results: dict containing named submatches.
        rrN)rmrg)	Zpatternsrk�p�restr�r�r�r�rir
r
rrm=s


rm)rF�
__author__rI�warnings�iorrvrrrrrKr.rarbrnrorpr�rmr
r
r
r�<module>s&
1nNV,==#PK�&�\H�4I7Q7Qrefactor.cpython-36.pycnu�[���3


 \=m�@s<dZdZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZdd	lmZd&dd�ZGd
d�de�Zdd�Zdd�Zdd�Zdd�Zejd'kr�ddlZejZdd�Z dd�Z!neZeZ eZ!dd�Z"Gdd�de�Z#Gd d!�d!e$�Z%Gd"d#�d#e�Z&Gd$d%�d%e%�Z'dS)(z�Refactoring framework.

Used as a main program, this can refactor any number of files and/or
recursively descend down directories.  Imported as a module, this
provides infrastructure to write your own refactoring tool.
z#Guido van Rossum <guido@python.org>�N)�chain�)�driver�tokenize�token)�	find_root)�pytree�pygram)�btm_matcherTcCstt|ggdg�}tjj|j�}g}xLttj|��D]:}|jd�r2|jd�r2|rZ|dd�}|j	|dd��q2W|S)zEReturn a sorted list of all available fix names in the given package.�*�fix_z.py�N����)
�
__import__�os�path�dirname�__file__�sorted�listdir�
startswith�endswith�append)Z	fixer_pkgZ
remove_prefixZpkgZ	fixer_dirZ	fix_names�name�r�(/usr/lib64/python3.6/lib2to3/refactor.py�get_all_fix_namessrc@seZdZdS)�
_EveryNodeN)�__name__�
__module__�__qualname__rrrrr+srcCs�t|tjtjf�r(|jdkr t�|jhSt|tj�rH|jrDt|j�St�t|tj	�r�t
�}x*|jD] }x|D]}|jt|��qlWqbW|Std|��dS)zf Accepts a pytree Pattern Node and returns a set
        of the pattern types which will match first. Nz$Oh no! I don't understand pattern %s)
�
isinstancerZNodePatternZLeafPattern�typerZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update�	Exception)Zpat�r�p�xrrrr$/s


r$cCs�tjt�}g}x�|D]|}|jrjyt|j�}Wntk
rJ|j|�Yq�XxB|D]}||j|�qRWq|jdk	r�||jj|�q|j|�qWx,tt	j
jj�t	j
j
�D]}||j|�q�Wt|�S)z^ Accepts a list of fixers and returns a dictionary
        of head node type --> fixer list.  N)�collections�defaultdict�list�patternr$rrZ_accept_typerr	�python_grammarZ
symbol2number�values�tokens�extend�dict)Z
fixer_listZ
head_nodesZevery�fixerZheadsZ	node_typerrr�_get_headnode_dictKs"



r5cs�fdd�t�d�D�S)zN
    Return the fully qualified names for fixers in the package pkg_name.
    csg|]}�d|�qS)�.r)�.0�fix_name)�pkg_namerr�
<listcomp>hsz+get_fixers_from_package.<locals>.<listcomp>F)r)r9r)r9r�get_fixers_from_packageds
r;cCs|S)Nr)�objrrr�	_identityksr=rcCs|jdd�S)Nz
�
)�replace)�inputrrr�_from_system_newlinesrsrAcCs tjdkr|jdtj�S|SdS)Nr>)r�linesepr?)r@rrr�_to_system_newlinests
rCcsTd}tjtj|�j���fdd�}ttjtjtj	h�}t
�}y�x�|�\}}||krVq@q@|tjkrl|rfPd}q@|tjko||dk�r,|�\}}|tjks�|dkr�P|�\}}|tjks�|dkr�P|�\}}|tj
kr�|dkr�|�\}}xJ|tjk�r(|j|�|�\}}|tj
k�s|d	k�rP|�\}}q�Wq@Pq@WWntk
�rJYnXt|�S)
NFcst��}|d|dfS)Nrr)�next)�tok)�genrr�advance�sz(_detect_future_features.<locals>.advanceT�fromZ
__future__�import�(�,)r�generate_tokens�io�StringIO�readline�	frozensetr�NEWLINE�NL�COMMENTr%�STRING�NAME�OP�add�
StopIteration)�sourceZhave_docstringrG�ignore�features�tp�valuer)rFr�_detect_future_featuressD








r^c@seZdZdZdS)�
FixerErrorzA fixer could not be loaded.N)rr r!�__doc__rrrrr_�sr_c@s�eZdZddd�ZdZdZd4dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zd7dd�Zdd�Zd8dd�Zdd�Zd d!�Zd9d"d#�Zd:d$d%�Zd&Zd'Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS);�RefactoringToolF)�print_function�write_unchanged_filesZFixrNcCs2||_|pg|_|jj�|_|dk	r0|jj|�|jdrDtj|_ntj	|_|jj
d�|_g|_t
jd�|_g|_d|_tj|jtj|jd�|_|j�\|_|_g|_tj�|_g|_g|_xXt|j|j�D]F}|j r�|jj!|�q�||jkr�|jj"|�q�||jkr�|jj"|�q�Wt#|j�|_$t#|j�|_%dS)z�Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: a dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
        NrbrcraF)�convert�logger)&�fixers�explicit�_default_options�copy�optionsr&r	�!python_grammar_no_print_statement�grammarr/�getrc�errors�loggingZ	getLoggerre�	fixer_log�wroterZDriverrrd�
get_fixers�	pre_order�
post_order�files�bmZ
BottomMatcher�BMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr5�bmi_pre_order_heads�bmi_post_order_heads)�selfZfixer_namesrjrgr4rrr�__init__�s<





zRefactoringTool.__init__cCs\g}g}�x&|jD�]}t|iidg�}|jdd�d}|j|j�rV|t|j�d�}|jd�}|jdjdd�|D��}yt	||�}Wn$t
k
r�td	||f��YnX||j|j
�}	|	jr�|jd
k	r�||jkr�|jd|�q|jd|�|	jd
k�r|j|	�q|	jdk�r |j|	�qtd|	j��qWtjd�}
|j|
d�|j|
d�||fS)aInspects the options to load the requested patterns and handlers.

        Returns:
          (pre_order, post_order), where pre_order is the list of fixers that
          want a pre-order AST traversal, and post_order is the list that want
          post-order traversal.
        rr6rN�_�cSsg|]}|j��qSr)�title)r7r)rrrr:�sz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order)�key���)rfr�rsplitr�FILE_PREFIX�len�split�CLASS_PREFIX�join�getattr�AttributeErrorr_rjrprg�log_message�	log_debug�orderr�operator�
attrgetter�sort)rzZpre_order_fixersZpost_order_fixersZfix_mod_path�modr8�parts�
class_nameZ	fix_classr4Zkey_funcrrrrr�s8


zRefactoringTool.get_fixerscOs�dS)zCalled when an error occurs.Nr)rz�msg�args�kwdsrrr�	log_errorszRefactoringTool.log_errorcGs|r||}|jj|�dS)zHook to log a message.N)re�info)rzr�r�rrrr�szRefactoringTool.log_messagecGs|r||}|jj|�dS)N)re�debug)rzr�r�rrrr�szRefactoringTool.log_debugcCsdS)zTCalled with the old version, new version, and filename of a
        refactored file.Nr)rz�old_text�new_text�filename�equalrrr�print_outputszRefactoringTool.print_outputcCs<x6|D].}tjj|�r&|j|||�q|j|||�qWdS)z)Refactor a list of files and directories.N)rr�isdir�refactor_dir�
refactor_file)rz�items�write�
doctests_onlyZdir_or_filerrr�refactor#s
zRefactoringTool.refactorc
Cs�tjd}x�tj|�D]�\}}}|jd|�|j�|j�xH|D]@}|jd�rBtjj|�d|krBtjj||�}	|j	|	||�qBWdd�|D�|dd�<qWdS)z�Descends down a directory and refactor every Python file found.

        Python files are assumed to have a .py extension.

        Files and subdirectories starting with '.' are skipped.
        �pyzDescending into %sr6rcSsg|]}|jd�s|�qS)r6)r)r7Zdnrrrr:>sz0RefactoringTool.refactor_dir.<locals>.<listcomp>N)
r�extsep�walkr�r�rr�splitextr�r�)
rzZdir_namer�r�Zpy_ext�dirpathZdirnames�	filenamesr�fullnamerrrr�,s

zRefactoringTool.refactor_dircCs�yt|d�}Wn.tk
r<}z|jd||�dSd}~XnXztj|j�d}Wd|j�Xt|d|d��}t|j	��|fSQRXdS)zG
        Do our best to decode a Python source file correctly.
        �rbzCan't open %s: %sNrr()�encoding)NN)
�open�OSErrorr�r�detect_encodingrO�close�_open_with_encodingrA�read)rzr��f�errr�rrr�_read_python_source@s
z#RefactoringTool._read_python_sourcecCs�|j|�\}}|dkrdS|d7}|rn|jd|�|j||�}|jsL||kr`|j|||||�q�|jd|�nH|j||�}|js�|r�|jr�|jt|�dd�|||d�n|jd|�dS)	zRefactors a file.Nr>zRefactoring doctests in %szNo doctest changes in %sr)r�r�zNo changes in %sr�)r�r��refactor_docstringrc�processed_file�refactor_string�was_changed�str)rzr�r�r�r@r��output�treerrrr�PszRefactoringTool.refactor_filecCs�t|�}d|krtj|j_zJy|jj|�}Wn4tk
r`}z|jd||jj	|�dSd}~XnXWd|j|j_X||_
|jd|�|j||�|S)aFRefactor a given input string.

        Args:
            data: a string holding the code to be refactored.
            name: a human-readable name for use in error/log messages.

        Returns:
            An AST corresponding to the refactored input stream; None if
            there were errors during the parse.
        rbzCan't parse %s: %s: %sNzRefactoring %s)
r^r	rkrrlZparse_stringr'r��	__class__r�future_featuresr��
refactor_tree)rz�datarr[r�r�rrrr�gs
zRefactoringTool.refactor_stringcCs�tjj�}|rN|jd�|j|d�}|js2||krB|j|d|�q�|jd�n:|j|d�}|jsj|r~|jr~|jt	|�d|�n
|jd�dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
�sys�stdinr�r�r�rcr�r�r�r�)rzr�r@r�r�rrr�refactor_stdin�s

zRefactoringTool.refactor_stdinc
Cs�x"t|j|j�D]}|j||�qW|j|j|j��|j|j|j��|jj|j	��}�xvt
|j���rАx`|jjD�]R}||ko�||rv||j
tjjdd�|jr�||j
tjjd��x
t||�D�]�}|||kr�||j|�yt|�Wntk
�rw�YnX|j�r(||jk�r(q�|j|�}|r�|j||�}|dk	r�|j|�x,|j�D] }|j�spg|_|jj|��q^W|jj|j	��}x2|D]*}	|	|k�r�g||	<||	j||	��q�Wq�WqvWq\Wx$t|j|j�D]}|j||��q�W|jS)a�Refactors a parse tree (modifying the tree in place).

        For compatible patterns the bottom matcher module is
        used. Otherwise the tree is traversed node-to-node for
        matches.

        Args:
            tree: a pytree.Node instance representing the root of the tree
                  to be refactored.
            name: a human-readable name for this tree.

        Returns:
            True if the tree was modified, False otherwise.
        T)r�reverse)rN)rrsrtZ
start_tree�traverse_byrxryrwZrunZleaves�anyr0rfr�rZBaseZdepthZkeep_line_orderZ
get_linenor-�remover�
ValueErrorZfixers_applied�match�	transformr?rr2Zfinish_treer�)
rzr�rr4Z	match_set�node�results�newZnew_matchesZfxrrrrr��sJ



$zRefactoringTool.refactor_treecCs^|sdSxP|D]H}xB||jD]4}|j|�}|r|j||�}|dk	r|j|�|}qWqWdS)aTraverse an AST, applying a set of fixers to each node.

        This is a helper method for refactor_tree().

        Args:
            fixers: a list of fixer instances.
            traversal: a generator that yields AST nodes.

        Returns:
            None
        N)r#r�r�r?)rzrfZ	traversalr�r4r�r�rrrr��s


zRefactoringTool.traverse_bycCs�|jj|�|dkr.|j|�d}|dkr.dS||k}|j||||�|r`|jd|�|js`dS|rv|j||||�n|jd|�dS)zR
        Called when a file has been refactored and there may be changes.
        NrzNo changes to %szNot writing changes to %s)rurr�r�r�rc�
write_file)rzr�r�r�r�r�r�rrrr��szRefactoringTool.processed_filec%Cs�yt|d|d�}Wn.tk
r@}z|jd||�dSd}~XnXzHy|jt|��Wn0tk
r�}z|jd||�WYdd}~XnXWd|j�X|jd|�d|_dS)z�Writes a string to a file.

        It first shows a unified diff between the old text and the new text, and
        then rewrites the file; the latter is only done if the write option is
        set.
        �w)r�zCan't create %s: %sNzCan't write %s: %szWrote changes to %sT)r�r�r�r�rCr�r�rq)rzr�r�r�r�r�r�rrrr�
s$
zRefactoringTool.write_filez>>> z... c
Csg}d}d}d}d}x�|jdd�D]�}|d7}|j�j|j�r�|dk	r\|j|j||||��|}|g}|j|j�}	|d|	�}q"|dk	r�|j||j�s�|||jj�dkr�|j	|�q"|dk	r�|j|j||||��d}d}|j	|�q"W|dk	�r|j|j||||��dj
|�S)a�Refactors a docstring, looking for doctests.

        This returns a modified version of the input string.  It looks
        for doctests, which start with a ">>>" prompt, and may be
        continued with "..." prompts, as long as the "..." is indented
        the same as the ">>>".

        (Unfortunately we can't use the doctest module's parser,
        since, like most parsers, it is not geared towards preserving
        the original source.)
        NrT)�keependsrr>r})�
splitlines�lstripr�PS1r2�refactor_doctest�find�PS2�rstriprr�)
rzr@r��result�blockZblock_lineno�indent�lineno�line�irrrr�%s:



z"RefactoringTool.refactor_docstringc
s(y�j||��}Wndtk
rv}zH�jjtj�rRx|D]}�jd|jd��q8W�jd|||j	j
|�|Sd}~XnX�j||��r$t|�j
dd�}|d|d�||dd�}	}|	dg|dks�t|	��|djd�s�|dd7<��j|jd�g}|�r$|��fd	d
�|D�7}|S)
z�Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).

        z
Source: %sr>z+Can't parse docstring in %s line %s: %s: %sNT)r�rrcsg|]}��j|�qSr)r�)r7r�)r�rzrrr:jsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>r�r�)�parse_blockr'reZisEnabledForro�DEBUGr�r�r�r�rr�r�r��AssertionErrorrr��pop)
rzr�r�r�r�r�r�r�r�Zclippedr)r�rzrr�Ps&
"z RefactoringTool.refactor_doctestcCs�|jrd}nd}|js$|jd|�n&|jd|�x|jD]}|j|�q8W|jrt|jd�x|jD]}|j|�qbW|jr�t|j�dkr�|jd�n|jdt|j��x&|jD]\}}}|j|f|�|�q�WdS)	N�werez
need to bezNo files %s modified.zFiles that %s modified:z$Warnings/messages while refactoring:rzThere was 1 error:zThere were %d errors:)rqrur�rprnr�)rzr��file�messager�r�r�rrr�	summarizems$
zRefactoringTool.summarizecCs"|jj|j|||��}t�|_|S)z�Parses a block into a tree.

        This is necessary to get correct line number / offset information
        in the parser diagnostics and embedded into the parse tree.
        )rZparse_tokens�	wrap_toksrPr�)rzr�r�r�r�rrrr��szRefactoringTool.parse_blockccshtj|j||�j�}xN|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqWdS)z;Wraps a tokenize stream to systematically modify start/end.rN)rrL�	gen_lines�__next__)rzr�r�r�r1r#r]Zline0Zcol0Zline1Zcol1Z	line_textrrrr��s
zRefactoringTool.wrap_toksccs�||j}||j}|}xV|D]N}|j|�r@|t|�d�Vn(||j�dkrXdVntd||f��|}qWx
dVqrWdS)z�Generates lines as expected by tokenize from a list of lines.

        This strips the first len(indent + self.PS1) characters off each line.
        Nr>zline=%r, prefix=%rr})r�r�rr�r�r�)rzr�r��prefix1Zprefix2�prefixr�rrrr��s



zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rr r!rhr�r�r{rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrra�s:
4(
	


O

+
rac@seZdZdS)�MultiprocessingUnsupportedN)rr r!rrrrr��sr�csBeZdZ�fdd�Zd�fdd�	Z�fdd�Z�fd	d
�Z�ZS)�MultiprocessRefactoringToolcs"tt|�j||�d|_d|_dS)N)�superr�r{�queue�output_lock)rzr��kwargs)r�rrr{�sz$MultiprocessRefactoringTool.__init__Frcs|dkrtt��j|||�Syddl�Wntk
r@t�YnX�jdk	rTtd���j��_�j	��_
��fdd�t|�D�}z.x|D]}|j�q�Wtt��j|||�Wd�jj
�xt|�D]}�jjd�q�Wx|D]}|j�r�|j
�q�Wd�_XdS)Nrrz already doing multiple processescsg|]}�j�jd��qS))�target)ZProcess�_child)r7r�)�multiprocessingrzrrr:�sz8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)r�r�r�r��ImportErrorr�r��RuntimeErrorZ
JoinableQueueZLockr��range�startr��putZis_alive)rzr�r�r�Z
num_processesZ	processesr)r�)r�)r�rzrr��s2









z$MultiprocessRefactoringTool.refactorc
sR|jj�}xB|dk	rL|\}}ztt|�j||�Wd|jj�X|jj�}qWdS)N)r�rmr�r�r�Z	task_done)rzZtaskr�r�)r�rrr��s


z"MultiprocessRefactoringTool._childcs2|jdk	r|jj||f�ntt|�j||�SdS)N)r�r�r�r�r�)rzr�r�)r�rrr��s

z)MultiprocessRefactoringTool.refactor_file)FFr)rr r!r{r�r�r��
__classcell__rr)r�rr��s
r�)T)rr)(r`�
__author__rr�ror�r+rM�	itertoolsrZpgen2rrrZ
fixer_utilrr}rr	r
rvrr'rr$r5r;r=�version_info�codecsr�r�rArCr^r_�objectrar�r�rrrr�<module>	sF



(	PK�&�\��WWWmain.cpython-36.opt-2.pycnu�[���3


 \�-�@s|ddlmZmZddlZddlZddlZddlZddlZddlZddl	m
Z
dd�ZGdd�de
j�Z
d	d
�Zd
dd�ZdS)�)�with_statement�print_functionN�)�refactorc	Cs(|j�}|j�}tj||||dddd�S)Nz
(original)z(refactored)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filename�r�$/usr/lib64/python3.6/lib2to3/main.py�
diff_textss
rcs:eZdZd
�fdd�	Zdd�Z�fdd�Zdd	�Z�ZS)�StdoutRefactoringToolrc		sR||_||_|r(|jtj�r(|tj7}||_||_||_tt	|�j
|||�dS)N)�	nobackups�
show_diffs�endswith�os�sep�_input_base_dir�_output_dir�_append_suffix�superr�__init__)	�selfZfixers�options�explicitrr�input_base_dir�
output_dir�
append_suffix)�	__class__rr
r$s
zStdoutRefactoringTool.__init__cOs*|jj|||f�|jj|f|�|�dS)N)�errors�append�logger�error)r�msg�args�kwargsrrr
�	log_errorAszStdoutRefactoringTool.log_errorc
!s||}|jrH|j|j�r6tjj|j|t|j�d��}ntd||jf��|jrX||j7}||kr�tjj	|�}tjj
|�r�|r�tj|�|jd||�|j
�s4|d}tjj|�r�ytj|�Wn.tk
r�}z|jd|�WYdd}~XnXytj||�Wn2tk
�r2}z|jd||�WYdd}~XnXtt|�j}	|	||||�|j
�sbtj||�||k�rxtj||�dS)Nz5filename %s does not start with the input_base_dir %szWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)r�
startswithrr�path�join�len�
ValueErrorr�dirname�isdir�makedirs�log_messager�lexists�remove�OSError�renamerr�
write_file�shutilZcopymode)
rZnew_textrZold_text�encodingZ
orig_filenamerZbackup�err�write)r rr
r6Es@


 
z StdoutRefactoringTool.write_filecCs�|r|jd|�n�|jd|�|jr�t|||�}yX|jdk	rp|j�&x|D]}t|�qJWtjj�WdQRXnx|D]}t|�qvWWn"tk
r�t	d|f�dSXdS)NzNo changes to %sz
Refactored %sz+couldn't encode %s's diff for your terminal)
r1rrZoutput_lock�print�sys�stdout�flush�UnicodeEncodeError�warn)r�old�newrZequalZ
diff_lines�linerrr
�print_outputls"



z"StdoutRefactoringTool.print_output)rrr)�__name__�
__module__�__qualname__rr(r6rD�
__classcell__rr)r r
rs'rcCstd|ftjd�dS)NzWARNING: %s)�file)r;r<�stderr)r%rrr
r@�sr@cstjdd�}|jddddd�|jdd	d
gdd�|jd
dddddd�|jddd
gdd�|jddddd�|jddddd�|jddddd�|jd dd!d�|jd"d#dd$d�|jd%d&dd'd(d�|jd)d*dd+d,d-d.�|jd/d0dd1d�|jd2dd+d,d3d.�d'}i}|j|�\}}|j�r@d4|d5<|j�s:td6�d4|_|j�r\|j�r\|j	d7�|j
�rx|j�rx|j	d8�|j�r�|j�r�td9�|j�r�|j�r�|j	d:�|j�r�t
d;�xtj��D]}t
|��q�W|�s�d<S|�st
d=tjd>�t
d?tjd>�d@SdA|k�r4d4}|j�r4t
dBtjd>�d@S|j�rDd4|dC<|j�rRtjntj}tjdD|dE�tjdF�}ttj���}	t�fdGdH�|jD��}
t�}|j�r�d'}x2|jD](}
|
dIk�r�d4}n|j�dJ|
��q�W|�r�|	j|�n|}n
|	j|�}|j|
�}t j!j"|�}|�rD|j#t j$��rDt j!j%|��rDt j!j&|�}|j�rh|j't j$�}|j(dK|j|�t)t*|�|t*|�|j|j||j|j
dL�}|j+�s�|�r�|j,�nBy|j||j|j-|j.�Wn&tj/k
�r�t
dMtjd>�dSX|j0�t1t2|j+��S)NNz2to3 [options] file|dir ...)Zusagez-dz--doctests_only�
store_truezFix up doctests only)�action�helpz-fz--fixr"z1Each FIX specifies a transformation; default: all)rL�defaultrMz-jz--processesZstorer�intzRun 2to3 concurrently)rLrN�typerMz-xz--nofixz'Prevent a transformation from being runz-lz--list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-vz	--verbosezMore verbose loggingz
--no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz--nobackupsFz&Don't write backups for modified filesz-oz--output-dir�strrzXPut output files in this directory instead of overwriting the input files.  Requires -n.)rLrPrNrMz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z--add-suffixzuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.T�write_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.)rIzUse --help to show usage.��-zCan't write to stdin.rz%(name)s: %(message)s)�format�levelzlib2to3.mainc3s|]}�d|VqdS)z.fix_Nr)�.0�fix)�	fixer_pkgrr
�	<genexpr>�szmain.<locals>.<genexpr>�allz.fix_z7Output in %r will mirror the input directory %r layout.)rrrz+Sorry, -j isn't supported on this platform.)3�optparseZOptionParserZ
add_option�
parse_argsrRr:r@rrr$Z
add_suffixZno_diffsZ
list_fixesr;rZget_all_fix_namesr<rJr�verbose�logging�DEBUG�INFOZbasicConfigZ	getLogger�setZget_fixers_from_packageZnofixrX�add�union�
differencerr*�commonprefixrrr/r.�rstrip�infor�sortedr!�refactor_stdinZ
doctests_onlyZ	processesZMultiprocessingUnsupportedZ	summarizerO�bool)rYr&�parserrj�flagsrZfixnamerVr#Zavail_fixesZunwanted_fixesrZall_presentrXZ	requestedZfixer_namesrZrtr)rYr
�main�s�




















rn)N)Z
__future__rrr<rrr_r7r\rrrZMultiprocessRefactoringToolrr@rnrrrr
�<module>s	gPK�&�\euf���patcomp.cpython-36.pycnu�[���3


 \��@s�dZdZddlZddlmZmZmZmZmZm	Z	ddl
mZddl
mZGdd	�d	e
�Zd
d�ZGdd
�d
e�Zejejejdd�Zdd�Zdd�Zdd�ZdS)z�Pattern compiler.

The grammar is taken from PatternGrammar.txt.

The compiler compiles a pattern to a pytree.*Pattern instance.
z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�'/usr/lib64/python3.6/lib2to3/patcomp.pyrsrc	csPtjtjtjh}tjtj|�j�}x(|D] }|\}}}}}||kr(|Vq(WdS)z6Tokenizes a string suppressing significant whitespace.N)	r�NEWLINE�INDENT�DEDENTr�generate_tokens�io�StringIO�readline)	�input�skip�tokensZ	quintuple�type�value�start�endZ	line_textrrr�tokenize_wrappers
rc@s:eZdZd
dd�Zddd�Zdd�Zdd	d
�Zdd�ZdS)�PatternCompilerNcCsZ|dkrtj|_tj|_ntj|�|_tj|j�|_tj|_	tj
|_tj|jt
d�|_dS)z^Initializer.

        Takes an optional alternative filename for the pattern grammar.
        N)Zconvert)r
Zpattern_grammarrZpattern_symbols�symsrZload_grammarZSymbolsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__(s
zPatternCompiler.__init__FcCsnt|�}y|jj||d�}Wn0tjk
rL}ztt|���WYdd}~XnX|r`|j|�|fS|j|�SdS)z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)rrZparse_tokensrZ
ParseErrorr�str�compile_node)r$rr&Z	with_treer�root�errr�compile_pattern7szPatternCompiler.compile_patternc
s�|j�jjkr|jd}|j�jjkrz�fdd�|jddd�D�}t|�dkrX|dStjdd�|D�ddd�}|j�S|j�jj	krʇfd	d�|jD�}t|�dkr�|dStj|gddd�}|j�S|j�jj
kr��j|jdd��}tj|�}|j�S|j�jj
k�st�d}|j}t|�d
k�rR|djtjk�rR|dj}|dd�}d}t|�dk�r�|d
j�jjk�r�|d}|dd�}�j||�}|dk	�r�|j�jjk�s�t�|j}	|	d}
|
jtjk�r�d}tj}n�|
jtjk�r�d}tj}np|
jtjk�r^|	djtjk�st�t|	�dk�s.t��j|	d�}}t|	�dk�rh�j|	d
�}n
d�sht�|dk�s||dk�r�|j�}tj|gg||d�}|dk	�r�||_|j�S)zXCompiles a node, recursively.

        This is one big switch on the node type.
        rcsg|]}�j|��qSr)r()�.0�ch)r$rr�
<listcomp>Osz0PatternCompiler.compile_node.<locals>.<listcomp>N�rcSsg|]
}|g�qSrr)r,�arrrr.Rs)�min�maxcsg|]}�j|��qSr)r()r,r-)r$rrr.Vs��F���r5r5r5)r3r4)rr!ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternZUnit�AssertionErrorr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�RBRACE�get_int�name)
r$�nodeZalts�pZunits�patternrB�nodes�repeatr6Zchildr1r2r)r$rr(Csh

 
"


zPatternCompiler.compile_nodecCsnt|�dkst�|d}|jtjkrDttj|j��}t	j
t|�|�S|jtjk�r|j}|j
�r�|tkrttd|��|dd�r�td��t	j
t|�S|dkr�d}n,|jd�s�t|j|d�}|dkr�td|��|dd�r�|j|djd�g}nd}t	j||�SnV|jdk�r |j|d�S|jd	k�r\|dk�s:t�|j|d�}t	j|ggddd
�Sd�sjt|��dS)NrrzInvalid token: %rzCan't have details for token�any�_zInvalid symbol: %r�(�[)r1r2F)r7r;rr�STRINGr'rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr"r(r6ZNodePatternr8)r$rFrGrCrrZcontent�
subpatternrrrr:�s<
zPatternCompiler.compile_basiccCs|jtjkst�t|j�S)N)rr�NUMBERr;�intr)r$rCrrrrA�szPatternCompiler.get_int)N)FF)N)rr
rr%r+r(r:rArrrrr &s


G
#r )rNrLrTZTOKENcCs.|dj�rtjS|tjkr&tj|SdSdS)Nr)�isalpharrNrZopmap)rrrrrM�s


rMcCs>|\}}}}|s||jkr*tj|||d�Stj|||d�SdS)z9Converts raw node information to a Node or Leaf instance.)�contextN)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrrWr6rrrr#�sr#cCst�j|�S)N)r r+)rErrrr+�sr+)�__doc__�
__author__rZpgen2rrrrrr�r	r
�	Exceptionrr�objectr rNrLrTrPrMr#r+rrrr�<module>	s  
		PK�&�\�7M:�
�
fixer_base.cpython-36.opt-2.pycnu�[���3


 \"�@sPddlZddlmZddlmZddlmZGdd�de�ZGdd	�d	e�Z	dS)
�N�)�PatternCompiler)�pygram)�does_tree_importc@s�eZdZdZdZdZdZdZej	d�Z
e�ZdZ
dZdZdZdZdZejZdd�Zdd	�Zd
d�Zdd
�Zdd�Zddd�Zdd�Zddd�Zdd�Zdd�Zdd�Z dS)�BaseFixNrZpostF�cCs||_||_|j�dS)N)�options�log�compile_pattern)�selfrr	�r�*/usr/lib64/python3.6/lib2to3/fixer_base.py�__init__/szBaseFix.__init__cCs,|jdk	r(t�}|j|jdd�\|_|_dS)NT)Z	with_tree)�PATTERNrr
�pattern�pattern_tree)r�PCrrr
r
;s
zBaseFix.compile_patterncCs
||_dS)N)�filename)rrrrr
�set_filenameFszBaseFix.set_filenamecCsd|i}|jj||�o|S)N�node)r�match)rr�resultsrrr
rMs	z
BaseFix.matchcCs
t��dS)N)�NotImplementedError)rrrrrr
�	transformYszBaseFix.transform�xxx_todo_changemecCs6|}x ||jkr$|tt|j��}qW|jj|�|S)N)�
used_names�str�next�numbers�add)r�template�namerrr
�new_nameis
zBaseFix.new_namecCs.|jrd|_|jjd|j�|jj|�dS)NFz### In file %s ###)�	first_logr	�appendr)r�messagerrr
�log_messagetszBaseFix.log_messagecCs>|j�}|j�}d|_d}|j|||f�|r:|j|�dS)N�zLine %d: could not convert: %s)�
get_linenoZclone�prefixr&)rr�reason�linenoZ
for_output�msgrrr
�cannot_convertzszBaseFix.cannot_convertcCs|j�}|jd||f�dS)NzLine %d: %s)r(r&)rrr*r+rrr
�warning�szBaseFix.warningcCs(|j|_|j|�tjd�|_d|_dS)NrT)rr�	itertools�countrr#)r�treerrrr
�
start_tree�s
zBaseFix.start_treecCsdS)Nr)rr1rrrr
�finish_tree�szBaseFix.finish_tree)r)N)!�__name__�
__module__�__qualname__rrrrrr/r0r�setr�orderZexplicitZ	run_orderZ_accept_typeZkeep_line_orderZ
BM_compatiblerZpython_symbolsZsymsrr
rrrr"r&r-r.r2r3rrrr
rs2




rcs(eZdZdZ�fdd�Zdd�Z�ZS)�ConditionalFixNcstt|�j|�d|_dS)N)�superr9r2�_should_skip)r�args)�	__class__rr
r2�szConditionalFix.start_treecCsJ|jdk	r|jS|jjd�}|d}dj|dd��}t|||�|_|jS)N�.r���r?)r;�skip_on�split�joinr)rrZpkgr!rrr
�should_skip�s
zConditionalFix.should_skip)r4r5r6r@r2rC�
__classcell__rr)r=r
r9�sr9)
r/Zpatcomprr'rZ
fixer_utilr�objectrr9rrrr
�<module>sPK�&�\!�����__init__.cpython-36.opt-2.pycnu�[���3


 \-�@sddddgZdS)ZdomZparsersZsaxZetreeN)�__all__�rr�$/usr/lib64/python3.6/xml/__init__.py�<module>sPK�+�\�s55dictconfig.cpython-36.pycnu�[���3

�Pf8Z�@s�ddlmZddlZddlZddlZddlZddlmZej	dej
�Zdd�Zyddlm
Z
Wnek
rzdd	�Z
YnXGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZeZdd�ZdS)�)�absolute_importN)�sixz^[a-z_][a-z0-9_]*$cCstj|�}|std|��dS)Nz!Not a valid Python identifier: %rT)�
IDENTIFIER�match�
ValueError)�s�m�r	� /usr/lib/python3.6/dictconfig.py�valid_ident"s
r)�_checkLevelcCsNt|t�r|}n:t|�|kr>|tjkr2td|��tj|}ntd|��|S)NzUnknown level: %rz*Level not an integer or a valid string: %r)�
isinstance�int�str�loggingZ_levelNamesr�	TypeError)�level�rvr	r	r
r.s

rc@s,eZdZdZdd�Zd	dd�Zd
dd�ZdS)�ConvertingDictz A converting dictionary wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�dict�__getitem__�configurator�convert�typer�ConvertingList�ConvertingTuple�parent�key)�selfr�value�resultr	r	r
rGs
zConvertingDict.__getitem__NcCsLtj|||�}|jj|�}||k	rH|||<t|�tttfkrH||_||_	|S)N)
r�getrrrrrrrr)rr�defaultrr r	r	r
r!Ss
zConvertingDict.getcCsDtj|||�}|jj|�}||k	r@t|�tttfkr@||_||_	|S)N)
r�poprrrrrrrr)rrr"rr r	r	r
r#_s
zConvertingDict.pop)N)N)�__name__�
__module__�__qualname__�__doc__rr!r#r	r	r	r
rDs
rc@s"eZdZdZdd�Zd	dd�ZdS)
rzA converting list wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�listrrrrrrrrr)rrrr r	r	r
rls
zConvertingList.__getitem__�cCs<tj||�}|jj|�}||k	r8t|�tttfkr8||_|S)N)	r(r#rrrrrrr)r�idxrr r	r	r
r#xs
zConvertingList.popN���)r+)r$r%r&r'rr#r	r	r	r
rjsrc@seZdZdZdd�ZdS)rzA converting tuple wrapper.cCsBtj||�}|jj|�}||k	r>t|�tttfkr>||_||_	|S)N)
�tuplerrrrrrrrr)rrrr r	r	r
r�s
zConvertingTuple.__getitem__N)r$r%r&r'rr	r	r	r
r�src@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ddd	�ZeZ
d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�BaseConfiguratorzI
    The configurator base class which defines some useful defaults.
    z%^(?P<prefix>[a-z]+)://(?P<suffix>.*)$z^\s*(\w+)\s*z^\.\s*(\w+)\s*z^\[\s*(\w+)\s*\]\s*z^\d+$�ext_convert�cfg_convert)ZextZcfgcCst|�|_||j_dS)N)r�configr)rr0r	r	r
�__init__�s
zBaseConfigurator.__init__c	Cs�|jd�}|jd�}y`|j|�}xP|D]H}|d|7}yt||�}Wq&tk
rl|j|�t||�}Yq&Xq&W|Stk
r�tj�dd�\}}td||f�}|||_	|_
|�YnXdS)z`
        Resolve strings to objects using standard import and attribute
        syntax.
        �.rr)NzCannot resolve %r: %s)�splitr#�importer�getattr�AttributeError�ImportError�sys�exc_infor�	__cause__�
__traceback__)	rr�nameZused�foundZfrag�e�tb�vr	r	r
�resolve�s"




zBaseConfigurator.resolvecCs
|j|�S)z*Default converter for the ext:// protocol.)rA)rrr	r	r
r.�szBaseConfigurator.ext_convertcCs|}|jj|�}|dkr&td|��n�||j�d�}|j|j�d}x�|r�|jj|�}|rp||j�d}nd|jj|�}|r�|j�d}|jj|�s�||}n2yt	|�}||}Wnt
k
r�||}YnX|r�||j�d�}qJtd||f��qJW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)�WORD_PATTERNrr�endr0�groups�DOT_PATTERN�
INDEX_PATTERN�
DIGIT_PATTERNrr)rr�restr�dr*�nr	r	r
r/�s2
zBaseConfigurator.cfg_convertcCs�t|t�r&t|t�r&t|�}||_n�t|t�rLt|t�rLt|�}||_n~t|t�rrt|t�rrt|�}||_nXt|tj	�r�|j
j|�}|r�|j�}|d}|j
j|d�}|r�|d}t||�}||�}|S)z�
        Convert values to an appropriate type. dicts, lists and tuples are
        replaced by their converting alternatives. Strings are checked to
        see if they have a conversion format and are converted if they do.
        �prefixN�suffix)r
rrrrr(rr,rZstring_types�CONVERT_PATTERNr�	groupdict�value_convertersr!r5)rrrrIrKZ	converterrLr	r	r
r�s*

zBaseConfigurator.convertcs��jd�}t|d�r8ttd�r8t|�tjkr8|j|�}�jdd�}t�fdd��D��}|f|�}|r�x |j�D]\}}t|||�qrW|S)z1Configure an object with a user-supplied factory.z()�__call__�	ClassTyper2Nc3s"|]}t|�r|�|fVqdS)N)r)�.0�k)r0r	r
�	<genexpr>sz4BaseConfigurator.configure_custom.<locals>.<genexpr>)	r#�hasattr�typesrrQrAr�items�setattr)rr0�cZprops�kwargsr r<rr	)r0r
�configure_customs
$

z!BaseConfigurator.configure_customcCst|t�rt|�}|S)z0Utility function which converts lists to tuples.)r
r(r,)rrr	r	r
�as_tuples
zBaseConfigurator.as_tupleN)r$r%r&r'�re�compilerMrBrErFrGrO�
__import__r4r1rAr.r/rr[r\r	r	r	r
r-�s 




"r-c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
ddd�Zddd�ZdS)�DictConfiguratorz]
    Configure logging using a dictionary-like object to describe the
    configuration.
    cCs�|j}d|krtd��|ddkr2td|d��|jdd�}i}tj��z||�r�|jd|�}tjdd	�dk�rx�|D]�}|tjkr�td|��qzy4tj|}||}|jdd�}|r�|j	t
|��Wqztk
�r�}	ztd
||	f��WYdd}	~	XqzXqzW|jd|�}
xZ|
D]R}y|j||
|d�Wn4tk
�rd}	ztd||	f��WYdd}	~	XnX�qW|jdd�}|�r�y|j
|d�Wn0tk
�r�}	ztd|	��WYdd}	~	XnX�n|jdd�}tjj�tjdd�=|jd|�}
xZ|
D]R}y|j|
|�|
|<Wn4tk
�rF}	ztd||	f��WYdd}	~	XnX�q�W|jd|�}xZ|D]R}y|j||�||<Wn4tk
�r�}	ztd||	f��WYdd}	~	XnX�q`W|jd|�}xht|�D]\}y |j||�}||_|||<Wn4tk
�r$}	ztd
||	f��WYdd}	~	XnX�q�Wtj}t|jj�}|j�g}|jd|�}
x�|
D]�}||k�r�|j|�}|d}t|�}t|�}|d}x<||k�r�||d|�|k�r�|j||�|d}�q�W|j|�y|j||
|�Wn4tk
�r$}	ztd||	f��WYdd}	~	XnX�q\WxF|D]>}|jj|}||k�rbtj|_g|_ d|_!n|�r2d|_"�q2W|jdd�}|�r�y|j
|�Wn0tk
�r�}	ztd|	��WYdd}	~	XnXWdtj#�XdS)zDo the configuration.�versionz$dictionary doesn't specify a versionr)zUnsupported version: %s�incrementalF�handlersN��zNo handler found with name %rrz"Unable to configure handler %r: %s�loggersTz!Unable to configure logger %r: %s�rootz#Unable to configure root logger: %sZdisable_existing_loggers�
formattersz$Unable to configure formatter %r: %s�filtersz!Unable to configure filter %r: %sr2)rdre)$r0rr#rZ_acquireLockr!r8�version_infoZ	_handlers�setLevelr�
StandardError�configure_logger�configure_root�clearZ_handlerList�configure_formatter�configure_filter�sorted�configure_handlerr<rgr(ZmanagerZ
loggerDict�sort�index�len�append�removeZNOTSETrrc�	propagateZdisabledZ_releaseLock)rr0rbZ
EMPTY_DICTrcr<ZhandlerZhandler_configrr>rfrgZdisable_existingrhriZexistingZ
child_loggers�iZprefixedZpflenZnum_existing�log�loggerr	r	r
�	configures�



"
$

$
$$



$

zDictConfigurator.configurecCs�d|krr|d}y|j|�}Wq�tk
rn}z4dt|�kr>�|jd�|d<||d<|j|�}WYdd}~Xq�Xn$|jdd�}|jdd�}tj||�}|S)z(Configure a formatter from a dictionary.z()z'format'�format�fmtNZdatefmt)r[rrr#r!rZ	Formatter)rr0�factoryr �terZdfmtr	r	r
rp�sz$DictConfigurator.configure_formattercCs.d|kr|j|�}n|jdd�}tj|�}|S)z%Configure a filter from a dictionary.z()r<�)r[r!r�Filter)rr0r r<r	r	r
rq�s

z!DictConfigurator.configure_filtercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z/Add filters to a filterer from a list of names.rizUnable to add filter %r: %sN)Z	addFilterr0rlr)rZfiltererri�fr>r	r	r
�add_filters�s

zDictConfigurator.add_filtersc-s@�jdd�}|rVy|jd|}Wn2tk
rT}ztd||f��WYdd}~XnX�jdd�}�jdd�}d�kr��jd�}t|d�r�ttd	�r�t|�tjkr�|j|�}|}n�|j�jd
��}t	|t
jj�o�d�k�r2y|jd�d�d<Wn8tk
�r.}ztd
�d|f��WYdd}~XnXnZt	|t
jj
��r`d�k�r`|j�d��d<n,t	|t
jj��r�d�k�r�|j�d��d<|}t�fdd��D��}	y|f|	�}
WnLtk
�r}z.dt|�k�r؂|	jd�|	d<|f|	�}
WYdd}~XnX|�r|
j|�|dk	�r*|
jt|��|�r<|j|
|�|
S)z&Configure a handler from a dictionary.�	formatterNrhzUnable to set formatter %r: %srriz()rPrQ�class�targetrcz#Unable to set target handler %r: %sZmailhostZaddressc3s"|]}t|�r|�|fVqdS)N)r)rRrS)r0r	r
rT�sz5DictConfigurator.configure_handler.<locals>.<genexpr>z'stream'�streamZstrm)r#r0rlrrUrVrrQrA�
issubclassrrcZ
MemoryHandlerZSMTPHandlerr\Z
SysLogHandlerrrrZsetFormatterrkrr�)rr0r�r>rrirYr��klassrZr r�r	)r0r
rs�sX
$

$



z"DictConfigurator.configure_handlercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z.Add handlers to a logger from a list of names.rczUnable to add handler %r: %sN)Z
addHandlerr0rlr)rr|rc�hr>r	r	r
�add_handlers	s

zDictConfigurator.add_handlersFcCs�|jdd�}|dk	r"|jt|��|s�x |jdd�D]}|j|�q6W|jdd�}|rd|j||�|jdd�}|r�|j||�dS)zU
        Perform configuration which is common to root and non-root loggers.
        rNrcri)r!rkrrcZ
removeHandlerr�r�)rr|r0rbrr�rcrir	r	r
�common_logger_configsz%DictConfigurator.common_logger_configcCs6tj|�}|j|||�|jdd�}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.ryN)r�	getLoggerr�r!ry)rr<r0rbr|ryr	r	r
rm#s

z!DictConfigurator.configure_loggercCstj�}|j|||�dS)z*Configure a root logger from a dictionary.N)rr�r�)rr0rbrgr	r	r
rn+szDictConfigurator.configure_rootN)F)F)F)
r$r%r&r'r}rprqr�rsr�r�rmrnr	r	r	r
r`s	5

r`cCst|�j�dS)z%Configure logging using a dictionary.N)�dictConfigClassr})r0r	r	r
�
dictConfig3sr�)Z
__future__rZlogging.handlersrr]r8rVZpip._vendorrr^�Irrrr7rrr(rr,r�objectr-r`r�r�r	r	r	r
�<module>s*	&
PK�+�\�s55dictconfig.cpython-36.opt-1.pycnu�[���3

�Pf8Z�@s�ddlmZddlZddlZddlZddlZddlmZej	dej
�Zdd�Zyddlm
Z
Wnek
rzdd	�Z
YnXGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZeZdd�ZdS)�)�absolute_importN)�sixz^[a-z_][a-z0-9_]*$cCstj|�}|std|��dS)Nz!Not a valid Python identifier: %rT)�
IDENTIFIER�match�
ValueError)�s�m�r	� /usr/lib/python3.6/dictconfig.py�valid_ident"s
r)�_checkLevelcCsNt|t�r|}n:t|�|kr>|tjkr2td|��tj|}ntd|��|S)NzUnknown level: %rz*Level not an integer or a valid string: %r)�
isinstance�int�str�loggingZ_levelNamesr�	TypeError)�level�rvr	r	r
r.s

rc@s,eZdZdZdd�Zd	dd�Zd
dd�ZdS)�ConvertingDictz A converting dictionary wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�dict�__getitem__�configurator�convert�typer�ConvertingList�ConvertingTuple�parent�key)�selfr�value�resultr	r	r
rGs
zConvertingDict.__getitem__NcCsLtj|||�}|jj|�}||k	rH|||<t|�tttfkrH||_||_	|S)N)
r�getrrrrrrrr)rr�defaultrr r	r	r
r!Ss
zConvertingDict.getcCsDtj|||�}|jj|�}||k	r@t|�tttfkr@||_||_	|S)N)
r�poprrrrrrrr)rrr"rr r	r	r
r#_s
zConvertingDict.pop)N)N)�__name__�
__module__�__qualname__�__doc__rr!r#r	r	r	r
rDs
rc@s"eZdZdZdd�Zd	dd�ZdS)
rzA converting list wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�listrrrrrrrrr)rrrr r	r	r
rls
zConvertingList.__getitem__�cCs<tj||�}|jj|�}||k	r8t|�tttfkr8||_|S)N)	r(r#rrrrrrr)r�idxrr r	r	r
r#xs
zConvertingList.popN���)r+)r$r%r&r'rr#r	r	r	r
rjsrc@seZdZdZdd�ZdS)rzA converting tuple wrapper.cCsBtj||�}|jj|�}||k	r>t|�tttfkr>||_||_	|S)N)
�tuplerrrrrrrrr)rrrr r	r	r
r�s
zConvertingTuple.__getitem__N)r$r%r&r'rr	r	r	r
r�src@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ddd	�ZeZ
d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�BaseConfiguratorzI
    The configurator base class which defines some useful defaults.
    z%^(?P<prefix>[a-z]+)://(?P<suffix>.*)$z^\s*(\w+)\s*z^\.\s*(\w+)\s*z^\[\s*(\w+)\s*\]\s*z^\d+$�ext_convert�cfg_convert)ZextZcfgcCst|�|_||j_dS)N)r�configr)rr0r	r	r
�__init__�s
zBaseConfigurator.__init__c	Cs�|jd�}|jd�}y`|j|�}xP|D]H}|d|7}yt||�}Wq&tk
rl|j|�t||�}Yq&Xq&W|Stk
r�tj�dd�\}}td||f�}|||_	|_
|�YnXdS)z`
        Resolve strings to objects using standard import and attribute
        syntax.
        �.rr)NzCannot resolve %r: %s)�splitr#�importer�getattr�AttributeError�ImportError�sys�exc_infor�	__cause__�
__traceback__)	rr�nameZused�foundZfrag�e�tb�vr	r	r
�resolve�s"




zBaseConfigurator.resolvecCs
|j|�S)z*Default converter for the ext:// protocol.)rA)rrr	r	r
r.�szBaseConfigurator.ext_convertcCs|}|jj|�}|dkr&td|��n�||j�d�}|j|j�d}x�|r�|jj|�}|rp||j�d}nd|jj|�}|r�|j�d}|jj|�s�||}n2yt	|�}||}Wnt
k
r�||}YnX|r�||j�d�}qJtd||f��qJW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)�WORD_PATTERNrr�endr0�groups�DOT_PATTERN�
INDEX_PATTERN�
DIGIT_PATTERNrr)rr�restr�dr*�nr	r	r
r/�s2
zBaseConfigurator.cfg_convertcCs�t|t�r&t|t�r&t|�}||_n�t|t�rLt|t�rLt|�}||_n~t|t�rrt|t�rrt|�}||_nXt|tj	�r�|j
j|�}|r�|j�}|d}|j
j|d�}|r�|d}t||�}||�}|S)z�
        Convert values to an appropriate type. dicts, lists and tuples are
        replaced by their converting alternatives. Strings are checked to
        see if they have a conversion format and are converted if they do.
        �prefixN�suffix)r
rrrrr(rr,rZstring_types�CONVERT_PATTERNr�	groupdict�value_convertersr!r5)rrrrIrKZ	converterrLr	r	r
r�s*

zBaseConfigurator.convertcs��jd�}t|d�r8ttd�r8t|�tjkr8|j|�}�jdd�}t�fdd��D��}|f|�}|r�x |j�D]\}}t|||�qrW|S)z1Configure an object with a user-supplied factory.z()�__call__�	ClassTyper2Nc3s"|]}t|�r|�|fVqdS)N)r)�.0�k)r0r	r
�	<genexpr>sz4BaseConfigurator.configure_custom.<locals>.<genexpr>)	r#�hasattr�typesrrQrAr�items�setattr)rr0�cZprops�kwargsr r<rr	)r0r
�configure_customs
$

z!BaseConfigurator.configure_customcCst|t�rt|�}|S)z0Utility function which converts lists to tuples.)r
r(r,)rrr	r	r
�as_tuples
zBaseConfigurator.as_tupleN)r$r%r&r'�re�compilerMrBrErFrGrO�
__import__r4r1rAr.r/rr[r\r	r	r	r
r-�s 




"r-c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
ddd�Zddd�ZdS)�DictConfiguratorz]
    Configure logging using a dictionary-like object to describe the
    configuration.
    cCs�|j}d|krtd��|ddkr2td|d��|jdd�}i}tj��z||�r�|jd|�}tjdd	�dk�rx�|D]�}|tjkr�td|��qzy4tj|}||}|jdd�}|r�|j	t
|��Wqztk
�r�}	ztd
||	f��WYdd}	~	XqzXqzW|jd|�}
xZ|
D]R}y|j||
|d�Wn4tk
�rd}	ztd||	f��WYdd}	~	XnX�qW|jdd�}|�r�y|j
|d�Wn0tk
�r�}	ztd|	��WYdd}	~	XnX�n|jdd�}tjj�tjdd�=|jd|�}
xZ|
D]R}y|j|
|�|
|<Wn4tk
�rF}	ztd||	f��WYdd}	~	XnX�q�W|jd|�}xZ|D]R}y|j||�||<Wn4tk
�r�}	ztd||	f��WYdd}	~	XnX�q`W|jd|�}xht|�D]\}y |j||�}||_|||<Wn4tk
�r$}	ztd
||	f��WYdd}	~	XnX�q�Wtj}t|jj�}|j�g}|jd|�}
x�|
D]�}||k�r�|j|�}|d}t|�}t|�}|d}x<||k�r�||d|�|k�r�|j||�|d}�q�W|j|�y|j||
|�Wn4tk
�r$}	ztd||	f��WYdd}	~	XnX�q\WxF|D]>}|jj|}||k�rbtj|_g|_ d|_!n|�r2d|_"�q2W|jdd�}|�r�y|j
|�Wn0tk
�r�}	ztd|	��WYdd}	~	XnXWdtj#�XdS)zDo the configuration.�versionz$dictionary doesn't specify a versionr)zUnsupported version: %s�incrementalF�handlersN��zNo handler found with name %rrz"Unable to configure handler %r: %s�loggersTz!Unable to configure logger %r: %s�rootz#Unable to configure root logger: %sZdisable_existing_loggers�
formattersz$Unable to configure formatter %r: %s�filtersz!Unable to configure filter %r: %sr2)rdre)$r0rr#rZ_acquireLockr!r8�version_infoZ	_handlers�setLevelr�
StandardError�configure_logger�configure_root�clearZ_handlerList�configure_formatter�configure_filter�sorted�configure_handlerr<rgr(ZmanagerZ
loggerDict�sort�index�len�append�removeZNOTSETrrc�	propagateZdisabledZ_releaseLock)rr0rbZ
EMPTY_DICTrcr<ZhandlerZhandler_configrr>rfrgZdisable_existingrhriZexistingZ
child_loggers�iZprefixedZpflenZnum_existing�log�loggerr	r	r
�	configures�



"
$

$
$$



$

zDictConfigurator.configurecCs�d|krr|d}y|j|�}Wq�tk
rn}z4dt|�kr>�|jd�|d<||d<|j|�}WYdd}~Xq�Xn$|jdd�}|jdd�}tj||�}|S)z(Configure a formatter from a dictionary.z()z'format'�format�fmtNZdatefmt)r[rrr#r!rZ	Formatter)rr0�factoryr �terZdfmtr	r	r
rp�sz$DictConfigurator.configure_formattercCs.d|kr|j|�}n|jdd�}tj|�}|S)z%Configure a filter from a dictionary.z()r<�)r[r!r�Filter)rr0r r<r	r	r
rq�s

z!DictConfigurator.configure_filtercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z/Add filters to a filterer from a list of names.rizUnable to add filter %r: %sN)Z	addFilterr0rlr)rZfiltererri�fr>r	r	r
�add_filters�s

zDictConfigurator.add_filtersc-s@�jdd�}|rVy|jd|}Wn2tk
rT}ztd||f��WYdd}~XnX�jdd�}�jdd�}d�kr��jd�}t|d�r�ttd	�r�t|�tjkr�|j|�}|}n�|j�jd
��}t	|t
jj�o�d�k�r2y|jd�d�d<Wn8tk
�r.}ztd
�d|f��WYdd}~XnXnZt	|t
jj
��r`d�k�r`|j�d��d<n,t	|t
jj��r�d�k�r�|j�d��d<|}t�fdd��D��}	y|f|	�}
WnLtk
�r}z.dt|�k�r؂|	jd�|	d<|f|	�}
WYdd}~XnX|�r|
j|�|dk	�r*|
jt|��|�r<|j|
|�|
S)z&Configure a handler from a dictionary.�	formatterNrhzUnable to set formatter %r: %srriz()rPrQ�class�targetrcz#Unable to set target handler %r: %sZmailhostZaddressc3s"|]}t|�r|�|fVqdS)N)r)rRrS)r0r	r
rT�sz5DictConfigurator.configure_handler.<locals>.<genexpr>z'stream'�streamZstrm)r#r0rlrrUrVrrQrA�
issubclassrrcZ
MemoryHandlerZSMTPHandlerr\Z
SysLogHandlerrrrZsetFormatterrkrr�)rr0r�r>rrirYr��klassrZr r�r	)r0r
rs�sX
$

$



z"DictConfigurator.configure_handlercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z.Add handlers to a logger from a list of names.rczUnable to add handler %r: %sN)Z
addHandlerr0rlr)rr|rc�hr>r	r	r
�add_handlers	s

zDictConfigurator.add_handlersFcCs�|jdd�}|dk	r"|jt|��|s�x |jdd�D]}|j|�q6W|jdd�}|rd|j||�|jdd�}|r�|j||�dS)zU
        Perform configuration which is common to root and non-root loggers.
        rNrcri)r!rkrrcZ
removeHandlerr�r�)rr|r0rbrr�rcrir	r	r
�common_logger_configsz%DictConfigurator.common_logger_configcCs6tj|�}|j|||�|jdd�}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.ryN)r�	getLoggerr�r!ry)rr<r0rbr|ryr	r	r
rm#s

z!DictConfigurator.configure_loggercCstj�}|j|||�dS)z*Configure a root logger from a dictionary.N)rr�r�)rr0rbrgr	r	r
rn+szDictConfigurator.configure_rootN)F)F)F)
r$r%r&r'r}rprqr�rsr�r�rmrnr	r	r	r
r`s	5

r`cCst|�j�dS)z%Configure logging using a dictionary.N)�dictConfigClassr})r0r	r	r
�
dictConfig3sr�)Z
__future__rZlogging.handlersrr]r8rVZpip._vendorrr^�Irrrr7rrr(rr,r�objectr-r`r�r�r	r	r	r
�<module>s*	&
PK|/�\~!�A�A�server.cpython-38.pycnu�[���U

e5d��@s
dZdZdddddgZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZdd	lmZdd
l	mZdZdZGd
d�dej�ZGdd�deje�Z Gdd�dej!�Z"Gdd�de"�Z#dd�Z$da%dd�Z&dd�Z'Gdd�de#�Z(dd�Z)e"e dddfdd�Z*e+dk�rddl,Z,e,�-�Z.e.j/dd d!d"�e.j/d#d$d%d&d'�e.j/d(d)e
�0�d*d+�e.j/d,d-de1d.d/d0�e.�2�Z3e3j4�r�e(Z5nee#e3j6d1�Z5Gd2d3�d3e �Z7e*e5e7e3j8e3j9d4�dS)5a@HTTP server classes.

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections,
as of version 0.3.

Notes on CGIHTTPRequestHandler
------------------------------

This class implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
subprocess.Popen() is used as a fallback, with slightly altered semantics.

In all cases, the implementation is intentionally naive -- all
requests are executed synchronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
z0.6�
HTTPServer�ThreadingHTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�partial)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c@seZdZdZdd�ZdS)r�cCs4tj�|�|jdd�\}}t�|�|_||_dS)z.Override server_bind to store the server name.N�)�socketserver�	TCPServer�server_bindZserver_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�#/usr/lib64/python3.8/http/server.pyr
�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressr
rrrrr�sc@seZdZdZdS)rTN)rrrZdaemon_threadsrrrrr�sc
@sJeZdZdZdej��dZdeZ	e
ZeZ
dZdd�Zdd	�Zd
d�Zdd
�ZdFdd�ZdGdd�ZdHdd�Zdd�Zdd�Zdd�ZdIdd�Zdd�Ze�d d!�e�ed"�ed#d$��D��Z d%e e!d&�<d'd(�Z"d)d*�Z#dJd+d,�Z$d-d.�Z%d/d0d1d2d3d4d5gZ&dd6d7d8d9d:d;d<d=d>d?d@dAg
Z'dBdC�Z(dDZ)e*j+j,Z-dEd!�e.j/�0�D�Z1dS)Kra�HTTP request handler base class.

    The following explanation of HTTP serves to guide you through the
    code as well as to expose any misunderstandings I may have about
    HTTP (so you don't need to read the code to figure out I'm wrong
    :-).

    HTTP (HyperText Transfer Protocol) is an extensible protocol on
    top of a reliable stream transport (e.g. TCP/IP).  The protocol
    recognizes three parts to a request:

    1. One line identifying the request type and path
    2. An optional set of RFC-822-style headers
    3. An optional data part

    The headers and data are separated by a blank line.

    The first line of the request has the form

    <command> <path> <version>

    where <command> is a (case-sensitive) keyword such as GET or POST,
    <path> is a string containing path information for the request,
    and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
    <path> is encoded using the URL encoding scheme (using %xx to signify
    the ASCII character with hex code xx).

    The specification specifies that lines are separated by CRLF but
    for compatibility with the widest range of clients recommends
    servers also handle LF.  Similarly, whitespace in the request line
    is treated sensibly (allowing multiple spaces between components
    and allowing trailing whitespace).

    Similarly, for output, lines ought to be separated by CRLF pairs
    but most clients grok LF characters just fine.

    If the first line of the request has the form

    <command> <path>

    (i.e. <version> is left out) then this is assumed to be an HTTP
    0.9 request; this form has no optional headers and data part and
    the reply consists of just the data.

    The reply form of the HTTP 1.x protocol again has three parts:

    1. One line giving the response code
    2. An optional set of RFC-822-style headers
    3. The data

    Again, the headers and data are separated by a blank line.

    The response code line has the form

    <version> <responsecode> <responsestring>

    where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
    <responsecode> is a 3-digit response code indicating success or
    failure of the request, and <responsestring> is an optional
    human-readable string explaining what the response code means.

    This server parses the request and the headers, and then calls a
    function specific to the request type (<command>).  Specifically,
    a request SPAM will be handled by a method do_SPAM().  If no
    such method exists the server sends an error response to the
    client.  If it exists, it is called with no arguments:

    do_SPAM()

    Note that the request name is case sensitive (i.e. SPAM and spam
    are different requests).

    The various request details are stored in instance variables:

    - client_address is the client IP address in the form (host,
    port);

    - command, path and version are the broken-down request line;

    - headers is an instance of email.message.Message (or a derived
    class) containing the header information;

    - rfile is a file object open for reading positioned at the
    start of the optional input data part;

    - wfile is a file object open for writing.

    IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

    The first thing to be written must be the response line.  Then
    follow 0 or more header lines, then a blank line, and then the
    actual data (if any).  The meaning of the header lines depends on
    the command executed by the server; in most cases, when data is
    returned, there should be at least one header line of the form

    Content-type: <type>/<subtype>

    where <type> and <subtype> should be registered MIME types,
    e.g. "text/html" or "text/plain".

    zPython/rz	BaseHTTP/�HTTP/0.9c
Cs�d|_|j|_}d|_t|jd�}|�d�}||_|��}t	|�dkrLdSt	|�dk�r&|d}zT|�
d	�srt�|�d
d�d}|�d�}t	|�d
kr�t�t|d�t|d�f}Wn,tt
fk
r�|�tjd|�YdSX|dk�r|jdk�rd|_|dk�r |�tjd|�dS||_d
t	|�k�rBdk�sZn|�tjd|�dS|dd
�\}}t	|�d
k�r�d|_|dk�r�|�tjd|�dS|||_|_|j�
d��r�d
|j�d
�|_ztjj|j|jd�|_Wn�tjjk
�r(}z|�tjdt|��WY�dSd}~XYnBtjjk
�rh}z|�tjdt|��WY�dSd}~XYnX|j�dd�}	|	��dk�r�d|_n |	��dk�r�|jdk�r�d|_|j�dd�}
|
��dk�r�|jdk�r�|jdk�r�|� ��s�dSdS) aHParse a request (internal).

        The request should be stored in self.raw_requestline; the results
        are in self.command, self.path, self.request_version and
        self.headers.

        Return True for success, False for failure; on failure, any relevant
        error response has already been sent back.

        NTz
iso-8859-1z
rF����zHTTP/�/r	�.r
zBad request version (%r))r	r	zHTTP/1.1)r
rzInvalid HTTP version (%s)zBad request syntax (%r)ZGETzBad HTTP/0.9 request type (%r)z//)Z_classz
Line too longzToo many headers�
Connection��close�
keep-aliveZExpectz100-continue)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
startswith�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr)�wordsZbase_version_numberZversion_numberr"r2�errZconntypeZexpectrrr�
parse_requests�


�
��
�
������
z$BaseHTTPRequestHandler.parse_requestcCs|�tj�|��dS)a7Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        T)�send_response_onlyrZCONTINUE�end_headers�rrrrr;xsz(BaseHTTPRequestHandler.handle_expect_100c
Cs�z�|j�d�|_t|j�dkrBd|_d|_d|_|�tj	�WdS|jsTd|_
WdS|��sbWdSd|j}t||�s�|�tj
d|j�WdSt||�}|�|j��Wn<tjk
r�}z|�d|�d|_
WY�dSd}~XYnXdS)	z�Handle a single HTTP request.

        You normally don't need to override this method; see the class
        __doc__ string for information on how to handle specific HTTP
        commands such as GET and POST.

        iirNTZdo_zUnsupported method (%r)zRequest timed out: %r)r6�readliner'r+r)r$r"r0rZREQUEST_URI_TOO_LONGr%r?�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushrZtimeout�	log_error)rZmname�method�errr�handle_one_request�s6

�
z)BaseHTTPRequestHandler.handle_one_requestcCs"d|_|��|js|��qdS)z&Handle multiple requests if necessary.TN)r%rLrBrrr�handle�szBaseHTTPRequestHandler.handleNcCsz|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|�d||�|�||�|�dd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d	�}|�d
d�}|�d|j
�|�d
tt|���|��|jdk�r|�r|j�|�dS)akSend and log an error reply.

        Arguments are
        * code:    an HTTP error code
                   3 digits
        * message: a simple optional 1 line reason phrase.
                   *( HTAB / SP / VCHAR / %x80-FF )
                   defaults to short entry matching the response code
        * explain: a detailed message defaults to the long entry
                   matching the response code.

        This sends an error response (so it must be called before any
        output has been generated), logs the error, and finally sends
        a piece of HTML explaining the error to the user.

        )�???rNNzcode %d, message %srr ��F��quote)�code�message�explainzUTF-8�replacezContent-Type�Content-LengthZHEAD)�	responses�KeyErrorrI�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENT�NOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer&r+rAr"rG�write)rrRrSrTZshortmsgZlongmsgZbodyZcontentrrrr0�s:���z!BaseHTTPRequestHandler.send_errorcCs:|�|�|�||�|�d|���|�d|���dS)z�Add the response header to the headers buffer and log the
        response code.

        Also send two standard headers with the server software
        version and the current date.

        ZServerZDateN)�log_requestr@rZ�version_string�date_time_string�rrRrSrrrrY�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|j�d|j||f�dd��dS)	zSend the response header only.rNrr�_headers_bufferz
%s %d %s
�latin-1�strict)r$rWrDrf�appendr1r_rerrrr@�s



��z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|j�d||f�dd��|��dkrh|��dkrVd|_n|��d	krhd
|_dS)z)Send a MIME header to the headers buffer.rrfz%s: %s
rgrhZ
connectionr Tr!FN)r$rDrfrir_r:r%)r�keyword�valuerrrrZs

�z"BaseHTTPRequestHandler.send_headercCs"|jdkr|j�d�|��dS)z,Send the blank line ending the MIME headers.rs
N)r$rfri�
flush_headersrBrrrrAs
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|j�d�|j��g|_dS)Nrf�)rDrGra�joinrfrBrrrrls
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|�d|jt|�t|��dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)�
isinstancerrk�log_messager)r&)rrR�sizerrrrb s
�z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS)z�Log an error.

        This is called when a request cannot be fulfilled.  By
        default it passes the message on to log_message().

        Arguments are the same as for log_message().

        XXX This should go to the separate error log.

        N)rq)r�format�argsrrrrI+sz BaseHTTPRequestHandler.log_errorcCsi|]}|d|d���qS)z\xZ02xr)�.0�crrr�
<dictcomp>;sz!BaseHTTPRequestHandler.<dictcomp>� ��z\\�\cGs2||}tj�d|��|��|�|j�f�dS)aZLog an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        Unicode control characters are replaced with escaped hex
        before writing the output to stderr.

        z%s - - [%s] %s
N)�sys�stderrra�address_string�log_date_time_string�	translate�_control_char_table)rrsrtrSrrrrq>s
��z"BaseHTTPRequestHandler.log_messagecCs|jd|jS)z*Return the server software version string.� )�server_version�sys_versionrBrrrrcXsz%BaseHTTPRequestHandler.version_stringcCs |dkrt��}tjj|dd�S)z@Return the current date and time formatted for a message header.NT)Zusegmt)�time�email�utilsZ
formatdate)rZ	timestamprrrrd\sz'BaseHTTPRequestHandler.date_time_stringc	CsBt��}t�|�\	}}}}}}}}	}
d||j|||||f}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)r��	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrrbs�z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)zReturn the client address.r)�client_addressrBrrrr~psz%BaseHTTPRequestHandler.address_string�HTTP/1.0cCsi|]}||j|jf�qSr)�phraseZdescription)ru�vrrrrws�)NN)N)N)roro)N)2rrr�__doc__r|r<r*r��__version__r��DEFAULT_ERROR_MESSAGEr\�DEFAULT_ERROR_CONTENT_TYPEr`r#r?r;rLrMr0rYr@rZrArlrbrIr&�	maketrans�	itertools�chain�ranger��ordrqrcrdrZweekdaynamer�r~r1r4r5ZHTTPMessager7r�__members__�valuesrWrrrrr�s^gj%
5


�
�	�cs�eZdZdZdeZdd��fdd�
Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ejsle��ej��Ze�ddddd���ZS)raWSimple HTTP request handler with GET and HEAD commands.

    This serves files from the current directory and any of its
    subdirectories.  The MIME type for files is determined by
    calling the .guess_type() method.

    The GET and HEAD requests are identical except that the HEAD
    request omits the actual contents of the file.

    zSimpleHTTP/N��	directorycs(|dkrt��}||_t�j||�dS�N)�os�getcwdr��super�__init__)rr�rt�kwargs��	__class__rrr��sz!SimpleHTTPRequestHandler.__init__cCs.|��}|r*z|�||j�W5|��XdS)zServe a GET request.N)�	send_headr �copyfilerG�r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|��}|r|��dS)zServe a HEAD request.N)r�r r�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADcCs^|�|j�}d}tj�|�r�tj�|j�}|j�d�s�|�t	j
�|d|d|dd|d|df}tj�|�}|�d|�|�
�dSd	D]&}tj�||�}tj�|�r�|}q�q�|�|�S|�|�}|�d�r�|�t	jd
�dSzt|d�}Wn&tk
�r|�t	jd
�YdSX�z"t�|���}d|jk�r�d
|jk�r�ztj�|jd�}	Wnttttfk
�r|YnzX|	j dk�r�|	j!t"j#j$d�}	|	j t"j#j$k�r�t"j"�%|j&t"j#j$�}
|
j!dd�}
|
|	k�r�|�t	j'�|�
�|�(�WdS|�t	j)�|�d|�|�dt*|d��|�d|�+|j&��|�
�|WS|�(��YnXdS)a{Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.

        Nrrr	r
r�ZLocation)z
index.htmlz	index.htmzFile not found�rbzIf-Modified-Sincez
If-None-Match)�tzinfo)Zmicrosecond�Content-typerV�z
Last-Modified),�translate_pathr2r��isdir�urllib�parseZurlsplit�endswithrYrZMOVED_PERMANENTLYZ
urlunsplitrZrArn�exists�list_directory�
guess_typer0�	NOT_FOUND�open�OSError�fstat�filenor8r�r�Zparsedate_to_datetime�	TypeErrorr/�
OverflowErrorr-r�rU�datetime�timezoneZutcZ
fromtimestamp�st_mtimer[r �OKr&rd)rr2r��partsZ	new_partsZnew_url�indexZctypeZfsZimsZ
last_modifrrrr��s��


���

�z"SimpleHTTPRequestHandler.send_headc
	Cs�zt�|�}Wn$tk
r2|�tjd�YdSX|jdd�d�g}ztjj	|j
dd�}Wn"tk
r�tj�	|j
�}YnXtj
|dd	�}t��}d
|}|�d�|�d�|�d
|�|�d|�|�d|�|�d�|D]v}tj
�||�}|}	}
tj
�|��r$|d}	|d}
tj
�|��r:|d}	|�dtjj|
dd�tj
|	dd	�f�q�|�d�d�|��|d�}t��}|�|�|�d�|�tj�|�dd|�|�dtt|���|��|S)z�Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        zNo permission to list directoryNcSs|��Sr�)r:)�arrr�<lambda>rmz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass��errorsFrPzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperr�ztext/html; charset=%srV) r��listdirr�r0rr��sortr�r��unquoter2�UnicodeDecodeErrorr]r^r|�getfilesystemencodingrirnr��islinkrQr_�io�BytesIOra�seekrYr�rZr&r+rA)
rr2�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr�sh�
�


�
���


z'SimpleHTTPRequestHandler.list_directorycCs�|�dd�d}|�dd�d}|���d�}ztjj|dd�}Wn tk
rbtj�|�}YnXt�|�}|�d�}t	d|�}|j
}|D]0}tj�
|�s�|tjtjfkr�q�tj�||�}q�|r�|d7}|S)	z�Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        �?r	r�#rr�r�N)r*r(r�r�r�r�r��	posixpath�normpath�filterr�r�r2�dirname�curdir�pardirrn)rr2Ztrailing_slashr=Zwordrrrr�:s$	


z'SimpleHTTPRequestHandler.translate_pathcCst�||�dS)a�Copy all data between two file objects.

        The SOURCE argument is a file object open for reading
        (or anything with a read() method) and the DESTINATION
        argument is a file object open for writing (or
        anything with a write() method).

        The only reason for overriding this would be to change
        the block size or perhaps to replace newlines by CRLF
        -- note however that this the default server uses this
        to copy binary data as well.

        N)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�Xsz!SimpleHTTPRequestHandler.copyfilecCsLt�|�\}}||jkr"|j|S|��}||jkr>|j|S|jdSdS)a�Guess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.

        rN)r��splitext�extensions_mapr:)rr2�baseZextrrrr�hs



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)r�.pyz.cz.h)rrrr�r�r�r�r�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��update�
__classcell__rrr�rr�s&	W:
�c	Cs�|�d�\}}}tj�|�}|�d�}g}|dd�D],}|dkrL|��q6|r6|dkr6|�|�q6|r�|��}|r�|dkr�|��d}q�|dkr�d}nd}|r�d�||f�}dd�|�|f}d�|�}|S)a�
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a collapsed path.

    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.

    Returns: The reconstituted URL, which will always start with a '/'.

    Raises: IndexError if too many '..' occur within the path.

    r�rNrz..rr)�	partitionr�r�r�r*�poprirn)	r2�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_path�s.


r�cCsrtrtSzddl}Wntk
r*YdSXz|�d�daWn.tk
rldtdd�|��D��aYnXtS)	z$Internal routine to get nobody's uidrNr�nobodyr
r	css|]}|dVqdS)r
Nr)rur�rrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>)r��pwd�ImportError�getpwnamrX�maxZgetpwall)r�rrr�
nobody_uid�s r�cCst�|tj�S)zTest for executable file.)r��access�X_OK)r2rrr�
executable�src@sVeZdZdZeed�ZdZdd�Zdd�Z	dd	�Z
d
dgZdd
�Zdd�Z
dd�ZdS)rz�Complete HTTP server with GET, HEAD and POST commands.

    GET and HEAD also support running CGI scripts.

    The POST command is *only* implemented for CGI scripts.

    �forkrcCs$|��r|��n|�tjd�dS)zRServe a POST request.

        This is only implemented for CGI scripts.

        zCan only POST to CGI scriptsN)�is_cgi�run_cgir0rrErBrrr�do_POST�s
�zCGIHTTPRequestHandler.do_POSTcCs|��r|��St�|�SdS)z-Version of send_head that support CGI scriptsN)rrrr�rBrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|�dd�}|d|�||dd�}}||jkrL||f|_dSdS)a3Test whether self.path corresponds to a CGI script.

        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.

        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.

        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).

        rr	NTF)r�r2�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr�s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�S)z1Test whether argument path is an executable file.)r)rr2rrr�
is_executablesz#CGIHTTPRequestHandler.is_executablecCstj�|�\}}|��dkS)z.Test whether argument path is a Python script.)r�z.pyw)r�r2r�r:)rr2r
rrrr�	is_pythonszCGIHTTPRequestHandler.is_pythonc)	Cs�|j\}}|d|}|�dt|�d�}|dkr�|d|�}||dd�}|�|�}tj�|�r�||}}|�dt|�d�}q*q�q*|�d�\}}}	|�d�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|�|�}tj�|��s
|�	t
jd|�dStj�|��s.|�	t
j
d|�dS|�|�}
|j�sF|
�sh|�|��sh|�	t
j
d	|�dSt�tj�}|��|d
<|jj|d<d|d
<|j|d<t|jj�|d<|j|d<tj�|�}||d<|�|�|d<||d<|	�r�|	|d<|jd|d<|j� d�}|�r�|�!�}t|�dk�r�ddl"}ddl#}|d|d<|d�$�dk�r�z"|d�%d�}|�&|��'d�}Wn|j(t)fk
�r�Yn&X|�!d�}t|�dk�r�|d|d<|j� d�dk�r�|j�*�|d<n|jd|d<|j� d�}|�r||d <|j� d!�}|�r||d"<g}|j�+d#�D]>}|dd�d$k�rR|�,|�-��n||d%d��!d&�}�q,d&�.|�|d'<|j� d(�}|�r�||d)<t/d|j�0d*g��}d+�.|�}|�r�||d,<d-D]}|�1|d��q�|�2t
j3d.�|�4�|	�5d/d0�}|j�r|
g}d1|k�r|�,|�t6�}|j7�8�t�9�}|dk�r�t�:|d�\}}t;�;|j<gggd�d�r~|j<�=d��sN�q~�qN|�r�|�>d2|�dSz\zt�?|�Wnt@k
�r�YnXt�A|j<�B�d�t�A|j7�B�d�t�C|||�Wn(|j�D|jE|j�t�Fd3�YnX�n�ddlG} |g}!|�|��rrtHjI}"|"�$��Jd4��rf|"dd5�|"d6d�}"|"d7g|!}!d1|	k�r�|!�,|	�|�Kd8| �L|!��ztM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d9�}$|j�$�d:k�r|#dk�r|j<�=|#�}%nd}%t;�;|j<jRgggd�d�r>|j<jR�Sd��s
�q>�q
|$�T|%�\}&}'|j7�U|&�|'�rj|�>d;|'�|$jV�W�|$jX�W�|$jY}(|(�r�|�>d2|(�n
|�Kd<�dS)=zExecute a CGI script.rr	rNr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationr
Z	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE)rZREMOTE_HOSTrrrrzScript output follows�+r��=zCGI script exit status %#xryzw.exe������z-uzcommand: %s)�stdin�stdoutr}�envZpostz%szCGI script exited OK)Zr	rr+r�r�r2r�r�r�r0rr��isfileZ	FORBIDDENr
�	have_forkrr�Zdeepcopy�environrcZserverrr1r&rr"r�r�r�r�r8r9r*�base64�binasciir:r_Zdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersri�striprnr�Zget_all�
setdefaultrYr�rlrUr�rGrHr�waitpid�selectr6�readrI�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessr|rr�rqZlist2cmdliner.r�r-�Popen�PIPEZ_sockZrecvZcommunicaterar}r r�
returncode))r�dir�restr2�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyr Zuqrestrr$r%Zlengthrr�lineZua�coZ
cookie_str�kZ
decoded_queryrtr��pid�stsr2ZcmdlineZinterp�nbytes�p�datarr}Zstatusrrrrs<





��
�


�








�

zCGIHTTPRequestHandler.run_cgiN)rrrr�rDr�r"Zrbufsizerr�rrrr
rrrrrr�s	
cGs4tj|tjtjd��}tt|��\}}}}}||fS)N)�type�flags)rZgetaddrinfoZSOCK_STREAMZ
AI_PASSIVE�next�iter)ZaddressZinfosZfamilyrA�protoZ	canonnameZsockaddrrrr�_get_best_family�s�rFr�i@c	Cs�t||�\|_}||_|||���}|j��dd�\}}d|krLd|�d�n|}td|�d|�d|�d|�d	�	�z|��Wn&tk
r�td
�t�	d�YnXW5QRXdS)zmTest the HTTP request handler class.

    This runs an HTTP server on port 8000 (or the port argument).

    Nr
r�[�]zServing HTTP on z port z	 (http://z/) ...z&
Keyboard interrupt received, exiting.r)
rFZaddress_familyr1rZgetsockname�printZ
serve_forever�KeyboardInterruptr|�exit)	�HandlerClass�ServerClassZprotocolr�bindZaddrZhttpdrZurl_hostrrr�test�s�rO�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�metavarrSz--directoryz-dz9Specify alternative directory [default:current directory])�defaultrSrZstorer�z&Specify alternate port [default: 8000])rRrUrA�nargsrSr�cseZdZ�fdd�Z�ZS)�DualStackServerc	s4t�t��|j�tjtjd�W5QRXt���S)Nr)	�
contextlib�suppress�	ExceptionrZ
setsockoptZIPPROTO_IPV6ZIPV6_V6ONLYr�r
rBr�rrr
s�zDualStackServer.server_bind)rrrr
r�rrr�rrWsrW)rLrMrrN):r�r��__all__r�r�Zemail.utilsr�r]Zhttp.clientr4r�r�r�r�r�r,r�rrr|r�Zurllib.parser�rX�	functoolsrrr�r�rrZThreadingMixInrZStreamRequestHandlerrrr�r�r�rrrFrOr�argparse�ArgumentParser�parser�add_argumentr�r.�
parse_argsrtZcgiZ
handler_classr�rWrrNrrrr�<module>s�R�s
0
�

�
�����PK|/�\I���cookiejar.cpython-38.pycnu�[���U

e5d#,�@sdZddddddddgZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
l	Zd	d
l
Zd	d
lZ
d	dlmZdZd
ad
d�Zee
jj�ZdZdd�ZdZdd�ZdddddddgZddddd d!d"d#d$d%d&d'gZgZeD]Ze�e� ��q�dud(d)�Z!dvd*d+�Z"d
d
d
d
d,�Z#e�$d-ej%�Z&d.d/�Z'd0d1�Z(e�$d2ej%�Z)e�$d3ej*ej%B�Z+e�$d4ej,ej%B�Z-d5d6�Z.e�$d7ej,ej%B�Z/d8d9�Z0d:d;�Z1e�$d<�Z2e�$d=�Z3e�$d>�Z4e�$d?�Z5d@dA�Z6e�$dB�Z7dCdD�Z8dEdF�Z9dGdH�Z:e�$dIej%�Z;dJdK�Z<dLdM�Z=dNdO�Z>dPdQ�Z?e�$dRej%�Z@dSdT�ZAdUdV�ZBdWdX�ZCdYdZ�ZDd[ZEe�$d\�ZFd]d^�ZGd_d`�ZHdadb�ZIdcdd�ZJGded�d�ZKGdfd�d�ZLGdgd�deL�ZMdhdi�ZNdjdk�ZOGdldm�dm�ZPGdnd�d�ZQGdod�deR�ZSGdpd�deQ�ZTdqdr�ZUGdsd�deT�ZVGdtd�deT�ZWd
S)wa�HTTP cookie handling for web clients.

This module has (now fairly distant) origins in Gisle Aas' Perl module
HTTP::Cookies, from the libwww-perl library.

Docstrings, comments and debug strings in this code refer to the
attributes of the HTTP cookie system as cookie-attributes, to distinguish
them clearly from Python attributes.

Class diagram (note that BSDDBCookieJar and the MSIE* classes are not
distributed with the Python standard library, but are available from
http://wwwsearch.sf.net/):

                        CookieJar____
                        /     \      \
            FileCookieJar      \      \
             /    |   \         \      \
 MozillaCookieJar | LWPCookieJar \      \
                  |               |      \
                  |   ---MSIEBase |       \
                  |  /      |     |        \
                  | /   MSIEDBCookieJar BSDDBCookieJar
                  |/
               MSIECookieJar

�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|�d�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�&/usr/lib64/python3.8/http/cookiejar.py�_debug,s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|��}|�d|�|��}|jd|dd�dS)Nr	zhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)rrr�f�msgrrr�_warn_unhandled_exception:s
ri�cCs�|dd�\}}}}}}|tkr�d|kr4dkr�nnhd|krLdkr�nnPd|krddkr�nn8d|kr|dkr�nn d|kr�dkr�nnt|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmIs&8��
��
��
r,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtj��}ntj�|�}d|j|j|j|j|j|jfS)aHReturn a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
    representing Universal Time (UTC, aka GMT).  An example of this format is:

    1994-11-24 08:49:37Z

    Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second��tZdtrrr�	time2isozWs�r5cCsR|dkrtj��}ntj�|�}dt|��|jt|jd|j|j	|j
|jfS)z�Return a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like this:

    Wed, DD-Mon-YYYY HH:MM:SS GMT

    Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2r3rrr�
time2netscapejs
�r8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTt�|�}|rfdt|�d��}|�d�rR|dt|�d��}|�d�dkrf|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s

rFc
Cs�t|�}|tjkrdSzt�|���d}Wn^tk
r�zt|�}Wntk
r`YYdSXd|krvdkr�nn|}nYdSYnX|dkr�d}|dkr�d}|dkr�d}t|�}t|�}t|�}t|�}|dk�r6t�t���d}|d}	|}
|||	}|	|
}	t	|	�dk�r6|	dk�r.|d}n|d}t
|||||||f�}|dk	�r�|dk�rdd}|��}t|�}|dk�r�dS||}|S)Nrr r	i��d�2r9)
rAr-ZMAXYEAR�MONTHS_LOWER�index�lower�
ValueError�time�	localtime�absr,�upperrF)
r0�mon�yr�hrr*r+rCZimonZcur_yrrEZtmpr4rDrrr�	_str2time�sV







rTzV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    (?:
       ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
       \s*
    )?
    (?:
       \(\w+\)         # ASCII representation of timezone in parens.
       \s*
    )?$cCs�t�|�}|rl|��}t�|d���d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|�	�}t
�d|d�}dgd	\}}}}}}	}
t�|�}|dk	r�|��\}}}}}}	}
ndSt
||||||	|
�S)
a�Returns time in seconds since epoch of time represented by a string.

    Return value is an integer.

    None is returned if the format of str is unrecognized, the time is outside
    the representable range, or the timezone string is not recognized.  If the
    string contains no timezone, UTC is assumed.

    The timezone in the string may be numerical (like "-0800" or "+0100") or a
    string timezone (like "UTC", "GMT", "BST" or "EST").  Currently, only the
    timezone strings equivalent to UTC (zero offset) are known to the function.

    The function loosely parses the following formats:

    Wed, 09 Feb 1994 22:23:32 GMT       -- HTTP format
    Tuesday, 08-Feb-94 14:15:29 GMT     -- old rfc850 HTTP format
    Tuesday, 08-Feb-1994 14:15:29 GMT   -- broken rfc850 HTTP format
    09 Feb 1994 22:23:32 GMT            -- HTTP format (no weekday)
    08-Feb-94 14:15:29 GMT              -- rfc850 format (no weekday)
    08-Feb-1994 14:15:29 GMT            -- broken rfc850 format (no weekday)

    The parser ignores leading and trailing whitespace.  The time may be
    absent.

    If the year is given with only 2 digits, the function will select the
    century that makes the year closest to the current date.

    rrr	r;���N�)�STRICT_DATE_REr@�groupsrIrJrKrA�floatr,�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_RErT)�textrE�grQr&r0rRrSr*r+rCrrr�	http2time�s$



�
rba�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   (?:
      ([-+]?\d\d?:?(:?\d\d)?
       |Z|z)             # timezone  (Z is "zero meridian", i.e. GMT)
      \s*
   )?$c
Csd|��}dgd\}}}}}}}t�|�}|dk	rL|��\}}}}}}}}	ndSt|||||||�S)av
    As for http2time, but parses the ISO 8601 formats:

    1994-02-03 14:15:29 -0100    -- ISO 8601 format
    1994-02-03 14:15:29          -- zone is optional
    1994-02-03                   -- only date
    1994-02-03T14:15:29          -- Use T as separator
    19940203T141529Z             -- ISO 8601 compact format
    19940203                     -- only date

    NrX)r\�ISO_DATE_REr@rZrT)
r`r0rQrRrSr*r+rCrE�_rrr�iso2time+s

recCs*|�d�\}}|jd|�|j|d�S)z)Return unmatched part of re.Match object.r	N)�span�string)�match�start�endrrr�	unmatchedLsrkz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Cs0t|t�rt�g}|D�]}|}g}|�rt�|�}|r�t|�}|�d�}t�|�}|rxt|�}|�d�}t�	d|�}n.t
�|�}|r�t|�}|�d�}|��}nd}|�||f�q$|�
��d�r�|�
�dd�}|r�|�|�g}q$t�dd|�\}}	|	dk�std|||f��|}q$|r|�|�q|S)	amParse header values into a list of lists containing key,value pairs.

    The function knows how to deal with ",", ";" and "=" as well as quoted
    values after "=".  A list of space separated tokens are parsed as if they
    were separated by ";".

    If the header_values passed as argument contains multiple values, then they
    are treated as if they were a single value separated by comma ",".

    This means that this function is useful for parsing header fields that
    follow this syntax (BNF as from the HTTP/1.1 specification, but we relax
    the requirement for tokens).

      headers           = #header
      header            = (token | parameter) *( [";"] (token | parameter))

      token             = 1*<any CHAR except CTLs or separators>
      separators        = "(" | ")" | "<" | ">" | "@"
                        | "," | ";" | ":" | "\" | <">
                        | "/" | "[" | "]" | "?" | "="
                        | "{" | "}" | SP | HT

      quoted-string     = ( <"> *(qdtext | quoted-pair ) <"> )
      qdtext            = <any TEXT except <">>
      quoted-pair       = "\" CHAR

      parameter         = attribute "=" value
      attribute         = token
      value             = token | quoted-string

    Each header is represented by a list of key/value pairs.  The value for a
    simple token (not part of a parameter) is None.  Syntactically incorrect
    headers will not necessarily be parsed as you would want.

    This is easier to describe with some examples:

    >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz'])
    [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]]
    >>> split_header_words(['text/html; charset="iso-8859-1"'])
    [[('text/html', None), ('charset', 'iso-8859-1')]]
    >>> split_header_words([r'Basic realm="\"foo\bar\""'])
    [[('Basic', None), ('realm', '"foobar"')]]

    rz\1N�,z^[=\s;]*rWr	z&split_header_words bug: '%s', '%s', %s)�
isinstance�str�AssertionError�HEADER_TOKEN_REr@rkrB�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr^�HEADER_VALUE_RE�rstrip�appendr\�
startswith�re�subn)
Z
header_values�resultr`Z	orig_text�pairsrE�name�valueZnon_junkZ
nr_junk_charsrrr�split_header_wordsUsJ-








��r}�([\"\\])cCs|g}|D]h}g}|D]F\}}|dk	rPt�d|�sDt�d|�}d|}d||f}|�|�q|r|�d�|��qd�|�S)a�Do the inverse (almost) of the conversion done by split_header_words.

    Takes a list of lists of (key, value) pairs and produces a single header
    value.  Attribute values are quoted if needed.

    >>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]])
    'text/plain; charset="iso-8859-1"'
    >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]])
    'text/plain, charset="iso-8859-1"'

    Nz^\w+$�\\\1z"%s"�%s=%s�; �, )rwr@�HEADER_JOIN_ESCAPE_REr^ru�join)Zlists�headersrz�attr�k�vrrr�join_header_words�sr�cCs0|�d�r|dd�}|�d�r,|dd�}|S)N�"r���)rv�endswith�r`rrr�strip_quotes�s


r�cCs�d}g}|D]�}g}d}t|�d��D]�\}}|��}|�d�\}}	}
|��}|sb|dkr&q�nq&|	rn|
��nd}
|dkr�|��}||kr�|}|dkr�|
dk	r�t|
�}
d}n|d	kr�|
dk	r�tt|
��}
|�||
f�q&|r|s�|�d
�|�|�q|S)a5Ad-hoc parser for Netscape protocol cookie-attributes.

    The old Netscape cookie format for Set-Cookie can for instance contain
    an unquoted "," in the expires field, so we have to use this ad-hoc
    parser instead of split_header_words.

    XXX This may not make the best possible effort to parse all the crap
    that Netscape Cookie headers contain.  Ronald Tschalar's HTTPClient
    parser is probably better, so could do worse than following that if
    this ever gives any trouble.

    Currently, this is also used for parsing RFC 2109 cookies.

    )�expires�domain�path�secure�version�port�max-ageF�;�=r	Nr�Tr�)r��0)�	enumerate�split�strip�	partitionrKr�rbru)Z
ns_headersZknown_attrsryZ	ns_headerrz�version_setZiiZparam�key�sep�val�lcrrr�parse_ns_headers�s>
r�z\.\d+$cCs:t�|�rdS|dkrdS|ddks2|ddkr6dSdS)z*Return True if text is a host domain name.FrWr	�.r�T��IPV4_REr@r�rrr�is_HDNs
r�cCsl|��}|��}||krdSt|�s(dS|�|�}|dksB|dkrFdS|�d�sTdSt|dd��shdSdS)a�Return True if domain A domain-matches domain B, according to RFC 2965.

    A and B may be host domain names or IP addresses.

    RFC 2965, section 1:

    Host names can be specified either as an IP address or a HDN string.
    Sometimes we compare one host name with another.  (Such comparisons SHALL
    be case-insensitive.)  Host A's name domain-matches host B's if

         *  their host name strings string-compare equal; or

         * A is a HDN string and has the form NB, where N is a non-empty
            name string, B has the form .B', and B' is a HDN string.  (So,
            x.y.com domain-matches .Y.com but not Y.com.)

    Note that domain-match is not a commutative operation: a.b.c.com
    domain-matches .c.com, but not the reverse.

    TFr�r	r�rN)rKr��rfindrv)�A�B�irrr�domain_matchs

r�cCst�|�rdSdS)zdReturn True if text is a sort-of-like a host domain name.

    For accepting/blocking domains.

    FTr�r�rrr�liberal_is_HDNFs
r�cCs`|��}|��}t|�r t|�s0||kr,dSdS|�d�}|rL|�|�rLdS|s\||kr\dSdS)z\For blocking/accepting domains.

    A and B may be host domain names or IP addresses.

    TFr�)rKr�rvr�)r�r��initial_dotrrr�user_domain_matchPs
r�z:\d+$cCsB|��}tj�|�d}|dkr,|�dd�}t�d|d�}|��S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    rrWZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer^rK)�request�url�hostrrr�request_hostesr�cCs4t|�}}|�d�dkr,t�|�s,|d}||fS)zzReturn a tuple (request-host, effective request-host name).

    As defined by RFC 2965, except both are lowercased.

    r�r��.local)r��findr�r@)r��erhn�req_hostrrr�eff_request_hostusr�cCs4|��}tj�|�}t|j�}|�d�s0d|}|S)z6Path component of request-URI, as defined by RFC 2965.�/)r�r�r�Zurlsplit�escape_pathr�rv)r�r��partsr�rrr�request_path�s

r�cCs`|j}|�d�}|dkrX||dd�}zt|�Wq\tk
rTtd|�YdSXnt}|S)N�:r	rznonnumeric port: '%s')r�r�rArLr�DEFAULT_HTTP_PORT)r�r�r�r�rrr�request_port�s


r�z%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|�d���S)Nz%%%sr)rBrP)rhrrr�uppercase_escaped_char�sr�cCstj�|t�}t�t|�}|S)zEEscape any invalid characters in HTTP URL, and uppercase all escapes.)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr^r�)r�rrrr��s
r�cCsP|�d�}|dkrL||dd�}|�d�}t|�rL|dksD|dkrLd|S|S)aBReturn reach of host h, as defined by RFC 2965, section 1.

    The reach R of a host name H is defined as follows:

       *  If

          -  H is the host domain name of a host; and,

          -  H has the form A.B; and

          -  A has no embedded (that is, interior) dots; and

          -  B has at least one embedded dot, or B is the string "local".
             then the reach of H is .B.

       *  Otherwise, the reach of H is H.

    >>> reach("www.acme.com")
    '.acme.com'
    >>> reach("acme.com")
    'acme.com'
    >>> reach("acme.local")
    '.local'

    r�r	rNZlocal)r�r�)�hr��brrr�reach�s

r�cCs$t|�}t|t|j��sdSdSdS)z�

    RFC 2965, section 3.3.6:

        An unverifiable transaction is to a third-party host if its request-
        host U does not domain-match the reach R of the request-host O in the
        origin transaction.

    TFN)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
r�c@sNeZdZdZddd�Zdd�Zddd	�Zd
d�Zddd
�Zdd�Z	dd�Z
dS)ra�HTTP Cookie.

    This class represents both Netscape and RFC 2965 cookies.

    This is deliberately a very simple class.  It just holds attributes.  It's
    possible to construct Cookie instances that don't comply with the cookie
    standards.  CookieJar.make_cookies is the factory function for Cookie
    objects -- it deals with cookie parsing, supplying defaults, and
    normalising to the representation used in this class.  CookiePolicy is
    responsible for checking them to see whether they should be accepted from
    and returned to the server.

    Note that the port may be present in the headers, but unspecified ("Port"
    rather than"Port=80", for example); if this is the case, port is None.

    FcCs�|dk	rt|�}|dk	r$tt|��}|dkr<|dkr<td��||_||_||_||_||_|��|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_t�|�|_dS)NTz-if port is None, port_specified must be false)rAr[rLr�r{r|r��port_specifiedrKr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�r{r|r�r�r�r�r�r�r�r�r�r�r�r��restr�rrr�__init__�s.

zCookie.__init__cCs
||jkS�N�r�)r�r{rrr�has_nonstandard_attrszCookie.has_nonstandard_attrNcCs|j�||�Sr�)r��get)r�r{�defaultrrr�get_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dSr�r�)r�r{r|rrr�set_nonstandard_attr szCookie.set_nonstandard_attrcCs,|dkrt��}|jdk	r(|j|kr(dSdS�NTF)rMr�)r��nowrrr�
is_expired#s
zCookie.is_expiredcCsX|jdkrd}n
d|j}|j||j}|jdk	rFd|j|jf}n|j}d||fS)NrWr�r�z<Cookie %s for %s>)r�r�r�r|r{)r��p�limitZ	namevaluerrr�__str__)s


zCookie.__str__cCslg}dD]$}t||�}|�d|t|�f�q|�dt|j��|�dt|j��d|jjd�|�fS)N)r�r{r|r�r�r�r�r�r�r�r�r�r�r�r�r�zrest=%sz
rfc2109=%sz%s(%s)r�)�getattrru�reprr�r��	__class__�__name__r�)r�rr{r�rrr�__repr__3s
zCookie.__repr__)F)N)N)r��
__module__�__qualname__�__doc__r�r�r�r�r�r�r�rrrrr�s�
*


c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)ra Defines which cookies get accepted from and returned to server.

    May also modify cookies, though this is probably a bad idea.

    The subclass DefaultCookiePolicy defines the standard rules for Netscape
    and RFC 2965 cookies -- override that if you want a customized policy.

    cCs
t��dS)z�Return true if (and only if) cookie should be accepted from server.

        Currently, pre-expired cookies never get this far -- the CookieJar
        class deletes such cookies itself.

        N��NotImplementedError�r��cookier�rrr�set_okKszCookiePolicy.set_okcCs
t��dS)zAReturn true if (and only if) cookie should be returned to server.Nr�r�rrr�	return_okTszCookiePolicy.return_okcCsdS)zMReturn false if cookies should not be returned, given cookie domain.
        Tr)r�r�r�rrr�domain_return_okXszCookiePolicy.domain_return_okcCsdS)zKReturn false if cookies should not be returned, given cookie path.
        Tr)r�r�r�rrr�path_return_ok]szCookiePolicy.path_return_okN)r�r�r�r�r�r�r�r�rrrrrBs
	c
@s�eZdZdZdZdZdZdZeeBZdddddddddeddd	f
d
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�ZdS)8rzBImplements the standard rules for accepting and returning cookies.rrrUr	NTF)ZhttpsZwsscCsv||_||_||_||_||_||_|	|_|
|_||_||_	|
|_
|dk	rVt|�|_nd|_|dk	rlt|�}||_
dS)zAConstructor arguments should be passed as keyword arguments only.Nr)�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�secure_protocols�tuple�_blocked_domains�_allowed_domains)r��blocked_domains�allowed_domainsr�r�r�r�r�r�r�r�r�r�r�rrrr�ms"zDefaultCookiePolicy.__init__cCs|jS)z4Return the sequence of blocked domains (as a tuple).)r�r�rrrr�sz#DefaultCookiePolicy.blocked_domainscCst|�|_dS)z$Set the sequence of blocked domains.N)r�r)r�rrrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs |jD]}t||�rdSqdSr�)rr�)r�r�Zblocked_domainrrr�
is_blocked�s

zDefaultCookiePolicy.is_blockedcCs|jS)z=Return None, or the sequence of allowed domains (as a tuple).)rrrrrr�sz#DefaultCookiePolicy.allowed_domainscCs|dk	rt|�}||_dS)z-Set the sequence of allowed domains, or None.N)r�r)r�rrrr�set_allowed_domains�sz'DefaultCookiePolicy.set_allowed_domainscCs.|jdkrdS|jD]}t||�rdSqdS)NFT)rr�)r�r�Zallowed_domainrrr�is_not_allowed�s


z"DefaultCookiePolicy.is_not_allowedcCsNtd|j|j�|jdk	st�dD]&}d|}t||�}|||�s"dSq"dS)z�
        If you override .set_ok(), be sure to call this method.  If it returns
        false, so should your subclass (assuming your subclass wants to be more
        strict about which cookies to accept).

        � - checking cookie %s=%sN)r��
verifiabilityr{r�r�r�Zset_ok_FT)rr{r|ror��r�r�r��nZfn_name�fnrrrr��s

zDefaultCookiePolicy.set_okcCsZ|jdkrtd|j|j�dS|jdkr:|js:td�dS|jdkrV|jsVtd�dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	�$   RFC 2965 cookies are switched off�$   Netscape cookies are switched offT)r�rr{r|r�r�r�rrr�set_ok_version�s
�z"DefaultCookiePolicy.set_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS�Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT�Zunverifiabler�r�r�rr�r�rrr�set_ok_verifiability�sz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|j�d�r,td|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�r�r{rvrr�rrr�set_ok_name�s
�zDefaultCookiePolicy.set_ok_namecCsL|jrHt|�}|jdks(|jdkrH|jrH|�|j|�sHtd|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�r�r�r�r)r�r�r��req_pathrrr�set_ok_path�s
����zDefaultCookiePolicy.set_ok_pathc
Cs�|�|j�rtd|j�dS|�|j�r8td|j�dS|j�r�t|�\}}|j}|jr�|�d�dkr�|�d�}|�dd|�}|dkr�||dd�}||d|�}	|	�	�dkr�t
|�dkr�td	|�dS|�d�r�|dd�}
n|}
|
�d�dk}|�s|d
k�rtd|�dS|j
dk�rX|�|��sX|�d��sXd|�|��sXtd||�dS|j
dk�sr|j|j@�r�t||��s�td
||�dS|j
dk�s�|j|j@�r�|dt
|��}|�d�dk�r�t�|��s�td||�dSdS)N�"   domain %s is in user block-listF�&   domain %s is not in user allow-listr�rr	r)�coZacZcomZeduZorgZnetZgovZmilrAZaeroZbiz�catZcoop�infoZjobsZmobiZmuseumr{ZproZtravelZeuz&   country-code second level domain %sr�z/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rr�rrr�r�r��countr�rK�lenrvr�r�r�r��DomainRFC2965Matchr��DomainStrictNoDotsr�r@)
r�r�r�r�r�r�r��jZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr�
set_ok_domain�s|

�

����
��
���z!DefaultCookiePolicy.set_ok_domainc	Cs�|jr�t|�}|dkrd}nt|�}|j�d�D]@}zt|�Wn"tk
rbtd|�YdSX||kr0q�q0td||j�dSdS)N�80rlz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)r�r�rnr�r�rArLr�r�r�r�Zreq_portr�rrr�set_ok_port+s&

�zDefaultCookiePolicy.set_ok_portcCs@td|j|j�dD]&}d|}t||�}|||�sdSqdS)z�
        If you override .return_ok(), be sure to call this method.  If it
        returns false, so should your subclass (assuming your subclass wants to
        be more strict about which cookies to return).

        r	)r�r
r�r�r�r�Z
return_ok_FT)rr{r|r�rrrrr�@s	

zDefaultCookiePolicy.return_okcCs<|jdkr|jstd�dS|jdkr8|js8td�dSdS)Nr	rFrT)r�r�rr�r�rrr�return_ok_versionRsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdSrrr�rrr�return_ok_verifiability[sz+DefaultCookiePolicy.return_ok_verifiabilitycCs"|jr|j|jkrtd�dSdS)Nz(   secure cookie with non-secure requestFT)r��typer�rr�rrr�return_ok_securegsz$DefaultCookiePolicy.return_ok_securecCs|�|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowrr�rrr�return_ok_expiresmsz%DefaultCookiePolicy.return_ok_expirescCsN|jrJt|�}|dkrd}|j�d�D]}||kr&qJq&td||j�dSdS)Nr#rlz0   request port %s does not match cookie port %sFT)r�r�r�rr$rrr�return_ok_portss�z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r*|�d�s*d|}n|}|jdkr^|j|j@r^|js^||kr^td�dS|jdkr�t||�s�td||�dS|jdkr�d|�	|�s�td||�dSdS)Nr�r	zQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sz;   request-host %s does not match Netscape cookie domain %sT)
r�r�rvr�r��DomainStrictNonDomainr�rr�r�)r�r�r�r�r�r��	dotdomainrrr�return_ok_domain�s6


�����z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|�d�sd|}|�d�s0d|}|rH|�d�sHd|}n|}|�|�sd|�|�sddS|�|�r|td|�dS|�|�r�td|�dSdS)Nr�FrrT)r�rvr�rrr)r�r�r�r�r�r.rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCsbtd|�t|�}t|�}||kr&dS|�|�rR|�d�sN|||d�dkrRdStd||�dS)Nz- checking cookie path=%sTr�rz  %s does not path-match %sF)rr�rrvr�)r�r�r�rZpathlenrrrr��s

��z"DefaultCookiePolicy.path_return_ok) r�r�r�r�r r-rZ
DomainLiberalZDomainStrictr�rrrrrrr�rrrrr"r%r�r&r'r)r+r,r/r�r�rrrrrcsT�
#	;	cCst|���}t|j|�Sr�)�sorted�keys�mapr�)Zadictr1rrr�vals_sorted_by_key�sr3c	csVt|�}|D]D}d}z
|jWntk
r2YnXd}t|�EdH|s|VqdS)zBIterates over nested mapping, depth-first, in sorted order by key.FTN)r3�items�AttributeError�
deepvalues)�mapping�values�objrrrr6�s
r6c@seZdZdS)�AbsentN�r�r�r�rrrrr:�sr:c@s�eZdZdZe�d�Ze�d�Ze�d�Ze�d�Z	e�d�Z
e�dej�Zd3d	d
�Z
dd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd4d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z d1d2�Z!dS)5rz�Collection of HTTP cookies.

    You may not need to know about this class: try
    urllib.request.build_opener(HTTPCookieProcessor).open(url).
    z\Wr~z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|dkrt�}||_t��|_i|_dSr�)r�_policy�
_threading�RLock�
_cookies_lock�_cookies�r��policyrrrr��s

zCookieJar.__init__cCs
||_dSr�)r<rArrr�
set_policy�szCookieJar.set_policycCs�g}|j�||�sgStd|�|j|}|��D]T}|j�||�sFq2||}|��D].}|j�||�srtd�qVtd�|�|�qVq2|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r<r�rr@r1r�r8r�ru)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s 

zCookieJar._cookies_for_domaincCs*g}|j��D]}|�|�||��q|S)z2Return a list of cookies to be returned to server.)r@r1�extendrE)r�r�rDr�rrr�_cookies_for_requestszCookieJar._cookies_for_requestc	Cs<|jdd�dd�d}g}|D�]}|j}|sHd}|dkrH|�d|�|jdk	rz|j�|j�rz|dkrz|j�d	|j�}n|j}|jdkr�|�|j�n|�d
|j|f�|dkr|j	r�|�d|j
�|j�d��r|j}|j
s�|�d�r�|d
d�}|�d|�|jdk	rd}|j�r,|d|j}|�|�q|S)z�Return a list of cookie-attributes to be returned to server.

        like ['foo="bar"; $Path="/"', ...]

        The $Version attribute is also added when appropriate (currently only
        once per request).

        cSs
t|j�Sr�)rr�)�arrr�<lambda>�z)CookieJar._cookie_attrs.<locals>.<lambda>T)r��reverseFr	z$Version=%sNrr�z
$Path="%s"r�rz$Domain="%s"z$Portz="%s")�sortr�rur|�non_word_rer@�quote_rer^r{r�r�r�rvr�r�r�)	r�rDr��attrsr�r�r|r�r�rrr�
_cookie_attrssF


��
�
zCookieJar._cookie_attrscCs�td�|j��z�tt���|j_|_|�|�}|�	|�}|r^|�
d�s^|�dd�|��|jj
r�|jjs�|�
d�s�|D]}|jdkr||�dd�q�q|W5|j��X|��dS)z�Add correct Cookie: header to request (urllib.request.Request object).

        The Cookie2 header is also added unless policy.hide_cookie2 is true.

        �add_cookie_headerrr�ZCookie2rz$Version="1"N)rr?�acquire�releaserArMr<r*rGrPZ
has_headerZadd_unredirected_headerr�r�r�r��clear_expired_cookies)r�r�rDrOr�rrrrQIs*



��

zCookieJar.add_cookie_headerc
Cs�g}d}d}|D�]z}|d\}}d}d}	i}
i}|dd�D�]0\}}
|��}||ks`||krd|}||krx|
dkrxd}
||
kr�q>|dkr�|
dkr�td	�d}	�qr|
��}
|d
kr�|r�q>|
dkr�td�q>|dk�r d}zt|
�}
Wn*tk
�rtd
�d}	Y�qrYnXd
}|j|
}
||k�s4||k�rh|
dk�r^|dk�r^td|�d}	�qr|
|
|<q>|
||<q>|	�rzq|�|||
|f�q|S)aReturn list of tuples containing normalised cookie information.

        attrs_set is the list of lists of key,value pairs extracted from
        the Set-Cookie or Set-Cookie2 headers.

        Tuples are name, value, standard, rest, where name and value are the
        cookie name and value, standard is a dictionary containing the standard
        cookie-attributes (discard, secure, version, expires or max-age,
        domain, path and port) and rest is a dictionary containing the rest of
        the cookie-attributes.

        )r�r�)r�r�r�r�r�r�r��
commenturlr	FrNTr�z%   missing value for domain attributer�zM   missing or invalid value for expires attribute: treating as session cookier�z?   missing or invalid (non-numeric) value for max-age attribute)r�r�rUz!   missing value for %s attribute)rKrrArLr*ru)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsr{r|Zmax_age_setZ
bad_cookie�standardr�r�r�r�rrr�_normalized_cookie_tuplesjsh





�

z#CookieJar._normalized_cookie_tuplescCs&|\}}}}|�dt�}|�dt�}|�dt�}	|�dt�}
|�dd�}|dk	rtzt|�}Wntk
rrYdSX|�dd�}|�dd�}
|�d	d�}|�d
d�}|tk	r�|dkr�d}t|�}nXd}t|�}|�d
�}|dk�r|dkr�|d|�}n|d|d�}t|�dk�rd
}|tk	}d}|�r:t|�	d��}|tk�rVt
|�\}}|}n|�	d��sjd|}d}|	tk	�r�|	dk�r�t|�}	nd}t�
dd|	�}	nd}	|
tk�r�d}
d}
nH|
|jk�rz|�|||�Wntk
�r�YnXtd|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rUrWTr�r�r	rr�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s')r�r:rArLr�r�r�r�boolrvr�r�rwr^r*�clear�KeyErrorrr)r��tupr�r{r|rZr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�_cookie_from_cookie_tuple�s�







��z#CookieJar._cookie_from_cookie_tuplecCs6|�|�}g}|D]}|�||�}|r|�|�q|Sr�)r[r`ru)r�rVr�rWrDr_r�rrr�_cookies_from_attrs_set's
z!CookieJar._cookies_from_attrs_setcCsHt|jdd�}|dkr |jj}|D]}|jdkr$d|_|r$d|_q$dS)Nr�rTr	)r�r<r�r�r�)r�rDZ
rfc2109_as_nsr�rrr�_process_rfc2109_cookies0s

z"CookieJar._process_rfc2109_cookiesc
Cs:|��}|�dg�}|�dg�}tt���|j_|_|jj}|jj}|sN|rf|sV|rf|s^|rf|sj|sjgSz|�t	|�|�}Wnt
k
r�t�g}YnX|�r6|�r6z|�t|�|�}	Wnt
k
r�t�g}	YnX|�
|	�|�r&i}
|D]}d|
|j|j|jf<q�|
fdd�}t||	�}	|	�r6|�|	�|S)zAReturn sequence of Cookie objects extracted from response object.zSet-Cookie2z
Set-CookieNcSs|j|j|jf}||kSr�)r�r�r{)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965isz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)rZget_allrArMr<r*r�r�rar}�	Exceptionrr�rbr�r�r{�filterrF)
r��responser�r�Zrfc2965_hdrsZns_hdrsr�r�rDZ
ns_cookiesrcr�rdrrr�make_cookies<s^�������
�



zCookieJar.make_cookiescCsN|j��z2tt���|j_|_|j�||�r:|�|�W5|j��XdS)z-Set a cookie if policy says it's OK to do so.N)	r?rRrSrArMr<r*r��
set_cookier�rrr�set_cookie_if_okss
zCookieJar.set_cookie_if_okcCsl|j}|j��zJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<W5|j��XdS)z?Set a cookie, without checking whether or not it should be set.N)r@r?rRrSr�r�r{)r�r��cZc2Zc3rrrri�s






zCookieJar.set_cookiecCsbtd|���|j��z8|�||�D]&}|j�||�r&td|�|�|�q&W5|j��XdS)zAExtract cookies from response, where allowable given the request.zextract_cookies: %sz setting cookie: %sN)	rrr?rRrSrhr<r�ri)r�rgr�r�rrr�extract_cookies�s

zCookieJar.extract_cookiescCst|dk	r2|dks|dkr td��|j|||=n>|dk	rX|dkrJtd��|j||=n|dk	rj|j|=ni|_dS)a�Clear some cookies.

        Invoking this method without arguments will clear all cookies.  If
        given a single argument, only cookies belonging to that domain will be
        removed.  If given two arguments, cookies belonging to the specified
        path within that domain are removed.  If given three arguments, then
        the cookie with the specified name, path and domain is removed.

        Raises KeyError if no matching cookie exists.

        Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLr@)r�r�r�r{rrrr]�s��
zCookieJar.clearcCsD|j��z(|D]}|jr|�|j|j|j�qW5|j��XdS)z�Discard all session cookies.

        Note that the .save() method won't save session cookies anyway, unless
        you ask otherwise by passing a true ignore_discard argument.

        N)r?rRrSr�r]r�r�r{)r�r�rrr�clear_session_cookies�s
zCookieJar.clear_session_cookiescCsP|j��z4t��}|D]"}|�|�r|�|j|j|j�qW5|j��XdS)a�Discard all expired cookies.

        You probably don't need to call this method: expired cookies are never
        sent back to the server (provided you're using DefaultCookiePolicy),
        this method is called by CookieJar itself every so often, and the
        .save() method won't save expired cookies anyway (unless you ask
        otherwise by passing a true ignore_expires argument).

        N)	r?rRrSrMr�r]r�r�r{)r�r�r�rrrrT�s


zCookieJar.clear_expired_cookiescCs
t|j�Sr�)r6r@rrrr�__iter__�szCookieJar.__iter__cCsd}|D]}|d}q|S)z#Return number of contained cookies.r	rr)r�r�r�rrr�__len__�s
zCookieJar.__len__cCs2g}|D]}|�t|��qd|jjd�|�fS�Nz<%s[%s]>r�)rur�r�r�r��r��rr�rrrr��szCookieJar.__repr__cCs2g}|D]}|�t|��qd|jjd�|�fSrp)rurnr�r�r�rqrrrr��szCookieJar.__str__)N)NNN)"r�r�r�r�rw�compilerMrNZstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�rCrErGrPrQr[r`rarbrhrjrirlr]rmrTrnror�r�rrrrr�s8





;!a\	7


c@seZdZdS)rNr;rrrrr�sc@s8eZdZdZddd�Zd
dd�Zddd	�Zdd
d�ZdS)rz6CookieJar that can be loaded from and saved to a file.NFcCs2t�||�|dk	rt�|�}||_t|�|_dS)z}
        Cookies are NOT loaded from the named file until either the .load() or
        .revert() method is called.

        N)rr��os�fspath�filenamer\�	delayload)r�rxryrBrrrr��s

zFileCookieJar.__init__cCs
t��dS)zSave cookies to a file.Nr�)r�rx�ignore_discard�ignore_expiresrrr�save�szFileCookieJar.savec	CsJ|dkr"|jdk	r|j}ntt��t|��}|�||||�W5QRXdS)zLoad cookies from a file.N)rxrL�MISSING_FILENAME_TEXT�open�_really_load�r�rxrzr{rrrr�loads

zFileCookieJar.loadcCs�|dkr"|jdk	r|j}ntt��|j��zFt�|j�}i|_z|�	|||�Wnt
k
rn||_�YnXW5|j��XdS)z�Clear all cookies and reload cookies from a saved file.

        Raises LoadError (or OSError) if reversion is not successful; the
        object's state will not be altered if this happens.

        N)rxrLr}r?rRrSr�Zdeepcopyr@r��OSError)r�rxrzr{Z	old_staterrr�revert	s

zFileCookieJar.revert)NFN)NFF)NFF)NFF)r�r�r�r�r�r|r�r�rrrrr�s


	�cCs |j|jfd|jfd|jfg}|jdk	r8|�d|jf�|jrH|�d�|jrX|�d�|jrh|�d�|j	rx|�d�|j
r�|�d	tt|j
��f�|j
r�|�d
�|jr�|�d|jf�|jr�|�d|jf�t|j���}|D]}|�|t|j|�f�q�|�d
t|j�f�t|g�S)z�Return string representation of Cookie in the LWP cookie file format.

    Actually, the format is extended a bit -- see module docstring.

    r�r�Nr�)�	path_specN)�	port_specN)�
domain_dotN)r�Nr�)r�Nr�rUr�)r{r|r�r�r�rur�r�r�r�r�r5r[r�r�r�r0r�r1rnr�r�)r�r�r1r�rrr�lwp_cookie_str$s:
�




�
r�c@s,eZdZdZddd�Zddd�Zd	d
�ZdS)
ra[
    The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
    "Set-Cookie3" is the format used by the libwww-perl library, not known
    to be compatible with any browser, but which is easy to read and
    doesn't lose information about RFC 2965 cookies.

    Additional methods

    as_lwp_str(ignore_discard=True, ignore_expired=True)

    TcCsTt��}g}|D]2}|s |jr q|s0|�|�r0q|�dt|��qd�|dg�S)z�Return cookies as a string of "\n"-separated "Set-Cookie3" headers.

        ignore_discard and ignore_expires: see docstring for FileCookieJar.save

        zSet-Cookie3: %s�
rW)rMr�r�rur�r�)r�rzr{r�rrr�rrr�
as_lwp_strMs
zLWPCookieJar.as_lwp_strNFc	CsX|dkr"|jdk	r|j}ntt��t|d��"}|�d�|�|�||��W5QRXdS)N�wz#LWP-Cookies-2.0
)rxrLr}r~�writer�r�rrrr|]s

zLWPCookieJar.savecCs0|��}|j�|�s$d|}t|��t��}d}d}	d}
�z�|��}|dkrP�q�|�|�s\q<|t|�d���}t|g�D�]f}|d\}
}i}i}|	D]}d||<q�|dd�D]n\}}|dk	r�|�	�}nd}||
ks�||	kr�|}||	k�r|dkr�d	}|||<q�||
k�r|||<q�|||<q�|j
}|d
�}|d�}|dk	�rJt|�}|dk�rXd	}|d�}|�d
�}t|d�|
||d�|d�|||d�|d�|d�|d�|||d�|d�|�}|�s�|j
�r�qz|�s�|�|��r�qz|�|�qzq<WnBtk
�r�Yn,tk
�r*t�td||f��YnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:)r�r�r�r�r�)r�r�r�r�r�r�rUrWr	FrTr�r�r�r�r�r�r�r�r�r�r�r�rUz&invalid Set-Cookie3 format file %r: %r)�readlinerur@rrMrvrr�r}rKr�rerr�r�rir�rer)r�rrxrzr{�magicrr��headerrXrY�line�datar{r|rZr�r�r�r�r�r�r�r�r�rkrrrris��










�
�zLWPCookieJar._really_load)TT)NFF)r�r�r�r�r�r|rrrrrr@s

c@s0eZdZdZe�d�ZdZdd�Zd
dd	�Z	dS)ra�

    WARNING: you may want to backup your browser's cookies file if you use
    this class to save cookies.  I *think* it works, but there have been
    bugs in the past!

    This class differs from CookieJar only in the format it uses to save and
    load cookies to and from a file.  This class uses the Mozilla/Netscape
    `cookies.txt' format.  lynx uses this file format, too.

    Don't expect cookies saved while the browser is running to be noticed by
    the browser (in fact, Mozilla on unix will overwrite your saved cookies if
    you change them on disk while it's running; on Windows, you probably can't
    save at all while the browser is running).

    Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
    Netscape cookies on saving.

    In particular, the cookie version and port number information is lost,
    together with information about whether or not Path, Port and Discard were
    specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
    domain as set in the HTTP header started with a dot (yes, I'm aware some
    domains in Netscape files start with a dot and some don't -- trust me, you
    really don't want to know any more about this).

    Note that though Mozilla and Netscape use the same format, they use
    slightly different headers.  The class saves cookies using the Netscape
    header by default (Mozilla can cope with that).

    z#( Netscape)? HTTP Cookie Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCstt��}|��}|j�|�s(td|���z|��}|dkr@�q*|�d�rV|dd�}|���d�s,|��dkrrq,|�d�\}}	}
}}}
}|dk}|	dk}	|
dkr�|}
d}|�d�}|	|ks�t	�d	}|dkr�d}d
}t
d|
|dd	||	||
d	|||ddi�}|�s
|j�r
q,|�s|�|��rq,|�
|�q,WnBtk
�rD�Yn,tk
�rnt�td||f��YnXdS)
Nz4%r does not look like a Netscape format cookies filerWr�r�)�#r�	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %r)rMr�rur@rr�r�rvr�rorr�r�rir�rer)r�rrxrzr{r�r�r�r�r�r�r�r�r{r|r�r�rkrrrr�st��

��
�
�zMozillaCookieJar._really_loadNFc
Cs�|dkr"|jdk	r|j}ntt��t|d���}|�|j�t��}|D]�}|sV|jrVqF|sf|�|�rfqF|j	rrd}nd}|j
�d�r�d}nd}|jdk	r�t
|j�}	nd}	|jdkr�d}
|j}n|j}
|j}|�d�|j
||j||	|
|g�d�qFW5QRXdS)Nr�r�ZFALSEr�rWr�r�)rxrLr}r~r�r�rMr�r�r�r�rvr�rnr|r{r�r�)r�rxrzr{rr�r�r�r�r�r{r|rrrr| sH



���zMozillaCookieJar.save)NFF)
r�r�r�r�rwrsrur�rr|rrrrr�s

A)N)N)Xr��__all__rvr�r-rwrMZurllib.parser�Zurllib.requestZ	threadingr=Zhttp.clientZhttpZcalendarr
rrrrnZclientZ	HTTP_PORTr�r}rr%r,r6r7rIr(rurKr5r8r>rsrtr?rFrTrY�Ir]�Xr_rbrcrerkrprqrsrrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr3r6r:rr�rrr�rrrrrr�<module>s��
�

8�
�
�8
�!



U
D'


#b!b7xPK|/�\�70]�]�client.cpython-38.pycnu�[���U

e5d���@sfdZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZdddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZe��ejj�dd�ejj��D�ZdZdZe�d �jZe�d!�jZe�d"�Z e�d#�Z!d$d%d&hZ"dBd(d)�Z#Gd*d+�d+ej$j%�Z&d,d-�Z'e&fd.d/�Z(Gd0d�dej)�Z*Gd1d�d�Z+zddl,Z,Wne-k
�r`YnXGd2d3�d3e+�Z.e�/d3�Gd4d�de0�Z1Gd5d�de1�Z2Gd6d�de1�Z3Gd7d�de1�Z4Gd8d	�d	e1�Z5Gd9d
�d
e1�Z6Gd:d�de1�Z7Gd;d
�d
e1�Z8Gd<d�de8�Z9Gd=d�de8�Z:Gd>d�de8�Z;Gd?d�de1�Z<Gd@d�de1�Z=GdAd�de>e<�Z?e1Z@dS)Ca�
HTTP/1.1 client library

<intro stuff goes here>
<other stuff, too>

HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:

    (null)
      |
      | HTTPConnection()
      v
    Idle
      |
      | putrequest()
      v
    Request-started
      |
      | ( putheader() )*  endheaders()
      v
    Request-sent
      |\_____________________________
      |                              | getresponse() raises
      | response = getresponse()     | ConnectionError
      v                              v
    Unread-response                Idle
    [Response-headers-read]
      |\____________________
      |                     |
      | response.read()     | putrequest()
      v                     v
    Idle                  Req-started-unread-response
                     ______/|
                   /        |
   response.read() |        | ( putheader() )*  endheaders()
                   v        v
       Request-started    Req-sent-unread-response
                            |
                            | response.read()
                            v
                          Request-sent

This diagram presents the following rules:
  -- a second request may not be started until {response-headers-read}
  -- a response [object] cannot be retrieved until {request-sent}
  -- there is no differentiation between an unread response body and a
     partially read response body

Note: this enforcement is applied by the HTTPConnection class. The
      HTTPResponse class does not enforce this state machine, which
      implies sophisticated clients may accelerate the request/response
      pipeline. Caution should be taken, though: accelerating the states
      beyond the above pattern may imply knowledge of the server's
      connection-close behavior for certain requests. For example, it
      is impossible to tell whether the server will close the connection
      UNTIL the response headers have been read; this means that further
      requests cannot be placed into the pipeline until it is known that
      the server will NOT be closing the connection.

Logical State                  __state            __response
-------------                  -------            ----------
Idle                           _CS_IDLE           None
Request-started                _CS_REQ_STARTED    None
Request-sent                   _CS_REQ_SENT       None
Unread-response                _CS_IDLE           <response_class>
Req-started-unread-response    _CS_REQ_STARTED    <response_class>
Req-sent-unread-response       _CS_REQ_SENT       <response_class>
�N)�urlsplit�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}||j�qS�)�phrase)�.0�vrr�#/usr/lib64/python3.8/http/client.py�
<dictcomp>jsri�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUT�datac
Cshz|�d�WStk
rb}z8t|j|j|j|jd|��||j|j�|f�d�W5d}~XYnXdS)z<Call data.encode("latin-1") but show a better error message.�latin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.N)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s���r(c@seZdZdd�ZdS)�HTTPMessagecCsj|��d}t|�}g}d}|��D]@}|d|���|krBd}n|dd���sVd}|r$|�|�q$|S)a�Find all header lines matching a given header name.

        Look through the list of headers and find all lines matching a given
        header name (and their continuation lines).  A list of the lines is
        returned, without interpretation.  If the header does not occur, an
        empty list is returned.  If the header occurs multiple times, all
        occurrences are returned.  Case is not important in the header name.

        �:rN�)�lower�len�keys�isspace�append)�selfr&�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r4rrrrr)�sr)cCsXg}|�td�}t|�tkr&td��|�|�t|�tkrHtdt��|dkrqTq|S)z�Reads potential header lines into a list from a file pointer.

    Length of line is limited by _MAXLINE, and number of
    headers is limited by _MAXHEADERS.
    r+�header linezgot more than %d headers��
�
�)�readline�_MAXLINEr-rr0�_MAXHEADERSr)�fp�headersr3rrr�
_read_headers�s
rBcCs,t|�}d�|��d�}tjj|d��|�S)aGParses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.

    r<�
iso-8859-1)�_class)rB�join�decode�email�parserZParserZparsestr)r@rDrAZhstringrrr�
parse_headers�s
rIcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdBd(d)�ZdCd*d+�ZdD�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdEd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)FrrNcCsR|�d�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)Zmakefiler@�
debuglevel�_methodrA�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r1�sockrK�method�urlrrr�__init__�szHTTPResponse.__init__cCst|j�td�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��z|�
dd�\}}}WnFtk
r�z|�
dd�\}}d}Wntk
r�d}YnXYnX|�d	�s�|�
�t|��z$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr+rCzstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr@r=r>r-rrK�print�reprr�split�
ValueError�
startswith�_close_connr�int)r1r3rOrPrQrrr�_read_statuss2

zHTTPResponse._read_statusc	Cs�|jdk	rdS|��\}}}|tkr&qHt|j�}|jdkrDtd|�~q||_|_|�	�|_
|dkrnd|_n|�d�r�d|_nt
|��t|j�|_|_|jdkr�|j��D]\}}td|d|�q�|j�d	�}|r�|��d
kr�d|_d|_nd|_|��|_d|_|j�d
�}|�rb|j�sbzt|�|_Wntk
�rLd|_YnX|jdk�rhd|_nd|_|tk�s�|tk�s�d|k�r�dk�s�n|jdk�r�d|_|j�s�|j�s�|jdk�r�d|_dS)Nrzheaders:)zHTTP/1.0zHTTP/0.9�
zHTTP/1.��header:r*�transfer-encodingrRTF�content-lengthr���HEAD)rArdZCONTINUErBr@rKr]�coderP�striprQrOrarrIrM�items�getr,rRrS�_check_closerUrTrcr`Z
NO_CONTENTZNOT_MODIFIEDrL)	r1rOrPrQZskipped_headers�hdr�valZtr_encrTrrr�begin5sf







�
�
���zHTTPResponse.begincCsv|j�d�}|jdkr.|r*d|��kr*dSdS|j�d�r>dS|rRd|��krRdS|j�d�}|rrd|��krrdSdS)NZ
connectionrf�closeTFz
keep-alivezproxy-connection)rArorOr,)r1ZconnZpconnrrrrp}s
zHTTPResponse._check_closecCs|j}d|_|��dS�N)r@rt)r1r@rrrrb�szHTTPResponse._close_conncs$zt���W5|jr|��XdSru)r@rb�superrt�r1��	__class__rrrt�szHTTPResponse.closecst���|jr|j��dSru)rv�flushr@rwrxrrrz�s
zHTTPResponse.flushcCsdS)zAlways returns TrueTrrwrrr�readable�szHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)r@rwrrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|��dS|dk	rRt|�}|�|�}t|�d|���S|jr`|��S|j	dkrv|j�
�}n6z|�|j	�}Wntk
r�|���YnXd|_	|��|SdS)Nr<rkr)
r@rLrb�	bytearray�readinto�
memoryview�tobytesrR�_readall_chunkedrT�read�
_safe_readr
)r1�amt�br2�srrrr��s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|��dS|jr4|�|�S|jdk	r^t|�|jkr^t|�d|j�}|j�|�}|s||r||��n&|jdk	r�|j|8_|js�|��|S)z^Read up to len(b) bytes into bytearray b and return the number
        of bytes read.
        Nrrk)	r@rLrbrR�_readinto_chunkedrTr-rr~)r1r�r2rrrr~�s$





zHTTPResponse.readintocCsr|j�td�}t|�tkr$td��|�d�}|dkrB|d|�}zt|d�WStk
rl|���YnXdS)Nr+z
chunk size�;r�)	r@r=r>r-r�findrcr`rb)r1r3�irrr�_read_next_chunk_sizes
z"HTTPResponse._read_next_chunk_sizecCs:|j�td�}t|�tkr$td��|s*q6|dkrq6qdS)Nr+ztrailer liner9)r@r=r>r-r�r1r3rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|�d�z|��}Wntk
rDtd��YnX|dkrb|��|��d}||_|S)NrZr<r)rSr�r�r`r
r�rb)r1rSrrr�_get_chunk_left s
zHTTPResponse._get_chunk_leftcCsp|jtkst�g}z6|��}|dkr&q>|�|�|��d|_qd�|�WStk
rjtd�|���YnXdS�Nrr<)	rRrN�AssertionErrorr�r0r�rSrEr
)r1�valuerSrrrr�8szHTTPResponse._readall_chunkedcCs�|jtkst�d}t|�}zv|��}|dkr2|WSt|�|kr\|�|�}|||_||WS|d|�}|�|�}||d�}||7}d|_qWn(tk
r�tt	|d|����YnXdS)Nr)
rRrNr�rr�r-�_safe_readintorSr
�bytes)r1r�Ztotal_bytesZmvbrSr2Ztemp_mvbrrrr�Fs$



zHTTPResponse._readinto_chunkedcCs.|j�|�}t|�|kr*t||t|���|S)aRead the number of bytes requested.

        This function should be used when <amt> bytes "should" be present for
        reading. If the bytes are truly not available (due to EOF), then the
        IncompleteRead exception can be used to detect the problem.
        )r@r�r-r
)r1r�rrrrr�^szHTTPResponse._safe_readcCs:t|�}|j�|�}||kr6tt|d|��||��|S)z2Same as _safe_read, but for reading into a buffer.N)r-r@r~r
r�)r1r�r�r2rrrr�js
zHTTPResponse._safe_readinto���cCs�|jdks|jdkrdS|jr(|�|�S|jdk	rJ|dksD||jkrJ|j}|j�|�}|sh|rh|��n|jdk	r�|jt|�8_|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        Nrkr<r)r@rLrR�_read1_chunkedrT�read1rbr-)r1r2�resultrrrr�rs


zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|�|�S|j�|�S)Nrkr<)r@rLrR�
_peek_chunked�peek)r1r2rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t��|�S|jdk	rL|dksF||jkrL|j}|j�|�}|sj|rj|��n|jdk	r�|jt|�8_|S)Nrkr<r)r@rLrRrvr=rTrbr-)r1�limitr�rxrrr=�s

zHTTPResponse.readlinecCsd|��}|dks|dkrdSd|kr0|ks6n|}|j�|�}|jt|�8_|s`td��|Sr�)r�r@r�rSr-r
)r1r2rSr�rrrr��szHTTPResponse._read1_chunkedcCsDz|��}Wntk
r"YdSX|dkr0dS|j�|�d|�S)Nr<)r�r
r@r�)r1r2rSrrrr��szHTTPResponse._peek_chunkedcCs
|j��Sru)r@�filenorwrrrr��szHTTPResponse.filenocCsF|jdkrt��|j�|�p|}t|t�s4t|d�s8|Sd�|�SdS)axReturns the value of the header matching *name*.

        If there are multiple matching headers, the values are
        combined into a single string separated by commas and spaces.

        If no matching header is found, returns *default* or None if
        the *default* is not specified.

        If the headers are unknown, raises http.client.ResponseNotReady.

        N�__iter__z, )rArZget_all�
isinstancer\�hasattrrE)r1r&�defaultrArrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|j���S)z&Return list of (header, value) tuples.N)rAr�listrnrwrrr�
getheaders�s
zHTTPResponse.getheaderscCs|Srurrwrrrr��szHTTPResponse.__iter__cCs|jS)ajReturns an instance of the class mimetools.Message containing
        meta-information associated with the URL.

        When the method is HTTP, these headers are those returned by
        the server at the head of the retrieved HTML page (including
        Content-Length and Content-Type).

        When the method is FTP, a Content-Length header will be
        present if (as is now usual) the server passed back a file
        length in response to the FTP retrieval request. A
        Content-Type header will be present if the MIME type can be
        guessed.

        When the method is local-file, returned headers will include
        a Date representing the file's last-modified time, a
        Content-Length giving file size, and a Content-Type
        containing a guess at the file's type. See also the
        description of the mimetools module.

        )rArwrrr�info�szHTTPResponse.infocCs|jS)aZReturn the real URL of the page.

        In some cases, the HTTP server redirects a client to another
        URL. The urlopen() function handles this transparently, but in
        some cases the caller needs to know which URL the client was
        redirected to. The geturl() method can be used to get at this
        redirected URL.

        )rXrwrrr�geturl�s
zHTTPResponse.geturlcCs|jS)zuReturn the HTTP status code that was sent with the response,
        or None if the URL is not an HTTP URL.

        )rPrwrrr�getcode�szHTTPResponse.getcode)rNN)N)r�)r�)r�)N)"r5r6r7rYrdrsrprbrtrzr{r|r�r~r�r�r�r�r�r�r�r�r�r=r�r�r�r�r�r�r�r�r��
__classcell__rrrxrr�s<	
!H

 "

	

c@s
eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	d
fdd�Zd7d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd8d d!�Zd9d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d:dd.�d/d0�Z!d	ifdd.�d1d2�Z"d3d4�Z#d5d6�Z$d	S);rrfzHTTP/1.1r+rcCst|tj�S)zFTest whether a file-like object is a text or a binary stream.
        )r��io�
TextIOBase)�streamrrr�
_is_textIOszHTTPConnection._is_textIOcCsf|dkr|��tkrdSdSt|d�r*dSzt|�}|jWStk
rNYnXt|t�rbt|�SdS)aGet the content-length based on the body.

        If the body is None, we set Content-Length: 0 for methods that expect
        a body (RFC 7230, Section 3.3.2). We also set the Content-Length for
        any method if the body is a str or bytes-like object and not a file.
        Nrr�)	�upper�_METHODS_EXPECTING_BODYr�r�nbytes�	TypeErrorr�r\r-)�bodyrWZmvrrr�_get_content_lengths

z"HTTPConnection._get_content_lengthN� cCsn||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|�||�\|_
|_|�|j
�tj|_dSru)�timeout�source_address�	blocksizerV�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterL�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�_validate_host�socketZcreate_connection�_create_connection)r1r�r�r�r�r�rrrrY4szHTTPConnection.__init__cCs<|jrtd��|�||�\|_|_|r.||_n
|j��dS)aDSet up host and port for HTTP CONNECT tunnelling.

        In a connection that uses HTTP CONNECT tunneling, the host passed to the
        constructor is used as a proxy server that relays all communication to
        the endpoint passed to `set_tunnel`. This done by sending an HTTP
        CONNECT request to the proxy server when the connection is established.

        This method must be called before the HTTP connection has been
        established.

        The headers argument should be a mapping of extra HTTP headers to send
        with the CONNECT request.
        z.Can't set up tunnel for established connectionN)rV�RuntimeErrorr�r�r�r��clear)r1r�r�rArrr�
set_tunnelJszHTTPConnection.set_tunnelcCs�|dkr�|�d�}|�d�}||kr�zt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd�}||fS)	Nr*�]r+r[znonnumeric port: '%s'r�[r�)�rfindrcr`�default_portr)r1r�r�r��jrrrr�bs

zHTTPConnection._get_hostportcCs
||_dSru)rK)r1�levelrrr�set_debuglevelvszHTTPConnection.set_debuglevelcCs�d|j|jf}|�d�}|�|�|j��D](\}}d||f}|�d�}|�|�q.|�d�|j|j|jd�}|�	�\}}	}
|	t
jjkr�|�
�td|	|
��f��|j�td�}t|�tkr�td	��|s�q�|d
kr�q�|jdkr�td|���q�dS)
NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
rr:�rWzTunnel connection failed: %d %sr+r8r9rrg)r�r�r�sendr�rn�response_classrVrLrd�http�
HTTPStatusZOKrt�OSErrorrmr@r=r>r-rrKr]rF)r1Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserOrl�messager3rrr�_tunnelys4�



�
zHTTPConnection._tunnelcCsB|�|j|jf|j|j�|_|j�tjtj	d�|j
r>|��dS)z3Connect to the host and port specified in __init__.r+N)r�r�r�r�r�rVZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�rwrrr�connect�s
�zHTTPConnection.connectcCsBt|_z|j}|r d|_|��W5|j}|r<d|_|��XdS)z(Close the connection to the HTTP server.N)r�r�r�rtrV)r1r�rVrrrrt�szHTTPConnection.closecCs|jdkr |jr|��nt��|jdkr8tdt|��t|d�r�|jdkrTtd�|�|�}|rt|jdkrttd�|�	|j
�}|s�q�|r�|�d�}|j�|�qtdSz|j�|�WnLt
k
�rt|tjj�r�|D]}|j�|�q�nt
dt|���YnXdS)	z�Send `data' to the server.
        ``data`` can be a string object, a bytes object, an array object, a
        file-like object that supports a .read() method, or an iterable object.
        Nrzsend:r��sendIng a read()able�encoding file using iso-8859-1rCz9data should be a bytes-like object or an iterable, got %r)rV�	auto_openr�rrKr]r^r�r�r�r�rZsendallr�r��collections�abc�Iterable�type)r1rr�	datablock�drrrr��s8






�zHTTPConnection.sendcCs|j�|�dS)zuAdd a line of output to the current request buffer.

        Assumes that the line does *not* end with \r\n.
        N)r�r0)r1r�rrr�_output�szHTTPConnection._outputccs^|jdkrtd�|�|�}|r2|jdkr2td�|�|j�}|sDqZ|rR|�d�}|Vq2dS)Nrr�r�rC)rKr]r�r�r�r)r1r{rr�rrr�_read_readable�s


zHTTPConnection._read_readableFcCs |j�d�d�|j�}|jdd�=|�|�|dk	�rt|d�rN|�|�}nZzt|�WnFtk
r�zt|�}Wn$tk
r�tdt	|���YnXYnX|f}|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d	�d
��d�|d}|�|�q�|�r|jdk�r|�d�dS)
z�Send the currently buffered request and clear the buffer.

        Appends an extra \r\n to the buffer.
        A message_body may be specified, to be appended to the request.
        )r<r<r:Nr�zAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrf�Xz
r�s0

)r��extendrEr�r�r�rr��iterr�rKr]�	_http_vsnr-r)r1�message_body�encode_chunkedrMZchunks�chunkrrr�_send_output�s:


�
�zHTTPConnection._send_outputcCs�|jr|j��rd|_|jtkr(t|_n
t|j��|�|�||_|pHd}|�|�d|||j	f}|�
|�|��|jdk�r�|�s�d}|�
d�r�t|�\}}}}}|r�z|�d�}Wntk
r�|�d�}YnX|�d	|�n�|jr�|j}	|j}
n|j}	|j}
z|	�d�}Wn tk
�r4|	�d�}YnX|	�d
�dk�rRd|d
}|
|jk�rl|�d	|�n|�d�}|�d	d||
f�|�s�|�dd�ndS)a`Send a request to the server.

        `method' specifies an HTTP request method, e.g. 'GET'.
        `url' specifies the object being requested, e.g. '/index.html'.
        `skip_host' if True does not add automatically a 'Host:' header
        `skip_accept_encoding' if True does not add automatically an
           'Accept-Encoding:' header
        N�/z%s %s %srfr[r�r�ZidnaZHostr*r�[�]z%s:%szAccept-EncodingZidentity)r�r|r�r��_CS_REQ_STARTEDr
�_validate_methodrL�_validate_path�
_http_vsn_strr��_encode_requestr�rarrr �	putheaderr�r�r�r�r�r�rF)r1rWrX�	skip_host�skip_accept_encoding�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequest sP






zHTTPConnection.putrequestcCs
|�d�S)Nr�)r)r1r�rrrr��szHTTPConnection._encode_requestcCs,t�|�}|r(td|�d|���d���dS)z&Validate a method name for putrequest.z)method can't contain control characters. � (found at least �)N)�$_contains_disallowed_method_pchar_re�searchr`�group)r1rW�matchrrrr��s

�zHTTPConnection._validate_methodcCs,t�|�}|r(td|�d|���d���dS)zValidate a url for putrequest.�&URL can't contain control characters. r�r�N��!_contains_disallowed_url_pchar_rer�rr�)r1rXr�rrrr��s
zHTTPConnection._validate_pathcCs,t�|�}|r(td|�d|���d���dS)z9Validate a host so it doesn't contain control characters.r�r�r�Nr)r1r�r�rrrr��s
zHTTPConnection._validate_hostcGs�|jtkrt��t|d�r$|�d�}t|�s:td|f��t|�}t|�D]\\}}t|d�rl|�d�||<nt	|t
�r�t|��d�||<t||�rJtd||f��qJd�
|�}|d|}|�|�dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        rr�zInvalid header name %rrzInvalid header value %rs
	s: N)r�r�rr�r�_is_legal_header_namer`r��	enumerater�rcr\�_is_illegal_header_valuerEr�)r1r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader�r�cCs*|jtkrt|_nt��|j||d�dS)z�Indicate that the last header line has been sent to the server.

        This method sends the request to the server.  The optional message_body
        argument can be used to pass a message body associated with the
        request.
        rN)r�r��_CS_REQ_SENTrr�)r1r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|�|||||�dS)z&Send a complete request to the server.N)�
_send_request)r1rWrXr�rAr�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|�||�}|dkr�|dk	r�|jdkr�td|�d
}|�dd�q�|�dt|��nd
}|��D]\}	}
|�|	|
�q�t|t�r�t	|d�}|j
||d�dS)Ncss|]}|��VqdSru)r,)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r+r�zaccept-encodingr�rirhFrzUnable to determine size of %rTzTransfer-EncodingrRzContent-Lengthr�r)�	frozensetr�r�rKr]r�r\rnr�r(r)r1rWrXr�rAr�Zheader_namesZskipsZcontent_lengthrqr�rrrr	�s0	


zHTTPConnection._send_requestcCs�|jr|j��rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}z\z|�	�Wnt
k
r�|���YnX|jt
ks�t�t|_|jr�|��n||_|WS|���YnXdS)a)Get the response from the server.

        If the HTTPConnection is in the correct state, returns an
        instance of HTTPResponse or of whatever object is returned by
        the response_class variable.

        If a request has not been sent or if a previous response has
        not be handled, ResponseNotReady is raised.  If the HTTP
        response indicates that the connection should be closed, then
        it will be closed before the response is returned.  When the
        connection is closed, the underlying socket is closed.
        Nrr�)r�r|r�rrrKr�rVrLrs�ConnectionErrorrtrUrNr�r�)r1r�rrr�getresponses0

�
zHTTPConnection.getresponse)NN)NF)FF)N)%r5r6r7r�r�rr��	HTTP_PORTr�r�rK�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrYr�r�r�r�r�rtr�r�r�r�r�r�r�r�r�r�rr�r	rrrrrrsL

�

	&
6�
	
�.csHeZdZdZeZdddejdfdddd��fdd�Z�fdd�Z	�Z
S)	�HTTPSConnectionz(This class allows communication via SSL.Nr�)�context�check_hostnamer�cs�tt|�j|||||	d�|dk	s2|dk	s2|dk	rHddl}
|
�dtd�||_||_|dkrtt�	�}|j
dk	rtd|_
|jtjk}|dkr�|j
}|r�|s�td��|s�|r�|�||�|j
dk	r�d|_
||_|dk	r�||j_
dS)N)r�rzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rZTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rvrrY�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr`Zload_cert_chain�_context)r1r�r�rrr�r�rrr�rZwill_verifyrxrrrYcs<���

zHTTPSConnection.__init__cs6t���|jr|j}n|j}|jj|j|d�|_dS)z(Connect to a host on a given (SSL) port.)�server_hostnameN)rvr�r�r�rZwrap_socketrV)r1rrxrrr��s

�zHTTPSConnection.connect)r5r6r7�__doc__�
HTTPS_PORTr�r�rrYr�r�rrrxrr\s��$rc@seZdZdS)rN�r5r6r7rrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dSru)�argsrO)r1rOrrrrY�szUnknownProtocol.__init__N�r5r6r7rYrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)r	Nrrrrrr	�sc@s$eZdZddd�Zdd�ZejZdS)r
NcCs|f|_||_||_dSru)r �partial�expected)r1r"r#rrrrY�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedr[z%s(%i bytes read%s))r#ryr5r-r")r1�errr�__repr__�s
�zIncompleteRead.__repr__)N)r5r6r7rYr%r"�__str__rrrrr
�s
c@seZdZdS)rNrrrrrr�sc@seZdZdS)r
Nrrrrrr
�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dSru)r^r r3r�rrrrY�szBadStatusLine.__init__Nr!rrrrr�sc@seZdZdd�ZdS)rcCst�|dt|f�dS)Nz&got more than %d bytes when reading %s)rrYr>)r1Z	line_typerrrrY�s�zLineTooLong.__init__Nr!rrrrr�sc@seZdZdd�ZdS)rcOs"t�|d�tj|f|�|�dS)Nr[)rrY�ConnectionResetError)r1�pos�kwrrrrY�szRemoteDisconnected.__init__Nr!rrrrr�s)r)ArZemail.parserrGZ
email.messager�r��rer�Zcollections.abcr�Zurllib.parser�__all__rrrNr�r�r�globals�updater��__members__rrr>r?�compile�	fullmatchrr�rrr�r�r(r�ZMessager)rBrI�BufferedIOBaserrr�ImportErrorrr0�	Exceptionrrrrrr	r
rr
rrrrr'rrrrrr�<module>s�F�



W8
PK|/�\�;�[ddclient.cpython-38.opt-2.pycnu�[���U

e5d���@sbddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddddddd	d
ddd
dddddddgZdZdZ
dZdZdZdZe��ejj�dd�ejj��D�ZdZdZe�d�jZe�d �jZe�d!�Ze�d"�Z d#d$d%hZ!dAd'd(�Z"Gd)d*�d*ej#j$�Z%d+d,�Z&e%fd-d.�Z'Gd/d�dej(�Z)Gd0d�d�Z*zddl+Z+Wne,k
�r\YnXGd1d2�d2e*�Z-e�.d2�Gd3d�de/�Z0Gd4d�de0�Z1Gd5d�de0�Z2Gd6d�de0�Z3Gd7d�de0�Z4Gd8d	�d	e0�Z5Gd9d
�d
e0�Z6Gd:d�de0�Z7Gd;d
�d
e7�Z8Gd<d�de7�Z9Gd=d�de7�Z:Gd>d�de0�Z;Gd?d�de0�Z<Gd@d�de=e;�Z>e0Z?dS)B�N)�urlsplit�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}||j�qS�)�phrase)�.0�vrr�#/usr/lib64/python3.8/http/client.py�
<dictcomp>jsri�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUT�datac
Cshz|�d�WStk
rb}z8t|j|j|j|jd|��||j|j�|f�d�W5d}~XYnXdS)N�latin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s���r(c@seZdZdd�ZdS)�HTTPMessagecCsj|��d}t|�}g}d}|��D]@}|d|���|krBd}n|dd���sVd}|r$|�|�q$|S)N�:r�)�lower�len�keys�isspace�append)�selfr&�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r4rrrrr)�sr)cCsXg}|�td�}t|�tkr&td��|�|�t|�tkrHtdt��|dkrqTq|S)Nr+�header linezgot more than %d headers��
�
�)�readline�_MAXLINEr-rr0�_MAXHEADERSr)�fp�headersr3rrr�
_read_headers�s
rBcCs,t|�}d�|��d�}tjj|d��|�S)Nr<�
iso-8859-1)�_class)rB�join�decode�email�parserZParserZparsestr)r@rDrAZhstringrrr�
parse_headers�s
rIcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdBd(d)�ZdCd*d+�ZdD�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdEd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)FrrNcCsR|�d�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)Zmakefiler@�
debuglevel�_methodrA�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r1�sockrK�method�urlrrr�__init__�szHTTPResponse.__init__cCst|j�td�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��z|�
dd�\}}}WnFtk
r�z|�
dd�\}}d}Wntk
r�d}YnXYnX|�d	�s�|�
�t|��z$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr+rCzstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr@r=r>r-rrK�print�reprr�split�
ValueError�
startswith�_close_connr�int)r1r3rOrPrQrrr�_read_statuss2

zHTTPResponse._read_statusc	Cs�|jdk	rdS|��\}}}|tkr&qHt|j�}|jdkrDtd|�~q||_|_|�	�|_
|dkrnd|_n|�d�r�d|_nt
|��t|j�|_|_|jdkr�|j��D]\}}td|d|�q�|j�d	�}|r�|��d
kr�d|_d|_nd|_|��|_d|_|j�d
�}|�rb|j�sbzt|�|_Wntk
�rLd|_YnX|jdk�rhd|_nd|_|tk�s�|tk�s�d|k�r�dk�s�n|jdk�r�d|_|j�s�|j�s�|jdk�r�d|_dS)Nrzheaders:)zHTTP/1.0zHTTP/0.9�
zHTTP/1.��header:r*�transfer-encodingrRTF�content-lengthr���HEAD)rArdZCONTINUErBr@rKr]�coderP�striprQrOrarrIrM�items�getr,rRrS�_check_closerUrTrcr`Z
NO_CONTENTZNOT_MODIFIEDrL)	r1rOrPrQZskipped_headers�hdr�valZtr_encrTrrr�begin5sf







�
�
���zHTTPResponse.begincCsv|j�d�}|jdkr.|r*d|��kr*dSdS|j�d�r>dS|rRd|��krRdS|j�d�}|rrd|��krrdSdS)NZ
connectionrf�closeTFz
keep-alivezproxy-connection)rArorOr,)r1ZconnZpconnrrrrp}s
zHTTPResponse._check_closecCs|j}d|_|��dS�N)r@rt)r1r@rrrrb�szHTTPResponse._close_conncs$zt���W5|jr|��XdSru)r@rb�superrt�r1��	__class__rrrt�szHTTPResponse.closecst���|jr|j��dSru)rv�flushr@rwrxrrrz�s
zHTTPResponse.flushcCsdS)NTrrwrrr�readable�szHTTPResponse.readablecCs
|jdkSru)r@rwrrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|��dS|dk	rRt|�}|�|�}t|�d|���S|jr`|��S|j	dkrv|j�
�}n6z|�|j	�}Wntk
r�|���YnXd|_	|��|SdS)Nr<rkr)
r@rLrb�	bytearray�readinto�
memoryview�tobytesrR�_readall_chunkedrT�read�
_safe_readr
)r1�amt�br2�srrrr��s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|��dS|jr4|�|�S|jdk	r^t|�|jkr^t|�d|j�}|j�|�}|s||r||��n&|jdk	r�|j|8_|js�|��|S)Nrrk)	r@rLrbrR�_readinto_chunkedrTr-rr~)r1r�r2rrrr~�s$





zHTTPResponse.readintocCsr|j�td�}t|�tkr$td��|�d�}|dkrB|d|�}zt|d�WStk
rl|���YnXdS)Nr+z
chunk size�;r�)	r@r=r>r-r�findrcr`rb)r1r3�irrr�_read_next_chunk_sizes
z"HTTPResponse._read_next_chunk_sizecCs:|j�td�}t|�tkr$td��|s*q6|dkrq6qdS)Nr+ztrailer liner9)r@r=r>r-r�r1r3rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|�d�z|��}Wntk
rDtd��YnX|dkrb|��|��d}||_|S)NrZr<r)rSr�r�r`r
r�rb)r1rSrrr�_get_chunk_left s
zHTTPResponse._get_chunk_leftcCsbg}z6|��}|dkrq0|�|�|��d|_qd�|�WStk
r\td�|���YnXdS�Nrr<)r�r0r�rSrEr
)r1�valuerSrrrr�8szHTTPResponse._readall_chunkedcCs�d}t|�}zv|��}|dkr$|WSt|�|krN|�|�}|||_||WS|d|�}|�|�}||d�}||7}d|_qWn(tk
r�tt|d|����YnXdS)Nr)rr�r-�_safe_readintorSr
�bytes)r1r�Ztotal_bytesZmvbrSr2Ztemp_mvbrrrr�Fs"



zHTTPResponse._readinto_chunkedcCs.|j�|�}t|�|kr*t||t|���|Sru)r@r�r-r
)r1r�rrrrr�^szHTTPResponse._safe_readcCs:t|�}|j�|�}||kr6tt|d|��||��|Sru)r-r@r~r
r�)r1r�r�r2rrrr�js
zHTTPResponse._safe_readinto���cCs�|jdks|jdkrdS|jr(|�|�S|jdk	rJ|dksD||jkrJ|j}|j�|�}|sh|rh|��n|jdk	r�|jt|�8_|S�Nrkr<r)r@rLrR�_read1_chunkedrT�read1rbr-)r1r2�resultrrrr�rs


zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|�|�S|j�|�S)Nrkr<)r@rLrR�
_peek_chunked�peek)r1r2rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t��|�S|jdk	rL|dksF||jkrL|j}|j�|�}|sj|rj|��n|jdk	r�|jt|�8_|Sr�)r@rLrRrvr=rTrbr-)r1�limitr�rxrrr=�s

zHTTPResponse.readlinecCsd|��}|dks|dkrdSd|kr0|ks6n|}|j�|�}|jt|�8_|s`td��|Sr�)r�r@r�rSr-r
)r1r2rSr�rrrr��szHTTPResponse._read1_chunkedcCsDz|��}Wntk
r"YdSX|dkr0dS|j�|�d|�S)Nr<)r�r
r@r�)r1r2rSrrrr��szHTTPResponse._peek_chunkedcCs
|j��Sru)r@�filenorwrrrr��szHTTPResponse.filenocCsF|jdkrt��|j�|�p|}t|t�s4t|d�s8|Sd�|�SdS)N�__iter__z, )rArZget_all�
isinstancer\�hasattrrE)r1r&�defaultrArrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|j���Sru)rAr�listrnrwrrr�
getheaders�s
zHTTPResponse.getheaderscCs|Srurrwrrrr��szHTTPResponse.__iter__cCs|jSru)rArwrrr�info�szHTTPResponse.infocCs|jSru)rXrwrrr�geturl�s
zHTTPResponse.geturlcCs|jSru)rPrwrrr�getcode�szHTTPResponse.getcode)rNN)N)r�)r�)r�)N)"r5r6r7rYrdrsrprbrtrzr{r|r�r~r�r�r�r�r�r�r�r�r�r=r�r�r�r�r�r�r�r�r��
__classcell__rrrxrr�s<	
!H

 "

	

c@s
eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	d
fdd�Zd7d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd8d d!�Zd9d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d:dd.�d/d0�Z!d	ifdd.�d1d2�Z"d3d4�Z#d5d6�Z$d	S);rrfzHTTP/1.1r+rcCst|tj�Sru)r��io�
TextIOBase)�streamrrr�
_is_textIOszHTTPConnection._is_textIOcCsf|dkr|��tkrdSdSt|d�r*dSzt|�}|jWStk
rNYnXt|t�rbt|�SdS)Nrr�)	�upper�_METHODS_EXPECTING_BODYr�r�nbytes�	TypeErrorr�r\r-)�bodyrWZmvrrr�_get_content_lengths

z"HTTPConnection._get_content_lengthN� cCsn||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|�||�\|_
|_|�|j
�tj|_dSru)�timeout�source_address�	blocksizerV�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterL�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�_validate_host�socketZcreate_connection�_create_connection)r1r�r�r�r�r�rrrrY4szHTTPConnection.__init__cCs<|jrtd��|�||�\|_|_|r.||_n
|j��dS)Nz.Can't set up tunnel for established connection)rV�RuntimeErrorr�r�r�r��clear)r1r�r�rArrr�
set_tunnelJszHTTPConnection.set_tunnelcCs�|dkr�|�d�}|�d�}||kr�zt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd�}||fS)	Nr*�]r+r[znonnumeric port: '%s'r�[r�)�rfindrcr`�default_portr)r1r�r�r��jrrrr�bs

zHTTPConnection._get_hostportcCs
||_dSru)rK)r1�levelrrr�set_debuglevelvszHTTPConnection.set_debuglevelcCs�d|j|jf}|�d�}|�|�|j��D](\}}d||f}|�d�}|�|�q.|�d�|j|j|jd�}|�	�\}}	}
|	t
jjkr�|�
�td|	|
��f��|j�td�}t|�tkr�td	��|s�q�|d
kr�q�|jdkr�td|���q�dS)
NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
rr:�rWzTunnel connection failed: %d %sr+r8r9rrg)r�r�r�sendr�rn�response_classrVrLrd�http�
HTTPStatusZOKrt�OSErrorrmr@r=r>r-rrKr]rF)r1Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserOrl�messager3rrr�_tunnelys4�



�
zHTTPConnection._tunnelcCsB|�|j|jf|j|j�|_|j�tjtj	d�|j
r>|��dS)Nr+)r�r�r�r�r�rVZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�rwrrr�connect�s
�zHTTPConnection.connectcCsBt|_z|j}|r d|_|��W5|j}|r<d|_|��XdSru)r�r�r�rtrV)r1r�rVrrrrt�szHTTPConnection.closecCs|jdkr |jr|��nt��|jdkr8tdt|��t|d�r�|jdkrTtd�|�|�}|rt|jdkrttd�|�	|j
�}|s�q�|r�|�d�}|j�|�qtdSz|j�|�WnLt
k
�rt|tjj�r�|D]}|j�|�q�nt
dt|���YnXdS)Nrzsend:r��sendIng a read()able�encoding file using iso-8859-1rCz9data should be a bytes-like object or an iterable, got %r)rV�	auto_openr�rrKr]r^r�r�r�r�rZsendallr�r��collections�abc�Iterable�type)r1rr�	datablock�drrrr��s8






�zHTTPConnection.sendcCs|j�|�dSru)r�r0)r1r�rrr�_output�szHTTPConnection._outputccs^|jdkrtd�|�|�}|r2|jdkr2td�|�|j�}|sDqZ|rR|�d�}|Vq2dS)Nrr�r�rC)rKr]r�r�r�r)r1r{rr�rrr�_read_readable�s


zHTTPConnection._read_readableFcCs |j�d�d�|j�}|jdd�=|�|�|dk	�rt|d�rN|�|�}nZzt|�WnFtk
r�zt|�}Wn$tk
r�tdt	|���YnXYnX|f}|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d�d	��d
�|d}|�|�q�|�r|jdk�r|�d�dS)N)r<r<r:r�zAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrf�Xz
r�s0

)r��extendrEr�r�r�rr��iterr�rKr]�	_http_vsnr-r)r1�message_body�encode_chunkedrMZchunks�chunkrrr�_send_output�s:


�
�zHTTPConnection._send_outputcCs�|jr|j��rd|_|jtkr(t|_n
t|j��|�|�||_|pHd}|�|�d|||j	f}|�
|�|��|jdk�r�|�s�d}|�
d�r�t|�\}}}}}|r�z|�d�}Wntk
r�|�d�}YnX|�d|�n�|jr�|j}	|j}
n|j}	|j}
z|	�d�}Wn tk
�r4|	�d�}YnX|	�d	�d
k�rRd|d}|
|jk�rl|�d|�n|�d�}|�dd
||
f�|�s�|�dd�ndS)N�/z%s %s %srfr[r�r�ZidnaZHostr*r�[�]z%s:%szAccept-EncodingZidentity)r�r|r�r��_CS_REQ_STARTEDr
�_validate_methodrL�_validate_path�
_http_vsn_strr��_encode_requestr�rarrr �	putheaderr�r�r�r�r�r�rF)r1rWrX�	skip_host�skip_accept_encoding�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequest sP






zHTTPConnection.putrequestcCs
|�d�S)Nr�)r)r1r�rrrr��szHTTPConnection._encode_requestcCs,t�|�}|r(td|�d|���d���dS)Nz)method can't contain control characters. � (found at least �))�$_contains_disallowed_method_pchar_re�searchr`�group)r1rW�matchrrrr��s

�zHTTPConnection._validate_methodcCs,t�|�}|r(td|�d|���d���dS�Nz&URL can't contain control characters. r�r���!_contains_disallowed_url_pchar_rer�rr�)r1rXr�rrrr��s
zHTTPConnection._validate_pathcCs,t�|�}|r(td|�d|���d���dSr�r)r1r�r�rrrr��s
zHTTPConnection._validate_hostcGs�|jtkrt��t|d�r$|�d�}t|�s:td|f��t|�}t|�D]\\}}t|d�rl|�d�||<nt	|t
�r�t|��d�||<t||�rJtd||f��qJd�
|�}|d|}|�|�dS)Nrr�zInvalid header name %rrzInvalid header value %rs
	s: )r�r�rr�r�_is_legal_header_namer`r��	enumerater�rcr\�_is_illegal_header_valuerEr�)r1r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader�r�cCs*|jtkrt|_nt��|j||d�dS)Nr)r�r��_CS_REQ_SENTrr�)r1r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|�|||||�dSru)�
_send_request)r1rWrXr�rAr�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|�||�}|dkr�|dk	r�|jdkr�td|�d
}|�dd�q�|�dt|��nd
}|��D]\}	}
|�|	|
�q�t|t�r�t	|d�}|j
||d�dS)Ncss|]}|��VqdSru)r,)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r+r�zaccept-encodingr�rirhFrzUnable to determine size of %rTzTransfer-EncodingrRzContent-Lengthr�r)�	frozensetr�r�rKr]r�r\rnr�r(r)r1rWrXr�rAr�Zheader_namesZskipsZcontent_lengthrqr�rrrr	�s0	


zHTTPConnection._send_requestcCs�|jr|j��rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}zNz|�	�Wnt
k
r�|���YnXt|_|j
r�|��n||_|WS|���YnXdS)Nrr�)r�r|r�rrrKr�rVrLrs�ConnectionErrorrtr�rU)r1r�rrr�getresponses.

�
zHTTPConnection.getresponse)NN)NF)FF)N)%r5r6r7r�r�rr��	HTTP_PORTr�r�rK�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrYr�r�r�r�r�rtr�r�r�r�r�r�r�r�r�r�rr�r	rrrrrrsL

�

	&
6�
	
�.csDeZdZeZdddejdfdddd��fdd�Z�fdd�Z�Z	S)�HTTPSConnectionNr�)�context�check_hostnamer�cs�tt|�j|||||	d�|dk	s2|dk	s2|dk	rHddl}
|
�dtd�||_||_|dkrtt�	�}|j
dk	rtd|_
|jtjk}|dkr�|j
}|r�|s�td��|s�|r�|�||�|j
dk	r�d|_
||_|dk	r�||j_
dS)N)r�rzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rZTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rvrrY�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr`Zload_cert_chain�_context)r1r�r�rrr�r�rrr�rZwill_verifyrxrrrYcs<���

zHTTPSConnection.__init__cs6t���|jr|j}n|j}|jj|j|d�|_dS)N)�server_hostname)rvr�r�r�rZwrap_socketrV)r1rrxrrr��s

�zHTTPSConnection.connect)
r5r6r7�
HTTPS_PORTr�r�rrYr�r�rrrxrr\s��$rc@seZdZdS)rN�r5r6r7rrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dSru)�argsrO)r1rOrrrrY�szUnknownProtocol.__init__N�r5r6r7rYrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)r	Nrrrrrr	�sc@s$eZdZddd�Zdd�ZejZdS)r
NcCs|f|_||_||_dSru)r�partial�expected)r1r!r"rrrrY�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedr[z%s(%i bytes read%s))r"ryr5r-r!)r1�errr�__repr__�s
�zIncompleteRead.__repr__)N)r5r6r7rYr$r"�__str__rrrrr
�s
c@seZdZdS)rNrrrrrr�sc@seZdZdS)r
Nrrrrrr
�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dSru)r^rr3r�rrrrY�szBadStatusLine.__init__Nr rrrrr�sc@seZdZdd�ZdS)rcCst�|dt|f�dS)Nz&got more than %d bytes when reading %s)rrYr>)r1Z	line_typerrrrY�s�zLineTooLong.__init__Nr rrrrr�sc@seZdZdd�ZdS)rcOs"t�|d�tj|f|�|�dS)Nr[)rrY�ConnectionResetError)r1�pos�kwrrrrY�szRemoteDisconnected.__init__Nr rrrrr�s)r)@Zemail.parserrGZ
email.messager�r��rer�Zcollections.abcr�Zurllib.parser�__all__rrrNr�r�r�globals�updater��__members__rrr>r?�compile�	fullmatchrr�rrr�r�r(r�ZMessager)rBrI�BufferedIOBaserrr�ImportErrorrr0�	Exceptionrrrrrr	r
rr
rrrrr&rrrrrr�<module>Gs��



W8
PK|/�\���I*I*cookies.cpython-38.opt-2.pycnu�[���U

e5d�O�
@spddlZddlZdddgZdjZdjZdjZGdd�de�Zej	ej
d	Zed
Zdd�e
ed
��e
eee��D�Ze�ed�ded�di�e�de�e��jZdd�Ze�d�Ze�d�Zdd�ZdddddddgZdd d!d"d#d$d%d&d'd(d)d*d+g
Zdeefd,d-�ZGd.d/�d/e�Zd0Z e d1Z!e�d2e d3e!d4ej"ej#B�Z$Gd5d�de�Z%Gd6d�de%�Z&dS)7�N�CookieError�
BaseCookie�SimpleCookie�z; � c@seZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�$/usr/lib64/python3.8/http/cookies.pyr�sz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}|d|�qS)z\%03or
)�.0�nr
r
r�
<dictcomp>�s�r��"�\"�\z\\z[%s]+cCs*|dkst|�r|Sd|�t�dSdS)Nr)�
_is_legal_key�	translate�_Translator��strr
r
r�_quote�srz\\[0-3][0-7][0-7]z[\\].cCsN|dkst|�dkr|S|ddks0|ddkr4|S|dd�}d}t|�}g}d|krf|k�rFnn�t�||�}t�||�}|s�|s�|�||d���qFd}}|r�|�d�}|r�|�d�}|�r|r�||k�r|�|||��|�||d�|d}qP|�|||��|�tt||d|d�d���|d}qPt|�S)N�rr������)	�len�
_OctalPatt�search�
_QuotePatt�append�start�chr�int�	_nulljoin)r�ir
�resZo_matchZq_match�j�kr
r
r�_unquote�s6


$
r+ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r-r,)ZfutureZweekdaynameZ	monthnamer,r-ZnowZyearZmonthZdayZhhZmmZssZwd�y�zr
r
r�_getdate�s�r0c
@s�eZdZddddddddd	d
�	ZddhZd
d�Zedd��Zedd��Zedd��Z	dd�Z
d1dd�Zdd�Ze
jZdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd2d)d*�ZeZd+d,�Zd3d-d.�Zd4d/d0�ZdS)5�Morsel�expires�Path�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersionZSameSite)	r2�path�commentZdomain�max-age�secure�httponly�versionZsamesiter8r9cCs0d|_|_|_|jD]}t�||d�qdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyr
r
r�__init__ s
zMorsel.__init__cCs|jS�N)r;�rAr
r
rrB(sz
Morsel.keycCs|jSrD)r<rEr
r
r�value,szMorsel.valuecCs|jSrD)r=rEr
r
r�coded_value0szMorsel.coded_valuecCs2|��}||jkr td|f��t�|||�dS�NzInvalid attribute %r)�lowerr>rr?r@)rA�K�Vr
r
rr@4s
zMorsel.__setitem__NcCs.|��}||jkr td|f��t�|||�SrH)rIr>rr?�
setdefault)rArB�valr
r
rrL:s
zMorsel.setdefaultcCs>t|t�stSt�||�o<|j|jko<|j|jko<|j|jkSrD)�
isinstancer1�NotImplementedr?�__eq__r<r;r=�rAZmorselr
r
rrP@s

�
�
�z
Morsel.__eq__cCs$t�}t�||�|j�|j�|SrD)r1r?�update�__dict__rQr
r
r�copyJszMorsel.copycCsRi}t|���D]0\}}|��}||jkr8td|f��|||<qt�||�dSrH)r?�itemsrIr>rrR)rA�values�datarBrMr
r
rrRPs

z
Morsel.updatecCs|��|jkSrD)rIr>)rArJr
r
r�
isReservedKeyYszMorsel.isReservedKeycCsH|��|jkrtd|f��t|�s2td|f��||_||_||_dS)Nz Attempt to set a reserved key %rzIllegal key %r)rIr>rrr;r<r=)rArBrMZ	coded_valr
r
r�set\sz
Morsel.setcCs|j|j|jd�S)N)rBrFrG�r;r<r=rEr
r
r�__getstate__gs�zMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrBrFrGrZ)rA�stater
r
r�__setstate__ns

zMorsel.__setstate__�Set-Cookie:cCsd||�|�fS)Nz%s %s)�OutputString)rA�attrs�headerr
r
r�outputssz
Morsel.outputcCsd|jj|��fS)N�<%s: %s>)�	__class__rr_rEr
r
r�__repr__xszMorsel.__repr__cCsd|�|��dd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rr)r_�replace)rAr`r
r
r�	js_output{s�zMorsel.js_outputcCs$g}|j}|d|j|jf�|dkr,|j}t|���}|D]�\}}|dkrNq<||krXq<|dkr�t|t�r�|d|j|t|�f�q<|dkr�t|t�r�|d|j||f�q<|dkr�t|t	�r�|d|j|t
|�f�q<||jk�r|�r|t	|j|��q<|d|j||f�q<t|�S)N�%s=%srr2r7z%s=%dr6)
r"rBrGr>�sortedrUrNr%r0rr�_flags�_semispacejoin)rAr`�resultr"rUrBrFr
r
rr_�s,zMorsel.OutputString)N)Nr^)N)N)rrr	r>rjrC�propertyrBrFrGr@rLrP�object�__ne__rTrRrXrYr[r]rb�__str__rergr_r
r
r
rr1�sB�



	


r1z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@sjeZdZdd�Zdd�Zddd�Zdd	�Zd
d�Zddd�ZeZ	dd�Z
ddd�Zdd�Ze
fdd�ZdS)rcCs||fSrDr
�rArMr
r
r�value_decode�szBaseCookie.value_decodecCst|�}||fSrDr�rArMZstrvalr
r
r�value_encode�szBaseCookie.value_encodeNcCs|r|�|�dSrD)�load)rA�inputr
r
rrC�szBaseCookie.__init__cCs.|�|t��}|�|||�t�|||�dSrD)�getr1rYr?r@)rArBZ
real_valuerG�Mr
r
rZ__set�szBaseCookie.__setcCs:t|t�rt�|||�n|�|�\}}|�|||�dSrD)rNr1r?r@rt�_BaseCookie__set)rArBrF�rval�cvalr
r
rr@�s
zBaseCookie.__setitem__r^�
cCs:g}t|���}|D]\}}|�|�||��q|�|�SrD)rirUr"rb�join)rAr`ra�seprlrUrBrFr
r
rrb�s
zBaseCookie.outputcCsJg}t|���}|D] \}}|�d|t|j�f�qd|jjt|�fS)Nrhrc)rirUr"�reprrFrdr�
_spacejoin)rA�lrUrBrFr
r
rre�s
zBaseCookie.__repr__cCs6g}t|���}|D]\}}|�|�|��qt|�SrD)rirUr"rgr&)rAr`rlrUrBrFr
r
rrgs
zBaseCookie.js_outputcCs4t|t�r|�|�n|��D]\}}|||<qdSrD)rNr�_BaseCookie__parse_stringrU)rAZrawdatarBrFr
r
rru
s


zBaseCookie.loadcCshd}t|�}g}d}d}d}d|kr2|k�rnn�|�||�}	|	sJ�q|	�d�|	�d�}
}|	�d�}|
ddkr�|s|q|�||
dd�|f�q|
��tjkr�|s�dS|dkr�|
��tjkr�|�||
df�q�dSn|�||
t	|�f�q|dk	�r|�||
|�
|�f�d}qdSqd}|D]>\}
}
}|
|k�rB|||
<n|\}}|�|
||�||
}�q$dS)	NrFrrrBrM�$T)r�match�group�endr"rIr1r>rjr+rrry)rArZpattr'r
Zparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�rBrFrx�tprzr{r
r
rZ__parse_stringsF



zBaseCookie.__parse_string)N)Nr^r|)N)rrr	rrrtrCryr@rbrprergru�_CookiePatternr�r
r
r
rr�s		
	

c@seZdZdd�Zdd�ZdS)rcCst|�|fSrD)r+rqr
r
rrr\szSimpleCookie.value_decodecCst|�}|t|�fSrD)rrrsr
r
rrt_szSimpleCookie.value_encodeN)rrr	rrrtr
r
r
rrUs)'�re�string�__all__r}r&rkr��	ExceptionrZ
ascii_lettersZdigitsZ_LegalCharsZ_UnescapedCharsrY�range�map�ordrrR�compile�escape�	fullmatchrrrr!r+Z_weekdaynameZ
_monthnamer0r?r1Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrr
r
r
r�<module>�sp
��

2�4����
�
PK|/�\M3�1����cookiejar.cpython-38.opt-1.pycnu�[���U

e5d#,�@sdZddddddddgZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
l	Zd	d
l
Zd	d
lZ
d	dlmZdZd
ad
d�Zee
jj�ZdZdd�ZdZdd�ZdddddddgZddddd d!d"d#d$d%d&d'gZgZeD]Ze�e� ��q�dud(d)�Z!dvd*d+�Z"d
d
d
d
d,�Z#e�$d-ej%�Z&d.d/�Z'd0d1�Z(e�$d2ej%�Z)e�$d3ej*ej%B�Z+e�$d4ej,ej%B�Z-d5d6�Z.e�$d7ej,ej%B�Z/d8d9�Z0d:d;�Z1e�$d<�Z2e�$d=�Z3e�$d>�Z4e�$d?�Z5d@dA�Z6e�$dB�Z7dCdD�Z8dEdF�Z9dGdH�Z:e�$dIej%�Z;dJdK�Z<dLdM�Z=dNdO�Z>dPdQ�Z?e�$dRej%�Z@dSdT�ZAdUdV�ZBdWdX�ZCdYdZ�ZDd[ZEe�$d\�ZFd]d^�ZGd_d`�ZHdadb�ZIdcdd�ZJGded�d�ZKGdfd�d�ZLGdgd�deL�ZMdhdi�ZNdjdk�ZOGdldm�dm�ZPGdnd�d�ZQGdod�deR�ZSGdpd�deQ�ZTdqdr�ZUGdsd�deT�ZVGdtd�deT�ZWd
S)wa�HTTP cookie handling for web clients.

This module has (now fairly distant) origins in Gisle Aas' Perl module
HTTP::Cookies, from the libwww-perl library.

Docstrings, comments and debug strings in this code refer to the
attributes of the HTTP cookie system as cookie-attributes, to distinguish
them clearly from Python attributes.

Class diagram (note that BSDDBCookieJar and the MSIE* classes are not
distributed with the Python standard library, but are available from
http://wwwsearch.sf.net/):

                        CookieJar____
                        /     \      \
            FileCookieJar      \      \
             /    |   \         \      \
 MozillaCookieJar | LWPCookieJar \      \
                  |               |      \
                  |   ---MSIEBase |       \
                  |  /      |     |        \
                  | /   MSIEDBCookieJar BSDDBCookieJar
                  |/
               MSIECookieJar

�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|�d�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�&/usr/lib64/python3.8/http/cookiejar.py�_debug,s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|��}|�d|�|��}|jd|dd�dS)Nr	zhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)rrr�f�msgrrr�_warn_unhandled_exception:s
ri�cCs�|dd�\}}}}}}|tkr�d|kr4dkr�nnhd|krLdkr�nnPd|krddkr�nn8d|kr|dkr�nn d|kr�dkr�nnt|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmIs&8��
��
��
r,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtj��}ntj�|�}d|j|j|j|j|j|jfS)aHReturn a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
    representing Universal Time (UTC, aka GMT).  An example of this format is:

    1994-11-24 08:49:37Z

    Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second��tZdtrrr�	time2isozWs�r5cCsR|dkrtj��}ntj�|�}dt|��|jt|jd|j|j	|j
|jfS)z�Return a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like this:

    Wed, DD-Mon-YYYY HH:MM:SS GMT

    Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2r3rrr�
time2netscapejs
�r8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTt�|�}|rfdt|�d��}|�d�rR|dt|�d��}|�d�dkrf|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s

rFc
Cs�t|�}|tjkrdSzt�|���d}Wn^tk
r�zt|�}Wntk
r`YYdSXd|krvdkr�nn|}nYdSYnX|dkr�d}|dkr�d}|dkr�d}t|�}t|�}t|�}t|�}|dk�r6t�t���d}|d}	|}
|||	}|	|
}	t	|	�dk�r6|	dk�r.|d}n|d}t
|||||||f�}|dk	�r�|dk�rdd}|��}t|�}|dk�r�dS||}|S)Nrr r	i��d�2r9)
rAr-ZMAXYEAR�MONTHS_LOWER�index�lower�
ValueError�time�	localtime�absr,�upperrF)
r0�mon�yr�hrr*r+rCZimonZcur_yrrEZtmpr4rDrrr�	_str2time�sV







rTzV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    (?:
       ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
       \s*
    )?
    (?:
       \(\w+\)         # ASCII representation of timezone in parens.
       \s*
    )?$cCs�t�|�}|rl|��}t�|d���d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|�	�}t
�d|d�}dgd	\}}}}}}	}
t�|�}|dk	r�|��\}}}}}}	}
ndSt
||||||	|
�S)
a�Returns time in seconds since epoch of time represented by a string.

    Return value is an integer.

    None is returned if the format of str is unrecognized, the time is outside
    the representable range, or the timezone string is not recognized.  If the
    string contains no timezone, UTC is assumed.

    The timezone in the string may be numerical (like "-0800" or "+0100") or a
    string timezone (like "UTC", "GMT", "BST" or "EST").  Currently, only the
    timezone strings equivalent to UTC (zero offset) are known to the function.

    The function loosely parses the following formats:

    Wed, 09 Feb 1994 22:23:32 GMT       -- HTTP format
    Tuesday, 08-Feb-94 14:15:29 GMT     -- old rfc850 HTTP format
    Tuesday, 08-Feb-1994 14:15:29 GMT   -- broken rfc850 HTTP format
    09 Feb 1994 22:23:32 GMT            -- HTTP format (no weekday)
    08-Feb-94 14:15:29 GMT              -- rfc850 format (no weekday)
    08-Feb-1994 14:15:29 GMT            -- broken rfc850 format (no weekday)

    The parser ignores leading and trailing whitespace.  The time may be
    absent.

    If the year is given with only 2 digits, the function will select the
    century that makes the year closest to the current date.

    rrr	r;���N�)�STRICT_DATE_REr@�groupsrIrJrKrA�floatr,�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_RErT)�textrE�grQr&r0rRrSr*r+rCrrr�	http2time�s$



�
rba�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   (?:
      ([-+]?\d\d?:?(:?\d\d)?
       |Z|z)             # timezone  (Z is "zero meridian", i.e. GMT)
      \s*
   )?$c
Csd|��}dgd\}}}}}}}t�|�}|dk	rL|��\}}}}}}}}	ndSt|||||||�S)av
    As for http2time, but parses the ISO 8601 formats:

    1994-02-03 14:15:29 -0100    -- ISO 8601 format
    1994-02-03 14:15:29          -- zone is optional
    1994-02-03                   -- only date
    1994-02-03T14:15:29          -- Use T as separator
    19940203T141529Z             -- ISO 8601 compact format
    19940203                     -- only date

    NrX)r\�ISO_DATE_REr@rZrT)
r`r0rQrRrSr*r+rCrE�_rrr�iso2time+s

recCs*|�d�\}}|jd|�|j|d�S)z)Return unmatched part of re.Match object.r	N)�span�string)�match�start�endrrr�	unmatchedLsrkz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Csg}|D]�}|}g}|r�t�|�}|r�t|�}|�d�}t�|�}|rft|�}|�d�}t�d|�}n.t�|�}|r�t|�}|�d�}|��}nd}|�	||f�q|�
��d�r�|�
�dd�}|r�|�	|�g}qt�
dd|�\}}	|}q|r|�	|�q|S)amParse header values into a list of lists containing key,value pairs.

    The function knows how to deal with ",", ";" and "=" as well as quoted
    values after "=".  A list of space separated tokens are parsed as if they
    were separated by ";".

    If the header_values passed as argument contains multiple values, then they
    are treated as if they were a single value separated by comma ",".

    This means that this function is useful for parsing header fields that
    follow this syntax (BNF as from the HTTP/1.1 specification, but we relax
    the requirement for tokens).

      headers           = #header
      header            = (token | parameter) *( [";"] (token | parameter))

      token             = 1*<any CHAR except CTLs or separators>
      separators        = "(" | ")" | "<" | ">" | "@"
                        | "," | ";" | ":" | "\" | <">
                        | "/" | "[" | "]" | "?" | "="
                        | "{" | "}" | SP | HT

      quoted-string     = ( <"> *(qdtext | quoted-pair ) <"> )
      qdtext            = <any TEXT except <">>
      quoted-pair       = "\" CHAR

      parameter         = attribute "=" value
      attribute         = token
      value             = token | quoted-string

    Each header is represented by a list of key/value pairs.  The value for a
    simple token (not part of a parameter) is None.  Syntactically incorrect
    headers will not necessarily be parsed as you would want.

    This is easier to describe with some examples:

    >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz'])
    [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]]
    >>> split_header_words(['text/html; charset="iso-8859-1"'])
    [[('text/html', None), ('charset', 'iso-8859-1')]]
    >>> split_header_words([r'Basic realm="\"foo\bar\""'])
    [[('Basic', None), ('realm', '"foobar"')]]

    rz\1N�,z^[=\s;]*rW)�HEADER_TOKEN_REr@rkrB�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr^�HEADER_VALUE_RE�rstrip�appendr\�
startswith�re�subn)
Z
header_values�resultr`Z	orig_text�pairsrE�name�valueZnon_junkZ
nr_junk_charsrrr�split_header_wordsUs>.







rz�([\"\\])cCs|g}|D]h}g}|D]F\}}|dk	rPt�d|�sDt�d|�}d|}d||f}|�|�q|r|�d�|��qd�|�S)a�Do the inverse (almost) of the conversion done by split_header_words.

    Takes a list of lists of (key, value) pairs and produces a single header
    value.  Attribute values are quoted if needed.

    >>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]])
    'text/plain; charset="iso-8859-1"'
    >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]])
    'text/plain, charset="iso-8859-1"'

    Nz^\w+$�\\\1z"%s"�%s=%s�; �, )rtr@�HEADER_JOIN_ESCAPE_REr^rr�join)Zlists�headersrw�attr�k�vrrr�join_header_words�sr�cCs0|�d�r|dd�}|�d�r,|dd�}|S)N�"r���)rs�endswith�r`rrr�strip_quotes�s


r�cCs�d}g}|D]�}g}d}t|�d��D]�\}}|��}|�d�\}}	}
|��}|sb|dkr&q�nq&|	rn|
��nd}
|dkr�|��}||kr�|}|dkr�|
dk	r�t|
�}
d}n|d	kr�|
dk	r�tt|
��}
|�||
f�q&|r|s�|�d
�|�|�q|S)a5Ad-hoc parser for Netscape protocol cookie-attributes.

    The old Netscape cookie format for Set-Cookie can for instance contain
    an unquoted "," in the expires field, so we have to use this ad-hoc
    parser instead of split_header_words.

    XXX This may not make the best possible effort to parse all the crap
    that Netscape Cookie headers contain.  Ronald Tschalar's HTTPClient
    parser is probably better, so could do worse than following that if
    this ever gives any trouble.

    Currently, this is also used for parsing RFC 2109 cookies.

    )�expires�domain�path�secure�version�port�max-ageF�;�=r	Nr�Tr�)r��0)�	enumerate�split�strip�	partitionrKr�rbrr)Z
ns_headersZknown_attrsrvZ	ns_headerrw�version_setZiiZparam�key�sep�val�lcrrr�parse_ns_headers�s>
r�z\.\d+$cCs:t�|�rdS|dkrdS|ddks2|ddkr6dSdS)z*Return True if text is a host domain name.FrWr	�.r�T��IPV4_REr@r�rrr�is_HDNs
r�cCsl|��}|��}||krdSt|�s(dS|�|�}|dksB|dkrFdS|�d�sTdSt|dd��shdSdS)a�Return True if domain A domain-matches domain B, according to RFC 2965.

    A and B may be host domain names or IP addresses.

    RFC 2965, section 1:

    Host names can be specified either as an IP address or a HDN string.
    Sometimes we compare one host name with another.  (Such comparisons SHALL
    be case-insensitive.)  Host A's name domain-matches host B's if

         *  their host name strings string-compare equal; or

         * A is a HDN string and has the form NB, where N is a non-empty
            name string, B has the form .B', and B' is a HDN string.  (So,
            x.y.com domain-matches .Y.com but not Y.com.)

    Note that domain-match is not a commutative operation: a.b.c.com
    domain-matches .c.com, but not the reverse.

    TFr�r	r�rN)rKr��rfindrs)�A�B�irrr�domain_matchs

r�cCst�|�rdSdS)zdReturn True if text is a sort-of-like a host domain name.

    For accepting/blocking domains.

    FTr�r�rrr�liberal_is_HDNFs
r�cCs`|��}|��}t|�r t|�s0||kr,dSdS|�d�}|rL|�|�rLdS|s\||kr\dSdS)z\For blocking/accepting domains.

    A and B may be host domain names or IP addresses.

    TFr�)rKr�rsr�)r�r��initial_dotrrr�user_domain_matchPs
r�z:\d+$cCsB|��}tj�|�d}|dkr,|�dd�}t�d|d�}|��S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    rrWZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer^rK)�request�url�hostrrr�request_hostesr�cCs4t|�}}|�d�dkr,t�|�s,|d}||fS)zzReturn a tuple (request-host, effective request-host name).

    As defined by RFC 2965, except both are lowercased.

    r�r��.local)r��findr�r@)r��erhn�req_hostrrr�eff_request_hostusr�cCs4|��}tj�|�}t|j�}|�d�s0d|}|S)z6Path component of request-URI, as defined by RFC 2965.�/)r�r�r�Zurlsplit�escape_pathr�rs)r�r��partsr�rrr�request_path�s

r�cCs`|j}|�d�}|dkrX||dd�}zt|�Wq\tk
rTtd|�YdSXnt}|S)N�:r	rznonnumeric port: '%s')r�r�rArLr�DEFAULT_HTTP_PORT)r�r�r�r�rrr�request_port�s


r�z%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|�d���S)Nz%%%sr)rBrP)rhrrr�uppercase_escaped_char�sr�cCstj�|t�}t�t|�}|S)zEEscape any invalid characters in HTTP URL, and uppercase all escapes.)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr^r�)r�rrrr��s
r�cCsP|�d�}|dkrL||dd�}|�d�}t|�rL|dksD|dkrLd|S|S)aBReturn reach of host h, as defined by RFC 2965, section 1.

    The reach R of a host name H is defined as follows:

       *  If

          -  H is the host domain name of a host; and,

          -  H has the form A.B; and

          -  A has no embedded (that is, interior) dots; and

          -  B has at least one embedded dot, or B is the string "local".
             then the reach of H is .B.

       *  Otherwise, the reach of H is H.

    >>> reach("www.acme.com")
    '.acme.com'
    >>> reach("acme.com")
    'acme.com'
    >>> reach("acme.local")
    '.local'

    r�r	rNZlocal)r�r�)�hr��brrr�reach�s

r�cCs$t|�}t|t|j��sdSdSdS)z�

    RFC 2965, section 3.3.6:

        An unverifiable transaction is to a third-party host if its request-
        host U does not domain-match the reach R of the request-host O in the
        origin transaction.

    TFN)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
r�c@sNeZdZdZddd�Zdd�Zddd	�Zd
d�Zddd
�Zdd�Z	dd�Z
dS)ra�HTTP Cookie.

    This class represents both Netscape and RFC 2965 cookies.

    This is deliberately a very simple class.  It just holds attributes.  It's
    possible to construct Cookie instances that don't comply with the cookie
    standards.  CookieJar.make_cookies is the factory function for Cookie
    objects -- it deals with cookie parsing, supplying defaults, and
    normalising to the representation used in this class.  CookiePolicy is
    responsible for checking them to see whether they should be accepted from
    and returned to the server.

    Note that the port may be present in the headers, but unspecified ("Port"
    rather than"Port=80", for example); if this is the case, port is None.

    FcCs�|dk	rt|�}|dk	r$tt|��}|dkr<|dkr<td��||_||_||_||_||_|��|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_t�|�|_dS)NTz-if port is None, port_specified must be false)rAr[rLr�rxryr��port_specifiedrKr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�rxryr�r�r�r�r�r�r�r�r�r�r�r��restr�rrr�__init__�s.

zCookie.__init__cCs
||jkS�N�r�)r�rxrrr�has_nonstandard_attrszCookie.has_nonstandard_attrNcCs|j�||�Sr�)r��get)r�rx�defaultrrr�get_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dSr�r�)r�rxryrrr�set_nonstandard_attr szCookie.set_nonstandard_attrcCs,|dkrt��}|jdk	r(|j|kr(dSdS�NTF)rMr�)r��nowrrr�
is_expired#s
zCookie.is_expiredcCsX|jdkrd}n
d|j}|j||j}|jdk	rFd|j|jf}n|j}d||fS)NrWr�r}z<Cookie %s for %s>)r�r�r�ryrx)r��p�limitZ	namevaluerrr�__str__)s


zCookie.__str__cCslg}dD]$}t||�}|�d|t|�f�q|�dt|j��|�dt|j��d|jjd�|�fS)N)r�rxryr�r�r�r�r�r�r�r�r�r�r�r�r}zrest=%sz
rfc2109=%sz%s(%s)r)�getattrrr�reprr�r��	__class__�__name__r�)r�rrxr�rrr�__repr__3s
zCookie.__repr__)F)N)N)r��
__module__�__qualname__�__doc__r�r�r�r�r�r�r�rrrrr�s�
*


c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)ra Defines which cookies get accepted from and returned to server.

    May also modify cookies, though this is probably a bad idea.

    The subclass DefaultCookiePolicy defines the standard rules for Netscape
    and RFC 2965 cookies -- override that if you want a customized policy.

    cCs
t��dS)z�Return true if (and only if) cookie should be accepted from server.

        Currently, pre-expired cookies never get this far -- the CookieJar
        class deletes such cookies itself.

        N��NotImplementedError�r��cookier�rrr�set_okKszCookiePolicy.set_okcCs
t��dS)zAReturn true if (and only if) cookie should be returned to server.Nr�r�rrr�	return_okTszCookiePolicy.return_okcCsdS)zMReturn false if cookies should not be returned, given cookie domain.
        Tr)r�r�r�rrr�domain_return_okXszCookiePolicy.domain_return_okcCsdS)zKReturn false if cookies should not be returned, given cookie path.
        Tr)r�r�r�rrr�path_return_ok]szCookiePolicy.path_return_okN)r�r�r�r�r�r�r�r�rrrrrBs
	c
@s�eZdZdZdZdZdZdZeeBZdddddddddeddd	f
d
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�ZdS)8rzBImplements the standard rules for accepting and returning cookies.rrrUr	NTF)ZhttpsZwsscCsv||_||_||_||_||_||_|	|_|
|_||_||_	|
|_
|dk	rVt|�|_nd|_|dk	rlt|�}||_
dS)zAConstructor arguments should be passed as keyword arguments only.Nr)�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�secure_protocols�tuple�_blocked_domains�_allowed_domains)r��blocked_domains�allowed_domainsr�r�r�r�r�r�r�r�r�r�r�rrrr�ms"zDefaultCookiePolicy.__init__cCs|jS)z4Return the sequence of blocked domains (as a tuple).)r��r�rrrr��sz#DefaultCookiePolicy.blocked_domainscCst|�|_dS)z$Set the sequence of blocked domains.N)r�r�)r�r�rrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs |jD]}t||�rdSqdSr�)r�r�)r�r�Zblocked_domainrrr�
is_blocked�s

zDefaultCookiePolicy.is_blockedcCs|jS)z=Return None, or the sequence of allowed domains (as a tuple).)r�rrrrr�sz#DefaultCookiePolicy.allowed_domainscCs|dk	rt|�}||_dS)z-Set the sequence of allowed domains, or None.N)r�r�)r�rrrr�set_allowed_domains�sz'DefaultCookiePolicy.set_allowed_domainscCs.|jdkrdS|jD]}t||�rdSqdS)NFT)r�r�)r�r�Zallowed_domainrrr�is_not_allowed�s


z"DefaultCookiePolicy.is_not_allowedcCs@td|j|j�dD]&}d|}t||�}|||�sdSqdS)z�
        If you override .set_ok(), be sure to call this method.  If it returns
        false, so should your subclass (assuming your subclass wants to be more
        strict about which cookies to accept).

        � - checking cookie %s=%s)r��
verifiabilityrxr�r�r�Zset_ok_FT�rrxryr��r�r�r��nZfn_name�fnrrrr��s

zDefaultCookiePolicy.set_okcCsZ|jdkrtd|j|j�dS|jdkr:|js:td�dS|jdkrV|jsVtd�dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	�$   RFC 2965 cookies are switched off�$   Netscape cookies are switched offT)r�rrxryr�r�r�rrr�set_ok_version�s
�z"DefaultCookiePolicy.set_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS�Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT�Zunverifiabler�r�r�rr�r�rrr�set_ok_verifiability�sz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|j�d�r,td|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�r�rxrsrr�rrr�set_ok_name�s
�zDefaultCookiePolicy.set_ok_namecCsL|jrHt|�}|jdks(|jdkrH|jrH|�|j|�sHtd|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�r�r�r�r)r�r�r��req_pathrrr�set_ok_path�s
����zDefaultCookiePolicy.set_ok_pathc
Cs�|�|j�rtd|j�dS|�|j�r8td|j�dS|j�r�t|�\}}|j}|jr�|�d�dkr�|�d�}|�dd|�}|dkr�||dd�}||d|�}	|	�	�dkr�t
|�dkr�td	|�dS|�d�r�|dd�}
n|}
|
�d�dk}|�s|d
k�rtd|�dS|j
dk�rX|�|��sX|�d��sXd|�|��sXtd||�dS|j
dk�sr|j|j@�r�t||��s�td
||�dS|j
dk�s�|j|j@�r�|dt
|��}|�d�dk�r�t�|��s�td||�dSdS)N�"   domain %s is in user block-listF�&   domain %s is not in user allow-listr�rr	r)�coZacZcomZeduZorgZnetZgovZmilrAZaeroZbiz�catZcoop�infoZjobsZmobiZmuseumrxZproZtravelZeuz&   country-code second level domain %sr�z/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rr�rrr�r�r��countr�rK�lenrsr�r�r�r��DomainRFC2965Matchr��DomainStrictNoDotsr�r@)
r�r�r�r�r�r�r��jZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr�
set_ok_domain�s|

�

����
��
���z!DefaultCookiePolicy.set_ok_domainc	Cs�|jr�t|�}|dkrd}nt|�}|j�d�D]@}zt|�Wn"tk
rbtd|�YdSX||kr0q�q0td||j�dSdS)N�80rlz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)r�r��strr�r�rArLr�r�r�r�Zreq_portr�rrr�set_ok_port+s&

�zDefaultCookiePolicy.set_ok_portcCs@td|j|j�dD]&}d|}t||�}|||�sdSqdS)z�
        If you override .return_ok(), be sure to call this method.  If it
        returns false, so should your subclass (assuming your subclass wants to
        be more strict about which cookies to return).

        r)r�rr�r�r�r�Z
return_ok_FTrr	rrrr�@s	

zDefaultCookiePolicy.return_okcCs<|jdkr|jstd�dS|jdkr8|js8td�dSdS)Nr	rFr
T)r�r�rr�r�rrr�return_ok_versionRsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdSrrr�rrr�return_ok_verifiability[sz+DefaultCookiePolicy.return_ok_verifiabilitycCs"|jr|j|jkrtd�dSdS)Nz(   secure cookie with non-secure requestFT)r��typer�rr�rrr�return_ok_securegsz$DefaultCookiePolicy.return_ok_securecCs|�|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowrr�rrr�return_ok_expiresmsz%DefaultCookiePolicy.return_ok_expirescCsN|jrJt|�}|dkrd}|j�d�D]}||kr&qJq&td||j�dSdS)Nr!rlz0   request port %s does not match cookie port %sFT)r�r�r�rr#rrr�return_ok_portss�z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r*|�d�s*d|}n|}|jdkr^|j|j@r^|js^||kr^td�dS|jdkr�t||�s�td||�dS|jdkr�d|�	|�s�td||�dSdS)Nr�r	zQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sz;   request-host %s does not match Netscape cookie domain %sT)
r�r�rsr�r��DomainStrictNonDomainr�rr�r�)r�r�r�r�r�r��	dotdomainrrr�return_ok_domain�s6


�����z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|�d�sd|}|�d�s0d|}|rH|�d�sHd|}n|}|�|�sd|�|�sddS|�|�r|td|�dS|�|�r�td|�dSdS)Nr�FrrT)r�rsr�rrr)r�r�r�r�r�r-rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCsbtd|�t|�}t|�}||kr&dS|�|�rR|�d�sN|||d�dkrRdStd||�dS)Nz- checking cookie path=%sTr�rz  %s does not path-match %sF)rr�rrsr�)r�r�r�rZpathlenrrrr��s

��z"DefaultCookiePolicy.path_return_ok) r�r�r�r�rr,rZ
DomainLiberalZDomainStrictr�r�rrrrrr�rrrrr r$r�r%r&r(r*r+r.r�r�rrrrrcsT�
#	;	cCst|���}t|j|�Sr�)�sorted�keys�mapr�)Zadictr0rrr�vals_sorted_by_key�sr2c	csVt|�}|D]D}d}z
|jWntk
r2YnXd}t|�EdH|s|VqdS)zBIterates over nested mapping, depth-first, in sorted order by key.FTN)r2�items�AttributeError�
deepvalues)�mapping�values�objrrrr5�s
r5c@seZdZdS)�AbsentN�r�r�r�rrrrr9�sr9c@s�eZdZdZe�d�Ze�d�Ze�d�Ze�d�Z	e�d�Z
e�dej�Zd3d	d
�Z
dd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd4d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z d1d2�Z!dS)5rz�Collection of HTTP cookies.

    You may not need to know about this class: try
    urllib.request.build_opener(HTTPCookieProcessor).open(url).
    z\Wr{z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|dkrt�}||_t��|_i|_dSr�)r�_policy�
_threading�RLock�
_cookies_lock�_cookies�r��policyrrrr��s

zCookieJar.__init__cCs
||_dSr�)r;r@rrr�
set_policy�szCookieJar.set_policycCs�g}|j�||�sgStd|�|j|}|��D]T}|j�||�sFq2||}|��D].}|j�||�srtd�qVtd�|�|�qVq2|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r;r�rr?r0r�r7r�rr)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s 

zCookieJar._cookies_for_domaincCs*g}|j��D]}|�|�||��q|S)z2Return a list of cookies to be returned to server.)r?r0�extendrD)r�r�rCr�rrr�_cookies_for_requestszCookieJar._cookies_for_requestc	Cs<|jdd�dd�d}g}|D�]}|j}|sHd}|dkrH|�d|�|jdk	rz|j�|j�rz|dkrz|j�d	|j�}n|j}|jdkr�|�|j�n|�d
|j|f�|dkr|j	r�|�d|j
�|j�d��r|j}|j
s�|�d�r�|d
d�}|�d|�|jdk	rd}|j�r,|d|j}|�|�q|S)z�Return a list of cookie-attributes to be returned to server.

        like ['foo="bar"; $Path="/"', ...]

        The $Version attribute is also added when appropriate (currently only
        once per request).

        cSs
t|j�Sr�)rr�)�arrr�<lambda>�z)CookieJar._cookie_attrs.<locals>.<lambda>T)r��reverseFr	z$Version=%sNr|r}z
$Path="%s"r�rz$Domain="%s"z$Portz="%s")�sortr�rrry�non_word_rer@�quote_rer^rxr�r�r�rsr�r�r�)	r�rCr��attrsr�r�ryr�r�rrr�
_cookie_attrssF


��
�
zCookieJar._cookie_attrscCs�td�|j��z�tt���|j_|_|�|�}|�	|�}|r^|�
d�s^|�dd�|��|jj
r�|jjs�|�
d�s�|D]}|jdkr||�dd�q�q|W5|j��X|��dS)z�Add correct Cookie: header to request (urllib.request.Request object).

        The Cookie2 header is also added unless policy.hide_cookie2 is true.

        �add_cookie_headerrr~ZCookie2rz$Version="1"N)rr>�acquire�releaserArMr;r)rFrOZ
has_headerZadd_unredirected_headerr�r�r�r��clear_expired_cookies)r�r�rCrNr�rrrrPIs*



��

zCookieJar.add_cookie_headerc
Cs�g}d}d}|D�]z}|d\}}d}d}	i}
i}|dd�D�]0\}}
|��}||ks`||krd|}||krx|
dkrxd}
||
kr�q>|dkr�|
dkr�td	�d}	�qr|
��}
|d
kr�|r�q>|
dkr�td�q>|dk�r d}zt|
�}
Wn*tk
�rtd
�d}	Y�qrYnXd
}|j|
}
||k�s4||k�rh|
dk�r^|dk�r^td|�d}	�qr|
|
|<q>|
||<q>|	�rzq|�|||
|f�q|S)aReturn list of tuples containing normalised cookie information.

        attrs_set is the list of lists of key,value pairs extracted from
        the Set-Cookie or Set-Cookie2 headers.

        Tuples are name, value, standard, rest, where name and value are the
        cookie name and value, standard is a dictionary containing the standard
        cookie-attributes (discard, secure, version, expires or max-age,
        domain, path and port) and rest is a dictionary containing the rest of
        the cookie-attributes.

        )r�r�)r�r�r�r�r�r�r��
commenturlr	FrNTr�z%   missing value for domain attributer�zM   missing or invalid value for expires attribute: treating as session cookier�z?   missing or invalid (non-numeric) value for max-age attribute)r�r�rTz!   missing value for %s attribute)rKrrArLr)rr)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsrxryZmax_age_setZ
bad_cookie�standardr�r�r�r�rrr�_normalized_cookie_tuplesjsh





�

z#CookieJar._normalized_cookie_tuplescCs&|\}}}}|�dt�}|�dt�}|�dt�}	|�dt�}
|�dd�}|dk	rtzt|�}Wntk
rrYdSX|�dd�}|�dd�}
|�d	d�}|�d
d�}|tk	r�|dkr�d}t|�}nXd}t|�}|�d
�}|dk�r|dkr�|d|�}n|d|d�}t|�dk�rd
}|tk	}d}|�r:t|�	d��}|tk�rVt
|�\}}|}n|�	d��sjd|}d}|	tk	�r�|	dk�r�t|�}	nd}t�
dd|	�}	nd}	|
tk�r�d}
d}
nH|
|jk�rz|�|||�Wntk
�r�YnXtd|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rTrWTr�r�r	rr�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s')r�r9rArLr�r�r�r�boolrsr�r�rtr^r)�clear�KeyErrorrr)r��tupr�rxryrYr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�_cookie_from_cookie_tuple�s�







��z#CookieJar._cookie_from_cookie_tuplecCs6|�|�}g}|D]}|�||�}|r|�|�q|Sr�)rZr_rr)r�rUr�rVrCr^r�rrr�_cookies_from_attrs_set's
z!CookieJar._cookies_from_attrs_setcCsHt|jdd�}|dkr |jj}|D]}|jdkr$d|_|r$d|_q$dS)Nr�rTr	)r�r;r�r�r�)r�rCZ
rfc2109_as_nsr�rrr�_process_rfc2109_cookies0s

z"CookieJar._process_rfc2109_cookiesc
Cs:|��}|�dg�}|�dg�}tt���|j_|_|jj}|jj}|sN|rf|sV|rf|s^|rf|sj|sjgSz|�t	|�|�}Wnt
k
r�t�g}YnX|�r6|�r6z|�t|�|�}	Wnt
k
r�t�g}	YnX|�
|	�|�r&i}
|D]}d|
|j|j|jf<q�|
fdd�}t||	�}	|	�r6|�|	�|S)zAReturn sequence of Cookie objects extracted from response object.zSet-Cookie2z
Set-CookieNcSs|j|j|jf}||kSr�)r�r�rx)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965isz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)rZget_allrArMr;r)r�r�r`rz�	Exceptionrr�rar�r�rx�filterrE)
r��responser�r�Zrfc2965_hdrsZns_hdrsr�r�rCZ
ns_cookiesrbr�rcrrr�make_cookies<s^�������
�



zCookieJar.make_cookiescCsN|j��z2tt���|j_|_|j�||�r:|�|�W5|j��XdS)z-Set a cookie if policy says it's OK to do so.N)	r>rQrRrArMr;r)r��
set_cookier�rrr�set_cookie_if_okss
zCookieJar.set_cookie_if_okcCsl|j}|j��zJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<W5|j��XdS)z?Set a cookie, without checking whether or not it should be set.N)r?r>rQrRr�r�rx)r�r��cZc2Zc3rrrrh�s






zCookieJar.set_cookiecCsbtd|���|j��z8|�||�D]&}|j�||�r&td|�|�|�q&W5|j��XdS)zAExtract cookies from response, where allowable given the request.zextract_cookies: %sz setting cookie: %sN)	rrr>rQrRrgr;r�rh)r�rfr�r�rrr�extract_cookies�s

zCookieJar.extract_cookiescCst|dk	r2|dks|dkr td��|j|||=n>|dk	rX|dkrJtd��|j||=n|dk	rj|j|=ni|_dS)a�Clear some cookies.

        Invoking this method without arguments will clear all cookies.  If
        given a single argument, only cookies belonging to that domain will be
        removed.  If given two arguments, cookies belonging to the specified
        path within that domain are removed.  If given three arguments, then
        the cookie with the specified name, path and domain is removed.

        Raises KeyError if no matching cookie exists.

        Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLr?)r�r�r�rxrrrr\�s��
zCookieJar.clearcCsD|j��z(|D]}|jr|�|j|j|j�qW5|j��XdS)z�Discard all session cookies.

        Note that the .save() method won't save session cookies anyway, unless
        you ask otherwise by passing a true ignore_discard argument.

        N)r>rQrRr�r\r�r�rx)r�r�rrr�clear_session_cookies�s
zCookieJar.clear_session_cookiescCsP|j��z4t��}|D]"}|�|�r|�|j|j|j�qW5|j��XdS)a�Discard all expired cookies.

        You probably don't need to call this method: expired cookies are never
        sent back to the server (provided you're using DefaultCookiePolicy),
        this method is called by CookieJar itself every so often, and the
        .save() method won't save expired cookies anyway (unless you ask
        otherwise by passing a true ignore_expires argument).

        N)	r>rQrRrMr�r\r�r�rx)r�r�r�rrrrS�s


zCookieJar.clear_expired_cookiescCs
t|j�Sr�)r5r?rrrr�__iter__�szCookieJar.__iter__cCsd}|D]}|d}q|S)z#Return number of contained cookies.r	rr)r�r�r�rrr�__len__�s
zCookieJar.__len__cCs2g}|D]}|�t|��qd|jjd�|�fS�Nz<%s[%s]>r)rrr�r�r�r��r��rr�rrrr��szCookieJar.__repr__cCs2g}|D]}|�t|��qd|jjd�|�fSro)rrr"r�r�r�rprrrr��szCookieJar.__str__)N)NNN)"r�r�r�r�rt�compilerLrMZstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�rBrDrFrOrPrZr_r`rargrirhrkr\rlrSrmrnr�r�rrrrr�s8





;!a\	7


c@seZdZdS)rNr:rrrrr�sc@s8eZdZdZddd�Zd
dd�Zddd	�Zdd
d�ZdS)rz6CookieJar that can be loaded from and saved to a file.NFcCs2t�||�|dk	rt�|�}||_t|�|_dS)z}
        Cookies are NOT loaded from the named file until either the .load() or
        .revert() method is called.

        N)rr��os�fspath�filenamer[�	delayload)r�rwrxrArrrr��s

zFileCookieJar.__init__cCs
t��dS)zSave cookies to a file.Nr�)r�rw�ignore_discard�ignore_expiresrrr�save�szFileCookieJar.savec	CsJ|dkr"|jdk	r|j}ntt��t|��}|�||||�W5QRXdS)zLoad cookies from a file.N)rwrL�MISSING_FILENAME_TEXT�open�_really_load�r�rwryrzrrrr�loads

zFileCookieJar.loadcCs�|dkr"|jdk	r|j}ntt��|j��zFt�|j�}i|_z|�	|||�Wnt
k
rn||_�YnXW5|j��XdS)z�Clear all cookies and reload cookies from a saved file.

        Raises LoadError (or OSError) if reversion is not successful; the
        object's state will not be altered if this happens.

        N)rwrLr|r>rQrRr�Zdeepcopyr?r��OSError)r�rwryrzZ	old_staterrr�revert	s

zFileCookieJar.revert)NFN)NFF)NFF)NFF)r�r�r�r�r�r{r�r�rrrrr�s


	�cCs |j|jfd|jfd|jfg}|jdk	r8|�d|jf�|jrH|�d�|jrX|�d�|jrh|�d�|j	rx|�d�|j
r�|�d	tt|j
��f�|j
r�|�d
�|jr�|�d|jf�|jr�|�d|jf�t|j���}|D]}|�|t|j|�f�q�|�d
t|j�f�t|g�S)z�Return string representation of Cookie in the LWP cookie file format.

    Actually, the format is extended a bit -- see module docstring.

    r�r�Nr�)�	path_specN)�	port_specN)�
domain_dotN)r�Nr�)r�Nr�rTr�)rxryr�r�r�rrr�r�r�r�r�r5r[r�r�r�r/r�r0r"r�r�)r�r�r0r�rrr�lwp_cookie_str$s:
�




�
r�c@s,eZdZdZddd�Zddd�Zd	d
�ZdS)
ra[
    The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
    "Set-Cookie3" is the format used by the libwww-perl library, not known
    to be compatible with any browser, but which is easy to read and
    doesn't lose information about RFC 2965 cookies.

    Additional methods

    as_lwp_str(ignore_discard=True, ignore_expired=True)

    TcCsTt��}g}|D]2}|s |jr q|s0|�|�r0q|�dt|��qd�|dg�S)z�Return cookies as a string of "\n"-separated "Set-Cookie3" headers.

        ignore_discard and ignore_expires: see docstring for FileCookieJar.save

        zSet-Cookie3: %s�
rW)rMr�r�rrr�r�)r�ryrzr�rqr�rrr�
as_lwp_strMs
zLWPCookieJar.as_lwp_strNFc	CsX|dkr"|jdk	r|j}ntt��t|d��"}|�d�|�|�||��W5QRXdS)N�wz#LWP-Cookies-2.0
)rwrLr|r}�writer�rrrrr{]s

zLWPCookieJar.savecCs0|��}|j�|�s$d|}t|��t��}d}d}	d}
�z�|��}|dkrP�q�|�|�s\q<|t|�d���}t|g�D�]f}|d\}
}i}i}|	D]}d||<q�|dd�D]n\}}|dk	r�|�	�}nd}||
ks�||	kr�|}||	k�r|dkr�d	}|||<q�||
k�r|||<q�|||<q�|j
}|d
�}|d�}|dk	�rJt|�}|dk�rXd	}|d�}|�d
�}t|d�|
||d�|d�|||d�|d�|d�|d�|||d�|d�|�}|�s�|j
�r�qz|�s�|�|��r�qz|�|�qzq<WnBtk
�r�Yn,tk
�r*t�td||f��YnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:)r�r�r�r�r�)r�r�r�r�r�r�rTrWr	FrTr�r�r�r�r�r�r�r�r�r�r�r�rTz&invalid Set-Cookie3 format file %r: %r)�readlinertr@rrMrsrr�rzrKr�rerr�r�rhr�rdr)r�rrwryrz�magicrr��headerrWrX�line�datarxryrYr�r�r�r�r�r�r�r�r�rjrrrr~is��










�
�zLWPCookieJar._really_load)TT)NFF)r�r�r�r�r�r{r~rrrrr@s

c@s0eZdZdZe�d�ZdZdd�Zd
dd	�Z	dS)ra�

    WARNING: you may want to backup your browser's cookies file if you use
    this class to save cookies.  I *think* it works, but there have been
    bugs in the past!

    This class differs from CookieJar only in the format it uses to save and
    load cookies to and from a file.  This class uses the Mozilla/Netscape
    `cookies.txt' format.  lynx uses this file format, too.

    Don't expect cookies saved while the browser is running to be noticed by
    the browser (in fact, Mozilla on unix will overwrite your saved cookies if
    you change them on disk while it's running; on Windows, you probably can't
    save at all while the browser is running).

    Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
    Netscape cookies on saving.

    In particular, the cookie version and port number information is lost,
    together with information about whether or not Path, Port and Discard were
    specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
    domain as set in the HTTP header started with a dot (yes, I'm aware some
    domains in Netscape files start with a dot and some don't -- trust me, you
    really don't want to know any more about this).

    Note that though Mozilla and Netscape use the same format, they use
    slightly different headers.  The class saves cookies using the Netscape
    header by default (Mozilla can cope with that).

    z#( Netscape)? HTTP Cookie Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCsbt��}|��}|j�|�s(td|��z�|��}|dkr>�q|�d�rT|dd�}|���d�s*|��dkrpq*|�d�\}}	}
}}}
}|dk}|	dk}	|
dkr�|}
d}|�d�}d	}|dkr�d}d
}t	d|
|dd	||	||
d	|||ddi�}|s�|j
r�q*|�s|�|��rq*|�|�q*WnBt
k
�r2�Yn,tk
�r\t�td||f��YnXdS)
Nz4%r does not look like a Netscape format cookies filerWr�r�)�#r�	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %r)rMr�rtr@rr�r�rsr�rr�r�rhr�rdr)r�rrwryrzr�r�r�r�r�r�r�r�rxryr�r�rjrrrr~�sr��

��
�

�zMozillaCookieJar._really_loadNFc
Cs�|dkr"|jdk	r|j}ntt��t|d���}|�|j�t��}|D]�}|sV|jrVqF|sf|�|�rfqF|j	rrd}nd}|j
�d�r�d}nd}|jdk	r�t
|j�}	nd}	|jdkr�d}
|j}n|j}
|j}|�d�|j
||j||	|
|g�d�qFW5QRXdS)Nr�r�ZFALSEr�rWr�r�)rwrLr|r}r�r�rMr�r�r�r�rsr�r"ryrxr�r�)r�rwryrzrr�r�r�r�r�rxryrrrr{ sH



���zMozillaCookieJar.save)NFF)
r�r�r�r�rtrrrtr�r~r{rrrrr�s

A)N)N)Xr��__all__rur�r-rtrMZurllib.parser�Zurllib.requestZ	threadingr<Zhttp.clientZhttpZcalendarr
rrrr"ZclientZ	HTTP_PORTr�r|rr%r,r6r7rIr(rrrKr5r8r>rrrsr?rFrTrY�Ir]�Xr_rbrcrerkrmrnrprorzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr2r5r9rr�rrr�rrrrrr�<module>s��
�

8�
�
�8
�!



U
D'


#b!b7xPK|/�\2�uI2Y2Yserver.cpython-38.opt-2.pycnu�[���U

e5d��@sdZdddddgZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlmZdd	lmZd
ZdZGdd�dej�ZGd
d�deje�ZGdd�dej �Z!Gdd�de!�Z"dd�Z#da$dd�Z%dd�Z&Gdd�de"�Z'dd�Z(e!edddfdd�Z)e*dk�rddl+Z+e+�,�Z-e-j.ddd d!�e-j.d"d#d$d%d&�e-j.d'd(e�/�d)d*�e-j.d+d,de0d-d.d/�e-�1�Z2e2j3�r�e'Z4nee"e2j5d0�Z4Gd1d2�d2e�Z6e)e4e6e2j7e2j8d3�dS)4z0.6�
HTTPServer�ThreadingHTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�partial)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c@seZdZdZdd�ZdS)r�cCs4tj�|�|jdd�\}}t�|�|_||_dS)N�)�socketserver�	TCPServer�server_bindZserver_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�#/usr/lib64/python3.8/http/server.pyr
�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressr
rrrrr�sc@seZdZdZdS)rTN)rrrZdaemon_threadsrrrrr�sc
@sFeZdZdej��dZdeZe	Z
eZdZ
dd�Zdd�Zd	d
�Zdd�ZdEdd�ZdFdd�ZdGdd�Zdd�Zdd�Zdd�ZdHdd�Zdd�Ze�dd �e�ed!�ed"d#��D��Zd$ee d%�<d&d'�Z!d(d)�Z"dId*d+�Z#d,d-�Z$d.d/d0d1d2d3d4gZ%d
d5d6d7d8d9d:d;d<d=d>d?d@g
Z&dAdB�Z'dCZ(e)j*j+Z,dDd �e-j.�/�D�Z0d
S)JrzPython/rz	BaseHTTP/�HTTP/0.9c
Cs�d|_|j|_}d|_t|jd�}|�d�}||_|��}t	|�dkrLdSt	|�dk�r&|d}zT|�
d�srt�|�d	d
�d
}|�d�}t	|�dkr�t�t|d�t|d
�f}Wn,tt
fk
r�|�tjd
|�YdSX|dk�r|jdk�rd|_|dk�r |�tjd|�dS||_dt	|�k�rBdk�sZn|�tjd|�dS|dd�\}}t	|�dk�r�d|_|dk�r�|�tjd|�dS|||_|_|j�
d��r�d	|j�d	�|_ztjj|j|jd�|_Wn�tjjk
�r(}z|�tjdt|��WY�dSd}~XYnBtjjk
�rh}z|�tjdt|��WY�dSd}~XYnX|j�dd�}	|	��dk�r�d|_n |	��dk�r�|jdk�r�d|_|j�dd�}
|
��dk�r�|jdk�r�|jdk�r�|� ��s�dSdS)NTz
iso-8859-1z
rF����zHTTP/�/r	�.r
zBad request version (%r))r	r	zHTTP/1.1)r
rzInvalid HTTP version (%s)zBad request syntax (%r)ZGETzBad HTTP/0.9 request type (%r)z//)Z_classz
Line too longzToo many headers�
Connection��close�
keep-aliveZExpectz100-continue)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
startswith�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr)�wordsZbase_version_numberZversion_numberr"r2�errZconntypeZexpectrrr�
parse_requests�


�
��
�
������
z$BaseHTTPRequestHandler.parse_requestcCs|�tj�|��dS�NT)�send_response_onlyrZCONTINUE�end_headers�rrrrr;xsz(BaseHTTPRequestHandler.handle_expect_100c
Cs�z�|j�d�|_t|j�dkrBd|_d|_d|_|�tj	�WdS|jsTd|_
WdS|��sbWdSd|j}t||�s�|�tj
d|j�WdSt||�}|�|j��Wn<tjk
r�}z|�d|�d|_
WY�dSd}~XYnXdS)NiirTZdo_zUnsupported method (%r)zRequest timed out: %r)r6�readliner'r+r)r$r"r0rZREQUEST_URI_TOO_LONGr%r?�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushrZtimeout�	log_error)rZmname�method�errr�handle_one_request�s6

�
z)BaseHTTPRequestHandler.handle_one_requestcCs"d|_|��|js|��qdSr@)r%rMrCrrr�handle�szBaseHTTPRequestHandler.handleNcCsz|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|�d||�|�||�|�dd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d�}|�d	d
�}|�d|j
�|�dtt|���|��|jd
k�r|�r|j�|�dS)N)�???rOzcode %d, message %srr ��F��quote)�code�message�explainzUTF-8�replacezContent-Type�Content-LengthZHEAD)�	responses�KeyErrorrJ�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENT�NOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer&r+rBr"rH�write)rrSrTrUZshortmsgZlongmsgZbodyZcontentrrrr0�s:���z!BaseHTTPRequestHandler.send_errorcCs:|�|�|�||�|�d|���|�d|���dS)NZServerZDate)�log_requestrAr[�version_string�date_time_string�rrSrTrrrrZ�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|j�d|j||f�dd��dS)Nrrr�_headers_bufferz
%s %d %s
�latin-1�strict)r$rXrErg�appendr1r`rfrrrrA�s



��z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|j�d||f�dd��|��dkrh|��dkrVd|_n|��d	krhd
|_dS)Nrrgz%s: %s
rhriZ
connectionr Tr!F)r$rErgrjr`r:r%)r�keyword�valuerrrr[s

�z"BaseHTTPRequestHandler.send_headercCs"|jdkr|j�d�|��dS)Nrs
)r$rgrj�
flush_headersrCrrrrBs
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|j�d�|j��g|_dS)Nrg�)rErHrb�joinrgrCrrrrms
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|�d|jt|�t|��dS)Nz
"%s" %s %s)�
isinstancerrl�log_messager)r&)rrS�sizerrrrc s
�z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS�N)rr)r�format�argsrrrrJ+sz BaseHTTPRequestHandler.log_errorcCsi|]}|d|d���qS)z\xZ02xr)�.0�crrr�
<dictcomp>;sz!BaseHTTPRequestHandler.<dictcomp>� ��z\\�\cGs2||}tj�d|��|��|�|j�f�dS)Nz%s - - [%s] %s
)�sys�stderrrb�address_string�log_date_time_string�	translate�_control_char_table)rrurvrTrrrrr>s
��z"BaseHTTPRequestHandler.log_messagecCs|jd|jS)N� )�server_version�sys_versionrCrrrrdXsz%BaseHTTPRequestHandler.version_stringcCs |dkrt��}tjj|dd�S)NT)Zusegmt)�time�email�utilsZ
formatdate)rZ	timestamprrrre\sz'BaseHTTPRequestHandler.date_time_stringc	CsBt��}t�|�\	}}}}}}}}	}
d||j|||||f}|S)Nz%02d/%3s/%04d %02d:%02d:%02d)r��	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrr�bs�z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS�Nr)�client_addressrCrrrr�psz%BaseHTTPRequestHandler.address_string�HTTP/1.0cCsi|]}||j|jf�qSr)�phraseZdescription)rw�vrrrrys�)NN)N)N)rprp)N)1rrrr~r<r*r��__version__r��DEFAULT_ERROR_MESSAGEr]�DEFAULT_ERROR_CONTENT_TYPErar#r?r;rMrNr0rZrAr[rBrmrcrJr&�	maketrans�	itertools�chain�ranger��ordrrrdrer�Zweekdaynamer�r�r1r4r5ZHTTPMessager7r�__members__�valuesrXrrrrr�s\ij%
5


�
�	�cs�eZdZdeZdd��fdd�
Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Ze
jshe
��e
j��Ze�ddddd���ZS)rzSimpleHTTP/N��	directorycs(|dkrt��}||_t�j||�dSrt)�os�getcwdr��super�__init__)rr�rv�kwargs��	__class__rrr��sz!SimpleHTTPRequestHandler.__init__cCs.|��}|r*z|�||j�W5|��XdSrt)�	send_headr �copyfilerH�r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|��}|r|��dSrt)r�r r�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADcCs^|�|j�}d}tj�|�r�tj�|j�}|j�d�s�|�t	j
�|d|d|dd|d|df}tj�|�}|�d|�|�
�dSdD]&}tj�||�}tj�|�r�|}q�q�|�|�S|�|�}|�d�r�|�t	jd	�dSzt|d
�}Wn&tk
�r|�t	jd	�YdSX�z"t�|���}d|jk�r�d|jk�r�ztj�|jd�}	Wnttttfk
�r|YnzX|	j dk�r�|	j!t"j#j$d
�}	|	j t"j#j$k�r�t"j"�%|j&t"j#j$�}
|
j!dd�}
|
|	k�r�|�t	j'�|�
�|�(�WdS|�t	j)�|�d|�|�dt*|d��|�d|�+|j&��|�
�|WS|�(��YnXdS)Nrrr	r
r�ZLocation)z
index.htmlz	index.htmzFile not found�rbzIf-Modified-Sincez
If-None-Match)�tzinfo)Zmicrosecond�Content-typerW�z
Last-Modified),�translate_pathr2r��isdir�urllib�parseZurlsplit�endswithrZrZMOVED_PERMANENTLYZ
urlunsplitr[rBro�exists�list_directory�
guess_typer0�	NOT_FOUND�open�OSError�fstat�filenor8r�r�Zparsedate_to_datetime�	TypeErrorr/�
OverflowErrorr-r�rV�datetime�timezoneZutcZ
fromtimestamp�st_mtimer\r �OKr&re)rr2r��partsZ	new_partsZnew_url�indexZctypeZfsZimsZ
last_modifrrrr��s��


���

�z"SimpleHTTPRequestHandler.send_headc
	Cs�zt�|�}Wn$tk
r2|�tjd�YdSX|jdd�d�g}ztjj	|j
dd�}Wn"tk
r�tj�	|j
�}YnXtj
|dd�}t��}d	|}|�d
�|�d�|�d|�|�d
|�|�d|�|�d�|D]v}tj
�||�}|}	}
tj
�|��r$|d}	|d}
tj
�|��r:|d}	|�dtjj|
dd�tj
|	dd�f�q�|�d�d�|��|d�}t��}|�|�|�d�|�tj�|�dd|�|�dtt|���|��|S)NzNo permission to list directorycSs|��Srt)r:)�arrr�<lambda>rnz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass��errorsFrQzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperr�ztext/html; charset=%srW) r��listdirr�r0rr��sortr�r��unquoter2�UnicodeDecodeErrorr^r_r~�getfilesystemencodingrjror��islinkrRr`�io�BytesIOrb�seekrZr�r[r&r+rB)
rr2�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr�sh�
�


�
���


z'SimpleHTTPRequestHandler.list_directorycCs�|�dd�d}|�dd�d}|���d�}ztjj|dd�}Wn tk
rbtj�|�}YnXt�|�}|�d�}t	d|�}|j
}|D]0}tj�
|�s�|tjtjfkr�q�tj�||�}q�|r�|d7}|S)N�?r	r�#rr�r�)r*r(r�r�r�r�r��	posixpath�normpath�filterr�r�r2�dirname�curdir�pardirro)rr2Ztrailing_slashr=Zwordrrrr�:s$	


z'SimpleHTTPRequestHandler.translate_pathcCst�||�dSrt)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�Xsz!SimpleHTTPRequestHandler.copyfilecCsLt�|�\}}||jkr"|j|S|��}||jkr>|j|S|jdSdS)Nr)r��splitext�extensions_mapr:)rr2�baseZextrrrr�hs



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)r�.pyz.cz.h)rrrr�r�r�r�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��update�
__classcell__rrr�rr�s$
	W:
�c	Cs�|�d�\}}}tj�|�}|�d�}g}|dd�D],}|dkrL|��q6|r6|dkr6|�|�q6|r�|��}|r�|dkr�|��d}q�|dkr�d}nd}|r�d�||f�}dd�|�|f}d�|�}|S)Nr�rrz..rr)�	partitionr�r�r�r*�poprjro)	r2�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_path�s.


r�cCsrtrtSzddl}Wntk
r*YdSXz|�d�daWn.tk
rldtdd�|��D��aYnXtS)Nrr�nobodyr
r	css|]}|dVqdS)r
Nr)rwr�rrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>)r��pwd�ImportError�getpwnamrY�maxZgetpwall)r�rrr�
nobody_uid�s rcCst�|tj�Srt)r��access�X_OK)r2rrr�
executable�src@sReZdZeed�ZdZdd�Zdd�Zdd�Z	d	d
gZ
dd�Zd
d�Zdd�Z
dS)r�forkrcCs$|��r|��n|�tjd�dS)NzCan only POST to CGI scripts)�is_cgi�run_cgir0rrFrCrrr�do_POST�s
�zCGIHTTPRequestHandler.do_POSTcCs|��r|��St�|�SdSrt)rrrr�rCrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|�dd�}|d|�||dd�}}||jkrL||f|_dSdS)Nrr	TF)r�r2�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr�s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�Srt)r)rr2rrr�
is_executablesz#CGIHTTPRequestHandler.is_executablecCstj�|�\}}|��dkS)N)r�z.pyw)r�r2r�r:)rr2rrrrr�	is_pythonszCGIHTTPRequestHandler.is_pythonc)	Cs�|j\}}|d|}|�dt|�d�}|dkr�|d|�}||dd�}|�|�}tj�|�r�||}}|�dt|�d�}q*q�q*|�d�\}}}	|�d�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|�|�}tj�|��s
|�	t
jd|�dStj�|��s.|�	t
j
d|�dS|�|�}
|j�sF|
�sh|�|��sh|�	t
j
d|�dSt�tj�}|��|d	<|jj|d
<d|d<|j|d
<t|jj�|d<|j|d<tj�|�}||d<|�|�|d<||d<|	�r�|	|d<|jd|d<|j� d�}|�r�|�!�}t|�dk�r�ddl"}ddl#}|d|d<|d�$�dk�r�z"|d�%d�}|�&|��'d�}Wn|j(t)fk
�r�Yn&X|�!d�}t|�dk�r�|d|d<|j� d�dk�r�|j�*�|d<n|jd|d<|j� d�}|�r||d<|j� d �}|�r||d!<g}|j�+d"�D]>}|dd�d#k�rR|�,|�-��n||d$d��!d%�}�q,d%�.|�|d&<|j� d'�}|�r�||d(<t/d|j�0d)g��}d*�.|�}|�r�||d+<d,D]}|�1|d��q�|�2t
j3d-�|�4�|	�5d.d/�}|j�r|
g}d0|k�r|�,|�t6�}|j7�8�t�9�}|dk�r�t�:|d�\}}t;�;|j<gggd�d�r~|j<�=d��sN�q~�qN|�r�|�>d1|�dSz\zt�?|�Wnt@k
�r�YnXt�A|j<�B�d�t�A|j7�B�d�t�C|||�Wn(|j�D|jE|j�t�Fd2�YnX�n�ddlG} |g}!|�|��rrtHjI}"|"�$��Jd3��rf|"dd4�|"d5d�}"|"d6g|!}!d0|	k�r�|!�,|	�|�Kd7| �L|!��ztM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d8�}$|j�$�d9k�r|#dk�r|j<�=|#�}%nd}%t;�;|j<jRgggd�d�r>|j<jR�Sd��s
�q>�q
|$�T|%�\}&}'|j7�U|&�|'�rj|�>d:|'�|$jV�W�|$jX�W�|$jY}(|(�r�|�>d1|(�n
|�Kd;�dS)<Nrr	rr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationr
Z	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE)rZREMOTE_HOSTrrrrzScript output follows�+r��=zCGI script exit status %#xr{zw.exe������z-uzcommand: %s)�stdin�stdoutr�envZpostz%szCGI script exited OK)Zr
rr+r�r�r2r�r�r�r0rr��isfileZ	FORBIDDENr�	have_forkr
r�Zdeepcopy�environrdZserverrr1r&rr"r�r�r�r�r8r9r*�base64�binasciir:r`Zdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersrj�stripror�Zget_all�
setdefaultrZr�rmrVrrHrIr�waitpid�selectr6�readrJ�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessr~rr�rrZlist2cmdliner.r�r-�Popen�PIPEZ_sockZrecvZcommunicaterbrr r �
returncode))r�dir�restr2�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyr!Zuqrestrr%r&Zlengthrr�lineZua�coZ
cookie_str�kZ
decoded_queryrvr��pid�stsr3ZcmdlineZinterp�nbytes�p�datar rZstatusrrrrs<





��
�


�








�

zCGIHTTPRequestHandler.run_cgiN)rrrrEr�r#Zrbufsizerr�rr	r
rrrrrrr�s
cGs4tj|tjtjd��}tt|��\}}}}}||fS)N)�type�flags)rZgetaddrinfoZSOCK_STREAMZ
AI_PASSIVE�next�iter)ZaddressZinfosZfamilyrB�protoZ	canonnameZsockaddrrrr�_get_best_family�s�rGr�i@c	Cs�t||�\|_}||_|||���}|j��dd�\}}d|krLd|�d�n|}td|�d|�d|�d|�d�	�z|��Wn&tk
r�td	�t�	d
�YnXW5QRXdS)Nr
r�[�]zServing HTTP on z port z	 (http://z/) ...z&
Keyboard interrupt received, exiting.r)
rGZaddress_familyr1rZgetsockname�printZ
serve_forever�KeyboardInterruptr~�exit)	�HandlerClass�ServerClassZprotocolr�bindZaddrZhttpdrZurl_hostrrr�test�s�rP�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�metavarrTz--directoryz-dz9Specify alternative directory [default:current directory])�defaultrTrZstorer�z&Specify alternate port [default: 8000])rSrVrB�nargsrTr�cseZdZ�fdd�Z�ZS)�DualStackServerc	s4t�t��|j�tjtjd�W5QRXt���Sr�)	�
contextlib�suppress�	ExceptionrZ
setsockoptZIPPROTO_IPV6ZIPV6_V6ONLYr�r
rCr�rrr
s�zDualStackServer.server_bind)rrrr
r�rrr�rrXsrX)rMrNrrO)9r��__all__r�r�Zemail.utilsr�r^Zhttp.clientr4r�r�r�r�r�r-r�rrr~r�Zurllib.parser�rY�	functoolsrrr�r�rrZThreadingMixInrZStreamRequestHandlerrrr�r�rrrrGrPr�argparse�ArgumentParser�parser�add_argumentr�r.�
parse_argsrvZcgiZ
handler_classr�rXrrOrrrr�<module>Ss��s
0
�

�
�����PK|/�\b��:����client.cpython-38.opt-1.pycnu�[���U

e5d���@sfdZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZdddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZe��ejj�dd�ejj��D�ZdZdZe�d �jZe�d!�jZe�d"�Z e�d#�Z!d$d%d&hZ"dBd(d)�Z#Gd*d+�d+ej$j%�Z&d,d-�Z'e&fd.d/�Z(Gd0d�dej)�Z*Gd1d�d�Z+zddl,Z,Wne-k
�r`YnXGd2d3�d3e+�Z.e�/d3�Gd4d�de0�Z1Gd5d�de1�Z2Gd6d�de1�Z3Gd7d�de1�Z4Gd8d	�d	e1�Z5Gd9d
�d
e1�Z6Gd:d�de1�Z7Gd;d
�d
e1�Z8Gd<d�de8�Z9Gd=d�de8�Z:Gd>d�de8�Z;Gd?d�de1�Z<Gd@d�de1�Z=GdAd�de>e<�Z?e1Z@dS)Ca�
HTTP/1.1 client library

<intro stuff goes here>
<other stuff, too>

HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:

    (null)
      |
      | HTTPConnection()
      v
    Idle
      |
      | putrequest()
      v
    Request-started
      |
      | ( putheader() )*  endheaders()
      v
    Request-sent
      |\_____________________________
      |                              | getresponse() raises
      | response = getresponse()     | ConnectionError
      v                              v
    Unread-response                Idle
    [Response-headers-read]
      |\____________________
      |                     |
      | response.read()     | putrequest()
      v                     v
    Idle                  Req-started-unread-response
                     ______/|
                   /        |
   response.read() |        | ( putheader() )*  endheaders()
                   v        v
       Request-started    Req-sent-unread-response
                            |
                            | response.read()
                            v
                          Request-sent

This diagram presents the following rules:
  -- a second request may not be started until {response-headers-read}
  -- a response [object] cannot be retrieved until {request-sent}
  -- there is no differentiation between an unread response body and a
     partially read response body

Note: this enforcement is applied by the HTTPConnection class. The
      HTTPResponse class does not enforce this state machine, which
      implies sophisticated clients may accelerate the request/response
      pipeline. Caution should be taken, though: accelerating the states
      beyond the above pattern may imply knowledge of the server's
      connection-close behavior for certain requests. For example, it
      is impossible to tell whether the server will close the connection
      UNTIL the response headers have been read; this means that further
      requests cannot be placed into the pipeline until it is known that
      the server will NOT be closing the connection.

Logical State                  __state            __response
-------------                  -------            ----------
Idle                           _CS_IDLE           None
Request-started                _CS_REQ_STARTED    None
Request-sent                   _CS_REQ_SENT       None
Unread-response                _CS_IDLE           <response_class>
Req-started-unread-response    _CS_REQ_STARTED    <response_class>
Req-sent-unread-response       _CS_REQ_SENT       <response_class>
�N)�urlsplit�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}||j�qS�)�phrase)�.0�vrr�#/usr/lib64/python3.8/http/client.py�
<dictcomp>jsri�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUT�datac
Cshz|�d�WStk
rb}z8t|j|j|j|jd|��||j|j�|f�d�W5d}~XYnXdS)z<Call data.encode("latin-1") but show a better error message.�latin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.N)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s���r(c@seZdZdd�ZdS)�HTTPMessagecCsj|��d}t|�}g}d}|��D]@}|d|���|krBd}n|dd���sVd}|r$|�|�q$|S)a�Find all header lines matching a given header name.

        Look through the list of headers and find all lines matching a given
        header name (and their continuation lines).  A list of the lines is
        returned, without interpretation.  If the header does not occur, an
        empty list is returned.  If the header occurs multiple times, all
        occurrences are returned.  Case is not important in the header name.

        �:rN�)�lower�len�keys�isspace�append)�selfr&�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r4rrrrr)�sr)cCsXg}|�td�}t|�tkr&td��|�|�t|�tkrHtdt��|dkrqTq|S)z�Reads potential header lines into a list from a file pointer.

    Length of line is limited by _MAXLINE, and number of
    headers is limited by _MAXHEADERS.
    r+�header linezgot more than %d headers��
�
�)�readline�_MAXLINEr-rr0�_MAXHEADERSr)�fp�headersr3rrr�
_read_headers�s
rBcCs,t|�}d�|��d�}tjj|d��|�S)aGParses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.

    r<�
iso-8859-1)�_class)rB�join�decode�email�parserZParserZparsestr)r@rDrAZhstringrrr�
parse_headers�s
rIcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdBd(d)�ZdCd*d+�ZdD�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdEd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)FrrNcCsR|�d�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)Zmakefiler@�
debuglevel�_methodrA�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r1�sockrK�method�urlrrr�__init__�szHTTPResponse.__init__cCst|j�td�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��z|�
dd�\}}}WnFtk
r�z|�
dd�\}}d}Wntk
r�d}YnXYnX|�d	�s�|�
�t|��z$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr+rCzstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr@r=r>r-rrK�print�reprr�split�
ValueError�
startswith�_close_connr�int)r1r3rOrPrQrrr�_read_statuss2

zHTTPResponse._read_statusc	Cs�|jdk	rdS|��\}}}|tkr&qHt|j�}|jdkrDtd|�~q||_|_|�	�|_
|dkrnd|_n|�d�r�d|_nt
|��t|j�|_|_|jdkr�|j��D]\}}td|d|�q�|j�d	�}|r�|��d
kr�d|_d|_nd|_|��|_d|_|j�d
�}|�rb|j�sbzt|�|_Wntk
�rLd|_YnX|jdk�rhd|_nd|_|tk�s�|tk�s�d|k�r�dk�s�n|jdk�r�d|_|j�s�|j�s�|jdk�r�d|_dS)Nrzheaders:)zHTTP/1.0zHTTP/0.9�
zHTTP/1.��header:r*�transfer-encodingrRTF�content-lengthr���HEAD)rArdZCONTINUErBr@rKr]�coderP�striprQrOrarrIrM�items�getr,rRrS�_check_closerUrTrcr`Z
NO_CONTENTZNOT_MODIFIEDrL)	r1rOrPrQZskipped_headers�hdr�valZtr_encrTrrr�begin5sf







�
�
���zHTTPResponse.begincCsv|j�d�}|jdkr.|r*d|��kr*dSdS|j�d�r>dS|rRd|��krRdS|j�d�}|rrd|��krrdSdS)NZ
connectionrf�closeTFz
keep-alivezproxy-connection)rArorOr,)r1ZconnZpconnrrrrp}s
zHTTPResponse._check_closecCs|j}d|_|��dS�N)r@rt)r1r@rrrrb�szHTTPResponse._close_conncs$zt���W5|jr|��XdSru)r@rb�superrt�r1��	__class__rrrt�szHTTPResponse.closecst���|jr|j��dSru)rv�flushr@rwrxrrrz�s
zHTTPResponse.flushcCsdS)zAlways returns TrueTrrwrrr�readable�szHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)r@rwrrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|��dS|dk	rRt|�}|�|�}t|�d|���S|jr`|��S|j	dkrv|j�
�}n6z|�|j	�}Wntk
r�|���YnXd|_	|��|SdS)Nr<rkr)
r@rLrb�	bytearray�readinto�
memoryview�tobytesrR�_readall_chunkedrT�read�
_safe_readr
)r1�amt�br2�srrrr��s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|��dS|jr4|�|�S|jdk	r^t|�|jkr^t|�d|j�}|j�|�}|s||r||��n&|jdk	r�|j|8_|js�|��|S)z^Read up to len(b) bytes into bytearray b and return the number
        of bytes read.
        Nrrk)	r@rLrbrR�_readinto_chunkedrTr-rr~)r1r�r2rrrr~�s$





zHTTPResponse.readintocCsr|j�td�}t|�tkr$td��|�d�}|dkrB|d|�}zt|d�WStk
rl|���YnXdS)Nr+z
chunk size�;r�)	r@r=r>r-r�findrcr`rb)r1r3�irrr�_read_next_chunk_sizes
z"HTTPResponse._read_next_chunk_sizecCs:|j�td�}t|�tkr$td��|s*q6|dkrq6qdS)Nr+ztrailer liner9)r@r=r>r-r�r1r3rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|�d�z|��}Wntk
rDtd��YnX|dkrb|��|��d}||_|S)NrZr<r)rSr�r�r`r
r�rb)r1rSrrr�_get_chunk_left s
zHTTPResponse._get_chunk_leftcCsbg}z6|��}|dkrq0|�|�|��d|_qd�|�WStk
r\td�|���YnXdS�Nrr<)r�r0r�rSrEr
)r1�valuerSrrrr�8szHTTPResponse._readall_chunkedcCs�d}t|�}zv|��}|dkr$|WSt|�|krN|�|�}|||_||WS|d|�}|�|�}||d�}||7}d|_qWn(tk
r�tt|d|����YnXdS)Nr)rr�r-�_safe_readintorSr
�bytes)r1r�Ztotal_bytesZmvbrSr2Ztemp_mvbrrrr�Fs"



zHTTPResponse._readinto_chunkedcCs.|j�|�}t|�|kr*t||t|���|S)aRead the number of bytes requested.

        This function should be used when <amt> bytes "should" be present for
        reading. If the bytes are truly not available (due to EOF), then the
        IncompleteRead exception can be used to detect the problem.
        )r@r�r-r
)r1r�rrrrr�^szHTTPResponse._safe_readcCs:t|�}|j�|�}||kr6tt|d|��||��|S)z2Same as _safe_read, but for reading into a buffer.N)r-r@r~r
r�)r1r�r�r2rrrr�js
zHTTPResponse._safe_readinto���cCs�|jdks|jdkrdS|jr(|�|�S|jdk	rJ|dksD||jkrJ|j}|j�|�}|sh|rh|��n|jdk	r�|jt|�8_|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        Nrkr<r)r@rLrR�_read1_chunkedrT�read1rbr-)r1r2�resultrrrr�rs


zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|�|�S|j�|�S)Nrkr<)r@rLrR�
_peek_chunked�peek)r1r2rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t��|�S|jdk	rL|dksF||jkrL|j}|j�|�}|sj|rj|��n|jdk	r�|jt|�8_|S)Nrkr<r)r@rLrRrvr=rTrbr-)r1�limitr�rxrrr=�s

zHTTPResponse.readlinecCsd|��}|dks|dkrdSd|kr0|ks6n|}|j�|�}|jt|�8_|s`td��|Sr�)r�r@r�rSr-r
)r1r2rSr�rrrr��szHTTPResponse._read1_chunkedcCsDz|��}Wntk
r"YdSX|dkr0dS|j�|�d|�S)Nr<)r�r
r@r�)r1r2rSrrrr��szHTTPResponse._peek_chunkedcCs
|j��Sru)r@�filenorwrrrr��szHTTPResponse.filenocCsF|jdkrt��|j�|�p|}t|t�s4t|d�s8|Sd�|�SdS)axReturns the value of the header matching *name*.

        If there are multiple matching headers, the values are
        combined into a single string separated by commas and spaces.

        If no matching header is found, returns *default* or None if
        the *default* is not specified.

        If the headers are unknown, raises http.client.ResponseNotReady.

        N�__iter__z, )rArZget_all�
isinstancer\�hasattrrE)r1r&�defaultrArrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|j���S)z&Return list of (header, value) tuples.N)rAr�listrnrwrrr�
getheaders�s
zHTTPResponse.getheaderscCs|Srurrwrrrr��szHTTPResponse.__iter__cCs|jS)ajReturns an instance of the class mimetools.Message containing
        meta-information associated with the URL.

        When the method is HTTP, these headers are those returned by
        the server at the head of the retrieved HTML page (including
        Content-Length and Content-Type).

        When the method is FTP, a Content-Length header will be
        present if (as is now usual) the server passed back a file
        length in response to the FTP retrieval request. A
        Content-Type header will be present if the MIME type can be
        guessed.

        When the method is local-file, returned headers will include
        a Date representing the file's last-modified time, a
        Content-Length giving file size, and a Content-Type
        containing a guess at the file's type. See also the
        description of the mimetools module.

        )rArwrrr�info�szHTTPResponse.infocCs|jS)aZReturn the real URL of the page.

        In some cases, the HTTP server redirects a client to another
        URL. The urlopen() function handles this transparently, but in
        some cases the caller needs to know which URL the client was
        redirected to. The geturl() method can be used to get at this
        redirected URL.

        )rXrwrrr�geturl�s
zHTTPResponse.geturlcCs|jS)zuReturn the HTTP status code that was sent with the response,
        or None if the URL is not an HTTP URL.

        )rPrwrrr�getcode�szHTTPResponse.getcode)rNN)N)r�)r�)r�)N)"r5r6r7rYrdrsrprbrtrzr{r|r�r~r�r�r�r�r�r�r�r�r�r=r�r�r�r�r�r�r�r�r��
__classcell__rrrxrr�s<	
!H

 "

	

c@s
eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	d
fdd�Zd7d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd8d d!�Zd9d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d:dd.�d/d0�Z!d	ifdd.�d1d2�Z"d3d4�Z#d5d6�Z$d	S);rrfzHTTP/1.1r+rcCst|tj�S)zFTest whether a file-like object is a text or a binary stream.
        )r��io�
TextIOBase)�streamrrr�
_is_textIOszHTTPConnection._is_textIOcCsf|dkr|��tkrdSdSt|d�r*dSzt|�}|jWStk
rNYnXt|t�rbt|�SdS)aGet the content-length based on the body.

        If the body is None, we set Content-Length: 0 for methods that expect
        a body (RFC 7230, Section 3.3.2). We also set the Content-Length for
        any method if the body is a str or bytes-like object and not a file.
        Nrr�)	�upper�_METHODS_EXPECTING_BODYr�r�nbytes�	TypeErrorr�r\r-)�bodyrWZmvrrr�_get_content_lengths

z"HTTPConnection._get_content_lengthN� cCsn||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|�||�\|_
|_|�|j
�tj|_dSru)�timeout�source_address�	blocksizerV�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterL�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�_validate_host�socketZcreate_connection�_create_connection)r1r�r�r�r�r�rrrrY4szHTTPConnection.__init__cCs<|jrtd��|�||�\|_|_|r.||_n
|j��dS)aDSet up host and port for HTTP CONNECT tunnelling.

        In a connection that uses HTTP CONNECT tunneling, the host passed to the
        constructor is used as a proxy server that relays all communication to
        the endpoint passed to `set_tunnel`. This done by sending an HTTP
        CONNECT request to the proxy server when the connection is established.

        This method must be called before the HTTP connection has been
        established.

        The headers argument should be a mapping of extra HTTP headers to send
        with the CONNECT request.
        z.Can't set up tunnel for established connectionN)rV�RuntimeErrorr�r�r�r��clear)r1r�r�rArrr�
set_tunnelJszHTTPConnection.set_tunnelcCs�|dkr�|�d�}|�d�}||kr�zt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd�}||fS)	Nr*�]r+r[znonnumeric port: '%s'r�[r�)�rfindrcr`�default_portr)r1r�r�r��jrrrr�bs

zHTTPConnection._get_hostportcCs
||_dSru)rK)r1�levelrrr�set_debuglevelvszHTTPConnection.set_debuglevelcCs�d|j|jf}|�d�}|�|�|j��D](\}}d||f}|�d�}|�|�q.|�d�|j|j|jd�}|�	�\}}	}
|	t
jjkr�|�
�td|	|
��f��|j�td�}t|�tkr�td	��|s�q�|d
kr�q�|jdkr�td|���q�dS)
NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
rr:�rWzTunnel connection failed: %d %sr+r8r9rrg)r�r�r�sendr�rn�response_classrVrLrd�http�
HTTPStatusZOKrt�OSErrorrmr@r=r>r-rrKr]rF)r1Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserOrl�messager3rrr�_tunnelys4�



�
zHTTPConnection._tunnelcCsB|�|j|jf|j|j�|_|j�tjtj	d�|j
r>|��dS)z3Connect to the host and port specified in __init__.r+N)r�r�r�r�r�rVZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�rwrrr�connect�s
�zHTTPConnection.connectcCsBt|_z|j}|r d|_|��W5|j}|r<d|_|��XdS)z(Close the connection to the HTTP server.N)r�r�r�rtrV)r1r�rVrrrrt�szHTTPConnection.closecCs|jdkr |jr|��nt��|jdkr8tdt|��t|d�r�|jdkrTtd�|�|�}|rt|jdkrttd�|�	|j
�}|s�q�|r�|�d�}|j�|�qtdSz|j�|�WnLt
k
�rt|tjj�r�|D]}|j�|�q�nt
dt|���YnXdS)	z�Send `data' to the server.
        ``data`` can be a string object, a bytes object, an array object, a
        file-like object that supports a .read() method, or an iterable object.
        Nrzsend:r��sendIng a read()able�encoding file using iso-8859-1rCz9data should be a bytes-like object or an iterable, got %r)rV�	auto_openr�rrKr]r^r�r�r�r�rZsendallr�r��collections�abc�Iterable�type)r1rr�	datablock�drrrr��s8






�zHTTPConnection.sendcCs|j�|�dS)zuAdd a line of output to the current request buffer.

        Assumes that the line does *not* end with \r\n.
        N)r�r0)r1r�rrr�_output�szHTTPConnection._outputccs^|jdkrtd�|�|�}|r2|jdkr2td�|�|j�}|sDqZ|rR|�d�}|Vq2dS)Nrr�r�rC)rKr]r�r�r�r)r1r{rr�rrr�_read_readable�s


zHTTPConnection._read_readableFcCs |j�d�d�|j�}|jdd�=|�|�|dk	�rt|d�rN|�|�}nZzt|�WnFtk
r�zt|�}Wn$tk
r�tdt	|���YnXYnX|f}|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d	�d
��d�|d}|�|�q�|�r|jdk�r|�d�dS)
z�Send the currently buffered request and clear the buffer.

        Appends an extra \r\n to the buffer.
        A message_body may be specified, to be appended to the request.
        )r<r<r:Nr�zAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrf�Xz
r�s0

)r��extendrEr�r�r�rr��iterr�rKr]�	_http_vsnr-r)r1�message_body�encode_chunkedrMZchunks�chunkrrr�_send_output�s:


�
�zHTTPConnection._send_outputcCs�|jr|j��rd|_|jtkr(t|_n
t|j��|�|�||_|pHd}|�|�d|||j	f}|�
|�|��|jdk�r�|�s�d}|�
d�r�t|�\}}}}}|r�z|�d�}Wntk
r�|�d�}YnX|�d	|�n�|jr�|j}	|j}
n|j}	|j}
z|	�d�}Wn tk
�r4|	�d�}YnX|	�d
�dk�rRd|d
}|
|jk�rl|�d	|�n|�d�}|�d	d||
f�|�s�|�dd�ndS)a`Send a request to the server.

        `method' specifies an HTTP request method, e.g. 'GET'.
        `url' specifies the object being requested, e.g. '/index.html'.
        `skip_host' if True does not add automatically a 'Host:' header
        `skip_accept_encoding' if True does not add automatically an
           'Accept-Encoding:' header
        N�/z%s %s %srfr[r�r�ZidnaZHostr*r�[�]z%s:%szAccept-EncodingZidentity)r�r|r�r��_CS_REQ_STARTEDr
�_validate_methodrL�_validate_path�
_http_vsn_strr��_encode_requestr�rarrr �	putheaderr�r�r�r�r�r�rF)r1rWrX�	skip_host�skip_accept_encoding�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequest sP






zHTTPConnection.putrequestcCs
|�d�S)Nr�)r)r1r�rrrr��szHTTPConnection._encode_requestcCs,t�|�}|r(td|�d|���d���dS)z&Validate a method name for putrequest.z)method can't contain control characters. � (found at least �)N)�$_contains_disallowed_method_pchar_re�searchr`�group)r1rW�matchrrrr��s

�zHTTPConnection._validate_methodcCs,t�|�}|r(td|�d|���d���dS)zValidate a url for putrequest.�&URL can't contain control characters. r�r�N��!_contains_disallowed_url_pchar_rer�rr�)r1rXr�rrrr��s
zHTTPConnection._validate_pathcCs,t�|�}|r(td|�d|���d���dS)z9Validate a host so it doesn't contain control characters.r�r�r�Nr�)r1r�r�rrrr��s
zHTTPConnection._validate_hostcGs�|jtkrt��t|d�r$|�d�}t|�s:td|f��t|�}t|�D]\\}}t|d�rl|�d�||<nt	|t
�r�t|��d�||<t||�rJtd||f��qJd�
|�}|d|}|�|�dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        rr�zInvalid header name %rrzInvalid header value %rs
	s: N)r�r�rr�r�_is_legal_header_namer`r��	enumerater�rcr\�_is_illegal_header_valuerEr�)r1r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader�r�cCs*|jtkrt|_nt��|j||d�dS)z�Indicate that the last header line has been sent to the server.

        This method sends the request to the server.  The optional message_body
        argument can be used to pass a message body associated with the
        request.
        rN)r�r��_CS_REQ_SENTrr�)r1r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|�|||||�dS)z&Send a complete request to the server.N)�
_send_request)r1rWrXr�rAr�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|�||�}|dkr�|dk	r�|jdkr�td|�d
}|�dd�q�|�dt|��nd
}|��D]\}	}
|�|	|
�q�t|t�r�t	|d�}|j
||d�dS)Ncss|]}|��VqdSru)r,)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r+r�zaccept-encodingr�rirhFrzUnable to determine size of %rTzTransfer-EncodingrRzContent-Lengthr�r)�	frozensetr�r�rKr]r�r\rnr�r(r)r1rWrXr�rAr�Zheader_namesZskipsZcontent_lengthrqr�rrrr�s0	


zHTTPConnection._send_requestcCs�|jr|j��rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}zNz|�	�Wnt
k
r�|���YnXt|_|j
r�|��n||_|WS|���YnXdS)a)Get the response from the server.

        If the HTTPConnection is in the correct state, returns an
        instance of HTTPResponse or of whatever object is returned by
        the response_class variable.

        If a request has not been sent or if a previous response has
        not be handled, ResponseNotReady is raised.  If the HTTP
        response indicates that the connection should be closed, then
        it will be closed before the response is returned.  When the
        connection is closed, the underlying socket is closed.
        Nrr�)r�r|r�rrrKr�rVrLrs�ConnectionErrorrtr�rU)r1r�rrr�getresponses.

�
zHTTPConnection.getresponse)NN)NF)FF)N)%r5r6r7r�r�rr��	HTTP_PORTr�r�rK�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrYr�r�r�r�r�rtr�r�r�r�r�r�r�r�r�r�rr�rr
rrrrrsL

�

	&
6�
	
�.csHeZdZdZeZdddejdfdddd��fdd�Z�fdd�Z	�Z
S)	�HTTPSConnectionz(This class allows communication via SSL.Nr�)�context�check_hostnamer�cs�tt|�j|||||	d�|dk	s2|dk	s2|dk	rHddl}
|
�dtd�||_||_|dkrtt�	�}|j
dk	rtd|_
|jtjk}|dkr�|j
}|r�|s�td��|s�|r�|�||�|j
dk	r�d|_
||_|dk	r�||j_
dS)N)r�rzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rZTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rvrrY�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr`Zload_cert_chain�_context)r1r�r�rrr�r�rrr�rZwill_verifyrxrrrYcs<���

zHTTPSConnection.__init__cs6t���|jr|j}n|j}|jj|j|d�|_dS)z(Connect to a host on a given (SSL) port.)�server_hostnameN)rvr�r�r�rZwrap_socketrV)r1rrxrrr��s

�zHTTPSConnection.connect)r5r6r7�__doc__�
HTTPS_PORTr�r�rrYr�r�rrrxrr\s��$rc@seZdZdS)rN�r5r6r7rrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dSru)�argsrO)r1rOrrrrY�szUnknownProtocol.__init__N�r5r6r7rYrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)r	Nrrrrrr	�sc@s$eZdZddd�Zdd�ZejZdS)r
NcCs|f|_||_||_dSru)r�partial�expected)r1r!r"rrrrY�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedr[z%s(%i bytes read%s))r"ryr5r-r!)r1�errr�__repr__�s
�zIncompleteRead.__repr__)N)r5r6r7rYr$r"�__str__rrrrr
�s
c@seZdZdS)rNrrrrrr�sc@seZdZdS)r
Nrrrrrr
�sc@seZdZdS)rNrrrrrr�sc@seZdZdS)rNrrrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dSru)r^rr3r�rrrrY�szBadStatusLine.__init__Nr rrrrr�sc@seZdZdd�ZdS)rcCst�|dt|f�dS)Nz&got more than %d bytes when reading %s)rrYr>)r1Z	line_typerrrrY�s�zLineTooLong.__init__Nr rrrrr�sc@seZdZdd�ZdS)rcOs"t�|d�tj|f|�|�dS)Nr[)rrY�ConnectionResetError)r1�pos�kwrrrrY�szRemoteDisconnected.__init__Nr rrrrr�s)r)ArZemail.parserrGZ
email.messager�r��rer�Zcollections.abcr�Zurllib.parser�__all__rrrNr�r�r�globals�updater��__members__rrr>r?�compile�	fullmatchrr�rrr�r�r(r�ZMessager)rBrI�BufferedIOBaserrr�ImportErrorrr0�	Exceptionrrrrrr	r
rr
rrrrr&rrrrrr�<module>s�F�



W8
PK|/�\ߺ��v;v;cookies.cpython-38.opt-1.pycnu�[���U

e5d�O�
@stdZddlZddlZdddgZdjZdjZdjZGd	d�de�Z	ej
ejd
ZedZ
dd
�eed��eeee
��D�Ze�ed�ded�di�e�de�e��jZdd�Ze�d�Ze�d�Zdd�Zddddddd gZdd!d"d#d$d%d&d'd(d)d*d+d,g
Zdeefd-d.�ZGd/d0�d0e�Z d1Z!e!d2Z"e�d3e!d4e"d5ej#ej$B�Z%Gd6d�de�Z&Gd7d�de&�Z'dS)8a.

Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

The Basics
----------

Importing is easy...

   >>> from http import cookies

Most of the time you start by creating a cookie.

   >>> C = cookies.SimpleCookie()

Once you've created your Cookie, you can add values just as if it were
a dictionary.

   >>> C = cookies.SimpleCookie()
   >>> C["fig"] = "newton"
   >>> C["sugar"] = "wafer"
   >>> C.output()
   'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'

Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header.  This is the
default behavior.  You can change the header and printed
attributes by using the .output() function

   >>> C = cookies.SimpleCookie()
   >>> C["rocky"] = "road"
   >>> C["rocky"]["path"] = "/cookie"
   >>> print(C.output(header="Cookie:"))
   Cookie: rocky=road; Path=/cookie
   >>> print(C.output(attrs=[], header="Cookie:"))
   Cookie: rocky=road

The load() method of a Cookie extracts cookies from a string.  In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.

   >>> C = cookies.SimpleCookie()
   >>> C.load("chips=ahoy; vienna=finger")
   >>> C.output()
   'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'

The load() method is darn-tootin smart about identifying cookies
within a string.  Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.

   >>> C = cookies.SimpleCookie()
   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C = cookies.SimpleCookie()
   >>> C["oreo"] = "doublestuff"
   >>> C["oreo"]["path"] = "/"
   >>> print(C)
   Set-Cookie: oreo=doublestuff; Path=/

Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C = cookies.SimpleCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'

The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.

   >>> C = cookies.SimpleCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   '7'
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number=7\r\nSet-Cookie: string=seven'

Finis.
�N�CookieError�
BaseCookie�SimpleCookie�z; � c@seZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�$/usr/lib64/python3.8/http/cookies.pyr�sz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}|d|�qS)z\%03or
)�.0�nr
r
r�
<dictcomp>�s�r��"�\"�\z\\z[%s]+cCs*|dkst|�r|Sd|�t�dSdS)z�Quote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    Nr)�
_is_legal_key�	translate�_Translator��strr
r
r�_quote�srz\\[0-3][0-7][0-7]z[\\].cCsN|dkst|�dkr|S|ddks0|ddkr4|S|dd�}d}t|�}g}d|krf|k�rFnn�t�||�}t�||�}|s�|s�|�||d���qFd}}|r�|�d�}|r�|�d�}|�r|r�||k�r|�|||��|�||d�|d}qP|�|||��|�tt||d|d�d���|d}qPt|�S)N�rr������)	�len�
_OctalPatt�search�
_QuotePatt�append�start�chr�int�	_nulljoin)r�ir
�resZo_matchZq_match�j�kr
r
r�_unquote�s6


$
r+ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r-r,)ZfutureZweekdaynameZ	monthnamer,r-ZnowZyearZmonthZdayZhhZmmZssZwd�y�zr
r
r�_getdate�s�r0c
@s�eZdZdZdddddddd	d
d�	Zdd
hZdd�Zedd��Zedd��Z	edd��Z
dd�Zd2dd�Zdd�Z
ejZdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd3d*d+�ZeZd,d-�Zd4d.d/�Zd5d0d1�ZdS)6�MorselaCA class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.
    �expires�Path�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersionZSameSite)	r2�path�commentZdomain�max-age�secure�httponly�versionZsamesiter8r9cCs0d|_|_|_|jD]}t�||d�qdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyr
r
r�__init__ s
zMorsel.__init__cCs|jS�N)r;�rAr
r
rrB(sz
Morsel.keycCs|jSrD)r<rEr
r
r�value,szMorsel.valuecCs|jSrD)r=rEr
r
r�coded_value0szMorsel.coded_valuecCs2|��}||jkr td|f��t�|||�dS�NzInvalid attribute %r)�lowerr>rr?r@)rA�K�Vr
r
rr@4s
zMorsel.__setitem__NcCs.|��}||jkr td|f��t�|||�SrH)rIr>rr?�
setdefault)rArB�valr
r
rrL:s
zMorsel.setdefaultcCs>t|t�stSt�||�o<|j|jko<|j|jko<|j|jkSrD)�
isinstancer1�NotImplementedr?�__eq__r<r;r=�rAZmorselr
r
rrP@s

�
�
�z
Morsel.__eq__cCs$t�}t�||�|j�|j�|SrD)r1r?�update�__dict__rQr
r
r�copyJszMorsel.copycCsRi}t|���D]0\}}|��}||jkr8td|f��|||<qt�||�dSrH)r?�itemsrIr>rrR)rA�values�datarBrMr
r
rrRPs

z
Morsel.updatecCs|��|jkSrD)rIr>)rArJr
r
r�
isReservedKeyYszMorsel.isReservedKeycCsH|��|jkrtd|f��t|�s2td|f��||_||_||_dS)Nz Attempt to set a reserved key %rzIllegal key %r)rIr>rrr;r<r=)rArBrMZ	coded_valr
r
r�set\sz
Morsel.setcCs|j|j|jd�S)N)rBrFrG�r;r<r=rEr
r
r�__getstate__gs�zMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrBrFrGrZ)rA�stater
r
r�__setstate__ns

zMorsel.__setstate__�Set-Cookie:cCsd||�|�fS)Nz%s %s)�OutputString)rA�attrs�headerr
r
r�outputssz
Morsel.outputcCsd|jj|��fS)N�<%s: %s>)�	__class__rr_rEr
r
r�__repr__xszMorsel.__repr__cCsd|�|��dd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rr)r_�replace)rAr`r
r
r�	js_output{s�zMorsel.js_outputcCs$g}|j}|d|j|jf�|dkr,|j}t|���}|D]�\}}|dkrNq<||krXq<|dkr�t|t�r�|d|j|t|�f�q<|dkr�t|t�r�|d|j||f�q<|dkr�t|t	�r�|d|j|t
|�f�q<||jk�r|�r|t	|j|��q<|d|j||f�q<t|�S)N�%s=%srr2r7z%s=%dr6)
r"rBrGr>�sortedrUrNr%r0rr�_flags�_semispacejoin)rAr`�resultr"rUrBrFr
r
rr_�s,zMorsel.OutputString)N)Nr^)N)N)rrr	�__doc__r>rjrC�propertyrBrFrGr@rLrP�object�__ne__rTrRrXrYr[r]rb�__str__rergr_r
r
r
rr1�sD�



	


r1z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@sneZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zddd�Z	e	Z
dd�Zddd�Zdd�Z
efdd�ZdS)rz'A container class for a set of Morsels.cCs||fS)a
real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        r
�rArMr
r
r�value_decode�szBaseCookie.value_decodecCst|�}||fS)z�real_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        r�rArMZstrvalr
r
r�value_encode�szBaseCookie.value_encodeNcCs|r|�|�dSrD)�load)rA�inputr
r
rrC�szBaseCookie.__init__cCs.|�|t��}|�|||�t�|||�dS)z+Private method for setting a cookie's valueN)�getr1rYr?r@)rArBZ
real_valuerG�Mr
r
rZ__set�szBaseCookie.__setcCs:t|t�rt�|||�n|�|�\}}|�|||�dS)zDictionary style assignment.N)rNr1r?r@ru�_BaseCookie__set)rArBrF�rval�cvalr
r
rr@�s
zBaseCookie.__setitem__r^�
cCs:g}t|���}|D]\}}|�|�||��q|�|�S)z"Return a string suitable for HTTP.)rirUr"rb�join)rAr`ra�seprlrUrBrFr
r
rrb�s
zBaseCookie.outputcCsJg}t|���}|D] \}}|�d|t|j�f�qd|jjt|�fS)Nrhrc)rirUr"�reprrFrdr�
_spacejoin)rA�lrUrBrFr
r
rre�s
zBaseCookie.__repr__cCs6g}t|���}|D]\}}|�|�|��qt|�S)z(Return a string suitable for JavaScript.)rirUr"rgr&)rAr`rlrUrBrFr
r
rrgs
zBaseCookie.js_outputcCs4t|t�r|�|�n|��D]\}}|||<qdS)z�Load cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        N)rNr�_BaseCookie__parse_stringrU)rAZrawdatarBrFr
r
rrv
s


zBaseCookie.loadcCshd}t|�}g}d}d}d}d|kr2|k�rnn�|�||�}	|	sJ�q|	�d�|	�d�}
}|	�d�}|
ddkr�|s|q|�||
dd�|f�q|
��tjkr�|s�dS|dkr�|
��tjkr�|�||
df�q�dSn|�||
t	|�f�q|dk	�r|�||
|�
|�f�d}qdSqd}|D]>\}
}
}|
|k�rB|||
<n|\}}|�|
||�||
}�q$dS)	NrFrrrBrM�$T)r�match�group�endr"rIr1r>rjr+rsrz)rArZpattr'r
Zparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�rBrFry�tpr{r|r
r
rZ__parse_stringsF



zBaseCookie.__parse_string)N)Nr^r})N)rrr	rmrsrurCrzr@rbrqrergrv�_CookiePatternr�r
r
r
rr�s		
	

c@s eZdZdZdd�Zdd�ZdS)rz�
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    cCst|�|fSrD)r+rrr
r
rrs\szSimpleCookie.value_decodecCst|�}|t|�fSrD)rrrtr
r
rru_szSimpleCookie.value_encodeN)rrr	rmrsrur
r
r
rrUs)(rm�re�string�__all__r~r&rkr��	ExceptionrZ
ascii_lettersZdigitsZ_LegalCharsZ_UnescapedCharsrY�range�map�ordrrR�compile�escape�	fullmatchrrrr!r+Z_weekdaynameZ
_monthnamer0r?r1Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrr
r
r
r�<module>'sr]
��

2�4����
�
PK|/�\�q5��;�;cookies.cpython-38.pycnu�[���U

e5d�O�
@stdZddlZddlZdddgZdjZdjZdjZGd	d�de�Z	ej
ejd
ZedZ
dd
�eed��eeee
��D�Ze�ed�ded�di�e�de�e��jZdd�Ze�d�Ze�d�Zdd�Zddddddd gZdd!d"d#d$d%d&d'd(d)d*d+d,g
Zdeefd-d.�ZGd/d0�d0e�Z d1Z!e!d2Z"e�d3e!d4e"d5ej#ej$B�Z%Gd6d�de�Z&Gd7d�de&�Z'dS)8a.

Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

The Basics
----------

Importing is easy...

   >>> from http import cookies

Most of the time you start by creating a cookie.

   >>> C = cookies.SimpleCookie()

Once you've created your Cookie, you can add values just as if it were
a dictionary.

   >>> C = cookies.SimpleCookie()
   >>> C["fig"] = "newton"
   >>> C["sugar"] = "wafer"
   >>> C.output()
   'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'

Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header.  This is the
default behavior.  You can change the header and printed
attributes by using the .output() function

   >>> C = cookies.SimpleCookie()
   >>> C["rocky"] = "road"
   >>> C["rocky"]["path"] = "/cookie"
   >>> print(C.output(header="Cookie:"))
   Cookie: rocky=road; Path=/cookie
   >>> print(C.output(attrs=[], header="Cookie:"))
   Cookie: rocky=road

The load() method of a Cookie extracts cookies from a string.  In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.

   >>> C = cookies.SimpleCookie()
   >>> C.load("chips=ahoy; vienna=finger")
   >>> C.output()
   'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'

The load() method is darn-tootin smart about identifying cookies
within a string.  Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.

   >>> C = cookies.SimpleCookie()
   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C = cookies.SimpleCookie()
   >>> C["oreo"] = "doublestuff"
   >>> C["oreo"]["path"] = "/"
   >>> print(C)
   Set-Cookie: oreo=doublestuff; Path=/

Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C = cookies.SimpleCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'

The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.

   >>> C = cookies.SimpleCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   '7'
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number=7\r\nSet-Cookie: string=seven'

Finis.
�N�CookieError�
BaseCookie�SimpleCookie�z; � c@seZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�$/usr/lib64/python3.8/http/cookies.pyr�sz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}|d|�qS)z\%03or
)�.0�nr
r
r�
<dictcomp>�s�r��"�\"�\z\\z[%s]+cCs*|dkst|�r|Sd|�t�dSdS)z�Quote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    Nr)�
_is_legal_key�	translate�_Translator��strr
r
r�_quote�srz\\[0-3][0-7][0-7]z[\\].cCsN|dkst|�dkr|S|ddks0|ddkr4|S|dd�}d}t|�}g}d|krf|k�rFnn�t�||�}t�||�}|s�|s�|�||d���qFd}}|r�|�d�}|r�|�d�}|�r|r�||k�r|�|||��|�||d�|d}qP|�|||��|�tt||d|d�d���|d}qPt|�S)N�rr������)	�len�
_OctalPatt�search�
_QuotePatt�append�start�chr�int�	_nulljoin)r�ir
�resZo_matchZq_match�j�kr
r
r�_unquote�s6


$
r+ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r-r,)ZfutureZweekdaynameZ	monthnamer,r-ZnowZyearZmonthZdayZhhZmmZssZwd�y�zr
r
r�_getdate�s�r0c
@s�eZdZdZdddddddd	d
d�	Zdd
hZdd�Zedd��Zedd��Z	edd��Z
dd�Zd2dd�Zdd�Z
ejZdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd3d*d+�ZeZd,d-�Zd4d.d/�Zd5d0d1�ZdS)6�MorselaCA class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.
    �expires�Path�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersionZSameSite)	r2�path�commentZdomain�max-age�secure�httponly�versionZsamesiter8r9cCs0d|_|_|_|jD]}t�||d�qdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyr
r
r�__init__ s
zMorsel.__init__cCs|jS�N)r;�rAr
r
rrB(sz
Morsel.keycCs|jSrD)r<rEr
r
r�value,szMorsel.valuecCs|jSrD)r=rEr
r
r�coded_value0szMorsel.coded_valuecCs2|��}||jkr td|f��t�|||�dS�NzInvalid attribute %r)�lowerr>rr?r@)rA�K�Vr
r
rr@4s
zMorsel.__setitem__NcCs.|��}||jkr td|f��t�|||�SrH)rIr>rr?�
setdefault)rArB�valr
r
rrL:s
zMorsel.setdefaultcCs>t|t�stSt�||�o<|j|jko<|j|jko<|j|jkSrD)�
isinstancer1�NotImplementedr?�__eq__r<r;r=�rAZmorselr
r
rrP@s

�
�
�z
Morsel.__eq__cCs$t�}t�||�|j�|j�|SrD)r1r?�update�__dict__rQr
r
r�copyJszMorsel.copycCsRi}t|���D]0\}}|��}||jkr8td|f��|||<qt�||�dSrH)r?�itemsrIr>rrR)rA�values�datarBrMr
r
rrRPs

z
Morsel.updatecCs|��|jkSrD)rIr>)rArJr
r
r�
isReservedKeyYszMorsel.isReservedKeycCsH|��|jkrtd|f��t|�s2td|f��||_||_||_dS)Nz Attempt to set a reserved key %rzIllegal key %r)rIr>rrr;r<r=)rArBrMZ	coded_valr
r
r�set\sz
Morsel.setcCs|j|j|jd�S)N)rBrFrG�r;r<r=rEr
r
r�__getstate__gs�zMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrBrFrGrZ)rA�stater
r
r�__setstate__ns

zMorsel.__setstate__�Set-Cookie:cCsd||�|�fS)Nz%s %s)�OutputString)rA�attrs�headerr
r
r�outputssz
Morsel.outputcCsd|jj|��fS)N�<%s: %s>)�	__class__rr_rEr
r
r�__repr__xszMorsel.__repr__cCsd|�|��dd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rr)r_�replace)rAr`r
r
r�	js_output{s�zMorsel.js_outputcCs$g}|j}|d|j|jf�|dkr,|j}t|���}|D]�\}}|dkrNq<||krXq<|dkr�t|t�r�|d|j|t|�f�q<|dkr�t|t�r�|d|j||f�q<|dkr�t|t	�r�|d|j|t
|�f�q<||jk�r|�r|t	|j|��q<|d|j||f�q<t|�S)N�%s=%srr2r7z%s=%dr6)
r"rBrGr>�sortedrUrNr%r0rr�_flags�_semispacejoin)rAr`�resultr"rUrBrFr
r
rr_�s,zMorsel.OutputString)N)Nr^)N)N)rrr	�__doc__r>rjrC�propertyrBrFrGr@rLrP�object�__ne__rTrRrXrYr[r]rb�__str__rergr_r
r
r
rr1�sD�



	


r1z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@sneZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zddd�Z	e	Z
dd�Zddd�Zdd�Z
efdd�ZdS)rz'A container class for a set of Morsels.cCs||fS)a
real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        r
�rArMr
r
r�value_decode�szBaseCookie.value_decodecCst|�}||fS)z�real_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        r�rArMZstrvalr
r
r�value_encode�szBaseCookie.value_encodeNcCs|r|�|�dSrD)�load)rA�inputr
r
rrC�szBaseCookie.__init__cCs.|�|t��}|�|||�t�|||�dS)z+Private method for setting a cookie's valueN)�getr1rYr?r@)rArBZ
real_valuerG�Mr
r
rZ__set�szBaseCookie.__setcCs:t|t�rt�|||�n|�|�\}}|�|||�dS)zDictionary style assignment.N)rNr1r?r@ru�_BaseCookie__set)rArBrF�rval�cvalr
r
rr@�s
zBaseCookie.__setitem__r^�
cCs:g}t|���}|D]\}}|�|�||��q|�|�S)z"Return a string suitable for HTTP.)rirUr"rb�join)rAr`ra�seprlrUrBrFr
r
rrb�s
zBaseCookie.outputcCsJg}t|���}|D] \}}|�d|t|j�f�qd|jjt|�fS)Nrhrc)rirUr"�reprrFrdr�
_spacejoin)rA�lrUrBrFr
r
rre�s
zBaseCookie.__repr__cCs6g}t|���}|D]\}}|�|�|��qt|�S)z(Return a string suitable for JavaScript.)rirUr"rgr&)rAr`rlrUrBrFr
r
rrgs
zBaseCookie.js_outputcCs4t|t�r|�|�n|��D]\}}|||<qdS)z�Load cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        N)rNr�_BaseCookie__parse_stringrU)rAZrawdatarBrFr
r
rrv
s


zBaseCookie.loadcCs�d}t|�}g}d}d}d}d|kr2|k�rnn�|�||�}	|	sJ�q|	�d�|	�d�}
}|	�d�}|
ddkr�|s|q|�||
dd�|f�q|
��tjkr�|s�dS|dkr�|
��tjkr�|�||
df�q�dSn|�||
t	|�f�q|dk	�r|�||
|�
|�f�d}qdSqd}|D]Z\}
}
}|
|k�rP|dk	�sFt�|||
<n,|
|k�s^t�|\}}|�|
||�||
}�q$dS)	NrFrrrBrM�$T)
r�match�group�endr"rIr1r>rjr+rs�AssertionErrorrz)rArZpattr'r
Zparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�rBrFry�tpr{r|r
r
rZ__parse_stringsJ



zBaseCookie.__parse_string)N)Nr^r})N)rrr	rmrsrurCrzr@rbrqrergrv�_CookiePatternr�r
r
r
rr�s		
	

c@s eZdZdZdd�Zdd�ZdS)rz�
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    cCst|�|fSrD)r+rrr
r
rrs\szSimpleCookie.value_decodecCst|�}|t|�fSrD)rrrtr
r
rru_szSimpleCookie.value_encodeN)rrr	rmrsrur
r
r
rrUs)(rm�re�string�__all__r~r&rkr��	ExceptionrZ
ascii_lettersZdigitsZ_LegalCharsZ_UnescapedCharsrY�range�map�ordrrR�compile�escape�	fullmatchrrrr!r+Z_weekdaynameZ
_monthnamer0r?r1Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrr
r
r
r�<module>'sr]
��

2�4����
�
PK|/�\CQ����cookiejar.cpython-38.opt-2.pycnu�[���U

e5d#,�@sddddddddgZdd	lZdd	lZdd	lZdd	lZdd	lZdd	lZdd	lZdd	l	Z
dd	lZdd
l
mZdZd	add
�Zeejj�ZdZdd�ZdZdd�ZdddddddgZdddddd d!d"d#d$d%d&gZgZeD]Ze�e���q�dtd'd(�Z dud)d*�Z!d	d	d	d	d+�Z"e�#d,ej$�Z%d-d.�Z&d/d0�Z'e�#d1ej$�Z(e�#d2ej)ej$B�Z*e�#d3ej+ej$B�Z,d4d5�Z-e�#d6ej+ej$B�Z.d7d8�Z/d9d:�Z0e�#d;�Z1e�#d<�Z2e�#d=�Z3e�#d>�Z4d?d@�Z5e�#dA�Z6dBdC�Z7dDdE�Z8dFdG�Z9e�#dHej$�Z:dIdJ�Z;dKdL�Z<dMdN�Z=dOdP�Z>e�#dQej$�Z?dRdS�Z@dTdU�ZAdVdW�ZBdXdY�ZCdZZDe�#d[�ZEd\d]�ZFd^d_�ZGd`da�ZHdbdc�ZIGddd�d�ZJGded�d�ZKGdfd�deK�ZLdgdh�ZMdidj�ZNGdkdl�dl�ZOGdmd�d�ZPGdnd�deQ�ZRGdod�deP�ZSdpdq�ZTGdrd�deS�ZUGdsd�deS�ZVd	S)v�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|�d�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�&/usr/lib64/python3.8/http/cookiejar.py�_debug,s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|��}|�d|�|��}|jd|dd�dS)Nr	zhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)rrr�f�msgrrr�_warn_unhandled_exception:s
ri�cCs�|dd�\}}}}}}|tkr�d|kr4dkr�nnhd|krLdkr�nnPd|krddkr�nn8d|kr|dkr�nn d|kr�dkr�nnt|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmIs&8��
��
��
r,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtj��}ntj�|�}d|j|j|j|j|j|jfS)Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second��tZdtrrr�	time2isozWs�r5cCsR|dkrtj��}ntj�|�}dt|��|jt|jd|j|j	|j
|jfS)Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2r3rrr�
time2netscapejs
�r8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTt�|�}|rfdt|�d��}|�d�rR|dt|�d��}|�d�dkrf|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s

rFc
Cs�t|�}|tjkrdSzt�|���d}Wn^tk
r�zt|�}Wntk
r`YYdSXd|krvdkr�nn|}nYdSYnX|dkr�d}|dkr�d}|dkr�d}t|�}t|�}t|�}t|�}|dk�r6t�t���d}|d}	|}
|||	}|	|
}	t	|	�dk�r6|	dk�r.|d}n|d}t
|||||||f�}|dk	�r�|dk�rdd}|��}t|�}|dk�r�dS||}|S)Nrr r	i��d�2r9)
rAr-ZMAXYEAR�MONTHS_LOWER�index�lower�
ValueError�time�	localtime�absr,�upperrF)
r0�mon�yr�hrr*r+rCZimonZcur_yrrEZtmpr4rDrrr�	_str2time�sV







rTzV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    (?:
       ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
       \s*
    )?
    (?:
       \(\w+\)         # ASCII representation of timezone in parens.
       \s*
    )?$cCs�t�|�}|rl|��}t�|d���d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|�	�}t
�d|d�}dgd\}}}}}}	}
t�|�}|dk	r�|��\}}}}}}	}
ndSt
||||||	|
�S)	Nrrr	r;����)�STRICT_DATE_REr@�groupsrIrJrKrA�floatr,�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_RErT)�textrE�grQr&r0rRrSr*r+rCrrr�	http2time�s$



�
rba�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   (?:
      ([-+]?\d\d?:?(:?\d\d)?
       |Z|z)             # timezone  (Z is "zero meridian", i.e. GMT)
      \s*
   )?$c
Csd|��}dgd\}}}}}}}t�|�}|dk	rL|��\}}}}}}}}	ndSt|||||||�S)NrX)r\�ISO_DATE_REr@rZrT)
r`r0rQrRrSr*r+rCrE�_rrr�iso2time+s

recCs*|�d�\}}|jd|�|j|d�S)Nr	)�span�string)�match�start�endrrr�	unmatchedLsrkz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Csg}|D]�}|}g}|r�t�|�}|r�t|�}|�d�}t�|�}|rft|�}|�d�}t�d|�}n.t�|�}|r�t|�}|�d�}|��}nd}|�	||f�q|�
��d�r�|�
�dd�}|r�|�	|�g}qt�
dd|�\}}	|}q|r|�	|�q|S)Nrz\1�,z^[=\s;]*rW)�HEADER_TOKEN_REr@rkrB�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr^�HEADER_VALUE_RE�rstrip�appendr\�
startswith�re�subn)
Z
header_values�resultr`Z	orig_text�pairsrE�name�valueZnon_junkZ
nr_junk_charsrrr�split_header_wordsUs>.







rz�([\"\\])cCs|g}|D]h}g}|D]F\}}|dk	rPt�d|�sDt�d|�}d|}d||f}|�|�q|r|�d�|��qd�|�S)Nz^\w+$�\\\1z"%s"�%s=%s�; �, )rtr@�HEADER_JOIN_ESCAPE_REr^rr�join)Zlists�headersrw�attr�k�vrrr�join_header_words�sr�cCs0|�d�r|dd�}|�d�r,|dd�}|S)N�"r���)rs�endswith�r`rrr�strip_quotes�s


r�cCs�d}g}|D]�}g}d}t|�d��D]�\}}|��}|�d�\}}	}
|��}|sb|dkr&q�nq&|	rn|
��nd}
|dkr�|��}||kr�|}|dkr�|
dk	r�t|
�}
d}n|dkr�|
dk	r�tt|
��}
|�||
f�q&|r|s�|�d	�|�|�q|S)
N)�expires�domain�path�secure�version�port�max-ageF�;�=r	r�Tr�)r��0)�	enumerate�split�strip�	partitionrKr�rbrr)Z
ns_headersZknown_attrsrvZ	ns_headerrw�version_setZiiZparam�key�sep�val�lcrrr�parse_ns_headers�s>
r�z\.\d+$cCs:t�|�rdS|dkrdS|ddks2|ddkr6dSdS)NFrWr	�.r�T��IPV4_REr@r�rrr�is_HDNs
r�cCsl|��}|��}||krdSt|�s(dS|�|�}|dksB|dkrFdS|�d�sTdSt|dd��shdSdS)NTFr�r	r�r)rKr��rfindrs)�A�B�irrr�domain_matchs

r�cCst�|�rdSdS�NFTr�r�rrr�liberal_is_HDNFs
r�cCs`|��}|��}t|�r t|�s0||kr,dSdS|�d�}|rL|�|�rLdS|s\||kr\dSdS)NTFr�)rKr�rsr�)r�r��initial_dotrrr�user_domain_matchPs
r�z:\d+$cCsB|��}tj�|�d}|dkr,|�dd�}t�d|d�}|��S)NrrWZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer^rK)�request�url�hostrrr�request_hostesr�cCs4t|�}}|�d�dkr,t�|�s,|d}||fS)Nr�r��.local)r��findr�r@)r��erhn�req_hostrrr�eff_request_hostusr�cCs4|��}tj�|�}t|j�}|�d�s0d|}|S)N�/)r�r�r�Zurlsplit�escape_pathr�rs)r�r��partsr�rrr�request_path�s

r�cCs`|j}|�d�}|dkrX||dd�}zt|�Wq\tk
rTtd|�YdSXnt}|S)N�:r	rznonnumeric port: '%s')r�r�rArLr�DEFAULT_HTTP_PORT)r�r�r�r�rrr�request_port�s


r�z%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|�d���S)Nz%%%sr)rBrP)rhrrr�uppercase_escaped_char�sr�cCstj�|t�}t�t|�}|S�N)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr^r�)r�rrrr��s
r�cCsP|�d�}|dkrL||dd�}|�d�}t|�rL|dksD|dkrLd|S|S)Nr�r	rZlocal)r�r�)�hr��brrr�reach�s

r�cCs$t|�}t|t|j��sdSdSdS�NTF)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
r�c@sJeZdZddd�Zdd�Zddd�Zd	d
�Zddd�Zd
d�Zdd�Z	dS)rFcCs�|dk	rt|�}|dk	r$tt|��}|dkr<|dkr<td��||_||_||_||_||_|��|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_t�|�|_dS)NTz-if port is None, port_specified must be false)rAr[rLr�rxryr��port_specifiedrKr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�rxryr�r�r�r�r�r�r�r�r�r�r�r��restr�rrr�__init__�s.

zCookie.__init__cCs
||jkSr��r�)r�rxrrr�has_nonstandard_attrszCookie.has_nonstandard_attrNcCs|j�||�Sr�)r��get)r�rx�defaultrrr�get_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dSr�r�)r�rxryrrr�set_nonstandard_attr szCookie.set_nonstandard_attrcCs,|dkrt��}|jdk	r(|j|kr(dSdSr�)rMr�)r��nowrrr�
is_expired#s
zCookie.is_expiredcCsX|jdkrd}n
d|j}|j||j}|jdk	rFd|j|jf}n|j}d||fS)NrWr�r}z<Cookie %s for %s>)r�r�r�ryrx)r��p�limitZ	namevaluerrr�__str__)s


zCookie.__str__cCslg}dD]$}t||�}|�d|t|�f�q|�dt|j��|�dt|j��d|jjd�|�fS)N)r�rxryr�r�r�r�r�r�r�r�r�r�r�r�r}zrest=%sz
rfc2109=%sz%s(%s)r)�getattrrr�reprr�r��	__class__�__name__r�)r�rrxr�rrr�__repr__3s
zCookie.__repr__)F)N)N)
r��
__module__�__qualname__r�r�r�r�r�r�r�rrrrr�s�
*


c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCs
t��dSr���NotImplementedError�r��cookier�rrr�set_okKszCookiePolicy.set_okcCs
t��dSr�r�r�rrr�	return_okTszCookiePolicy.return_okcCsdS�NTr)r�r�r�rrr�domain_return_okXszCookiePolicy.domain_return_okcCsdSr�r)r�r�r�rrr�path_return_ok]szCookiePolicy.path_return_okN)r�r�r�r�r�r�r�rrrrrBs		c
@s�eZdZdZdZdZdZeeBZdddddddddedddf
d	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�ZdS)7rrrrUr	NTF)ZhttpsZwsscCsv||_||_||_||_||_||_|	|_|
|_||_||_	|
|_
|dk	rVt|�|_nd|_|dk	rlt|�}||_
dS)Nr)�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�secure_protocols�tuple�_blocked_domains�_allowed_domains)r��blocked_domains�allowed_domainsr�r�r�r�r�r�r�r�r�r�r�rrrr�ms"zDefaultCookiePolicy.__init__cCs|jSr�)r��r�rrrr�sz#DefaultCookiePolicy.blocked_domainscCst|�|_dSr�)r�r�)r�rrrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs |jD]}t||�rdSqdSr�)r�r�)r�r�Zblocked_domainrrr�
is_blocked�s

zDefaultCookiePolicy.is_blockedcCs|jSr�)r�rrrrr�sz#DefaultCookiePolicy.allowed_domainscCs|dk	rt|�}||_dSr�)r�r�)r�rrrr�set_allowed_domains�sz'DefaultCookiePolicy.set_allowed_domainscCs.|jdkrdS|jD]}t||�rdSqdSr�)r�r�)r�r�Zallowed_domainrrr�is_not_allowed�s


z"DefaultCookiePolicy.is_not_allowedcCs@td|j|j�dD]&}d|}t||�}|||�sdSqdS)N� - checking cookie %s=%s)r��
verifiabilityrxr�r�r�Zset_ok_FT�rrxryr��r�r�r��nZfn_name�fnrrrr��s

zDefaultCookiePolicy.set_okcCsZ|jdkrtd|j|j�dS|jdkr:|js:td�dS|jdkrV|jsVtd�dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	�$   RFC 2965 cookies are switched off�$   Netscape cookies are switched offT)r�rrxryr�r�r�rrr�set_ok_version�s
�z"DefaultCookiePolicy.set_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS�Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT�Zunverifiabler�r�r�rr�r�rrr�set_ok_verifiability�sz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|j�d�r,td|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�r�rxrsrr�rrr�set_ok_name�s
�zDefaultCookiePolicy.set_ok_namecCsL|jrHt|�}|jdks(|jdkrH|jrH|�|j|�sHtd|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�r�r�r�r)r�r�r��req_pathrrr�set_ok_path�s
����zDefaultCookiePolicy.set_ok_pathc
Cs�|�|j�rtd|j�dS|�|j�r8td|j�dS|j�r�t|�\}}|j}|jr�|�d�dkr�|�d�}|�dd|�}|dkr�||dd�}||d|�}	|	�	�dkr�t
|�dkr�td	|�dS|�d�r�|dd�}
n|}
|
�d�dk}|�s|d
k�rtd|�dS|j
dk�rX|�|��sX|�d��sXd|�|��sXtd||�dS|j
dk�sr|j|j@�r�t||��s�td
||�dS|j
dk�s�|j|j@�r�|dt
|��}|�d�dk�r�t�|��s�td||�dSdS)N�"   domain %s is in user block-listF�&   domain %s is not in user allow-listr�rr	r)�coZacZcomZeduZorgZnetZgovZmilrAZaeroZbiz�catZcoop�infoZjobsZmobiZmuseumrxZproZtravelZeuz&   country-code second level domain %sr�z/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rr�rrr�r�r��countr�rK�lenrsr�r�r�r��DomainRFC2965Matchr��DomainStrictNoDotsr�r@)
r�r�r�r�r�r�r��jZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr�
set_ok_domain�s|

�

����
��
���z!DefaultCookiePolicy.set_ok_domainc	Cs�|jr�t|�}|dkrd}nt|�}|j�d�D]@}zt|�Wn"tk
rbtd|�YdSX||kr0q�q0td||j�dSdS)N�80rlz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)r�r��strr�r�rArLr�r�r�r�Zreq_portr�rrr�set_ok_port+s&

�zDefaultCookiePolicy.set_ok_portcCs@td|j|j�dD]&}d|}t||�}|||�sdSqdS)Nr)r�rr�r�r�r�Z
return_ok_FTr	r
rrrr�@s	

zDefaultCookiePolicy.return_okcCs<|jdkr|jstd�dS|jdkr8|js8td�dSdS)Nr	r
FrT)r�r�rr�r�rrr�return_ok_versionRsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdSrrr�rrr�return_ok_verifiability[sz+DefaultCookiePolicy.return_ok_verifiabilitycCs"|jr|j|jkrtd�dSdS)Nz(   secure cookie with non-secure requestFT)r��typer�rr�rrr�return_ok_securegsz$DefaultCookiePolicy.return_ok_securecCs|�|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowrr�rrr�return_ok_expiresmsz%DefaultCookiePolicy.return_ok_expirescCsN|jrJt|�}|dkrd}|j�d�D]}||kr&qJq&td||j�dSdS)Nr"rlz0   request port %s does not match cookie port %sFT)r�r�r�rr$rrr�return_ok_portss�z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r*|�d�s*d|}n|}|jdkr^|j|j@r^|js^||kr^td�dS|jdkr�t||�s�td||�dS|jdkr�d|�	|�s�td||�dSdS)Nr�r	zQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sz;   request-host %s does not match Netscape cookie domain %sT)
r�r�rsr�r��DomainStrictNonDomainr�rr�r�)r�r�r�r�r�r��	dotdomainrrr�return_ok_domain�s6


�����z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|�d�sd|}|�d�s0d|}|rH|�d�sHd|}n|}|�|�sd|�|�sddS|�|�r|td|�dS|�|�r�td|�dSdS)Nr�FrrT)r�rsr�rrr)r�r�r�r�r�r.rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCsbtd|�t|�}t|�}||kr&dS|�|�rR|�d�sN|||d�dkrRdStd||�dS)Nz- checking cookie path=%sTr�rz  %s does not path-match %sF)rr�rrsr�)r�r�r�rZpathlenrrrr��s

��z"DefaultCookiePolicy.path_return_ok)r�r�r�rr-rZ
DomainLiberalZDomainStrictr�rrrrrrr�rrrrr!r%r�r&r'r)r+r,r/r�r�rrrrrcsR�
#	;	cCst|���}t|j|�Sr�)�sorted�keys�mapr�)Zadictr1rrr�vals_sorted_by_key�sr3c	csVt|�}|D]D}d}z
|jWntk
r2YnXd}t|�EdH|s|VqdSr�)r3�items�AttributeError�
deepvalues)�mapping�values�objrrrr6�s
r6c@seZdZdS)�AbsentN�r�r�r�rrrrr:�sr:c@s�eZdZe�d�Ze�d�Ze�d�Ze�d�Ze�d�Z	e�dej
�Zd2dd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd3d$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dS)4rz\Wr{z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|dkrt�}||_t��|_i|_dSr�)r�_policy�
_threading�RLock�
_cookies_lock�_cookies�r��policyrrrr��s

zCookieJar.__init__cCs
||_dSr�)r<rArrr�
set_policy�szCookieJar.set_policycCs�g}|j�||�sgStd|�|j|}|��D]T}|j�||�sFq2||}|��D].}|j�||�srtd�qVtd�|�|�qVq2|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r<r�rr@r1r�r8r�rr)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s 

zCookieJar._cookies_for_domaincCs*g}|j��D]}|�|�||��q|Sr�)r@r1�extendrE)r�r�rDr�rrr�_cookies_for_requestszCookieJar._cookies_for_requestc	Cs<|jdd�dd�d}g}|D�]}|j}|sHd}|dkrH|�d|�|jdk	rz|j�|j�rz|dkrz|j�d|j�}n|j}|jdkr�|�|j�n|�d	|j|f�|dkr|j	r�|�d
|j
�|j�d��r|j}|j
s�|�d�r�|dd�}|�d
|�|jdk	rd}|j�r,|d|j}|�|�q|S)NcSs
t|j�Sr�)rr�)�arrr�<lambda>�z)CookieJar._cookie_attrs.<locals>.<lambda>T)r��reverseFr	z$Version=%sr|r}z
$Path="%s"r�rz$Domain="%s"z$Portz="%s")�sortr�rrry�non_word_rer@�quote_rer^rxr�r�r�rsr�r�r�)	r�rDr��attrsr�r�ryr�r�rrr�
_cookie_attrssF


��
�
zCookieJar._cookie_attrscCs�td�|j��z�tt���|j_|_|�|�}|�	|�}|r^|�
d�s^|�dd�|��|jj
r�|jjs�|�
d�s�|D]}|jdkr||�dd�q�q|W5|j��X|��dS)N�add_cookie_headerrr~ZCookie2rz$Version="1")rr?�acquire�releaserArMr<r*rGrPZ
has_headerZadd_unredirected_headerr�r�r�r��clear_expired_cookies)r�r�rDrOr�rrrrQIs*



��

zCookieJar.add_cookie_headerc
Cs�g}d}d}|D�]z}|d\}}d}d}	i}
i}|dd�D�]0\}}
|��}||ks`||krd|}||krx|
dkrxd}
||
kr�q>|dkr�|
dkr�td�d}	�qr|
��}
|d	kr�|r�q>|
dkr�td
�q>|dk�r d}zt|
�}
Wn*tk
�rtd�d}	Y�qrYnXd	}|j|
}
||k�s4||k�rh|
dk�r^|d
k�r^td|�d}	�qr|
|
|<q>|
||<q>|	�rzq|�|||
|f�q|S)N)r�r�)r�r�r�r�r�r�r��
commenturlr	FrTr�z%   missing value for domain attributer�zM   missing or invalid value for expires attribute: treating as session cookier�z?   missing or invalid (non-numeric) value for max-age attribute)r�r�rUz!   missing value for %s attribute)rKrrArLr*rr)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsrxryZmax_age_setZ
bad_cookie�standardr�r�r�r�rrr�_normalized_cookie_tuplesjsh





�

z#CookieJar._normalized_cookie_tuplescCs&|\}}}}|�dt�}|�dt�}|�dt�}	|�dt�}
|�dd�}|dk	rtzt|�}Wntk
rrYdSX|�dd�}|�dd�}
|�d	d�}|�d
d�}|tk	r�|dkr�d}t|�}nXd}t|�}|�d
�}|dk�r|dkr�|d|�}n|d|d�}t|�dk�rd
}|tk	}d}|�r:t|�	d��}|tk�rVt
|�\}}|}n|�	d��sjd|}d}|	tk	�r�|	dk�r�t|�}	nd}t�
dd|	�}	nd}	|
tk�r�d}
d}
nH|
|jk�rz|�|||�Wntk
�r�YnXtd|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rUrWTr�r�r	rr�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s')r�r:rArLr�r�r�r�boolrsr�r�rtr^r*�clear�KeyErrorrr)r��tupr�rxryrZr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�_cookie_from_cookie_tuple�s�







��z#CookieJar._cookie_from_cookie_tuplecCs6|�|�}g}|D]}|�||�}|r|�|�q|Sr�)r[r`rr)r�rVr�rWrDr_r�rrr�_cookies_from_attrs_set's
z!CookieJar._cookies_from_attrs_setcCsHt|jdd�}|dkr |jj}|D]}|jdkr$d|_|r$d|_q$dS)Nr�rTr	)r�r<r�r�r�)r�rDZ
rfc2109_as_nsr�rrr�_process_rfc2109_cookies0s

z"CookieJar._process_rfc2109_cookiesc
Cs:|��}|�dg�}|�dg�}tt���|j_|_|jj}|jj}|sN|rf|sV|rf|s^|rf|sj|sjgSz|�t	|�|�}Wnt
k
r�t�g}YnX|�r6|�r6z|�t|�|�}	Wnt
k
r�t�g}	YnX|�
|	�|�r&i}
|D]}d|
|j|j|jf<q�|
fdd�}t||	�}	|	�r6|�|	�|S)NzSet-Cookie2z
Set-CookiecSs|j|j|jf}||kSr�)r�r�rx)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965isz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)rZget_allrArMr<r*r�r�rarz�	Exceptionrr�rbr�r�rx�filterrF)
r��responser�r�Zrfc2965_hdrsZns_hdrsr�r�rDZ
ns_cookiesrcr�rdrrr�make_cookies<s^�������
�



zCookieJar.make_cookiescCsN|j��z2tt���|j_|_|j�||�r:|�|�W5|j��XdSr�)	r?rRrSrArMr<r*r��
set_cookier�rrr�set_cookie_if_okss
zCookieJar.set_cookie_if_okcCsl|j}|j��zJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<W5|j��XdSr�)r@r?rRrSr�r�rx)r�r��cZc2Zc3rrrri�s






zCookieJar.set_cookiecCsbtd|���|j��z8|�||�D]&}|j�||�r&td|�|�|�q&W5|j��XdS)Nzextract_cookies: %sz setting cookie: %s)	rrr?rRrSrhr<r�ri)r�rgr�r�rrr�extract_cookies�s

zCookieJar.extract_cookiescCst|dk	r2|dks|dkr td��|j|||=n>|dk	rX|dkrJtd��|j||=n|dk	rj|j|=ni|_dS)Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLr@)r�r�r�rxrrrr]�s��
zCookieJar.clearcCsD|j��z(|D]}|jr|�|j|j|j�qW5|j��XdSr�)r?rRrSr�r]r�r�rx)r�r�rrr�clear_session_cookies�s
zCookieJar.clear_session_cookiescCsP|j��z4t��}|D]"}|�|�r|�|j|j|j�qW5|j��XdSr�)	r?rRrSrMr�r]r�r�rx)r�r�r�rrrrT�s


zCookieJar.clear_expired_cookiescCs
t|j�Sr�)r6r@rrrr�__iter__�szCookieJar.__iter__cCsd}|D]}|d}q|S)Nr	rr)r�r�r�rrr�__len__�s
zCookieJar.__len__cCs2g}|D]}|�t|��qd|jjd�|�fS�Nz<%s[%s]>r)rrr�r�r�r��r��rr�rrrr��szCookieJar.__repr__cCs2g}|D]}|�t|��qd|jjd�|�fSrp)rrr#r�r�r�rqrrrr��szCookieJar.__str__)N)NNN)!r�r�r�rt�compilerMrNZstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�rCrErGrPrQr[r`rarbrhrjrirlr]rmrTrnror�r�rrrrr�s6





;!a\	7


c@seZdZdS)rNr;rrrrr�sc@s4eZdZddd�Zddd�Zd
dd�Zdd	d
�ZdS)rNFcCs2t�||�|dk	rt�|�}||_t|�|_dSr�)rr��os�fspath�filenamer\�	delayload)r�rxryrBrrrr��s

zFileCookieJar.__init__cCs
t��dSr�r�)r�rx�ignore_discard�ignore_expiresrrr�save�szFileCookieJar.savec	CsJ|dkr"|jdk	r|j}ntt��t|��}|�||||�W5QRXdSr�)rxrL�MISSING_FILENAME_TEXT�open�_really_load�r�rxrzr{rrrr�loads

zFileCookieJar.loadcCs�|dkr"|jdk	r|j}ntt��|j��zFt�|j�}i|_z|�	|||�Wnt
k
rn||_�YnXW5|j��XdSr�)rxrLr}r?rRrSr�Zdeepcopyr@r��OSError)r�rxrzr{Z	old_staterrr�revert	s

zFileCookieJar.revert)NFN)NFF)NFF)NFF)r�r�r�r�r|r�r�rrrrr�s


	�cCs |j|jfd|jfd|jfg}|jdk	r8|�d|jf�|jrH|�d�|jrX|�d�|jrh|�d�|j	rx|�d�|j
r�|�dtt|j
��f�|j
r�|�d	�|jr�|�d
|jf�|jr�|�d|jf�t|j���}|D]}|�|t|j|�f�q�|�dt|j�f�t|g�S)
Nr�r�r�)�	path_specN)�	port_specN)�
domain_dotN)r�Nr�)r�Nr�rUr�)rxryr�r�r�rrr�r�r�r�r�r5r[r�r�r�r0r�r1r#r�r�)r�r�r1r�rrr�lwp_cookie_str$s:
�




�
r�c@s(eZdZd
dd�Zddd�Zdd	�ZdS)rTcCsTt��}g}|D]2}|s |jr q|s0|�|�r0q|�dt|��qd�|dg�S)NzSet-Cookie3: %s�
rW)rMr�r�rrr�r�)r�rzr{r�rrr�rrr�
as_lwp_strMs
zLWPCookieJar.as_lwp_strNFc	CsX|dkr"|jdk	r|j}ntt��t|d��"}|�d�|�|�||��W5QRXdS)N�wz#LWP-Cookies-2.0
)rxrLr}r~�writer�r�rrrr|]s

zLWPCookieJar.savecCs0|��}|j�|�s$d|}t|��t��}d}d}	d}
�z�|��}|dkrP�q�|�|�s\q<|t|�d���}t|g�D�]f}|d\}
}i}i}|	D]}d||<q�|dd�D]n\}}|dk	r�|�	�}nd}||
ks�||	kr�|}||	k�r|dkr�d	}|||<q�||
k�r|||<q�|||<q�|j
}|d
�}|d�}|dk	�rJt|�}|dk�rXd	}|d�}|�d
�}t|d�|
||d�|d�|||d�|d�|d�|d�|||d�|d�|�}|�s�|j
�r�qz|�s�|�|��r�qz|�|�qzq<WnBtk
�r�Yn,tk
�r*t�td||f��YnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:)r�r�r�r�r�)r�r�r�r�r�r�rUrWr	FrTr�r�r�r�r�r�r�r�r�r�r�r�rUz&invalid Set-Cookie3 format file %r: %r)�readlinerur@rrMrsrr�rzrKr�rerr�r�rir�rer)r�rrxrzr{�magicrr��headerrXrY�line�datarxryrZr�r�r�r�r�r�r�r�r�rkrrrris��










�
�zLWPCookieJar._really_load)TT)NFF)r�r�r�r�r|rrrrrr@s

c@s,eZdZe�d�ZdZdd�Zd	dd�ZdS)
rz#( Netscape)? HTTP Cookie Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCsbt��}|��}|j�|�s(td|��z�|��}|dkr>�q|�d�rT|dd�}|���d�s*|��dkrpq*|�d�\}}	}
}}}
}|dk}|	dk}	|
dkr�|}
d}|�d�}d	}|dkr�d}d
}t	d|
|dd	||	||
d	|||ddi�}|s�|j
r�q*|�s|�|��rq*|�|�q*WnBt
k
�r2�Yn,tk
�r\t�td||f��YnXdS)
Nz4%r does not look like a Netscape format cookies filerWr�r�)�#r�	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %r)rMr�rur@rr�r�rsr�rr�r�rir�rer)r�rrxrzr{r�r�r�r�r�r�r�r�rxryr�r�rkrrrr�sr��

��
�

�zMozillaCookieJar._really_loadNFc
Cs�|dkr"|jdk	r|j}ntt��t|d���}|�|j�t��}|D]�}|sV|jrVqF|sf|�|�rfqF|j	rrd}nd}|j
�d�r�d}nd}|jdk	r�t
|j�}	nd}	|jdkr�d}
|j}n|j}
|j}|�d�|j
||j||	|
|g�d�qFW5QRXdS)Nr�r�ZFALSEr�rWr�r�)rxrLr}r~r�r�rMr�r�r�r�rsr�r#ryrxr�r�)r�rxrzr{rr�r�r�r�r�rxryrrrr| sH



���zMozillaCookieJar.save)NFF)	r�r�r�rtrsrur�rr|rrrrr�s
A)N)N)W�__all__rvr�r-rtrMZurllib.parser�Zurllib.requestZ	threadingr=Zhttp.clientZhttpZcalendarr
rrrr#ZclientZ	HTTP_PORTr�r}rr%r,r6r7rIr(rrrKr5r8r>rsrtr?rFrTrY�Ir]�Xr_rbrcrerkrmrnrprorzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr3r6r:rr�rrr�rrrrrr�<module>s��
�

8�
�
�8
�!



U
D'


#b!b7xPK|/�\~!�A�A�server.cpython-38.opt-1.pycnu�[���U

e5d��@s
dZdZdddddgZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZdd	lmZdd
l	mZdZdZGd
d�dej�ZGdd�deje�Z Gdd�dej!�Z"Gdd�de"�Z#dd�Z$da%dd�Z&dd�Z'Gdd�de#�Z(dd�Z)e"e dddfdd�Z*e+dk�rddl,Z,e,�-�Z.e.j/dd d!d"�e.j/d#d$d%d&d'�e.j/d(d)e
�0�d*d+�e.j/d,d-de1d.d/d0�e.�2�Z3e3j4�r�e(Z5nee#e3j6d1�Z5Gd2d3�d3e �Z7e*e5e7e3j8e3j9d4�dS)5a@HTTP server classes.

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections,
as of version 0.3.

Notes on CGIHTTPRequestHandler
------------------------------

This class implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
subprocess.Popen() is used as a fallback, with slightly altered semantics.

In all cases, the implementation is intentionally naive -- all
requests are executed synchronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
z0.6�
HTTPServer�ThreadingHTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�partial)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c@seZdZdZdd�ZdS)r�cCs4tj�|�|jdd�\}}t�|�|_||_dS)z.Override server_bind to store the server name.N�)�socketserver�	TCPServer�server_bindZserver_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�#/usr/lib64/python3.8/http/server.pyr
�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressr
rrrrr�sc@seZdZdZdS)rTN)rrrZdaemon_threadsrrrrr�sc
@sJeZdZdZdej��dZdeZ	e
ZeZ
dZdd�Zdd	�Zd
d�Zdd
�ZdFdd�ZdGdd�ZdHdd�Zdd�Zdd�Zdd�ZdIdd�Zdd�Ze�d d!�e�ed"�ed#d$��D��Z d%e e!d&�<d'd(�Z"d)d*�Z#dJd+d,�Z$d-d.�Z%d/d0d1d2d3d4d5gZ&dd6d7d8d9d:d;d<d=d>d?d@dAg
Z'dBdC�Z(dDZ)e*j+j,Z-dEd!�e.j/�0�D�Z1dS)Kra�HTTP request handler base class.

    The following explanation of HTTP serves to guide you through the
    code as well as to expose any misunderstandings I may have about
    HTTP (so you don't need to read the code to figure out I'm wrong
    :-).

    HTTP (HyperText Transfer Protocol) is an extensible protocol on
    top of a reliable stream transport (e.g. TCP/IP).  The protocol
    recognizes three parts to a request:

    1. One line identifying the request type and path
    2. An optional set of RFC-822-style headers
    3. An optional data part

    The headers and data are separated by a blank line.

    The first line of the request has the form

    <command> <path> <version>

    where <command> is a (case-sensitive) keyword such as GET or POST,
    <path> is a string containing path information for the request,
    and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
    <path> is encoded using the URL encoding scheme (using %xx to signify
    the ASCII character with hex code xx).

    The specification specifies that lines are separated by CRLF but
    for compatibility with the widest range of clients recommends
    servers also handle LF.  Similarly, whitespace in the request line
    is treated sensibly (allowing multiple spaces between components
    and allowing trailing whitespace).

    Similarly, for output, lines ought to be separated by CRLF pairs
    but most clients grok LF characters just fine.

    If the first line of the request has the form

    <command> <path>

    (i.e. <version> is left out) then this is assumed to be an HTTP
    0.9 request; this form has no optional headers and data part and
    the reply consists of just the data.

    The reply form of the HTTP 1.x protocol again has three parts:

    1. One line giving the response code
    2. An optional set of RFC-822-style headers
    3. The data

    Again, the headers and data are separated by a blank line.

    The response code line has the form

    <version> <responsecode> <responsestring>

    where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
    <responsecode> is a 3-digit response code indicating success or
    failure of the request, and <responsestring> is an optional
    human-readable string explaining what the response code means.

    This server parses the request and the headers, and then calls a
    function specific to the request type (<command>).  Specifically,
    a request SPAM will be handled by a method do_SPAM().  If no
    such method exists the server sends an error response to the
    client.  If it exists, it is called with no arguments:

    do_SPAM()

    Note that the request name is case sensitive (i.e. SPAM and spam
    are different requests).

    The various request details are stored in instance variables:

    - client_address is the client IP address in the form (host,
    port);

    - command, path and version are the broken-down request line;

    - headers is an instance of email.message.Message (or a derived
    class) containing the header information;

    - rfile is a file object open for reading positioned at the
    start of the optional input data part;

    - wfile is a file object open for writing.

    IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

    The first thing to be written must be the response line.  Then
    follow 0 or more header lines, then a blank line, and then the
    actual data (if any).  The meaning of the header lines depends on
    the command executed by the server; in most cases, when data is
    returned, there should be at least one header line of the form

    Content-type: <type>/<subtype>

    where <type> and <subtype> should be registered MIME types,
    e.g. "text/html" or "text/plain".

    zPython/rz	BaseHTTP/�HTTP/0.9c
Cs�d|_|j|_}d|_t|jd�}|�d�}||_|��}t	|�dkrLdSt	|�dk�r&|d}zT|�
d	�srt�|�d
d�d}|�d�}t	|�d
kr�t�t|d�t|d�f}Wn,tt
fk
r�|�tjd|�YdSX|dk�r|jdk�rd|_|dk�r |�tjd|�dS||_d
t	|�k�rBdk�sZn|�tjd|�dS|dd
�\}}t	|�d
k�r�d|_|dk�r�|�tjd|�dS|||_|_|j�
d��r�d
|j�d
�|_ztjj|j|jd�|_Wn�tjjk
�r(}z|�tjdt|��WY�dSd}~XYnBtjjk
�rh}z|�tjdt|��WY�dSd}~XYnX|j�dd�}	|	��dk�r�d|_n |	��dk�r�|jdk�r�d|_|j�dd�}
|
��dk�r�|jdk�r�|jdk�r�|� ��s�dSdS) aHParse a request (internal).

        The request should be stored in self.raw_requestline; the results
        are in self.command, self.path, self.request_version and
        self.headers.

        Return True for success, False for failure; on failure, any relevant
        error response has already been sent back.

        NTz
iso-8859-1z
rF����zHTTP/�/r	�.r
zBad request version (%r))r	r	zHTTP/1.1)r
rzInvalid HTTP version (%s)zBad request syntax (%r)ZGETzBad HTTP/0.9 request type (%r)z//)Z_classz
Line too longzToo many headers�
Connection��close�
keep-aliveZExpectz100-continue)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
startswith�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr)�wordsZbase_version_numberZversion_numberr"r2�errZconntypeZexpectrrr�
parse_requests�


�
��
�
������
z$BaseHTTPRequestHandler.parse_requestcCs|�tj�|��dS)a7Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        T)�send_response_onlyrZCONTINUE�end_headers�rrrrr;xsz(BaseHTTPRequestHandler.handle_expect_100c
Cs�z�|j�d�|_t|j�dkrBd|_d|_d|_|�tj	�WdS|jsTd|_
WdS|��sbWdSd|j}t||�s�|�tj
d|j�WdSt||�}|�|j��Wn<tjk
r�}z|�d|�d|_
WY�dSd}~XYnXdS)	z�Handle a single HTTP request.

        You normally don't need to override this method; see the class
        __doc__ string for information on how to handle specific HTTP
        commands such as GET and POST.

        iirNTZdo_zUnsupported method (%r)zRequest timed out: %r)r6�readliner'r+r)r$r"r0rZREQUEST_URI_TOO_LONGr%r?�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushrZtimeout�	log_error)rZmname�method�errr�handle_one_request�s6

�
z)BaseHTTPRequestHandler.handle_one_requestcCs"d|_|��|js|��qdS)z&Handle multiple requests if necessary.TN)r%rLrBrrr�handle�szBaseHTTPRequestHandler.handleNcCsz|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|�d||�|�||�|�dd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d	�}|�d
d�}|�d|j
�|�d
tt|���|��|jdk�r|�r|j�|�dS)akSend and log an error reply.

        Arguments are
        * code:    an HTTP error code
                   3 digits
        * message: a simple optional 1 line reason phrase.
                   *( HTAB / SP / VCHAR / %x80-FF )
                   defaults to short entry matching the response code
        * explain: a detailed message defaults to the long entry
                   matching the response code.

        This sends an error response (so it must be called before any
        output has been generated), logs the error, and finally sends
        a piece of HTML explaining the error to the user.

        )�???rNNzcode %d, message %srr ��F��quote)�code�message�explainzUTF-8�replacezContent-Type�Content-LengthZHEAD)�	responses�KeyErrorrI�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENT�NOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer&r+rAr"rG�write)rrRrSrTZshortmsgZlongmsgZbodyZcontentrrrr0�s:���z!BaseHTTPRequestHandler.send_errorcCs:|�|�|�||�|�d|���|�d|���dS)z�Add the response header to the headers buffer and log the
        response code.

        Also send two standard headers with the server software
        version and the current date.

        ZServerZDateN)�log_requestr@rZ�version_string�date_time_string�rrRrSrrrrY�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|j�d|j||f�dd��dS)	zSend the response header only.rNrr�_headers_bufferz
%s %d %s
�latin-1�strict)r$rWrDrf�appendr1r_rerrrr@�s



��z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|j�d||f�dd��|��dkrh|��dkrVd|_n|��d	krhd
|_dS)z)Send a MIME header to the headers buffer.rrfz%s: %s
rgrhZ
connectionr Tr!FN)r$rDrfrir_r:r%)r�keyword�valuerrrrZs

�z"BaseHTTPRequestHandler.send_headercCs"|jdkr|j�d�|��dS)z,Send the blank line ending the MIME headers.rs
N)r$rfri�
flush_headersrBrrrrAs
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|j�d�|j��g|_dS)Nrf�)rDrGra�joinrfrBrrrrls
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|�d|jt|�t|��dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)�
isinstancerrk�log_messager)r&)rrR�sizerrrrb s
�z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS)z�Log an error.

        This is called when a request cannot be fulfilled.  By
        default it passes the message on to log_message().

        Arguments are the same as for log_message().

        XXX This should go to the separate error log.

        N)rq)r�format�argsrrrrI+sz BaseHTTPRequestHandler.log_errorcCsi|]}|d|d���qS)z\xZ02xr)�.0�crrr�
<dictcomp>;sz!BaseHTTPRequestHandler.<dictcomp>� ��z\\�\cGs2||}tj�d|��|��|�|j�f�dS)aZLog an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        Unicode control characters are replaced with escaped hex
        before writing the output to stderr.

        z%s - - [%s] %s
N)�sys�stderrra�address_string�log_date_time_string�	translate�_control_char_table)rrsrtrSrrrrq>s
��z"BaseHTTPRequestHandler.log_messagecCs|jd|jS)z*Return the server software version string.� )�server_version�sys_versionrBrrrrcXsz%BaseHTTPRequestHandler.version_stringcCs |dkrt��}tjj|dd�S)z@Return the current date and time formatted for a message header.NT)Zusegmt)�time�email�utilsZ
formatdate)rZ	timestamprrrrd\sz'BaseHTTPRequestHandler.date_time_stringc	CsBt��}t�|�\	}}}}}}}}	}
d||j|||||f}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)r��	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrrbs�z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)zReturn the client address.r)�client_addressrBrrrr~psz%BaseHTTPRequestHandler.address_string�HTTP/1.0cCsi|]}||j|jf�qSr)�phraseZdescription)ru�vrrrrws�)NN)N)N)roro)N)2rrr�__doc__r|r<r*r��__version__r��DEFAULT_ERROR_MESSAGEr\�DEFAULT_ERROR_CONTENT_TYPEr`r#r?r;rLrMr0rYr@rZrArlrbrIr&�	maketrans�	itertools�chain�ranger��ordrqrcrdrZweekdaynamer�r~r1r4r5ZHTTPMessager7r�__members__�valuesrWrrrrr�s^gj%
5


�
�	�cs�eZdZdZdeZdd��fdd�
Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ejsle��ej��Ze�ddddd���ZS)raWSimple HTTP request handler with GET and HEAD commands.

    This serves files from the current directory and any of its
    subdirectories.  The MIME type for files is determined by
    calling the .guess_type() method.

    The GET and HEAD requests are identical except that the HEAD
    request omits the actual contents of the file.

    zSimpleHTTP/N��	directorycs(|dkrt��}||_t�j||�dS�N)�os�getcwdr��super�__init__)rr�rt�kwargs��	__class__rrr��sz!SimpleHTTPRequestHandler.__init__cCs.|��}|r*z|�||j�W5|��XdS)zServe a GET request.N)�	send_headr �copyfilerG�r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|��}|r|��dS)zServe a HEAD request.N)r�r r�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADcCs^|�|j�}d}tj�|�r�tj�|j�}|j�d�s�|�t	j
�|d|d|dd|d|df}tj�|�}|�d|�|�
�dSd	D]&}tj�||�}tj�|�r�|}q�q�|�|�S|�|�}|�d�r�|�t	jd
�dSzt|d�}Wn&tk
�r|�t	jd
�YdSX�z"t�|���}d|jk�r�d
|jk�r�ztj�|jd�}	Wnttttfk
�r|YnzX|	j dk�r�|	j!t"j#j$d�}	|	j t"j#j$k�r�t"j"�%|j&t"j#j$�}
|
j!dd�}
|
|	k�r�|�t	j'�|�
�|�(�WdS|�t	j)�|�d|�|�dt*|d��|�d|�+|j&��|�
�|WS|�(��YnXdS)a{Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.

        Nrrr	r
r�ZLocation)z
index.htmlz	index.htmzFile not found�rbzIf-Modified-Sincez
If-None-Match)�tzinfo)Zmicrosecond�Content-typerV�z
Last-Modified),�translate_pathr2r��isdir�urllib�parseZurlsplit�endswithrYrZMOVED_PERMANENTLYZ
urlunsplitrZrArn�exists�list_directory�
guess_typer0�	NOT_FOUND�open�OSError�fstat�filenor8r�r�Zparsedate_to_datetime�	TypeErrorr/�
OverflowErrorr-r�rU�datetime�timezoneZutcZ
fromtimestamp�st_mtimer[r �OKr&rd)rr2r��partsZ	new_partsZnew_url�indexZctypeZfsZimsZ
last_modifrrrr��s��


���

�z"SimpleHTTPRequestHandler.send_headc
	Cs�zt�|�}Wn$tk
r2|�tjd�YdSX|jdd�d�g}ztjj	|j
dd�}Wn"tk
r�tj�	|j
�}YnXtj
|dd	�}t��}d
|}|�d�|�d�|�d
|�|�d|�|�d|�|�d�|D]v}tj
�||�}|}	}
tj
�|��r$|d}	|d}
tj
�|��r:|d}	|�dtjj|
dd�tj
|	dd	�f�q�|�d�d�|��|d�}t��}|�|�|�d�|�tj�|�dd|�|�dtt|���|��|S)z�Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        zNo permission to list directoryNcSs|��Sr�)r:)�arrr�<lambda>rmz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass��errorsFrPzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperr�ztext/html; charset=%srV) r��listdirr�r0rr��sortr�r��unquoter2�UnicodeDecodeErrorr]r^r|�getfilesystemencodingrirnr��islinkrQr_�io�BytesIOra�seekrYr�rZr&r+rA)
rr2�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr�sh�
�


�
���


z'SimpleHTTPRequestHandler.list_directorycCs�|�dd�d}|�dd�d}|���d�}ztjj|dd�}Wn tk
rbtj�|�}YnXt�|�}|�d�}t	d|�}|j
}|D]0}tj�
|�s�|tjtjfkr�q�tj�||�}q�|r�|d7}|S)	z�Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        �?r	r�#rr�r�N)r*r(r�r�r�r�r��	posixpath�normpath�filterr�r�r2�dirname�curdir�pardirrn)rr2Ztrailing_slashr=Zwordrrrr�:s$	


z'SimpleHTTPRequestHandler.translate_pathcCst�||�dS)a�Copy all data between two file objects.

        The SOURCE argument is a file object open for reading
        (or anything with a read() method) and the DESTINATION
        argument is a file object open for writing (or
        anything with a write() method).

        The only reason for overriding this would be to change
        the block size or perhaps to replace newlines by CRLF
        -- note however that this the default server uses this
        to copy binary data as well.

        N)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�Xsz!SimpleHTTPRequestHandler.copyfilecCsLt�|�\}}||jkr"|j|S|��}||jkr>|j|S|jdSdS)a�Guess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.

        rN)r��splitext�extensions_mapr:)rr2�baseZextrrrr�hs



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)r�.pyz.cz.h)rrrr�r�r�r�r�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��update�
__classcell__rrr�rr�s&	W:
�c	Cs�|�d�\}}}tj�|�}|�d�}g}|dd�D],}|dkrL|��q6|r6|dkr6|�|�q6|r�|��}|r�|dkr�|��d}q�|dkr�d}nd}|r�d�||f�}dd�|�|f}d�|�}|S)a�
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a collapsed path.

    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.

    Returns: The reconstituted URL, which will always start with a '/'.

    Raises: IndexError if too many '..' occur within the path.

    r�rNrz..rr)�	partitionr�r�r�r*�poprirn)	r2�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_path�s.


r�cCsrtrtSzddl}Wntk
r*YdSXz|�d�daWn.tk
rldtdd�|��D��aYnXtS)	z$Internal routine to get nobody's uidrNr�nobodyr
r	css|]}|dVqdS)r
Nr)rur�rrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>)r��pwd�ImportError�getpwnamrX�maxZgetpwall)r�rrr�
nobody_uid�s r�cCst�|tj�S)zTest for executable file.)r��access�X_OK)r2rrr�
executable�src@sVeZdZdZeed�ZdZdd�Zdd�Z	dd	�Z
d
dgZdd
�Zdd�Z
dd�ZdS)rz�Complete HTTP server with GET, HEAD and POST commands.

    GET and HEAD also support running CGI scripts.

    The POST command is *only* implemented for CGI scripts.

    �forkrcCs$|��r|��n|�tjd�dS)zRServe a POST request.

        This is only implemented for CGI scripts.

        zCan only POST to CGI scriptsN)�is_cgi�run_cgir0rrErBrrr�do_POST�s
�zCGIHTTPRequestHandler.do_POSTcCs|��r|��St�|�SdS)z-Version of send_head that support CGI scriptsN)rrrr�rBrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|�dd�}|d|�||dd�}}||jkrL||f|_dSdS)a3Test whether self.path corresponds to a CGI script.

        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.

        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.

        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).

        rr	NTF)r�r2�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr�s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�S)z1Test whether argument path is an executable file.)r)rr2rrr�
is_executablesz#CGIHTTPRequestHandler.is_executablecCstj�|�\}}|��dkS)z.Test whether argument path is a Python script.)r�z.pyw)r�r2r�r:)rr2r
rrrr�	is_pythonszCGIHTTPRequestHandler.is_pythonc)	Cs�|j\}}|d|}|�dt|�d�}|dkr�|d|�}||dd�}|�|�}tj�|�r�||}}|�dt|�d�}q*q�q*|�d�\}}}	|�d�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|�|�}tj�|��s
|�	t
jd|�dStj�|��s.|�	t
j
d|�dS|�|�}
|j�sF|
�sh|�|��sh|�	t
j
d	|�dSt�tj�}|��|d
<|jj|d<d|d
<|j|d<t|jj�|d<|j|d<tj�|�}||d<|�|�|d<||d<|	�r�|	|d<|jd|d<|j� d�}|�r�|�!�}t|�dk�r�ddl"}ddl#}|d|d<|d�$�dk�r�z"|d�%d�}|�&|��'d�}Wn|j(t)fk
�r�Yn&X|�!d�}t|�dk�r�|d|d<|j� d�dk�r�|j�*�|d<n|jd|d<|j� d�}|�r||d <|j� d!�}|�r||d"<g}|j�+d#�D]>}|dd�d$k�rR|�,|�-��n||d%d��!d&�}�q,d&�.|�|d'<|j� d(�}|�r�||d)<t/d|j�0d*g��}d+�.|�}|�r�||d,<d-D]}|�1|d��q�|�2t
j3d.�|�4�|	�5d/d0�}|j�r|
g}d1|k�r|�,|�t6�}|j7�8�t�9�}|dk�r�t�:|d�\}}t;�;|j<gggd�d�r~|j<�=d��sN�q~�qN|�r�|�>d2|�dSz\zt�?|�Wnt@k
�r�YnXt�A|j<�B�d�t�A|j7�B�d�t�C|||�Wn(|j�D|jE|j�t�Fd3�YnX�n�ddlG} |g}!|�|��rrtHjI}"|"�$��Jd4��rf|"dd5�|"d6d�}"|"d7g|!}!d1|	k�r�|!�,|	�|�Kd8| �L|!��ztM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d9�}$|j�$�d:k�r|#dk�r|j<�=|#�}%nd}%t;�;|j<jRgggd�d�r>|j<jR�Sd��s
�q>�q
|$�T|%�\}&}'|j7�U|&�|'�rj|�>d;|'�|$jV�W�|$jX�W�|$jY}(|(�r�|�>d2|(�n
|�Kd<�dS)=zExecute a CGI script.rr	rNr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationr
Z	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE)rZREMOTE_HOSTrrrrzScript output follows�+r��=zCGI script exit status %#xryzw.exe������z-uzcommand: %s)�stdin�stdoutr}�envZpostz%szCGI script exited OK)Zr	rr+r�r�r2r�r�r�r0rr��isfileZ	FORBIDDENr
�	have_forkrr�Zdeepcopy�environrcZserverrr1r&rr"r�r�r�r�r8r9r*�base64�binasciir:r_Zdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersri�striprnr�Zget_all�
setdefaultrYr�rlrUr�rGrHr�waitpid�selectr6�readrI�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessr|rr�rqZlist2cmdliner.r�r-�Popen�PIPEZ_sockZrecvZcommunicaterar}r r�
returncode))r�dir�restr2�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyr Zuqrestrr$r%Zlengthrr�lineZua�coZ
cookie_str�kZ
decoded_queryrtr��pid�stsr2ZcmdlineZinterp�nbytes�p�datarr}Zstatusrrrrs<





��
�


�








�

zCGIHTTPRequestHandler.run_cgiN)rrrr�rDr�r"Zrbufsizerr�rrrr
rrrrrr�s	
cGs4tj|tjtjd��}tt|��\}}}}}||fS)N)�type�flags)rZgetaddrinfoZSOCK_STREAMZ
AI_PASSIVE�next�iter)ZaddressZinfosZfamilyrA�protoZ	canonnameZsockaddrrrr�_get_best_family�s�rFr�i@c	Cs�t||�\|_}||_|||���}|j��dd�\}}d|krLd|�d�n|}td|�d|�d|�d|�d	�	�z|��Wn&tk
r�td
�t�	d�YnXW5QRXdS)zmTest the HTTP request handler class.

    This runs an HTTP server on port 8000 (or the port argument).

    Nr
r�[�]zServing HTTP on z port z	 (http://z/) ...z&
Keyboard interrupt received, exiting.r)
rFZaddress_familyr1rZgetsockname�printZ
serve_forever�KeyboardInterruptr|�exit)	�HandlerClass�ServerClassZprotocolr�bindZaddrZhttpdrZurl_hostrrr�test�s�rO�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�metavarrSz--directoryz-dz9Specify alternative directory [default:current directory])�defaultrSrZstorer�z&Specify alternate port [default: 8000])rRrUrA�nargsrSr�cseZdZ�fdd�Z�ZS)�DualStackServerc	s4t�t��|j�tjtjd�W5QRXt���S)Nr)	�
contextlib�suppress�	ExceptionrZ
setsockoptZIPPROTO_IPV6ZIPV6_V6ONLYr�r
rBr�rrr
s�zDualStackServer.server_bind)rrrr
r�rrr�rrWsrW)rLrMrrN):r�r��__all__r�r�Zemail.utilsr�r]Zhttp.clientr4r�r�r�r�r�r,r�rrr|r�Zurllib.parser�rX�	functoolsrrr�r�rrZThreadingMixInrZStreamRequestHandlerrrr�r�r�rrrFrOr�argparse�ArgumentParser�parser�add_argumentr�r.�
parse_argsrtZcgiZ
handler_classr�rWrrNrrrr�<module>s�R�s
0
�

�
�����PK0�\7�!�!protocols.cpython-38.opt-1.pycnu�[���U

e5d��@sbdZdZGdd�d�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de�Zdd
�ZdS)zAbstract Protocol base classes.)�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocol�BufferedProtocolc@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)raCommon base class for protocol interfaces.

    Usually user implements protocols that derived from BaseProtocol
    like Protocol or ProcessProtocol.

    The only case when BaseProtocol should be implemented directly is
    write-only transport like write pipe
    �cCsdS)z�Called when a connection is made.

        The argument is the transport representing the pipe connection.
        To receive data, wait for data_received() calls.
        When the connection is closed, connection_lost() is called.
        Nr)�selfZ	transportrr�)/usr/lib64/python3.8/asyncio/protocols.py�connection_madeszBaseProtocol.connection_madecCsdS)z�Called when the connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        Nr�r�excrrr�connection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark.

        Pause and resume calls are paired -- pause_writing() is called
        once when the buffer goes strictly over the high-water mark
        (even if subsequent writes increases the buffer size even
        more), and eventually resume_writing() is called once when the
        buffer size reaches the low-water mark.

        Note that if the buffer size equals the high-water mark,
        pause_writing() is not called -- it must go strictly over.
        Conversely, resume_writing() is called when the buffer size is
        equal or lower than the low-water mark.  These end conditions
        are important to ensure that things go as expected when either
        mark is zero.

        NOTE: This is the only Protocol callback that is not called
        through EventLoop.call_soon() -- if it were, it would have no
        effect when it's most needed (when the app keeps writing
        without yielding until pause_writing() is called).
        Nr�rrrr�
pause_writing%szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark.

        See pause_writing() for details.
        Nrr
rrr�resume_writing;szBaseProtocol.resume_writingN)	�__name__�
__module__�__qualname__�__doc__�	__slots__r	rrrrrrrr	s	rc@s$eZdZdZdZdd�Zdd�ZdS)ranInterface for stream protocol.

    The user should implement this interface.  They can inherit from
    this class but don't need to.  The implementations here do
    nothing (they don't raise exceptions).

    When the user wants to requests a transport, they pass a protocol
    factory to a utility function (e.g., EventLoop.create_connection()).

    When the connection is made successfully, connection_made() is
    called with a suitable transport object.  Then data_received()
    will be called 0 or more times with data (bytes) received from the
    transport; finally, connection_lost() will be called exactly once
    with either an exception object or None as an argument.

    State machine of calls:

      start -> CM [-> DR*] [-> ER?] -> CL -> end

    * CM: connection_made()
    * DR: data_received()
    * ER: eof_received()
    * CL: connection_lost()
    rcCsdS)zTCalled when some data is received.

        The argument is a bytes object.
        Nr)r�datarrr�
data_received^szProtocol.data_receivedcCsdS�z�Called when the other end calls write_eof() or equivalent.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        Nrr
rrr�eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrrrrBsrc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
ra�Interface for stream protocol with manual buffer control.

    Important: this has been added to asyncio in Python 3.7
    *on a provisional basis*!  Consider it as an experimental API that
    might be changed or removed in Python 3.8.

    Event methods, such as `create_server` and `create_connection`,
    accept factories that return protocols that implement this interface.

    The idea of BufferedProtocol is that it allows to manually allocate
    and control the receive buffer.  Event loops can then use the buffer
    provided by the protocol to avoid unnecessary data copies.  This
    can result in noticeable performance improvement for protocols that
    receive big amounts of data.  Sophisticated protocols can allocate
    the buffer only once at creation time.

    State machine of calls:

      start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end

    * CM: connection_made()
    * GB: get_buffer()
    * BU: buffer_updated()
    * ER: eof_received()
    * CL: connection_lost()
    rcCsdS)aPCalled to allocate a new receive buffer.

        *sizehint* is a recommended minimal size for the returned
        buffer.  When set to -1, the buffer size can be arbitrary.

        Must return an object that implements the
        :ref:`buffer protocol <bufferobjects>`.
        It is an error to return a zero-sized buffer.
        Nr)r�sizehintrrr�
get_buffer�szBufferedProtocol.get_buffercCsdS)z�Called when the buffer was updated with the received data.

        *nbytes* is the total number of bytes that were written to
        the buffer.
        Nr)r�nbytesrrr�buffer_updated�szBufferedProtocol.buffer_updatedcCsdSrrr
rrrr�szBufferedProtocol.eof_receivedN)rrrrrrrrrrrrrms
rc@s$eZdZdZdZdd�Zdd�ZdS)rz Interface for datagram protocol.rcCsdS)z&Called when some datagram is received.Nr)rrZaddrrrr�datagram_received�sz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError.

        (Other than BlockingIOError or InterruptedError.)
        Nrr
rrr�error_received�szDatagramProtocol.error_receivedN)rrrrrrrrrrrr�src@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
rz,Interface for protocol for subprocess calls.rcCsdS)z�Called when the subprocess writes data into stdout/stderr pipe.

        fd is int file descriptor.
        data is bytes object.
        Nr)r�fdrrrr�pipe_data_received�sz%SubprocessProtocol.pipe_data_receivedcCsdS)z�Called when a file descriptor associated with the child process is
        closed.

        fd is the int file descriptor that was closed.
        Nr)rrrrrr�pipe_connection_lost�sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nrr
rrr�process_exited�sz!SubprocessProtocol.process_exitedN)rrrrrr r!r"rrrrr�s
rcCs�t|�}|r�|�|�}t|�}|s*td��||krL||d|�<|�|�dS|d|�|d|�<|�|�||d�}t|�}qdS)Nz%get_buffer() returned an empty buffer)�lenr�RuntimeErrorr)�protorZdata_lenZbufZbuf_lenrrr�_feed_data_to_buffered_proto�s


r&N)r�__all__rrrrrr&rrrr�<module>s9+9PK0�\T=T\W�W� base_events.cpython-38.opt-2.pycnu�[���U

e5d��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZzddlZWnek
r�dZYnXddlmZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlm Z dZ!dZ"dZ#e$ed�Z%dZ&e'�Z(dd�Z)dd�Z*dd�Z+d*dd�Z,d+dd�Z-dd�Z.e$ed ��r�d!d"�Z/nd#d"�Z/Gd$d%�d%ej0�Z1Gd&d'�d'ej2�Z3Gd(d)�d)ej4�Z5dS),�N�)�	constants)�
coroutines)�events)�
exceptions)�futures)�	protocols)�sslproto)�	staggered)�tasks)�
transports)�trsock)�logger)�
BaseEventLoop�dg�?�AF_INET6i�QcCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�+/usr/lib64/python3.8/asyncio/base_events.py�_format_handleJs
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeSs


r!cCsLttd�std��n4z|�tjtjd�Wntk
rFtd��YnXdS)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr"�OSError��sockrrr�_set_reuseport\s

r+c		Cs�ttd�sdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|t�rz|dkrzd}n@t|t�r�|dkr�d}n(zt	|�}Wnt
tfk
r�YdSX|tjkr�tj
g}tr�|�tj�n|g}t|t�r�|�d�}d|k�rdS|D]t}zVt�||�t�rJ|tjk�rJ|||d||||ffWS|||d||ffWSWntk
�rzYnX�q
dS)N�	inet_ptonr��Zidna�%)r#r$�IPPROTO_TCPZIPPROTO_UDP�SOCK_STREAM�
SOCK_DGRAMr�bytesr�int�	TypeErrorr%�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder,r()	�host�port�family�type�protoZflowinfoZscopeidZafs�afrrr�_ipaddr_infogsN
�






rAcCs�t��}|D]*}|d}||kr(g||<||�|�qt|���}g}|dkr||�|dd|d��|dd|d�=|�dd�tj�tj	|��D��|S)Nrrcss|]}|dk	r|VqdS�Nr)�.0�arrr�	<genexpr>�s�z(_interleave_addrinfos.<locals>.<genexpr>)
�collections�OrderedDictr9�list�values�extend�	itertools�chain�
from_iterable�zip_longest)Z	addrinfosZfirst_address_family_countZaddrinfos_by_family�addrr=Zaddrinfos_listsZ	reorderedrrr�_interleave_addrinfos�s"
��rPcCs4|��s"|��}t|ttf�r"dSt�|���dSrB)�	cancelled�	exceptionr�
SystemExit�KeyboardInterruptrZ	_get_loop�stop)�fut�excrrr�_run_until_complete_cb�s
rX�TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|�tjtj	d�dS�Nr)
r=r$r7rr>r1r?r0r&rYr)rrr�_set_nodelay�s
�
�r[cCsdSrBrr)rrrr[�sc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�_SendfileFallbackProtocolcCsht|tj�std��||_|��|_|��|_|j	|_
|��|�|�|j
r^|jj
��|_nd|_dS)Nz.transport should be _FlowControlMixin instance)rrZ_FlowControlMixinr5�
_transportZget_protocol�_protoZ
is_reading�_should_resume_readingZ_protocol_paused�_should_resume_writing�
pause_reading�set_protocol�_loop�
create_future�_write_ready_fut)�self�transprrr�__init__�s


z"_SendfileFallbackProtocol.__init__c�s2|j��rtd��|j}|dkr$dS|IdHdS)NzConnection closed by peer)r]�
is_closing�ConnectionErrorre)rfrVrrr�drain�s
z_SendfileFallbackProtocol.draincCstd��dS)Nz?Invalid state: connection should have been established already.��RuntimeError)rf�	transportrrr�connection_made�sz)_SendfileFallbackProtocol.connection_madecCs@|jdk	r0|dkr$|j�td��n|j�|�|j�|�dS)NzConnection is closed by peer)reZ
set_exceptionrjr^�connection_lost)rfrWrrrrp�s
�z)_SendfileFallbackProtocol.connection_lostcCs |jdk	rdS|jj��|_dSrB)rer]rcrd�rfrrr�
pause_writing�s
z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|j�d�d|_dS)NF)re�
set_resultrqrrr�resume_writing�s
z(_SendfileFallbackProtocol.resume_writingcCstd��dS�Nz'Invalid state: reading should be pausedrl)rf�datarrr�
data_received�sz'_SendfileFallbackProtocol.data_receivedcCstd��dSrurlrqrrr�eof_receivedsz&_SendfileFallbackProtocol.eof_receivedc�sF|j�|j�|jr|j��|jdk	r2|j��|jrB|j��dSrB)	r]rbr^r_�resume_readingre�cancelr`rtrqrrr�restores


z!_SendfileFallbackProtocol.restoreN)�__name__�
__module__�__qualname__rhrkrorprrrtrwrxr{rrrrr\�sr\c@sxeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zdd�Z
dd�Zdd�Zdd�ZdS)�ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_	dS)NrF)
rc�_sockets�
_active_count�_waiters�_protocol_factory�_backlog�_ssl_context�_ssl_handshake_timeout�_serving�_serving_forever_fut)rf�loop�sockets�protocol_factoryZssl_context�backlog�ssl_handshake_timeoutrrrrhszServer.__init__cCsd|jj�d|j�d�S)N�<z	 sockets=�>)�	__class__r|r�rqrrr�__repr__ szServer.__repr__cCs|jd7_dSrZ)r�rqrrr�_attach#szServer._attachcCs.|jd8_|jdkr*|jdkr*|��dS)Nrr)r�r��_wakeuprqrrr�_detach'szServer._detachcCs,|j}d|_|D]}|��s|�|�qdSrB)r��doners)rf�waiters�waiterrrrr�-s
zServer._wakeupc	CsJ|jr
dSd|_|jD].}|�|j�|j�|j||j||j|j�qdS�NT)	r�r�Zlistenr�rc�_start_servingr�r�r�)rfr*rrrr�4s
�zServer._start_servingcCs|jSrB)rcrqrrr�get_loop>szServer.get_loopcCs|jSrB)r�rqrrr�
is_servingAszServer.is_servingcCs"|jdkrdStdd�|jD��S)Nrcss|]}t�|�VqdSrB)r
ZTransportSocket)rC�srrrrEHsz!Server.sockets.<locals>.<genexpr>)r��tuplerqrrrr�Ds
zServer.socketscCsn|j}|dkrdSd|_|D]}|j�|�qd|_|jdk	rX|j��sX|j��d|_|jdkrj|��dS)NFr)	r�rcZ
_stop_servingr�r�r�rzr�r�)rfr�r*rrr�closeJs
�

zServer.closec�s"|��tjd|jd�IdHdS)Nr�r�)r�r�sleeprcrqrrr�
start_serving]szServer.start_servingc	�s�|jdk	rtd|�d���|jdkr4td|�d���|��|j��|_zLz|jIdHWn6tjk
r�z|��|�	�IdHW5�XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z
 is closed)
r�rmr�r�rcrdrZCancelledErrorr��wait_closedrqrrr�
serve_forevercs 

�
zServer.serve_foreverc�s<|jdks|jdkrdS|j��}|j�|�|IdHdSrB)r�r�rcrdr9)rfr�rrrr�xs

zServer.wait_closedN)r|r}r~rhr�r�r�r�r�r�r��propertyr�r�r�r�r�rrrrrs


rc@sPeZdZdd�Zdd�Zdd�Zdd�d	d
�Zdd�Zd
d�Zd�ddd�dd�Z	d�ddddddd�dd�Z
d�dd�Zd�dd�Zd�dd�Z
d�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zejfd7d8�Zd9d:�Zd;d<�Zdd=�d>d?�Z dd=�d@dA�Z!dd=�dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dd=�dJdK�Z&dLdM�Z'dNdO�Z(dPdQ�Z)dRdRdRdRdS�dTdU�Z*d�dVdW�Z+d�ddX�dYdZ�Z,d[d\�Z-d]d^�Z.d_d`�Z/d�dadb�Z0d�ddRdRdRdddddddc�
ddde�Z1d�dfdg�Z2d�ddX�dhdi�Z3djdk�Z4dldm�Z5ddddn�dodp�Z6d�dRdRdRe7ddddq�drds�Z8dRe9j:dRdRdS�dtdu�Z;dvdw�Z<d�e9j=e9j>ddxddddddy�	dzd{�Z?ddd|�d}d~�Z@dd��ZAd�d��ZBd�d��ZCeDjEeDjEeDjEdddRdddd��	d�d��ZFeDjEeDjEeDjEdddRdddd��	d�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRdS)�rcCs�d|_d|_d|_t��|_g|_d|_d|_d|_	t
�d�j|_
d|_|�t���d|_d|_d|_d|_d|_t��|_d|_dS)NrF�	monotonicg�������?)�_timer_cancelled_count�_closed�	_stoppingrF�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�time�get_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debugrZ_is_debug_mode�slow_callback_duration�_current_handle�
_task_factory�"_coroutine_origin_tracking_enabled�&_coroutine_origin_tracking_saved_depth�weakrefZWeakSet�
_asyncgens�_asyncgens_shutdown_calledrqrrrrh�s$

zBaseEventLoop.__init__c	Cs.d|jj�d|���d|���d|���d�	S)Nr�z	 running=z closed=z debug=r�)r�r|�
is_running�	is_closed�	get_debugrqrrrr��s,�zBaseEventLoop.__repr__cCstj|d�S)Nr�)rZFuturerqrrrrd�szBaseEventLoop.create_futureN)�namecCsN|��|jdkr2tj|||d�}|jrJ|jd=n|�||�}t�||�|S)N)r�r����)�
_check_closedr�rr�_source_tracebackZ_set_task_name)rf�coror�Ztaskrrr�create_task�s

zBaseEventLoop.create_taskcCs"|dk	rt|�std��||_dS)Nz'task factory must be a callable or None)�callabler5r�)rf�factoryrrr�set_task_factory�s
zBaseEventLoop.set_task_factorycCs|jSrB)r�rqrrr�get_task_factory�szBaseEventLoop.get_task_factory)�extra�servercCst�dSrB��NotImplementedError)rfr*�protocolr�r�r�rrr�_make_socket_transport�sz$BaseEventLoop._make_socket_transportFT)�server_side�server_hostnamer�r�r��call_connection_madecCst�dSrBr�)rfZrawsockr��
sslcontextr�r�r�r�r�r�r�rrr�_make_ssl_transport�sz!BaseEventLoop._make_ssl_transportcCst�dSrBr�)rfr*r��addressr�r�rrr�_make_datagram_transport�sz&BaseEventLoop._make_datagram_transportcCst�dSrBr��rf�piper�r�r�rrr�_make_read_pipe_transport�sz'BaseEventLoop._make_read_pipe_transportcCst�dSrBr�r�rrr�_make_write_pipe_transport�sz(BaseEventLoop._make_write_pipe_transportc	
�st�dSrBr�)
rfr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transport�sz(BaseEventLoop._make_subprocess_transportcCst�dSrBr�rqrrr�_write_to_self�szBaseEventLoop._write_to_selfcCst�dSrBr�)rf�
event_listrrr�_process_events�szBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)r�rmrqrrrr��szBaseEventLoop._check_closedcCs*|j�|�|��s&|�|j|���dSrB)r��discardr��call_soon_threadsafer��aclose�rf�agenrrr�_asyncgen_finalizer_hook�sz&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|�d�t|d�|j�|�dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call��source)r��warnings�warn�ResourceWarningr��addr�rrr�_asyncgen_firstiter_hooks
�z&BaseEventLoop._asyncgen_firstiter_hookc�s�d|_t|j�sdSt|j�}|j��tjdd�|D�d|d��IdH}t||�D]*\}}t|t	�rT|�
d|��||d��qTdS)NTcSsg|]}|���qSr)r�)rCZagrrr�
<listcomp>sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsr�z;an error occurred during closing of asynchronous generator )�messagerRZasyncgen)r��lenr�rH�clearr�gather�zipr�	Exception�call_exception_handler)rfZ
closing_agensZresults�resultr�rrr�shutdown_asyncgenss"


�
�z BaseEventLoop.shutdown_asyncgenscCs(|��rtd��t��dk	r$td��dS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)r�rmrZ_get_running_looprqrrr�_check_running&s�zBaseEventLoop._check_runningc	Cs�|��|��|�|j�t��|_t��}tj	|j
|jd�z t
�|�|��|jrLq^qLW5d|_d|_t
�d�|�d�tj	|�XdS)N)�	firstiter�	finalizerF)r�r��_set_coroutine_origin_tracking�_debug�	threading�	get_identr��sys�get_asyncgen_hooks�set_asyncgen_hooksr�r�r�rZ_set_running_loop�	_run_once)rfZold_agen_hooksrrr�run_forever-s$
�


zBaseEventLoop.run_foreverc	Cs�|��|��t�|�}tj||d�}|r4d|_|�t�z<z|�
�Wn*|rp|��rp|��sp|�
��YnXW5|�	t�X|��s�td��|��S)Nr�Fz+Event loop stopped before Future completed.)r�r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrXZremove_done_callbackrr�rQrRrmr�)rfZfutureZnew_taskrrr�run_until_completeDs"
z BaseEventLoop.run_until_completecCs
d|_dSr�)r�rqrrrrUjszBaseEventLoop.stopcCsj|��rtd��|jrdS|jr,t�d|�d|_|j��|j��|j	}|dk	rfd|_	|j
dd�dS)Nz!Cannot close a running event loopzClose %rTF)�wait)r�rmr�r�r�debugr�r�r�r�Zshutdown�rf�executorrrrr�rs

zBaseEventLoop.closecCs|jSrB)r�rqrrrr��szBaseEventLoop.is_closedcCs0|��s,|d|��t|d�|��s,|��dS)Nzunclosed event loop r�)r�r�r�r�)rfZ_warnrrr�__del__�szBaseEventLoop.__del__cCs
|jdk	SrB)r�rqrrrr��szBaseEventLoop.is_runningcCst��SrB)r�r�rqrrrr��szBaseEventLoop.time)�contextcGs2|j|��||f|�d|i�}|jr.|jd=|S)Nr
r�)�call_atr�r�)rfZdelay�callbackr
r��timerrrr�
call_later�s�zBaseEventLoop.call_latercGsZ|��|jr"|��|�|d�t�|||||�}|jrB|jd=t�|j	|�d|_	|S)Nrr�T)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushr�)rf�whenrr
r�rrrrr�szBaseEventLoop.call_atcGsB|��|jr"|��|�|d�|�|||�}|jr>|jd=|S)N�	call_soonr�)r�r�rr�
_call_soonr��rfrr
r�rrrrr�s
zBaseEventLoop.call_sooncCsDt�|�st�|�r$td|�d���t|�s@td|�d|����dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZiscoroutineZiscoroutinefunctionr5r�)rfr�methodrrrr�s
�
��zBaseEventLoop._check_callbackcCs.t�||||�}|jr|jd=|j�|�|S)Nr�)rZHandler�r�r9)rfrr�r
rrrrr�s
zBaseEventLoop._call_sooncCs,|jdkrdSt��}||jkr(td��dS)NzMNon-thread-safe operation invoked on an event loop other than the current one)r�rrrm)rfZ	thread_idrrrr�s	

�zBaseEventLoop._check_threadcGsB|��|jr|�|d�|�|||�}|jr6|jd=|��|S)Nr�r�)r�r�rrr�r�rrrrr��sz"BaseEventLoop.call_soon_threadsafecGsZ|��|jr|�|d�|dkr@|j}|dkr@tj��}||_tj|j|f|��|d�S)N�run_in_executorr�)	r�r�rr��
concurrentr�ThreadPoolExecutorZwrap_futureZsubmit)rfr�funcr�rrrrs
�zBaseEventLoop.run_in_executorcCs&t|tjj�st�dtd�||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9�)rrrrr�r��DeprecationWarningr�r
rrr�set_default_executors�z"BaseEventLoop.set_default_executorcCs�|�d|��g}|r$|�d|���|r8|�d|���|rL|�d|���|r`|�d|���d�|�}t�d|�|��}t�||||||�}	|��|}
d|�d	|
d
d�d|	��}|
|jkr�t�|�n
t�|�|	S)
N�:zfamily=ztype=zproto=zflags=�, zGet address info %szGetting address info z took g@�@z.3fzms: )	r9�joinrr	r�r$�getaddrinfor��info)rfr;r<r=r>r?�flags�msg�t0�addrinfo�dtrrr�_getaddrinfo_debugs&


z BaseEventLoop._getaddrinfo_debugr�r=r>r?r'c
�s2|jr|j}ntj}|�d|||||||�IdHSrB)r�r,r$r%r)rfr;r<r=r>r?r'Zgetaddr_funcrrrr%2s�zBaseEventLoop.getaddrinfoc�s|�dtj||�IdHSrB)rr$�getnameinfo)rfZsockaddrr'rrrr.<s�zBaseEventLoop.getnameinfo)�fallbackc
�s�|jr|��dkrtd��|�||||�z|�||||�IdHWStjk
rl}z
|s\�W5d}~XYnX|�||||�IdHS)Nrzthe socket must be non-blocking)r�Z
gettimeoutr%�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)rfr*�file�offset�countr/rWrrr�
sock_sendfile@s��zBaseEventLoop.sock_sendfilec�st�d|�d���dS)Nz-syscall sendfile is not available for socket z and file {file!r} combination�rr2�rfr*r4r5r6rrrr1Ns
�z#BaseEventLoop._sock_sendfile_nativec

�s�|r|�|�|rt|tj�ntj}t|�}d}zt|rNt|||�}|dkrNq�t|�d|�}|�d|j|�IdH}	|	szq�|�	||d|	��IdH||	7}q2|W�S|dkr�t|d�r�|�||�XdS)Nr�seek)
r:�minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE�	bytearrayr#�
memoryviewr�readintoZsock_sendall)
rfr*r4r5r6�	blocksize�buf�
total_sent�view�readrrrr3Us,
��
z%BaseEventLoop._sock_sendfile_fallbackcCs�dt|dd�krtd��|jtjks,td��|dk	rbt|t�sLtd�|���|dkrbtd�|���t|t�sztd�|���|dkr�td�|���dS)N�b�modez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r}))	rr%r>r$r1rr4r5�formatr9rrrr0os2
��
����z$BaseEventLoop._check_sendfile_paramsc�s@g}|�|�|\}}}}}	d}
z�tj|||d�}
|
�d�|dk	r�|D]r\}}}}}z|
�|�Wq�WqHtk
r�}z0d|�d|j����}
t|j|
�}|�|�W5d}~XYqHXqH|���|�	|
|	�IdH|
WStk
�r}z"|�|�|
dk	�r
|
�
��W5d}~XYn |
dk	�r4|
�
��YnXdS)N�r=r>r?Fz*error while attempting to bind on address �: )r9r$�setblocking�bindr(�strerror�lower�errno�pop�sock_connectr�)rfrZ	addr_infoZlocal_addr_infosZ
my_exceptionsr=Ztype_r?�_r�r*ZladdrrWr(rrr�
_connect_sock�s:



�


zBaseEventLoop._connect_sock)
�sslr=r?r'r*�
local_addrr�r��happy_eyeballs_delay�
interleavec
	�sl|
dk	r|std��|
dkr0|r0|s,td��|}
|dk	rD|sDtd��|dk	rX|
dkrXd}
|dk	sj|dk	�r�|dk	rztd���j||f|tj||�d�IdH}|s�td��|	dk	r܈j|	|tj||�d�IdH��s�td��nd�|
r�t||
�}g�|dk�rH|D]D}z ���|��IdH}W�qvWntk
�r@Y�qYnX�qn.tj���fdd	�|D�|�d
�IdH\}}}|dk�r dd��D��t	��dk�r��d
�nJt
�d
��t�fdd	��D���r҈d
�td�d�
dd	��D�����n.|dk�rtd��|jtjk�r td|�����j||||
|d�IdH\}}�j�rd|�d�}t�d|||||�||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host�1ssl_handshake_timeout is only meaningful with sslr�8host/port and sock can not be specified at the same time�r=r>r?r'r��!getaddrinfo() returned empty listc3s |]}t��j�|��VqdSrB)�	functools�partialrQ)rCr*)r�laddr_infosrfrrrE�s��z2BaseEventLoop.create_connection.<locals>.<genexpr>r�cSsg|]}|D]}|�qqSrr)rC�subrWrrrr��sz3BaseEventLoop.create_connection.<locals>.<listcomp>rc3s|]}t|��kVqdSrB�r�rCrW)�modelrrrEszMultiple exceptions: {}r#css|]}t|�VqdSrBr^r_rrrrE
sz5host and port was not specified and no sock specified�"A Stream Socket was expected, got )r�r$z%r connected to %s:%r: (%r, %r))r%�_ensure_resolvedr$r1r(rPrQr
Zstaggered_racer�r�allrFr$r>�_create_connection_transportr��get_extra_inforr	)rfr�r;r<rRr=r?r'r*rSr�r�rTrU�infosr*rPrnr�r)rr\r`rfr�create_connection�s�����


�
��

�
���
�zBaseEventLoop.create_connectionc	�s�|�d�|�}|��}|rHt|t�r*dn|}	|j|||	||||d�}
n|�|||�}
z|IdHWn|
���YnX|
|fS)NF�r�r�r�)rIrdr�boolr�r�r�)rfr*r�rRr�r�r�r�r�r�rnrrrrd%s*
�z*BaseEventLoop._create_connection_transportc
�s�|��rtd��t|dtjj�}|tjjkr:td|����|tjjkr�z|�||||�IdHWStj	k
r�}z
|sx�W5d}~XYnX|s�td|����|�
||||�IdHS)NzTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport zHfallback is disabled and native sendfile is not supported for transport )rirmrrZ
_SendfileModeZUNSUPPORTEDZ
TRY_NATIVE�_sendfile_nativerr2�_sendfile_fallback)rfrnr4r5r6r/rErWrrr�sendfile?s4�����zBaseEventLoop.sendfilec�st�d��dS)Nz!sendfile syscall is not supportedr8)rfrgr4r5r6rrrrjns�zBaseEventLoop._sendfile_nativec
�s�|r|�|�|rt|d�nd}t|�}d}t|�}z�|rXt|||�}|dkrX|W�bSt|�d|�}	|�d|j|	�IdH}
|
s�|W�0S|�	�IdH|�
|	d|
��||
7}q6W5|dkr�t|d�r�|�||�|��IdHXdS)Ni@rr:)r:r;r<r\r#r{r=rr>rk�write)rfrgr4r5r6r?r@rAr?rBrCrrrrkrs*
z BaseEventLoop._sendfile_fallbackrhc
�s�tdkrtd��t|tj�s*td|����t|dd�sFtd|�d���|��}tj|||||||dd�}|�	�|�
|�|�|j|�}	|�|j
�}
z|IdHWn.tk
r�|��|	��|
���YnX|jS)Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz
transport z  is not supported by start_tls())r�r�)rRrmrZ
SSLContextr5rrdr	ZSSLProtocolrarbrrory�
BaseExceptionr�rzZ_app_transport)rfrnr�r�r�r�r�r�Zssl_protocolZ
conmade_cbZ	resume_cbrrr�	start_tls�sB	�
��
zBaseEventLoop.start_tls)r=r?r'�
reuse_address�
reuse_port�allow_broadcastr*c �s�|
dk	r�|
jtjkr"td|
�����s>�s>|s>|s>|s>|s>|	r~t��||||||	d�}d�dd�|��D��}td|�d���|
�d�d}
�n�s��s�|d	kr�td
��||fdff}�n�ttd��r�|tj	k�r���fD]}|dk	r�t
|t�s�td
��qڈ�rx�d	dk�rxz"t
�t�
��j��r.t���WnFtk
�rFYn2tk
�rv}zt�d�|�W5d}~XYnX||f��fff}n�i}d	�fd�ffD]�\}}|dk	�r�|j||tj|||d�IdH}|�s�td��|D]:\}}}}}||f}||k�rddg||<||||<�q�q���fdd�|��D�}|�sHtd��g}|tk	�rv|�rftd��ntjdtdd�|D]�\\}}\}}d}
d}
zxtj|tj|d�}
|�r�t|
�|	�r�|
�tjtjd�|
�d���r�|
�|���r|	�s|� |
|�IdH|}
Wn^tk
�rJ}z |
dk	�r0|
�!�|�"|�W5d}~XYn&|
dk	�rb|
�!��YnX�q|�qz|d	�|�}|�#�}|�$|
||
|�}|j%�r̈�r�t�&d��||�nt�'d�||�z|IdHWn|�!��YnX||fS)NzA UDP Socket was expected, got )rS�remote_addrr=r?r'rprqrrr#css$|]\}}|r|�d|��VqdS)�=Nr)rC�k�vrrrrE�sz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zKsocket modifier keyword arguments can not be used when sock is specified. (�)Frzunexpected address family)NN�AF_UNIXzstring is expected)r�z2Unable to check or remove stale UNIX socket %r: %rrrXrYcs8g|]0\}}�r|ddks�r,|ddks||f�qS)rNrr)rC�keyZ	addr_pair�rSrsrrr��s�z:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.r)�
stacklevelrGz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r>r$r2r%�dictr$�itemsrIr#rxrrr5�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr(r�errorrb�_unsetr�r�r r+r&r'ZSO_BROADCASTrJrOr�r9rdr�r�r&r	) rfr�rSrsr=r?r'rprqrrr*ZoptsZproblemsZr_addrZaddr_pairs_inforO�errZ
addr_infos�idxrfZfamrPZpror�rzrZ
local_addressZremote_addressrWr�r�rnrr{r�create_datagram_endpoint�s$�������
�

��
�
�

����




���z&BaseEventLoop.create_datagram_endpointc
�s\|dd�\}}t|||||f|dd���}	|	dk	r<|	gS|j||||||d�IdHSdS)Nrr-)rAr%)
rfr�r=r>r?r'r�r;r<r&rrrrbLs�zBaseEventLoop._ensure_resolvedc�s8|j||f|tj||d�IdH}|s4td|�d���|S)N)r=r>r'r�zgetaddrinfo(z) returned empty list)rbr$r1r()rfr;r<r=r'rfrrr�_create_server_getaddrinfoXs�z(BaseEventLoop._create_server_getaddrinfor)	r=r'r*r�rRrprqr�r�c	�s�t|t�rtd��|dk	r*|dkr*td��|dk	s<�dk	�r"|dk	rLtd��|	dkrhtjdkoftjdk}	g}
|dkr|dg}n$t|t�s�t|t	j
j�s�|g}n|}����fdd�|D�}tj
|d	�i�IdH}ttj�|��}d
}�z|D�]}|\}}}}}zt�|||�}Wn8tjk
�rH�j�r@tjd|||dd
�Yq�YnX|
�|�|	�rl|�tjtjd�|
�rzt|�t�r�|tjk�r�ttd��r�|�tj tj!d�z|�"|�Wq�t#k
�r�}z t#|j$d||j%�&�f�d�W5d}~XYq�Xq�d}W5|�s|
D]}|���qXn4|dk�r4td��|j'tj(k�rPtd|����|g}
|
D]}|�)d
��qZt*�|
||||�}|�r�|�+�tj,d�d�IdH�j�r�t�-d|�|S)Nz*ssl argument must be an SSLContext or NonerVrW�posix�cygwinr.csg|]}�j|���d��qS))r=r')r�)rCr;�r=r'r<rfrrr��s�
�z/BaseEventLoop.create_server.<locals>.<listcomp>r�Fz:create_server() failed to create socket.socket(%r, %r, %r)T��exc_info�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedrarr�z
%r is serving).rrir5r%r�r�r�platformrrF�abc�Iterablerr��setrKrLrMr�r$r�r�r�warningr9r&r'ZSO_REUSEADDRr+r8rr#r�ZIPV6_V6ONLYrJr(rMrKrLr>r1rIrr�r�r&)rfr�r;r<r=r'r*r�rRrprqr�r�r�ZhostsZfsrfZ	completed�resr@Zsocktyper?Z	canonnameZsar�r�rr�r�
create_server`s�
��
��
�

������
�zBaseEventLoop.create_server)rRr�c�sv|jtjkrtd|����|dk	r.|s.td��|j|||dd|d�IdH\}}|jrn|�d�}t�d|||�||fS)NrarVr.T)r�r�r$z%r handled: (%r, %r))	r>r$r1r%rdr�rerr	)rfr�r*rRr�rnr�rrr�connect_accepted_socket�s$��
z%BaseEventLoop.connect_accepted_socketc�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz Read pipe %r connected: (%r, %r))rdr�r�r�rr	�fileno�rfr�r�r�r�rnrrr�connect_read_pipe�s�zBaseEventLoop.connect_read_pipec�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz!Write pipe %r connected: (%r, %r))rdr�r�r�rr	r�r�rrr�connect_write_pipes�z BaseEventLoop.connect_write_pipecCs�|g}|dk	r"|�dt|����|dk	rJ|tjkrJ|�dt|����n8|dk	rf|�dt|����|dk	r�|�dt|����t�d�|��dS)Nzstdin=zstdout=stderr=zstdout=zstderr=� )r9r!rrrr	r$)rfr(r�r�r�r&rrr�_log_subprocessszBaseEventLoop._log_subprocess)	r�r�r��universal_newlinesr�r��encoding�errors�textc	�s�t|ttf�std��|r"td��|s.td��|dkr>td��|rJtd��|	dk	rZtd��|
dk	rjtd��|�}
d}|jr�d	|}|�||||�|j|
|d
||||f|�IdH}|jr�|dk	r�t�d||�||
fS)Nzcmd must be a string� universal_newlines must be Falsezshell must be Truer�bufsize must be 0�text must be False�encoding must be None�errors must be Nonezrun shell command %rT�%s: %r)	rr3rr%r�r�r�rr&)rfr��cmdr�r�r�r�r�r�r�r�r�r�r��	debug_logrnrrr�subprocess_shellsB��
zBaseEventLoop.subprocess_shellc	�s�|rtd��|rtd��|dkr(td��|r4td��|	dk	rDtd��|
dk	rTtd��|f|}|�}d}|jr�d|��}|�||||�|j||d	||||f|
�IdH}|jr�|dk	r�t�d
||�||fS)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r%r�r�r�rr&)rfr�Zprogramr�r�r�r�r�r�r�r�r�r�r�Z
popen_argsr�r�rnrrr�subprocess_execCs@

��
zBaseEventLoop.subprocess_execcCs|jSrB)r�rqrrr�get_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk	rt|�std|����||_dS)Nz+A callable object or None is expected, got )r�r5r�)rfZhandlerrrr�set_exception_handlerjsz#BaseEventLoop.set_exception_handlerc	Cs|�d�}|sd}|�d�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}t|�D]�}|dkr|qn||}|dkr�d�t�|��}d	}||�	�7}n2|dkr�d�t�|��}d
}||�	�7}nt
|�}|�|�d|���qntj
d�|�|d
�dS)Nr�z!Unhandled exception in event looprRFZsource_tracebackZhandle_traceback>r�rRr.z+Object created at (most recent call last):
z+Handle created at (most recent call last):
rH�
r�)�getr>�
__traceback__r�r��sortedr$�	traceback�format_list�rstriprr9rr�)	rfr
r�rRr�Z	log_linesrz�value�tbrrr�default_exception_handler{s<

���z'BaseEventLoop.default_exception_handlercCs�|jdkrVz|�|�Wq�ttfk
r2�Yq�tk
rRtjddd�Yq�Xn�z|�||�Wn�ttfk
r��Ynttk
r�}zVz|�d||d��Wn:ttfk
r��Yn"tk
r�tjddd�YnXW5d}~XYnXdS)Nz&Exception in default exception handlerTr�z$Unhandled error in exception handler)r�rRr
zeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rSrTrnrr�)rfr
rWrrrr��s4
���z$BaseEventLoop.call_exception_handlercCs|jr
dS|j�|�dSrB)�
_cancelledr�r9�rfrrrr�
_add_callback�szBaseEventLoop._add_callbackcCs|�|�|��dSrB)r�r�r�rrr�_add_callback_signalsafe�s
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dSrZ)r�r�r�rrr�_timer_handle_cancelled�sz%BaseEventLoop._timer_handle_cancelledc	Cs�t|j�}|tkr`|j|tkr`g}|jD]}|jr<d|_q*|�|�q*t�|�||_d|_n4|jr�|jdjr�|jd8_t�	|j�}d|_q`d}|j
s�|jr�d}n*|jr�|jdj}t
td||���t�}|j�|�}|�|�|��|j}|j�r:|jd}|j|k�r�q:t�	|j�}d|_|j
�|�q�t|j
�}t|�D]|}	|j
��}|j�rf�qL|j�r�zD||_|��}
|��|��|
}||jk�r�t�dt|�|�W5d|_Xn|���qLd}dS)NFrrzExecuting %s took %.3f seconds)r�r��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�r9r�heapify�heappopr�r�Z_whenr;�maxr��MAXIMUM_SELECT_TIMEOUTZ	_selectorZselectr�r��range�popleftr�r�Z_runr�rr�r)rfZsched_countZ
new_scheduledrZtimeoutrr�Zend_timeZntodo�ir)r+rrrr�sj
��





�
zBaseEventLoop._run_oncecCsHt|�t|j�krdS|r2t��|_t�tj�nt�|j�||_dSrB)rir�r�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH�rfZenabledrrrr�Fs���z,BaseEventLoop._set_coroutine_origin_trackingcCs|jSrB)r�rqrrrr�UszBaseEventLoop.get_debugcCs ||_|��r|�|j|�dSrB)r�r�r�r�r�rrrr�XszBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)N)NN)FN)rN)NN)NN)Sr|r}r~rhr�rdr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrUr�r�r�r�rr�r�rrrrrrr�rr!r,r%r.r7r1r3r0rQrgrdrlrjrkror�r�r$r1rbr�r6Z
AI_PASSIVEr�r�r�r�r�rrr�r�r�r�r�r�r�r�r�rr�r�r�rrrrr�sF���
�
�
�
�
		&	
	�

�
%���
�/�/���	��w��%�"29Nr)rr)r)6rFZcollections.abcZconcurrent.futuresrrZrrKr�r$rrrr�r�rr�r�rR�ImportErrorr.rrrrrrr	r
rrr
�logr�__all__r�r�r#r8r��objectr�rr!r+rArPrXr[ZProtocolr\ZAbstractServerrZAbstractEventLooprrrrr�<module>sb

		
;


DoPK0�\���I�Ievents.cpython-38.opt-2.pycnu�[���U

e5d4f�@sxdZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	Gdd�d�Z
Gdd	�d	e
�ZGd
d�d�ZGdd
�d
�Z
Gdd�d�ZGdd�de�Zdae��ZGdd�dej�Ze�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Z eZ!eZ"eZ#eZ$zdd*l%mZmZmZmZWne&k
�rbYnXeZ'eZ(eZ)eZ*dS)+)�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�get_running_loop�_get_running_loop�N�)�format_helpers)�
exceptionsc@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r)�	_callback�_args�
_cancelled�_loop�_source_traceback�_repr�__weakref__�_contextNcCs\|dkrt��}||_||_||_||_d|_d|_|j��rRt	�
t�d��|_
nd|_
dS)NFr)�contextvarsZcopy_contextrrrrrr�	get_debugr�
extract_stack�sys�	_getframer)�self�callback�args�loop�context�r&�&/usr/lib64/python3.8/asyncio/events.py�__init__ s
�zHandle.__init__cCsl|jjg}|jr|�d�|jdk	r:|�t�|j|j��|jrh|jd}|�d|d�d|d���|S)N�	cancelled���zcreated at r�:r)	�	__class__�__name__r�appendrr�_format_callback_sourcerr)r!�info�framer&r&r'�
_repr_info/s


�
zHandle._repr_infocCs(|jdk	r|jS|��}d�d�|��S)Nz<{}>� )rr2�format�join)r!r0r&r&r'�__repr__;s
zHandle.__repr__cCs0|js,d|_|j��r t|�|_d|_d|_dS�NT)rrr�reprrrr�r!r&r&r'�cancelAs

z
Handle.cancelcCs|jS�N)rr9r&r&r'r)LszHandle.cancelledc
Cs�z|jj|jf|j��Wn|ttfk
r4�Yndtk
r�}zFt�|j|j�}d|��}|||d�}|j	rz|j	|d<|j
�|�W5d}~XYnXd}dS)NzException in callback )�messageZ	exception�handleZsource_traceback)r�runrr�
SystemExit�KeyboardInterrupt�
BaseExceptionrr/rr�call_exception_handler)r!�exc�cb�msgr%r&r&r'�_runOs$�
�
zHandle._run)N)
r-�
__module__�__qualname__�	__slots__r(r2r6r:r)rFr&r&r&r'rs
rcs~eZdZddgZd�fdd�	Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Z�fdd�Z
dd�Z�ZS)r�
_scheduled�_whenNcs0t��||||�|jr |jd=||_d|_dS)Nr*F)�superr(rrKrJ)r!�whenr"r#r$r%�r,r&r'r(hs
zTimerHandle.__init__cs0t���}|jrdnd}|�|d|j���|S)N�rzwhen=)rLr2r�insertrK)r!r0�posrNr&r'r2ps
zTimerHandle._repr_infocCs
t|j�Sr;)�hashrKr9r&r&r'�__hash__vszTimerHandle.__hash__cCs|j|jkSr;�rK�r!�otherr&r&r'�__lt__yszTimerHandle.__lt__cCs|j|jkrdS|�|�Sr7�rK�__eq__rUr&r&r'�__le__|szTimerHandle.__le__cCs|j|jkSr;rTrUr&r&r'�__gt__�szTimerHandle.__gt__cCs|j|jkrdS|�|�Sr7rXrUr&r&r'�__ge__�szTimerHandle.__ge__cCs>t|t�r:|j|jko8|j|jko8|j|jko8|j|jkStSr;)�
isinstancerrKrrr�NotImplementedrUr&r&r'rY�s

�
�
�zTimerHandle.__eq__cCs|�|�}|tkrtS|Sr;)rYr^)r!rVZequalr&r&r'�__ne__�s
zTimerHandle.__ne__cs |js|j�|�t���dSr;)rr�_timer_handle_cancelledrLr:r9rNr&r'r:�szTimerHandle.cancelcCs|jSr;rTr9r&r&r'rM�szTimerHandle.when)N)r-rGrHrIr(r2rSrWrZr[r\rYr_r:rM�
__classcell__r&r&rNr'rcsrc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)rcCst�dSr;��NotImplementedErrorr9r&r&r'�close�szAbstractServer.closecCst�dSr;rbr9r&r&r'�get_loop�szAbstractServer.get_loopcCst�dSr;rbr9r&r&r'�
is_serving�szAbstractServer.is_servingc�st�dSr;rbr9r&r&r'�
start_serving�szAbstractServer.start_servingc�st�dSr;rbr9r&r&r'�
serve_forever�szAbstractServer.serve_foreverc�st�dSr;rbr9r&r&r'�wait_closed�szAbstractServer.wait_closedc�s|Sr;r&r9r&r&r'�
__aenter__�szAbstractServer.__aenter__c�s|��|��IdHdSr;)rdri)r!rCr&r&r'�	__aexit__�szAbstractServer.__aexit__N)r-rGrHrdrerfrgrhrirjrkr&r&r&r'r�src@sReZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�dd�Zdd �Zd!d"�Zd#d$�Zd%d%d%d%d&�d'd(�Zdtd)d*�Zdudd%d%d%ddddddd+�
d,d-�Zdvejejdd.ddddd/d0�	d1d2�Zdwd/d3�d4d5�Zd6ddd7�d8d9�Zdxddddd:�d;d<�Zdydd.ddd/d=�d>d?�Zdzd%d%d%ddddd@�dAdB�ZdCdD�Z dEdF�Z!e"j#e"j#e"j#dG�dHdI�Z$e"j#e"j#e"j#dG�dJdK�Z%dLdM�Z&dNdO�Z'dPdQ�Z(dRdS�Z)dTdU�Z*dVdW�Z+dXdY�Z,dZd[�Z-d\d]�Z.d{dd3�d^d_�Z/d`da�Z0dbdc�Z1ddde�Z2dfdg�Z3dhdi�Z4djdk�Z5dldm�Z6dndo�Z7dpdq�Z8drds�Z9dS)|rcCst�dSr;rbr9r&r&r'�run_forever�szAbstractEventLoop.run_forevercCst�dSr;rb)r!Zfuturer&r&r'�run_until_complete�sz$AbstractEventLoop.run_until_completecCst�dSr;rbr9r&r&r'�stop�szAbstractEventLoop.stopcCst�dSr;rbr9r&r&r'�
is_running�szAbstractEventLoop.is_runningcCst�dSr;rbr9r&r&r'�	is_closed�szAbstractEventLoop.is_closedcCst�dSr;rbr9r&r&r'rd�s	zAbstractEventLoop.closec�st�dSr;rbr9r&r&r'�shutdown_asyncgens�sz$AbstractEventLoop.shutdown_asyncgenscCst�dSr;rb)r!r=r&r&r'r`�sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|��S)Nr)�
call_later�r!r"r#r&r&r'�	call_soonszAbstractEventLoop.call_sooncGst�dSr;rb)r!Zdelayr"r#r&r&r'rrszAbstractEventLoop.call_latercGst�dSr;rb)r!rMr"r#r&r&r'�call_atszAbstractEventLoop.call_atcCst�dSr;rbr9r&r&r'�timeszAbstractEventLoop.timecCst�dSr;rbr9r&r&r'�
create_futureszAbstractEventLoop.create_futureN)�namecCst�dSr;rb)r!�cororxr&r&r'�create_taskszAbstractEventLoop.create_taskcGst�dSr;rbrsr&r&r'�call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGst�dSr;rb)r!�executor�funcr#r&r&r'�run_in_executorsz!AbstractEventLoop.run_in_executorcCst�dSr;rb)r!r|r&r&r'�set_default_executorsz&AbstractEventLoop.set_default_executorr)�family�type�proto�flagsc�st�dSr;rb)r!�host�portr�r�r�r�r&r&r'�getaddrinfo#szAbstractEventLoop.getaddrinfoc�st�dSr;rb)r!Zsockaddrr�r&r&r'�getnameinfo'szAbstractEventLoop.getnameinfo)
�sslr�r�r��sock�
local_addr�server_hostname�ssl_handshake_timeout�happy_eyeballs_delay�
interleavec
�st�dSr;rb)r!�protocol_factoryr�r�r�r�r�r�r�r�r�r�r�r�r&r&r'�create_connection*sz#AbstractEventLoop.create_connection�dT)	r�r�r��backlogr��
reuse_address�
reuse_portr�rgc	
�st�dSr;rb)
r!r�r�r�r�r�r�r�r�r�r�r�rgr&r&r'�
create_server3s3zAbstractEventLoop.create_server)�fallbackc�st�dSr;rb)r!�	transport�file�offset�countr�r&r&r'�sendfilehszAbstractEventLoop.sendfileF)�server_sider�r�c�st�dSr;rb)r!r�ZprotocolZ
sslcontextr�r�r�r&r&r'�	start_tlsps	zAbstractEventLoop.start_tls)r�r�r�r�c�st�dSr;rb)r!r��pathr�r�r�r�r&r&r'�create_unix_connection{sz(AbstractEventLoop.create_unix_connection)r�r�r�r�rgc�st�dSr;rb)r!r�r�r�r�r�r�rgr&r&r'�create_unix_server�sz$AbstractEventLoop.create_unix_server)r�r�r�r�r��allow_broadcastr�c�st�dSr;rb)r!r�r�Zremote_addrr�r�r�r�r�r�r�r&r&r'�create_datagram_endpoint�s!z*AbstractEventLoop.create_datagram_endpointc�st�dSr;rb�r!r��piper&r&r'�connect_read_pipe�sz#AbstractEventLoop.connect_read_pipec�st�dSr;rbr�r&r&r'�connect_write_pipe�sz$AbstractEventLoop.connect_write_pipe)�stdin�stdout�stderrc�st�dSr;rb)r!r��cmdr�r�r��kwargsr&r&r'�subprocess_shell�sz"AbstractEventLoop.subprocess_shellc�st�dSr;rb)r!r�r�r�r�r#r�r&r&r'�subprocess_exec�sz!AbstractEventLoop.subprocess_execcGst�dSr;rb�r!�fdr"r#r&r&r'�
add_reader�szAbstractEventLoop.add_readercCst�dSr;rb�r!r�r&r&r'�
remove_reader�szAbstractEventLoop.remove_readercGst�dSr;rbr�r&r&r'�
add_writer�szAbstractEventLoop.add_writercCst�dSr;rbr�r&r&r'�
remove_writer�szAbstractEventLoop.remove_writerc�st�dSr;rb)r!r��nbytesr&r&r'�	sock_recvszAbstractEventLoop.sock_recvc�st�dSr;rb)r!r�Zbufr&r&r'�sock_recv_intosz AbstractEventLoop.sock_recv_intoc�st�dSr;rb)r!r��datar&r&r'�sock_sendallszAbstractEventLoop.sock_sendallc�st�dSr;rb)r!r�Zaddressr&r&r'�sock_connectszAbstractEventLoop.sock_connectc�st�dSr;rb)r!r�r&r&r'�sock_acceptszAbstractEventLoop.sock_acceptc�st�dSr;rb)r!r�r�r�r�r�r&r&r'�
sock_sendfileszAbstractEventLoop.sock_sendfilecGst�dSr;rb)r!�sigr"r#r&r&r'�add_signal_handlersz$AbstractEventLoop.add_signal_handlercCst�dSr;rb)r!r�r&r&r'�remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCst�dSr;rb)r!�factoryr&r&r'�set_task_factorysz"AbstractEventLoop.set_task_factorycCst�dSr;rbr9r&r&r'�get_task_factory"sz"AbstractEventLoop.get_task_factorycCst�dSr;rbr9r&r&r'�get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCst�dSr;rb)r!Zhandlerr&r&r'�set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCst�dSr;rb�r!r%r&r&r'�default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCst�dSr;rbr�r&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCst�dSr;rbr9r&r&r'r5szAbstractEventLoop.get_debugcCst�dSr;rb)r!Zenabledr&r&r'�	set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN):r-rGrHrlrmrnrorprdrqr`rtrrrurvrwrzr{r~rr�r�r��socketZ	AF_UNSPECZ
AI_PASSIVEr�r�r�r�r�r�r�r��
subprocess�PIPEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rBrr�r&r&r&r'r�s��
��
��5�	�����!��%
���rc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rcCst�dSr;rbr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCst�dSr;rb�r!r$r&r&r'r	Isz&AbstractEventLoopPolicy.set_event_loopcCst�dSr;rbr9r&r&r'r
Msz&AbstractEventLoopPolicy.new_event_loopcCst�dSr;rbr9r&r&r'rUsz)AbstractEventLoopPolicy.get_child_watchercCst�dSr;rb)r!�watcherr&r&r'rYsz)AbstractEventLoopPolicy.set_child_watcherN)r-rGrHrr	r
rrr&r&r&r'r<s

rc@sBeZdZdZGdd�dej�Zdd�Zdd�Zdd	�Z	d
d�Z
dS)�BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr�_set_calledr&r&r&r'�_Localmsr�cCs|��|_dSr;)r��_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tt��tj�r2|�|���|jjdkrPt	dt��j
��|jjS)Nz,There is no current event loop in thread %r.)r�rr�r]�	threadingZcurrent_threadZ_MainThreadr	r
�RuntimeErrorrxr9r&r&r'rts���z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dSr7)r�r�rr�r&r&r'r	�sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|��Sr;)�
_loop_factoryr9r&r&r'r
�sz)BaseDefaultEventLoopPolicy.new_event_loop)r-rGrHr�r��localr�r(rr	r
r&r&r&r'r�^s
r�c@seZdZdZdS)�_RunningLoop)NNN)r-rGrH�loop_pidr&r&r&r'r��sr�cCst�}|dkrtd��|S)Nzno running event loop)rr��r$r&r&r'r�srcCs&tj\}}|dk	r"|t��kr"|SdSr;)�
_running_loopr��os�getpid)Zrunning_loop�pidr&r&r'r�s
rcCs|t��ft_dSr;)r�r�r�r�r�r&r&r'r
�sr
c	Cs.t� tdkr ddlm}|�aW5QRXdS)Nr��DefaultEventLoopPolicy)�_lock�_event_loop_policy�r�r�r&r&r'�_init_event_loop_policy�sr�cCstdkrt�tSr;)r�r�r&r&r&r'r�srcCs|adSr;)r�)Zpolicyr&r&r'r�srcCst�}|dk	r|St���Sr;)rrr)Zcurrent_loopr&r&r'r�s
rcCst��|�dSr;)rr	r�r&r&r'r	�sr	cCs
t���Sr;)rr
r&r&r&r'r
�sr
cCs
t���Sr;)rrr&r&r&r'r�srcCst��|�Sr;)rr)r�r&r&r'r�sr)rr
rr)+�__all__rr�r�r�rr�r�rrrrrrrr�r�ZLockr�r�r�r�rrr
r�rrrr	r
rrZ_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio�ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'�<module>sVJ@*q"9
	PK0�\�S�Y�s�s$selector_events.cpython-38.opt-1.pycnu�[���U

e5dT��@s.dZdZddlZddlZddlZddlZddlZddlZddlZzddl	Z	Wne
k
rddZ	YnXddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZdd�Zdd�ZGdd�dej�ZGdd�dejej�ZGdd�de�ZGdd�de�ZdS)z�Event loop using a selector and related classes.

A selector is a "notify-when-ready" multiplexer.  For a subclass which
also includes support for signal handling, see the unix_events sub-module.
)�BaseSelectorEventLoop�N�)�base_events)�	constants)�events)�futures)�	protocols)�sslproto)�
transports)�trsock)�loggercCs8z|�|�}Wntk
r$YdSXt|j|@�SdS�NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�//usr/lib64/python3.8/asyncio/selector_events.py�_test_selector_event s
rcCs tdk	rt|tj�rtd��dS)Nz"Socket cannot be of type SSLSocket)�ssl�
isinstanceZ	SSLSocket�	TypeError)�sockrrr�_check_ssl_socket+srcs�eZdZdZdS�fdd�	ZdTddd�dd�ZdUddddejd	�d
d�ZdVdd
�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdddejfdd�Zdddejfdd�Zddejfdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+�Z,S)WrzJSelector event loop.

    See events.EventLoop for API specification.
    NcsFt���|dkrt��}t�d|jj�||_|�	�t
��|_dS)NzUsing selector: %s)
�super�__init__�	selectorsZDefaultSelectorr�debug�	__class__�__name__�	_selector�_make_self_pipe�weakrefZWeakValueDictionary�_transports)�selfr�r rrr6s
zBaseSelectorEventLoop.__init__��extra�servercCst||||||�S�N)�_SelectorSocketTransport)r&r�protocol�waiterr)r*rrr�_make_socket_transport@s
�z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer)r*�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r2r()r	ZSSLProtocolr,Z_app_transport)r&Zrawsockr-�
sslcontextr.r0r1r)r*r2Zssl_protocolrrr�_make_ssl_transportEs��z)BaseSelectorEventLoop._make_ssl_transportcCst||||||�Sr+)�_SelectorDatagramTransport)r&rr-�addressr.r)rrr�_make_datagram_transportRs
�z.BaseSelectorEventLoop._make_datagram_transportcsL|��rtd��|��rdS|��t���|jdk	rH|j��d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer"�r&r'rrr;Ws


zBaseSelectorEventLoop.closecCsB|�|j���|j��d|_|j��d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor;�_csock�
_internal_fdsr<rrrr:bs

z&BaseSelectorEventLoop._close_self_pipecCsNt��\|_|_|j�d�|j�d�|jd7_|�|j��|j�dS)NFr)	�socketZ
socketpairr>r@�setblockingrA�_add_readerr?�_read_from_selfr<rrrr#js
z%BaseSelectorEventLoop._make_self_pipecCsdSr+r�r&�datarrr�_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|j�d�}|sWqT|�|�Wqtk
r:YqYqtk
rPYqTYqXqdS)Ni)r>�recvrH�InterruptedError�BlockingIOErrorrFrrrrEusz%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|�d�Wn(tk
rH|jrDtjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketT��exc_info)r@�send�OSError�_debugrr)r&Zcsockrrr�_write_to_self�s�z$BaseSelectorEventLoop._write_to_self�dc
Cs"|�|��|j||||||�dSr+)rDr?�_accept_connection)r&�protocol_factoryrr3r*�backlogr2rrr�_start_serving�s�z$BaseSelectorEventLoop._start_servingc
Cst|�D]�}z0|��\}}	|jr0t�d||	|�|�d�Wn�tttfk
rZYdSt	k
r�}
zd|
j
t
jt
jt
j
t
jfkr�|�d|
t�|�d��|�|���|�tj|j||||||�n�W5d}
~
XYqXd|	i}|�||||||�}|�|�qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exceptionrB�peername)�range�acceptrQrrrCrKrJ�ConnectionAbortedErrorrP�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr�TransportSocketr=r?Z
call_laterrZACCEPT_RETRY_DELAYrW�_accept_connection2Zcreate_task)
r&rUrr3r*rVr2�_�conn�addr�excr)r\rrrrT�sV�����z(BaseSelectorEventLoop._accept_connectionc
�s�d}d}zt|�}|��}	|r8|j||||	d|||d�}n|j|||	||d�}z|	IdHWntk
rx|���YnXWntttfk
r��Yn\tk
r�}
z>|jr�d|
d�}|dk	r�||d<|dk	r�||d<|�|�W5d}
~
XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr-�	transport)	�
create_futurer4r/�
BaseExceptionr;�
SystemExit�KeyboardInterruptrQr_)r&rUrcr)r3r*r2r-rfr.re�contextrrrra�sP���z)BaseSelectorEventLoop._accept_connection2c
Cs�|}t|t�sJzt|���}Wn*tttfk
rHtd|���d�YnXz|j|}Wntk
rlYnX|��s�t	d|�d|����dS)NzInvalid file object: zFile descriptor z is used by transport )
r�intr?�AttributeErrorr�
ValueErrorr%r�
is_closingr8)r&rr?rfrrr�_ensure_fd_no_transport�s
�z-BaseSelectorEventLoop._ensure_fd_no_transportc		Gs�|��t�|||d�}z|j�|�}Wn*tk
rR|j�|tj|df�Yn>X|j|j	}\}}|j�
||tjB||f�|dk	r�|��dSr+)�
_check_closedr�Handler"rr�registerr�
EVENT_READrG�modify�cancel�	r&r�callback�argsZhandler�mask�reader�writerrrrrDs�
�z!BaseSelectorEventLoop._add_readercCs�|��rdSz|j�|�}Wntk
r2YdSX|j|j}\}}|tjM}|sd|j�|�n|j�	||d|f�|dk	r�|�
�dSdSdS�NFT)r9r"rrrrGrrt�
unregisterrurv�r&rrrzr{r|rrrr=sz$BaseSelectorEventLoop._remove_readerc		Gs�|��t�|||d�}z|j�|�}Wn*tk
rR|j�|tjd|f�Yn>X|j|j	}\}}|j�
||tjB||f�|dk	r�|��dSr+)rqrrrr"rrrsr�EVENT_WRITErGrurvrwrrr�_add_writer%s�
�z!BaseSelectorEventLoop._add_writercCs�|��rdSz|j�|�}Wntk
r2YdSX|j|j}\}}|tjM}|sd|j�|�n|j�	|||df�|dk	r�|�
�dSdSdS)�Remove a writer callback.FNT)r9r"rrrrGrr�r~rurvrrrr�_remove_writer4sz$BaseSelectorEventLoop._remove_writercGs|�|�|j||f|��S)zAdd a reader callback.)rprD�r&rrxryrrr�
add_readerKs
z BaseSelectorEventLoop.add_readercCs|�|�|�|�S)zRemove a reader callback.)rpr=�r&rrrr�
remove_readerPs
z#BaseSelectorEventLoop.remove_readercGs|�|�|j||f|��S)zAdd a writer callback..)rpr�r�rrr�
add_writerUs
z BaseSelectorEventLoop.add_writercCs|�|�|�|�S)r�)rpr�r�rrr�
remove_writerZs
z#BaseSelectorEventLoop.remove_writerc	�s�t|�|jr"|��dkr"td��z|�|�WSttfk
rFYnX|��}|��}|�	||j
|||�|�t�
|j|��|IdHS)z�Receive data from the socket.

        The return value is a bytes object representing the data received.
        The maximum amount of data to be received at once is specified by
        nbytes.
        r�the socket must be non-blockingN)rrQ�
gettimeoutrnrIrKrJrgr?r��
_sock_recv�add_done_callback�	functools�partial�_sock_read_done)r&r�n�futrrrr�	sock_recv_s�zBaseSelectorEventLoop.sock_recvcCs|�|�dSr+)r��r&rr�rrrr�tsz%BaseSelectorEventLoop._sock_read_donec
Cs�|��rdSz|�|�}Wn\ttfk
r4YdSttfk
rL�Yn6tk
rv}z|�|�W5d}~XYnX|�|�dSr+)	�donerIrKrJrirjrh�
set_exception�
set_result)r&r�rr�rGrerrrr�wsz BaseSelectorEventLoop._sock_recvc	�s�t|�|jr"|��dkr"td��z|�|�WSttfk
rFYnX|��}|��}|�	||j
|||�|�t�
|j|��|IdHS)z�Receive data from the socket.

        The received data is written into *buf* (a writable buffer).
        The return value is the number of bytes written.
        rr�N)rrQr�rn�	recv_intorKrJrgr?r��_sock_recv_intor�r�r�r�)r&r�bufr�rrrr�sock_recv_into�s�z$BaseSelectorEventLoop.sock_recv_intoc
Cs�|��rdSz|�|�}Wn\ttfk
r4YdSttfk
rL�Yn6tk
rv}z|�|�W5d}~XYnX|�|�dSr+)	r�r�rKrJrirjrhr�r�)r&r�rr��nbytesrerrrr��sz%BaseSelectorEventLoop._sock_recv_intoc	�s�t|�|jr"|��dkr"td��z|�|�}Wnttfk
rLd}YnX|t|�kr^dS|��}|�	�}|�
t�|j
|��|�||j||t|�|g�|IdHS)a�Send data to the socket.

        The socket must be connected to a remote socket. This method continues
        to send data from data until either all data has been sent or an
        error occurs. None is returned on success. On error, an exception is
        raised, and there is no way to determine how much data, if any, was
        successfully processed by the receiving end of the connection.
        rr�N)rrQr�rnrOrKrJ�lenrgr?r�r�r��_sock_write_doner��
_sock_sendall�
memoryview)r&rrGr�r�rrrr�sock_sendall�s&	
��z"BaseSelectorEventLoop.sock_sendallc
Cs�|��rdS|d}z|�||d��}Wnbttfk
rDYdSttfk
r\�Yn2tk
r�}z|�|�WY�dSd}~XYnX||7}|t|�kr�|�	d�n||d<dS)Nr)
r�rOrKrJrirjrhr�r�r�)r&r�rZview�pos�startr�rerrrr��s 
z#BaseSelectorEventLoop._sock_sendallc�s�t|�|jr"|��dkr"td��ttd�r8|jtjkrf|j||j|j	|d�IdH}|d\}}}}}|�
�}|�|||�|IdHS)zTConnect to a remote socket at address.

        This method is a coroutine.
        rr��AF_UNIX)�family�proto�loopN)rrQr�rn�hasattrrBr�r�Z_ensure_resolvedr�rg�
_sock_connect)r&rr6Zresolvedrbr�rrr�sock_connect�s�z"BaseSelectorEventLoop.sock_connectc
Cs�|��}z|�|�Wn�ttfk
rV|�t�|j|��|�||j	|||�YnNt
tfk
rn�Yn6tk
r�}z|�
|�W5d}~XYnX|�d�dSr+)r?ZconnectrKrJr�r�r�r�r��_sock_connect_cbrirjrhr�r�)r&r�rr6rrerrrr��s�z#BaseSelectorEventLoop._sock_connectcCs|�|�dSr+)r�r�rrrr�sz&BaseSelectorEventLoop._sock_write_donec
Cs�|��rdSz,|�tjtj�}|dkr6t|d|����WnZttfk
rPYnNtt	fk
rh�Yn6t
k
r�}z|�|�W5d}~XYnX|�d�dS)NrzConnect call failed )
r�Z
getsockoptrBZ
SOL_SOCKETZSO_ERRORrPrKrJrirjrhr�r�)r&r�rr6�errrerrrr�sz&BaseSelectorEventLoop._sock_connect_cbc�sBt|�|jr"|��dkr"td��|��}|�|d|�|IdHS)aWAccept a connection.

        The socket must be bound to an address and listening for connections.
        The return value is a pair (conn, address) where conn is a new socket
        object usable to send and receive data on the connection, and address
        is the address bound to the socket on the other end of the connection.
        rr�FN)rrQr�rnrg�_sock_accept)r&rr�rrr�sock_acceptsz!BaseSelectorEventLoop.sock_acceptc
Cs�|��}|r|�|�|��r"dSz|��\}}|�d�Wnnttfk
rh|�||j|d|�YnRt	t
fk
r��Yn:tk
r�}z|�|�W5d}~XYnX|�
||f�dSr})r?r�r�r\rCrKrJr�r�rirjrhr�r�)r&r�Z
registeredrrrcr6rerrrr�*s
z"BaseSelectorEventLoop._sock_acceptc	�sp|j|j=|��}|��|��IdHz |j|j|||dd�IdHW�S|��|r^|��||j|j<XdS)NF)Zfallback)	r%�_sock_fd�
is_reading�
pause_reading�_make_empty_waiter�_reset_empty_waiter�resume_readingZ
sock_sendfile�_sock)r&Ztransp�file�offset�countr�rrr�_sendfile_native<s
�z&BaseSelectorEventLoop._sendfile_nativecCs�|D]v\}}|j|j}\}}|tj@rL|dk	rL|jrB|�|�n
|�|�|tj@r|dk	r|jrp|�|�q|�|�qdSr+)	�fileobjrGrrtZ
_cancelledr=Z
_add_callbackr�r�)r&Z
event_listrrzr�r{r|rrr�_process_eventsJs
z%BaseSelectorEventLoop._process_eventscCs|�|���|��dSr+)r=r?r;)r&rrrr�
_stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)-r!�
__module__�__qualname__�__doc__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr'rr0s~
����
�
	�
.�
)rcs�eZdZdZeZdZd�fdd�	Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
ejfdd�Zddd�Zdd�Zdd�Zdd�Zdd�Z�ZS) �_SelectorTransportiNcs�t��||�t�|�|jd<z|��|jd<Wntk
rNd|jd<YnXd|jkr�z|��|jd<Wn tj	k
r�d|jd<YnX||_
|��|_d|_
|�|�||_|��|_d|_d|_|jdk	r�|j��||j|j<dS)NrBZsocknamerZFr)rrrr`�_extraZgetsocknamerPZgetpeernamerB�errorr�r?r��_protocol_connected�set_protocol�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr%)r&r�rr-r)r*r'rrris,





z_SelectorTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���|jdk	r�|j��s�t|jj	|jt
j�}|rz|�d�n
|�d�t|jj	|jt
j�}|r�d}nd}|�
�}|�d|�d	|�d
��d�d�|��S)
N�closed�closingzfd=zread=pollingz	read=idle�pollingZidlezwrite=<z
, bufsize=�>z<{}>� )r r!r��appendr�r��_loopr9rr"rrtr��get_write_buffer_size�format�join)r&�infor��state�bufsizerrr�__repr__�s0


�
�z_SelectorTransport.__repr__cCs|�d�dSr+)�_force_closer<rrr�abort�sz_SelectorTransport.abortcCs||_d|_dS�NT)�	_protocolr��r&r-rrrr��sz_SelectorTransport.set_protocolcCs|jSr+)r�r<rrr�get_protocol�sz_SelectorTransport.get_protocolcCs|jSr+)r�r<rrrro�sz_SelectorTransport.is_closingcCsT|jr
dSd|_|j�|j�|jsP|jd7_|j�|j�|j�|jd�dS�NTr)	r�r�r=r�r�r�r��	call_soon�_call_connection_lostr<rrrr;�sz_SelectorTransport.closecCs,|jdk	r(|d|��t|d�|j��dS)Nzunclosed transport )�source)r��ResourceWarningr;)r&Z_warnrrr�__del__�s
z_SelectorTransport.__del__�Fatal error on transportcCsNt|t�r(|j��r@tjd||dd�n|j�||||jd��|�|�dS)Nz%r: %sTrM)rXrYrfr-)	rrPr��	get_debugrrr_r�r�)r&rerXrrr�_fatal_error�s

�z_SelectorTransport._fatal_errorcCsd|jr
dS|jr(|j��|j�|j�|jsBd|_|j�|j�|jd7_|j�|j	|�dSr�)
r�r��clearr�r�r�r�r=r�r��r&rerrrr��s
z_SelectorTransport._force_closecCsVz|jr|j�|�W5|j��d|_d|_d|_|j}|dk	rP|��d|_XdSr+)r�r;r�r�r�Z_detachr�Zconnection_lost)r&rer*rrrr��s
z(_SelectorTransport._call_connection_lostcCs
t|j�Sr+)r�r�r<rrrr��sz(_SelectorTransport.get_write_buffer_sizecGs"|jr
dS|jj||f|��dSr+)r�r�rDr�rrrrD�sz_SelectorTransport._add_reader)NN)r�)r!r�r��max_size�	bytearrayr�r�rr�r�r�r�ror;�warnings�warnr�r�r�r�r�rDr�rrr'rr�]s 

r�cs�eZdZdZejjZd#�fdd�	Z�fdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�fdd�Zdd �Zd!d"�Z�ZS)$r,TNcs~d|_t��|||||�d|_d|_d|_t�|j�|j	�
|jj|�|j	�
|j
|j|j�|dk	rz|j	�
tj|d�dSr
)�_read_ready_cbrr�_eof�_paused�
_empty_waiterrZ_set_nodelayr�r�r�r��connection_maderDr��_read_readyr�_set_result_unless_cancelled)r&r�rr-r.r)r*r'rrr�s 
�
�z!_SelectorSocketTransport.__init__cs.t|tj�r|j|_n|j|_t��|�dSr+)rrZBufferedProtocol�_read_ready__get_bufferr��_read_ready__data_receivedrr�r�r'rrr�	s
z%_SelectorSocketTransport.set_protocolcCs|jo|jSr+)r�r�r<rrrr�sz#_SelectorSocketTransport.is_readingcCs>|js|jrdSd|_|j�|j�|j��r:t�d|�dS)NTz%r pauses reading)r�r�r�r=r�r�rrr<rrrr�s
z&_SelectorSocketTransport.pause_readingcCs@|js|jsdSd|_|�|j|j�|j��r<t�d|�dS)NFz%r resumes reading)	r�r�rDr�r�r�r�rrr<rrrr�s
z'_SelectorSocketTransport.resume_readingcCs|��dSr+)r�r<rrrr�$sz$_SelectorSocketTransport._read_readyc
Cs`|jr
dSz |j�d�}t|�s(td��WnLttfk
rD�Yn4tk
rv}z|�|d�WY�dSd}~XYnXz|j	�
|�}Wndttfk
r�YdSttfk
r��Yn4tk
r�}z|�|d�WY�dSd}~XYnX|�s|�
�dSz|j�|�WnJttfk
�r,�Yn0tk
�rZ}z|�|d�W5d}~XYnXdS)N���z%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.�$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r�r�Z
get_bufferr�r8rirjrhr�r�r�rKrJ�_read_ready__on_eofZbuffer_updated)r&r�rer�rrrr�'sF��z0_SelectorSocketTransport._read_ready__get_bufferc
Cs�|jr
dSz|j�|j�}Wndttfk
r6YdSttfk
rN�Yn4tk
r�}z|�	|d�WY�dSd}~XYnX|s�|�
�dSz|j�|�WnFttfk
r��Yn.tk
r�}z|�	|d�W5d}~XYnXdS)Nr�z2Fatal error: protocol.data_received() call failed.)
r�r�rIr�rKrJrirjrhr�r�r�Z
data_received)r&rGrerrrr�Ls.�z3_SelectorSocketTransport._read_ready__data_receivedc
Cs�|j��rt�d|�z|j��}WnLttfk
r>�Yn4tk
rp}z|�	|d�WY�dSd}~XYnX|r�|j�
|j�n|��dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)
r�r�rrr�Zeof_receivedrirjrhr�r=r�r;)r&Z	keep_openrerrrr�es
�z,_SelectorSocketTransport._read_ready__on_eofc
Cs6t|tttf�s$tdt|�j����|jr2td��|j	dk	rDtd��|sLdS|j
rz|j
tjkrht
�d�|j
d7_
dS|j�sz|j�|�}Wnbttfk
r�Ynbttfk
r��YnJtk
r�}z|�|d�WY�dSd}~XYnX||d�}|�sdS|j�|j|j�|j�|�|��dS)N�/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progress�socket.send() raised exception.r�%Fatal write error on socket transport)r�bytesr�r�r�typer!r�r8r�r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r�rOrKrJrirjrhr�r�r�r��_write_ready�extend�_maybe_pause_protocol)r&rGr�rerrr�writezs:

z_SelectorSocketTransport.writec
Cs|jr
dSz|j�|j�}Wn�ttfk
r4Yn�ttfk
rL�Yn�tk
r�}z>|j	�
|j�|j��|�
|d�|jdk	r�|j�|�W5d}~XYnnX|r�|jd|�=|��|j�s|j	�
|j�|jdk	r�|j�d�|jr�|�d�n|j�r|j�tj�dS)Nr�)r�r�rOr�rKrJrirjrhr�r�r�r�r�r�r��_maybe_resume_protocolr�r�r�r��shutdownrB�SHUT_WR)r&r�rerrrr�s2


z%_SelectorSocketTransport._write_readycCs.|js|jrdSd|_|js*|j�tj�dSr�)r�r�r�r�rrBrr<rrr�	write_eof�s
z"_SelectorSocketTransport.write_eofcCsdSr�rr<rrr�
can_write_eof�sz&_SelectorSocketTransport.can_write_eofcs*t��|�|jdk	r&|j�td��dS)NzConnection is closed by peer)rr�r�r��ConnectionErrorr�r'rrr��s

�z._SelectorSocketTransport._call_connection_lostcCs6|jdk	rtd��|j��|_|js0|j�d�|jS)NzEmpty waiter is already set)r�r8r�rgr�r�r<rrrr��s
z+_SelectorSocketTransport._make_empty_waitercCs
d|_dSr+)r�r<rrrr��sz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!r�r�Z_start_tls_compatiblerZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerr�r�r�r�r�r�r�r�rrrr	r�r�r�r�rrr'rr,�s*�%'r,csFeZdZejZd�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r5Ncs^t��||||�||_|j�|jj|�|j�|j|j|j	�|dk	rZ|j�t
j|d�dSr+)rr�_addressr�r�r�r�rDr�r�rr�)r&r�rr-r6r.r)r'rrr�s
�
�z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss|]\}}t|�VqdSr+)r�)�.0rGrbrrr�	<genexpr>�szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�r<rrrr��sz0_SelectorDatagramTransport.get_write_buffer_sizec
Cs�|jr
dSz|j�|j�\}}Wn�ttfk
r8Yn�tk
rd}z|j�|�W5d}~XYnTt	t
fk
r|�Yn<tk
r�}z|�|d�W5d}~XYnX|j�
||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rKrJrPr��error_receivedrirjrhr�Zdatagram_received�r&rGrdrerrrr��sz&_SelectorDatagramTransport._read_readyc
Cs�t|tttf�s$tdt|�j����|s,dS|jrV|d|jfkrPtd|j����|j}|j	r�|jr�|j	t
jkrxt�
d�|j	d7_	dS|j�slz,|jdr�|j�|�n|j�||�WdSttfk
r�|j�|j|j�Yn�tk
�r}z|j�|�WY�dSd}~XYnPttfk
�r6�Yn6tk
�rj}z|�|d�WY�dSd}~XYnX|j� t|�|f�|�!�dS)Nr�z!Invalid address: must be None or r�rrZ�'Fatal write error on datagram transport)"rr�r�r�rr�r!rrnr�rr�rrr�r�r�rO�sendtorKrJr�r�r��
_sendto_readyrPr�rrirjrhr�r�rrrrrr�sH
�

�z!_SelectorDatagramTransport.sendtoc
Cs|jr�|j��\}}z*|jdr.|j�|�n|j�||�Wqttfk
rj|j�||f�Yq�Yqt	k
r�}z|j
�|�WY�dSd}~XYqtt
fk
r��Yqtk
r�}z|�|d�WY�dSd}~XYqXq|��|j�s|j�|j�|j�r|�d�dS)NrZr)r��popleftr�r�rOrrKrJ�
appendleftrPr�rrirjrhr�rr�r�r�r�r�rrrrr*s2
�z(_SelectorDatagramTransport._sendto_ready)NNN)N)r!r�r��collections�dequer�rr�r�rrr�rrr'rr5�s�

+r5)r��__all__rr^r�rrBr�r$r�ImportError�rrrrrr	r
r�logrrrZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r,r5rrrr�<module>sF
1�oPK0�\���kkstaggered.cpython-38.opt-1.pycnu�[���U

e5dh�
@s�dZdZddlZddlZddlmZddlmZddlmZddlm	Z	dd	�ej
ejgejfej
eejejejej
eejej
efd
�dd�ZdS)
zFSupport for running coroutines in parallel with staggered start times.)�staggered_race�N�)�events)�
exceptions)�locks)�tasks)�loop)�coro_fns�delayr�returnc	�s��p
t���t|��d�d�g�g�tjtjdd���������fdd�����d��}��|�z<d}|t
��kr�t���IdH\}}t
|�}ql���fW�S�D]}|�	�q�XdS)a�Run coroutines with staggered start times and take the first to finish.

    This method takes an iterable of coroutine functions. The first one is
    started immediately. From then on, whenever the immediately preceding one
    fails (raises an exception), or when *delay* seconds has passed, the next
    coroutine is started. This continues until one of the coroutines complete
    successfully, in which case all others are cancelled, or until all
    coroutines fail.

    The coroutines provided should be well-behaved in the following way:

    * They should only ``return`` if completed successfully.

    * They should always raise an exception if they did not complete
      successfully. In particular, if they handle cancellation, they should
      probably reraise, like this::

        try:
            # do work
        except asyncio.CancelledError:
            # undo partially completed work
            raise

    Args:
        coro_fns: an iterable of coroutine functions, i.e. callables that
            return a coroutine object when called. Use ``functools.partial`` or
            lambdas to pass arguments.

        delay: amount of time, in seconds, between starting coroutines. If
            ``None``, the coroutines will run sequentially.

        loop: the event loop to use.

    Returns:
        tuple *(winner_result, winner_index, exceptions)* where

        - *winner_result*: the result of the winning coroutine, or ``None``
          if no coroutines won.

        - *winner_index*: the index of the winning coroutine in
          ``coro_fns``, or ``None`` if no coroutines won. If the winning
          coroutine may return None on success, *winner_index* can be used
          to definitively determine whether any coroutine won.

        - *exceptions*: list of exceptions returned by the coroutines.
          ``len(exceptions)`` is equal to the number of coroutines actually
          started, and the order is the same as in ``coro_fns``. The winning
          coroutine's entry is ``None``.

    N)�previous_failedrc	
�s|dk	r6t�tj��t�|����IdHW5QRXzt��\}}Wntk
r\YdSXt	�
�}���|��}��|���d�z|�IdH}WnJt
tfk
r��Yn\tk
r�}z|�|<|��W5d}~XYn,X|�|�t��D]\}}||kr�|��q�dS)N)�
contextlib�suppress�exceptions_mod�TimeoutErrorrZwait_for�wait�next�
StopIterationr�Event�create_task�append�
SystemExit�KeyboardInterrupt�
BaseException�set�	enumerate�cancel)	rZ
this_indexZcoro_fnZthis_failedZ	next_task�result�e�i�t�r
Z
enum_coro_fnsrr�run_one_coroZ
running_tasksZwinner_indexZ
winner_result��)/usr/lib64/python3.8/asyncio/staggered.pyr"Rs. 

z$staggered_race.<locals>.run_one_coror)
rZget_running_loopr�typing�Optionalrrrrr�lenrr)r	r
rZ
first_taskr Z
done_countZdone�_r#r!r$rs(=
�0
r)�__doc__�__all__r
r%�rrrrr�Iterable�Callable�	Awaitabler&�floatZAbstractEventLoopZTupleZAny�intZList�	Exceptionrr#r#r#r$�<module>s&����PK0�\�o2y�/�/transports.cpython-38.pycnu�[���U

e5d�(�@s|dZdZGdd�d�ZGdd�de�ZGdd�de�ZGdd	�d	ee�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZdS)zAbstract Transport class.)�
BaseTransport�
ReadTransport�WriteTransport�	Transport�DatagramTransport�SubprocessTransportc@sHeZdZdZdZddd�Zddd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)rzBase class for transports.��_extraNcCs|dkri}||_dS�Nr)�self�extra�r�*/usr/lib64/python3.8/asyncio/transports.py�__init__szBaseTransport.__init__cCs|j�||�S)z#Get optional transport information.)r�get)r
�name�defaultrrr
�get_extra_infoszBaseTransport.get_extra_infocCst�dS)z2Return True if the transport is closing or closed.N��NotImplementedError�r
rrr
�
is_closingszBaseTransport.is_closingcCst�dS)aClose the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        Nrrrrr
�closeszBaseTransport.closecCst�dS)zSet a new protocol.Nr)r
�protocolrrr
�set_protocol%szBaseTransport.set_protocolcCst�dS)zReturn the current protocol.Nrrrrr
�get_protocol)szBaseTransport.get_protocol)N)N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrrrr
r	s


rc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
rz#Interface for read-only transports.rcCst�dS)z*Return True if the transport is receiving.Nrrrrr
�
is_reading3szReadTransport.is_readingcCst�dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        Nrrrrr
�
pause_reading7szReadTransport.pause_readingcCst�dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        Nrrrrr
�resume_reading?szReadTransport.resume_readingN)rrrrrr r!r"rrrr
r.s
rc@sNeZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)rz$Interface for write-only transports.rNcCst�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        Nr�r
�high�lowrrr
�set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCst�dS)z,Return the current size of the write buffer.Nrrrrr
�get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCst�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        Nr)r
�datarrr
�writefszWriteTransport.writecCsd�|�}|�|�dS)z�Write a list (or any iterable) of data bytes to the transport.

        The default implementation concatenates the arguments and
        calls write() on the result.
        �N)�joinr))r
Zlist_of_datar(rrr
�
writelinesns
zWriteTransport.writelinescCst�dS)z�Close the write end after flushing buffered data.

        (This is like typing ^D into a UNIX program reading from stdin.)

        Data may still be received.
        Nrrrrr
�	write_eofwszWriteTransport.write_eofcCst�dS)zAReturn True if this transport supports write_eof(), False if not.Nrrrrr
�
can_write_eof�szWriteTransport.can_write_eofcCst�dS�z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        Nrrrrr
�abort�szWriteTransport.abort)NN)rrrrrr&r'r)r,r-r.r0rrrr
rHs
		rc@seZdZdZdZdS)raSInterface representing a bidirectional transport.

    There may be several implementations, but typically, the user does
    not implement new transports; rather, the platform provides some
    useful transports that are implemented using the platform's best
    practices.

    The user never instantiates a transport directly; they call a
    utility function, passing it a protocol factory and other
    information necessary to create the transport and protocol.  (E.g.
    EventLoop.create_connection() or EventLoop.create_server().)

    The utility function will asynchronously create a transport and a
    protocol and hook them up by calling the protocol's
    connection_made() method, passing it the transport.

    The implementation here raises NotImplemented for every method
    except writelines(), which calls write() in a loop.
    rN)rrrrrrrrr
r�src@s&eZdZdZdZddd�Zdd�ZdS)	rz(Interface for datagram (UDP) transports.rNcCst�dS)aSend data to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        addr is target socket address.
        If addr is None use target address pointed on transport creation.
        Nr)r
r(Zaddrrrr
�sendto�szDatagramTransport.sendtocCst�dSr/rrrrr
r0�szDatagramTransport.abort)N)rrrrrr1r0rrrr
r�s

rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rrcCst�dS)zGet subprocess id.Nrrrrr
�get_pid�szSubprocessTransport.get_pidcCst�dS)z�Get subprocess returncode.

        See also
        http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode
        Nrrrrr
�get_returncode�sz"SubprocessTransport.get_returncodecCst�dS)z&Get transport for pipe with number fd.Nr)r
�fdrrr
�get_pipe_transport�sz&SubprocessTransport.get_pipe_transportcCst�dS)z�Send signal to subprocess.

        See also:
        docs.python.org/3/library/subprocess#subprocess.Popen.send_signal
        Nr)r
�signalrrr
�send_signal�szSubprocessTransport.send_signalcCst�dS)aLStop the subprocess.

        Alias for close() method.

        On Posix OSs the method sends SIGTERM to the subprocess.
        On Windows the Win32 API function TerminateProcess()
         is called to stop the subprocess.

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate
        Nrrrrr
�	terminate�szSubprocessTransport.terminatecCst�dS)z�Kill the subprocess.

        On Posix OSs the function sends SIGKILL to the subprocess.
        On Windows kill() is an alias for terminate().

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.kill
        Nrrrrr
�kill�s	zSubprocessTransport.killN)
rrrrr2r3r5r7r8r9rrrr
r�srcsZeZdZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zddd
�Z	ddd�Z
dd�Z�ZS)�_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class.

    The subclass must implement get_write_buffer_size().  It must call
    _maybe_pause_protocol() whenever the write buffer size increases,
    and _maybe_resume_protocol() whenever it decreases.  It may also
    override set_write_buffer_limits() (e.g. to specify different
    defaults).

    The subclass constructor must call super().__init__(extra).  This
    will call set_write_buffer_limits().

    The user may call set_write_buffer_limits() and
    get_write_buffer_size(), and their protocol's pause_writing() and
    resume_writing() may be called.
    )�_loop�_protocol_paused�_high_water�
_low_waterNcs0t��|�|dk	st�||_d|_|��dS)NF)�superr�AssertionErrorr;r<�_set_write_buffer_limits)r
rZloop��	__class__rr
rs
z_FlowControlMixin.__init__c
Cs�|��}||jkrdS|js�d|_z|j��WnRttfk
rJ�Yn:tk
r�}z|j�	d|||jd��W5d}~XYnXdS)NTzprotocol.pause_writing() failed��messageZ	exceptionZ	transportr)
r'r=r<�	_protocolZ
pause_writing�
SystemExit�KeyboardInterrupt�
BaseExceptionr;�call_exception_handler)r
�size�excrrr
�_maybe_pause_protocols 
�z'_FlowControlMixin._maybe_pause_protocolc
Cs�|jr||��|jkr|d|_z|j��WnRttfk
rB�Yn:tk
rz}z|j�	d|||jd��W5d}~XYnXdS)NFz protocol.resume_writing() failedrD)
r<r'r>rFZresume_writingrGrHrIr;rJ)r
rLrrr
�_maybe_resume_protocol!s��z(_FlowControlMixin._maybe_resume_protocolcCs|j|jfSr	)r>r=rrrr
�get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|�d|�d���||_||_dS)Ni��zhigh (z) must be >= low (z) must be >= 0)�
ValueErrorr=r>r#rrr
rA4s�z*_FlowControlMixin._set_write_buffer_limitscCs|j||d�|��dS)N)r$r%)rArMr#rrr
r&Dsz)_FlowControlMixin.set_write_buffer_limitscCst�dSr	rrrrr
r'Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN)
rrrrrrrMrNrOrAr&r'�
__classcell__rrrBr
r:�s

r:N)	r�__all__rrrrrrr:rrrr
�<module>s%F6PK0�\�H��m�mevents.cpython-38.pycnu�[���U

e5d4f�@s|dZdZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
Gdd�d�ZGd	d
�d
e�ZGdd�d�Z
Gd
d�d�ZGdd�d�ZGdd�de�Zdae��ZGdd�dej�Ze�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Z d)d*�Z!eZ"eZ#eZ$eZ%zdd+l&mZmZmZmZWne'k
�rfYnXeZ(eZ)eZ*eZ+dS),z!Event loop and event loop policy.)�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�get_running_loop�_get_running_loop�N�)�format_helpers)�
exceptionsc@sFeZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)rz1Object returned by callback registration methods.)�	_callback�_args�
_cancelled�_loop�_source_traceback�_repr�__weakref__�_contextNcCs\|dkrt��}||_||_||_||_d|_d|_|j��rRt	�
t�d��|_
nd|_
dS)NFr)�contextvarsZcopy_contextrrrrrr�	get_debugr�
extract_stack�sys�	_getframer)�self�callback�args�loop�context�r&�&/usr/lib64/python3.8/asyncio/events.py�__init__ s
�zHandle.__init__cCsl|jjg}|jr|�d�|jdk	r:|�t�|j|j��|jrh|jd}|�d|d�d|d���|S)N�	cancelled���zcreated at r�:r)	�	__class__�__name__r�appendrr�_format_callback_sourcerr)r!�info�framer&r&r'�
_repr_info/s


�
zHandle._repr_infocCs(|jdk	r|jS|��}d�d�|��S)Nz<{}>� )rr2�format�join)r!r0r&r&r'�__repr__;s
zHandle.__repr__cCs0|js,d|_|j��r t|�|_d|_d|_dS�NT)rrr�reprrrr�r!r&r&r'�cancelAs

z
Handle.cancelcCs|jS�N)rr9r&r&r'r)LszHandle.cancelledc
Cs�z|jj|jf|j��Wn|ttfk
r4�Yndtk
r�}zFt�|j|j�}d|��}|||d�}|j	rz|j	|d<|j
�|�W5d}~XYnXd}dS)NzException in callback )�messageZ	exception�handleZsource_traceback)r�runrr�
SystemExit�KeyboardInterrupt�
BaseExceptionrr/rr�call_exception_handler)r!�exc�cb�msgr%r&r&r'�_runOs$�
�
zHandle._run)N)r-�
__module__�__qualname__�__doc__�	__slots__r(r2r6r:r)rFr&r&r&r'rs
rcs�eZdZdZddgZd�fdd�	Z�fdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�fdd�Zdd�Z�ZS)rz7Object returned by timed callback registration methods.�
_scheduled�_whenNcs<|dk	st�t��||||�|jr,|jd=||_d|_dS)Nr*F)�AssertionError�superr(rrLrK)r!�whenr"r#r$r%�r,r&r'r(hszTimerHandle.__init__cs0t���}|jrdnd}|�|d|j���|S)N�rzwhen=)rNr2r�insertrL)r!r0�posrPr&r'r2ps
zTimerHandle._repr_infocCs
t|j�Sr;)�hashrLr9r&r&r'�__hash__vszTimerHandle.__hash__cCs|j|jkSr;�rL�r!�otherr&r&r'�__lt__yszTimerHandle.__lt__cCs|j|jkrdS|�|�Sr7�rL�__eq__rWr&r&r'�__le__|szTimerHandle.__le__cCs|j|jkSr;rVrWr&r&r'�__gt__�szTimerHandle.__gt__cCs|j|jkrdS|�|�Sr7rZrWr&r&r'�__ge__�szTimerHandle.__ge__cCs>t|t�r:|j|jko8|j|jko8|j|jko8|j|jkStSr;)�
isinstancerrLrrr�NotImplementedrWr&r&r'r[�s

�
�
�zTimerHandle.__eq__cCs|�|�}|tkrtS|Sr;)r[r`)r!rXZequalr&r&r'�__ne__�s
zTimerHandle.__ne__cs |js|j�|�t���dSr;)rr�_timer_handle_cancelledrNr:r9rPr&r'r:�szTimerHandle.cancelcCs|jS)z�Return a scheduled callback time.

        The time is an absolute timestamp, using the same time
        reference as loop.time().
        rVr9r&r&r'rO�szTimerHandle.when)N)r-rGrHrIrJr(r2rUrYr\r]r^r[rar:rO�
__classcell__r&r&rPr'rcsrc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)rz,Abstract server returned by create_server().cCst�dS)z5Stop serving.  This leaves existing connections open.N��NotImplementedErrorr9r&r&r'�close�szAbstractServer.closecCst�dS)z4Get the event loop the Server object is attached to.Nrdr9r&r&r'�get_loop�szAbstractServer.get_loopcCst�dS)z3Return True if the server is accepting connections.Nrdr9r&r&r'�
is_serving�szAbstractServer.is_servingc�st�dS)z�Start accepting connections.

        This method is idempotent, so it can be called when
        the server is already being serving.
        Nrdr9r&r&r'�
start_serving�szAbstractServer.start_servingc�st�dS)z�Start accepting connections until the coroutine is cancelled.

        The server is closed when the coroutine is cancelled.
        Nrdr9r&r&r'�
serve_forever�szAbstractServer.serve_foreverc�st�dS)z*Coroutine to wait until service is closed.Nrdr9r&r&r'�wait_closed�szAbstractServer.wait_closedc�s|Sr;r&r9r&r&r'�
__aenter__�szAbstractServer.__aenter__c�s|��|��IdHdSr;)rfrk)r!rCr&r&r'�	__aexit__�szAbstractServer.__aexit__N)r-rGrHrIrfrgrhrirjrkrlrmr&r&r&r'r�src@sVeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�dd�Zd d!�Zd"d#�Zd$d%�Zd&d&d&d&d'�d(d)�Zdud*d+�Zdvdd&d&d&ddddddd,�
d-d.�Zdwejejdd/ddddd0d1�	d2d3�Zdxd0d4�d5d6�Zd7ddd8�d9d:�Zdyddddd;�d<d=�Zdzdd/ddd0d>�d?d@�Zd{d&d&d&dddddA�dBdC�Z dDdE�Z!dFdG�Z"e#j$e#j$e#j$dH�dIdJ�Z%e#j$e#j$e#j$dH�dKdL�Z&dMdN�Z'dOdP�Z(dQdR�Z)dSdT�Z*dUdV�Z+dWdX�Z,dYdZ�Z-d[d\�Z.d]d^�Z/d|dd4�d_d`�Z0dadb�Z1dcdd�Z2dedf�Z3dgdh�Z4didj�Z5dkdl�Z6dmdn�Z7dodp�Z8dqdr�Z9dsdt�Z:dS)}rzAbstract event loop.cCst�dS)z*Run the event loop until stop() is called.Nrdr9r&r&r'�run_forever�szAbstractEventLoop.run_forevercCst�dS)zpRun the event loop until a Future is done.

        Return the Future's result, or raise its exception.
        Nrd)r!Zfuturer&r&r'�run_until_complete�sz$AbstractEventLoop.run_until_completecCst�dS)z�Stop the event loop as soon as reasonable.

        Exactly how soon that is may depend on the implementation, but
        no more I/O callbacks should be scheduled.
        Nrdr9r&r&r'�stop�szAbstractEventLoop.stopcCst�dS)z3Return whether the event loop is currently running.Nrdr9r&r&r'�
is_running�szAbstractEventLoop.is_runningcCst�dS)z*Returns True if the event loop was closed.Nrdr9r&r&r'�	is_closed�szAbstractEventLoop.is_closedcCst�dS)z�Close the loop.

        The loop should not be running.

        This is idempotent and irreversible.

        No other methods should be called after this one.
        Nrdr9r&r&r'rf�s	zAbstractEventLoop.closec�st�dS)z,Shutdown all active asynchronous generators.Nrdr9r&r&r'�shutdown_asyncgens�sz$AbstractEventLoop.shutdown_asyncgenscCst�dS)z3Notification that a TimerHandle has been cancelled.Nrd)r!r=r&r&r'rb�sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|��S)Nr)�
call_later�r!r"r#r&r&r'�	call_soonszAbstractEventLoop.call_sooncGst�dSr;rd)r!Zdelayr"r#r&r&r'rtszAbstractEventLoop.call_latercGst�dSr;rd)r!rOr"r#r&r&r'�call_atszAbstractEventLoop.call_atcCst�dSr;rdr9r&r&r'�timeszAbstractEventLoop.timecCst�dSr;rdr9r&r&r'�
create_futureszAbstractEventLoop.create_futureN)�namecCst�dSr;rd)r!�cororzr&r&r'�create_taskszAbstractEventLoop.create_taskcGst�dSr;rdrur&r&r'�call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGst�dSr;rd)r!�executor�funcr#r&r&r'�run_in_executorsz!AbstractEventLoop.run_in_executorcCst�dSr;rd)r!r~r&r&r'�set_default_executorsz&AbstractEventLoop.set_default_executorr)�family�type�proto�flagsc�st�dSr;rd)r!�host�portr�r�r�r�r&r&r'�getaddrinfo#szAbstractEventLoop.getaddrinfoc�st�dSr;rd)r!Zsockaddrr�r&r&r'�getnameinfo'szAbstractEventLoop.getnameinfo)
�sslr�r�r��sock�
local_addr�server_hostname�ssl_handshake_timeout�happy_eyeballs_delay�
interleavec
�st�dSr;rd)r!�protocol_factoryr�r�r�r�r�r�r�r�r�r�r�r�r&r&r'�create_connection*sz#AbstractEventLoop.create_connection�dT)	r�r�r��backlogr��
reuse_address�
reuse_portr�ric	
�st�dS)adA coroutine which creates a TCP server bound to host and port.

        The return value is a Server object which can be used to stop
        the service.

        If host is an empty string or None all interfaces are assumed
        and a list of multiple sockets will be returned (most likely
        one for IPv4 and another one for IPv6). The host parameter can also be
        a sequence (e.g. list) of hosts to bind to.

        family can be set to either AF_INET or AF_INET6 to force the
        socket to use IPv4 or IPv6. If not set it will be determined
        from host (defaults to AF_UNSPEC).

        flags is a bitmask for getaddrinfo().

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows.

        ssl_handshake_timeout is the time in seconds that an SSL server
        will wait for completion of the SSL handshake before aborting the
        connection. Default is 60s.

        start_serving set to True (default) causes the created server
        to start accepting connections immediately.  When set to False,
        the user should await Server.start_serving() or Server.serve_forever()
        to make the server to start accepting connections.
        Nrd)
r!r�r�r�r�r�r�r�r�r�r�r�rir&r&r'�
create_server3s3zAbstractEventLoop.create_server)�fallbackc�st�dS)zRSend a file through a transport.

        Return an amount of sent bytes.
        Nrd)r!�	transport�file�offset�countr�r&r&r'�sendfilehszAbstractEventLoop.sendfileF)�server_sider�r�c�st�dS)z|Upgrade a transport to TLS.

        Return a new transport that *protocol* should start using
        immediately.
        Nrd)r!r�ZprotocolZ
sslcontextr�r�r�r&r&r'�	start_tlsps	zAbstractEventLoop.start_tls)r�r�r�r�c�st�dSr;rd)r!r��pathr�r�r�r�r&r&r'�create_unix_connection{sz(AbstractEventLoop.create_unix_connection)r�r�r�r�ric�st�dS)a�A coroutine which creates a UNIX Domain Socket server.

        The return value is a Server object, which can be used to stop
        the service.

        path is a str, representing a file systsem path to bind the
        server socket to.

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.

        ssl_handshake_timeout is the time in seconds that an SSL server
        will wait for the SSL handshake to complete (defaults to 60s).

        start_serving set to True (default) causes the created server
        to start accepting connections immediately.  When set to False,
        the user should await Server.start_serving() or Server.serve_forever()
        to make the server to start accepting connections.
        Nrd)r!r�r�r�r�r�r�rir&r&r'�create_unix_server�sz$AbstractEventLoop.create_unix_server)r�r�r�r�r��allow_broadcastr�c�st�dS)a�A coroutine which creates a datagram endpoint.

        This method will try to establish the endpoint in the background.
        When successful, the coroutine returns a (transport, protocol) pair.

        protocol_factory must be a callable returning a protocol instance.

        socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on
        host (or family if specified), socket type SOCK_DGRAM.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified it will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows and some UNIX's. If the
        :py:data:`~socket.SO_REUSEPORT` constant is not defined then this
        capability is unsupported.

        allow_broadcast tells the kernel to allow this endpoint to send
        messages to the broadcast address.

        sock can optionally be specified in order to use a preexisting
        socket object.
        Nrd)r!r�r�Zremote_addrr�r�r�r�r�r�r�r&r&r'�create_datagram_endpoint�s!z*AbstractEventLoop.create_datagram_endpointc�st�dS)aRegister read pipe in event loop. Set the pipe to non-blocking mode.

        protocol_factory should instantiate object with Protocol interface.
        pipe is a file-like object.
        Return pair (transport, protocol), where transport supports the
        ReadTransport interface.Nrd�r!r��piper&r&r'�connect_read_pipe�sz#AbstractEventLoop.connect_read_pipec�st�dS)aRegister write pipe in event loop.

        protocol_factory should instantiate object with BaseProtocol interface.
        Pipe is file-like object already switched to nonblocking.
        Return pair (transport, protocol), where transport support
        WriteTransport interface.Nrdr�r&r&r'�connect_write_pipe�sz$AbstractEventLoop.connect_write_pipe)�stdin�stdout�stderrc�st�dSr;rd)r!r��cmdr�r�r��kwargsr&r&r'�subprocess_shell�sz"AbstractEventLoop.subprocess_shellc�st�dSr;rd)r!r�r�r�r�r#r�r&r&r'�subprocess_exec�sz!AbstractEventLoop.subprocess_execcGst�dSr;rd�r!�fdr"r#r&r&r'�
add_reader�szAbstractEventLoop.add_readercCst�dSr;rd�r!r�r&r&r'�
remove_reader�szAbstractEventLoop.remove_readercGst�dSr;rdr�r&r&r'�
add_writer�szAbstractEventLoop.add_writercCst�dSr;rdr�r&r&r'�
remove_writer�szAbstractEventLoop.remove_writerc�st�dSr;rd)r!r��nbytesr&r&r'�	sock_recvszAbstractEventLoop.sock_recvc�st�dSr;rd)r!r�Zbufr&r&r'�sock_recv_intosz AbstractEventLoop.sock_recv_intoc�st�dSr;rd)r!r��datar&r&r'�sock_sendallszAbstractEventLoop.sock_sendallc�st�dSr;rd)r!r�Zaddressr&r&r'�sock_connectszAbstractEventLoop.sock_connectc�st�dSr;rd)r!r�r&r&r'�sock_acceptszAbstractEventLoop.sock_acceptc�st�dSr;rd)r!r�r�r�r�r�r&r&r'�
sock_sendfileszAbstractEventLoop.sock_sendfilecGst�dSr;rd)r!�sigr"r#r&r&r'�add_signal_handlersz$AbstractEventLoop.add_signal_handlercCst�dSr;rd)r!r�r&r&r'�remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCst�dSr;rd)r!�factoryr&r&r'�set_task_factorysz"AbstractEventLoop.set_task_factorycCst�dSr;rdr9r&r&r'�get_task_factory"sz"AbstractEventLoop.get_task_factorycCst�dSr;rdr9r&r&r'�get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCst�dSr;rd)r!Zhandlerr&r&r'�set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCst�dSr;rd�r!r%r&r&r'�default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCst�dSr;rdr�r&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCst�dSr;rdr9r&r&r'r5szAbstractEventLoop.get_debugcCst�dSr;rd)r!Zenabledr&r&r'�	set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN);r-rGrHrIrnrorprqrrrfrsrbrvrtrwrxryr|r}r�r�r�r�r��socketZ	AF_UNSPECZ
AI_PASSIVEr�r�r�r�r�r�r�r��
subprocess�PIPEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rBrr�r&r&r&r'r�s��
��
��5�	�����!��%
���rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rz-Abstract policy for accessing the event loop.cCst�dS)a:Get the event loop for the current context.

        Returns an event loop object implementing the BaseEventLoop interface,
        or raises an exception in case no event loop has been set for the
        current context and the current policy does not specify to create one.

        It should never return None.Nrdr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCst�dS)z3Set the event loop for the current context to loop.Nrd�r!r$r&r&r'r	Isz&AbstractEventLoopPolicy.set_event_loopcCst�dS)z�Create and return a new event loop object according to this
        policy's rules. If there's need to set this loop as the event loop for
        the current context, set_event_loop must be called explicitly.Nrdr9r&r&r'r
Msz&AbstractEventLoopPolicy.new_event_loopcCst�dS)z$Get the watcher for child processes.Nrdr9r&r&r'rUsz)AbstractEventLoopPolicy.get_child_watchercCst�dS)z$Set the watcher for child processes.Nrd)r!�watcherr&r&r'rYsz)AbstractEventLoopPolicy.set_child_watcherN)	r-rGrHrIrr	r
rrr&r&r&r'r<s
rc@sFeZdZdZdZGdd�dej�Zdd�Zdd�Z	d	d
�Z
dd�ZdS)
�BaseDefaultEventLoopPolicya�Default policy implementation for accessing the event loop.

    In this policy, each thread has its own event loop.  However, we
    only automatically create an event loop by default for the main
    thread; other threads by default have no event loop.

    Other policies may have different rules (e.g. a single global
    event loop, or automatically creating an event loop per thread, or
    using some other notion of context to which an event loop is
    associated).
    Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr�_set_calledr&r&r&r'�_Localmsr�cCs|��|_dSr;)r��_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tt��tj�r2|�|���|jjdkrPt	dt��j
��|jjS)zvGet the event loop for the current context.

        Returns an instance of EventLoop or raises an exception.
        Nz,There is no current event loop in thread %r.)r�rr�r_�	threadingZcurrent_threadZ_MainThreadr	r
�RuntimeErrorrzr9r&r&r'rts���z)BaseDefaultEventLoopPolicy.get_event_loopcCs*d|j_|dkst|t�st�||j_dS)zSet the event loop.TN)r�r�r_rrMrr�r&r&r'r	�sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|��S)zvCreate a new event loop.

        You must call set_event_loop() to make this the current event
        loop.
        )�
_loop_factoryr9r&r&r'r
�sz)BaseDefaultEventLoopPolicy.new_event_loop)r-rGrHrIr�r��localr�r(rr	r
r&r&r&r'r�^sr�c@seZdZdZdS)�_RunningLoop)NNN)r-rGrH�loop_pidr&r&r&r'r��sr�cCst�}|dkrtd��|S)zrReturn the running event loop.  Raise a RuntimeError if there is none.

    This function is thread-specific.
    Nzno running event loop)rr��r$r&r&r'r�srcCs&tj\}}|dk	r"|t��kr"|SdS)z�Return the running event loop or None.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)�
_running_loopr��os�getpid)Zrunning_loop�pidr&r&r'r�s
rcCs|t��ft_dS)z�Set the running event loop.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)r�r�r�r�r�r&r&r'r
�sr
c	Cs.t� tdkr ddlm}|�aW5QRXdS)Nr��DefaultEventLoopPolicy)�_lock�_event_loop_policy�r�r�r&r&r'�_init_event_loop_policy�sr�cCstdkrt�tS)z"Get the current event loop policy.N)r�r�r&r&r&r'r�srcCs|dkst|t�st�|adS)zZSet the current event loop policy.

    If policy is None, the default policy is restored.N)r_rrMr�)Zpolicyr&r&r'r�srcCst�}|dk	r|St���S)aGReturn an asyncio event loop.

    When called from a coroutine or a callback (e.g. scheduled with call_soon
    or similar API), this function will always return the running event loop.

    If there is no running event loop set, the function will return
    the result of `get_event_loop_policy().get_event_loop()` call.
    N)rrr)Zcurrent_loopr&r&r'r�s
rcCst��|�dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr	r�r&r&r'r	�sr	cCs
t���S)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr
r&r&r&r'r
�sr
cCs
t���S)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rrr&r&r&r'r�srcCst��|�S)zMEquivalent to calling
    get_event_loop_policy().set_child_watcher(watcher).)rr)r�r&r&r'r�sr)rr
rr),rI�__all__rr�r�r�rr�r�rrrrrrrr�r�ZLockr�r�r�r�rrr
r�rrrr	r
rrZ_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio�ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'�<module>sXJ@*q"9
	PK0�\�x��**#format_helpers.cpython-38.opt-2.pycnu�[���U

e5dd	�@sdddlZddlZddlZddlZddlZddlmZdd�Zdd�Zdd	�Z	ddd�Z
dd
d�ZdS)�N�)�	constantscCsVt�|�}t�|�r&|j}|j|jfSt|tj�r<t	|j
�St|tj�rRt	|j
�SdS�N)�inspectZunwrapZ
isfunction�__code__�co_filename�co_firstlineno�
isinstance�	functools�partial�_get_function_source�func�
partialmethod)r
�code�r�./usr/lib64/python3.8/asyncio/format_helpers.pyr
s



rcCs8t||d�}t|�}|r4|d|d�d|d��7}|S)Nz at r�:r)�_format_callbackr)r
�args�	func_repr�sourcerrr�_format_callback_sources
rcCsHg}|r|�dd�|D��|r8|�dd�|��D��d�d�|��S)Ncss|]}t�|�VqdSr��reprlib�repr)�.0�argrrr�	<genexpr>&sz*_format_args_and_kwargs.<locals>.<genexpr>css&|]\}}|�dt�|���VqdS)�=Nr)r�k�vrrrr(sz({})z, )�extend�items�format�join)r�kwargsr"rrr�_format_args_and_kwargssr&�cCs�t|tj�r.t||�|}t|j|j|j|�St|d�rF|j	rF|j	}n t|d�r^|j
r^|j
}nt|�}|t||�7}|r�||7}|S)N�__qualname__�__name__)r	r
rr&rr
r�keywords�hasattrr(r)r)r
rr%�suffixrrrrr,srcCsD|dkrt��j}|dkr tj}tjjt�|�|dd�}|�	�|S)NF)�limit�lookup_lines)
�sys�	_getframe�f_backrZDEBUG_STACK_DEPTH�	traceback�StackSummary�extract�
walk_stack�reverse)�fr-�stackrrr�
extract_stack>s
�r9)r')NN)r
rrr/r2r'rrrr&rr9rrrr�<module>s
PK0�\�Ŀ � queues.cpython-38.pycnu�[���U

e5d �@s�dZddlZddlZddlZddlmZddlmZGdd�de�ZGdd	�d	e�Z	Gd
d�d�Z
Gdd
�d
e
�ZGdd�de
�ZdS))�Queue�
PriorityQueue�	LifoQueue�	QueueFull�
QueueEmpty�N�)�events)�locksc@seZdZdZdS)rz;Raised when Queue.get_nowait() is called on an empty Queue.N��__name__�
__module__�__qualname__�__doc__�rr�&/usr/lib64/python3.8/asyncio/queues.pyrsrc@seZdZdZdS)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr
rrrrrsrc@s�eZdZdZd)dd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�ZdS)*raA queue, useful for coordinating producer and consumer coroutines.

    If maxsize is less than or equal to zero, the queue size is infinite. If it
    is an integer greater than 0, then "await put()" will block when the
    queue reaches maxsize, until an item is removed by get().

    Unlike the standard library Queue, you can reliably know this Queue's size
    with qsize(), since your single-threaded asyncio application won't be
    interrupted between calling qsize() and doing an operation on the Queue.
    rN��loopcCsp|dkrt��|_n||_tjdtdd�||_t��|_	t��|_
d|_tj
|d�|_|j��|�|�dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.�)�
stacklevelrr)rZget_event_loop�_loop�warnings�warn�DeprecationWarning�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr	ZEvent�	_finished�set�_init)�self�maxsizerrrr�__init__!s�


zQueue.__init__cCst��|_dS�N)rr�_queue�r"r#rrrr!6szQueue._initcCs
|j��Sr%)r&�popleft�r"rrr�_get9sz
Queue._getcCs|j�|�dSr%�r&�append�r"�itemrrr�_put<sz
Queue._putcCs&|r"|��}|��s|�d�q"qdSr%)r(ZdoneZ
set_result)r"�waitersZwaiterrrr�_wakeup_nextAs

zQueue._wakeup_nextcCs(dt|�j�dt|�d�d|���d�S)N�<z at z#x� �>)�typer�id�_formatr)rrr�__repr__IszQueue.__repr__cCsdt|�j�d|���d�S)Nr2r3r4)r5rr7r)rrr�__str__Lsz
Queue.__str__cCs~d|j��}t|dd�r,|dt|j���7}|jrH|dt|j��d�7}|jrd|dt|j��d�7}|jrz|d|j��7}|S)Nzmaxsize=r&z _queue=z
 _getters[�]z
 _putters[z tasks=)r�getattr�listr&r�lenrr)r"�resultrrrr7Osz
Queue._formatcCs
t|j�S)zNumber of items in the queue.)r=r&r)rrr�qsize[szQueue.qsizecCs|jS)z%Number of items allowed in the queue.)rr)rrrr#_sz
Queue.maxsizecCs|jS)z3Return True if the queue is empty, False otherwise.�r&r)rrr�emptydszQueue.emptycCs |jdkrdS|��|jkSdS)z�Return True if there are maxsize items in the queue.

        Note: if the Queue was initialized with maxsize=0 (the default),
        then full() is never True.
        rFN)rr?r)rrr�fullhs
z
Queue.fullc�s�|��r�|j��}|j�|�z|IdHWq|��z|j�|�Wntk
r`YnX|��s~|��s~|�	|j��YqXq|�
|�S)z�Put an item into the queue.

        Put an item into the queue. If the queue is full, wait until a free
        slot is available before adding item.
        N)rBr�
create_futurerr,�cancel�remove�
ValueError�	cancelledr1�
put_nowait)r"r.Zputterrrr�putss

z	Queue.putcCs>|��rt�|�|�|jd7_|j��|�|j�dS)zyPut an item into the queue without blocking.

        If no free slot is immediately available, raise QueueFull.
        rN)rBrr/rr�clearr1rr-rrrrH�s

zQueue.put_nowaitc�s�|��r�|j��}|j�|�z|IdHWq|��z|j�|�Wntk
r`YnX|��s~|��s~|�	|j��YqXq|�
�S)zoRemove and return an item from the queue.

        If queue is empty, wait until an item is available.
        N)rArrCrr,rDrErFrGr1�
get_nowait)r"�getterrrr�get�s

z	Queue.getcCs$|��rt�|��}|�|j�|S)z�Remove and return an item from the queue.

        Return an item if one is immediately available, else raise QueueEmpty.
        )rArr*r1rr-rrrrK�s
zQueue.get_nowaitcCs8|jdkrtd��|jd8_|jdkr4|j��dS)a$Indicate that a formerly enqueued task is complete.

        Used by queue consumers. For each get() used to fetch a task,
        a subsequent call to task_done() tells the queue that the processing
        on the task is complete.

        If a join() is currently blocking, it will resume when all items have
        been processed (meaning that a task_done() call was received for every
        item that had been put() into the queue).

        Raises ValueError if called more times than there were items placed in
        the queue.
        rz!task_done() called too many timesrN)rrFrr r)rrr�	task_done�s


zQueue.task_donec�s|jdkr|j��IdHdS)aBlock until all items in the queue have been gotten and processed.

        The count of unfinished tasks goes up whenever an item is added to the
        queue. The count goes down whenever a consumer calls task_done() to
        indicate that the item was retrieved and all work on it is complete.
        When the count of unfinished tasks drops to zero, join() unblocks.
        rN)rr�waitr)rrr�join�s
z
Queue.join)r)rrr
rr$r!r*r/r1r8r9r7r?�propertyr#rArBrIrHrMrKrNrPrrrrrs(
rc@s4eZdZdZdd�Zejfdd�Zejfdd�Z	dS)	rz�A subclass of Queue; retrieves entries in priority order (lowest first).

    Entries are typically tuples of the form: (priority number, data).
    cCs
g|_dSr%r@r'rrrr!�szPriorityQueue._initcCs||j|�dSr%r@)r"r.�heappushrrrr/�szPriorityQueue._putcCs
||j�Sr%r@)r"�heappoprrrr*�szPriorityQueue._getN)
rrr
rr!�heapqrRr/rSr*rrrrr�src@s(eZdZdZdd�Zdd�Zdd�ZdS)	rzEA subclass of Queue that retrieves most recently added entries first.cCs
g|_dSr%r@r'rrrr!�szLifoQueue._initcCs|j�|�dSr%r+r-rrrr/�szLifoQueue._putcCs
|j��Sr%)r&�popr)rrrr*�szLifoQueue._getN)rrr
rr!r/r*rrrrr�sr)
�__all__rrTr�rr	�	Exceptionrrrrrrrrr�<module>sKPK0�\j�xxconstants.cpython-38.opt-1.pycnu�[���U

e5d��@s8dZZZdZZZdZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6d3Z7d4Z8d5Z9d6Z:d7Z;d8Z<d9Z=d:Z>d;Z?d<Z@d=ZAd>ZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIdFZJdGZKdHZLdIS)J���n�s�w�eZnw�sw�neZse�nsZewZnsew�centerZnone�x�yZboth�left�top�rightZbottomZraisedZsunkenZflatZridgeZgrooveZsolidZ
horizontalZvertical�numeric�charZwordZbaselineZinsideZoutsideZselz	sel.firstzsel.last�end�insertZcurrentZanchor�allZnormalZdisabledZactiveZhiddenZcascadeZcheckbuttonZcommandZradiobuttonZ	separatorZsingleZbrowseZmultipleZextendedZdotboxZ	underlineZpiesliceZchordZarc�firstZlastZbuttZ
projecting�roundZbevelZmiterZmovetoZscrollZunitsZpagesN)MZNOZFALSEZOFFZYESZTRUEZON�N�S�W�EZNWZSWZNEZSEZNSZEWZNSEWZCENTERZNONE�X�YZBOTHZLEFTZTOPZRIGHTZBOTTOMZRAISEDZSUNKENZFLATZRIDGEZGROOVEZSOLIDZ
HORIZONTALZVERTICALZNUMERICZCHARZWORDZBASELINEZINSIDEZOUTSIDEZSELZ	SEL_FIRSTZSEL_LASTZENDZINSERTZCURRENTZANCHORZALLZNORMALZDISABLEDZACTIVEZHIDDENZCASCADEZCHECKBUTTONZCOMMANDZRADIOBUTTONZ	SEPARATORZSINGLEZBROWSEZMULTIPLEZEXTENDEDZDOTBOXZ	UNDERLINEZPIESLICEZCHORDZARCZFIRSTZLASTZBUTTZ
PROJECTINGZROUNDZBEVELZMITERZMOVETOZSCROLLZUNITSZPAGES�rr�)/usr/lib64/python3.8/tkinter/constants.py�<module>s�PK0�\`��S�Ssslproto.cpython-38.opt-1.pycnu�[���U

e5dJj�@s�ddlZddlZzddlZWnek
r4dZYnXddlmZddlmZddlmZddlmZddl	m
Z
dd	�Zd
ZdZ
dZd
ZGdd�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�base_events)�	constants)�	protocols)�
transports)�loggercCs"|rtd��t��}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF)�
ValueError�sslZcreate_default_contextZcheck_hostname)�server_side�server_hostname�
sslcontext�r
�(/usr/lib64/python3.8/asyncio/sslproto.py�_create_transport_contextsrZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@s~eZdZdZdZddd�Zedd��Zedd	��Zed
d��Z	edd
��Z
ddd�Zddd�Zdd�Z
ddd�Zddd�ZdS)�_SSLPipeaAn SSL "Pipe".

    An SSL pipe allows you to communicate with an SSL/TLS protocol instance
    through memory buffers. It can be used to implement a security layer for an
    existing connection where you don't have access to the connection's file
    descriptor, or for some reason you don't want to use it.

    An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode,
    data is passed through untransformed. In wrapped mode, application level
    data is encrypted to SSL record level data and vice versa. The SSL record
    level is the lowest level in the SSL protocol suite and is what travels
    as-is over the wire.

    An SslPipe initially is in "unwrapped" mode. To start SSL, call
    do_handshake(). To shutdown SSL again, call unwrap().
    iNcCsH||_||_||_t|_t��|_t��|_d|_	d|_
d|_d|_dS)a�
        The *context* argument specifies the ssl.SSLContext to use.

        The *server_side* argument indicates whether this is a server side or
        client side transport.

        The optional *server_hostname* argument can be used to specify the
        hostname you are connecting to. You may only specify this parameter if
        the _ssl module supports Server Name Indication (SNI).
        NF)
�_context�_server_side�_server_hostname�
_UNWRAPPED�_stater	Z	MemoryBIO�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextr
rr
r
r�__init__8s

z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)r�rr
r
rrNsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance.

        Return None if the pipe is not wrapped.
        )rrr
r
r�
ssl_objectSsz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake
        that is currently in progress.)rrr
r
r�need_ssldata[sz_SSLPipe.need_ssldatacCs
|jtkS)zj
        Whether a security layer is currently in effect.

        Return False during handshake.
        )r�_WRAPPEDrr
r
r�wrappedasz_SSLPipe.wrappedcCsR|jtkrtd��|jj|j|j|j|jd�|_	t
|_||_|jddd�\}}|S)aLStart the SSL handshake.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the handshake is complete. The callback will be
        called with None if successful, else an exception instance.
        z"handshake in progress or completed)r
r�T)�only_handshake)
rr�RuntimeErrorrZwrap_biorrrrr�
_DO_HANDSHAKEr�feed_ssldata�r�callback�ssldata�appdatar
r
r�do_handshakejs	
�z_SSLPipe.do_handshakecCsB|jtkrtd��|jtkr$td��t|_||_|�d�\}}|S)a1Start the SSL shutdown sequence.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the shutdown is complete. The callback will be
        called without arguments.
        zno security layer presentzshutdown in progressr$)rrr&�	_SHUTDOWNrr(r)r
r
r�shutdowns	

z_SSLPipe.shutdowncCs|j��|�d�\}}dS)z�Send a potentially "ragged" EOF.

        This method will raise an SSL_ERROR_EOF exception if the EOF is
        unexpected.
        r$N)rZ	write_eofr()rr+r,r
r
r�feed_eof�s
z_SSLPipe.feed_eofFc
Cs�|jtkr"|r|g}ng}g|fSd|_|r8|j�|�g}g}z�|jtkrz|j��t|_|j	rl|�	d�|rz||fWS|jtkr�|j�
|j�}|�|�|s�q�q�nJ|jt
kr�|j��d|_t|_|jr�|��n|jtkr�|�|j�
��Wnztjtjfk
�rl}zRt|dd�}|tjtjtjfk�rP|jtk�rN|j	�rN|�	|��|tjk|_W5d}~XYnX|jj�r�|�|j�
��||fS)a�Feed SSL record level data into the pipe.

        The data must be a bytes instance. It is OK to send an empty bytes
        instance. This can be used to get ssldata for a handshake initiated by
        this endpoint.

        Return a (ssldata, appdata) tuple. The ssldata element is a list of
        buffers containing SSL data that needs to be sent to the remote SSL.

        The appdata element is a list of buffers containing plaintext data that
        needs to be forwarded to the application. The appdata list may contain
        an empty buffer indicating an SSL "close_notify" alert. This alert must
        be acknowledged by calling shutdown().
        FN�errno)rrrr�writer'rr-r"r�read�max_size�appendr.Zunwraprr	�SSLError�CertificateError�getattr�SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITE�SSL_ERROR_SYSCALLr�pending)r�datar%r,r+�chunk�exc�	exc_errnor
r
rr(�sZ










�

z_SSLPipe.feed_ssldatarc
Cs|jtkr6|t|�kr&||d�g}ng}|t|�fSg}t|�}d|_z(|t|�krn||j�||d��7}Wnhtjk
r�}zHt	|dd�}|j
dkr�tj}|_|tjtj
tjfkr��|tjk|_W5d}~XYnX|jjr�|�|j���|t|�k�s|jrB�qqB||fS)aFeed plaintext data into the pipe.

        Return an (ssldata, offset) tuple. The ssldata element is a list of
        buffers containing record level data that needs to be sent to the
        remote SSL instance. The offset is the number of plaintext bytes that
        were processed, which may be less than the length of data.

        NOTE: In case of short writes, this call MUST be retried with the SAME
        buffer passed into the *data* argument (i.e. the id() must be the
        same). This is an OpenSSL requirement. A further particularity is that
        a short write will always have offset == 0, because the _ssl module
        does not enable partial writes. And even though the offset is zero,
        there will still be encrypted data in ssldata.
        NFr1ZPROTOCOL_IS_SHUTDOWN)rr�len�
memoryviewrrr2r	r6r8�reasonr9r1r:r;rr<r5r3)rr=�offsetr+Zviewr?r@r
r
r�feed_appdata�s4

�z_SSLPipe.feed_appdata)N)N)N)F)r)�__name__�
__module__�__qualname__�__doc__r4r�propertyrr r!r#r-r/r0r(rEr
r
r
rr$s 








Krc@s�eZdZejjZdd�Zd"dd�Zdd�Z	dd	�Z
d
d�Zdd
�Ze
jfdd�Zdd�Zdd�Zdd�Zd#dd�Zdd�Zedd��Zdd�Zdd�Zd d!�ZdS)$�_SSLProtocolTransportcCs||_||_d|_dS)NF)�_loop�
_ssl_protocol�_closed)r�loopZssl_protocolr
r
rr!sz_SSLProtocolTransport.__init__NcCs|j�||�S)z#Get optional transport information.)rM�_get_extra_info�r�name�defaultr
r
r�get_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j�|�dS�N)rM�_set_app_protocol)r�protocolr
r
r�set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSrU)rM�
_app_protocolrr
r
r�get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSrU)rNrr
r
r�
is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|j��dS)a
Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) called
        with None as its argument.
        TN)rNrM�_start_shutdownrr
r
r�close4sz_SSLProtocolTransport.closecCs&|js"|d|��t|d�|��dS)Nzunclosed transport )�source)rN�ResourceWarningr])rZ_warnr
r
r�__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd��|��S)Nz*SSL transport has not been initialized yet)rM�
_transportr&�
is_reading)rZtrr
r
rrbDsz _SSLProtocolTransport.is_readingcCs|jj��dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        N)rMra�
pause_readingrr
r
rrcJsz#_SSLProtocolTransport.pause_readingcCs|jj��dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        N)rMra�resume_readingrr
r
rrdRsz$_SSLProtocolTransport.resume_readingcCs|jj�||�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        N)rMra�set_write_buffer_limits)rZhighZlowr
r
rreZsz-_SSLProtocolTransport.set_write_buffer_limitscCs|jj��S)z,Return the current size of the write buffer.)rMra�get_write_buffer_sizerr
r
rrfosz+_SSLProtocolTransport.get_write_buffer_sizecCs
|jjjSrU)rMra�_protocol_pausedrr
r
rrgssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttf�s$tdt|�j����|s,dS|j�|�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        z+data: expecting a bytes-like instance, got N)	�
isinstance�bytes�	bytearrayrB�	TypeError�typerFrM�_write_appdata�rr=r
r
rr2xs
z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr
rr
r
r�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|j��d|_dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        TN)rM�_abortrNrr
r
r�abort�s
z_SSLProtocolTransport.abort)N)NN)rFrGrHrZ
_SendfileModeZFALLBACKZ_sendfile_compatiblerrTrXrZr[r]�warnings�warnr`rbrcrdrerfrJrgr2rorqr
r
r
rrKs$



rKc@s�eZdZdZd,dd�Zdd�Zd-d	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zd.dd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd/d&d'�Zd(d)�Zd*d+�ZdS)0�SSLProtocolz�SSL protocol.

    Implementation of SSL on top of a socket using incoming and outgoing
    buffers which are ssl.MemoryBIO objects.
    FNTc		Cs�tdkrtd��|dkr tj}n|dkr6td|����|sDt||�}||_|rZ|sZ||_nd|_||_t	|d�|_
t��|_
d|_||_||_|�|�t|j|�|_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )rF)r	r&rZSSL_HANDSHAKE_TIMEOUTrrrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrLrVrK�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownra�_call_connection_made�_ssl_handshake_timeout)	rrO�app_protocolrZwaiterr
rZcall_connection_madeZssl_handshake_timeoutr
r
rr�s@��

zSSLProtocol.__init__cCs||_t|tj�|_dSrU)rYrhrZBufferedProtocol�_app_protocol_is_buffer)rr�r
r
rrV�s
�zSSLProtocol._set_app_protocolcCsD|jdkrdS|j��s:|dk	r.|j�|�n|j�d�d|_dSrU)r|Z	cancelledZ
set_exceptionZ
set_result�rr?r
r
r�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|��dS)zXCalled when the low-level connection is made.

        Start the SSL handshake.
        N)rarrurrr~�_start_handshake)r�	transportr
r
r�connection_made�s�zSSLProtocol.connection_madecCsn|jr d|_|j�|jj|�n|jdk	r2d|j_d|_d|_t|dd�rT|j	�
�|�|�d|_d|_dS)z�Called when the low-level connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        FNT�_handshake_timeout_handle)
rrL�	call_soonrY�connection_lostr}rNrar8r��cancelr�r~r�r
r
rr��s


zSSLProtocol.connection_lostcCs|j��dS)z\Called when the low-level transport's buffer goes over
        the high-water mark.
        N)rY�
pause_writingrr
r
rr��szSSLProtocol.pause_writingcCs|j��dS)z^Called when the low-level transport's buffer drains below
        the low-water mark.
        N)rY�resume_writingrr
r
rr�szSSLProtocol.resume_writingcCs"|jdkrdSz|j�|�\}}WnLttfk
r<�Yn4tk
rn}z|�|d�WY�dSd}~XYnX|D]}|j�|�qt|D]�}|�rz&|jr�t	�
|j|�n|j�|�WnPttfk
r��Yn8tk
�r
}z|�|d�WY�dSd}~XYnXq�|�
��qq�dS)zXCalled when some SSL data is received.

        The argument is a bytes object.
        NzSSL error in data receivedz/application protocol failed to receive SSL data)r~r(�
SystemExit�KeyboardInterrupt�
BaseException�_fatal_errorrar2r�rZ_feed_data_to_buffered_protorY�
data_receivedr\)rr=r+r,�er>Zexr
r
rr�s<
��zSSLProtocol.data_receivedcCsTzB|j��rt�d|�|�t�|js@|j	�
�}|r@t�d�W5|j��XdS)aCalled when the other end of the low-level stream
        is half-closed.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        z%r received EOFz?returning true from eof_received() has no effect when using sslN)rar]rL�	get_debugr�debugr��ConnectionResetErrorr�rY�eof_receivedZwarning)rZ	keep_openr
r
rr�-s


zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk	r,|j�||�S|SdSrU)rwrarTrQr
r
rrPCs



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|��nd|_|�d�dS)NTr$)r�r�rprmrr
r
rr\Ks
zSSLProtocol._start_shutdowncCs.|j�|df�|jt|�7_|��dS)Nr)rzr5r{rA�_process_write_backlogrnr
r
rrmTszSSLProtocol._write_appdatacCs\|j��r$t�d|�|j��|_nd|_d|_|j�d�|j�	|j
|j�|_|�
�dS)Nz%r starts SSL handshakeT)r$r)rLr�rr��time�_handshake_start_timer�rzr5Z
call_laterr��_check_handshake_timeoutr�r�rr
r
rr�Ys

��zSSLProtocol._start_handshakecCs*|jdkr&d|j�d�}|�t|��dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)r�r�r��ConnectionAbortedError)r�msgr
r
rr�hs
�z$SSLProtocol._check_handshake_timeoutc
Csd|_|j��|jj}z|dk	r&|�|��}Wnbttfk
rJ�YnJtk
r�}z,t	|t
j�rld}nd}|�||�WY�dSd}~XYnX|j
��r�|j
��|j}t�d||d�|jj||��|��|d�|jr�|j�|j�|��d|_|j
�|j�dS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compressionr T)r�r�r�r~r Zgetpeercertr�r�r�rhr	r7r�rLr�r�r�rr�rw�updater�r�r�rYr�r}r�rr�r�)rZ
handshake_excZsslobjr�r?r�Zdtr
r
r�_on_handshake_completeqs8

�z"SSLProtocol._on_handshake_completec
CsB|jdks|jdkrdSz�tt|j��D]�}|jd\}}|rR|j�||�\}}n*|rj|j�|j�}d}n|j�|j	�}d}|D]}|j�
|�q�|t|�kr�||f|jd<|jjr�|j��q�|jd=|j
t|�8_
q(Wn\ttfk
r��YnDtk
�r<}z$|j�r |�|�n|�|d�W5d}~XYnXdS)NrrzFatal error on SSL transport)rar~�rangerArzrEr-r�r/�	_finalizer2Z_pausedrdr{r�r�r�r�r�)r�ir=rDr+r>r?r
r
rr��s:�
z"SSLProtocol._process_write_backlog�Fatal error on transportcCsVt|t�r(|j��r@tjd||dd�n|j�|||j|d��|jrR|j�|�dS)Nz%r: %sT)�exc_info)�messageZ	exceptionr�rW)	rh�OSErrorrLr�rr�Zcall_exception_handlerraZ_force_close)rr?r�r
r
rr��s

�zSSLProtocol._fatal_errorcCsd|_|jdk	r|j��dSrU)r~rar]rr
r
rr��s
zSSLProtocol._finalizecCs(z|jdk	r|j��W5|��XdSrU)r�rarqrr
r
rrp�s
zSSLProtocol._abort)FNTN)N)N)r�)rFrGrHrIrrVr�r�r�r�r�r�r�rPr\rmr�r�r�r�r�r�rpr
r
r
rrt�s0�
.

&
		)+
rt)rxrrr	�ImportError�rrrr�logrrrr'r"r.�objectrZ_FlowControlMixinZ	TransportrKZProtocolrtr
r
r
r�<module>s*
y�xPK0�\ۂ�U
+
+futures.cpython-38.opt-1.pycnu�[���U

e5db3�@s�dZdZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZejZej
Z
ejZejZejdZGd	d
�d
�ZeZdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�dd�ZzddlZWnek
r�YnXejZZdS)z.A Future class similar to the one in PEP 3148.)�Future�wrap_future�isfuture�N�)�base_futures)�events)�
exceptions)�format_helpersc@s�eZdZdZeZdZdZdZdZ	dZ
dZdd�dd�Ze
jZdd�Zd	d
�Zedd��Zejd
d��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Z e Z!dS)'ra,This class is *almost* compatible with concurrent.futures.Future.

    Differences:

    - This class is not thread-safe.

    - result() and exception() do not take a timeout argument and
      raise an exception when the future isn't done yet.

    - Callbacks registered with add_done_callback() are always called
      via the event loop's call_soon().

    - This class is not compatible with the wait() and as_completed()
      methods in the concurrent.futures package.

    (In Python 3.4 or later we may be able to unify the implementations.)
    NF��loopcCs@|dkrt��|_n||_g|_|j��r<t�t�d��|_	dS)z�Initialize the future.

        The optional event_loop argument allows explicitly setting the event
        loop object used by the future. If it's not provided, the future uses
        the default event loop.
        Nr)
r�get_event_loop�_loop�
_callbacksZ	get_debugr	�
extract_stack�sys�	_getframe�_source_traceback��selfr�r�'/usr/lib64/python3.8/asyncio/futures.py�__init__Ds
�zFuture.__init__cCsd�|jjd�|����S)Nz<{} {}>� )�format�	__class__�__name__�join�
_repr_info�rrrr�__repr__Vs
�zFuture.__repr__cCsF|js
dS|j}|jj�d�||d�}|jr6|j|d<|j�|�dS)Nz exception was never retrieved)�message�	exception�futureZsource_traceback)�_Future__log_traceback�
_exceptionrrrr
Zcall_exception_handler)r�exc�contextrrr�__del__Zs�
zFuture.__del__cCs|jS�N)r#rrrr�_log_tracebackjszFuture._log_tracebackcCst|�rtd��d|_dS)Nz'_log_traceback can only be set to FalseF)�bool�
ValueErrorr#)r�valrrrr)nscCs|j}|dkrtd��|S)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r
�RuntimeErrorrrrr�get_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|��dS)z�Cancel the future and schedule callbacks.

        If the future is already done or cancelled, return False.  Otherwise,
        change the future's state to cancelled, schedule the callbacks and
        return True.
        FT)r#�_state�_PENDING�
_CANCELLED�_Future__schedule_callbacksrrrr�cancel{s
z
Future.cancelcCsH|jdd�}|sdSg|jdd�<|D]\}}|jj|||d�q(dS)z�Internal: Ask the event loop to call all callbacks.

        The callbacks are scheduled to be called as soon as possible. Also
        clears the callback list.
        N�r&)rr
�	call_soon)rZ	callbacks�callback�ctxrrrZ__schedule_callbacks�szFuture.__schedule_callbackscCs
|jtkS)z(Return True if the future was cancelled.)r/r1rrrr�	cancelled�szFuture.cancelledcCs
|jtkS)z�Return True if the future is done.

        Done means either that a result / exception are available, or that the
        future was cancelled.
        )r/r0rrrr�done�szFuture.donecCs@|jtkrtj�|jtkr$t�d��d|_|jdk	r:|j�|jS)aReturn the result this future represents.

        If the future has been cancelled, raises CancelledError.  If the
        future's result isn't yet available, raises InvalidStateError.  If
        the future is done and has an exception set, this exception is raised.
        zResult is not ready.FN)	r/r1r�CancelledError�	_FINISHED�InvalidStateErrorr#r$�_resultrrrr�result�s



z
Future.resultcCs0|jtkrtj�|jtkr$t�d��d|_|jS)a&Return the exception that was set on this future.

        The exception (or None if no exception was set) is returned only if
        the future is done.  If the future has been cancelled, raises
        CancelledError.  If the future isn't done yet, raises
        InvalidStateError.
        zException is not set.F)r/r1rr:r;r<r#r$rrrrr!�s


zFuture.exceptionr4cCsB|jtkr|jj|||d�n |dkr.t��}|j�||f�dS)z�Add a callback to be run when the future becomes done.

        The callback is called with a single argument - the future object. If
        the future is already done when this is called, the callback is
        scheduled with call_soon.
        r4N)r/r0r
r5�contextvarsZcopy_contextr�append)r�fnr&rrr�add_done_callback�s

zFuture.add_done_callbackcs<�fdd�|jD�}t|j�t|�}|r8||jdd�<|S)z}Remove all instances of a callback from the "call when done" list.

        Returns the number of callbacks removed.
        cs g|]\}}|�kr||f�qSrr)�.0�fr7�rArr�
<listcomp>�s�z/Future.remove_done_callback.<locals>.<listcomp>N)r�len)rrAZfiltered_callbacksZ
removed_countrrEr�remove_done_callback�s
�zFuture.remove_done_callbackcCs8|jtkr t�|j�d|����||_t|_|��dS)z�Mark the future done and set its result.

        If the future is already done when this method is called, raises
        InvalidStateError.
        �: N)r/r0rr<r=r;r2)rr>rrr�
set_result�s

zFuture.set_resultcCsb|jtkr t�|j�d|����t|t�r0|�}t|�tkrDtd��||_t	|_|�
�d|_dS)z�Mark the future done and set an exception.

        If the future is already done when this method is called, raises
        InvalidStateError.
        rIzPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r/r0rr<�
isinstance�type�
StopIteration�	TypeErrorr$r;r2r#)rr!rrr�
set_exception�s

zFuture.set_exceptionccs,|��sd|_|V|��s$td��|��S)NTzawait wasn't used with future)r9�_asyncio_future_blockingr-r>rrrr�	__await__szFuture.__await__)"r�
__module__�__qualname__�__doc__r0r/r=r$r
rrPr#rrZ_future_repr_inforrr'�propertyr)�setterr.r3r2r8r9r>r!rBrHrJrOrQ�__iter__rrrrrs:

rcCs,z
|j}Wntk
rYnX|�S|jSr()r.�AttributeErrorr
)�futr.rrr�	_get_loops
rZcCs|��rdS|�|�dS)z?Helper setting the result only if the future was not cancelled.N)r8rJ)rYr>rrr�_set_result_unless_cancelledsr[cCsXt|�}|tjjkr tj|j�S|tjjkr8tj|j�S|tjjkrPtj|j�S|SdSr()rL�
concurrent�futuresr:r�args�TimeoutErrorr<)r%Z	exc_classrrr�_convert_future_exc#sr`cCsR|��r|��|��sdS|��}|dk	r<|�t|��n|��}|�|�dS)z8Copy state from a future to a concurrent.futures.Future.N)r8r3Zset_running_or_notify_cancelr!rOr`r>rJ)r\�sourcer!r>rrr�_set_concurrent_future_state/srbcCsT|��rdS|��r|��n2|��}|dk	r>|�t|��n|��}|�|�dS)zqInternal helper to copy state from another Future.

    The other Future may be a concurrent.futures.Future.
    N)r8r3r!rOr`r>rJ)ra�destr!r>rrr�_copy_future_state>s
rdcs�t��st�tjj�std��t��s<t�tjj�s<td��t��rLt��nd�t��r`t��nd�dd�����fdd�}����fdd	�}��|���|�dS)
aChain two futures so that when one completes, so does the other.

    The result (or exception) of source will be copied to destination.
    If destination is cancelled, source gets cancelled too.
    Compatible with both asyncio.Future and concurrent.futures.Future.
    z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|�rt||�n
t||�dSr()rrdrb)r"�otherrrr�
_set_statebsz!_chain_future.<locals>._set_statecs2|��r.�dks��kr"���n���j�dSr()r8r3�call_soon_threadsafe)�destination)�	dest_loopra�source_looprr�_call_check_cancelhs
z)_chain_future.<locals>._call_check_cancelcsJ���r�dk	r���rdS�dks,��kr8��|�n����|�dSr()r8Z	is_closedrg)ra)rfrirhrjrr�_call_set_stateos��z&_chain_future.<locals>._call_set_state)rrKr\r]rrNrZrB)rarhrkrlr)rfrirhrarjr�
_chain_futureRs��	
rmr
cCs2t|�r|S|dkrt��}|��}t||�|S)z&Wrap concurrent.futures.Future object.N)rrrZ
create_futurerm)r"rZ
new_futurerrrr|s
r)rT�__all__Zconcurrent.futuresr\r?Zloggingr�rrrr	rr0r1r;�DEBUGZSTACK_DEBUGrZ	_PyFuturerZr[r`rbrdrmrZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s:
q*
PK0�\��M%!%!trsock.cpython-38.pycnu�[���U

e5d��@s"ddlZddlZGdd�d�ZdS)�Nc@s�eZdZdZdZejd�dd�Zdd�Zedd	��Z	ed
d��Z
edd
��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z d8d9�Z!d:d;�Z"d<d=�Z#d>d?�Z$d@dA�Z%dBdC�Z&dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,dPdQ�Z-dRdS�Z.dTdU�Z/dVdW�Z0dXdY�Z1dZd[�Z2d\S)]�TransportSocketz�A socket-like wrapper for exposing real transport sockets.

    These objects can be safely returned by APIs like
    `transport.get_extra_info('socket')`.  All potentially disruptive
    operations (like "socket.close()") are banned.
    ��_sock)�sockcCs
||_dS�Nr)�selfr�r�&/usr/lib64/python3.8/asyncio/trsock.py�__init__szTransportSocket.__init__cCstjd|�d�t|d�dS)NzUsing z� on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)�source)�warnings�warn�DeprecationWarning)rZwhatrrr	�_nas

�zTransportSocket._nacCs|jjSr)r�family�rrrr	rszTransportSocket.familycCs|jjSr)r�typerrrr	rszTransportSocket.typecCs|jjSr)r�protorrrr	r"szTransportSocket.protocCs�d|���d|j�d|j�d|j��}|��dkr�z|��}|rN|�d|��}Wntjk
rfYnXz|��}|r�|�d|��}Wntjk
r�YnX|�d�S)	Nz<asyncio.TransportSocket fd=z	, family=z, type=z, proto=���z, laddr=z, raddr=�>)�filenorrr�getsockname�socket�error�getpeername)r�sZladdrZraddrrrr	�__repr__&s $�zTransportSocket.__repr__cCstd��dS)Nz/Cannot serialize asyncio.TransportSocket object)�	TypeErrorrrrr	�__getstate__=szTransportSocket.__getstate__cCs
|j��Sr)rrrrrr	r@szTransportSocket.filenocCs
|j��Sr)r�duprrrr	rCszTransportSocket.dupcCs
|j��Sr)r�get_inheritablerrrr	r FszTransportSocket.get_inheritablecCs|j�|�dSr)r�shutdown)rZhowrrr	r!IszTransportSocket.shutdowncOs|jj||�Sr)r�
getsockopt�r�args�kwargsrrr	r"NszTransportSocket.getsockoptcOs|jj||�dSr)r�
setsockoptr#rrr	r&QszTransportSocket.setsockoptcCs
|j��Sr)rrrrrr	rTszTransportSocket.getpeernamecCs
|j��Sr)rrrrrr	rWszTransportSocket.getsocknamecCs
|j��Sr)r�
getsockbynamerrrr	r'ZszTransportSocket.getsockbynamecCs|�d�|j��S)Nzaccept() method)rr�acceptrrrr	r(]s
zTransportSocket.acceptcOs|�d�|jj||�S)Nzconnect() method)rr�connectr#rrr	r)as
zTransportSocket.connectcOs|�d�|jj||�S)Nzconnect_ex() method)rr�
connect_exr#rrr	r*es
zTransportSocket.connect_excOs|�d�|jj||�S)Nz
bind() method)rr�bindr#rrr	r+is
zTransportSocket.bindcOs|�d�|jj||�S)Nzioctl() method)rr�ioctlr#rrr	r,ms
zTransportSocket.ioctlcOs|�d�|jj||�S)Nzlisten() method)rr�listenr#rrr	r-qs
zTransportSocket.listencCs|�d�|j��S)Nzmakefile() method)rr�makefilerrrr	r.us
zTransportSocket.makefilecOs|�d�|jj||�S)Nzsendfile() method)rr�sendfiler#rrr	r/ys
zTransportSocket.sendfilecCs|�d�|j��S)Nzclose() method)rr�closerrrr	r0}s
zTransportSocket.closecCs|�d�|j��S)Nzdetach() method)rr�detachrrrr	r1�s
zTransportSocket.detachcOs|�d�|jj||�S)Nzsendmsg_afalg() method)rr�
sendmsg_afalgr#rrr	r2�s
zTransportSocket.sendmsg_afalgcOs|�d�|jj||�S)Nzsendmsg() method)rr�sendmsgr#rrr	r3�s
zTransportSocket.sendmsgcOs|�d�|jj||�S)Nzsendto() method)rr�sendtor#rrr	r4�s
zTransportSocket.sendtocOs|�d�|jj||�S)Nz
send() method)rr�sendr#rrr	r5�s
zTransportSocket.sendcOs|�d�|jj||�S)Nzsendall() method)rr�sendallr#rrr	r6�s
zTransportSocket.sendallcOs|�d�|jj||�S)Nzset_inheritable() method)rr�set_inheritabler#rrr	r7�s
zTransportSocket.set_inheritablecCs|�d�|j�|�S)Nzshare() method)rr�share)rZ
process_idrrr	r8�s
zTransportSocket.sharecOs|�d�|jj||�S)Nzrecv_into() method)rr�	recv_intor#rrr	r9�s
zTransportSocket.recv_intocOs|�d�|jj||�S)Nzrecvfrom_into() method)rr�
recvfrom_intor#rrr	r:�s
zTransportSocket.recvfrom_intocOs|�d�|jj||�S)Nzrecvmsg_into() method)rr�recvmsg_intor#rrr	r;�s
zTransportSocket.recvmsg_intocOs|�d�|jj||�S)Nzrecvmsg() method)rr�recvmsgr#rrr	r<�s
zTransportSocket.recvmsgcOs|�d�|jj||�S)Nzrecvfrom() method)rr�recvfromr#rrr	r=�s
zTransportSocket.recvfromcOs|�d�|jj||�S)Nz
recv() method)rr�recvr#rrr	r>�s
zTransportSocket.recvcCs|dkrdStd��dS)Nrz<settimeout(): only 0 timeout is allowed on transport sockets��
ValueError)r�valuerrr	�
settimeout�s
�zTransportSocket.settimeoutcCsdS)Nrrrrrr	�
gettimeout�szTransportSocket.gettimeoutcCs|sdStd��dS)Nz3setblocking(): transport sockets cannot be blockingr?)r�flagrrr	�setblocking�s
�zTransportSocket.setblockingcCs|�d�|j��S�Nzcontext manager protocol)rr�	__enter__rrrr	rG�s
zTransportSocket.__enter__cGs|�d�|jj|�SrF)rr�__exit__)r�errrrr	rH�s
zTransportSocket.__exit__N)3�__name__�
__module__�__qualname__�__doc__�	__slots__rr
r�propertyrrrrrrrr r!r"r&rrr'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>rBrCrErGrHrrrr	rsb


r)rrrrrrr	�<module>sPK0�\[k�AAtasks.cpython-38.opt-2.pycnu�[���U

e5d���@srdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	lmZe�d�jZdAd
d�ZdBdd
�ZdCdd�Zdd�ZGdd�dej�ZeZzddlZWnek
r�YnXejZZdd�dd�ZejjZejj Z ejj!Z!dde!d�dd�Z"dd�Z#dd�dd�Z$dd �Z%d!d"�Z&ddd#�d$d%�Z'ej(d&d'��Z)dDdd�d(d)�Z*dd�d*d+�Z+ej(d,d-��Z,ee,_Gd.d/�d/ej-�Z.dd0d1�d2d3�Z/dd�d4d5�Z0d6d7�Z1e	�2�Z3iZ4d8d9�Z5d:d;�Z6d<d=�Z7d>d?�Z8e5Z9e8Z:e6Z;e7Z<z$dd@lm5Z5m8Z8m6Z6m7Z7m3Z3m4Z4Wnek
�r\YnXe5Z=e8Z>e6Z?e7Z@dS)E)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield�
ensure_future�run_coroutine_threadsafe�current_task�	all_tasks�_register_task�_unregister_task�_enter_task�_leave_task�N�)�
base_tasks)�
coroutines)�events)�
exceptions)�futures)�
_is_coroutinecCs|dkrt��}t�|�S�N)r�get_running_loop�_current_tasks�get��loop�r"�%/usr/lib64/python3.8/asyncio/tasks.pyr"srcs^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)Nrr��cs&h|]}t�|��kr|��s|�qSr")r�	_get_loop�done��.0�tr r"r#�	<setcomp><s�zall_tasks.<locals>.<setcomp>)rr�list�
_all_tasks�RuntimeError�r!�iZtasksr"r r#r)srcs^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)Nrrr$csh|]}t�|��kr|�qSr")rr%r'r r"r#r*Usz$_all_tasks_compat.<locals>.<setcomp>)r�get_event_loopr+r,r-r.r"r r#�_all_tasks_compat@sr1cCs4|dk	r0z
|j}Wntk
r&Yn
X||�dSr)�set_name�AttributeError)�task�namer2r"r"r#�_set_task_nameXs
r6cs�eZdZdZed$dd��Zed%dd��Zddd��fdd	�
Z�fd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�dd�Zddd�dd�Zdd�Zd&�fd d!�	Zd"d#�Z�ZS)'rTNcCs(tjdtdd�|dkr t��}t|�S)NzVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead���
stacklevel)�warnings�warn�DeprecationWarningrr0r��clsr!r"r"r#rts�zTask.current_taskcCstjdtdd�t|�S)NzPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r1r=r"r"r#r�s
�zTask.all_tasks)r!r5cs�t�j|d�|jr|jd=t�|�s:d|_td|����|dkrRdt���|_n
t	|�|_d|_
d|_||_t
��|_|jj|j|jd�t|�dS)Nr ���Fza coroutine was expected, got zTask-��context)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending�	TypeError�_task_name_counter�_name�str�_must_cancel�_fut_waiter�_coro�contextvarsZcopy_context�_context�_loop�	call_soon�_Task__stepr)�self�coror!r5��	__class__r"r#rC�s


z
Task.__init__csF|jtjkr8|jr8|dd�}|jr,|j|d<|j�|�t���dS)Nz%Task was destroyed but it is pending!)r4�messageZsource_traceback)	Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB�__del__)rSrArUr"r#rX�s�
zTask.__del__cCs
t�|�Sr)rZ_task_repr_info�rSr"r"r#�
_repr_info�szTask._repr_infocCs|jSr)rMrYr"r"r#�get_coro�sz
Task.get_corocCs|jSr)rIrYr"r"r#�get_name�sz
Task.get_namecCst|�|_dSr)rJrI)rS�valuer"r"r#r2�sz
Task.set_namecCstd��dS)Nz*Task does not support set_result operation�r-)rS�resultr"r"r#�
set_result�szTask.set_resultcCstd��dS)Nz-Task does not support set_exception operationr^)rS�	exceptionr"r"r#�
set_exception�szTask.set_exception)�limitcCst�||�Sr)rZ_task_get_stack)rSrcr"r"r#�	get_stack�szTask.get_stack)rc�filecCst�|||�Sr)rZ_task_print_stack)rSrcrer"r"r#�print_stack�s	zTask.print_stackcCs4d|_|��rdS|jdk	r*|j��r*dSd|_dS�NFT)Z_log_tracebackr&rL�cancelrKrYr"r"r#rh�s

zTask.cancelc
s�|��rt�d|�d|����|jr>t|tj�s8t��}d|_|j}d|_t|j	|��zfz"|dkrp|�d�}n
|�|�}Wn�t
k
r�}z*|jr�d|_t���nt��|j�W5d}~XY�n�tjk
r�t���Y�n�ttfk
�r}zt��|��W5d}~XY�n�tk
�rL}zt��|�W5d}~XY�npXt|dd�}|dk	�r@t�|�|j	k	�r�td|�d|�d��}|j	j|j||jd�n�|�r||k�r�td	|���}|j	j|j||jd�n8d|_|j|j|jd�||_|j�r>|j���r>d|_n*td
|�d|���}|j	j|j||jd�n||dk�r`|j	j|j|jd�n\t �!|��r�td|�d|���}|j	j|j||jd�n$td
|���}|j	j|j||jd�W5t
|j	|�d}XdS)Nz_step(): already done: z, F�_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r&rZInvalidStateErrorrK�
isinstance�CancelledErrorrMrLrrPr�send�throw�
StopIterationrBrhr`r]�KeyboardInterrupt�
SystemExitrb�
BaseException�getattrrr%r-rQrRrOri�add_done_callback�
_Task__wakeup�inspectZisgenerator)rS�excrTr_Zblocking�new_excrUr"r#Z__steps��  
��
�����
���
zTask.__stepc
CsJz|��Wn,tk
r8}z|�|�W5d}~XYn
X|��d}dSr)r_rqrR)rS�futurervr"r"r#Z__wakeup[sz
Task.__wakeup)N)N)N)�__name__�
__module__�__qualname__rF�classmethodrrrCrXrZr[r\r2r`rbrdrfrhrRrt�
__classcell__r"r"rUr#rbs$!Tr)r5cCs t��}|�|�}t||�|Sr)rrrr6)rTr5r!r4r"r"r#rxs

r)r!�timeout�return_whenc�s�t�|�st�|�r(tdt|�j����|s4td��|tt	t
fkrPtd|�����dkrbt���nt
jdtdd��fdd�t|�D�}t|||��IdHS)	Nzexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: �[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|�d��qS�r �r�r(�fr r"r#r*�szwait.<locals>.<setcomp>)r�isfuturerrErG�typery�
ValueErrorrrrrrr:r;r<�set�_wait)�fsr!r~rr"r r#r�s
�rcGs|��s|�d�dSr)r&r`)�waiter�argsr"r"r#�_release_waiter�sr�r c
�s�|dkrt��}ntjdtdd�|dkr4|IdHS|dkr�t||d�}|��rX|��St||d�IdHz|��Wn.t	j
k
r�}zt	��|�W5d}~XYn
Xt	���|��}|�
|t|�}t�t|�}t||d�}|�|�z�z|IdHWnPt	j
k
�rF|���r$|��YW�dS|�|�t||d�IdH�YnX|���r^|��W�*S|�|�t||d�IdHt	���W5|��XdS)Nr�r7r8rr )rrr:r;r<rr&r_�_cancel_and_waitrrk�TimeoutError�
create_future�
call_laterr��	functools�partialrsrh�remove_done_callback)�futr~r!rvr��timeout_handle�cbr"r"r#r�sL

�





rc
�s�|���d�|dk	r"|�|t���t|������fdd�}|D]}|�|�q@z�IdHW5�dk	rp���|D]}|�|�qtXt�t�}}|D]"}|��r�|�	|�q�|�	|�q�||fS)NcsZ�d8��dks4�tks4�tkrV|��sV|��dk	rV�dk	rD������sV��d�dS)Nrr)rr�	cancelledrarhr&r`�r��Zcounterrr�r�r"r#�_on_completions���
�z_wait.<locals>._on_completion)
r�r�r��lenrsrhr�r�r&�add)r�r~rr!r�r�r&Zpendingr"r�r#r��s(r�c	�sF|��}t�t|�}|�|�z|��|IdHW5|�|�XdSr)r�r�r�r�rsr�rh)r�r!r�r�r"r"r#r�&s
r�)r!r~c#s�t�|�st�|�r(tdt|�j����ddlm}|�d���dkrPt	�
��ntjdt
dd��fdd	�t|�D��d����fd
d�}���fdd
���fdd�}�D]}|���q��r�|dk	r҈�||��tt���D]}|�Vq�dS)Nz#expect an iterable of futures, not r)�Queuer r�r7r8csh|]}t|�d��qSr�r�r�r r"r#r*Uszas_completed.<locals>.<setcomp>cs*�D]}|�����d�q���dSr)r��
put_nowait�clearr�)r�r&�todor"r#�_on_timeoutXs
z!as_completed.<locals>._on_timeoutcs4�sdS��|���|��s0�dk	r0���dSr)�remover�rhr�)r&r�r�r"r#r�^s

z$as_completed.<locals>._on_completionc�s$���IdH}|dkrtj�|��Sr)rrr�r_r�)r&r"r#�
_wait_for_onefsz#as_completed.<locals>._wait_for_one)rr�rrErGr�ryZqueuesr�rr0r:r;r<r�rsr��ranger�)r�r!r~r�r�r�r��_r")r�r&r!r�r�r#r7s*

�rccs
dVdSrr"r"r"r"r#�__sleep0us	r�c�sr|dkrt�IdH|S|dkr*t��}ntjdtdd�|��}|�|tj	||�}z|IdHW�S|�
�XdS)Nrr�r7r8)r�rrr:r;r<r�r�rZ_set_result_unless_cancelledrh)Zdelayr_r!rx�hr"r"r#r	�s$
��r	cCs�t�|�r6|dkrt��}|�|�}|jr2|jd=|St�|�rb|dk	r^|t�|�k	r^t	d��|St
�|�r|tt
|�|d�Std��dS)Nr?zRThe future belongs to a different loop than the one specified as the loop argumentr z:An asyncio.Future, a coroutine or an awaitable is required)rrErr0rrDrr�r%r�ruZisawaitabler�_wrap_awaitablerG)Zcoro_or_futurer!r4r"r"r#r�s



rccs|��EdHSr)�	__await__)Z	awaitabler"r"r#r��sr�cs*eZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFutureNr cst�j|d�||_d|_dS)Nr F)rBrC�	_children�_cancel_requested)rS�childrenr!rUr"r#rC�sz_GatheringFuture.__init__cCs6|��rdSd}|jD]}|��rd}q|r2d|_|Srg)r&r�rhr�)rSZretZchildr"r"r#rh�s
z_GatheringFuture.cancel)ryrzr{rCrhr}r"r"rUr#r��sr�F)r!�return_exceptionscs�|s<|dkrt��}ntjdtdd�|�����g��S�����fdd�}i}g�d�d�|D]f}||kr�t||d�}|dkr�t�	|�}||k	r�d|_
�d	7�|||<|�|�n||}��|�qdt
�|d���S)
Nr�r7r8cs��d7����r$|��s |��dS�sd|��rFt��}��|�dS|��}|dk	rd��|�dS��kr�g}�D]8}|��r�t��}n|��}|dkr�|��}|�|�qt�jrĈ�t���n
��	|�dS)Nr)
r&r�rarrkrbr_�appendr�r`)r�rvZresults�res�r�Z	nfinishedZnfuts�outerr�r"r#�_done_callbacks4


zgather.<locals>._done_callbackrr Fr)rr0r:r;r<r�r`rrr%rFrsr�r�)r!r�Zcoros_or_futuresr�Z
arg_to_fut�argr�r"r�r#r
�s:
�
1
r
cst|dk	rtjdtdd�t||d�����r0�St���}|����fdd����fdd�}������|��S)	Nr�r7r8r cs\���r|��s|��dS|��r.���n*|��}|dk	rJ��|�n��|���dSr)r�rarhrbr`r_)�innerrv�r�r"r#�_inner_done_callbackus
z$shield.<locals>._inner_done_callbackcs���s����dSr)r&r�r�)r�r�r"r#�_outer_done_callback�sz$shield.<locals>._outer_done_callback)	r:r;r<rr&rr%r�rs)r�r!r�r")r�r�r�r#rPs�


rcs:t���std��tj������fdd�}��|��S)NzA coroutine object is requiredc
slzt�t��d���WnNttfk
r2�Yn6tk
rf}z���rT��|��W5d}~XYnXdS)Nr )rZ
_chain_futurerrprorqZset_running_or_notify_cancelrb)rv�rTrxr!r"r#�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rrErG�
concurrentr�FutureZcall_soon_threadsafe)rTr!r�r"r�r#r
�s



r
cCst�|�dSr)r,r��r4r"r"r#r�srcCs4t�|�}|dk	r(td|�d|�d���|t|<dS)NzCannot enter into task z while another task z is being executed.�rrr-�r!r4rr"r"r#r�s
rcCs2t�|�}||k	r(td|�d|�d���t|=dS)Nz
Leaving task z! does not match the current task �.r�r�r"r"r#r�s
rcCst�|�dSr)r,�discardr�r"r"r#r�sr)rrrrr,r)N)N)N)N)A�__all__Zconcurrent.futuresr�rNr�ru�	itertools�typesr:�weakref�rrrrrr�count�__next__rHrrr1r6Z	_PyFuturerZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrr�rr�r�r�	coroutiner�r	rr�r�r�r
rr
ZWeakSetr,rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ
_c_enter_taskZ
_c_leave_taskr"r"r"r#�<module>s�	





#H,>

x?$PK0�\H�� �[�[#windows_events.cpython-38.opt-2.pycnu�[���U

e5di��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZddl	mZdd	l	mZdd
l	mZddlmZdZdZd
ZdZdZdZdZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de �Z!Gdd�dej"�Z#Gdd�dej$�Z%Gd d!�d!�Z&Gd"d#�d#ej'�Z(e#Z)Gd$d%�d%e
j*�Z+Gd&d'�d'e
j*�Z,e,Z-dS)(�N�)�events)�base_subprocess)�futures)�
exceptions)�proactor_events)�selector_events)�tasks)�
windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicy���i�i�g����MbP?g�������?csZeZdZdd��fdd�
Z�fdd�Zdd�Z�fd	d
�Z�fdd�Z�fd
d�Z�Z	S)�_OverlappedFutureN��loopcs&t�j|d�|jr|jd=||_dS�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr��	__class__��./usr/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt���}|jdk	rD|jjr dnd}|�dd|�d|jjd�d��|S)N�pendingZ	completedrzoverlapped=<z, �#x�>)r�
_repr_inforr"�insert�address�r�info�staterr r!r%7s


 z_OverlappedFuture._repr_infoc
Csr|jdkrdSz|j��WnJtk
rf}z,d||d�}|jrJ|j|d<|j�|�W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failed��message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextr r r!�_cancel_overlapped>s
�
z$_OverlappedFuture._cancel_overlappedcs|��t���S�N)r6rr0�rrr r!r0Nsz_OverlappedFuture.cancelcst��|�|��dSr7)r�
set_exceptionr6�rr-rr r!r9Rsz_OverlappedFuture.set_exceptioncst��|�d|_dSr7)r�
set_resultr�r�resultrr r!r;Vsz_OverlappedFuture.set_result)
�__name__�
__module__�__qualname__rr%r6r0r9r;�
__classcell__r r rr!r+srcsjeZdZdd��fdd�
Zdd�Z�fdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	�fdd�Z
�ZS)�_BaseWaitHandleFutureNrcs8t�j|d�|jr|jd=||_||_||_d|_dS)NrrT)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst�|jd�tjkS�Nr)�_winapiZWaitForSingleObjectrCZ
WAIT_OBJECT_0r8r r r!�_pollls�z_BaseWaitHandleFuture._pollcsdt���}|�d|jd���|jdk	rB|��r4dnd}|�|�|jdk	r`|�d|jd���|S)Nzhandle=r#ZsignaledZwaitingzwait_handle=)rr%�appendrCrJrDr(rr r!r%qs



z _BaseWaitHandleFuture._repr_infocCs
d|_dSr7)r�r�futr r r!�_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�|�Wn`tk
r�}zB|jtjkrzd||d�}|jrd|j|d<|j�	|�WY�dSW5d}~XYnX|�
d�dS�NFz$Failed to unregister the wait handler+r/)rErD�_overlappedZUnregisterWaitr1�winerror�ERROR_IO_PENDINGrr2r3rN�rrGr4r5r r r!�_unregister_wait�s$�
z&_BaseWaitHandleFuture._unregister_waitcs|��t���Sr7)rTrr0r8rr r!r0�sz_BaseWaitHandleFuture.cancelcs|��t��|�dSr7)rTrr9r:rr r!r9�sz#_BaseWaitHandleFuture.set_exceptioncs|��t��|�dSr7)rTrr;r<rr r!r;�sz _BaseWaitHandleFuture.set_result)r>r?r@rrJr%rNrTr0r9r;rAr r rr!rB[s
rBcsBeZdZdd��fdd�
Zdd�Z�fdd�Z�fd	d
�Z�ZS)�_WaitCancelFutureNrcst�j||||d�d|_dS)Nr)rr�_done_callback)rr�eventrGrrr r!r�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr8r r r!r0�sz_WaitCancelFuture.cancelcs$t��|�|jdk	r |�|�dSr7)rr;rVr<rr r!r;�s
z_WaitCancelFuture.set_resultcs$t��|�|jdk	r |�|�dSr7)rr9rVr:rr r!r9�s
z_WaitCancelFuture.set_exception)r>r?r@rr0r;r9rAr r rr!rU�srUcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureNrcs<t�j||||d�||_d|_t�dddd�|_d|_dS)NrTF)rr�	_proactorZ_unregister_proactorrPZCreateEvent�_event�
_event_fut)rrrFrG�proactorrrr r!r�s
z_WaitHandleFuture.__init__csF|jdk	r"t�|j�d|_d|_|j�|j�d|_t��|�dSr7)	r[rI�CloseHandler\rZ�_unregisterrrrNrLrr r!rN�s
	z%_WaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�||j�Wn`tk
r�}zB|jtjkr~d||d�}|jrh|j|d<|j	�
|�WY�dSW5d}~XYnX|j�|j|j
�|_dSrO)rErDrPZUnregisterWaitExr[r1rQrRrr2r3rZ�_wait_cancelrNr\rSr r r!rT�s(�

�z"_WaitHandleFuture._unregister_wait)r>r?r@rrNrTrAr r rr!rY�srYc@s8eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZeZdS)�
PipeServercCs,||_t��|_d|_d|_|�d�|_dS�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr'r r r!r�s

zPipeServer.__init__cCs|j|�d�}|_|S�NF)rgri)r�tmpr r r!�_get_unconnected_pipesz PipeServer._get_unconnected_pipec
Csr|��rdStjtjB}|r&|tjO}t�|j|tjtjBtj	Btj
tjtjtj
tj�}t�|�}|j�|�|Sr7)�closedrIZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPipercZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr
ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerf�add)r�first�flags�h�piper r r!ris(

��
zPipeServer._server_pipe_handlecCs
|jdkSr7)rcr8r r r!rmszPipeServer.closedcCsR|jdk	r|j��d|_|jdk	rN|jD]}|��q*d|_d|_|j��dSr7)rhr0rcrf�closerg�clear)rrtr r r!rus




zPipeServer.closeN)	r>r?r@rrlrirmru�__del__r r r r!ra�s
rac@seZdZdS)�_WindowsSelectorEventLoopN)r>r?r@r r r r!rx,srxcsDeZdZd�fdd�	Z�fdd�Zdd�Zdd	�Zd
d
d�Z�ZS)r
Ncs|dkrt�}t��|�dSr7)rrr)rr]rr r!r3szProactorEventLoop.__init__c	sXz|�|j�t���W5|jdk	rR|jj}|j��|dk	rL|j�|�d|_XdSr7)	Z_self_reading_futurerr0rZr_�	call_soonZ_loop_self_readingr�run_forever�rrrr r!rz8s

zProactorEventLoop.run_foreverc�s8|j�|�}|IdH}|�}|j||d|id�}||fS)N�addr��extra)rZ�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr'�frt�protocol�transr r r!�create_pipe_connectionKs
�z(ProactorEventLoop.create_pipe_connectionc�s.t���d�����fdd�	������gS)Nc
sd}zn|rN|��}�j�|����r4|��WdS��}�j||d�id����}|dkrdWdS�j�|�}Wn�t	k
r�}zF|r�|�
�dkr���d||d��|��n�jr�t
jd|dd�W5d}~XYn2tjk
r�|r�|��YnX|�_|���dS)	Nr|r}rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)�exc_info)r=rf�discardrmrur�rlrZ�accept_piper1�filenor3Z_debugrZwarningr�CancelledErrorrh�add_done_callback)r�rtr�r4�r'�loop_accept_piper�rZserverr r!r�VsH��
�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rary)rr�r'r r�r!�start_serving_pipeSs(
z$ProactorEventLoop.start_serving_pipec		�s�|��}
t||||||||f|
|d�|	��}z|
IdHWnDttfk
rT�Yn,tk
r~|��|��IdH�YnX|S)N)�waiterr~)�
create_future�_WindowsSubprocessTransport�
SystemExit�KeyboardInterrupt�
BaseExceptionruZ_wait)rr��args�shell�stdin�stdout�stderr�bufsizer~�kwargsr�Ztranspr r r!�_make_subprocess_transport�s*
���z,ProactorEventLoop._make_subprocess_transport)N)N)	r>r?r@rrzr�r�r�rAr r rr!r
0s0�r
c@s�eZdZd:dd�Zdd�Zdd�Zdd	�Zd;dd�Zd
d�Zd<dd�Z	d=dd�Z
d>dd�Zd?dd�Zd@dd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�ZdAd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdBd2d3�Zd4d5�Zd6d7�Zd8d9�Zd
S)CrrcCsDd|_g|_t�tjtd|�|_i|_t�	�|_
g|_t�	�|_dSrH)
r2�_resultsrP�CreateIoCompletionPort�INVALID_HANDLE_VALUErn�_iocp�_cacherdrerE�
_unregistered�_stopped_serving)rZconcurrencyr r r!r�s�
zIocpProactor.__init__cCs|jdkrtd��dS)NzIocpProactor is closed)r�rXr8r r r!�
_check_closed�s
zIocpProactor._check_closedcCsFdt|j�dt|j�g}|jdkr0|�d�d|jjd�|�fS)Nzoverlapped#=%sz
result#=%srmz<%s %s>� )�lenr�r�r�rKrr>�join)rr)r r r!�__repr__�s�

zIocpProactor.__repr__cCs
||_dSr7)r2)rrr r r!�set_loop�szIocpProactor.set_loopNcCs |js|�|�|j}g|_|Sr7)r�rJ)r�timeoutrkr r r!�select�s

zIocpProactor.selectcCs|j��}|�|�|Sr7)r2r�r;)r�valuerMr r r!�_result�s

zIocpProactor._resultrcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)N�c
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7��	getresultr1rQrPZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTED�ConnectionResetErrorr��r��keyrr4r r r!�finish_recv�s
�z&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocprP�
Overlappedrn�
isinstance�socketZWSARecvr�ZReadFile�BrokenPipeErrorr��	_register�r�conn�nbytesrrrr�r r r!�recv�s


zIocpProactor.recvcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)Nrc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z+IocpProactor.recv_into.<locals>.finish_recv)r�rPr�rnr�r�ZWSARecvIntor�ZReadFileIntor�r�r�)rr��bufrrrr�r r r!�	recv_into�s


zIocpProactor.recv_intocCs`|�|�t�t�}z|�|��||�Wntk
rH|�d�YSXdd�}|�|||�S)N)r�Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z*IocpProactor.recvfrom.<locals>.finish_recv)	r�rPr�rnZWSARecvFromr�r�r�r�r�r r r!�recvfrom�s


zIocpProactor.recvfromcCs>|�|�t�t�}|�|��|||�dd�}|�|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sends
�z(IocpProactor.sendto.<locals>.finish_send)r�rPr�rnZ	WSASendTor�r�)rr�r�rrr|rr�r r r!�sendto�s



zIocpProactor.sendtocCsZ|�|�t�t�}t|tj�r4|�|��||�n|�|��|�dd�}|�	|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r�s
�z&IocpProactor.send.<locals>.finish_send)
r�rPr�rnr�r�ZWSASendr�Z	WriteFiler�)rr�r�rrrr�r r r!�sends


zIocpProactor.sendcsv|���|��j��t�t�}|����������fdd�}dd�}|�|�|�}||��}t	j
||jd�|S)NcsD|��t�d����}��tjtj|���	��
������fS)Nz@P)r��structZpackr��
setsockoptr��
SOL_SOCKETrPZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)r�r�rr��r��listenerr r!�
finish_accept*s�z*IocpProactor.accept.<locals>.finish_acceptc�s4z|IdHWn tjk
r.|���YnXdSr7)rr�ru)r.r�r r r!�accept_coro3s
z(IocpProactor.accept.<locals>.accept_coror)r��_get_accept_socket�familyrPr�rnZAcceptExr�r�r	Z
ensure_futurer2)rr�rr�r�r.�coror r�r!�accept$s

	
zIocpProactor.acceptc
s��jtjkr4t����|�|j��}|�d�|S|�	��zt�
����j�WnBtk
r�}z$|j
tjkrt����ddkr��W5d}~XYnXt�t�}|����|��fdd�}|�|�|�S)Nrrcs|����tjtjd��SrH)r�r�r�r�rPZSO_UPDATE_CONNECT_CONTEXT�r�r�r�r�r r!�finish_connectVs�z,IocpProactor.connect.<locals>.finish_connect)�typer�Z
SOCK_DGRAMrPZ
WSAConnectr�r2r�r;r�Z	BindLocalr�r1rQ�errnoZ	WSAEINVALZgetsocknamer�rnZ	ConnectExr�)rr�r'rM�err�r r�r!�connect@s"



zIocpProactor.connectc		Csb|�|�t�t�}|d@}|d?d@}|�|��t�|���|||dd�dd�}|�|||�S)Nr� rc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sendfileis
�z.IocpProactor.sendfile.<locals>.finish_sendfile)	r�rPr�rnZTransmitFiler��msvcrtZ
get_osfhandler�)	rZsock�file�offset�countrZ
offset_lowZoffset_highr�r r r!�sendfile_s


�	zIocpProactor.sendfilecsJ|���t�t�}|�����}|r0|���S�fdd�}|�|�|�S)Ncs|���Sr7)r�r��rtr r!�finish_accept_pipesz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�rPr�rnZConnectNamedPiper�r�r�)rrtrZ	connectedr�r r�r!r�ts


zIocpProactor.accept_pipec
�srt}zt�|�}WqhWn0tk
rF}z|jtjkr6�W5d}~XYnXt|dt�}t�	|�IdHqt
�|�S)N�)�CONNECT_PIPE_INIT_DELAYrPZConnectPiper1rQZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr	�sleepr
ro)rr'ZdelayrFr4r r r!r�s
zIocpProactor.connect_pipecCs|�||d�Srj)�_wait_for_handle)rrFr�r r r!�wait_for_handle�szIocpProactor.wait_for_handlecCs|�|dd�}||_|Srb)r�rV)rrWZ
done_callbackrMr r r!r`�szIocpProactor._wait_cancelcs�|��|dkrtj}nt�|d�}t�t�}t�||j	|j
|�}|r\t||||jd��nt
|||||jd���jr~�jd=�fdd�}�|d|f|j|j
<�S)N�@�@rrcs���Sr7)rJr��r�r r!�finish_wait_for_handle�sz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handler)r�rI�INFINITE�math�ceilrPr�rnZRegisterWaitWithQueuer�r'rUr2rYrr�)rrFr�Z
_is_cancel�msrrGr�r r�r!r��s*
�
�	zIocpProactor._wait_for_handlecCs0||jkr,|j�|�t�|��|jdd�dSrH)rErprPr�r�r��r�objr r r!r��s
z IocpProactor._register_with_iocpc
Cs�|��t||jd�}|jr$|jd=|jsrz|dd|�}Wn,tk
rf}z|�|�W5d}~XYnX|�|�||||f|j|j	<|Sr)
r�rr2rr"r1r9r;r�r')rrr��callbackr�r�r�r r r!r��s

zIocpProactor._registercCs|��|j�|�dSr7)r�r�rKr{r r r!r_�szIocpProactor._unregistercCst�|�}|�d�|SrH)r�r�)rr��sr r r!r��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��nt�|d�}|tkr>td��t�|j|�}|dkrX�qZd}|\}}}}z|j�|�\}}	}
}WnXt	k
r�|j
��r�|j
�dd||||fd��|dtj
fkr�t�|�Yq>YnX|
|jkr�|��q>|��s>z||||	�}Wn:tk
�r@}
z|�|
�|j�|�W5d}
~
XYq>X|�|�|j�|�q>|jD]}	|j�|	jd��q`|j��dS)Nrznegative timeoutr�ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,�status)r��
ValueErrorr�r�rPZGetQueuedCompletionStatusr�r��pop�KeyErrorr2Z	get_debugr3r�rIr^r�r0Zdoner1r9r�rKr;r�r'rv)rr�r�r��errZtransferredr�r'r�rr�r�r�r�r r r!rJsL


��	






zIocpProactor._pollcCs|j�|�dSr7)r�rpr�r r r!�
_stop_serving9szIocpProactor._stop_servingcCs|jdkrdSt|j���D]�\}\}}}}|��r6qt|t�rBqz|��Wqtk
r�}z6|j	dk	r�d||d�}|j
r�|j
|d<|j	�|�W5d}~XYqXqd}t�
�}	|	|}
|jr�|
t�
�kr�t�d|t�
�|	�t�
�|}
|�|�q�g|_t�|j�d|_dS)NzCancelling a future failedr+r/g�?z,%r is running after closing for %.1f seconds)r��listr��itemsZ	cancelledr�rUr0r1r2rr3�time�	monotonicr�debugrJr�rIr^)rr'rMrr�r�r4r5Z
msg_updateZ
start_timeZnext_msgr r r!ru?s@


�
 
�zIocpProactor.closecCs|��dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r`r�r�r�r_r�rJr�rurwr r r r!r�s6








"
 

7/rc@seZdZdd�ZdS)r�c
sPtj|f|||||d�|���_�fdd�}�jj�t�jj��}	|	�|�dS)N)r�r�r�r�r�cs�j��}��|�dSr7)�_procZpollZ_process_exited)r��
returncoder8r r!r�ys
z4_WindowsSubprocessTransport._start.<locals>.callback)	r
�Popenr�r2rZr��intrCr�)
rr�r�r�r�r�r�r�r�r�r r8r!�_startts���z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!r�rsr�c@seZdZeZdS)rN)r>r?r@r�
_loop_factoryr r r r!r�src@seZdZeZdS)rN)r>r?r@r
rr r r r!r�sr).rPrIr�r�r�r�r�r�rd�rrrrrrr	r
�logr�__all__rnr�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerrBrUrY�objectraZBaseSelectorEventLooprxZBaseProactorEventLoopr
rZBaseSubprocessTransportr�rZBaseDefaultEventLoopPolicyrrrr r r r!�<module>sP0J4;e`PK0�\���1N�N�base_events.cpython-38.pycnu�[���U

e5d��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZzddlZWnek
r�dZYnXddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddl m!Z!dZ"dZ#dZ$e%e	d�Z&dZ'e(�Z)dd�Z*dd�Z+dd�Z,d+dd�Z-d,dd�Z.dd �Z/e%e	d!��r�d"d#�Z0nd$d#�Z0Gd%d&�d&ej1�Z2Gd'd(�d(ej3�Z4Gd)d*�d*ej5�Z6dS)-a�Base implementation of event loop.

The event loop can be broken up into a multiplexer (the part
responsible for notifying us of I/O events) and the event loop proper,
which wraps a multiplexer with functionality for scheduling callbacks,
immediately or at a given time in the future.

Whenever a public API takes a callback, subsequent positional
arguments will be passed to the callback if/when it is called.  This
avoids the proliferation of trivial lambdas implementing closures.
Keyword arguments for the callback are not supported; this is a
conscious design decision, leaving the door open for keyword arguments
to modify the meaning of the API call itself.
�N�)�	constants)�
coroutines)�events)�
exceptions)�futures)�	protocols)�sslproto)�	staggered)�tasks)�
transports)�trsock)�logger)�
BaseEventLoop�dg�?�AF_INET6i�QcCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�+/usr/lib64/python3.8/asyncio/base_events.py�_format_handleJs
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeSs


r!cCsLttd�std��n4z|�tjtjd�Wntk
rFtd��YnXdS)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr"�OSError��sockrrr�_set_reuseport\s

r+c		Cs�ttd�sdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|t�rz|dkrzd}n@t|t�r�|dkr�d}n(zt	|�}Wnt
tfk
r�YdSX|tjkr�tj
g}tr�|�tj�n|g}t|t�r�|�d�}d|k�rdS|D]t}zVt�||�t�rJ|tjk�rJ|||d||||ffWS|||d||ffWSWntk
�rzYnX�q
dS)N�	inet_ptonr��Zidna�%)r#r$�IPPROTO_TCPZIPPROTO_UDP�SOCK_STREAM�
SOCK_DGRAMr�bytesr�int�	TypeErrorr%�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder,r()	�host�port�family�type�protoZflowinfoZscopeidZafs�afrrr�_ipaddr_infogsN
�






rAcCs�t��}|D]*}|d}||kr(g||<||�|�qt|���}g}|dkr||�|dd|d��|dd|d�=|�dd�tj�tj	|��D��|S)z-Interleave list of addrinfo tuples by family.rrNcss|]}|dk	r|VqdS�Nr)�.0�arrr�	<genexpr>�s�z(_interleave_addrinfos.<locals>.<genexpr>)
�collections�OrderedDictr9�list�values�extend�	itertools�chain�
from_iterable�zip_longest)Z	addrinfosZfirst_address_family_countZaddrinfos_by_family�addrr=Zaddrinfos_listsZ	reorderedrrr�_interleave_addrinfos�s"
��rPcCs4|��s"|��}t|ttf�r"dSt�|���dSrB)�	cancelled�	exceptionr�
SystemExit�KeyboardInterruptrZ	_get_loop�stop)�fut�excrrr�_run_until_complete_cb�s
rX�TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|�tjtj	d�dS�Nr)
r=r$r7rr>r1r?r0r&rYr)rrr�_set_nodelay�s
�
�r[cCsdSrBrr)rrrr[�sc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�_SendfileFallbackProtocolcCsht|tj�std��||_|��|_|��|_|j	|_
|��|�|�|j
r^|jj
��|_nd|_dS)Nz.transport should be _FlowControlMixin instance)rrZ_FlowControlMixinr5�
_transportZget_protocol�_protoZ
is_reading�_should_resume_readingZ_protocol_paused�_should_resume_writing�
pause_reading�set_protocol�_loop�
create_future�_write_ready_fut)�self�transprrr�__init__�s


z"_SendfileFallbackProtocol.__init__c�s2|j��rtd��|j}|dkr$dS|IdHdS)NzConnection closed by peer)r]�
is_closing�ConnectionErrorre)rfrVrrr�drain�s
z_SendfileFallbackProtocol.draincCstd��dS)Nz?Invalid state: connection should have been established already.��RuntimeError)rf�	transportrrr�connection_made�sz)_SendfileFallbackProtocol.connection_madecCs@|jdk	r0|dkr$|j�td��n|j�|�|j�|�dS)NzConnection is closed by peer)reZ
set_exceptionrjr^�connection_lost)rfrWrrrrp�s
�z)_SendfileFallbackProtocol.connection_lostcCs |jdk	rdS|jj��|_dSrB)rer]rcrd�rfrrr�
pause_writing�s
z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|j�d�d|_dS)NF)re�
set_resultrqrrr�resume_writing�s
z(_SendfileFallbackProtocol.resume_writingcCstd��dS�Nz'Invalid state: reading should be pausedrl)rf�datarrr�
data_received�sz'_SendfileFallbackProtocol.data_receivedcCstd��dSrurlrqrrr�eof_receivedsz&_SendfileFallbackProtocol.eof_receivedc�sF|j�|j�|jr|j��|jdk	r2|j��|jrB|j��dSrB)	r]rbr^r_�resume_readingre�cancelr`rtrqrrr�restores


z!_SendfileFallbackProtocol.restoreN)�__name__�
__module__�__qualname__rhrkrorprrrtrwrxr{rrrrr\�sr\c@sxeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zdd�Z
dd�Zdd�Zdd�ZdS)�ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_	dS)NrF)
rc�_sockets�
_active_count�_waiters�_protocol_factory�_backlog�_ssl_context�_ssl_handshake_timeout�_serving�_serving_forever_fut)rf�loop�sockets�protocol_factoryZssl_context�backlog�ssl_handshake_timeoutrrrrhszServer.__init__cCsd|jj�d|j�d�S)N�<z	 sockets=�>)�	__class__r|r�rqrrr�__repr__ szServer.__repr__cCs |jdk	st�|jd7_dSrZ)r��AssertionErrorr�rqrrr�_attach#szServer._attachcCs<|jdkst�|jd8_|jdkr8|jdkr8|��dS)Nrr)r�r�r��_wakeuprqrrr�_detach'szServer._detachcCs,|j}d|_|D]}|��s|�|�qdSrB)r��doners)rf�waiters�waiterrrrr�-s
zServer._wakeupc	CsJ|jr
dSd|_|jD].}|�|j�|j�|j||j||j|j�qdS)NT)	r�r�Zlistenr�rc�_start_servingr�r�r�)rfr*rrrr�4s
�zServer._start_servingcCs|jSrB)rcrqrrr�get_loop>szServer.get_loopcCs|jSrB)r�rqrrr�
is_servingAszServer.is_servingcCs"|jdkrdStdd�|jD��S)Nrcss|]}t�|�VqdSrB)r
ZTransportSocket)rC�srrrrEHsz!Server.sockets.<locals>.<genexpr>)r��tuplerqrrrr�Ds
zServer.socketscCsn|j}|dkrdSd|_|D]}|j�|�qd|_|jdk	rX|j��sX|j��d|_|jdkrj|��dS)NFr)	r�rcZ
_stop_servingr�r�r�rzr�r�)rfr�r*rrr�closeJs
�

zServer.closec�s"|��tjd|jd�IdHdS)Nr�r�)r�r�sleeprcrqrrr�
start_serving]szServer.start_servingc	�s�|jdk	rtd|�d���|jdkr4td|�d���|��|j��|_zLz|jIdHWn6tjk
r�z|��|�	�IdHW5�XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z
 is closed)
r�rmr�r�rcrdrZCancelledErrorr��wait_closedrqrrr�
serve_forevercs 

�
zServer.serve_foreverc�s<|jdks|jdkrdS|j��}|j�|�|IdHdSrB)r�r�rcrdr9)rfr�rrrr�xs

zServer.wait_closedN)r|r}r~rhr�r�r�r�r�r�r��propertyr�r�r�r�r�rrrrrs


rc@sPeZdZdd�Zdd�Zdd�Zdd�d	d
�Zdd�Zd
d�Zd�ddd�dd�Z	d�ddddddd�dd�Z
d�dd�Zd�dd�Zd�dd�Z
d�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zejfd7d8�Zd9d:�Zd;d<�Zdd=�d>d?�Z dd=�d@dA�Z!dd=�dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dd=�dJdK�Z&dLdM�Z'dNdO�Z(dPdQ�Z)dRdRdRdRdS�dTdU�Z*d�dVdW�Z+d�ddX�dYdZ�Z,d[d\�Z-d]d^�Z.d_d`�Z/d�dadb�Z0d�ddRdRdRdddddddc�
ddde�Z1d�dfdg�Z2d�ddX�dhdi�Z3djdk�Z4dldm�Z5ddddn�dodp�Z6d�dRdRdRe7ddddq�drds�Z8dRe9j:dRdRdS�dtdu�Z;dvdw�Z<d�e9j=e9j>ddxddddddy�	dzd{�Z?ddd|�d}d~�Z@dd��ZAd�d��ZBd�d��ZCeDjEeDjEeDjEdddRdddd��	d�d��ZFeDjEeDjEeDjEdddRdddd��	d�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRdS)�rcCs�d|_d|_d|_t��|_g|_d|_d|_d|_	t
�d�j|_
d|_|�t���d|_d|_d|_d|_d|_t��|_d|_dS)NrF�	monotonicg�������?)�_timer_cancelled_count�_closed�	_stoppingrF�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�time�get_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debugrZ_is_debug_mode�slow_callback_duration�_current_handle�
_task_factory�"_coroutine_origin_tracking_enabled�&_coroutine_origin_tracking_saved_depth�weakrefZWeakSet�
_asyncgens�_asyncgens_shutdown_calledrqrrrrh�s$

zBaseEventLoop.__init__c	Cs.d|jj�d|���d|���d|���d�	S)Nr�z	 running=z closed=z debug=r�)r�r|�
is_running�	is_closed�	get_debugrqrrrr��s,�zBaseEventLoop.__repr__cCstj|d�S)z,Create a Future object attached to the loop.r�)rZFuturerqrrrrd�szBaseEventLoop.create_futureN)�namecCsN|��|jdkr2tj|||d�}|jrJ|jd=n|�||�}t�||�|S)zDSchedule a coroutine object.

        Return a task object.
        N)r�r����)�
_check_closedr�rr�_source_tracebackZ_set_task_name)rf�coror�Ztaskrrr�create_task�s

zBaseEventLoop.create_taskcCs"|dk	rt|�std��||_dS)awSet a task factory that will be used by loop.create_task().

        If factory is None the default task factory will be set.

        If factory is a callable, it should have a signature matching
        '(loop, coro)', where 'loop' will be a reference to the active
        event loop, 'coro' will be a coroutine object.  The callable
        must return a Future.
        Nz'task factory must be a callable or None)�callabler5r�)rf�factoryrrr�set_task_factory�s
zBaseEventLoop.set_task_factorycCs|jS)z<Return a task factory, or None if the default one is in use.)r�rqrrr�get_task_factory�szBaseEventLoop.get_task_factory)�extra�servercCst�dS)zCreate socket transport.N��NotImplementedError)rfr*�protocolr�r�r�rrr�_make_socket_transport�sz$BaseEventLoop._make_socket_transportFT)�server_side�server_hostnamer�r�r��call_connection_madecCst�dS)zCreate SSL transport.Nr�)rfZrawsockr��
sslcontextr�r�r�r�r�r�r�rrr�_make_ssl_transport�sz!BaseEventLoop._make_ssl_transportcCst�dS)zCreate datagram transport.Nr�)rfr*r��addressr�r�rrr�_make_datagram_transport�sz&BaseEventLoop._make_datagram_transportcCst�dS)zCreate read pipe transport.Nr��rf�piper�r�r�rrr�_make_read_pipe_transport�sz'BaseEventLoop._make_read_pipe_transportcCst�dS)zCreate write pipe transport.Nr�r�rrr�_make_write_pipe_transport�sz(BaseEventLoop._make_write_pipe_transportc	
�st�dS)zCreate subprocess transport.Nr�)
rfr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transport�sz(BaseEventLoop._make_subprocess_transportcCst�dS)z�Write a byte to self-pipe, to wake up the event loop.

        This may be called from a different thread.

        The subclass is responsible for implementing the self-pipe.
        Nr�rqrrr�_write_to_self�szBaseEventLoop._write_to_selfcCst�dS)zProcess selector events.Nr�)rf�
event_listrrr�_process_events�szBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)r�rmrqrrrr��szBaseEventLoop._check_closedcCs*|j�|�|��s&|�|j|���dSrB)r��discardr��call_soon_threadsafer��aclose�rf�agenrrr�_asyncgen_finalizer_hook�sz&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|�d�t|d�|j�|�dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call��source)r��warnings�warn�ResourceWarningr��addr�rrr�_asyncgen_firstiter_hooks
�z&BaseEventLoop._asyncgen_firstiter_hookc�s�d|_t|j�sdSt|j�}|j��tjdd�|D�d|d��IdH}t||�D]*\}}t|t	�rT|�
d|��||d��qTdS)z,Shutdown all active asynchronous generators.TNcSsg|]}|���qSr)r�)rCZagrrr�
<listcomp>sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsr�z;an error occurred during closing of asynchronous generator )�messagerRZasyncgen)r��lenr�rH�clearr�gather�zipr�	Exception�call_exception_handler)rfZ
closing_agensZresults�resultr�rrr�shutdown_asyncgenss"


�
�z BaseEventLoop.shutdown_asyncgenscCs(|��rtd��t��dk	r$td��dS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)r�rmrZ_get_running_looprqrrr�_check_running&s�zBaseEventLoop._check_runningc	Cs�|��|��|�|j�t��|_t��}tj	|j
|jd�z t
�|�|��|jrLq^qLW5d|_d|_t
�d�|�d�tj	|�XdS)zRun until stop() is called.)�	firstiter�	finalizerFN)r�r��_set_coroutine_origin_tracking�_debug�	threading�	get_identr��sys�get_asyncgen_hooks�set_asyncgen_hooksr�r�r�rZ_set_running_loop�	_run_once)rfZold_agen_hooksrrr�run_forever-s$
�


zBaseEventLoop.run_foreverc	Cs�|��|��t�|�}tj||d�}|r4d|_|�t�z<z|�
�Wn*|rp|��rp|��sp|�
��YnXW5|�	t�X|��s�td��|��S)a\Run until the Future is done.

        If the argument is a coroutine, it is wrapped in a Task.

        WARNING: It would be disastrous to call run_until_complete()
        with the same coroutine twice -- it would wrap it in two
        different Tasks and that can't be good.

        Return the Future's result, or raise its exception.
        r�Fz+Event loop stopped before Future completed.)r�r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrXZremove_done_callbackrr�rQrRrmr�)rfZfutureZnew_taskrrr�run_until_completeDs"
z BaseEventLoop.run_until_completecCs
d|_dS)z�Stop running the event loop.

        Every callback already scheduled will still run.  This simply informs
        run_forever to stop looping after a complete iteration.
        TN)r�rqrrrrUjszBaseEventLoop.stopcCsj|��rtd��|jrdS|jr,t�d|�d|_|j��|j��|j	}|dk	rfd|_	|j
dd�dS)z�Close the event loop.

        This clears the queues and shuts down the executor,
        but does not wait for the executor to finish.

        The event loop must not be running.
        z!Cannot close a running event loopNzClose %rTF)�wait)r�rmr�r�r�debugr�r�r�r�Zshutdown�rf�executorrrrr�rs

zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)r�rqrrrr��szBaseEventLoop.is_closedcCs0|��s,|d|��t|d�|��s,|��dS)Nzunclosed event loop r�)r�r�r�r�)rfZ_warnrrr�__del__�szBaseEventLoop.__del__cCs
|jdk	S)z*Returns True if the event loop is running.N)r�rqrrrr��szBaseEventLoop.is_runningcCst��S)z�Return the time according to the event loop's clock.

        This is a float expressed in seconds since an epoch, but the
        epoch, precision, accuracy and drift are unspecified and may
        differ per event loop.
        )r�r�rqrrrr��szBaseEventLoop.time)�contextcGs2|j|��||f|�d|i�}|jr.|jd=|S)a8Arrange for a callback to be called at a given time.

        Return a Handle: an opaque object with a cancel() method that
        can be used to cancel the call.

        The delay can be an int or float, expressed in seconds.  It is
        always relative to the current time.

        Each callback will be called exactly once.  If two callbacks
        are scheduled for exactly the same time, it undefined which
        will be called first.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        r
r�)�call_atr�r�)rfZdelay�callbackr
r��timerrrr�
call_later�s�zBaseEventLoop.call_latercGsZ|��|jr"|��|�|d�t�|||||�}|jrB|jd=t�|j	|�d|_	|S)z|Like call_later(), but uses an absolute time.

        Absolute time corresponds to the event loop's time() method.
        rr�T)
r�r��
_check_thread�_check_callbackr�TimerHandler��heapq�heappushr�)rf�whenrr
r�rrrrr�szBaseEventLoop.call_atcGsB|��|jr"|��|�|d�|�|||�}|jr>|jd=|S)aTArrange for a callback to be called as soon as possible.

        This operates as a FIFO queue: callbacks are called in the
        order in which they are registered.  Each callback will be
        called exactly once.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        �	call_soonr�)r�r�rr�
_call_soonr��rfrr
r�rrrrr�s
zBaseEventLoop.call_sooncCsDt�|�st�|�r$td|�d���t|�s@td|�d|����dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZiscoroutineZiscoroutinefunctionr5r�)rfr�methodrrrr�s
�
��zBaseEventLoop._check_callbackcCs.t�||||�}|jr|jd=|j�|�|S)Nr�)r�Handler�r�r9)rfrr�r
rrrrr�s
zBaseEventLoop._call_sooncCs,|jdkrdSt��}||jkr(td��dS)aoCheck that the current thread is the thread running the event loop.

        Non-thread-safe methods of this class make this assumption and will
        likely behave incorrectly when the assumption is violated.

        Should only be called when (self._debug == True).  The caller is
        responsible for checking this condition for performance reasons.
        NzMNon-thread-safe operation invoked on an event loop other than the current one)r�rrrm)rfZ	thread_idrrrr�s	

�zBaseEventLoop._check_threadcGsB|��|jr|�|d�|�|||�}|jr6|jd=|��|S)z"Like call_soon(), but thread-safe.r�r�)r�r�rrr�r�rrrrr��sz"BaseEventLoop.call_soon_threadsafecGsZ|��|jr|�|d�|dkr@|j}|dkr@tj��}||_tj|j|f|��|d�S)N�run_in_executorr�)	r�r�rr��
concurrentr�ThreadPoolExecutorZwrap_futureZsubmit)rfr�funcr�rrrrs
�zBaseEventLoop.run_in_executorcCs&t|tjj�st�dtd�||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9�)rrrrr�r��DeprecationWarningr�r
rrr�set_default_executors�z"BaseEventLoop.set_default_executorcCs�|�d|��g}|r$|�d|���|r8|�d|���|rL|�d|���|r`|�d|���d�|�}t�d|�|��}t�||||||�}	|��|}
d|�d	|
d
d�d|	��}|
|jkr�t�|�n
t�|�|	S)
N�:zfamily=ztype=zproto=zflags=�, zGet address info %szGetting address info z took g@�@z.3fzms: )	r9�joinrr	r�r$�getaddrinfor��info)rfr;r<r=r>r?�flags�msg�t0�addrinfo�dtrrr�_getaddrinfo_debugs&


z BaseEventLoop._getaddrinfo_debugr�r=r>r?r)c
�s2|jr|j}ntj}|�d|||||||�IdHSrB)r�r.r$r'r)rfr;r<r=r>r?r)Zgetaddr_funcrrrr'2s�zBaseEventLoop.getaddrinfoc�s|�dtj||�IdHSrB)rr$�getnameinfo)rfZsockaddrr)rrrr0<s�zBaseEventLoop.getnameinfo)�fallbackc
�s�|jr|��dkrtd��|�||||�z|�||||�IdHWStjk
rl}z
|s\�W5d}~XYnX|�||||�IdHS)Nrzthe socket must be non-blocking)r�Z
gettimeoutr%�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)rfr*�file�offset�countr1rWrrr�
sock_sendfile@s��zBaseEventLoop.sock_sendfilec�st�d|�d���dS)Nz-syscall sendfile is not available for socket z and file {file!r} combination�rr4�rfr*r6r7r8rrrr3Ns
�z#BaseEventLoop._sock_sendfile_nativec

�s�|r|�|�|rt|tj�ntj}t|�}d}zt|rNt|||�}|dkrNq�t|�d|�}|�d|j|�IdH}	|	szq�|�	||d|	��IdH||	7}q2|W�S|dkr�t|d�r�|�||�XdS)Nr�seek)
r<�minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE�	bytearrayr#�
memoryviewr�readintoZsock_sendall)
rfr*r6r7r8�	blocksize�buf�
total_sent�view�readrrrr5Us,
��
z%BaseEventLoop._sock_sendfile_fallbackcCs�dt|dd�krtd��|jtjks,td��|dk	rbt|t�sLtd�|���|dkrbtd�|���t|t�sztd�|���|dkr�td�|���dS)N�b�modez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r}))	rr%r>r$r1rr4r5�formatr;rrrr2os2
��
����z$BaseEventLoop._check_sendfile_paramsc�s@g}|�|�|\}}}}}	d}
z�tj|||d�}
|
�d�|dk	r�|D]r\}}}}}z|
�|�Wq�WqHtk
r�}z0d|�d|j����}
t|j|
�}|�|�W5d}~XYqHXqH|���|�	|
|	�IdH|
WStk
�r}z"|�|�|
dk	�r
|
�
��W5d}~XYn |
dk	�r4|
�
��YnXdS)z$Create, bind and connect one socket.N�r=r>r?Fz*error while attempting to bind on address �: )r9r$�setblocking�bindr(�strerror�lower�errno�pop�sock_connectr�)rfrZ	addr_infoZlocal_addr_infosZ
my_exceptionsr=Ztype_r?�_r�r*ZladdrrWr*rrr�
_connect_sock�s:



�


zBaseEventLoop._connect_sock)
�sslr=r?r)r*�
local_addrr�r��happy_eyeballs_delay�
interleavec
	�sl|
dk	r|std��|
dkr0|r0|s,td��|}
|dk	rD|sDtd��|dk	rX|
dkrXd}
|dk	sj|dk	�r�|dk	rztd���j||f|tj||�d�IdH}|s�td��|	dk	r܈j|	|tj||�d�IdH��s�td��nd�|
r�t||
�}g�|dk�rH|D]D}z ���|��IdH}W�qvWntk
�r@Y�qYnX�qn.tj���fd	d
�|D�|�d�IdH\}}}|dk�r dd
��D��t	��dk�r��d�nJt
�d��t�fdd
��D���r҈d�td�d�
dd
��D�����n.|dk�rtd��|jtjk�r td|�����j||||
|d�IdH\}}�j�rd|�d�}t�d|||||�||fS)a�Connect to a TCP server.

        Create a streaming transport connection to a given Internet host and
        port: socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_STREAM. protocol_factory must be
        a callable returning a protocol instance.

        This method is a coroutine which will try to establish the connection
        in the background.  When successful, the coroutine returns a
        (transport, protocol) pair.
        Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host�1ssl_handshake_timeout is only meaningful with sslr�8host/port and sock can not be specified at the same time�r=r>r?r)r��!getaddrinfo() returned empty listc3s |]}t��j�|��VqdSrB)�	functools�partialrS)rCr,)r�laddr_infosrfrrrE�s��z2BaseEventLoop.create_connection.<locals>.<genexpr>r�cSsg|]}|D]}|�qqSrr)rC�subrWrrrr��sz3BaseEventLoop.create_connection.<locals>.<listcomp>rc3s|]}t|��kVqdSrB�r�rCrW)�modelrrrEszMultiple exceptions: {}r%css|]}t|�VqdSrBr`rarrrrE
sz5host and port was not specified and no sock specified�"A Stream Socket was expected, got )r�r$z%r connected to %s:%r: (%r, %r))r%�_ensure_resolvedr$r1r(rPrSr
Zstaggered_racer�r�allrHr&r>�_create_connection_transportr��get_extra_inforr	)rfr�r;r<rTr=r?r)r*rUr�r�rVrW�infosr,rRrnr�r)rr^rbrfr�create_connection�s�����


�
��

�
���
�zBaseEventLoop.create_connectionc	�s�|�d�|�}|��}|rHt|t�r*dn|}	|j|||	||||d�}
n|�|||�}
z|IdHWn|
���YnX|
|fS)NF�r�r�r�)rKrdr�boolr�r�r�)rfr*r�rTr�r�r�r�r�r�rnrrrrf%s*
�z*BaseEventLoop._create_connection_transportc
�s�|��rtd��t|dtjj�}|tjjkr:td|����|tjjkr�z|�||||�IdHWStj	k
r�}z
|sx�W5d}~XYnX|s�td|����|�
||||�IdHS)a�Send a file to transport.

        Return the total number of bytes which were sent.

        The method uses high-performance os.sendfile if available.

        file must be a regular file object opened in binary mode.

        offset tells from where to start reading the file. If specified,
        count is the total number of bytes to transmit as opposed to
        sending the file until EOF is reached. File position is updated on
        return or also in case of error in which case file.tell()
        can be used to figure out the number of bytes
        which were sent.

        fallback set to True makes asyncio to manually read and send
        the file when the platform does not support the sendfile syscall
        (e.g. Windows or SSL socket on Unix).

        Raise SendfileNotAvailableError if the system does not support
        sendfile syscall and fallback is False.
        zTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport )rirmrrZ
_SendfileModeZUNSUPPORTEDZ
TRY_NATIVE�_sendfile_nativerr4�_sendfile_fallback)rfrnr6r7r8r1rGrWrrr�sendfile?s4�����zBaseEventLoop.sendfilec�st�d��dS)Nz!sendfile syscall is not supportedr:)rfrgr6r7r8rrrrlns�zBaseEventLoop._sendfile_nativec
�s�|r|�|�|rt|d�nd}t|�}d}t|�}z�|rXt|||�}|dkrX|W�bSt|�d|�}	|�d|j|	�IdH}
|
s�|W�0S|�	�IdH|�
|	d|
��||
7}q6W5|dkr�t|d�r�|�||�|��IdHXdS)Ni@rr<)r<r=r>r\r#r{r?rr@rk�write)rfrgr6r7r8rArBrCr?rDrErrrrmrs*
z BaseEventLoop._sendfile_fallbackrjc
�s�tdkrtd��t|tj�s*td|����t|dd�sFtd|�d���|��}tj|||||||dd�}|�	�|�
|�|�|j|�}	|�|j
�}
z|IdHWn.tk
r�|��|	��|
���YnX|jS)	zzUpgrade transport to TLS.

        Return a new transport that *protocol* should start using
        immediately.
        Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz
transport z  is not supported by start_tls())r�r�)rTrmrZ
SSLContextr5rrdr	ZSSLProtocolrarbrrory�
BaseExceptionr�rzZ_app_transport)rfrnr�r�r�r�r�r�Zssl_protocolZ
conmade_cbZ	resume_cbrrr�	start_tls�sB	�
��
zBaseEventLoop.start_tls)r=r?r)�
reuse_address�
reuse_port�allow_broadcastr*c �s|
dk	r�|
jtjkr"td|
�����s>�s>|s>|s>|s>|s>|	r~t��||||||	d�}d�dd�|��D��}td|�d���|
�d	�d}
�n�s��s�|d
kr�td��||fdff}�n�ttd
��r�|tj	k�r���fD]}|dk	r�t
|t�s�td��qڈ�rx�d
dk�rxz"t
�t�
��j��r.t���WnFtk
�rFYn2tk
�rv}zt�d�|�W5d}~XYnX||f��fff}n�i}d
�fd�ffD]�\}}|dk	�r�t
|t��r�t|�dk�s�td��|j||tj|||d�IdH}|�std��|D]:\}}}}}||f}||k�r0ddg||<||||<�q�q���fdd�|��D�}|�sjtd��g}|tk	�r�|�r�td��ntjdtdd�|D]�\\}}\}}d}
d}
zxtj|tj|d�}
|�r�t|
�|	�r�|
�tj tj!d�|
�d	���r|
�"|���r*|	�s&|�#|
|�IdH|}
Wn^tk
�rl}z |
dk	�rR|
�$�|�%|�W5d}~XYn&|
dk	�r�|
�$��YnX�q��q�|d
�|�}|�&�}|�'|
||
|�}|j(�r��r�t�)d��||�nt�*d�||�z|IdHWn|�$��YnX||fS)zCreate datagram connection.NzA UDP Socket was expected, got )rU�remote_addrr=r?r)rrrsrtr%css$|]\}}|r|�d|��VqdS)�=Nr)rC�k�vrrrrE�sz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zKsocket modifier keyword arguments can not be used when sock is specified. (�)Frzunexpected address family)NN�AF_UNIXzstring is expected)r�z2Unable to check or remove stale UNIX socket %r: %rrr!z2-tuple is expectedrZr[cs8g|]0\}}�r|ddks�r,|ddks||f�qS)rNrr)rC�keyZ	addr_pair�rUrurrr��s�z:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.)�
stacklevelrIz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))+r>r$r2r%�dictr&�itemsrKr#rzrrr5�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr(r�errorr�r�r�rd�_unsetr�r�r"r+r&r'ZSO_BROADCASTrLrQr�r9rdr�r�r(r	) rfr�rUrur=r?r)rrrsrtr*ZoptsZproblemsZr_addrZaddr_pairs_inforO�errZ
addr_infos�idxrhZfamrRZpror�r|rZ
local_addressZremote_addressrWr�r�rnrr}r�create_datagram_endpoint�s*�������
�

��
��
�

����




���z&BaseEventLoop.create_datagram_endpointc
�s\|dd�\}}t|||||f|dd���}	|	dk	r<|	gS|j||||||d�IdHSdS)Nr!r/)rAr')
rfr�r=r>r?r)r�r;r<r(rrrrdLs�zBaseEventLoop._ensure_resolvedc�s8|j||f|tj||d�IdH}|s4td|�d���|S)N)r=r>r)r�zgetaddrinfo(z) returned empty list)rdr$r1r()rfr;r<r=r)rhrrr�_create_server_getaddrinfoXs�z(BaseEventLoop._create_server_getaddrinfor)	r=r)r*r�rTrrrsr�r�c	�s�t|t�rtd��|dk	r*|dkr*td��|dk	s<�dk	�r"|dk	rLtd��|	dkrhtjdkoftjdk}	g}
|dkr|dg}n$t|t�s�t|t	j
j�s�|g}n|}����fdd	�|D�}tj
|d
�i�IdH}ttj�|��}d}�z|D�]}|\}}}}}zt�|||�}Wn8tjk
�rH�j�r@tjd|||d
d�Yq�YnX|
�|�|	�rl|�tjtjd
�|
�rzt|�t�r�|tjk�r�ttd��r�|�tj tj!d
�z|�"|�Wq�t#k
�r�}z t#|j$d||j%�&�f�d�W5d}~XYq�Xq�d
}W5|�s|
D]}|���qXn4|dk�r4td��|j'tj(k�rPtd|����|g}
|
D]}|�)d��qZt*�|
||||�}|�r�|�+�tj,d�d�IdH�j�r�t�-d|�|S)a1Create a TCP server.

        The host parameter can be a string, in that case the TCP server is
        bound to host and port.

        The host parameter can also be a sequence of strings and in that case
        the TCP server is bound to all hosts of the sequence. If a host
        appears multiple times (possibly indirectly e.g. when hostnames
        resolve to the same IP address), the server is only bound once to that
        host.

        Return a Server object which can be used to stop the service.

        This method is a coroutine.
        z*ssl argument must be an SSLContext or NoneNrXrY�posix�cygwinr.csg|]}�j|���d��qS))r=r))r�)rCr;�r=r)r<rfrrr��s�
�z/BaseEventLoop.create_server.<locals>.<listcomp>r�Fz:create_server() failed to create socket.socket(%r, %r, %r)T��exc_info�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedrcrr�z
%r is serving).rrkr5r%r�r�r�platformrrF�abc�Iterablerr��setrKrLrMr�r$r�r�r�warningr9r&r'ZSO_REUSEADDRr+r8rr#r�ZIPV6_V6ONLYrLr(rOrMrNr>r1rKrr�r�r()rfr�r;r<r=r)r*r�rTrrrsr�r�r�ZhostsZfsrhZ	completed�resr@Zsocktyper?Z	canonnameZsar�r�rr�r�
create_server`s�
��
��
�

������
�zBaseEventLoop.create_server)rTr�c�sv|jtjkrtd|����|dk	r.|s.td��|j|||dd|d�IdH\}}|jrn|�d�}t�d|||�||fS)	aHandle an accepted connection.

        This is used by servers that accept connections outside of
        asyncio but that use asyncio to handle connections.

        This method is a coroutine.  When completed, the coroutine
        returns a (transport, protocol) pair.
        rcNrXr.T)r�r�r$z%r handled: (%r, %r))	r>r$r1r%rfr�rgrr	)rfr�r*rTr�rnr�rrr�connect_accepted_socket�s$��
z%BaseEventLoop.connect_accepted_socketc�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz Read pipe %r connected: (%r, %r))rdr�r�r�rr	�fileno�rfr�r�r�r�rnrrr�connect_read_pipe�s�zBaseEventLoop.connect_read_pipec�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz!Write pipe %r connected: (%r, %r))rdr�r�r�rr	r�r�rrr�connect_write_pipes�z BaseEventLoop.connect_write_pipecCs�|g}|dk	r"|�dt|����|dk	rJ|tjkrJ|�dt|����n8|dk	rf|�dt|����|dk	r�|�dt|����t�d�|��dS)Nzstdin=zstdout=stderr=zstdout=zstderr=� )r9r!rrrr	r&)rfr*r�r�r�r(rrr�_log_subprocessszBaseEventLoop._log_subprocess)	r�r�r��universal_newlinesr�r��encoding�errors�textc	�s�t|ttf�std��|r"td��|s.td��|dkr>td��|rJtd��|	dk	rZtd��|
dk	rjtd��|�}
d}|jr�d	|}|�||||�|j|
|d
||||f|�IdH}|jr�|dk	r�t�d||�||
fS)Nzcmd must be a string� universal_newlines must be Falsezshell must be Truer�bufsize must be 0�text must be False�encoding must be None�errors must be Nonezrun shell command %rT�%s: %r)	rr3rr%r�r�r�rr()rfr��cmdr�r�r�r�r�r�r�r�r�r�r��	debug_logrnrrr�subprocess_shellsB��
zBaseEventLoop.subprocess_shellc	�s�|rtd��|rtd��|dkr(td��|r4td��|	dk	rDtd��|
dk	rTtd��|f|}|�}d}|jr�d|��}|�||||�|j||d	||||f|
�IdH}|jr�|dk	r�t�d
||�||fS)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r%r�r�r�rr()rfr�Zprogramr�r�r�r�r�r�r�r�r�r�r�Z
popen_argsr�r�rnrrr�subprocess_execCs@

��
zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use.
        )r�rqrrr�get_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk	rt|�std|����||_dS)a�Set handler as the new event loop exception handler.

        If handler is None, the default exception handler will
        be set.

        If handler is a callable object, it should have a
        signature matching '(loop, context)', where 'loop'
        will be a reference to the active event loop, 'context'
        will be a dict object (see `call_exception_handler()`
        documentation for details about context).
        Nz+A callable object or None is expected, got )r�r5r�)rfZhandlerrrr�set_exception_handlerjsz#BaseEventLoop.set_exception_handlerc	Cs|�d�}|sd}|�d�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}t|�D]�}|dkr|qn||}|dkr�d	�t�|��}d
}||�	�7}n2|dkr�d	�t�|��}d}||�	�7}nt
|�}|�|�d|���qntj
d
�|�|d�dS)aEDefault exception handler.

        This is called when an exception occurs and no exception
        handler is set, and can be called by a custom exception
        handler that wants to defer to the default behavior.

        This default handler logs the error message and other
        context-dependent information.  In debug mode, a truncated
        stack trace is also appended showing where the given object
        (e.g. a handle or future or task) was created, if any.

        The context parameter has the same meaning as in
        `call_exception_handler()`.
        r�z!Unhandled exception in event looprRNFZsource_tracebackZhandle_traceback>r�rRr.z+Object created at (most recent call last):
z+Handle created at (most recent call last):
rJ�
r�)�getr>�
__traceback__r�r��sortedr&�	traceback�format_list�rstriprr9rr�)	rfr
r�rRr�Z	log_linesr|�value�tbrrr�default_exception_handler{s<

���z'BaseEventLoop.default_exception_handlercCs�|jdkrVz|�|�Wq�ttfk
r2�Yq�tk
rRtjddd�Yq�Xn�z|�||�Wn�ttfk
r��Ynttk
r�}zVz|�d||d��Wn:ttfk
r��Yn"tk
r�tjddd�YnXW5d}~XYnXdS)aDCall the current event loop's exception handler.

        The context argument is a dict containing the following keys:

        - 'message': Error message;
        - 'exception' (optional): Exception object;
        - 'future' (optional): Future instance;
        - 'task' (optional): Task instance;
        - 'handle' (optional): Handle instance;
        - 'protocol' (optional): Protocol instance;
        - 'transport' (optional): Transport instance;
        - 'socket' (optional): Socket instance;
        - 'asyncgen' (optional): Asynchronous generator that caused
                                 the exception.

        New keys maybe introduced in the future.

        Note: do not overload this method in an event loop subclass.
        For custom exception handling, use the
        `set_exception_handler()` method.
        Nz&Exception in default exception handlerTr�z$Unhandled error in exception handler)r�rRr
zeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rSrTrprr�)rfr
rWrrrr��s4
���z$BaseEventLoop.call_exception_handlercCs>t|tj�std��|jrdSt|tj�r.t�|j�|�dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrrr��
_cancelledrr�r9�rfrrrr�
_add_callback�s
zBaseEventLoop._add_callbackcCs|�|�|��dS)z6Like _add_callback() but called from a signal handler.N)r�r�r�rrr�_add_callback_signalsafe�s
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)r�r�r�rrr�_timer_handle_cancelled�sz%BaseEventLoop._timer_handle_cancelledc	Cs�t|j�}|tkr`|j|tkr`g}|jD]}|jr<d|_q*|�|�q*t�|�||_d|_n4|jr�|jdjr�|jd8_t�	|j�}d|_q`d}|j
s�|jr�d}n*|jr�|jdj}t
td||���t�}|j�|�}|�|�|��|j}|j�r:|jd}|j|k�r�q:t�	|j�}d|_|j
�|�q�t|j
�}t|�D]|}	|j
��}|j�rf�qL|j�r�zD||_|��}
|��|��|
}||jk�r�t�dt|�|�W5d|_Xn|���qLd}dS)z�Run one full iteration of the event loop.

        This calls all currently ready callbacks, polls for I/O,
        schedules the resulting callbacks, and finally schedules
        'call_later' callbacks.
        FrrNzExecuting %s took %.3f seconds)r�r��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�r9r�heapify�heappopr�r�Z_whenr=�maxr��MAXIMUM_SELECT_TIMEOUTZ	_selectorZselectr�r��range�popleftr�r�Z_runr�rr�r)rfZsched_countZ
new_scheduledrZtimeoutrr�Zend_timeZntodo�ir+r-rrrr�sj
��





�
zBaseEventLoop._run_oncecCsHt|�t|j�krdS|r2t��|_t�tj�nt�|j�||_dSrB)rkr�r�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH�rfZenabledrrrr�Fs���z,BaseEventLoop._set_coroutine_origin_trackingcCs|jSrB)r�rqrrrr�UszBaseEventLoop.get_debugcCs ||_|��r|�|j|�dSrB)r�r�r�r�r�rrrr�XszBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)N)NN)FN)rN)NN)NN)Sr|r}r~rhr�rdr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrUr�r�r�r�rr�r�rrrrrrr�rr#r.r'r0r9r3r5r2rSrirfrnrlrmrqr�r�r$r1rdr�r6Z
AI_PASSIVEr�r�r�r�r�rrr�r�r�r�r�r�r�r�r�rr�r�r�rrrrr�sF���
�
�
�
�
		&	
	�

�
%���
�/�/���	��w��%�"29Nr)rr)r)7�__doc__rFZcollections.abcZconcurrent.futuresrr\rrKr�r$r�rrr�r�rr�r�rT�ImportErrorr.rrrrrrr	r
rrr
�logr�__all__r�r�r#r8r��objectr�rr!r+rArPrXr[ZProtocolr\ZAbstractServerrZAbstractEventLooprrrrr�<module>sd

		
;


DoPK0�\9c��_�_#windows_events.cpython-38.opt-1.pycnu�[���U

e5di��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddlmZd
ZdZdZdZdZdZdZGdd�de
j�ZGdd�de
j�ZGdd�de�ZGdd�de�Z Gdd�de!�Z"Gdd�dej#�Z$Gdd �d ej%�Z&Gd!d"�d"�Z'Gd#d$�d$ej(�Z)e$Z*Gd%d&�d&ej+�Z,Gd'd(�d(ej+�Z-e-Z.dS))z.Selector and proactor event loops for Windows.�N�)�events)�base_subprocess)�futures)�
exceptions)�proactor_events)�selector_events)�tasks)�
windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicy���i�i�g����MbP?g�������?cs^eZdZdZdd��fdd�
Z�fdd�Zdd	�Z�fd
d�Z�fdd
�Z�fdd�Z	�Z
S)�_OverlappedFuturez�Subclass of Future which represents an overlapped operation.

    Cancelling it will immediately cancel the overlapped operation.
    N��loopcs&t�j|d�|jr|jd=||_dS�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr��	__class__��./usr/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt���}|jdk	rD|jjr dnd}|�dd|�d|jjd�d��|S)N�pendingZ	completedrzoverlapped=<z, �#x�>)r�
_repr_inforr"�insert�address�r�info�staterr r!r%7s


 z_OverlappedFuture._repr_infoc
Csr|jdkrdSz|j��WnJtk
rf}z,d||d�}|jrJ|j|d<|j�|�W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failed��message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextr r r!�_cancel_overlapped>s
�
z$_OverlappedFuture._cancel_overlappedcs|��t���S�N)r6rr0�rrr r!r0Nsz_OverlappedFuture.cancelcst��|�|��dSr7)r�
set_exceptionr6�rr-rr r!r9Rsz_OverlappedFuture.set_exceptioncst��|�d|_dSr7)r�
set_resultr�r�resultrr r!r;Vsz_OverlappedFuture.set_result)�__name__�
__module__�__qualname__�__doc__rr%r6r0r9r;�
__classcell__r r rr!r+srcsneZdZdZdd��fdd�
Zdd�Z�fdd	�Zd
d�Zdd
�Z�fdd�Z	�fdd�Z
�fdd�Z�ZS)�_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrcs8t�j|d�|jr|jd=||_||_||_d|_dS)NrrT)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst�|jd�tjkS�Nr)�_winapiZWaitForSingleObjectrDZ
WAIT_OBJECT_0r8r r r!�_pollls�z_BaseWaitHandleFuture._pollcsdt���}|�d|jd���|jdk	rB|��r4dnd}|�|�|jdk	r`|�d|jd���|S)Nzhandle=r#ZsignaledZwaitingzwait_handle=)rr%�appendrDrKrEr(rr r!r%qs



z _BaseWaitHandleFuture._repr_infocCs
d|_dSr7)r�r�futr r r!�_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�|�Wn`tk
r�}zB|jtjkrzd||d�}|jrd|j|d<|j�	|�WY�dSW5d}~XYnX|�
d�dS�NFz$Failed to unregister the wait handler+r/)rFrE�_overlappedZUnregisterWaitr1�winerror�ERROR_IO_PENDINGrr2r3rO�rrHr4r5r r r!�_unregister_wait�s$�
z&_BaseWaitHandleFuture._unregister_waitcs|��t���Sr7)rUrr0r8rr r!r0�sz_BaseWaitHandleFuture.cancelcs|��t��|�dSr7)rUrr9r:rr r!r9�sz#_BaseWaitHandleFuture.set_exceptioncs|��t��|�dSr7)rUrr;r<rr r!r;�sz _BaseWaitHandleFuture.set_result)
r>r?r@rArrKr%rOrUr0r9r;rBr r rr!rC[s
rCcsFeZdZdZdd��fdd�
Zdd�Z�fdd	�Z�fd
d�Z�ZS)�_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a
    _WaitHandleFuture using an event.
    Nrcst�j||||d�d|_dS)Nr)rr�_done_callback)rr�eventrHrrr r!r�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr8r r r!r0�sz_WaitCancelFuture.cancelcs$t��|�|jdk	r |�|�dSr7)rr;rWr<rr r!r;�s
z_WaitCancelFuture.set_resultcs$t��|�|jdk	r |�|�dSr7)rr9rWr:rr r!r9�s
z_WaitCancelFuture.set_exception)	r>r?r@rArr0r;r9rBr r rr!rV�s
rVcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureNrcs<t�j||||d�||_d|_t�dddd�|_d|_dS)NrTF)rr�	_proactorZ_unregister_proactorrQZCreateEvent�_event�
_event_fut)rrrGrH�proactorrrr r!r�s
z_WaitHandleFuture.__init__csF|jdk	r"t�|j�d|_d|_|j�|j�d|_t��|�dSr7)	r\rJ�CloseHandler]r[�_unregisterrrrOrMrr r!rO�s
	z%_WaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�||j�Wn`tk
r�}zB|jtjkr~d||d�}|jrh|j|d<|j	�
|�WY�dSW5d}~XYnX|j�|j|j
�|_dSrP)rFrErQZUnregisterWaitExr\r1rRrSrr2r3r[�_wait_cancelrOr]rTr r r!rU�s(�

�z"_WaitHandleFuture._unregister_wait)r>r?r@rrOrUrBr r rr!rZ�srZc@s<eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZeZ	dS)
�
PipeServerzXClass representing a pipe server.

    This is much like a bound, listening socket.
    cCs,||_t��|_d|_d|_|�d�|_dS�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr'r r r!r�s

zPipeServer.__init__cCs|j|�d�}|_|S)NF)rhrj)r�tmpr r r!�_get_unconnected_pipesz PipeServer._get_unconnected_pipec
Csr|��rdStjtjB}|r&|tjO}t�|j|tjtjBtj	Btj
tjtjtj
tj�}t�|�}|j�|�|Sr7)�closedrJZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperdZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr
ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerg�add)r�first�flags�h�piper r r!rjs(

��
zPipeServer._server_pipe_handlecCs
|jdkSr7)rdr8r r r!rmszPipeServer.closedcCsR|jdk	r|j��d|_|jdk	rN|jD]}|��q*d|_d|_|j��dSr7)rir0rdrg�closerh�clear)rrtr r r!rus




zPipeServer.closeN)
r>r?r@rArrlrjrmru�__del__r r r r!rb�s
rbc@seZdZdZdS)�_WindowsSelectorEventLoopz'Windows version of selector event loop.N)r>r?r@rAr r r r!rx,srxcsHeZdZdZd
�fdd�	Z�fdd�Zdd�Zd	d
�Zddd�Z�Z	S)r
z2Windows version of proactor event loop using IOCP.Ncs|dkrt�}t��|�dSr7)rrr)rr^rr r!r3szProactorEventLoop.__init__c	sXz|�|j�t���W5|jdk	rR|jj}|j��|dk	rL|j�|�d|_XdSr7)	Z_self_reading_futurerr0r[r`�	call_soonZ_loop_self_readingr�run_forever�rrrr r!rz8s

zProactorEventLoop.run_foreverc�s8|j�|�}|IdH}|�}|j||d|id�}||fS)N�addr��extra)r[�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr'�frt�protocol�transr r r!�create_pipe_connectionKs
�z(ProactorEventLoop.create_pipe_connectionc�s.t���d�����fdd�	������gS)Nc
sd}zn|rN|��}�j�|����r4|��WdS��}�j||d�id����}|dkrdWdS�j�|�}Wn�t	k
r�}zF|r�|�
�dkr���d||d��|��n�jr�t
jd|dd�W5d}~XYn2tjk
r�|r�|��YnX|�_|���dS)	Nr|r}rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)�exc_info)r=rg�discardrmrur�rlr[�accept_piper1�filenor3Z_debugrZwarningr�CancelledErrorri�add_done_callback)r�rtr�r4�r'�loop_accept_piper�rZserverr r!r�VsH��
�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rbry)rr�r'r r�r!�start_serving_pipeSs(
z$ProactorEventLoop.start_serving_pipec		�s�|��}
t||||||||f|
|d�|	��}z|
IdHWnDttfk
rT�Yn,tk
r~|��|��IdH�YnX|S)N)�waiterr~)�
create_future�_WindowsSubprocessTransport�
SystemExit�KeyboardInterrupt�
BaseExceptionruZ_wait)rr��args�shell�stdin�stdout�stderr�bufsizer~�kwargsr�Ztranspr r r!�_make_subprocess_transport�s*
���z,ProactorEventLoop._make_subprocess_transport)N)N)
r>r?r@rArrzr�r�r�rBr r rr!r
0s0�r
c@s�eZdZdZd;dd�Zdd�Zdd�Zd	d
�Zd<dd
�Zdd�Z	d=dd�Z
d>dd�Zd?dd�Zd@dd�Z
dAdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdBd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZdCd3d4�Zd5d6�Zd7d8�Zd9d:�ZdS)Drz#Proactor implementation using IOCP.rcCsDd|_g|_t�tjtd|�|_i|_t�	�|_
g|_t�	�|_dSrI)
r2�_resultsrQ�CreateIoCompletionPort�INVALID_HANDLE_VALUErn�_iocp�_cachererfrF�
_unregistered�_stopped_serving)rZconcurrencyr r r!r�s�
zIocpProactor.__init__cCs|jdkrtd��dS)NzIocpProactor is closed)r�rYr8r r r!�
_check_closed�s
zIocpProactor._check_closedcCsFdt|j�dt|j�g}|jdkr0|�d�d|jjd�|�fS)Nzoverlapped#=%sz
result#=%srmz<%s %s>� )�lenr�r�r�rLrr>�join)rr)r r r!�__repr__�s�

zIocpProactor.__repr__cCs
||_dSr7)r2)rrr r r!�set_loop�szIocpProactor.set_loopNcCs |js|�|�|j}g|_|Sr7)r�rK)r�timeoutrkr r r!�select�s

zIocpProactor.selectcCs|j��}|�|�|Sr7)r2r�r;)r�valuerNr r r!�_result�s

zIocpProactor._resultrcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)N�c
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7��	getresultr1rRrQZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTED�ConnectionResetErrorr��r��keyrr4r r r!�finish_recv�s
�z&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocprQ�
Overlappedrn�
isinstance�socketZWSARecvr�ZReadFile�BrokenPipeErrorr��	_register�r�conn�nbytesrrrr�r r r!�recv�s


zIocpProactor.recvcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)Nrc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z+IocpProactor.recv_into.<locals>.finish_recv)r�rQr�rnr�r�ZWSARecvIntor�ZReadFileIntor�r�r�)rr��bufrrrr�r r r!�	recv_into�s


zIocpProactor.recv_intocCs`|�|�t�t�}z|�|��||�Wntk
rH|�d�YSXdd�}|�|||�S)N)r�Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z*IocpProactor.recvfrom.<locals>.finish_recv)	r�rQr�rnZWSARecvFromr�r�r�r�r�r r r!�recvfrom�s


zIocpProactor.recvfromcCs>|�|�t�t�}|�|��|||�dd�}|�|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sends
�z(IocpProactor.sendto.<locals>.finish_send)r�rQr�rnZ	WSASendTor�r�)rr�r�rrr|rr�r r r!�sendto�s



zIocpProactor.sendtocCsZ|�|�t�t�}t|tj�r4|�|��||�n|�|��|�dd�}|�	|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r�s
�z&IocpProactor.send.<locals>.finish_send)
r�rQr�rnr�r�ZWSASendr�Z	WriteFiler�)rr�r�rrrr�r r r!�sends


zIocpProactor.sendcsv|���|��j��t�t�}|����������fdd�}dd�}|�|�|�}||��}t	j
||jd�|S)NcsD|��t�d����}��tjtj|���	��
������fS)Nz@P)r��structZpackr��
setsockoptr��
SOL_SOCKETrQZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)r�r�rr��r��listenerr r!�
finish_accept*s�z*IocpProactor.accept.<locals>.finish_acceptc�s4z|IdHWn tjk
r.|���YnXdSr7)rr�ru)r.r�r r r!�accept_coro3s
z(IocpProactor.accept.<locals>.accept_coror)r��_get_accept_socket�familyrQr�rnZAcceptExr�r�r	Z
ensure_futurer2)rr�rr�r�r.�coror r�r!�accept$s

	
zIocpProactor.acceptc
s��jtjkr4t����|�|j��}|�d�|S|�	��zt�
����j�WnBtk
r�}z$|j
tjkrt����ddkr��W5d}~XYnXt�t�}|����|��fdd�}|�|�|�S)Nrrcs|����tjtjd��SrI)r�r�r�r�rQZSO_UPDATE_CONNECT_CONTEXT�r�r�r�r�r r!�finish_connectVs�z,IocpProactor.connect.<locals>.finish_connect)�typer�Z
SOCK_DGRAMrQZ
WSAConnectr�r2r�r;r�Z	BindLocalr�r1rR�errnoZ	WSAEINVALZgetsocknamer�rnZ	ConnectExr�)rr�r'rN�err�r r�r!�connect@s"



zIocpProactor.connectc		Csb|�|�t�t�}|d@}|d?d@}|�|��t�|���|||dd�dd�}|�|||�S)Nr� rc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sendfileis
�z.IocpProactor.sendfile.<locals>.finish_sendfile)	r�rQr�rnZTransmitFiler��msvcrtZ
get_osfhandler�)	rZsock�file�offset�countrZ
offset_lowZoffset_highr�r r r!�sendfile_s


�	zIocpProactor.sendfilecsJ|���t�t�}|�����}|r0|���S�fdd�}|�|�|�S)Ncs|���Sr7)r�r��rtr r!�finish_accept_pipesz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�rQr�rnZConnectNamedPiper�r�r�)rrtrZ	connectedr�r r�r!r�ts


zIocpProactor.accept_pipec
�srt}zt�|�}WqhWn0tk
rF}z|jtjkr6�W5d}~XYnXt|dt�}t�	|�IdHqt
�|�S)N�)�CONNECT_PIPE_INIT_DELAYrQZConnectPiper1rRZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr	�sleepr
ro)rr'ZdelayrGr4r r r!r�s
zIocpProactor.connect_pipecCs|�||d�S)z�Wait for a handle.

        Return a Future object. The result of the future is True if the wait
        completed, or False if the wait did not complete (on timeout).
        F)�_wait_for_handle)rrGr�r r r!�wait_for_handle�szIocpProactor.wait_for_handlecCs|�|dd�}||_|Src)r�rW)rrXZ
done_callbackrNr r r!ra�szIocpProactor._wait_cancelcs�|��|dkrtj}nt�|d�}t�t�}t�||j	|j
|�}|r\t||||jd��nt
|||||jd���jr~�jd=�fdd�}�|d|f|j|j
<�S)N�@�@rrcs���Sr7)rKr��r�r r!�finish_wait_for_handle�sz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handler)r�rJ�INFINITE�math�ceilrQr�rnZRegisterWaitWithQueuer�r'rVr2rZrr�)rrGr�Z
_is_cancel�msrrHr�r r�r!r��s*
�
�	zIocpProactor._wait_for_handlecCs0||jkr,|j�|�t�|��|jdd�dSrI)rFrprQr�r�r��r�objr r r!r��s
z IocpProactor._register_with_iocpc
Cs�|��t||jd�}|jr$|jd=|jsrz|dd|�}Wn,tk
rf}z|�|�W5d}~XYnX|�|�||||f|j|j	<|Sr)
r�rr2rr"r1r9r;r�r')rrr��callbackr�r�r�r r r!r��s

zIocpProactor._registercCs|��|j�|�dS)a
Unregister an overlapped object.

        Call this method when its future has been cancelled. The event can
        already be signalled (pending in the proactor event queue). It is also
        safe if the event is never signalled (because it was cancelled).
        N)r�r�rLr{r r r!r`�szIocpProactor._unregistercCst�|�}|�d�|SrI)r�r�)rr��sr r r!r��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��nt�|d�}|tkr>td��t�|j|�}|dkrX�qZd}|\}}}}z|j�|�\}}	}
}WnXt	k
r�|j
��r�|j
�dd||||fd��|dtj
fkr�t�|�Yq>YnX|
|jkr�|��q>|��s>z||||	�}Wn:tk
�r@}
z|�|
�|j�|�W5d}
~
XYq>X|�|�|j�|�q>|jD]}	|j�|	jd��q`|j��dS)Nrznegative timeoutr�ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,�status)r��
ValueErrorr�r�rQZGetQueuedCompletionStatusr�r��pop�KeyErrorr2Z	get_debugr3r�rJr_r�r0Zdoner1r9r�rLr;r�r'rv)rr�r�r��errZtransferredr�r'r�rr�r�r�r�r r r!rKsL


��	






zIocpProactor._pollcCs|j�|�dSr7)r�rpr�r r r!�
_stop_serving9szIocpProactor._stop_servingcCs|jdkrdSt|j���D]�\}\}}}}|��r6qt|t�rBqz|��Wqtk
r�}z6|j	dk	r�d||d�}|j
r�|j
|d<|j	�|�W5d}~XYqXqd}t�
�}	|	|}
|jr�|
t�
�kr�t�d|t�
�|	�t�
�|}
|�|�q�g|_t�|j�d|_dS)NzCancelling a future failedr+r/g�?z,%r is running after closing for %.1f seconds)r��listr��itemsZ	cancelledr�rVr0r1r2rr3�time�	monotonicr�debugrKr�rJr_)rr'rNrr�r�r4r5Z
msg_updateZ
start_timeZnext_msgr r r!ru?s@


�
 
�zIocpProactor.closecCs|��dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rArr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rar�r�r�r`r�rKr�rurwr r r r!r�s8








"
 

7/rc@seZdZdd�ZdS)r�c
sPtj|f|||||d�|���_�fdd�}�jj�t�jj��}	|	�|�dS)N)r�r�r�r�r�cs�j��}��|�dSr7)�_procZpollZ_process_exited)r��
returncoder8r r!r�ys
z4_WindowsSubprocessTransport._start.<locals>.callback)	r
�Popenr�r2r[r��intrDr�)
rr�r�r�r�r�r�r�r�r�r r8r!�_startts���z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!r�rsr�c@seZdZeZdS)rN)r>r?r@r�
_loop_factoryr r r r!r�src@seZdZeZdS)rN)r>r?r@r
rr r r r!r�sr)/rArQrJr�r�r�r�r�r�re�rrrrrrr	r
�logr�__all__rnr�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerrCrVrZ�objectrbZBaseSelectorEventLooprxZBaseProactorEventLoopr
rZBaseSubprocessTransportr�rZBaseDefaultEventLoopPolicyrrrr r r r!�<module>sR0J4;e`PK0�\�h���runners.cpython-38.opt-1.pycnu�[���U

e5d�@sBdZddlmZddlmZddlmZdd�dd�Zd	d
�ZdS))�run�)�
coroutines)�events)�tasksN)�debugcCs�t��dk	rtd��t�|�s,td�|���t��}z*t�|�|dk	rR|�
|�|�|�W�Szt
|�|�|���W5t�d�|�	�XXdS)a�Execute the coroutine and return the result.

    This function runs the passed coroutine, taking care of
    managing the asyncio event loop and finalizing asynchronous
    generators.

    This function cannot be called when another asyncio event loop is
    running in the same thread.

    If debug is True, the event loop will be run in debug mode.

    This function always creates a new event loop and closes it at the end.
    It should be used as a main entry point for asyncio programs, and should
    ideally only be called once.

    Example:

        async def main():
            await asyncio.sleep(1)
            print('hello')

        asyncio.run(main())
    Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop�RuntimeErrorrZiscoroutine�
ValueError�formatZnew_event_loopZset_event_loop�close�_cancel_all_tasks�run_until_completeZshutdown_asyncgensZ	set_debug)�mainr�loop�r�'/usr/lib64/python3.8/asyncio/runners.pyrs"�



rcCsvt�|�}|sdS|D]}|��q|�tj||dd���|D]0}|��rNq@|��dk	r@|�d|��|d��q@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)�message�	exception�task)rZ	all_tasksZcancelrZgatherZ	cancelledrZcall_exception_handler)rZ	to_cancelrrrrr6s"

��r)�__all__�rrrrrrrrr�<module>s
.PK0�\���Estaggered.cpython-38.pycnu�[���U

e5dh�
@s�dZdZddlZddlZddlmZddlmZddlmZddlm	Z	dd	�ej
ejgejfej
eejejejej
eejej
efd
�dd�ZdS)
zFSupport for running coroutines in parallel with staggered start times.)�staggered_race�N�)�events)�
exceptions)�locks)�tasks)�loop)�coro_fns�delayr�returnc		�s��p
t���t|��d�d�g�g�tjtjdd���������fdd�����d��}��|�zfd}|t
��kr�t���IdH\}}t
|�}|D]$}|�
�r�|��s�|��r�|���q�ql���fW�S�D]}|�	�q�XdS)a�Run coroutines with staggered start times and take the first to finish.

    This method takes an iterable of coroutine functions. The first one is
    started immediately. From then on, whenever the immediately preceding one
    fails (raises an exception), or when *delay* seconds has passed, the next
    coroutine is started. This continues until one of the coroutines complete
    successfully, in which case all others are cancelled, or until all
    coroutines fail.

    The coroutines provided should be well-behaved in the following way:

    * They should only ``return`` if completed successfully.

    * They should always raise an exception if they did not complete
      successfully. In particular, if they handle cancellation, they should
      probably reraise, like this::

        try:
            # do work
        except asyncio.CancelledError:
            # undo partially completed work
            raise

    Args:
        coro_fns: an iterable of coroutine functions, i.e. callables that
            return a coroutine object when called. Use ``functools.partial`` or
            lambdas to pass arguments.

        delay: amount of time, in seconds, between starting coroutines. If
            ``None``, the coroutines will run sequentially.

        loop: the event loop to use.

    Returns:
        tuple *(winner_result, winner_index, exceptions)* where

        - *winner_result*: the result of the winning coroutine, or ``None``
          if no coroutines won.

        - *winner_index*: the index of the winning coroutine in
          ``coro_fns``, or ``None`` if no coroutines won. If the winning
          coroutine may return None on success, *winner_index* can be used
          to definitively determine whether any coroutine won.

        - *exceptions*: list of exceptions returned by the coroutines.
          ``len(exceptions)`` is equal to the number of coroutines actually
          started, and the order is the same as in ``coro_fns``. The winning
          coroutine's entry is ``None``.

    N)�previous_failedrc	
�sN|dk	r6t�tj��t�|����IdHW5QRXzt��\}}Wntk
r\YdSXt	�
�}���|��}��|�t
��|dks�t���d�t
��|dks�t�z|�IdH}WnLttfk
r��Ynptk
�r}z|�|<|��W5d}~XYn>X�dk�st�|�|�t��D]\}}||k�r,|���q,dS)N�r)�
contextlib�suppress�exceptions_mod�TimeoutErrorrZwait_for�wait�next�
StopIterationr�Event�create_task�append�len�AssertionError�
SystemExit�KeyboardInterrupt�
BaseException�set�	enumerate�cancel)	rZ
this_indexZcoro_fnZthis_failedZ	next_task�result�e�i�t�r
Z
enum_coro_fnsrr�run_one_coroZ
running_tasksZwinner_indexZ
winner_result��)/usr/lib64/python3.8/asyncio/staggered.pyr%Rs4 


z$staggered_race.<locals>.run_one_coror)rZget_running_loopr�typing�Optionalrrrrrrrr�doneZ	cancelledZ	exception)	r	r
rZ
first_taskr#Z
done_countr*�_�dr&r$r'rs,=
�0
r)�__doc__�__all__rr(�rrrrr�Iterable�Callable�	Awaitabler)�floatZAbstractEventLoopZTupleZAny�intZList�	Exceptionrr&r&r&r'�<module>s&����PK0�\��b��subprocess.cpython-38.pycnu�[���U

e5d��@s�dZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ej
Z
ejZejZGd	d
�d
ej
ej�ZGdd�d�Zddddejfd
d�Zddddejd�dd�ZdS))�create_subprocess_exec�create_subprocess_shell�N�)�events)�	protocols)�streams)�tasks)�loggercsXeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Z�ZS)�SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.csHt�j|d�||_d|_|_|_d|_d|_g|_|j	�
�|_dS)N��loopF)�super�__init__�_limit�stdin�stdout�stderr�
_transport�_process_exited�	_pipe_fds�_loopZ
create_future�
_stdin_closed)�self�limitr��	__class__��*/usr/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk	r&|�d|j���|jdk	rB|�d|j���|jdk	r^|�d|j���d�d�|��S)Nzstdin=zstdout=zstderr=z<{}>� )r�__name__r�appendrr�format�join)r�inforrr�__repr__s



z!SubprocessStreamProtocol.__repr__cCs�||_|�d�}|dk	rDtj|j|jd�|_|j�|�|j�	d�|�d�}|dk	r�tj|j|jd�|_
|j
�|�|j�	d�|�d�}|dk	r�tj||d|jd�|_dS)Nr�rr�r)�protocol�readerr)
r�get_pipe_transportr�StreamReaderrrrZ
set_transportrr r�StreamWriterr)r�	transportZstdout_transportZstderr_transportZstdin_transportrrr�connection_made)s,
�
�
�z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk	r6|�|�dS)Nrr&)rrZ	feed_data)r�fd�datar(rrr�pipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs�|dkrN|j}|dk	r|��|�|�|dkr>|j�d�n|j�|�dS|dkr^|j}n|dkrn|j}nd}|dk	r�|dkr�|��n
|�|�||j	kr�|j	�
|�|��dS)Nrrr&)r�closeZconnection_lostrZ
set_resultZ
set_exceptionrrZfeed_eofr�remove�_maybe_close_transport)rr.�exc�piper(rrr�pipe_connection_lostKs*



z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|��dS)NT)rr3�rrrr�process_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|j�dkr$|jr$|j��d|_dS)Nr)�lenrrrr1r7rrrr3js
z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdS�N)rr)r�streamrrr�_get_close_waiteros
z*SubprocessStreamProtocol._get_close_waiter)
r�
__module__�__qualname__�__doc__rr$r-r0r6r8r3r<�
__classcell__rrrrr
s	

r
c@sjeZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ddd�ZdS)�ProcesscCs8||_||_||_|j|_|j|_|j|_|��|_dSr:)rZ	_protocolrrrrZget_pid�pid)rr,r'rrrrruszProcess.__init__cCsd|jj�d|j�d�S)N�<r�>)rrrBr7rrrr$~szProcess.__repr__cCs
|j��Sr:)rZget_returncoder7rrr�
returncode�szProcess.returncodec�s|j��IdHS)z?Wait until the process exit and return the process return code.N)rZ_waitr7rrr�wait�szProcess.waitcCs|j�|�dSr:)r�send_signal)r�signalrrrrG�szProcess.send_signalcCs|j��dSr:)r�	terminater7rrrrI�szProcess.terminatecCs|j��dSr:)r�killr7rrrrJ�szProcess.killc
�s�|j��}|j�|�|r,t�d|t|��z|j��IdHWn8tt	fk
rx}z|rht�d||�W5d}~XYnX|r�t�d|�|j�
�dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r�	get_debugr�writer	�debugr9Zdrain�BrokenPipeError�ConnectionResetErrorr1)r�inputrMr4rrr�_feed_stdin�s 
� zProcess._feed_stdinc�sdSr:rr7rrr�_noop�sz
Process._noopc�s�|j�|�}|dkr|j}n|dks(t�|j}|j��rV|dkrDdnd}t�d||�|�	�IdH}|j��r�|dkrzdnd}t�d||�|�
�|S)Nr&rrrz%r communicate: read %sz%r communicate: close %s)rr)r�AssertionErrorrrrKr	rM�readr1)rr.r,r;�name�outputrrr�_read_stream�s

zProcess._read_streamNc�s�|dk	r|�|�}n|��}|jdk	r2|�d�}n|��}|jdk	rP|�d�}n|��}tj||||jd�IdH\}}}|��IdH||fS)Nrr&r)	rQrRrrWrrZgatherrrF)rrPrrrrrr�communicate�s


�zProcess.communicate)N)rr=r>rr$�propertyrErFrGrIrJrQrRrWrXrrrrrAts	
rAc
�sb�dkrt���ntjdtdd���fdd�}�j||f|||d�|��IdH\}}	t||	��S)N�ZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r&��
stacklevelcst��d�S�Nr%�r
rr%rr�<lambda>�s�z)create_subprocess_shell.<locals>.<lambda>�rrr)r�get_event_loop�warnings�warn�DeprecationWarningZsubprocess_shellrA)
�cmdrrrrr�kwds�protocol_factoryr,r'rr%rr�s$
����r)rrrrrc�sf�dkrt���ntjdtdd���fdd�}�j||f|�|||d�|��IdH\}	}
t|	|
��S)NrZr&r[cst��d�Sr]r^rr%rrr_�s�z(create_subprocess_exec.<locals>.<lambda>r`)rrarbrcrdZsubprocess_execrA)Zprogramrrrrr�argsrfrgr,r'rr%rr�s(
�����r)�__all__�
subprocessrb�rrrr�logr	�PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr
rAZ_DEFAULT_LIMITrrrrrr�<module>s.�bV�
�PK0�\���
		format_helpers.cpython-38.pycnu�[���U

e5dd	�@sdddlZddlZddlZddlZddlZddlmZdd�Zdd�Zdd	�Z	ddd�Z
dd
d�ZdS)�N�)�	constantscCsVt�|�}t�|�r&|j}|j|jfSt|tj�r<t	|j
�St|tj�rRt	|j
�SdS�N)�inspectZunwrapZ
isfunction�__code__�co_filename�co_firstlineno�
isinstance�	functools�partial�_get_function_source�func�
partialmethod)r
�code�r�./usr/lib64/python3.8/asyncio/format_helpers.pyr
s



rcCs8t||d�}t|�}|r4|d|d�d|d��7}|S)Nz at r�:r)�_format_callbackr)r
�args�	func_repr�sourcerrr�_format_callback_sources
rcCsHg}|r|�dd�|D��|r8|�dd�|��D��d�d�|��S)z�Format function arguments and keyword arguments.

    Special case for a single parameter: ('hello',) is formatted as ('hello').
    css|]}t�|�VqdSr��reprlib�repr)�.0�argrrr�	<genexpr>&sz*_format_args_and_kwargs.<locals>.<genexpr>css&|]\}}|�dt�|���VqdS)�=Nr)r�k�vrrrr(sz({})z, )�extend�items�format�join)r�kwargsr"rrr�_format_args_and_kwargssr&�cCs�t|tj�r.t||�|}t|j|j|j|�St|d�rF|j	rF|j	}n t|d�r^|j
r^|j
}nt|�}|t||�7}|r�||7}|S)N�__qualname__�__name__)r	r
rr&rr
r�keywords�hasattrr(r)r)r
rr%�suffixrrrrr,srcCsD|dkrt��j}|dkr tj}tjjt�|�|dd�}|�	�|S)zlReplacement for traceback.extract_stack() that only does the
    necessary work for asyncio debug mode.
    NF)�limit�lookup_lines)
�sys�	_getframe�f_backrZDEBUG_STACK_DEPTH�	traceback�StackSummary�extract�
walk_stack�reverse)�fr-�stackrrr�
extract_stack>s
�r9)r')NN)r
rrr/r2r'rrrr&rr9rrrr�<module>s
PK0�\$��'��base_tasks.cpython-38.opt-1.pycnu�[���U

e5d�	�@sDddlZddlZddlmZddlmZdd�Zdd�Zd	d
�ZdS)�N�)�base_futures)�
coroutinescCsnt�|�}|jrd|d<|�dd|���t�|j�}|�dd|�d��|jdk	rj|�dd	|j���|S)
NZ
cancellingrrzname=%r�zcoro=<�>�z	wait_for=)	rZ_future_repr_infoZ_must_cancel�insertZget_namerZ_format_coroutine�_coroZ_fut_waiter)�task�info�coro�r
�*/usr/lib64/python3.8/asyncio/base_tasks.py�_task_repr_infos

rcCs�g}t|jd�r|jj}n0t|jd�r0|jj}nt|jd�rF|jj}nd}|dk	r�|dk	r�|dk	rt|dkrlq�|d8}|�|�|j}qR|��nH|jdk	r�|jj	}|dk	r�|dk	r�|dkr�q�|d8}|�|j
�|j}q�|S)N�cr_frame�gi_frame�ag_framerr)�hasattrr	rrr�append�f_back�reverse�
_exception�
__traceback__�tb_frame�tb_next)r
�limitZframes�f�tbr
r
r�_task_get_stacks6





rcCs�g}t�}|j|d�D]Z}|j}|j}|j}|j}	||krN|�|�t�|�t�	|||j
�}
|�|||	|
f�q|j}|s�t
d|��|d�n2|dk	r�t
d|�d�|d�nt
d|�d�|d�tj||d�|dk	r�t�|j|�D]}
t
|
|dd�q�dS)	N)rz
No stack for )�filezTraceback for z (most recent call last):z
Stack for �)r�end)�setZ	get_stack�f_lineno�f_code�co_filename�co_name�add�	linecache�
checkcache�getline�	f_globalsrr�print�	traceback�
print_list�format_exception_only�	__class__)r
rr�extracted_list�checkedr�lineno�co�filename�name�line�excr
r
r�_task_print_stack<s,

r9)r(r-r rrrrr9r
r
r
r�<module>s#PK0�\��gF�� unix_events.cpython-38.opt-2.pycnu�[���U

e5dۿ�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZdZe	jdkr�ed��dd�ZGdd�dej�ZGdd�dej�Z Gdd�dej!ej"�Z#Gdd�dej$�Z%Gdd�d�Z&dd�Z'Gdd �d e&�Z(Gd!d"�d"e(�Z)Gd#d$�d$e(�Z*Gd%d&�d&e&�Z+Gd'd(�d(e&�Z,Gd)d*�d*ej-�Z.eZ/e.Z0dS)+�N�)�base_events)�base_subprocess)�	constants)�
coroutines)�events)�
exceptions)�futures)�selector_events)�tasks)�
transports)�logger)�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�MultiLoopChildWatcher�ThreadedChildWatcher�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS�N�)�signum�framerr�+/usr/lib64/python3.8/asyncio/unix_events.py�_sighandler_noop*srcs�eZdZd(�fdd�	Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	d)dd�Z
d*dd�Zd+dd�Zdd�Z
d,ddddd�dd�Zd-dddddd�dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z�ZS).�_UnixSelectorEventLoopNcst��|�i|_dSr)�super�__init__�_signal_handlers)�self�selector��	__class__rrr5sz_UnixSelectorEventLoop.__init__csZt���t��s.t|j�D]}|�|�qn(|jrVtjd|�d�t	|d�|j�
�dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal��source)r�close�sys�
is_finalizing�listr�remove_signal_handler�warnings�warn�ResourceWarning�clear�r�sigr!rrr%9s
�z_UnixSelectorEventLoop.closecCs|D]}|sq|�|�qdSr)�_handle_signal)r�datarrrr�_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac
GsLt�|�st�|�rtd��|�|�|��zt�|j�	��Wn2t
tfk
rt}ztt
|���W5d}~XYnXt�|||d�}||j|<zt�|t�t�|d�Wn�tk
�rF}zz|j|=|j�szt�d�Wn4t
tfk
�r}zt�d|�W5d}~XYnX|jtjk�r4td|�d���n�W5d}~XYnXdS)Nz3coroutines cannot be used with add_signal_handler()F����set_wakeup_fd(-1) failed: %s�sig � cannot be caught)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signalZ
_check_closed�signal�
set_wakeup_fdZ_csock�fileno�
ValueError�OSError�RuntimeError�strrZHandlerr�siginterruptr
�info�errno�EINVAL)rr/�callback�args�exc�handleZnexcrrr�add_signal_handlerNs2
�

z)_UnixSelectorEventLoop.add_signal_handlercCs8|j�|�}|dkrdS|jr*|�|�n
|�|�dSr)r�getZ
_cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{sz%_UnixSelectorEventLoop._handle_signalc
Cs�|�|�z|j|=Wntk
r,YdSX|tjkr@tj}ntj}zt�||�WnBtk
r�}z$|jtj	kr�t
d|�d���n�W5d}~XYnX|js�zt�d�Wn2ttfk
r�}zt
�d|�W5d}~XYnXdS)NFr5r6r3r4T)r8r�KeyErrorr9�SIGINT�default_int_handler�SIG_DFLr=rBrCr>r:r<r
rA)rr/�handlerrFrrrr)�s(

z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|t�std|����|t��kr2td|����dS)Nzsig must be an int, not zinvalid signal number )�
isinstance�intr7r9�
valid_signalsr<r.rrrr8�s
z$_UnixSelectorEventLoop._check_signalcCst|||||�Sr)�_UnixReadPipeTransport�r�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�Sr)�_UnixWritePipeTransportrSrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc	

�s�t����}
|
��std��|��}t||||||||f||d�|	��}|
�|��|j|�z|IdHWnDt	t
fk
r��Yn,tk
r�|��|�
�IdH�YnXW5QRX|S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)r�get_child_watcher�	is_activer>�
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�
SystemExit�KeyboardInterrupt�
BaseExceptionr%Z_wait)
rrUrE�shell�stdin�stdout�stderr�bufsizerW�kwargs�watcherrV�transprrr�_make_subprocess_transport�s8

���
�z1_UnixSelectorEventLoop._make_subprocess_transportcCs|�|j|�dSr)�call_soon_threadsafeZ_process_exited)r�pid�
returncoderkrrrr`�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostname�ssl_handshake_timeoutc	�s
|r|dkr6td��n |dk	r&td��|dk	r6td��|dk	r�|dk	rNtd��t�|�}t�tjtjd�}z |�d�|�||�IdHWq�|���Yq�Xn@|dkr�td��|j	tjks�|j
tjkr�td|����|�d�|j|||||d	�IdH\}}||fS)
Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl�1ssl_handshake_timeout is only meaningful with ssl�3path and sock can not be specified at the same timerFzno path and sock were specified�.A UNIX Domain Stream Socket was expected, got )rs)r<�os�fspath�socket�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr%�family�typeZ_create_connection_transport)	r�protocol_factory�pathrprqrrrs�	transportrUrrr�create_unix_connection�sR���



��
�z-_UnixSelectorEventLoop.create_unix_connection�dT)rq�backlogrprs�
start_servingc
�s�t|t�rtd��|dk	r&|s&td��|dk	�rH|dk	r@td��t�|�}t�tjtj�}|ddkr�z t	�
t�	|�j�r�t�|�WnBt
k
r�Yn0tk
r�}zt�d||�W5d}~XYnXz|�|�Wnltk
�r0}	z8|��|	jtjk�rd|�d�}
ttj|
�d�n�W5d}	~	XYn|���YnXn<|dk�rZtd	��|jtjk�sv|jtjk�r�td
|����|�d�t�||g||||�}|�r�|��tjd|d�IdH|S)
Nz*ssl argument must be an SSLContext or Nonertrur)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrvF)�loop)rO�boolr7r<rwrxryrzr{�stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorr=r
�errorZbindr%rBZ
EADDRINUSEr}r~r|rZServerZ_start_servingr�sleep)rrr�rqr�rprsr��errrF�msgZserverrrr�create_unix_serversn
�
�
�

�
��
�z)_UnixSelectorEventLoop.create_unix_serverc
�s�z
tjWn,tk
r6}zt�d��W5d}~XYnXz|��}Wn2ttjfk
rv}zt�d��W5d}~XYnXzt�|�j	}Wn,t
k
r�}zt�d��W5d}~XYnX|r�|n|}	|	s�dS|��}
|�|
d|||||	d�|
IdHS)Nzos.sendfile() is not availableznot a regular filer)
rw�sendfile�AttributeErrorr�SendfileNotAvailableErrorr;�io�UnsupportedOperation�fstat�st_sizer=r]�_sock_sendfile_native_impl)rrq�file�offset�countrFr;r�Zfsize�	blocksize�futrrr�_sock_sendfile_nativeJs2
��z,_UnixSelectorEventLoop._sock_sendfile_nativec	Cs,|��}	|dk	r|�|�|��r4|�|||�dS|rd||}|dkrd|�|||�|�|�dSzt�|	|||�}
W�nDttfk
r�|dkr�|�	||�|�
|	|j||	||||||�
Y�nbtk
�rj}z�|dk	�r|j
t
jk�rt|�tk	�rtdt
j�}||_|}|dk�rBt�d�}
|�|||�|�|
�n|�|||�|�|�W5d}~XYn�ttfk
�r��Yn�tk
�r�}z|�|||�|�|�W5d}~XYnjX|
dk�r�|�|||�|�|�nD||
7}||
7}|dk�r
|�	||�|�
|	|j||	||||||�
dS)Nrzsocket is not connectedzos.sendfile call failed)r;�
remove_writer�	cancelled�_sock_sendfile_update_fileposZ
set_resultrwr��BlockingIOError�InterruptedError�_sock_add_cancellation_callbackZ
add_writerr�r=rBZENOTCONNr~�ConnectionError�	__cause__rr�Z
set_exceptionrarbrc)rr�Z
registered_fdrqr;r�r�r��
total_sent�fdZsentrF�new_excr�rrrr�as�

�


�
��
�

�z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt�||tj�dS�Nr)rw�lseek�SEEK_SET)rr;r�r�rrrr��sz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcs��fdd�}|�|�dS)Ncs&|��r"���}|dkr"��|�dS)Nr3)r�r;r�)r�r��rrqrr�cb�szB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb)Zadd_done_callback)rr�rqr�rr�rr��sz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)�__name__�
__module__�__qualname__rr%r2rHr0r)r8rXrZrlr`r�r�r�r�r�r��
__classcell__rrr!rr/sF-
 �
�
�
��.��CFrcs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jfdd�Zddd�Zdd�Zdd�Z�ZS) rRiNcs�t��|�||jd<||_||_|��|_||_d|_d|_	t
�|j�j}t
�|�s�t
�|�s�t
�|�s�d|_d|_d|_td��t
�|jd�|j�|jj|�|j�|jj|j|j�|dk	r�|j�tj|d�dS)NrTFz)Pipe transport is for pipes/sockets only.)rr�_extra�_loop�_piper;�_fileno�	_protocol�_closing�_pausedrwr�r�r��S_ISFIFOr��S_ISCHRr<�set_blocking�	call_soon�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)rr�rTrUrVrW�moder!rrr�s:


���
�z_UnixReadPipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���t|jdd�}|jdk	r�|dk	r�t�	||jt
j�}|r�|�d�q�|�d�n |jdk	r�|�d�n
|�d�d�d	�
|��S)
N�closed�closing�fd=�	_selector�polling�idle�open�<{}>� )r"r�r��appendr�r��getattrr�r
�_test_selector_event�	selectorsZ
EVENT_READ�format�join)rrAr r�rrr�__repr__�s(


�

z_UnixReadPipeTransport.__repr__c
Cs�zt�|j|j�}WnDttfk
r,Yn�tk
rX}z|�|d�W5d}~XYn^X|rl|j�	|�nJ|j
��r�t�
d|�d|_|j
�|j�|j
�|jj�|j
�|jd�dS)Nz"Fatal read error on pipe transport�%r was closed by peerT)rw�readr��max_sizer�r�r=�_fatal_errorr�Z
data_receivedr��	get_debugr
rAr��_remove_readerr�Zeof_received�_call_connection_lost)rr1rFrrrr��s
z"_UnixReadPipeTransport._read_readycCs>|js|jrdSd|_|j�|j�|j��r:t�d|�dS)NTz%r pauses reading)r�r�r�r�r�r�r
�debug�rrrr�
pause_reading�s
z$_UnixReadPipeTransport.pause_readingcCsB|js|jsdSd|_|j�|j|j�|j��r>t�d|�dS)NFz%r resumes reading)	r�r�r�r�r�r�r�r
r�r�rrr�resume_readings
z%_UnixReadPipeTransport.resume_readingcCs
||_dSr�r��rrUrrr�set_protocol
sz#_UnixReadPipeTransport.set_protocolcCs|jSrr�r�rrr�get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSr�r�r�rrr�
is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|�d�dSr)r��_closer�rrrr%sz_UnixReadPipeTransport.closecCs,|jdk	r(|d|��t|d�|j��dS�Nzunclosed transport r#�r�r,r%�r�_warnrrr�__del__s
z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r4|jtjkr4|j��rLtjd||dd�n|j�||||j	d��|�
|�dS�Nz%r: %sT��exc_info)�message�	exceptionr�rU)rOr=rBZEIOr�r�r
r��call_exception_handlerr�r��rrFr�rrrr�s
�z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j�|j�|j�|j|�dS�NT)r�r�r�r�r�r��rrFrrrr�-sz_UnixReadPipeTransport._closecCs4z|j�|�W5|j��d|_d|_d|_XdSr�r�r%r�r�Zconnection_lostr�rrrr�2s
z,_UnixReadPipeTransport._call_connection_lost)NN)r�)r�r�r�r�rr�r�r�r�r�r�r�r%r*r+r�r�r�r�r�rrr!rrR�s
rRcs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejfdd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rYNc
s�t��||�||jd<||_|��|_||_t�|_d|_	d|_
t�|j�j
}t�|�}t�|�}t�|�}	|s�|s�|	s�d|_d|_d|_td��t�|jd�|j�|jj|�|	s�|r�tj�d�s�|j�|jj|j|j�|dk	r�|j�tj|d�dS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrr�r�r;r�r��	bytearray�_buffer�
_conn_lostr�rwr�r�r�r�r�r�r<r�r�r�r�r&�platform�
startswithr�r�r	r�)
rr�rTrUrVrWr�Zis_charZis_fifoZ	is_socketr!rrr?s:




�
�z _UnixWritePipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���t|jdd�}|jdk	r�|dk	r�t�	||jt
j�}|r�|�d�n
|�d�|��}|�d|���n |jdk	r�|�d�n
|�d�d	�
d
�|��S)Nr�r�r�r�r�r�zbufsize=r�r�r�)r"r�r�r�r�r�r�r�r
r�r�ZEVENT_WRITE�get_write_buffer_sizer�r�)rrAr r�rhrrrr�ds,


�


z _UnixWritePipeTransport.__repr__cCs
t|j�Sr)�lenr�r�rrrr�|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|j��rt�d|�|jr*|�t��n|��dS)Nr�)r�r�r
rAr�r��BrokenPipeErrorr�rrrr�s

z#_UnixWritePipeTransport._read_readyc
Cs4t|t�rt|�}|sdS|js&|jrN|jtjkr<t�d�|jd7_dS|j	�szt
�|j|�}Wntt
tfk
r�d}YnZttfk
r��YnBtk
r�}z$|jd7_|�|d�WY�dSd}~XYnX|t|�kr�dS|dk�rt|�|d�}|j�|j|j�|j	|7_	|��dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr�#Fatal write error on pipe transport)rOr��
memoryviewr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�rw�writer�r�r�rarbrcr�r�r�Z_add_writer�_write_readyZ_maybe_pause_protocol)rr1�nrFrrrr�s6


z_UnixWritePipeTransport.writec
Cszt�|j|j�}Wn�ttfk
r,Yn�ttfk
rD�Yn�tk
r�}z6|j�	�|j
d7_
|j�|j�|�
|d�W5d}~XYnfX|t|j�kr�|j�	�|j�|j�|��|jr�|j�|j�|�d�dS|dkr�|jd|�=dS)Nrr�r)rwrr�r�r�r�rarbrcr-r�r��_remove_writerr�r�Z_maybe_resume_protocolr�r�r�)rrrFrrrr�s*


z$_UnixWritePipeTransport._write_readycCsdSr�rr�rrr�
can_write_eof�sz%_UnixWritePipeTransport.can_write_eofcCs8|jr
dSd|_|js4|j�|j�|j�|jd�dSr�)r�r�r�r�r�r�r�r�rrr�	write_eof�sz!_UnixWritePipeTransport.write_eofcCs
||_dSrr�r�rrrr��sz$_UnixWritePipeTransport.set_protocolcCs|jSrr�r�rrrr��sz$_UnixWritePipeTransport.get_protocolcCs|jSrr�r�rrrr��sz"_UnixWritePipeTransport.is_closingcCs|jdk	r|js|��dSr)r�r�rr�rrrr%�sz_UnixWritePipeTransport.closecCs,|jdk	r(|d|��t|d�|j��dSr�r�r�rrrr��s
z_UnixWritePipeTransport.__del__cCs|�d�dSr)r�r�rrr�abort�sz_UnixWritePipeTransport.abortr�cCsNt|t�r(|j��r@tjd||dd�n|j�||||jd��|�|�dSr�)	rOr=r�r�r
r�r�r�r�r�rrrr��s

�z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|j�|j�|j��|j�|j�|j�|j|�dSr�)	r�r�r�rr�r-r�r�r�r�rrrr��s
z_UnixWritePipeTransport._closecCs4z|j�|�W5|j��d|_d|_d|_XdSrr�r�rrrr��s
z-_UnixWritePipeTransport._call_connection_lost)NN)r�)N)r�r�r�rr�r�r�rrrrr�r�r�r%r*r+r�rr�r�r�r�rrr!rrY<s"%	#	

rYc@seZdZdd�ZdS)r^c		Ks�d}|tjkrt��\}}zPtj|f||||d|d�|��|_|dk	rh|��t|��d|d�|j_	d}W5|dk	r�|��|��XdS)NF)rdrerfrgZuniversal_newlinesrh�wb)�	buffering)
�
subprocess�PIPEryZ
socketpairr%�Popen�_procr��detachre)	rrErdrerfrgrhriZstdin_wrrr�_starts.
���z_UnixSubprocessTransport._startN)r�r�r�rrrrrr^	sr^c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rcGs
t��dSr��NotImplementedError�rrnrDrErrrr_9s	z&AbstractChildWatcher.add_child_handlercCs
t��dSrr�rrnrrr�remove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs
t��dSrr�rr�rrr�attach_loopLsz AbstractChildWatcher.attach_loopcCs
t��dSrrr�rrrr%VszAbstractChildWatcher.closecCs
t��dSrrr�rrrr\]szAbstractChildWatcher.is_activecCs
t��dSrrr�rrr�	__enter__fszAbstractChildWatcher.__enter__cCs
t��dSrr�r�a�b�crrr�__exit__lszAbstractChildWatcher.__exit__N)
r�r�r�r_rrr%r\rrrrrrr"s
	rcCs2t�|�rt�|�St�|�r*t�|�S|SdSr)rw�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)�statusrrr�_compute_returncodeqs



r#c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dSr)r��
_callbacksr�rrrr�szBaseChildWatcher.__init__cCs|�d�dSr)rr�rrrr%�szBaseChildWatcher.closecCs|jdk	o|j��Sr)r�Z
is_runningr�rrrr\�szBaseChildWatcher.is_activecCs
t��dSrr)r�expected_pidrrr�_do_waitpid�szBaseChildWatcher._do_waitpidcCs
t��dSrrr�rrr�_do_waitpid_all�sz BaseChildWatcher._do_waitpid_allcCsf|jdk	r$|dkr$|jr$t�dt�|jdk	r<|j�tj�||_|dk	rb|�tj|j	�|�
�dS)NzCA loop is being detached from a child watcher with pending handlers)r�r%r*r+�RuntimeWarningr)r9�SIGCHLDrH�	_sig_chldr(rrrrr�s�
zBaseChildWatcher.attach_loopc
Cs^z|��WnLttfk
r&�Yn4tk
rX}z|j�d|d��W5d}~XYnXdS)N�$Unknown exception in SIGCHLD handler)r�r�)r(rarbrcr�r�r�rrrr+�s�zBaseChildWatcher._sig_chldN)
r�r�r�rr%r\r'r(rr+rrrrr$sr$csLeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs|j��t���dSr)r%r-rr%r�r!rrr%�s
zSafeChildWatcher.closecCs|Srrr�rrrr�szSafeChildWatcher.__enter__cCsdSrrrrrrr�szSafeChildWatcher.__exit__cGs||f|j|<|�|�dSr)r%r'rrrrr_�sz"SafeChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdS�NTF�r%rJrrrrr�s
z%SafeChildWatcher.remove_child_handlercCst|j�D]}|�|�q
dSr�r(r%r'rrrrr(�sz SafeChildWatcher._do_waitpid_allcCs�zt�|tj�\}}Wn(tk
r>|}d}t�d|�Yn.X|dkrLdSt|�}|j��rlt�	d||�z|j
�|�\}}Wn.tk
r�|j��r�tjd|dd�YnX|||f|��dS)N��8Unknown child process pid %d, will report returncode 255r�$process %s exited with returncode %s�'Child watcher got an unexpected pid: %rTr�)
rw�waitpid�WNOHANG�ChildProcessErrorr
rr#r�r�r�r%�poprJ)rr&rnr"rorDrErrrr'�s4�

�
�zSafeChildWatcher._do_waitpid)r�r�r�r%rrr_rr(r'r�rrr!rr�srcsPeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs$t���t��|_i|_d|_dSr�)rr�	threadingZLock�_lock�_zombies�_forksr�r!rrrs

zFastChildWatcher.__init__cs"|j��|j��t���dSr)r%r-r:rr%r�r!rrr%s

zFastChildWatcher.closec
Cs0|j� |jd7_|W5QR�SQRXdS)Nr)r9r;r�rrrrszFastChildWatcher.__enter__c	Cs^|j�B|jd8_|js"|js0W5QR�dSt|j�}|j��W5QRXt�d|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)r9r;r:r?r-r
r)rrrrZcollateral_victimsrrrrs
�zFastChildWatcher.__exit__c	Gsf|j�Fz|j�|�}Wn.tk
rF||f|j|<YW5QR�dSXW5QRX|||f|��dSr)r9r:r7rJr%)rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdSr-r.rrrrr5s
z%FastChildWatcher.remove_child_handlerc	Cs�zt�dtj�\}}Wntk
r,YdSX|dkr:dSt|�}|j��z|j�|�\}}WnNtk
r�|j	r�||j
|<|j��r�t
�d||�YW5QR�qd}YnX|j��r�t
�d||�W5QRX|dkr�t
�d||�q|||f|��qdS)Nr3rz,unknown process %s exited with returncode %sr2z8Caught subprocess termination from unknown pid: %d -> %d)rwr4r5r6r#r9r%r7rJr;r:r�r�r
r�r)rrnr"rorDrErrrr(<s@

�

��z FastChildWatcher._do_waitpid_all)r�r�r�rr%rrr_rr(r�rrr!rr�s
rc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rcCsi|_d|_dSr)r%�_saved_sighandlerr�rrrrzszMultiLoopChildWatcher.__init__cCs
|jdk	Sr)r<r�rrrr\~szMultiLoopChildWatcher.is_activecCsT|j��|jdkrdSt�tj�}||jkr:t�d�nt�tj|j�d|_dS)Nz+SIGCHLD handler was changed by outside code)	r%r-r<r9�	getsignalr*r+r
r)rrNrrrr%�s


zMultiLoopChildWatcher.closecCs|Srrr�rrrr�szMultiLoopChildWatcher.__enter__cCsdSrr�r�exc_typeZexc_valZexc_tbrrrr�szMultiLoopChildWatcher.__exit__cGs&t��}|||f|j|<|�|�dSr)r�get_running_loopr%r')rrnrDrEr�rrrr_�sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdSr-r.rrrrr�s
z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk	rdSt�tj|j�|_|jdkr<t�d�tj|_t�tjd�dS)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)r<r9r*r+r
rrMr@rrrrr�s


z!MultiLoopChildWatcher.attach_loopcCst|j�D]}|�|�q
dSrr/rrrrr(�sz%MultiLoopChildWatcher._do_waitpid_allc	Cs�zt�|tj�\}}Wn,tk
rB|}d}t�d|�d}YnX|dkrPdSt|�}d}z|j�|�\}}}Wn$t	k
r�tjd|dd�YnHX|�
�r�t�d||�n.|r�|��r�t�d	||�|j
|||f|��dS)
Nr0r1FrTr3r��%Loop %r that handles pid %r is closedr2)rwr4r5r6r
rr#r%r7rJ�	is_closedr�r�rm)	rr&rnr"roZ	debug_logr�rDrErrrr'�s:�
��z!MultiLoopChildWatcher._do_waitpidc	CsLz|��Wn:ttfk
r&�Yn"tk
rFtjddd�YnXdS)Nr,Tr�)r(rarbrcr
r)rrrrrrr+�szMultiLoopChildWatcher._sig_chldN)r�r�r�rr\r%rrr_rrr(r'r+rrrrrgs%rc@sjeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	j
fd
d�Zdd�Zdd�Z
dd�Zdd�ZdS)rcCst�d�|_i|_dSr�)�	itertoolsr��_pid_counter�_threadsr�rrrr�szThreadedChildWatcher.__init__cCsdSr�rr�rrrr\�szThreadedChildWatcher.is_activecCs|��dSr)�
_join_threadsr�rrrr%�szThreadedChildWatcher.closecCs.dd�t|j���D�}|D]}|��qdS)NcSsg|]}|��r|js|�qSr)�is_alive�daemon��.0�threadrrr�
<listcomp>�s�z6ThreadedChildWatcher._join_threads.<locals>.<listcomp>)r(rE�valuesr�)r�threadsrKrrrrF�sz"ThreadedChildWatcher._join_threadscCs|Srrr�rrrrszThreadedChildWatcher.__enter__cCsdSrrr>rrrrszThreadedChildWatcher.__exit__cCs6dd�t|j���D�}|r2||j�d�t|d�dS)NcSsg|]}|��r|�qSr)rGrIrrrrL	s�z0ThreadedChildWatcher.__del__.<locals>.<listcomp>z0 has registered but not finished child processesr#)r(rErMr"r,)rr�rNrrrr�s�zThreadedChildWatcher.__del__cGsFt��}tj|jdt|j���||||fdd�}||j|<|��dS)Nzwaitpid-T)�target�namerErH)	rr@r8ZThreadr'�nextrDrE�start)rrnrDrEr�rKrrrr_s
�
z&ThreadedChildWatcher.add_child_handlercCsdSr�rrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCs�zt�|d�\}}Wn(tk
r<|}d}t�d|�Yn Xt|�}|��r\t�d||�|��rtt�d||�n|j	|||f|��|j
�|�dS)Nrr0r1r2rA)rwr4r6r
rr#r�r�rBrmrEr7)rr�r&rDrErnr"rorrrr'"s&�
�z ThreadedChildWatcher._do_waitpidN)r�r�r�rr\r%rFrrr*r+r�r_rrr'rrrrr�s
	rcsDeZdZeZ�fdd�Zdd�Z�fdd�Zdd�Zd	d
�Z	�Z
S)�_UnixDefaultEventLoopPolicycst���d|_dSr)rr�_watcherr�r!rrrAs
z$_UnixDefaultEventLoopPolicy.__init__c	CsHtj�8|jdkr:t�|_tt��tj�r:|j�|j	j
�W5QRXdSr)rr9rTrrOr8�current_thread�_MainThreadr�_localr�r�rrr�
_init_watcherEs
�z)_UnixDefaultEventLoopPolicy._init_watchercs6t��|�|jdk	r2tt��tj�r2|j�|�dSr)r�set_event_looprTrOr8rUrVrrr!rrrYMs

�z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|��|jSr)rTrXr�rrrr[[s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk	r|j��||_dSr)rTr%)rrjrrr�set_child_watcheres

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�rZ
_loop_factoryrrXrYr[rZr�rrr!rrS=s
rS)1rBr�rCrwr�r9ryr�rr&r8r*�rrrrrrr	r
rr�logr
�__all__r��ImportErrorrZBaseSelectorEventLooprZ
ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr#r$rrrrZBaseDefaultEventLoopPolicyrSrrrrrr�<module>s^	
	�NO5Ji}Y3PK0�\��M%!%!trsock.cpython-38.opt-1.pycnu�[���U

e5d��@s"ddlZddlZGdd�d�ZdS)�Nc@s�eZdZdZdZejd�dd�Zdd�Zedd	��Z	ed
d��Z
edd
��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z d8d9�Z!d:d;�Z"d<d=�Z#d>d?�Z$d@dA�Z%dBdC�Z&dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,dPdQ�Z-dRdS�Z.dTdU�Z/dVdW�Z0dXdY�Z1dZd[�Z2d\S)]�TransportSocketz�A socket-like wrapper for exposing real transport sockets.

    These objects can be safely returned by APIs like
    `transport.get_extra_info('socket')`.  All potentially disruptive
    operations (like "socket.close()") are banned.
    ��_sock)�sockcCs
||_dS�Nr)�selfr�r�&/usr/lib64/python3.8/asyncio/trsock.py�__init__szTransportSocket.__init__cCstjd|�d�t|d�dS)NzUsing z� on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)�source)�warnings�warn�DeprecationWarning)rZwhatrrr	�_nas

�zTransportSocket._nacCs|jjSr)r�family�rrrr	rszTransportSocket.familycCs|jjSr)r�typerrrr	rszTransportSocket.typecCs|jjSr)r�protorrrr	r"szTransportSocket.protocCs�d|���d|j�d|j�d|j��}|��dkr�z|��}|rN|�d|��}Wntjk
rfYnXz|��}|r�|�d|��}Wntjk
r�YnX|�d�S)	Nz<asyncio.TransportSocket fd=z	, family=z, type=z, proto=���z, laddr=z, raddr=�>)�filenorrr�getsockname�socket�error�getpeername)r�sZladdrZraddrrrr	�__repr__&s $�zTransportSocket.__repr__cCstd��dS)Nz/Cannot serialize asyncio.TransportSocket object)�	TypeErrorrrrr	�__getstate__=szTransportSocket.__getstate__cCs
|j��Sr)rrrrrr	r@szTransportSocket.filenocCs
|j��Sr)r�duprrrr	rCszTransportSocket.dupcCs
|j��Sr)r�get_inheritablerrrr	r FszTransportSocket.get_inheritablecCs|j�|�dSr)r�shutdown)rZhowrrr	r!IszTransportSocket.shutdowncOs|jj||�Sr)r�
getsockopt�r�args�kwargsrrr	r"NszTransportSocket.getsockoptcOs|jj||�dSr)r�
setsockoptr#rrr	r&QszTransportSocket.setsockoptcCs
|j��Sr)rrrrrr	rTszTransportSocket.getpeernamecCs
|j��Sr)rrrrrr	rWszTransportSocket.getsocknamecCs
|j��Sr)r�
getsockbynamerrrr	r'ZszTransportSocket.getsockbynamecCs|�d�|j��S)Nzaccept() method)rr�acceptrrrr	r(]s
zTransportSocket.acceptcOs|�d�|jj||�S)Nzconnect() method)rr�connectr#rrr	r)as
zTransportSocket.connectcOs|�d�|jj||�S)Nzconnect_ex() method)rr�
connect_exr#rrr	r*es
zTransportSocket.connect_excOs|�d�|jj||�S)Nz
bind() method)rr�bindr#rrr	r+is
zTransportSocket.bindcOs|�d�|jj||�S)Nzioctl() method)rr�ioctlr#rrr	r,ms
zTransportSocket.ioctlcOs|�d�|jj||�S)Nzlisten() method)rr�listenr#rrr	r-qs
zTransportSocket.listencCs|�d�|j��S)Nzmakefile() method)rr�makefilerrrr	r.us
zTransportSocket.makefilecOs|�d�|jj||�S)Nzsendfile() method)rr�sendfiler#rrr	r/ys
zTransportSocket.sendfilecCs|�d�|j��S)Nzclose() method)rr�closerrrr	r0}s
zTransportSocket.closecCs|�d�|j��S)Nzdetach() method)rr�detachrrrr	r1�s
zTransportSocket.detachcOs|�d�|jj||�S)Nzsendmsg_afalg() method)rr�
sendmsg_afalgr#rrr	r2�s
zTransportSocket.sendmsg_afalgcOs|�d�|jj||�S)Nzsendmsg() method)rr�sendmsgr#rrr	r3�s
zTransportSocket.sendmsgcOs|�d�|jj||�S)Nzsendto() method)rr�sendtor#rrr	r4�s
zTransportSocket.sendtocOs|�d�|jj||�S)Nz
send() method)rr�sendr#rrr	r5�s
zTransportSocket.sendcOs|�d�|jj||�S)Nzsendall() method)rr�sendallr#rrr	r6�s
zTransportSocket.sendallcOs|�d�|jj||�S)Nzset_inheritable() method)rr�set_inheritabler#rrr	r7�s
zTransportSocket.set_inheritablecCs|�d�|j�|�S)Nzshare() method)rr�share)rZ
process_idrrr	r8�s
zTransportSocket.sharecOs|�d�|jj||�S)Nzrecv_into() method)rr�	recv_intor#rrr	r9�s
zTransportSocket.recv_intocOs|�d�|jj||�S)Nzrecvfrom_into() method)rr�
recvfrom_intor#rrr	r:�s
zTransportSocket.recvfrom_intocOs|�d�|jj||�S)Nzrecvmsg_into() method)rr�recvmsg_intor#rrr	r;�s
zTransportSocket.recvmsg_intocOs|�d�|jj||�S)Nzrecvmsg() method)rr�recvmsgr#rrr	r<�s
zTransportSocket.recvmsgcOs|�d�|jj||�S)Nzrecvfrom() method)rr�recvfromr#rrr	r=�s
zTransportSocket.recvfromcOs|�d�|jj||�S)Nz
recv() method)rr�recvr#rrr	r>�s
zTransportSocket.recvcCs|dkrdStd��dS)Nrz<settimeout(): only 0 timeout is allowed on transport sockets��
ValueError)r�valuerrr	�
settimeout�s
�zTransportSocket.settimeoutcCsdS)Nrrrrrr	�
gettimeout�szTransportSocket.gettimeoutcCs|sdStd��dS)Nz3setblocking(): transport sockets cannot be blockingr?)r�flagrrr	�setblocking�s
�zTransportSocket.setblockingcCs|�d�|j��S�Nzcontext manager protocol)rr�	__enter__rrrr	rG�s
zTransportSocket.__enter__cGs|�d�|jj|�SrF)rr�__exit__)r�errrrr	rH�s
zTransportSocket.__exit__N)3�__name__�
__module__�__qualname__�__doc__�	__slots__rr
r�propertyrrrrrrrr r!r"r&rrr'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>rBrCrErGrHrrrr	rsb


r)rrrrrrr	�<module>sPK0�\�N&coroutines.cpython-38.pycnu�[���U

e5d]"�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddlmZdd	�Ze�ZGd
d�d�Zdd
�Ze�Zdd�ZejejejjefZe�Zdd�Zdd�ZdS))�	coroutine�iscoroutinefunction�iscoroutine�N�)�base_futures)�	constants)�format_helpers)�loggercCs"tjjp tjjo ttj�d��S)NZPYTHONASYNCIODEBUG)�sys�flags�dev_mode�ignore_environment�bool�os�environ�get�rr�*/usr/lib64/python3.8/asyncio/coroutines.py�_is_debug_modes�rc@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zddd
�Zdd�Z	e
dd��Ze
dd��Ze
dd��Z
dd�Ze
dd��Zdd�ZdS)�CoroWrapperNcCsZt�|�st�|�st|��||_||_t�t�	d��|_
t|dd�|_t|dd�|_
dS)Nr�__name__�__qualname__)�inspect�isgeneratorr�AssertionError�gen�funcr�
extract_stackr
�	_getframe�_source_traceback�getattrrr)�selfrrrrr�__init__'szCoroWrapper.__init__cCsJt|�}|jr4|jd}|d|d�d|d��7}d|jj�d|�d�S)	N���z
, created at r�:r�<� �>)�_format_coroutiner�	__class__r)r!�	coro_repr�framerrr�__repr__/s

zCoroWrapper.__repr__cCs|S�Nr�r!rrr�__iter__7szCoroWrapper.__iter__cCs|j�d�Sr-�r�sendr.rrr�__next__:szCoroWrapper.__next__cCs|j�|�Sr-r0)r!�valuerrrr1=szCoroWrapper.sendcCs|j�|||�Sr-)r�throw)r!�typer3�	tracebackrrrr4@szCoroWrapper.throwcCs
|j��Sr-)r�closer.rrrr7CszCoroWrapper.closecCs|jjSr-)r�gi_framer.rrrr8FszCoroWrapper.gi_framecCs|jjSr-)r�
gi_runningr.rrrr9JszCoroWrapper.gi_runningcCs|jjSr-)r�gi_coder.rrrr:NszCoroWrapper.gi_codecCs|Sr-rr.rrr�	__await__RszCoroWrapper.__await__cCs|jjSr-)r�gi_yieldfromr.rrrr<UszCoroWrapper.gi_yieldfromcCs�t|dd�}t|dd�}|dk	r||jdkr||�d�}t|dd�}|rrd�t�|��}|dtj�d	�7}||��7}t�	|�dS)
Nrr8r#z was never yielded fromrr�zB
Coroutine object created at (most recent call last, truncated to z last lines):
)
r �f_lasti�joinr6�format_listrZDEBUG_STACK_DEPTH�rstripr	�error)r!rr+�msg�tbrrr�__del__Ys
zCoroWrapper.__del__)N)NN)r�
__module__rr"r,r/r2r1r4r7�propertyr8r9r:r;r<rErrrrr$s"





rcsztjdtdd�t���r�St���r.��nt����fdd���t�	���t
sX�}nt�����fdd��}t|_|S)z�Decorator to mark coroutines.

    If the coroutine is not yielded from before it is destroyed,
    an error message is logged.
    zN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead�)�
stacklevelc?sr�||�}t�|�s(t�|�s(t|t�r4|EdH}n:z
|j}Wntk
rRYnXt|tj	j
�rn|�EdH}|Sr-)rZisfuturerr�
isinstancerr;�AttributeError�collections�abc�	Awaitable)�args�kw�resZ
await_meth�rrr�corozs
�
zcoroutine.<locals>.corocs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)NrRr#rr)rrr rr)rO�kwds�w�rSrrr�wrapper�szcoroutine.<locals>.wrapper)�warnings�warn�DeprecationWarningrr�isgeneratorfunction�	functools�wraps�typesr�_DEBUG�
_is_coroutine)rrWrrVrris"�


rcCst�|�pt|dd�tkS)z6Return True if func is a decorated coroutine function.r`N)rrr r`rRrrrr�s
�rcCs@t|�tkrdSt|t�r8tt�dkr4t�t|��dSdSdS)z)Return True if obj is a coroutine object.T�dFN)r5�_iscoroutine_typecacherJ�_COROUTINE_TYPES�len�add)�objrrrr�s
rc
stt|�st�t|t���fdd�}dd�}d}t|d�rF|jrF|j}nt|d�r\|jr\|j}||�}|s~||�rz|�d�S|Sd}t|d�r�|jr�|j}nt|d	�r�|jr�|j}|j	p�d
}d}��r0|j
dk	�r0t�|j
��s0t
�|j
�}|dk	r�|\}}|dk�r|�d|�d
|��}	n|�d|�d
|��}	n@|dk	�rV|j}|�d|�d
|��}	n|j}|�d|�d
|��}	|	S)Ncs`�rt�|jdi�St|d�r,|jr,|j}n*t|d�rD|jrD|j}ndt|�j�d�}|�d�S)Nrrrr%z without __name__>z())rZ_format_callbackr�hasattrrrr5)rS�	coro_name�Zis_corowrapperrr�get_name�sz#_format_coroutine.<locals>.get_namecSsHz|jWStk
rBz|jWYStk
r<YYdSXYnXdS)NF)�
cr_runningrKr9)rSrrr�
is_running�sz%_format_coroutine.<locals>.is_running�cr_coder:z runningr8�cr_framez<empty co_filename>rz done, defined at r$z running, defined at z running at )rrrJrrgrmr:r8rn�co_filenamerrr[rZ_get_function_source�f_lineno�co_firstlineno)
rSrjrlZ	coro_coderhZ
coro_frame�filename�lineno�sourcer*rrirr(�sL
	

�
�

r() �__all__Zcollections.abcrLr\rrr
r6r^rXr=rrr�logr	rr_rr�objectr`r�
CoroutineType�
GeneratorTyperM�	Coroutinerc�setrbrr(rrrr�<module>s2E8�PK0�\��Kl�l� base_events.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZzddlZWnek
r�dZYnXddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddl m!Z!dZ"dZ#dZ$e%e	d�Z&dZ'e(�Z)dd�Z*dd�Z+dd�Z,d+dd�Z-d,dd�Z.dd �Z/e%e	d!��r�d"d#�Z0nd$d#�Z0Gd%d&�d&ej1�Z2Gd'd(�d(ej3�Z4Gd)d*�d*ej5�Z6dS)-a�Base implementation of event loop.

The event loop can be broken up into a multiplexer (the part
responsible for notifying us of I/O events) and the event loop proper,
which wraps a multiplexer with functionality for scheduling callbacks,
immediately or at a given time in the future.

Whenever a public API takes a callback, subsequent positional
arguments will be passed to the callback if/when it is called.  This
avoids the proliferation of trivial lambdas implementing closures.
Keyword arguments for the callback are not supported; this is a
conscious design decision, leaving the door open for keyword arguments
to modify the meaning of the API call itself.
�N�)�	constants)�
coroutines)�events)�
exceptions)�futures)�	protocols)�sslproto)�	staggered)�tasks)�
transports)�trsock)�logger)�
BaseEventLoop�dg�?�AF_INET6i�QcCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�+/usr/lib64/python3.8/asyncio/base_events.py�_format_handleJs
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeSs


r!cCsLttd�std��n4z|�tjtjd�Wntk
rFtd��YnXdS)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr"�OSError��sockrrr�_set_reuseport\s

r+c		Cs�ttd�sdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|t�rz|dkrzd}n@t|t�r�|dkr�d}n(zt	|�}Wnt
tfk
r�YdSX|tjkr�tj
g}tr�|�tj�n|g}t|t�r�|�d�}d|k�rdS|D]t}zVt�||�t�rJ|tjk�rJ|||d||||ffWS|||d||ffWSWntk
�rzYnX�q
dS)N�	inet_ptonr��Zidna�%)r#r$�IPPROTO_TCPZIPPROTO_UDP�SOCK_STREAM�
SOCK_DGRAMr�bytesr�int�	TypeErrorr%�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder,r()	�host�port�family�type�protoZflowinfoZscopeidZafs�afrrr�_ipaddr_infogsN
�






rAcCs�t��}|D]*}|d}||kr(g||<||�|�qt|���}g}|dkr||�|dd|d��|dd|d�=|�dd�tj�tj	|��D��|S)z-Interleave list of addrinfo tuples by family.rrNcss|]}|dk	r|VqdS�Nr)�.0�arrr�	<genexpr>�s�z(_interleave_addrinfos.<locals>.<genexpr>)
�collections�OrderedDictr9�list�values�extend�	itertools�chain�
from_iterable�zip_longest)Z	addrinfosZfirst_address_family_countZaddrinfos_by_family�addrr=Zaddrinfos_listsZ	reorderedrrr�_interleave_addrinfos�s"
��rPcCs4|��s"|��}t|ttf�r"dSt�|���dSrB)�	cancelled�	exceptionr�
SystemExit�KeyboardInterruptrZ	_get_loop�stop)�fut�excrrr�_run_until_complete_cb�s
rX�TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|�tjtj	d�dS�Nr)
r=r$r7rr>r1r?r0r&rYr)rrr�_set_nodelay�s
�
�r[cCsdSrBrr)rrrr[�sc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�_SendfileFallbackProtocolcCsht|tj�std��||_|��|_|��|_|j	|_
|��|�|�|j
r^|jj
��|_nd|_dS)Nz.transport should be _FlowControlMixin instance)rrZ_FlowControlMixinr5�
_transportZget_protocol�_protoZ
is_reading�_should_resume_readingZ_protocol_paused�_should_resume_writing�
pause_reading�set_protocol�_loop�
create_future�_write_ready_fut)�self�transprrr�__init__�s


z"_SendfileFallbackProtocol.__init__c�s2|j��rtd��|j}|dkr$dS|IdHdS)NzConnection closed by peer)r]�
is_closing�ConnectionErrorre)rfrVrrr�drain�s
z_SendfileFallbackProtocol.draincCstd��dS)Nz?Invalid state: connection should have been established already.��RuntimeError)rf�	transportrrr�connection_made�sz)_SendfileFallbackProtocol.connection_madecCs@|jdk	r0|dkr$|j�td��n|j�|�|j�|�dS)NzConnection is closed by peer)reZ
set_exceptionrjr^�connection_lost)rfrWrrrrp�s
�z)_SendfileFallbackProtocol.connection_lostcCs |jdk	rdS|jj��|_dSrB)rer]rcrd�rfrrr�
pause_writing�s
z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|j�d�d|_dS)NF)re�
set_resultrqrrr�resume_writing�s
z(_SendfileFallbackProtocol.resume_writingcCstd��dS�Nz'Invalid state: reading should be pausedrl)rf�datarrr�
data_received�sz'_SendfileFallbackProtocol.data_receivedcCstd��dSrurlrqrrr�eof_receivedsz&_SendfileFallbackProtocol.eof_receivedc�sF|j�|j�|jr|j��|jdk	r2|j��|jrB|j��dSrB)	r]rbr^r_�resume_readingre�cancelr`rtrqrrr�restores


z!_SendfileFallbackProtocol.restoreN)�__name__�
__module__�__qualname__rhrkrorprrrtrwrxr{rrrrr\�sr\c@sxeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zdd�Z
dd�Zdd�Zdd�ZdS)�ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_	dS)NrF)
rc�_sockets�
_active_count�_waiters�_protocol_factory�_backlog�_ssl_context�_ssl_handshake_timeout�_serving�_serving_forever_fut)rf�loop�sockets�protocol_factoryZssl_context�backlog�ssl_handshake_timeoutrrrrhszServer.__init__cCsd|jj�d|j�d�S)N�<z	 sockets=�>)�	__class__r|r�rqrrr�__repr__ szServer.__repr__cCs|jd7_dSrZ)r�rqrrr�_attach#szServer._attachcCs.|jd8_|jdkr*|jdkr*|��dS)Nrr)r�r��_wakeuprqrrr�_detach'szServer._detachcCs,|j}d|_|D]}|��s|�|�qdSrB)r��doners)rf�waiters�waiterrrrr�-s
zServer._wakeupc	CsJ|jr
dSd|_|jD].}|�|j�|j�|j||j||j|j�qdS)NT)	r�r�Zlistenr�rc�_start_servingr�r�r�)rfr*rrrr�4s
�zServer._start_servingcCs|jSrB)rcrqrrr�get_loop>szServer.get_loopcCs|jSrB)r�rqrrr�
is_servingAszServer.is_servingcCs"|jdkrdStdd�|jD��S)Nrcss|]}t�|�VqdSrB)r
ZTransportSocket)rC�srrrrEHsz!Server.sockets.<locals>.<genexpr>)r��tuplerqrrrr�Ds
zServer.socketscCsn|j}|dkrdSd|_|D]}|j�|�qd|_|jdk	rX|j��sX|j��d|_|jdkrj|��dS)NFr)	r�rcZ
_stop_servingr�r�r�rzr�r�)rfr�r*rrr�closeJs
�

zServer.closec�s"|��tjd|jd�IdHdS)Nr�r�)r�r�sleeprcrqrrr�
start_serving]szServer.start_servingc	�s�|jdk	rtd|�d���|jdkr4td|�d���|��|j��|_zLz|jIdHWn6tjk
r�z|��|�	�IdHW5�XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z
 is closed)
r�rmr�r�rcrdrZCancelledErrorr��wait_closedrqrrr�
serve_forevercs 

�
zServer.serve_foreverc�s<|jdks|jdkrdS|j��}|j�|�|IdHdSrB)r�r�rcrdr9)rfr�rrrr�xs

zServer.wait_closedN)r|r}r~rhr�r�r�r�r�r�r��propertyr�r�r�r�r�rrrrrs


rc@sPeZdZdd�Zdd�Zdd�Zdd�d	d
�Zdd�Zd
d�Zd�ddd�dd�Z	d�ddddddd�dd�Z
d�dd�Zd�dd�Zd�dd�Z
d�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zejfd7d8�Zd9d:�Zd;d<�Zdd=�d>d?�Z dd=�d@dA�Z!dd=�dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dd=�dJdK�Z&dLdM�Z'dNdO�Z(dPdQ�Z)dRdRdRdRdS�dTdU�Z*d�dVdW�Z+d�ddX�dYdZ�Z,d[d\�Z-d]d^�Z.d_d`�Z/d�dadb�Z0d�ddRdRdRdddddddc�
ddde�Z1d�dfdg�Z2d�ddX�dhdi�Z3djdk�Z4dldm�Z5ddddn�dodp�Z6d�dRdRdRe7ddddq�drds�Z8dRe9j:dRdRdS�dtdu�Z;dvdw�Z<d�e9j=e9j>ddxddddddy�	dzd{�Z?ddd|�d}d~�Z@dd��ZAd�d��ZBd�d��ZCeDjEeDjEeDjEdddRdddd��	d�d��ZFeDjEeDjEeDjEdddRdddd��	d�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRdS)�rcCs�d|_d|_d|_t��|_g|_d|_d|_d|_	t
�d�j|_
d|_|�t���d|_d|_d|_d|_d|_t��|_d|_dS)NrF�	monotonicg�������?)�_timer_cancelled_count�_closed�	_stoppingrF�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�time�get_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debugrZ_is_debug_mode�slow_callback_duration�_current_handle�
_task_factory�"_coroutine_origin_tracking_enabled�&_coroutine_origin_tracking_saved_depth�weakrefZWeakSet�
_asyncgens�_asyncgens_shutdown_calledrqrrrrh�s$

zBaseEventLoop.__init__c	Cs.d|jj�d|���d|���d|���d�	S)Nr�z	 running=z closed=z debug=r�)r�r|�
is_running�	is_closed�	get_debugrqrrrr��s,�zBaseEventLoop.__repr__cCstj|d�S)z,Create a Future object attached to the loop.r�)rZFuturerqrrrrd�szBaseEventLoop.create_futureN)�namecCsN|��|jdkr2tj|||d�}|jrJ|jd=n|�||�}t�||�|S)zDSchedule a coroutine object.

        Return a task object.
        N)r�r����)�
_check_closedr�rr�_source_tracebackZ_set_task_name)rf�coror�Ztaskrrr�create_task�s

zBaseEventLoop.create_taskcCs"|dk	rt|�std��||_dS)awSet a task factory that will be used by loop.create_task().

        If factory is None the default task factory will be set.

        If factory is a callable, it should have a signature matching
        '(loop, coro)', where 'loop' will be a reference to the active
        event loop, 'coro' will be a coroutine object.  The callable
        must return a Future.
        Nz'task factory must be a callable or None)�callabler5r�)rf�factoryrrr�set_task_factory�s
zBaseEventLoop.set_task_factorycCs|jS)z<Return a task factory, or None if the default one is in use.)r�rqrrr�get_task_factory�szBaseEventLoop.get_task_factory)�extra�servercCst�dS)zCreate socket transport.N��NotImplementedError)rfr*�protocolr�r�r�rrr�_make_socket_transport�sz$BaseEventLoop._make_socket_transportFT)�server_side�server_hostnamer�r�r��call_connection_madecCst�dS)zCreate SSL transport.Nr�)rfZrawsockr��
sslcontextr�r�r�r�r�r�r�rrr�_make_ssl_transport�sz!BaseEventLoop._make_ssl_transportcCst�dS)zCreate datagram transport.Nr�)rfr*r��addressr�r�rrr�_make_datagram_transport�sz&BaseEventLoop._make_datagram_transportcCst�dS)zCreate read pipe transport.Nr��rf�piper�r�r�rrr�_make_read_pipe_transport�sz'BaseEventLoop._make_read_pipe_transportcCst�dS)zCreate write pipe transport.Nr�r�rrr�_make_write_pipe_transport�sz(BaseEventLoop._make_write_pipe_transportc	
�st�dS)zCreate subprocess transport.Nr�)
rfr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transport�sz(BaseEventLoop._make_subprocess_transportcCst�dS)z�Write a byte to self-pipe, to wake up the event loop.

        This may be called from a different thread.

        The subclass is responsible for implementing the self-pipe.
        Nr�rqrrr�_write_to_self�szBaseEventLoop._write_to_selfcCst�dS)zProcess selector events.Nr�)rf�
event_listrrr�_process_events�szBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)r�rmrqrrrr��szBaseEventLoop._check_closedcCs*|j�|�|��s&|�|j|���dSrB)r��discardr��call_soon_threadsafer��aclose�rf�agenrrr�_asyncgen_finalizer_hook�sz&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|�d�t|d�|j�|�dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call��source)r��warnings�warn�ResourceWarningr��addr�rrr�_asyncgen_firstiter_hooks
�z&BaseEventLoop._asyncgen_firstiter_hookc�s�d|_t|j�sdSt|j�}|j��tjdd�|D�d|d��IdH}t||�D]*\}}t|t	�rT|�
d|��||d��qTdS)z,Shutdown all active asynchronous generators.TNcSsg|]}|���qSr)r�)rCZagrrr�
<listcomp>sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsr�z;an error occurred during closing of asynchronous generator )�messagerRZasyncgen)r��lenr�rH�clearr�gather�zipr�	Exception�call_exception_handler)rfZ
closing_agensZresults�resultr�rrr�shutdown_asyncgenss"


�
�z BaseEventLoop.shutdown_asyncgenscCs(|��rtd��t��dk	r$td��dS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)r�rmrZ_get_running_looprqrrr�_check_running&s�zBaseEventLoop._check_runningc	Cs�|��|��|�|j�t��|_t��}tj	|j
|jd�z t
�|�|��|jrLq^qLW5d|_d|_t
�d�|�d�tj	|�XdS)zRun until stop() is called.)�	firstiter�	finalizerFN)r�r��_set_coroutine_origin_tracking�_debug�	threading�	get_identr��sys�get_asyncgen_hooks�set_asyncgen_hooksr�r�r�rZ_set_running_loop�	_run_once)rfZold_agen_hooksrrr�run_forever-s$
�


zBaseEventLoop.run_foreverc	Cs�|��|��t�|�}tj||d�}|r4d|_|�t�z<z|�
�Wn*|rp|��rp|��sp|�
��YnXW5|�	t�X|��s�td��|��S)a\Run until the Future is done.

        If the argument is a coroutine, it is wrapped in a Task.

        WARNING: It would be disastrous to call run_until_complete()
        with the same coroutine twice -- it would wrap it in two
        different Tasks and that can't be good.

        Return the Future's result, or raise its exception.
        r�Fz+Event loop stopped before Future completed.)r�r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrXZremove_done_callbackrr�rQrRrmr�)rfZfutureZnew_taskrrr�run_until_completeDs"
z BaseEventLoop.run_until_completecCs
d|_dS)z�Stop running the event loop.

        Every callback already scheduled will still run.  This simply informs
        run_forever to stop looping after a complete iteration.
        TN)r�rqrrrrUjszBaseEventLoop.stopcCsj|��rtd��|jrdS|jr,t�d|�d|_|j��|j��|j	}|dk	rfd|_	|j
dd�dS)z�Close the event loop.

        This clears the queues and shuts down the executor,
        but does not wait for the executor to finish.

        The event loop must not be running.
        z!Cannot close a running event loopNzClose %rTF)�wait)r�rmr�r�r�debugr�r�r�r�Zshutdown�rf�executorrrrr�rs

zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)r�rqrrrr��szBaseEventLoop.is_closedcCs0|��s,|d|��t|d�|��s,|��dS)Nzunclosed event loop r�)r�r�r�r�)rfZ_warnrrr�__del__�szBaseEventLoop.__del__cCs
|jdk	S)z*Returns True if the event loop is running.N)r�rqrrrr��szBaseEventLoop.is_runningcCst��S)z�Return the time according to the event loop's clock.

        This is a float expressed in seconds since an epoch, but the
        epoch, precision, accuracy and drift are unspecified and may
        differ per event loop.
        )r�r�rqrrrr��szBaseEventLoop.time)�contextcGs2|j|��||f|�d|i�}|jr.|jd=|S)a8Arrange for a callback to be called at a given time.

        Return a Handle: an opaque object with a cancel() method that
        can be used to cancel the call.

        The delay can be an int or float, expressed in seconds.  It is
        always relative to the current time.

        Each callback will be called exactly once.  If two callbacks
        are scheduled for exactly the same time, it undefined which
        will be called first.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        rr�)�call_atr�r�)rfZdelay�callbackrr��timerrrr�
call_later�s�zBaseEventLoop.call_latercGsZ|��|jr"|��|�|d�t�|||||�}|jrB|jd=t�|j	|�d|_	|S)z|Like call_later(), but uses an absolute time.

        Absolute time corresponds to the event loop's time() method.
        r
r�T)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushr�)rf�whenrrr�rrrrr
�szBaseEventLoop.call_atcGsB|��|jr"|��|�|d�|�|||�}|jr>|jd=|S)aTArrange for a callback to be called as soon as possible.

        This operates as a FIFO queue: callbacks are called in the
        order in which they are registered.  Each callback will be
        called exactly once.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        �	call_soonr�)r�r�rr�
_call_soonr��rfrrr�rrrrr�s
zBaseEventLoop.call_sooncCsDt�|�st�|�r$td|�d���t|�s@td|�d|����dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZiscoroutineZiscoroutinefunctionr5r�)rfr�methodrrrr�s
�
��zBaseEventLoop._check_callbackcCs.t�||||�}|jr|jd=|j�|�|S)Nr�)rZHandler�r�r9)rfrr�rrrrrr�s
zBaseEventLoop._call_sooncCs,|jdkrdSt��}||jkr(td��dS)aoCheck that the current thread is the thread running the event loop.

        Non-thread-safe methods of this class make this assumption and will
        likely behave incorrectly when the assumption is violated.

        Should only be called when (self._debug == True).  The caller is
        responsible for checking this condition for performance reasons.
        NzMNon-thread-safe operation invoked on an event loop other than the current one)r�r�rrm)rfZ	thread_idrrrr�s	

�zBaseEventLoop._check_threadcGsB|��|jr|�|d�|�|||�}|jr6|jd=|��|S)z"Like call_soon(), but thread-safe.r�r�)r�r�rrr�r�rrrrr��sz"BaseEventLoop.call_soon_threadsafecGsZ|��|jr|�|d�|dkr@|j}|dkr@tj��}||_tj|j|f|��|d�S)N�run_in_executorr�)	r�r�rr��
concurrentr�ThreadPoolExecutorZwrap_futureZsubmit)rfr
�funcr�rrrrs
�zBaseEventLoop.run_in_executorcCs&t|tjj�st�dtd�||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9�)rrrrr�r��DeprecationWarningr�r	rrr�set_default_executors�z"BaseEventLoop.set_default_executorcCs�|�d|��g}|r$|�d|���|r8|�d|���|rL|�d|���|r`|�d|���d�|�}t�d|�|��}t�||||||�}	|��|}
d|�d	|
d
d�d|	��}|
|jkr�t�|�n
t�|�|	S)
N�:zfamily=ztype=zproto=zflags=�, zGet address info %szGetting address info z took g@�@z.3fzms: )	r9�joinrrr�r$�getaddrinfor��info)rfr;r<r=r>r?�flags�msg�t0�addrinfo�dtrrr�_getaddrinfo_debugs&


z BaseEventLoop._getaddrinfo_debugr�r=r>r?r&c
�s2|jr|j}ntj}|�d|||||||�IdHSrB)r�r+r$r$r)rfr;r<r=r>r?r&Zgetaddr_funcrrrr$2s�zBaseEventLoop.getaddrinfoc�s|�dtj||�IdHSrB)rr$�getnameinfo)rfZsockaddrr&rrrr-<s�zBaseEventLoop.getnameinfo)�fallbackc
�s�|jr|��dkrtd��|�||||�z|�||||�IdHWStjk
rl}z
|s\�W5d}~XYnX|�||||�IdHS)Nrzthe socket must be non-blocking)r�Z
gettimeoutr%�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)rfr*�file�offset�countr.rWrrr�
sock_sendfile@s��zBaseEventLoop.sock_sendfilec�st�d|�d���dS)Nz-syscall sendfile is not available for socket z and file {file!r} combination�rr1�rfr*r3r4r5rrrr0Ns
�z#BaseEventLoop._sock_sendfile_nativec

�s�|r|�|�|rt|tj�ntj}t|�}d}zt|rNt|||�}|dkrNq�t|�d|�}|�d|j|�IdH}	|	szq�|�	||d|	��IdH||	7}q2|W�S|dkr�t|d�r�|�||�XdS)Nr�seek)
r9�minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE�	bytearrayr#�
memoryviewr�readintoZsock_sendall)
rfr*r3r4r5�	blocksize�buf�
total_sent�view�readrrrr2Us,
��
z%BaseEventLoop._sock_sendfile_fallbackcCs�dt|dd�krtd��|jtjks,td��|dk	rbt|t�sLtd�|���|dkrbtd�|���t|t�sztd�|���|dkr�td�|���dS)N�b�modez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r}))	rr%r>r$r1rr4r5�formatr8rrrr/os2
��
����z$BaseEventLoop._check_sendfile_paramsc�s@g}|�|�|\}}}}}	d}
z�tj|||d�}
|
�d�|dk	r�|D]r\}}}}}z|
�|�Wq�WqHtk
r�}z0d|�d|j����}
t|j|
�}|�|�W5d}~XYqHXqH|���|�	|
|	�IdH|
WStk
�r}z"|�|�|
dk	�r
|
�
��W5d}~XYn |
dk	�r4|
�
��YnXdS)z$Create, bind and connect one socket.N�r=r>r?Fz*error while attempting to bind on address �: )r9r$�setblocking�bindr(�strerror�lower�errno�pop�sock_connectr�)rfrZ	addr_infoZlocal_addr_infosZ
my_exceptionsr=Ztype_r?�_r�r*ZladdrrWr'rrr�
_connect_sock�s:



�


zBaseEventLoop._connect_sock)
�sslr=r?r&r*�
local_addrr�r��happy_eyeballs_delay�
interleavec
	�sl|
dk	r|std��|
dkr0|r0|s,td��|}
|dk	rD|sDtd��|dk	rX|
dkrXd}
|dk	sj|dk	�r�|dk	rztd���j||f|tj||�d�IdH}|s�td��|	dk	r܈j|	|tj||�d�IdH��s�td��nd�|
r�t||
�}g�|dk�rH|D]D}z ���|��IdH}W�qvWntk
�r@Y�qYnX�qn.tj���fd	d
�|D�|�d�IdH\}}}|dk�r dd
��D��t	��dk�r��d�nJt
�d��t�fdd
��D���r҈d�td�d�
dd
��D�����n.|dk�rtd��|jtjk�r td|�����j||||
|d�IdH\}}�j�rd|�d�}t�d|||||�||fS)a�Connect to a TCP server.

        Create a streaming transport connection to a given Internet host and
        port: socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_STREAM. protocol_factory must be
        a callable returning a protocol instance.

        This method is a coroutine which will try to establish the connection
        in the background.  When successful, the coroutine returns a
        (transport, protocol) pair.
        Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host�1ssl_handshake_timeout is only meaningful with sslr�8host/port and sock can not be specified at the same time�r=r>r?r&r��!getaddrinfo() returned empty listc3s |]}t��j�|��VqdSrB)�	functools�partialrP)rCr))r�laddr_infosrfrrrE�s��z2BaseEventLoop.create_connection.<locals>.<genexpr>r�cSsg|]}|D]}|�qqSrr)rC�subrWrrrr��sz3BaseEventLoop.create_connection.<locals>.<listcomp>rc3s|]}t|��kVqdSrB�r�rCrW)�modelrrrEszMultiple exceptions: {}r"css|]}t|�VqdSrBr]r^rrrrE
sz5host and port was not specified and no sock specified�"A Stream Socket was expected, got )r�r$z%r connected to %s:%r: (%r, %r))r%�_ensure_resolvedr$r1r(rPrPr
Zstaggered_racer�r�allrEr#r>�_create_connection_transportr��get_extra_inforr)rfr�r;r<rQr=r?r&r*rRr�r�rSrT�infosr)rOrnr�r)rr[r_rfr�create_connection�s�����


�
��

�
���
�zBaseEventLoop.create_connectionc	�s�|�d�|�}|��}|rHt|t�r*dn|}	|j|||	||||d�}
n|�|||�}
z|IdHWn|
���YnX|
|fS)NF�r�r�r�)rHrdr�boolr�r�r�)rfr*r�rQr�r�r�r�r�r�rnrrrrc%s*
�z*BaseEventLoop._create_connection_transportc
�s�|��rtd��t|dtjj�}|tjjkr:td|����|tjjkr�z|�||||�IdHWStj	k
r�}z
|sx�W5d}~XYnX|s�td|����|�
||||�IdHS)a�Send a file to transport.

        Return the total number of bytes which were sent.

        The method uses high-performance os.sendfile if available.

        file must be a regular file object opened in binary mode.

        offset tells from where to start reading the file. If specified,
        count is the total number of bytes to transmit as opposed to
        sending the file until EOF is reached. File position is updated on
        return or also in case of error in which case file.tell()
        can be used to figure out the number of bytes
        which were sent.

        fallback set to True makes asyncio to manually read and send
        the file when the platform does not support the sendfile syscall
        (e.g. Windows or SSL socket on Unix).

        Raise SendfileNotAvailableError if the system does not support
        sendfile syscall and fallback is False.
        zTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport )rirmrrZ
_SendfileModeZUNSUPPORTEDZ
TRY_NATIVE�_sendfile_nativerr1�_sendfile_fallback)rfrnr3r4r5r.rDrWrrr�sendfile?s4�����zBaseEventLoop.sendfilec�st�d��dS)Nz!sendfile syscall is not supportedr7)rfrgr3r4r5rrrrins�zBaseEventLoop._sendfile_nativec
�s�|r|�|�|rt|d�nd}t|�}d}t|�}z�|rXt|||�}|dkrX|W�bSt|�d|�}	|�d|j|	�IdH}
|
s�|W�0S|�	�IdH|�
|	d|
��||
7}q6W5|dkr�t|d�r�|�||�|��IdHXdS)Ni@rr9)r9r:r;r\r#r{r<rr=rk�write)rfrgr3r4r5r>r?r@r?rArBrrrrjrs*
z BaseEventLoop._sendfile_fallbackrgc
�s�tdkrtd��t|tj�s*td|����t|dd�sFtd|�d���|��}tj|||||||dd�}|�	�|�
|�|�|j|�}	|�|j
�}
z|IdHWn.tk
r�|��|	��|
���YnX|jS)	zzUpgrade transport to TLS.

        Return a new transport that *protocol* should start using
        immediately.
        Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz
transport z  is not supported by start_tls())r�r�)rQrmrZ
SSLContextr5rrdr	ZSSLProtocolrarbrrory�
BaseExceptionr�rzZ_app_transport)rfrnr�r�r�r�r�r�Zssl_protocolZ
conmade_cbZ	resume_cbrrr�	start_tls�sB	�
��
zBaseEventLoop.start_tls)r=r?r&�
reuse_address�
reuse_port�allow_broadcastr*c �s�|
dk	r�|
jtjkr"td|
�����s>�s>|s>|s>|s>|s>|	r~t��||||||	d�}d�dd�|��D��}td|�d���|
�d	�d}
�n�s��s�|d
kr�td��||fdff}�n�ttd
��r�|tj	k�r���fD]}|dk	r�t
|t�s�td��qڈ�rx�d
dk�rxz"t
�t�
��j��r.t���WnFtk
�rFYn2tk
�rv}zt�d�|�W5d}~XYnX||f��fff}n�i}d
�fd�ffD]�\}}|dk	�r�|j||tj|||d�IdH}|�s�td��|D]:\}}}}}||f}||k�rddg||<||||<�q�q���fdd�|��D�}|�sHtd��g}|tk	�rv|�rftd��ntjdtdd�|D]�\\}}\}}d}
d}
zxtj|tj|d�}
|�r�t|
�|	�r�|
�tjtjd�|
�d	���r�|
�|���r|	�s|� |
|�IdH|}
Wn^tk
�rJ}z |
dk	�r0|
�!�|�"|�W5d}~XYn&|
dk	�rb|
�!��YnX�q|�qz|d
�|�}|�#�}|�$|
||
|�}|j%�r̈�r�t�&d��||�nt�'d�||�z|IdHWn|�!��YnX||fS)zCreate datagram connection.NzA UDP Socket was expected, got )rR�remote_addrr=r?r&rorprqr"css$|]\}}|r|�d|��VqdS)�=Nr)rC�k�vrrrrE�sz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zKsocket modifier keyword arguments can not be used when sock is specified. (�)Frzunexpected address family)NN�AF_UNIXzstring is expected)r�z2Unable to check or remove stale UNIX socket %r: %rrrWrXcs8g|]0\}}�r|ddks�r,|ddks||f�qS)rNrr)rC�keyZ	addr_pair�rRrrrrr��s�z:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.r)�
stacklevelrFz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r>r$r2r%�dictr#�itemsrHr#rwrrr5�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr(r�errorra�_unsetr�r�rr+r&r'ZSO_BROADCASTrIrNr�r9rdr�r�r%r) rfr�rRrrr=r?r&rorprqr*ZoptsZproblemsZr_addrZaddr_pairs_inforO�errZ
addr_infos�idxreZfamrOZpror�ryrZ
local_addressZremote_addressrWr�r�rnrrzr�create_datagram_endpoint�s$�������
�

��
�
�

����




���z&BaseEventLoop.create_datagram_endpointc
�s\|dd�\}}t|||||f|dd���}	|	dk	r<|	gS|j||||||d�IdHSdS)Nrr,)rAr$)
rfr�r=r>r?r&r�r;r<r%rrrraLs�zBaseEventLoop._ensure_resolvedc�s8|j||f|tj||d�IdH}|s4td|�d���|S)N)r=r>r&r�zgetaddrinfo(z) returned empty list)rar$r1r()rfr;r<r=r&rerrr�_create_server_getaddrinfoXs�z(BaseEventLoop._create_server_getaddrinfor)	r=r&r*r�rQrorpr�r�c	�s�t|t�rtd��|dk	r*|dkr*td��|dk	s<�dk	�r"|dk	rLtd��|	dkrhtjdkoftjdk}	g}
|dkr|dg}n$t|t�s�t|t	j
j�s�|g}n|}����fdd	�|D�}tj
|d
�i�IdH}ttj�|��}d}�z|D�]}|\}}}}}zt�|||�}Wn8tjk
�rH�j�r@tjd|||d
d�Yq�YnX|
�|�|	�rl|�tjtjd
�|
�rzt|�t�r�|tjk�r�ttd��r�|�tj tj!d
�z|�"|�Wq�t#k
�r�}z t#|j$d||j%�&�f�d�W5d}~XYq�Xq�d
}W5|�s|
D]}|���qXn4|dk�r4td��|j'tj(k�rPtd|����|g}
|
D]}|�)d��qZt*�|
||||�}|�r�|�+�tj,d�d�IdH�j�r�t�-d|�|S)a1Create a TCP server.

        The host parameter can be a string, in that case the TCP server is
        bound to host and port.

        The host parameter can also be a sequence of strings and in that case
        the TCP server is bound to all hosts of the sequence. If a host
        appears multiple times (possibly indirectly e.g. when hostnames
        resolve to the same IP address), the server is only bound once to that
        host.

        Return a Server object which can be used to stop the service.

        This method is a coroutine.
        z*ssl argument must be an SSLContext or NoneNrUrV�posix�cygwinr.csg|]}�j|���d��qS))r=r&)r�)rCr;�r=r&r<rfrrr��s�
�z/BaseEventLoop.create_server.<locals>.<listcomp>r�Fz:create_server() failed to create socket.socket(%r, %r, %r)T��exc_info�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedr`rr�z
%r is serving).rrhr5r%r�r�r�platformrrF�abc�Iterablerr��setrKrLrMr�r$r�r�r�warningr9r&r'ZSO_REUSEADDRr+r8rr#r�ZIPV6_V6ONLYrIr(rLrJrKr>r1rHrr�r�r%)rfr�r;r<r=r&r*r�rQrorpr�r�r�ZhostsZfsreZ	completed�resr@Zsocktyper?Z	canonnameZsar�r�rr�r�
create_server`s�
��
��
�

������
�zBaseEventLoop.create_server)rQr�c�sv|jtjkrtd|����|dk	r.|s.td��|j|||dd|d�IdH\}}|jrn|�d�}t�d|||�||fS)	aHandle an accepted connection.

        This is used by servers that accept connections outside of
        asyncio but that use asyncio to handle connections.

        This method is a coroutine.  When completed, the coroutine
        returns a (transport, protocol) pair.
        r`NrUr.T)r�r�r$z%r handled: (%r, %r))	r>r$r1r%rcr�rdrr)rfr�r*rQr�rnr�rrr�connect_accepted_socket�s$��
z%BaseEventLoop.connect_accepted_socketc�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz Read pipe %r connected: (%r, %r))rdr�r�r�rr�fileno�rfr�r�r�r�rnrrr�connect_read_pipe�s�zBaseEventLoop.connect_read_pipec�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz!Write pipe %r connected: (%r, %r))rdr�r�r�rrr�r�rrr�connect_write_pipes�z BaseEventLoop.connect_write_pipecCs�|g}|dk	r"|�dt|����|dk	rJ|tjkrJ|�dt|����n8|dk	rf|�dt|����|dk	r�|�dt|����t�d�|��dS)Nzstdin=zstdout=stderr=zstdout=zstderr=� )r9r!rrrrr#)rfr'r�r�r�r%rrr�_log_subprocessszBaseEventLoop._log_subprocess)	r�r�r��universal_newlinesr�r��encoding�errors�textc	�s�t|ttf�std��|r"td��|s.td��|dkr>td��|rJtd��|	dk	rZtd��|
dk	rjtd��|�}
d}|jr�d	|}|�||||�|j|
|d
||||f|�IdH}|jr�|dk	r�t�d||�||
fS)Nzcmd must be a string� universal_newlines must be Falsezshell must be Truer�bufsize must be 0�text must be False�encoding must be None�errors must be Nonezrun shell command %rT�%s: %r)	rr3rr%r�r�r�rr%)rfr��cmdr�r�r�r�r�r�r�r�r�r�r��	debug_logrnrrr�subprocess_shellsB��
zBaseEventLoop.subprocess_shellc	�s�|rtd��|rtd��|dkr(td��|r4td��|	dk	rDtd��|
dk	rTtd��|f|}|�}d}|jr�d|��}|�||||�|j||d	||||f|
�IdH}|jr�|dk	r�t�d
||�||fS)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r%r�r�r�rr%)rfr�Zprogramr�r�r�r�r�r�r�r�r�r�r�Z
popen_argsr�r�rnrrr�subprocess_execCs@

��
zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use.
        )r�rqrrr�get_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk	rt|�std|����||_dS)a�Set handler as the new event loop exception handler.

        If handler is None, the default exception handler will
        be set.

        If handler is a callable object, it should have a
        signature matching '(loop, context)', where 'loop'
        will be a reference to the active event loop, 'context'
        will be a dict object (see `call_exception_handler()`
        documentation for details about context).
        Nz+A callable object or None is expected, got )r�r5r�)rfZhandlerrrr�set_exception_handlerjsz#BaseEventLoop.set_exception_handlerc	Cs|�d�}|sd}|�d�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}t|�D]�}|dkr|qn||}|dkr�d	�t�|��}d
}||�	�7}n2|dkr�d	�t�|��}d}||�	�7}nt
|�}|�|�d|���qntj
d
�|�|d�dS)aEDefault exception handler.

        This is called when an exception occurs and no exception
        handler is set, and can be called by a custom exception
        handler that wants to defer to the default behavior.

        This default handler logs the error message and other
        context-dependent information.  In debug mode, a truncated
        stack trace is also appended showing where the given object
        (e.g. a handle or future or task) was created, if any.

        The context parameter has the same meaning as in
        `call_exception_handler()`.
        r�z!Unhandled exception in event looprRNFZsource_tracebackZhandle_traceback>r�rRr.z+Object created at (most recent call last):
z+Handle created at (most recent call last):
rG�
r�)�getr>�
__traceback__r�r��sortedr#�	traceback�format_list�rstriprr9rr�)	rfrr�rRr�Z	log_linesry�value�tbrrr�default_exception_handler{s<

���z'BaseEventLoop.default_exception_handlercCs�|jdkrVz|�|�Wq�ttfk
r2�Yq�tk
rRtjddd�Yq�Xn�z|�||�Wn�ttfk
r��Ynttk
r�}zVz|�d||d��Wn:ttfk
r��Yn"tk
r�tjddd�YnXW5d}~XYnXdS)aDCall the current event loop's exception handler.

        The context argument is a dict containing the following keys:

        - 'message': Error message;
        - 'exception' (optional): Exception object;
        - 'future' (optional): Future instance;
        - 'task' (optional): Task instance;
        - 'handle' (optional): Handle instance;
        - 'protocol' (optional): Protocol instance;
        - 'transport' (optional): Transport instance;
        - 'socket' (optional): Socket instance;
        - 'asyncgen' (optional): Asynchronous generator that caused
                                 the exception.

        New keys maybe introduced in the future.

        Note: do not overload this method in an event loop subclass.
        For custom exception handling, use the
        `set_exception_handler()` method.
        Nz&Exception in default exception handlerTr�z$Unhandled error in exception handler)r�rRrzeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rSrTrmrr�)rfrrWrrrr��s4
���z$BaseEventLoop.call_exception_handlercCs|jr
dS|j�|�dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N)�
_cancelledr�r9�rfrrrr�
_add_callback�szBaseEventLoop._add_callbackcCs|�|�|��dS)z6Like _add_callback() but called from a signal handler.N)r�r�r�rrr�_add_callback_signalsafe�s
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)r�r�r�rrr�_timer_handle_cancelled�sz%BaseEventLoop._timer_handle_cancelledc	Cs�t|j�}|tkr`|j|tkr`g}|jD]}|jr<d|_q*|�|�q*t�|�||_d|_n4|jr�|jdjr�|jd8_t�	|j�}d|_q`d}|j
s�|jr�d}n*|jr�|jdj}t
td||���t�}|j�|�}|�|�|��|j}|j�r:|jd}|j|k�r�q:t�	|j�}d|_|j
�|�q�t|j
�}t|�D]|}	|j
��}|j�rf�qL|j�r�zD||_|��}
|��|��|
}||jk�r�t�dt|�|�W5d|_Xn|���qLd}dS)z�Run one full iteration of the event loop.

        This calls all currently ready callbacks, polls for I/O,
        schedules the resulting callbacks, and finally schedules
        'call_later' callbacks.
        FrrNzExecuting %s took %.3f seconds)r�r��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�r9r�heapify�heappopr�r�Z_whenr:�maxr��MAXIMUM_SELECT_TIMEOUTZ	_selectorZselectr�r��range�popleftr�r�Z_runr�rr�r)rfZsched_countZ
new_scheduledrZtimeoutrr�Zend_timeZntodo�ir(r*rrrr�sj
��





�
zBaseEventLoop._run_oncecCsHt|�t|j�krdS|r2t��|_t�tj�nt�|j�||_dSrB)rhr�r�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH�rfZenabledrrrr�Fs���z,BaseEventLoop._set_coroutine_origin_trackingcCs|jSrB)r�rqrrrr�UszBaseEventLoop.get_debugcCs ||_|��r|�|j|�dSrB)r�r�r�r�r�rrrr�XszBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)N)NN)FN)rN)NN)NN)Sr|r}r~rhr�rdr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrUr�r�r�r�rr�r�rr
rrrrr�rr r+r$r-r6r0r2r/rPrfrcrkrirjrnr�r�r$r1rar�r6Z
AI_PASSIVEr�r�r�r�r�rrr�r�r�r�r�r�r�r�r�rr�r�r�rrrrr�sF���
�
�
�
�
		&	
	�

�
%���
�/�/���	��w��%�"29Nr)rr)r)7�__doc__rFZcollections.abcZconcurrent.futuresrrYrrKr�r$r~rr�r�r�rr�r�rQ�ImportErrorr.rrrrrrr	r
rrr
�logr�__all__r�r�r#r8r��objectr�rr!r+rArPrXr[ZProtocolr\ZAbstractServerrZAbstractEventLooprrrrr�<module>sd

		
;


DoPK0�\��?�?locks.cpython-38.opt-1.pycnu�[���U

e5d|C�@s�dZdZddlZddlZddlZddlmZddlmZddlmZddlm	Z	Gd	d
�d
�Z
Gdd�d�ZGd
d�de�ZGdd�d�Z
Gdd�de�ZGdd�de�ZGdd�de�ZdS)zSynchronization primitives.)�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�events)�futures)�
exceptions)�
coroutinesc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ContextManagera\Context manager.

    This enables the following idiom for acquiring and releasing a
    lock around a block:

        with (yield from lock):
            <block>

    while failing loudly when accidentally using:

        with lock:
            <block>

    Deprecated, use 'async with' statement:
        async with lock:
            <block>
    cCs
||_dS�N)�_lock)�self�lock�r�%/usr/lib64/python3.8/asyncio/locks.py�__init__"sz_ContextManager.__init__cCsdSr
r�rrrr�	__enter__%sz_ContextManager.__enter__cGsz|j��W5d|_XdSr
)r�release�r�argsrrr�__exit__*sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__�__doc__rrrrrrrrsrc@sReZdZdd�Zdd�Zejdd��Zej	e_	dd�Z
d	d
�Zdd�Zd
d�Z
dS)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeErrorrrrrr2s�z_ContextManagerMixin.__enter__cGsdSr
rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd�|��EdHt|�S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead���
stacklevel)�warnings�warn�DeprecationWarning�acquirerrrrr�__iter__;s�z_ContextManagerMixin.__iter__c�s|��IdHt|�Sr
)r&rrrrrZ
__acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd�|����S)Nz='with await lock' is deprecated use 'async with lock' insteadr r!)r#r$r%�!_ContextManagerMixin__acquire_ctx�	__await__rrrrr)Ys
�z_ContextManagerMixin.__await__c�s|��IdHdSr
)r&rrrr�
__aenter__`sz_ContextManagerMixin.__aenter__c�s|��dSr
)r)r�exc_type�exc�tbrrr�	__aexit__fsz_ContextManagerMixin.__aexit__N)rrrrr�types�	coroutiner'rZ
_is_coroutiner(r)r*r.rrrrr1s
rcsNeZdZdZdd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z	�Z
S)ra�Primitive lock objects.

    A primitive lock is a synchronization primitive that is not owned
    by a particular coroutine when locked.  A primitive lock is in one
    of two states, 'locked' or 'unlocked'.

    It is created in the unlocked state.  It has two basic methods,
    acquire() and release().  When the state is unlocked, acquire()
    changes the state to locked and returns immediately.  When the
    state is locked, acquire() blocks until a call to release() in
    another coroutine changes it to unlocked, then the acquire() call
    resets it to locked and returns.  The release() method should only
    be called in the locked state; it changes the state to unlocked
    and returns immediately.  If an attempt is made to release an
    unlocked lock, a RuntimeError will be raised.

    When more than one coroutine is blocked in acquire() waiting for
    the state to turn to unlocked, only one coroutine proceeds when a
    release() call resets the state to unlocked; first coroutine which
    is blocked in acquire() is being processed.

    acquire() is a coroutine and should be called with 'await'.

    Locks also support the asynchronous context management protocol.
    'async with lock' statement should be used.

    Usage:

        lock = Lock()
        ...
        await lock.acquire()
        try:
            ...
        finally:
            lock.release()

    Context manager usage:

        lock = Lock()
        ...
        async with lock:
             ...

    Lock objects can be tested for locking state:

        if not lock.locked():
           await lock.acquire()
        else:
           # lock is acquired
           ...

    N��loopcCs:d|_d|_|dkr t��|_n||_tjdtdd�dS�NF�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r r!)�_waiters�_lockedr�get_event_loop�_loopr#r$r%�rr2rrrr�s�z
Lock.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S�	N�lockedZunlocked�
, waiters:�<r���� [�]>)�super�__repr__r6r5�len�r�resZextra��	__class__rrrB�s

z
Lock.__repr__cCs|jS)z Return True if lock is acquired.)r6rrrrr;�szLock.lockedc	�s�|js.|jdks$tdd�|jD��r.d|_dS|jdkrBt��|_|j��}|j�|�z"z|IdHW5|j�|�XWn&t	j
k
r�|js�|���YnXd|_dS)z�Acquire a lock.

        This method blocks until the lock is unlocked, then sets it to
        locked and returns True.
        Ncss|]}|��VqdSr
)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>T)r6r5�all�collections�dequer8�
create_future�append�remover
�CancelledError�_wake_up_first�r�futrrrr&�s&�


zLock.acquirecCs"|jrd|_|��ntd��dS)aGRelease a lock.

        When the lock is locked, reset it to unlocked, and return.
        If any other coroutines are blocked waiting for the lock to become
        unlocked, allow exactly one of them to proceed.

        When invoked on an unlocked lock, a RuntimeError is raised.

        There is no return value.
        FzLock is not acquired.N)r6rSrrrrrr�s
zLock.releasecCsJ|js
dSztt|j��}Wntk
r2YdSX|��sF|�d�dS)z*Wake up the first waiter if it isn't done.NT)r5�next�iter�
StopIteration�done�
set_resultrTrrrrS�szLock._wake_up_first)rrrrrrBr;r&rrS�
__classcell__rrrFrrjs5 rcsNeZdZdZdd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z	�Z
S)ra#Asynchronous equivalent to threading.Event.

    Class implementing event objects. An event manages a flag that can be set
    to true with the set() method and reset to false with the clear() method.
    The wait() method blocks until the flag is true. The flag is initially
    false.
    Nr1cCs>t��|_d|_|dkr$t��|_n||_tjdt	dd�dSr3)
rMrNr5�_valuerr7r8r#r$r%r9rrrrs
�zEvent.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S)	N�setZunsetr<r=rr>r?r@)rArBr\r5rCrDrFrrrBs

zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.�r\rrrr�is_setszEvent.is_setcCs.|js*d|_|jD]}|��s|�d�qdS)z�Set the internal flag to true. All coroutines waiting for it to
        become true are awakened. Coroutine that call wait() once the flag is
        true will not block at all.
        TN)r\r5rYrZrTrrrr]s

z	Event.setcCs
d|_dS)z�Reset the internal flag to false. Subsequently, coroutines calling
        wait() will block until set() is called to set the internal flag
        to true again.FNr^rrrr�clear"szEvent.clearc	�sF|jr
dS|j��}|j�|�z|IdHW�dS|j�|�XdS)z�Block until the internal flag is true.

        If the internal flag is true on entry, return True
        immediately.  Otherwise, block until another coroutine calls
        set() to set the flag to true, then return True.
        TN)r\r8rOr5rPrQrTrrr�wait(s

z
Event.wait)rrrrrrBr_r]r`rar[rrrFrr�srcsReZdZdZddd�dd�Z�fdd�Zdd	�Zd
d�Zdd
d�Zdd�Z	�Z
S)raAsynchronous equivalent to threading.Condition.

    This class implements condition variable objects. A condition variable
    allows one or more coroutines to wait until they are notified by another
    coroutine.

    A new Lock object is created and used as the underlying lock.
    Nr1cCs~|dkrt��|_n||_tjdtdd�|dkr>t|d�}n|j|jk	rRtd��||_|j	|_	|j
|_
|j|_t�
�|_dS)Nr4r r!r1z"loop argument must agree with lock)rr7r8r#r$r%r�
ValueErrorrr;r&rrMrNr5)rrr2rrrrEs �zCondition.__init__csNt���}|��rdnd}|jr4|�dt|j���}d|dd��d|�d�Sr:)rArBr;r5rCrDrFrrrB[s

zCondition.__repr__c�s�|��std��|��z@|j��}|j�	|�z|IdHW�W�dS|j�
|�XW5d}z|��IdHWq�Wq^tjk
r�d}Yq^Xq^|r�tj�XdS)a�Wait until notified.

        If the calling coroutine has not acquired the lock when this
        method is called, a RuntimeError is raised.

        This method releases the underlying lock, and then blocks
        until it is awakened by a notify() or notify_all() call for
        the same condition variable in another coroutine.  Once
        awakened, it re-acquires the lock and returns True.
        zcannot wait on un-acquired lockFNT)r;rrr&r
rRr8rOr5rPrQ)rrHrUrrrrabs$

zCondition.waitc�s$|�}|s |��IdH|�}q|S)z�Wait until a predicate becomes true.

        The predicate should be a callable which result will be
        interpreted as a boolean value.  The final predicate value is
        the return value.
        N)ra)rZ	predicate�resultrrr�wait_for�s
zCondition.wait_forrcCsJ|��std��d}|jD]*}||kr*qF|��s|d7}|�d�qdS)aBy default, wake up one coroutine waiting on this condition, if any.
        If the calling coroutine has not acquired the lock when this method
        is called, a RuntimeError is raised.

        This method wakes up at most n of the coroutines waiting for the
        condition variable; it is a no-op if no coroutines are waiting.

        Note: an awakened coroutine does not actually return from its
        wait() call until it can reacquire the lock. Since notify() does
        not release the lock, its caller should.
        z!cannot notify on un-acquired lockrrFN)r;rr5rYrZ)r�n�idxrUrrr�notify�s
zCondition.notifycCs|�t|j��dS)aWake up all threads waiting on this condition. This method acts
        like notify(), but wakes up all waiting threads instead of one. If the
        calling thread has not acquired the lock when this method is called,
        a RuntimeError is raised.
        N)rgrCr5rrrr�
notify_all�szCondition.notify_all)N)r)rrrrrrBrardrgrhr[rrrFrr;s	%
rcsPeZdZdZddd�dd�Z�fdd�Zd	d
�Zdd�Zd
d�Zdd�Z	�Z
S)raA Semaphore implementation.

    A semaphore manages an internal counter which is decremented by each
    acquire() call and incremented by each release() call. The counter
    can never go below zero; when acquire() finds that it is zero, it blocks,
    waiting until some other thread calls release().

    Semaphores also support the context management protocol.

    The optional argument gives the initial value for the internal
    counter; it defaults to 1. If the value given is less than 0,
    ValueError is raised.
    rNr1cCsN|dkrtd��||_t��|_|dkr4t��|_n||_tj	dt
dd�dS)Nrz$Semaphore initial value must be >= 0r4r r!)rbr\rMrNr5rr7r8r#r$r%�r�valuer2rrrr�s
�zSemaphore.__init__csVt���}|��rdn
d|j��}|jr<|�dt|j���}d|dd��d|�d�S)	Nr;zunlocked, value:r<r=rr>r?r@)rArBr;r\r5rCrDrFrrrB�s

zSemaphore.__repr__cCs,|jr(|j��}|��s|�d�dSqdSr
)r5�popleftrYrZ)rZwaiterrrr�
_wake_up_next�s


zSemaphore._wake_up_nextcCs
|jdkS)z:Returns True if semaphore can not be acquired immediately.rr^rrrrr;�szSemaphore.lockedc�st|jdkrb|j��}|j�|�z|IdHWq|��|jdkrX|��sX|���YqXq|jd8_dS)a5Acquire a semaphore.

        If the internal counter is larger than zero on entry,
        decrement it by one and return True immediately.  If it is
        zero on entry, block, waiting until some other coroutine has
        called release() to make it larger than 0, and then return
        True.
        rNrT)r\r8rOr5rPZcancelrHrlrTrrrr&�s	


zSemaphore.acquirecCs|jd7_|��dS)z�Release a semaphore, incrementing the internal counter by one.
        When it was zero on entry and another coroutine is waiting for it to
        become larger than zero again, wake up that coroutine.
        rN)r\rlrrrrr�szSemaphore.release)r)rrrrrrBrlr;r&rr[rrrFrr�s
rcs4eZdZdZd	dd��fdd�Z�fdd�Z�ZS)
rz�A bounded semaphore implementation.

    This raises ValueError in release() if it would increase the value
    above the initial value.
    rNr1cs.|rtjdtdd�||_t�j||d�dS)Nr4r r!r1)r#r$r%�_bound_valuerArrirFrrr
s�zBoundedSemaphore.__init__cs"|j|jkrtd��t���dS)Nz(BoundedSemaphore released too many times)r\rmrbrArrrFrrrszBoundedSemaphore.release)r)rrrrrrr[rrrFrrs	r)r�__all__rMr/r#�rr	r
rrrrrrrrrrrr�<module>s "9DzNPK0�\˼��-�-� unix_events.cpython-38.opt-1.pycnu�[���U

e5dۿ�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZdZe
jdkr�ed��dd�ZGdd�dej�ZGdd�dej �Z!Gdd�dej"ej#�Z$Gdd�dej%�Z&Gdd�d�Z'dd�Z(Gd d!�d!e'�Z)Gd"d#�d#e)�Z*Gd$d%�d%e)�Z+Gd&d'�d'e'�Z,Gd(d)�d)e'�Z-Gd*d+�d+ej.�Z/eZ0e/Z1dS),z2Selector event loop for Unix with signal handling.�N�)�base_events)�base_subprocess)�	constants)�
coroutines)�events)�
exceptions)�futures)�selector_events)�tasks)�
transports)�logger)�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�MultiLoopChildWatcher�ThreadedChildWatcher�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N�)�signum�framerr�+/usr/lib64/python3.8/asyncio/unix_events.py�_sighandler_noop*srcs�eZdZdZd)�fdd�	Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
d*dd�Zd+dd�Zd,dd�Z
dd�Zd-ddddd�dd�Zd.dddddd�dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Z�ZS)/�_UnixSelectorEventLoopzdUnix event loop.

    Adds signal handling and UNIX Domain Socket support to SelectorEventLoop.
    Ncst��|�i|_dS�N)�super�__init__�_signal_handlers)�self�selector��	__class__rrr5sz_UnixSelectorEventLoop.__init__csZt���t��s.t|j�D]}|�|�qn(|jrVtjd|�d�t	|d�|j�
�dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal��source)r�close�sys�
is_finalizing�listr�remove_signal_handler�warnings�warn�ResourceWarning�clear�r�sigr!rrr%9s
�z_UnixSelectorEventLoop.closecCs|D]}|sq|�|�qdSr)�_handle_signal)r�datarrrr�_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac
GsLt�|�st�|�rtd��|�|�|��zt�|j�	��Wn2t
tfk
rt}ztt
|���W5d}~XYnXt�|||d�}||j|<zt�|t�t�|d�Wn�tk
�rF}zz|j|=|j�szt�d�Wn4t
tfk
�r}zt�d|�W5d}~XYnX|jtjk�r4td|�d���n�W5d}~XYnXdS)z�Add a handler for a signal.  UNIX only.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        z3coroutines cannot be used with add_signal_handler()NF����set_wakeup_fd(-1) failed: %s�sig � cannot be caught)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signalZ
_check_closed�signal�
set_wakeup_fdZ_csock�fileno�
ValueError�OSError�RuntimeError�strrZHandlerr�siginterruptr
�info�errno�EINVAL)rr/�callback�args�exc�handleZnexcrrr�add_signal_handlerNs2
�

z)_UnixSelectorEventLoop.add_signal_handlercCs8|j�|�}|dkrdS|jr*|�|�n
|�|�dS)z2Internal helper that is the actual signal handler.N)r�getZ
_cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{sz%_UnixSelectorEventLoop._handle_signalc
Cs�|�|�z|j|=Wntk
r,YdSX|tjkr@tj}ntj}zt�||�WnBtk
r�}z$|jtj	kr�t
d|�d���n�W5d}~XYnX|js�zt�d�Wn2ttfk
r�}zt
�d|�W5d}~XYnXdS)zwRemove a handler for a signal.  UNIX only.

        Return True if a signal handler was removed, False if not.
        Fr5r6Nr3r4T)r8r�KeyErrorr9�SIGINT�default_int_handler�SIG_DFLr=rBrCr>r:r<r
rA)rr/�handlerrFrrrr)�s(

z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|t�std|����|t��kr2td|����dS)z�Internal helper to validate a signal.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        zsig must be an int, not zinvalid signal number N)�
isinstance�intr7r9�
valid_signalsr<r.rrrr8�s
z$_UnixSelectorEventLoop._check_signalcCst|||||�Sr)�_UnixReadPipeTransport�r�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�Sr)�_UnixWritePipeTransportrSrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc	

�s�t����}
|
��std��|��}t||||||||f||d�|	��}|
�|��|j|�z|IdHWnDt	t
fk
r��Yn,tk
r�|��|�
�IdH�YnXW5QRX|S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)r�get_child_watcher�	is_activer>�
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�
SystemExit�KeyboardInterrupt�
BaseExceptionr%Z_wait)
rrUrE�shell�stdin�stdout�stderr�bufsizerW�kwargs�watcherrV�transprrr�_make_subprocess_transport�s8

���
�z1_UnixSelectorEventLoop._make_subprocess_transportcCs|�|j|�dSr)�call_soon_threadsafeZ_process_exited)r�pid�
returncoderkrrrr`�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostname�ssl_handshake_timeoutc	�s
|r|dkr6td��n |dk	r&td��|dk	r6td��|dk	r�|dk	rNtd��t�|�}t�tjtjd�}z |�d�|�||�IdHWq�|���Yq�Xn@|dkr�td��|j	tjks�|j
tjkr�td|����|�d�|j|||||d	�IdH\}}||fS)
Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl�1ssl_handshake_timeout is only meaningful with ssl�3path and sock can not be specified at the same timerFzno path and sock were specified�.A UNIX Domain Stream Socket was expected, got )rs)r<�os�fspath�socket�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr%�family�typeZ_create_connection_transport)	r�protocol_factory�pathrprqrrrs�	transportrUrrr�create_unix_connection�sR���



��
�z-_UnixSelectorEventLoop.create_unix_connection�dT)rq�backlogrprs�
start_servingc
�s�t|t�rtd��|dk	r&|s&td��|dk	�rH|dk	r@td��t�|�}t�tjtj�}|ddkr�z t	�
t�	|�j�r�t�|�WnBt
k
r�Yn0tk
r�}zt�d||�W5d}~XYnXz|�|�Wnltk
�r0}	z8|��|	jtjk�rd|�d�}
ttj|
�d�n�W5d}	~	XYn|���YnXn<|dk�rZtd	��|jtjk�sv|jtjk�r�td
|����|�d�t�||g||||�}|�r�|��tjd|d�IdH|S)
Nz*ssl argument must be an SSLContext or Nonertrur)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrvF)�loop)rO�boolr7r<rwrxryrzr{�stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorr=r
�errorZbindr%rBZ
EADDRINUSEr}r~r|rZServerZ_start_servingr�sleep)rrr�rqr�rprsr��errrF�msgZserverrrr�create_unix_serversn
�
�
�

�
��
�z)_UnixSelectorEventLoop.create_unix_serverc
�s�z
tjWn,tk
r6}zt�d��W5d}~XYnXz|��}Wn2ttjfk
rv}zt�d��W5d}~XYnXzt�|�j	}Wn,t
k
r�}zt�d��W5d}~XYnX|r�|n|}	|	s�dS|��}
|�|
d|||||	d�|
IdHS)Nzos.sendfile() is not availableznot a regular filer)
rw�sendfile�AttributeErrorr�SendfileNotAvailableErrorr;�io�UnsupportedOperation�fstat�st_sizer=r]�_sock_sendfile_native_impl)rrq�file�offset�countrFr;r�Zfsize�	blocksize�futrrr�_sock_sendfile_nativeJs2
��z,_UnixSelectorEventLoop._sock_sendfile_nativec	Cs,|��}	|dk	r|�|�|��r4|�|||�dS|rd||}|dkrd|�|||�|�|�dSzt�|	|||�}
W�nDttfk
r�|dkr�|�	||�|�
|	|j||	||||||�
Y�nbtk
�rj}z�|dk	�r|j
t
jk�rt|�tk	�rtdt
j�}||_|}|dk�rBt�d�}
|�|||�|�|
�n|�|||�|�|�W5d}~XYn�ttfk
�r��Yn�tk
�r�}z|�|||�|�|�W5d}~XYnjX|
dk�r�|�|||�|�|�nD||
7}||
7}|dk�r
|�	||�|�
|	|j||	||||||�
dS)Nrzsocket is not connectedzos.sendfile call failed)r;�
remove_writer�	cancelled�_sock_sendfile_update_fileposZ
set_resultrwr��BlockingIOError�InterruptedError�_sock_add_cancellation_callbackZ
add_writerr�r=rBZENOTCONNr~�ConnectionError�	__cause__rr�Z
set_exceptionrarbrc)rr�Z
registered_fdrqr;r�r�r��
total_sent�fdZsentrF�new_excr�rrrr�as�

�


�
��
�

�z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt�||tj�dS�Nr)rw�lseek�SEEK_SET)rr;r�r�rrrr��sz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcs��fdd�}|�|�dS)Ncs&|��r"���}|dkr"��|�dS)Nr3)r�r;r�)r�r��rrqrr�cb�szB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb)Zadd_done_callback)rr�rqr�rr�rr��sz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)�__name__�
__module__�__qualname__�__doc__rr%r2rHr0r)r8rXrZrlr`r�r�r�r�r�r��
__classcell__rrr!rr/sH-
 �
�
�
��.��CFrcs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jfdd�Zddd�Zdd�Zdd�Z�ZS) rRiNcs�t��|�||jd<||_||_|��|_||_d|_d|_	t
�|j�j}t
�|�s�t
�|�s�t
�|�s�d|_d|_d|_td��t
�|jd�|j�|jj|�|j�|jj|j|j�|dk	r�|j�tj|d�dS)NrTFz)Pipe transport is for pipes/sockets only.)rr�_extra�_loop�_piper;�_fileno�	_protocol�_closing�_pausedrwr�r�r��S_ISFIFOr��S_ISCHRr<�set_blocking�	call_soon�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)rr�rTrUrVrW�moder!rrr�s:


���
�z_UnixReadPipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���t|jdd�}|jdk	r�|dk	r�t�	||jt
j�}|r�|�d�q�|�d�n |jdk	r�|�d�n
|�d�d�d	�
|��S)
N�closed�closing�fd=�	_selector�polling�idle�open�<{}>� )r"r�r��appendr�r��getattrr�r
�_test_selector_event�	selectorsZ
EVENT_READ�format�join)rrAr r�rrr�__repr__�s(


�

z_UnixReadPipeTransport.__repr__c
Cs�zt�|j|j�}WnDttfk
r,Yn�tk
rX}z|�|d�W5d}~XYn^X|rl|j�	|�nJ|j
��r�t�
d|�d|_|j
�|j�|j
�|jj�|j
�|jd�dS)Nz"Fatal read error on pipe transport�%r was closed by peerT)rw�readr��max_sizer�r�r=�_fatal_errorr�Z
data_receivedr��	get_debugr
rAr��_remove_readerr�Zeof_received�_call_connection_lost)rr1rFrrrr��s
z"_UnixReadPipeTransport._read_readycCs>|js|jrdSd|_|j�|j�|j��r:t�d|�dS)NTz%r pauses reading)r�r�r�r�r�r�r
�debug�rrrr�
pause_reading�s
z$_UnixReadPipeTransport.pause_readingcCsB|js|jsdSd|_|j�|j|j�|j��r>t�d|�dS)NFz%r resumes reading)	r�r�r�r�r�r�r�r
r�r�rrr�resume_readings
z%_UnixReadPipeTransport.resume_readingcCs
||_dSr�r��rrUrrr�set_protocol
sz#_UnixReadPipeTransport.set_protocolcCs|jSrr�r�rrr�get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSr�r�r�rrr�
is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|�d�dSr)r��_closer�rrrr%sz_UnixReadPipeTransport.closecCs,|jdk	r(|d|��t|d�|j��dS�Nzunclosed transport r#�r�r,r%�r�_warnrrr�__del__s
z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r4|jtjkr4|j��rLtjd||dd�n|j�||||j	d��|�
|�dS�Nz%r: %sT��exc_info)�message�	exceptionr�rU)rOr=rBZEIOr�r�r
r��call_exception_handlerr�r��rrFr�rrrr�s
�z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j�|j�|j�|j|�dS�NT)r�r�r�r�r�r��rrFrrrr�-sz_UnixReadPipeTransport._closecCs4z|j�|�W5|j��d|_d|_d|_XdSr�r�r%r�r�Zconnection_lostr�rrrr�2s
z,_UnixReadPipeTransport._call_connection_lost)NN)r�)r�r�r�r�rr�r�r�r�r�r�r�r%r*r+r�r�r�r�r�rrr!rrR�s
rRcs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejfdd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rYNc
s�t��||�||jd<||_|��|_||_t�|_d|_	d|_
t�|j�j
}t�|�}t�|�}t�|�}	|s�|s�|	s�d|_d|_d|_td��t�|jd�|j�|jj|�|	s�|r�tj�d�s�|j�|jj|j|j�|dk	r�|j�tj|d�dS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrr�r�r;r�r��	bytearray�_buffer�
_conn_lostr�rwr�r�r�r�r�r�r<r�r�r�r�r&�platform�
startswithr�r�r	r�)
rr�rTrUrVrWr�Zis_charZis_fifoZ	is_socketr!rrr?s:




�
�z _UnixWritePipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���t|jdd�}|jdk	r�|dk	r�t�	||jt
j�}|r�|�d�n
|�d�|��}|�d|���n |jdk	r�|�d�n
|�d�d	�
d
�|��S)Nr�r�r�r�r�r�zbufsize=r�r�r�)r"r�r�r�r�r�r�r�r
r�r�ZEVENT_WRITE�get_write_buffer_sizer�r�)rrAr r�rhrrrr�ds,


�


z _UnixWritePipeTransport.__repr__cCs
t|j�Sr)�lenr�r�rrrr�|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|j��rt�d|�|jr*|�t��n|��dS)Nr�)r�r�r
rAr�r��BrokenPipeErrorr�rrrr�s

z#_UnixWritePipeTransport._read_readyc
Cs4t|t�rt|�}|sdS|js&|jrN|jtjkr<t�d�|jd7_dS|j	�szt
�|j|�}Wntt
tfk
r�d}YnZttfk
r��YnBtk
r�}z$|jd7_|�|d�WY�dSd}~XYnX|t|�kr�dS|dk�rt|�|d�}|j�|j|j�|j	|7_	|��dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr�#Fatal write error on pipe transport)rOr��
memoryviewr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�rw�writer�r�r�rarbrcr�r�r�Z_add_writer�_write_readyZ_maybe_pause_protocol)rr1�nrFrrrr�s6


z_UnixWritePipeTransport.writec
Cszt�|j|j�}Wn�ttfk
r,Yn�ttfk
rD�Yn�tk
r�}z6|j�	�|j
d7_
|j�|j�|�
|d�W5d}~XYnfX|t|j�kr�|j�	�|j�|j�|��|jr�|j�|j�|�d�dS|dkr�|jd|�=dS)Nrrr)rwrr�r�r�r�rarbrcr-r�r��_remove_writerr�r�Z_maybe_resume_protocolr�r�r�)rrrFrrrr�s*


z$_UnixWritePipeTransport._write_readycCsdSr�rr�rrr�
can_write_eof�sz%_UnixWritePipeTransport.can_write_eofcCs8|jr
dSd|_|js4|j�|j�|j�|jd�dSr�)r�r�r�r�r�r�r�r�rrr�	write_eof�sz!_UnixWritePipeTransport.write_eofcCs
||_dSrr�r�rrrr��sz$_UnixWritePipeTransport.set_protocolcCs|jSrr�r�rrrr��sz$_UnixWritePipeTransport.get_protocolcCs|jSrr�r�rrrr��sz"_UnixWritePipeTransport.is_closingcCs|jdk	r|js|��dSr)r�r�rr�rrrr%�sz_UnixWritePipeTransport.closecCs,|jdk	r(|d|��t|d�|j��dSr�r�r�rrrr��s
z_UnixWritePipeTransport.__del__cCs|�d�dSr)r�r�rrr�abort�sz_UnixWritePipeTransport.abortr�cCsNt|t�r(|j��r@tjd||dd�n|j�||||jd��|�|�dSr�)	rOr=r�r�r
r�r�r�r�r�rrrr��s

�z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|j�|j�|j��|j�|j�|j�|j|�dSr�)	r�r�r�rr�r-r�r�r�r�rrrr��s
z_UnixWritePipeTransport._closecCs4z|j�|�W5|j��d|_d|_d|_XdSrr�r�rrrr��s
z-_UnixWritePipeTransport._call_connection_lost)NN)r�)N)r�r�r�rr�r�r�rrrrr�r�r�r%r*r+r�r	r�r�r�r�rrr!rrY<s"%	#	

rYc@seZdZdd�ZdS)r^c		Ks�d}|tjkrt��\}}zPtj|f||||d|d�|��|_|dk	rh|��t|��d|d�|j_	d}W5|dk	r�|��|��XdS)NF)rdrerfrgZuniversal_newlinesrh�wb)�	buffering)
�
subprocess�PIPEryZ
socketpairr%�Popen�_procr��detachre)	rrErdrerfrgrhriZstdin_wrrr�_starts.
���z_UnixSubprocessTransport._startN)r�r�r�rrrrrr^	sr^c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)raHAbstract base class for monitoring child processes.

    Objects derived from this class monitor a collection of subprocesses and
    report their termination or interruption by a signal.

    New callbacks are registered with .add_child_handler(). Starting a new
    process must be done within a 'with' block to allow the watcher to suspend
    its activity until the new process if fully registered (this is needed to
    prevent a race condition in some implementations).

    Example:
        with watcher:
            proc = subprocess.Popen("sleep 1")
            watcher.add_child_handler(proc.pid, callback)

    Notes:
        Implementations of this class must be thread-safe.

        Since child watcher objects may catch the SIGCHLD signal and call
        waitpid(-1), there should be only one active object per process.
    cGs
t��dS)aRegister a new child handler.

        Arrange for callback(pid, returncode, *args) to be called when
        process 'pid' terminates. Specifying another callback for the same
        process replaces the previous handler.

        Note: callback() must be thread-safe.
        N��NotImplementedError�rrnrDrErrrr_9s	z&AbstractChildWatcher.add_child_handlercCs
t��dS)z�Removes the handler for process 'pid'.

        The function returns True if the handler was successfully removed,
        False if there was nothing to remove.Nr�rrnrrr�remove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs
t��dS)z�Attach the watcher to an event loop.

        If the watcher was previously attached to an event loop, then it is
        first detached before attaching to the new loop.

        Note: loop may be None.
        Nr�rr�rrr�attach_loopLsz AbstractChildWatcher.attach_loopcCs
t��dS)zlClose the watcher.

        This must be called to make sure that any underlying resource is freed.
        Nrr�rrrr%VszAbstractChildWatcher.closecCs
t��dS)z�Return ``True`` if the watcher is active and is used by the event loop.

        Return True if the watcher is installed and ready to handle process exit
        notifications.

        Nrr�rrrr\]szAbstractChildWatcher.is_activecCs
t��dS)zdEnter the watcher's context and allow starting new processes

        This function must return selfNrr�rrr�	__enter__fszAbstractChildWatcher.__enter__cCs
t��dS)zExit the watcher's contextNr�r�a�b�crrr�__exit__lszAbstractChildWatcher.__exit__N)r�r�r�r�r_rrr%r\rrrrrrr"s
	rcCs2t�|�rt�|�St�|�r*t�|�S|SdSr)rw�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)�statusrrr�_compute_returncodeqs



r$c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dSr)r��
_callbacksr�rrrr�szBaseChildWatcher.__init__cCs|�d�dSr)rr�rrrr%�szBaseChildWatcher.closecCs|jdk	o|j��Sr)r�Z
is_runningr�rrrr\�szBaseChildWatcher.is_activecCs
t��dSrr)r�expected_pidrrr�_do_waitpid�szBaseChildWatcher._do_waitpidcCs
t��dSrrr�rrr�_do_waitpid_all�sz BaseChildWatcher._do_waitpid_allcCsf|jdk	r$|dkr$|jr$t�dt�|jdk	r<|j�tj�||_|dk	rb|�tj|j	�|�
�dS)NzCA loop is being detached from a child watcher with pending handlers)r�r&r*r+�RuntimeWarningr)r9�SIGCHLDrH�	_sig_chldr)rrrrr�s�
zBaseChildWatcher.attach_loopc
Cs^z|��WnLttfk
r&�Yn4tk
rX}z|j�d|d��W5d}~XYnXdS)N�$Unknown exception in SIGCHLD handler)r�r�)r)rarbrcr�r�r�rrrr,�s�zBaseChildWatcher._sig_chldN)
r�r�r�rr%r\r(r)rr,rrrrr%sr%csPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)rad'Safe' child watcher implementation.

    This implementation avoids disrupting other code spawning processes by
    polling explicitly each process in the SIGCHLD handler instead of calling
    os.waitpid(-1).

    This is a safe solution but it has a significant overhead when handling a
    big number of children (O(n) each time SIGCHLD is raised)
    cs|j��t���dSr)r&r-rr%r�r!rrr%�s
zSafeChildWatcher.closecCs|Srrr�rrrr�szSafeChildWatcher.__enter__cCsdSrrrrrrr�szSafeChildWatcher.__exit__cGs||f|j|<|�|�dSr)r&r(rrrrr_�sz"SafeChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdS�NTF�r&rJrrrrr�s
z%SafeChildWatcher.remove_child_handlercCst|j�D]}|�|�q
dSr�r(r&r(rrrrr)�sz SafeChildWatcher._do_waitpid_allcCs�zt�|tj�\}}Wn(tk
r>|}d}t�d|�Yn.X|dkrLdSt|�}|j��rlt�	d||�z|j
�|�\}}Wn.tk
r�|j��r�tjd|dd�YnX|||f|��dS)N��8Unknown child process pid %d, will report returncode 255r�$process %s exited with returncode %s�'Child watcher got an unexpected pid: %rTr�)
rw�waitpid�WNOHANG�ChildProcessErrorr
rr$r�r�r�r&�poprJ)rr'rnr#rorDrErrrr(�s4�

�
�zSafeChildWatcher._do_waitpid)r�r�r�r�r%rrr_rr)r(r�rrr!rr�s
rcsTeZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)raW'Fast' child watcher implementation.

    This implementation reaps every terminated processes by calling
    os.waitpid(-1) directly, possibly breaking other code spawning processes
    and waiting for their termination.

    There is no noticeable overhead when handling a big number of children
    (O(1) each time a child terminates).
    cs$t���t��|_i|_d|_dSr�)rr�	threadingZLock�_lock�_zombies�_forksr�r!rrrs

zFastChildWatcher.__init__cs"|j��|j��t���dSr)r&r-r;rr%r�r!rrr%s

zFastChildWatcher.closec
Cs0|j� |jd7_|W5QR�SQRXdS)Nr)r:r<r�rrrrszFastChildWatcher.__enter__c	Cs^|j�B|jd8_|js"|js0W5QR�dSt|j�}|j��W5QRXt�d|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)r:r<r;r?r-r
r)rrrrZcollateral_victimsrrrrs
�zFastChildWatcher.__exit__c	Gsf|j�Fz|j�|�}Wn.tk
rF||f|j|<YW5QR�dSXW5QRX|||f|��dSr)r:r;r8rJr&)rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdSr.r/rrrrr5s
z%FastChildWatcher.remove_child_handlerc	Cs�zt�dtj�\}}Wntk
r,YdSX|dkr:dSt|�}|j��z|j�|�\}}WnNtk
r�|j	r�||j
|<|j��r�t
�d||�YW5QR�qd}YnX|j��r�t
�d||�W5QRX|dkr�t
�d||�q|||f|��qdS)Nr3rz,unknown process %s exited with returncode %sr3z8Caught subprocess termination from unknown pid: %d -> %d)rwr5r6r7r$r:r&r8rJr<r;r�r�r
r�r)rrnr#rorDrErrrr)<s@

�

��z FastChildWatcher._do_waitpid_all)r�r�r�r�rr%rrr_rr)r�rrr!rr�s	rc@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)ra~A watcher that doesn't require running loop in the main thread.

    This implementation registers a SIGCHLD signal handler on
    instantiation (which may conflict with other code that
    install own handler for this signal).

    The solution is safe but it has a significant overhead when
    handling a big number of processes (*O(n)* each time a
    SIGCHLD is received).
    cCsi|_d|_dSr)r&�_saved_sighandlerr�rrrrzszMultiLoopChildWatcher.__init__cCs
|jdk	Sr)r=r�rrrr\~szMultiLoopChildWatcher.is_activecCsT|j��|jdkrdSt�tj�}||jkr:t�d�nt�tj|j�d|_dS)Nz+SIGCHLD handler was changed by outside code)	r&r-r=r9�	getsignalr+r,r
r)rrNrrrr%�s


zMultiLoopChildWatcher.closecCs|Srrr�rrrr�szMultiLoopChildWatcher.__enter__cCsdSrr�r�exc_typeZexc_valZexc_tbrrrr�szMultiLoopChildWatcher.__exit__cGs&t��}|||f|j|<|�|�dSr)r�get_running_loopr&r()rrnrDrEr�rrrr_�sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdSr.r/rrrrr�s
z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk	rdSt�tj|j�|_|jdkr<t�d�tj|_t�tjd�dS)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)r=r9r+r,r
rrMr@rrrrr�s


z!MultiLoopChildWatcher.attach_loopcCst|j�D]}|�|�q
dSrr0rrrrr)�sz%MultiLoopChildWatcher._do_waitpid_allc	Cs�zt�|tj�\}}Wn,tk
rB|}d}t�d|�d}YnX|dkrPdSt|�}d}z|j�|�\}}}Wn$t	k
r�tjd|dd�YnHX|�
�r�t�d||�n.|r�|��r�t�d	||�|j
|||f|��dS)
Nr1r2FrTr4r��%Loop %r that handles pid %r is closedr3)rwr5r6r7r
rr$r&r8rJ�	is_closedr�r�rm)	rr'rnr#roZ	debug_logr�rDrErrrr(�s:�
��z!MultiLoopChildWatcher._do_waitpidc	CsLz|��Wn:ttfk
r&�Yn"tk
rFtjddd�YnXdS)Nr-Tr�)r)rarbrcr
r)rrrrrrr,�szMultiLoopChildWatcher._sig_chldN)r�r�r�r�rr\r%rrr_rrr)r(r,rrrrrgs%rc@sneZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
jfdd�Zdd�Z
dd�Zdd�Zdd�ZdS)raAThreaded child watcher implementation.

    The watcher uses a thread per process
    for waiting for the process finish.

    It doesn't require subscription on POSIX signal
    but a thread creation is not free.

    The watcher has O(1) complexity, its performance doesn't depend
    on amount of spawn processes.
    cCst�d�|_i|_dSr�)�	itertoolsr��_pid_counter�_threadsr�rrrr�szThreadedChildWatcher.__init__cCsdSr�rr�rrrr\�szThreadedChildWatcher.is_activecCs|��dSr)�
_join_threadsr�rrrr%�szThreadedChildWatcher.closecCs.dd�t|j���D�}|D]}|��qdS)z%Internal: Join all non-daemon threadscSsg|]}|��r|js|�qSr)�is_alive�daemon��.0�threadrrr�
<listcomp>�s�z6ThreadedChildWatcher._join_threads.<locals>.<listcomp>N)r(rF�valuesr�)r�threadsrLrrrrG�sz"ThreadedChildWatcher._join_threadscCs|Srrr�rrrrszThreadedChildWatcher.__enter__cCsdSrrr?rrrrszThreadedChildWatcher.__exit__cCs6dd�t|j���D�}|r2||j�d�t|d�dS)NcSsg|]}|��r|�qSr)rHrJrrrrM	s�z0ThreadedChildWatcher.__del__.<locals>.<listcomp>z0 has registered but not finished child processesr#)r(rFrNr"r,)rr�rOrrrr�s�zThreadedChildWatcher.__del__cGsFt��}tj|jdt|j���||||fdd�}||j|<|��dS)Nzwaitpid-T)�target�namerErI)	rrAr9ZThreadr(�nextrErF�start)rrnrDrEr�rLrrrr_s
�
z&ThreadedChildWatcher.add_child_handlercCsdSr�rrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCs�zt�|d�\}}Wn(tk
r<|}d}t�d|�Yn Xt|�}|��r\t�d||�|��rtt�d||�n|j	|||f|��|j
�|�dS)Nrr1r2r3rB)rwr5r7r
rr$r�r�rCrmrFr8)rr�r'rDrErnr#rorrrr("s&�
�z ThreadedChildWatcher._do_waitpidN)r�r�r�r�rr\r%rGrrr*r+r�r_rrr(rrrrr�s	rcsHeZdZdZeZ�fdd�Zdd�Z�fdd�Zdd	�Z	d
d�Z
�ZS)�_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cst���d|_dSr)rr�_watcherr�r!rrrAs
z$_UnixDefaultEventLoopPolicy.__init__c	CsHtj�8|jdkr:t�|_tt��tj�r:|j�|j	j
�W5QRXdSr)rr:rUrrOr9�current_thread�_MainThreadr�_localr�r�rrr�
_init_watcherEs
�z)_UnixDefaultEventLoopPolicy._init_watchercs6t��|�|jdk	r2tt��tj�r2|j�|�dS)z�Set the event loop.

        As a side effect, if a child watcher was set before, then calling
        .set_event_loop() from the main thread will call .attach_loop(loop) on
        the child watcher.
        N)r�set_event_looprUrOr9rVrWrrr!rrrZMs

�z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|��|jS)z~Get the watcher for child processes.

        If not yet set, a ThreadedChildWatcher object is automatically created.
        N)rUrYr�rrrr[[s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk	r|j��||_dS)z$Set the watcher for child processes.N)rUr%)rrjrrr�set_child_watcheres

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�r�rZ
_loop_factoryrrYrZr[r[r�rrr!rrT=s
rT)2r�rBr�rDrwr�r9ryr�rr&r9r*�rrrrrrr	r
rr�logr
�__all__r��ImportErrorrZBaseSelectorEventLooprZ
ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr$r%rrrrZBaseDefaultEventLoopPolicyrTrrrrrr�<module>s`	
	�NO5Ji}Y3PK0�\ٗ'99sslproto.cpython-38.opt-2.pycnu�[���U

e5dJj�@s�ddlZddlZzddlZWnek
r4dZYnXddlmZddlmZddlmZddlmZddl	m
Z
dd	�Zd
ZdZ
dZd
ZGdd�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�base_events)�	constants)�	protocols)�
transports)�loggercCs"|rtd��t��}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF)�
ValueError�sslZcreate_default_contextZcheck_hostname)�server_side�server_hostname�
sslcontext�r
�(/usr/lib64/python3.8/asyncio/sslproto.py�_create_transport_contextsrZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@szeZdZdZddd�Zedd��Zedd��Zed	d
��Zedd��Z	dd
d�Z
ddd�Zdd�Zddd�Z
ddd�ZdS)�_SSLPipeiNcCsH||_||_||_t|_t��|_t��|_d|_	d|_
d|_d|_dS�NF)
�_context�_server_side�_server_hostname�
_UNWRAPPED�_stater	Z	MemoryBIO�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextr
rr
r
r�__init__8s

z_SSLPipe.__init__cCs|jS�N)r�rr
r
rrNsz_SSLPipe.contextcCs|jSr )rr!r
r
r�
ssl_objectSsz_SSLPipe.ssl_objectcCs|jSr )rr!r
r
r�need_ssldata[sz_SSLPipe.need_ssldatacCs
|jtkSr )r�_WRAPPEDr!r
r
r�wrappedasz_SSLPipe.wrappedcCsR|jtkrtd��|jj|j|j|j|jd�|_	t
|_||_|jddd�\}}|S)Nz"handshake in progress or completed)r
r�T)�only_handshake)
rr�RuntimeErrorrZwrap_biorrrrr�
_DO_HANDSHAKEr�feed_ssldata�r�callback�ssldata�appdatar
r
r�do_handshakejs	
�z_SSLPipe.do_handshakecCsB|jtkrtd��|jtkr$td��t|_||_|�d�\}}|S)Nzno security layer presentzshutdown in progressr&)rrr(�	_SHUTDOWNrr*r+r
r
r�shutdowns	

z_SSLPipe.shutdowncCs|j��|�d�\}}dS)Nr&)rZ	write_eofr*)rr-r.r
r
r�feed_eof�s
z_SSLPipe.feed_eofFc
Cs�|jtkr"|r|g}ng}g|fSd|_|r8|j�|�g}g}z�|jtkrz|j��t|_|j	rl|�	d�|rz||fWS|jtkr�|j�
|j�}|�|�|s�q�q�nJ|jt
kr�|j��d|_t|_|jr�|��n|jtkr�|�|j�
��Wnztjtjfk
�rl}zRt|dd�}|tjtjtjfk�rP|jtk�rN|j	�rN|�	|��|tjk|_W5d}~XYnX|jj�r�|�|j�
��||fS)NF�errno)rrrr�writer)rr/r$r�read�max_size�appendr0Zunwraprr	�SSLError�CertificateError�getattr�SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITE�SSL_ERROR_SYSCALLr�pending)r�datar'r.r-�chunk�exc�	exc_errnor
r
rr*�sZ










�

z_SSLPipe.feed_ssldatarc
Cs|jtkr6|t|�kr&||d�g}ng}|t|�fSg}t|�}d|_z(|t|�krn||j�||d��7}Wnhtjk
r�}zHt	|dd�}|j
dkr�tj}|_|tjtj
tjfkr��|tjk|_W5d}~XYnX|jjr�|�|j���|t|�k�s|jrB�qqB||fS)NFr3ZPROTOCOL_IS_SHUTDOWN)rr�len�
memoryviewrrr4r	r8r:�reasonr;r3r<r=rr>r7r5)rr?�offsetr-ZviewrArBr
r
r�feed_appdata�s4

�z_SSLPipe.feed_appdata)N)N)N)F)r)�__name__�
__module__�__qualname__r6r�propertyrr"r#r%r/r1r2r*rGr
r
r
rr$s








Krc@s�eZdZejjZdd�Zd"dd�Zdd�Z	dd	�Z
d
d�Zdd
�Ze
jfdd�Zdd�Zdd�Zdd�Zd#dd�Zdd�Zedd��Zdd�Zdd�Zd d!�ZdS)$�_SSLProtocolTransportcCs||_||_d|_dSr)�_loop�
_ssl_protocol�_closed)r�loopZssl_protocolr
r
rr!sz_SSLProtocolTransport.__init__NcCs|j�||�Sr )rN�_get_extra_info�r�name�defaultr
r
r�get_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j�|�dSr )rN�_set_app_protocol)r�protocolr
r
r�set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSr )rN�
_app_protocolr!r
r
r�get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSr )rOr!r
r
r�
is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|j��dS�NT)rOrN�_start_shutdownr!r
r
r�close4sz_SSLProtocolTransport.closecCs&|js"|d|��t|d�|��dS)Nzunclosed transport )�source)rO�ResourceWarningr^)rZ_warnr
r
r�__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd��|��S)Nz*SSL transport has not been initialized yet)rN�
_transportr(�
is_reading)rZtrr
r
rrcDsz _SSLProtocolTransport.is_readingcCs|jj��dSr )rNrb�
pause_readingr!r
r
rrdJsz#_SSLProtocolTransport.pause_readingcCs|jj��dSr )rNrb�resume_readingr!r
r
rreRsz$_SSLProtocolTransport.resume_readingcCs|jj�||�dSr )rNrb�set_write_buffer_limits)rZhighZlowr
r
rrfZsz-_SSLProtocolTransport.set_write_buffer_limitscCs|jj��Sr )rNrb�get_write_buffer_sizer!r
r
rrgosz+_SSLProtocolTransport.get_write_buffer_sizecCs
|jjjSr )rNrb�_protocol_pausedr!r
r
rrhssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttf�s$tdt|�j����|s,dS|j�|�dS)Nz+data: expecting a bytes-like instance, got )	�
isinstance�bytes�	bytearrayrD�	TypeError�typerHrN�_write_appdata�rr?r
r
rr4xs
z_SSLProtocolTransport.writecCsdSrr
r!r
r
r�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|j��d|_dSr\)rN�_abortrOr!r
r
r�abort�s
z_SSLProtocolTransport.abort)N)NN)rHrIrJrZ
_SendfileModeZFALLBACKZ_sendfile_compatiblerrUrXrZr[r^�warnings�warnrarcrdrerfrgrKrhr4rprrr
r
r
rrLs$



rLc@s�eZdZd+dd�Zdd�Zd,dd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zd-dd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd.d%d&�Zd'd(�Zd)d*�ZdS)/�SSLProtocolFNTc		Cs�tdkrtd��|dkr tj}n|dkr6td|����|sDt||�}||_|rZ|sZ||_nd|_||_t	|d�|_
t��|_
d|_||_||_|�|�t|j|�|_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )rF)r	r(rZSSL_HANDSHAKE_TIMEOUTrrrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrMrVrL�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownrb�_call_connection_made�_ssl_handshake_timeout)	rrP�app_protocolrZwaiterr
rZcall_connection_madeZssl_handshake_timeoutr
r
rr�s@��

zSSLProtocol.__init__cCs||_t|tj�|_dSr )rYrirZBufferedProtocol�_app_protocol_is_buffer)rr�r
r
rrV�s
�zSSLProtocol._set_app_protocolcCsD|jdkrdS|j��s:|dk	r.|j�|�n|j�d�d|_dSr )r}Z	cancelledZ
set_exceptionZ
set_result�rrAr
r
r�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|��dSr )rbrrvrrr�_start_handshake)r�	transportr
r
r�connection_made�s�zSSLProtocol.connection_madecCsn|jr d|_|j�|jj|�n|jdk	r2d|j_d|_d|_t|dd�rT|j	�
�|�|�d|_d|_dS)NFT�_handshake_timeout_handle)
r�rM�	call_soonrY�connection_lostr~rOrbr:r��cancelr�rr�r
r
rr��s


zSSLProtocol.connection_lostcCs|j��dSr )rY�
pause_writingr!r
r
rr��szSSLProtocol.pause_writingcCs|j��dSr )rY�resume_writingr!r
r
rr�szSSLProtocol.resume_writingcCs"|jdkrdSz|j�|�\}}WnLttfk
r<�Yn4tk
rn}z|�|d�WY�dSd}~XYnX|D]}|j�|�qt|D]�}|�rz&|jr�t	�
|j|�n|j�|�WnPttfk
r��Yn8tk
�r
}z|�|d�WY�dSd}~XYnXq�|�
��qq�dS)NzSSL error in data receivedz/application protocol failed to receive SSL data)rr*�
SystemExit�KeyboardInterrupt�
BaseException�_fatal_errorrbr4r�rZ_feed_data_to_buffered_protorY�
data_receivedr])rr?r-r.�er@Zexr
r
rr�s<
��zSSLProtocol.data_receivedcCsTzB|j��rt�d|�|�t�|js@|j	�
�}|r@t�d�W5|j��XdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl)rbr^rM�	get_debugr�debugr��ConnectionResetErrorr�rY�eof_receivedZwarning)rZ	keep_openr
r
rr�-s


zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk	r,|j�||�S|SdSr )rxrbrUrRr
r
rrQCs



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|��nd|_|�d�dS)NTr&)r�r�rqrnr!r
r
rr]Ks
zSSLProtocol._start_shutdowncCs.|j�|df�|jt|�7_|��dS)Nr)r{r7r|rC�_process_write_backlogror
r
rrnTszSSLProtocol._write_appdatacCs\|j��r$t�d|�|j��|_nd|_d|_|j�d�|j�	|j
|j�|_|�
�dS)Nz%r starts SSL handshakeT)r&r)rMr�rr��time�_handshake_start_timer�r{r7Z
call_laterr��_check_handshake_timeoutr�r�r!r
r
rr�Ys

��zSSLProtocol._start_handshakecCs*|jdkr&d|j�d�}|�t|��dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)r�r�r��ConnectionAbortedError)r�msgr
r
rr�hs
�z$SSLProtocol._check_handshake_timeoutc
Csd|_|j��|jj}z|dk	r&|�|��}Wnbttfk
rJ�YnJtk
r�}z,t	|t
j�rld}nd}|�||�WY�dSd}~XYnX|j
��r�|j
��|j}t�d||d�|jj||��|��|d�|jr�|j�|j�|��d|_|j
�|j�dS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compressionr"T)r�r�r�rr"Zgetpeercertr�r�r�rir	r9r�rMr�r�r�rr�rx�updater�r�r�rYr�r~r�r�r�r�)rZ
handshake_excZsslobjr�rAr�Zdtr
r
r�_on_handshake_completeqs8

�z"SSLProtocol._on_handshake_completec
CsB|jdks|jdkrdSz�tt|j��D]�}|jd\}}|rR|j�||�\}}n*|rj|j�|j�}d}n|j�|j	�}d}|D]}|j�
|�q�|t|�kr�||f|jd<|jjr�|j��q�|jd=|j
t|�8_
q(Wn\ttfk
r��YnDtk
�r<}z$|j�r |�|�n|�|d�W5d}~XYnXdS)NrrzFatal error on SSL transport)rbr�rangerCr{rGr/r�r1�	_finalizer4Z_pausedrer|r�r�r�r�r�)r�ir?rFr-r@rAr
r
rr��s:�
z"SSLProtocol._process_write_backlog�Fatal error on transportcCsVt|t�r(|j��r@tjd||dd�n|j�|||j|d��|jrR|j�|�dS)Nz%r: %sT)�exc_info)�messageZ	exceptionr�rW)	ri�OSErrorrMr�rr�Zcall_exception_handlerrbZ_force_close)rrAr�r
r
rr��s

�zSSLProtocol._fatal_errorcCsd|_|jdk	r|j��dSr )rrbr^r!r
r
rr��s
zSSLProtocol._finalizecCs(z|jdk	r|j��W5|��XdSr )r�rbrrr!r
r
rrq�s
zSSLProtocol._abort)FNTN)N)N)r�)rHrIrJrrVr�r�r�r�r�r�r�rQr]rnr�r�r�r�r�r�rqr
r
r
rru�s.�
.

&
		)+
ru)ryrsr	�ImportError�rrrr�logrrrr)r$r0�objectrZ_FlowControlMixinZ	TransportrLZProtocolrur
r
r
r�<module>s*
y�xPK0�\k*�	�	exceptions.cpython-38.pycnu�[���U

e5da�@sldZdZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de	�Z
Gdd
�d
e�ZdS)zasyncio exceptions.)�CancelledError�InvalidStateError�TimeoutError�IncompleteReadError�LimitOverrunError�SendfileNotAvailableErrorc@seZdZdZdS)rz!The Future or Task was cancelled.N��__name__�
__module__�__qualname__�__doc__�rr�*/usr/lib64/python3.8/asyncio/exceptions.pyr	src@seZdZdZdS)rz*The operation exceeded the given deadline.Nrrrrr
r
src@seZdZdZdS)rz+The operation is not allowed in this state.Nrrrrr
rsrc@seZdZdZdS)rz~Sendfile syscall is not available.

    Raised if OS does not support sendfile syscall for given socket or
    file type.
    Nrrrrr
rsrcs(eZdZdZ�fdd�Zdd�Z�ZS)rz�
    Incomplete read error. Attributes:

    - partial: read bytes string before the end of stream was reached
    - expected: total number of expected bytes (or None if unknown)
    cs@|dkrdnt|�}t��t|��d|�d��||_||_dS)NZ	undefinedz bytes read on a total of z expected bytes)�repr�super�__init__�len�partial�expected)�selfrrZ
r_expected��	__class__rr
r$szIncompleteReadError.__init__cCst|�|j|jffS�N)�typerr�rrrr
�
__reduce__+szIncompleteReadError.__reduce__�rr	r
rrr�
__classcell__rrrr
rsrcs(eZdZdZ�fdd�Zdd�Z�ZS)rz�Reached the buffer limit while looking for a separator.

    Attributes:
    - consumed: total number of to be consumed bytes.
    cst��|�||_dSr)rr�consumed)r�messagerrrr
r5szLimitOverrunError.__init__cCst|�|jd|jffS)N�)r�argsrrrrr
r9szLimitOverrunError.__reduce__rrrrr
r/srN)r�__all__�
BaseExceptionr�	Exceptionrr�RuntimeErrorr�EOFErrorrrrrrr
�<module>sPK0�\\dkss"windows_utils.cpython-38.opt-2.pycnu�[���U

e5d��@s�ddlZejdkred��ddlZddlZddlZddlZddlZddlZddl	Z	dZ
dZejZej
Z
e��Zdded�d	d
�ZGdd�d�ZGd
d�dej�ZdS)�NZwin32z
win32 only)�pipe�Popen�PIPE�
PipeHandlei F)TT)�duplex�
overlapped�bufsizec
Cs$tjd�t��tt��d�}|r>tj}tj	tj
B}||}}ntj}tj
}d|}}|tjO}|drp|tj
O}|dr�tj
}nd}d}	}
z\t�||tjd||tjtj�}	t�||dtjtj|tj�}
tj|	dd�}|�d�|	|
fWS|	dk	�rt�|	�|
dk	�rt�|
��YnXdS)Nz\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�T�r)�tempfileZmktemp�format�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ	PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2Zov�r�-/usr/lib64/python3.8/asyncio/windows_utils.pyr sb��


��





rc@s^eZdZdd�Zdd�Zedd��Zdd�Zej	d	�d
d�Z
ejfdd
�Z
dd�Zdd�ZdS)rcCs
||_dS�N��_handle��self�handlerrr�__init__VszPipeHandle.__init__cCs2|jdk	rd|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r�	__class__�__name__rrrr�__repr__Ys
zPipeHandle.__repr__cCs|jSrr�rrrrr`szPipeHandle.handlecCs|jdkrtd��|jS)NzI/O operation on closed pipe)r�
ValueErrorr%rrr�filenods
zPipeHandle.fileno)rcCs|jdk	r||j�d|_dSrr)rrrrr�closeis

zPipeHandle.closecCs*|jdk	r&|d|��t|d�|��dS)Nz	unclosed )�source)r�ResourceWarningr()rZ_warnrrr�__del__ns
zPipeHandle.__del__cCs|Srrr%rrr�	__enter__sszPipeHandle.__enter__cCs|��dSr)r()r�t�v�tbrrr�__exit__vszPipeHandle.__exit__N)r#�
__module__�__qualname__rr$�propertyrr'rrr(�warnings�warnr+r,r0rrrrrQs
rcseZdZd�fdd�	Z�ZS)rNc	sxd}}}d}	}
}|tkr@tddd�\}}	t�|tj�}n|}|tkrhtdd�\}
}
t�|
d�}n|}|tkr�tdd�\}}t�|d�}n|tkr�|}n|}z�z t�j	|f|||d�|��Wn0|	|
|fD]}|dk	r�t
�|�qւYn>X|	dk	�r
t|	�|_
|
dk	�rt|
�|_|dk	�r2t|�|_W5|tk�rJt�|�|tk�r^t�|�|tk�rrt�|�XdS)N)FTT)rr)TFrr)�stdin�stdout�stderr)rr�msvcrtZopen_osfhandler�O_RDONLY�STDOUTr(�superrrrrr6r7r8)r�argsr6r7r8�kwdsZ	stdin_rfdZ
stdout_wfdZ
stderr_wfdZstdin_whZ	stdout_rhZ	stderr_rhZstdin_rhZ	stdout_whZ	stderr_wh�h�r"rrr�sN��










zPopen.__init__)NNN)r#r1r2r�
__classcell__rrr@rr}sr)�sys�platform�ImportErrorr�	itertoolsr9r�
subprocessrr4�__all__ZBUFSIZErr;�countrrrrrrrr�<module>s"
1,PK
0�\���+�+futures.cpython-38.pycnu�[���U

e5db3�@s�dZdZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZejZej
Z
ejZejZejdZGd	d
�d
�ZeZdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�dd�ZzddlZWnek
r�YnXejZZdS)z.A Future class similar to the one in PEP 3148.)�Future�wrap_future�isfuture�N�)�base_futures)�events)�
exceptions)�format_helpersc@s�eZdZdZeZdZdZdZdZ	dZ
dZdd�dd�Ze
jZdd�Zd	d
�Zedd��Zejd
d��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Z e Z!dS)'ra,This class is *almost* compatible with concurrent.futures.Future.

    Differences:

    - This class is not thread-safe.

    - result() and exception() do not take a timeout argument and
      raise an exception when the future isn't done yet.

    - Callbacks registered with add_done_callback() are always called
      via the event loop's call_soon().

    - This class is not compatible with the wait() and as_completed()
      methods in the concurrent.futures package.

    (In Python 3.4 or later we may be able to unify the implementations.)
    NF��loopcCs@|dkrt��|_n||_g|_|j��r<t�t�d��|_	dS)z�Initialize the future.

        The optional event_loop argument allows explicitly setting the event
        loop object used by the future. If it's not provided, the future uses
        the default event loop.
        Nr)
r�get_event_loop�_loop�
_callbacksZ	get_debugr	�
extract_stack�sys�	_getframe�_source_traceback��selfr�r�'/usr/lib64/python3.8/asyncio/futures.py�__init__Ds
�zFuture.__init__cCsd�|jjd�|����S)Nz<{} {}>� )�format�	__class__�__name__�join�
_repr_info�rrrr�__repr__Vs
�zFuture.__repr__cCsF|js
dS|j}|jj�d�||d�}|jr6|j|d<|j�|�dS)Nz exception was never retrieved)�message�	exception�futureZsource_traceback)�_Future__log_traceback�
_exceptionrrrr
Zcall_exception_handler)r�exc�contextrrr�__del__Zs�
zFuture.__del__cCs|jS�N)r#rrrr�_log_tracebackjszFuture._log_tracebackcCst|�rtd��d|_dS)Nz'_log_traceback can only be set to FalseF)�bool�
ValueErrorr#)r�valrrrr)nscCs|j}|dkrtd��|S)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r
�RuntimeErrorrrrr�get_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|��dS)z�Cancel the future and schedule callbacks.

        If the future is already done or cancelled, return False.  Otherwise,
        change the future's state to cancelled, schedule the callbacks and
        return True.
        FT)r#�_state�_PENDING�
_CANCELLED�_Future__schedule_callbacksrrrr�cancel{s
z
Future.cancelcCsH|jdd�}|sdSg|jdd�<|D]\}}|jj|||d�q(dS)z�Internal: Ask the event loop to call all callbacks.

        The callbacks are scheduled to be called as soon as possible. Also
        clears the callback list.
        N�r&)rr
�	call_soon)rZ	callbacks�callback�ctxrrrZ__schedule_callbacks�szFuture.__schedule_callbackscCs
|jtkS)z(Return True if the future was cancelled.)r/r1rrrr�	cancelled�szFuture.cancelledcCs
|jtkS)z�Return True if the future is done.

        Done means either that a result / exception are available, or that the
        future was cancelled.
        )r/r0rrrr�done�szFuture.donecCs@|jtkrtj�|jtkr$t�d��d|_|jdk	r:|j�|jS)aReturn the result this future represents.

        If the future has been cancelled, raises CancelledError.  If the
        future's result isn't yet available, raises InvalidStateError.  If
        the future is done and has an exception set, this exception is raised.
        zResult is not ready.FN)	r/r1r�CancelledError�	_FINISHED�InvalidStateErrorr#r$�_resultrrrr�result�s



z
Future.resultcCs0|jtkrtj�|jtkr$t�d��d|_|jS)a&Return the exception that was set on this future.

        The exception (or None if no exception was set) is returned only if
        the future is done.  If the future has been cancelled, raises
        CancelledError.  If the future isn't done yet, raises
        InvalidStateError.
        zException is not set.F)r/r1rr:r;r<r#r$rrrrr!�s


zFuture.exceptionr4cCsB|jtkr|jj|||d�n |dkr.t��}|j�||f�dS)z�Add a callback to be run when the future becomes done.

        The callback is called with a single argument - the future object. If
        the future is already done when this is called, the callback is
        scheduled with call_soon.
        r4N)r/r0r
r5�contextvarsZcopy_contextr�append)r�fnr&rrr�add_done_callback�s

zFuture.add_done_callbackcs<�fdd�|jD�}t|j�t|�}|r8||jdd�<|S)z}Remove all instances of a callback from the "call when done" list.

        Returns the number of callbacks removed.
        cs g|]\}}|�kr||f�qSrr)�.0�fr7�rArr�
<listcomp>�s�z/Future.remove_done_callback.<locals>.<listcomp>N)r�len)rrAZfiltered_callbacksZ
removed_countrrEr�remove_done_callback�s
�zFuture.remove_done_callbackcCs8|jtkr t�|j�d|����||_t|_|��dS)z�Mark the future done and set its result.

        If the future is already done when this method is called, raises
        InvalidStateError.
        �: N)r/r0rr<r=r;r2)rr>rrr�
set_result�s

zFuture.set_resultcCsb|jtkr t�|j�d|����t|t�r0|�}t|�tkrDtd��||_t	|_|�
�d|_dS)z�Mark the future done and set an exception.

        If the future is already done when this method is called, raises
        InvalidStateError.
        rIzPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r/r0rr<�
isinstance�type�
StopIteration�	TypeErrorr$r;r2r#)rr!rrr�
set_exception�s

zFuture.set_exceptionccs,|��sd|_|V|��s$td��|��S)NTzawait wasn't used with future)r9�_asyncio_future_blockingr-r>rrrr�	__await__szFuture.__await__)"r�
__module__�__qualname__�__doc__r0r/r=r$r
rrPr#rrZ_future_repr_inforrr'�propertyr)�setterr.r3r2r8r9r>r!rBrHrJrOrQ�__iter__rrrrrs:

rcCs,z
|j}Wntk
rYnX|�S|jSr()r.�AttributeErrorr
)�futr.rrr�	_get_loops
rZcCs|��rdS|�|�dS)z?Helper setting the result only if the future was not cancelled.N)r8rJ)rYr>rrr�_set_result_unless_cancelledsr[cCsXt|�}|tjjkr tj|j�S|tjjkr8tj|j�S|tjjkrPtj|j�S|SdSr()rL�
concurrent�futuresr:r�args�TimeoutErrorr<)r%Z	exc_classrrr�_convert_future_exc#sr`cCs^|��st�|��r|��|��s(dS|��}|dk	rH|�t|��n|��}|�	|�dS)z8Copy state from a future to a concurrent.futures.Future.N)
r9�AssertionErrorr8r3Zset_running_or_notify_cancelr!rOr`r>rJ)r\�sourcer!r>rrr�_set_concurrent_future_state/srccCsl|��st�|��rdS|��r$t�|��r6|��n2|��}|dk	rV|�t|��n|��}|�|�dS)zqInternal helper to copy state from another Future.

    The other Future may be a concurrent.futures.Future.
    N)	r9rar8r3r!rOr`r>rJ)rb�destr!r>rrr�_copy_future_state>s
recs�t��st�tjj�std��t��s<t�tjj�s<td��t��rLt��nd�t��r`t��nd�dd�����fdd�}����fdd	�}��|���|�dS)
aChain two futures so that when one completes, so does the other.

    The result (or exception) of source will be copied to destination.
    If destination is cancelled, source gets cancelled too.
    Compatible with both asyncio.Future and concurrent.futures.Future.
    z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|�rt||�n
t||�dSr()rrerc)r"�otherrrr�
_set_statebsz!_chain_future.<locals>._set_statecs2|��r.�dks��kr"���n���j�dSr()r8r3�call_soon_threadsafe)�destination)�	dest_looprb�source_looprr�_call_check_cancelhs
z)_chain_future.<locals>._call_check_cancelcsJ���r�dk	r���rdS�dks,��kr8��|�n����|�dSr()r8Z	is_closedrh)rb)rgrjrirkrr�_call_set_stateos��z&_chain_future.<locals>._call_set_state)rrKr\r]rrNrZrB)rbrirlrmr)rgrjrirbrkr�
_chain_futureRs��	
rnr
cCsNt|�r|St|tjj�s(td|����|dkr8t��}|��}t	||�|S)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got N)
rrKr\r]rrarrZ
create_futurern)r"rZ
new_futurerrrr|s�
r)rT�__all__Zconcurrent.futuresr\r?Zloggingr�rrrr	rr0r1r;�DEBUGZSTACK_DEBUGrZ	_PyFuturerZr[r`rcrernrZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s:
q*
PK
0�\�O�=]=]$proactor_events.cpython-38.opt-1.pycnu�[���U

e5d<}�@sTdZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
dd	l	mZdd
l	mZddl	mZddl	mZdd
lmZdd�ZGdd�dejej�ZGdd�deej�ZGdd�deej�ZGdd�de�ZGdd�de�ZGdd�deeej�ZGdd�deeej�Z Gdd�de
j!�Z"dS) z�Event loop using a proactor and related classes.

A proactor is a "notify-on-completion" multiplexer.  Currently a
proactor is only implemented on Windows with IOCP.
)�BaseProactorEventLoop�N�)�base_events)�	constants)�futures)�
exceptions)�	protocols)�sslproto)�
transports)�trsock)�loggercCs�t�|�|jd<z|��|jd<Wn0tjk
rR|j��rNtj	d|dd�YnXd|jkr�z|�
�|jd<Wn tjk
r�d|jd<YnXdS)N�socketZsocknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extraZgetsocknamer
�error�_loop�	get_debugr�warningZgetpeername)�	transport�sock�r�//usr/lib64/python3.8/asyncio/proactor_events.py�_set_socket_extras
�
rcs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejfdd�Z
ddd�Zdd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncs�t��||�|�|�||_|�|�||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	rl|j�
�|j�|jj|�|dk	r�|j�tj|d�dS)NrF)�super�__init__�
_set_extra�_sock�set_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_eof_writtenZ_attachr�	call_soon�	_protocolZconnection_maderZ_set_result_unless_cancelled��self�loopr�protocol�waiter�extra�server��	__class__rrr2s(




�z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|jdk	rP|�d|j�����|jdk	rl|�d|j���|jdk	r�|�d|j���|jr�|�dt	|j����|j
r�|�d�d�d	�|��S)
N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� )
r4�__name__r �appendr(�filenor$r%r#�lenr)�format�join)r-�inforrr�__repr__Hs 






z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)r�r-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs
||_dS�N�r+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrC�r-rrr�get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr�
is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr
dSd|_|jd7_|js>|jdkr>|j�|jd�|jdk	rX|j��d|_dS)NTr)	r(r'r#r%rr*�_call_connection_lostr$�cancelrDrrr�closefs

z _ProactorBasePipeTransport.closecCs*|jdk	r&|d|��t|d�|��dS)Nzunclosed transport )�source)r �ResourceWarningrI)r-Z_warnrrr�__del__qs
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportc	CsVzDt|t�r*|j��rBtjd||dd�n|j�||||jd��W5|�|�XdS)Nz%r: %sTr)�message�	exceptionrr/)	�_force_close�
isinstance�OSErrorrrr�debug�call_exception_handlerr+)r-�excrNrrr�_fatal_errorvs

�z'_ProactorBasePipeTransport._fatal_errorcCs�|jdk	r6|j��s6|dkr*|j�d�n|j�|�|jr@dSd|_|jd7_|jrj|j��d|_|jr�|j��d|_d|_	d|_
|j�|j
|�dS)NTrr)�
_empty_waiter�done�
set_resultZ
set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrP�s"

z'_ProactorBasePipeTransport._force_closec	Cs^z|j�	|�W5t|jd�r,|j�tj�|j��d|_|j}|dk	rX|��d|_XdS)N�shutdown)
�hasattrr rZr
Z	SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrG�s
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk	r|t|j�7}|SrB)r&r#r;)r-�sizerrr�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8�
__module__�__qualname__�__doc__rr?rr!rErFrI�warnings�warnrLrVrPrGr]�
__classcell__rrr3rr.s �
rcsTeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
�ZS)�_ProactorReadPipeTransportzTransport for read pipes.Ncs:d|_d|_t��||||||�|j�|j�d|_dS)NTF)�
_pending_data�_pausedrrrr*�
_loop_readingr,r3rrr�s
z#_ProactorReadPipeTransport.__init__cCs|jo|jSrB)rfr(rDrrr�
is_reading�sz%_ProactorReadPipeTransport.is_readingcCs0|js|jrdSd|_|j��r,t�d|�dS)NTz%r pauses reading)r(rfrrrrSrDrrr�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsn|js|jsdSd|_|jdkr0|j�|jd�|j}d|_|dk	rT|j�|j|�|j��rjt	�
d|�dS)NFz%r resumes reading)r(rfr$rr*rgre�_data_receivedrrrS�r-�datarrr�resume_reading�s

z)_ProactorReadPipeTransport.resume_readingc
Cs�|j��rt�d|�z|j��}WnLttfk
r>�Yn4tk
rp}z|�	|d�WY�dSd}~XYnX|s~|�
�dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrrrSr+Zeof_received�
SystemExit�KeyboardInterrupt�
BaseExceptionrVrI)r-Z	keep_openrUrrr�
_eof_received�s
�z(_ProactorReadPipeTransport._eof_receivedc
Cs�|jr||_dS|s |��dSt|jtj�r�zt�|j|�Wq�tt	fk
rZ�Yq�t
k
r�}z|�|d�WY�dSd}~XYq�Xn|j�|�dS)Nz3Fatal error: protocol.buffer_updated() call failed.)
rfrerqrQr+rZBufferedProtocolZ_feed_data_to_buffered_protornrorprVZ
data_received)r-rlrUrrrrj�s"�z)_ProactorReadPipeTransport._data_receivedc
Cstd}�zRzp|dk	r2d|_|��r*|��}n|��|jrHd}WW��dS|dkr\WW��dS|jsv|jj�	|j
d�|_Wn�tk
r�}z0|js�|�|d�n|j�
�r�tjddd�W5d}~XYn�tk
r�}z|�|�W5d}~XYnftk
�r}z|�|d�W5d}~XYn8tjk
�r>|j�s:�YnX|j�sV|j�|j�W5|dk	�rn|�|�XdS)N�i�z"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rjr$rX�resultrHr(rfr�	_proactor�recvr �ConnectionAbortedErrorrVrrrS�ConnectionResetErrorrPrRr�CancelledError�add_done_callbackrg)r-�futrlrUrrrrgs@

�
z(_ProactorReadPipeTransport._loop_reading)NNN)N)r8r^r_r`rrhrirmrqrjrgrcrrr3rrd�s�	rdcs^eZdZdZdZ�fdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)�_ProactorBaseWritePipeTransportzTransport for write pipes.Tcst�j||�d|_dSrB)rrrW�r-�args�kwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCs�t|tttf�s$tdt|�j����|jr2td��|j	dk	rDtd��|sLdS|j
rz|j
tjkrht
�d�|j
d7_
dS|jdkr�|jt|�d�n.|js�t|�|_|��n|j�|�|��dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rl)rQ�bytes�	bytearray�
memoryview�	TypeError�typer8r)�RuntimeErrorrWr'r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESrrr%�
_loop_writingr#�_maybe_pause_protocol�extendrkrrr�writeKs,�




z%_ProactorBaseWritePipeTransport.writeNc
CsVz�|dk	r |jdkr |jr WdSd|_d|_|r8|��|dkrL|j}d|_|s�|jrf|j�|jd�|jrz|j	�
tj�|�
�nN|jj�|j	|�|_|j��s�t|�|_|j�|j�|��n|j�|j�|jdk	r�|jdkr�|j�d�Wn\tk
�r"}z|�|�W5d}~XYn0tk
�rP}z|�|d�W5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(r&rsr#rr*rGr)r rZr
�SHUT_WR�_maybe_resume_protocolrt�sendrXr;ryr�r�rWrYrwrPrRrV)r-�frlrUrrrr�qs8



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS�NTrrDrrr�
can_write_eof�sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|��dSrB)rIrDrrr�	write_eof�sz)_ProactorBaseWritePipeTransport.write_eofcCs|�d�dSrB�rPrDrrr�abort�sz%_ProactorBaseWritePipeTransport.abortcCs:|jdk	rtd��|j��|_|jdkr4|j�d�|jS)NzEmpty waiter is already set)rWr�rZ
create_futurer%rYrDrrr�_make_empty_waiter�s

z2_ProactorBaseWritePipeTransport._make_empty_waitercCs
d|_dSrB)rWrDrrr�_reset_empty_waiter�sz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)r8r^r_r`Z_start_tls_compatiblerr�r�r�r�r�r�r�rcrrr3rr{As&
)r{cs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs4t�j||�|jj�|jd�|_|j�|j�dS)N�)	rrrrtrur r$ry�_pipe_closedr|r3rrr�sz$_ProactorWritePipeTransport.__init__cCs@|��rdS|jrdSd|_|jdk	r4|�t��n|��dSrB)Z	cancelledr(r$r%rP�BrokenPipeErrorrI)r-rzrrrr��s
z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rr�rcrrr3rr��sr�csXeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	ddd�Z
�ZS)�_ProactorDatagramTransportiNcs>||_d|_t�j|||||d�t��|_|j�|j	�dS)N)r0r1)
�_addressrWrr�collections�dequer#rr*rg)r-r.rr/�addressr0r1r3rrr�s

z#_ProactorDatagramTransport.__init__cCst||�dSrB�rrArrrr�sz%_ProactorDatagramTransport._set_extracCstdd�|jD��S)Ncss|]\}}t|�VqdSrB)r;)�.0rl�_rrr�	<genexpr>�szC_ProactorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr#rDrrrr]�sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|�d�dSrBr�rDrrrr��sz _ProactorDatagramTransport.abortcCs�t|tttf�stdt|���|s&dS|jdk	rN|d|jfkrNtd|j����|jr�|jr�|jt	j
krpt�d�|jd7_dS|j
�t|�|f�|jdkr�|��|��dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQrr�r�r�r�r��
ValueErrorr'rr�rrr#r9r%r�r�)r-rl�addrrrr�sendto�s&�
�

z!_ProactorDatagramTransport.sendtoc
Csz�|jrWdSd|_|r |��|jr2|jrN|jrN|jrH|j�|jd�WdS|j�	�\}}|jdk	r||jj
�|j|�|_n|jj
j
|j||d�|_WnZtk
r�}z|j�|�W5d}~XYnDtk
r�}z|�|d�W5d}~XYnX|j�|j�|��dS)N)r�z'Fatal write error on datagram transport)r'r%rsr#r�r(rr*rG�popleftrtr�r r�rRr+�error_received�	ExceptionrVryr�r�)r-rzrlr�rUrrrr��s2
��z(_ProactorDatagramTransport._loop_writingc
Cs4d}�zz�|jrWW��dSd|_|dk	rf|��}|jrFd}WW��dS|jdk	r^||j}}n|\}}|jrvWW��dS|jdk	r�|jj�	|j
|j�|_n|jj�|j
|j�|_WnJt
k
r�}z|j�|�W5d}~XYn8tjk
r�|js��YnX|jdk	�r|j�|j�W5|�r.|j�||�XdSrB)r+Zdatagram_receivedr'r$rsr(r�rrtrur �max_sizeZrecvfromrRr�rrxryrg)r-rzrlr��resrUrrrrgs>



��
z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N)r8r^r_r�rrr]r�r�r�rgrcrrr3rr��s�

!r�c@s eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFrrDrrrr�Jsz*_ProactorDuplexPipeTransport.can_write_eofcCst�dSrB)�NotImplementedErrorrDrrrr�Msz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_r`r�r�rrrrr�Esr�csBeZdZdZejjZd�fdd�	Zdd�Z	dd�Z
d	d
�Z�ZS)�_ProactorSocketTransportz Transport for connected sockets.Ncs$t��||||||�t�|�dSrB)rrrZ_set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||�dSrBr�rArrrr]sz#_ProactorSocketTransport._set_extracCsdSr�rrDrrrr�`sz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdkr.|j�tj�dSr�)r(r)r%r rZr
r�rDrrrr�cs

z"_ProactorSocketTransport.write_eof)NNN)
r8r^r_r`rZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerrr�r�rcrrr3rr�Qs�r�cs�eZdZ�fdd�Zd3dd�Zd4dddddd�dd	�Zd5d
d�Zd6dd
�Zd7dd�Zd8dd�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd9d&d'�Zd(d)�Zd:d+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS);rcsht���t�d|jj�||_||_d|_i|_	|�
|�|��t�
�t��krdt�|j���dS)NzUsing proactor: %s)rrrrSr4r8rt�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe�	threading�current_thread�main_thread�signal�
set_wakeup_fd�_csockr:)r-Zproactorr3rrrms

zBaseProactorEventLoop.__init__NcCst||||||�SrB)r�)r-rr/r0r1r2rrr�_make_socket_transportzs
�z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer1r2�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r��r1r2)r	ZSSLProtocolr�Z_app_transport)r-Zrawsockr/�
sslcontextr0r�r�r1r2r�Zssl_protocolrrr�_make_ssl_transports��z)BaseProactorEventLoop._make_ssl_transportcCst||||||�SrB)r�)r-rr/r�r0r1rrr�_make_datagram_transport�s
�z.BaseProactorEventLoop._make_datagram_transportcCst|||||�SrB)r��r-rr/r0r1rrr�_make_duplex_pipe_transport�s�z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�SrB)rdr�rrr�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�SrB)r�r�rrr�_make_write_pipe_transport�s�z0BaseProactorEventLoop._make_write_pipe_transportcsj|��rtd��|��rdSt��t��kr6t�d�|��|�	�|j
��d|_
d|_t
���dS)Nz!Cannot close a running event loop���)Z
is_runningr��	is_closedr�r�r�r�r��_stop_accept_futures�_close_self_pipertrIr�rrDr3rrrI�s

zBaseProactorEventLoop.closec�s|j�||�IdHSrB)rtru)r-r�nrrr�	sock_recv�szBaseProactorEventLoop.sock_recvc�s|j�||�IdHSrB)rtZ	recv_into)r-rZbufrrr�sock_recv_into�sz$BaseProactorEventLoop.sock_recv_intoc�s|j�||�IdHSrB)rtr�)r-rrlrrr�sock_sendall�sz"BaseProactorEventLoop.sock_sendallc�s|j�||�IdHSrB)rtZconnect)r-rr�rrr�sock_connect�sz"BaseProactorEventLoop.sock_connectc�s|j�|�IdHSrB)rt�acceptrArrr�sock_accept�sz!BaseProactorEventLoop.sock_acceptc
�s(z|��}Wn2ttjfk
r>}zt�d��W5d}~XYnXzt�|�j}Wn,t	k
r|}zt�d��W5d}~XYnX|r�|n|}|s�dSt
|d�}|r�t
|||�n|}	t
||�}d}
zLt
|	||�}|dkr�|
W�0S|j�
||||�IdH||7}|
|7}
q�W5|
dk�r"|�|�XdS)Nznot a regular filerl��)r:�AttributeError�io�UnsupportedOperationrZSendfileNotAvailableError�os�fstat�st_sizerR�min�seekrt�sendfile)r-r�file�offset�countr:�errZfsizeZ	blocksizeZend_posZ
total_sentrrr�_sock_sendfile_native�s0


z+BaseProactorEventLoop._sock_sendfile_nativec�sZ|��}|��|��IdHz |j|j|||dd�IdHW�S|��|rT|��XdS)NF)Zfallback)rhrir�r�rmZ
sock_sendfiler )r-Ztranspr�r�r�rmrrr�_sendfile_native�s�z&BaseProactorEventLoop._sendfile_nativecCsL|jdk	r|j��d|_|j��d|_|j��d|_|jd8_dS)Nr)r�rH�_ssockrIr��
_internal_fdsrDrrrr��s



z&BaseProactorEventLoop._close_self_pipecCs:t��\|_|_|j�d�|j�d�|jd7_dS)NFr)r
Z
socketpairr�r�Zsetblockingr�rDrrrr��sz%BaseProactorEventLoop._make_self_pipec
Cs�z4|dk	r|��|j|k	r"WdS|j�|jd�}Wnbtjk
rLYdSttfk
rd�YnFt	k
r�}z|�
d||d��W5d}~XYnX||_|�|j�dS)Niz.Error on reading from the event loop self pipe)rNrOr.)
rsr�rtrur�rrxrnrorprTry�_loop_self_reading)r-r�rUrrrr��s$
�z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|�d�Wn(tk
rH|jrDtjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketTr)r�r�rR�_debugrrS)r-Zcsockrrr�_write_to_selfs�z$BaseProactorEventLoop._write_to_self�dcs(d�������fdd�	�����dS)Nc
s,z�|dk	rn|��\}}�jr,t�d�||���}�dk	rX�j||�dd|i��d�n�j||d|i�d����r|WdS�j���}Wn�t	k
r�}zH��
�dkrʈ�d|t�
��d�����n�jr�tjd	�dd
�W5d}~XYn8tjk
�r���YnX|�j��
�<|���dS)Nz#%r got a new connection from %r: %rTr)r�r1r2r�r�r�zAccept failed on a socket)rNrOr
zAccept failed on socket %rr)rsr�rrSr�r�r�rtr�rRr:rTrrrIrrxr�ry)r�Zconnr�r/rU�r.�protocol_factoryr-r2rr�r�rrr./s\����
�z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r*)r-r�rr�r2Zbacklogr�rr�r�_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z
event_listrrr�_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|j��D]}|��q
|j��dSrB)r��valuesrH�clear)r-�futurerrrr�Zs
z*BaseProactorEventLoop._stop_accept_futurescCs6|j�|��d�}|r|��|j�|�|��dSrB)r��popr:rHrt�
_stop_servingrI)r-rr�rrrr�_s
z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNr�N)r8r^r_rr�r�r�r�r�r�rIr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rcrrr3rrks\
�
���
�
�
�


�
+r)#r`�__all__r�r�r
rar�r�r��rrrrrr	r
r�logrrZ_FlowControlMixinZ
BaseTransportrZ
ReadTransportrdZWriteTransportr{r�r�Z	Transportr�r�Z
BaseEventLooprrrrr�<module>sR���n��PK
0�\�\@��/�/transports.cpython-38.opt-1.pycnu�[���U

e5d�(�@s|dZdZGdd�d�ZGdd�de�ZGdd�de�ZGdd	�d	ee�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZdS)zAbstract Transport class.)�
BaseTransport�
ReadTransport�WriteTransport�	Transport�DatagramTransport�SubprocessTransportc@sHeZdZdZdZddd�Zddd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)rzBase class for transports.��_extraNcCs|dkri}||_dS�Nr)�self�extra�r�*/usr/lib64/python3.8/asyncio/transports.py�__init__szBaseTransport.__init__cCs|j�||�S)z#Get optional transport information.)r�get)r
�name�defaultrrr
�get_extra_infoszBaseTransport.get_extra_infocCst�dS)z2Return True if the transport is closing or closed.N��NotImplementedError�r
rrr
�
is_closingszBaseTransport.is_closingcCst�dS)aClose the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        Nrrrrr
�closeszBaseTransport.closecCst�dS)zSet a new protocol.Nr)r
�protocolrrr
�set_protocol%szBaseTransport.set_protocolcCst�dS)zReturn the current protocol.Nrrrrr
�get_protocol)szBaseTransport.get_protocol)N)N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrrrr
r	s


rc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
rz#Interface for read-only transports.rcCst�dS)z*Return True if the transport is receiving.Nrrrrr
�
is_reading3szReadTransport.is_readingcCst�dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        Nrrrrr
�
pause_reading7szReadTransport.pause_readingcCst�dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        Nrrrrr
�resume_reading?szReadTransport.resume_readingN)rrrrrr r!r"rrrr
r.s
rc@sNeZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)rz$Interface for write-only transports.rNcCst�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        Nr�r
�high�lowrrr
�set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCst�dS)z,Return the current size of the write buffer.Nrrrrr
�get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCst�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        Nr)r
�datarrr
�writefszWriteTransport.writecCsd�|�}|�|�dS)z�Write a list (or any iterable) of data bytes to the transport.

        The default implementation concatenates the arguments and
        calls write() on the result.
        �N)�joinr))r
Zlist_of_datar(rrr
�
writelinesns
zWriteTransport.writelinescCst�dS)z�Close the write end after flushing buffered data.

        (This is like typing ^D into a UNIX program reading from stdin.)

        Data may still be received.
        Nrrrrr
�	write_eofwszWriteTransport.write_eofcCst�dS)zAReturn True if this transport supports write_eof(), False if not.Nrrrrr
�
can_write_eof�szWriteTransport.can_write_eofcCst�dS�z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        Nrrrrr
�abort�szWriteTransport.abort)NN)rrrrrr&r'r)r,r-r.r0rrrr
rHs
		rc@seZdZdZdZdS)raSInterface representing a bidirectional transport.

    There may be several implementations, but typically, the user does
    not implement new transports; rather, the platform provides some
    useful transports that are implemented using the platform's best
    practices.

    The user never instantiates a transport directly; they call a
    utility function, passing it a protocol factory and other
    information necessary to create the transport and protocol.  (E.g.
    EventLoop.create_connection() or EventLoop.create_server().)

    The utility function will asynchronously create a transport and a
    protocol and hook them up by calling the protocol's
    connection_made() method, passing it the transport.

    The implementation here raises NotImplemented for every method
    except writelines(), which calls write() in a loop.
    rN)rrrrrrrrr
r�src@s&eZdZdZdZddd�Zdd�ZdS)	rz(Interface for datagram (UDP) transports.rNcCst�dS)aSend data to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        addr is target socket address.
        If addr is None use target address pointed on transport creation.
        Nr)r
r(Zaddrrrr
�sendto�szDatagramTransport.sendtocCst�dSr/rrrrr
r0�szDatagramTransport.abort)N)rrrrrr1r0rrrr
r�s

rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rrcCst�dS)zGet subprocess id.Nrrrrr
�get_pid�szSubprocessTransport.get_pidcCst�dS)z�Get subprocess returncode.

        See also
        http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode
        Nrrrrr
�get_returncode�sz"SubprocessTransport.get_returncodecCst�dS)z&Get transport for pipe with number fd.Nr)r
�fdrrr
�get_pipe_transport�sz&SubprocessTransport.get_pipe_transportcCst�dS)z�Send signal to subprocess.

        See also:
        docs.python.org/3/library/subprocess#subprocess.Popen.send_signal
        Nr)r
�signalrrr
�send_signal�szSubprocessTransport.send_signalcCst�dS)aLStop the subprocess.

        Alias for close() method.

        On Posix OSs the method sends SIGTERM to the subprocess.
        On Windows the Win32 API function TerminateProcess()
         is called to stop the subprocess.

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate
        Nrrrrr
�	terminate�szSubprocessTransport.terminatecCst�dS)z�Kill the subprocess.

        On Posix OSs the function sends SIGKILL to the subprocess.
        On Windows kill() is an alias for terminate().

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.kill
        Nrrrrr
�kill�s	zSubprocessTransport.killN)
rrrrr2r3r5r7r8r9rrrr
r�srcsZeZdZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zddd
�Z	ddd�Z
dd�Z�ZS)�_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class.

    The subclass must implement get_write_buffer_size().  It must call
    _maybe_pause_protocol() whenever the write buffer size increases,
    and _maybe_resume_protocol() whenever it decreases.  It may also
    override set_write_buffer_limits() (e.g. to specify different
    defaults).

    The subclass constructor must call super().__init__(extra).  This
    will call set_write_buffer_limits().

    The user may call set_write_buffer_limits() and
    get_write_buffer_size(), and their protocol's pause_writing() and
    resume_writing() may be called.
    )�_loop�_protocol_paused�_high_water�
_low_waterNcs$t��|�||_d|_|��dS)NF)�superrr;r<�_set_write_buffer_limits)r
rZloop��	__class__rr
rsz_FlowControlMixin.__init__c
Cs�|��}||jkrdS|js�d|_z|j��WnRttfk
rJ�Yn:tk
r�}z|j�	d|||jd��W5d}~XYnXdS)NTzprotocol.pause_writing() failed��messageZ	exceptionZ	transportr)
r'r=r<�	_protocolZ
pause_writing�
SystemExit�KeyboardInterrupt�
BaseExceptionr;�call_exception_handler)r
�size�excrrr
�_maybe_pause_protocols 
�z'_FlowControlMixin._maybe_pause_protocolc
Cs�|jr||��|jkr|d|_z|j��WnRttfk
rB�Yn:tk
rz}z|j�	d|||jd��W5d}~XYnXdS)NFz protocol.resume_writing() failedrC)
r<r'r>rEZresume_writingrFrGrHr;rI)r
rKrrr
�_maybe_resume_protocol!s��z(_FlowControlMixin._maybe_resume_protocolcCs|j|jfSr	)r>r=rrrr
�get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|�d|�d���||_||_dS)Ni��zhigh (z) must be >= low (z) must be >= 0)�
ValueErrorr=r>r#rrr
r@4s�z*_FlowControlMixin._set_write_buffer_limitscCs|j||d�|��dS)N)r$r%)r@rLr#rrr
r&Dsz)_FlowControlMixin.set_write_buffer_limitscCst�dSr	rrrrr
r'Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN)
rrrrrrrLrMrNr@r&r'�
__classcell__rrrAr
r:�s

r:N)	r�__all__rrrrrrr:rrrr
�<module>s%F6PK
0�\���  futures.cpython-38.opt-2.pycnu�[���U

e5db3�@s�dZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ejZejZej
Z
ejZejdZGdd	�d	�ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�dd�ZzddlZWnek
r�YnXejZZdS))�Future�wrap_future�isfuture�N�)�base_futures)�events)�
exceptions)�format_helpersc@s�eZdZeZdZdZdZdZdZ	dZ
dd�dd�Zej
Zdd�Zdd	�Zed
d��Zejdd��Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�dd�Zdd�Zd d!�Zd"d#�Zd$d%�ZeZ dS)&rNF��loopcCs@|dkrt��|_n||_g|_|j��r<t�t�d��|_	dS)Nr)
r�get_event_loop�_loop�
_callbacksZ	get_debugr	�
extract_stack�sys�	_getframe�_source_traceback��selfr�r�'/usr/lib64/python3.8/asyncio/futures.py�__init__Ds
�zFuture.__init__cCsd�|jjd�|����S)Nz<{} {}>� )�format�	__class__�__name__�join�
_repr_info�rrrr�__repr__Vs
�zFuture.__repr__cCsF|js
dS|j}|jj�d�||d�}|jr6|j|d<|j�|�dS)Nz exception was never retrieved)�message�	exception�futureZsource_traceback)�_Future__log_traceback�
_exceptionrrrr
Zcall_exception_handler)r�exc�contextrrr�__del__Zs�
zFuture.__del__cCs|jS�N)r#rrrr�_log_tracebackjszFuture._log_tracebackcCst|�rtd��d|_dS)Nz'_log_traceback can only be set to FalseF)�bool�
ValueErrorr#)r�valrrrr)nscCs|j}|dkrtd��|S)Nz!Future object is not initialized.)r
�RuntimeErrorrrrr�get_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|��dS)NFT)r#�_state�_PENDING�
_CANCELLED�_Future__schedule_callbacksrrrr�cancel{s
z
Future.cancelcCsH|jdd�}|sdSg|jdd�<|D]\}}|jj|||d�q(dS�N�r&)rr
�	call_soon)rZ	callbacks�callback�ctxrrrZ__schedule_callbacks�szFuture.__schedule_callbackscCs
|jtkSr()r/r1rrrr�	cancelled�szFuture.cancelledcCs
|jtkSr()r/r0rrrr�done�szFuture.donecCs@|jtkrtj�|jtkr$t�d��d|_|jdk	r:|j�|jS)NzResult is not ready.F)	r/r1r�CancelledError�	_FINISHED�InvalidStateErrorr#r$�_resultrrrr�result�s



z
Future.resultcCs0|jtkrtj�|jtkr$t�d��d|_|jS)NzException is not set.F)r/r1rr;r<r=r#r$rrrrr!�s


zFuture.exceptionr5cCsB|jtkr|jj|||d�n |dkr.t��}|j�||f�dSr4)r/r0r
r6�contextvarsZcopy_contextr�append)r�fnr&rrr�add_done_callback�s

zFuture.add_done_callbackcs<�fdd�|jD�}t|j�t|�}|r8||jdd�<|S)Ncs g|]\}}|�kr||f�qSrr)�.0�fr8�rBrr�
<listcomp>�s�z/Future.remove_done_callback.<locals>.<listcomp>)r�len)rrBZfiltered_callbacksZ
removed_countrrFr�remove_done_callback�s
�zFuture.remove_done_callbackcCs8|jtkr t�|j�d|����||_t|_|��dS)N�: )r/r0rr=r>r<r2)rr?rrr�
set_result�s

zFuture.set_resultcCsb|jtkr t�|j�d|����t|t�r0|�}t|�tkrDtd��||_t	|_|�
�d|_dS)NrJzPStopIteration interacts badly with generators and cannot be raised into a FutureT)r/r0rr=�
isinstance�type�
StopIteration�	TypeErrorr$r<r2r#)rr!rrr�
set_exception�s

zFuture.set_exceptionccs,|��sd|_|V|��s$td��|��S)NTzawait wasn't used with future)r:�_asyncio_future_blockingr-r?rrrr�	__await__szFuture.__await__)!r�
__module__�__qualname__r0r/r>r$r
rrQr#rrZ_future_repr_inforrr'�propertyr)�setterr.r3r2r9r:r?r!rCrIrKrPrR�__iter__rrrrrs8

rcCs,z
|j}Wntk
rYnX|�S|jSr()r.�AttributeErrorr
)�futr.rrr�	_get_loops
rZcCs|��rdS|�|�dSr()r9rK)rYr?rrr�_set_result_unless_cancelledsr[cCsXt|�}|tjjkr tj|j�S|tjjkr8tj|j�S|tjjkrPtj|j�S|SdSr()rM�
concurrent�futuresr;r�args�TimeoutErrorr=)r%Z	exc_classrrr�_convert_future_exc#sr`cCsR|��r|��|��sdS|��}|dk	r<|�t|��n|��}|�|�dSr()r9r3Zset_running_or_notify_cancelr!rPr`r?rK)r\�sourcer!r?rrr�_set_concurrent_future_state/srbcCsT|��rdS|��r|��n2|��}|dk	r>|�t|��n|��}|�|�dSr()r9r3r!rPr`r?rK)ra�destr!r?rrr�_copy_future_state>s
rdcs�t��st�tjj�std��t��s<t�tjj�s<td��t��rLt��nd�t��r`t��nd�dd�����fdd�}����fdd�}��|���|�dS)	Nz(A future is required for source argumentz-A future is required for destination argumentcSs"t|�rt||�n
t||�dSr()rrdrb)r"�otherrrr�
_set_statebsz!_chain_future.<locals>._set_statecs2|��r.�dks��kr"���n���j�dSr()r9r3�call_soon_threadsafe)�destination)�	dest_loopra�source_looprr�_call_check_cancelhs
z)_chain_future.<locals>._call_check_cancelcsJ���r�dk	r���rdS�dks,��kr8��|�n����|�dSr()r9Z	is_closedrg)ra)rfrirhrjrr�_call_set_stateos��z&_chain_future.<locals>._call_set_state)rrLr\r]rrOrZrC)rarhrkrlr)rfrirhrarjr�
_chain_futureRs��	
rmr
cCs2t|�r|S|dkrt��}|��}t||�|Sr()rrrZ
create_futurerm)r"rZ
new_futurerrrr|s
r)�__all__Zconcurrent.futuresr\r@Zloggingr�rrrr	rr0r1r<�DEBUGZSTACK_DEBUGrZ	_PyFuturerZr[r`rbrdrmrZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s8
q*
PK
0�\wI<wssexceptions.cpython-38.opt-2.pycnu�[���U

e5da�@shdZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
e�Z	Gdd�de�Z
d
S))�CancelledError�InvalidStateError�TimeoutError�IncompleteReadError�LimitOverrunError�SendfileNotAvailableErrorc@seZdZdS)rN��__name__�
__module__�__qualname__�rr�*/usr/lib64/python3.8/asyncio/exceptions.pyr	src@seZdZdS)rNrrrrrr
src@seZdZdS)rNrrrrrrsrc@seZdZdS)rNrrrrrrsrcs$eZdZ�fdd�Zdd�Z�ZS)rcs@|dkrdnt|�}t��t|��d|�d��||_||_dS)NZ	undefinedz bytes read on a total of z expected bytes)�repr�super�__init__�len�partial�expected)�selfrrZ
r_expected��	__class__rrr$szIncompleteReadError.__init__cCst|�|j|jffS�N)�typerr�rrrr�
__reduce__+szIncompleteReadError.__reduce__�rr	r
rr�
__classcell__rrrrrsrcs$eZdZ�fdd�Zdd�Z�ZS)rcst��|�||_dSr)rr�consumed)r�messagerrrrr5szLimitOverrunError.__init__cCst|�|jd|jffS)N�)r�argsrrrrrr9szLimitOverrunError.__reduce__rrrrrr/srN)�__all__�
BaseExceptionr�	Exceptionrr�RuntimeErrorr�EOFErrorrrrrrr�<module>sPK
0�\k*�	�	exceptions.cpython-38.opt-1.pycnu�[���U

e5da�@sldZdZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de	�Z
Gdd
�d
e�ZdS)zasyncio exceptions.)�CancelledError�InvalidStateError�TimeoutError�IncompleteReadError�LimitOverrunError�SendfileNotAvailableErrorc@seZdZdZdS)rz!The Future or Task was cancelled.N��__name__�
__module__�__qualname__�__doc__�rr�*/usr/lib64/python3.8/asyncio/exceptions.pyr	src@seZdZdZdS)rz*The operation exceeded the given deadline.Nrrrrr
r
src@seZdZdZdS)rz+The operation is not allowed in this state.Nrrrrr
rsrc@seZdZdZdS)rz~Sendfile syscall is not available.

    Raised if OS does not support sendfile syscall for given socket or
    file type.
    Nrrrrr
rsrcs(eZdZdZ�fdd�Zdd�Z�ZS)rz�
    Incomplete read error. Attributes:

    - partial: read bytes string before the end of stream was reached
    - expected: total number of expected bytes (or None if unknown)
    cs@|dkrdnt|�}t��t|��d|�d��||_||_dS)NZ	undefinedz bytes read on a total of z expected bytes)�repr�super�__init__�len�partial�expected)�selfrrZ
r_expected��	__class__rr
r$szIncompleteReadError.__init__cCst|�|j|jffS�N)�typerr�rrrr
�
__reduce__+szIncompleteReadError.__reduce__�rr	r
rrr�
__classcell__rrrr
rsrcs(eZdZdZ�fdd�Zdd�Z�ZS)rz�Reached the buffer limit while looking for a separator.

    Attributes:
    - consumed: total number of to be consumed bytes.
    cst��|�||_dSr)rr�consumed)r�messagerrrr
r5szLimitOverrunError.__init__cCst|�|jd|jffS)N�)r�argsrrrrr
r9szLimitOverrunError.__reduce__rrrrr
r/srN)r�__all__�
BaseExceptionr�	Exceptionrr�RuntimeErrorr�EOFErrorrrrrrr
�<module>sPK
0�\�Ŀ � queues.cpython-38.opt-1.pycnu�[���U

e5d �@s�dZddlZddlZddlZddlmZddlmZGdd�de�ZGdd	�d	e�Z	Gd
d�d�Z
Gdd
�d
e
�ZGdd�de
�ZdS))�Queue�
PriorityQueue�	LifoQueue�	QueueFull�
QueueEmpty�N�)�events)�locksc@seZdZdZdS)rz;Raised when Queue.get_nowait() is called on an empty Queue.N��__name__�
__module__�__qualname__�__doc__�rr�&/usr/lib64/python3.8/asyncio/queues.pyrsrc@seZdZdZdS)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr
rrrrrsrc@s�eZdZdZd)dd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�ZdS)*raA queue, useful for coordinating producer and consumer coroutines.

    If maxsize is less than or equal to zero, the queue size is infinite. If it
    is an integer greater than 0, then "await put()" will block when the
    queue reaches maxsize, until an item is removed by get().

    Unlike the standard library Queue, you can reliably know this Queue's size
    with qsize(), since your single-threaded asyncio application won't be
    interrupted between calling qsize() and doing an operation on the Queue.
    rN��loopcCsp|dkrt��|_n||_tjdtdd�||_t��|_	t��|_
d|_tj
|d�|_|j��|�|�dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.�)�
stacklevelrr)rZget_event_loop�_loop�warnings�warn�DeprecationWarning�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr	ZEvent�	_finished�set�_init)�self�maxsizerrrr�__init__!s�


zQueue.__init__cCst��|_dS�N)rr�_queue�r"r#rrrr!6szQueue._initcCs
|j��Sr%)r&�popleft�r"rrr�_get9sz
Queue._getcCs|j�|�dSr%�r&�append�r"�itemrrr�_put<sz
Queue._putcCs&|r"|��}|��s|�d�q"qdSr%)r(ZdoneZ
set_result)r"�waitersZwaiterrrr�_wakeup_nextAs

zQueue._wakeup_nextcCs(dt|�j�dt|�d�d|���d�S)N�<z at z#x� �>)�typer�id�_formatr)rrr�__repr__IszQueue.__repr__cCsdt|�j�d|���d�S)Nr2r3r4)r5rr7r)rrr�__str__Lsz
Queue.__str__cCs~d|j��}t|dd�r,|dt|j���7}|jrH|dt|j��d�7}|jrd|dt|j��d�7}|jrz|d|j��7}|S)Nzmaxsize=r&z _queue=z
 _getters[�]z
 _putters[z tasks=)r�getattr�listr&r�lenrr)r"�resultrrrr7Osz
Queue._formatcCs
t|j�S)zNumber of items in the queue.)r=r&r)rrr�qsize[szQueue.qsizecCs|jS)z%Number of items allowed in the queue.)rr)rrrr#_sz
Queue.maxsizecCs|jS)z3Return True if the queue is empty, False otherwise.�r&r)rrr�emptydszQueue.emptycCs |jdkrdS|��|jkSdS)z�Return True if there are maxsize items in the queue.

        Note: if the Queue was initialized with maxsize=0 (the default),
        then full() is never True.
        rFN)rr?r)rrr�fullhs
z
Queue.fullc�s�|��r�|j��}|j�|�z|IdHWq|��z|j�|�Wntk
r`YnX|��s~|��s~|�	|j��YqXq|�
|�S)z�Put an item into the queue.

        Put an item into the queue. If the queue is full, wait until a free
        slot is available before adding item.
        N)rBr�
create_futurerr,�cancel�remove�
ValueError�	cancelledr1�
put_nowait)r"r.Zputterrrr�putss

z	Queue.putcCs>|��rt�|�|�|jd7_|j��|�|j�dS)zyPut an item into the queue without blocking.

        If no free slot is immediately available, raise QueueFull.
        rN)rBrr/rr�clearr1rr-rrrrH�s

zQueue.put_nowaitc�s�|��r�|j��}|j�|�z|IdHWq|��z|j�|�Wntk
r`YnX|��s~|��s~|�	|j��YqXq|�
�S)zoRemove and return an item from the queue.

        If queue is empty, wait until an item is available.
        N)rArrCrr,rDrErFrGr1�
get_nowait)r"�getterrrr�get�s

z	Queue.getcCs$|��rt�|��}|�|j�|S)z�Remove and return an item from the queue.

        Return an item if one is immediately available, else raise QueueEmpty.
        )rArr*r1rr-rrrrK�s
zQueue.get_nowaitcCs8|jdkrtd��|jd8_|jdkr4|j��dS)a$Indicate that a formerly enqueued task is complete.

        Used by queue consumers. For each get() used to fetch a task,
        a subsequent call to task_done() tells the queue that the processing
        on the task is complete.

        If a join() is currently blocking, it will resume when all items have
        been processed (meaning that a task_done() call was received for every
        item that had been put() into the queue).

        Raises ValueError if called more times than there were items placed in
        the queue.
        rz!task_done() called too many timesrN)rrFrr r)rrr�	task_done�s


zQueue.task_donec�s|jdkr|j��IdHdS)aBlock until all items in the queue have been gotten and processed.

        The count of unfinished tasks goes up whenever an item is added to the
        queue. The count goes down whenever a consumer calls task_done() to
        indicate that the item was retrieved and all work on it is complete.
        When the count of unfinished tasks drops to zero, join() unblocks.
        rN)rr�waitr)rrr�join�s
z
Queue.join)r)rrr
rr$r!r*r/r1r8r9r7r?�propertyr#rArBrIrHrMrKrNrPrrrrrs(
rc@s4eZdZdZdd�Zejfdd�Zejfdd�Z	dS)	rz�A subclass of Queue; retrieves entries in priority order (lowest first).

    Entries are typically tuples of the form: (priority number, data).
    cCs
g|_dSr%r@r'rrrr!�szPriorityQueue._initcCs||j|�dSr%r@)r"r.�heappushrrrr/�szPriorityQueue._putcCs
||j�Sr%r@)r"�heappoprrrr*�szPriorityQueue._getN)
rrr
rr!�heapqrRr/rSr*rrrrr�src@s(eZdZdZdd�Zdd�Zdd�ZdS)	rzEA subclass of Queue that retrieves most recently added entries first.cCs
g|_dSr%r@r'rrrr!�szLifoQueue._initcCs|j�|�dSr%r+r-rrrr/�szLifoQueue._putcCs
|j��Sr%)r&�popr)rrrr*�szLifoQueue._getN)rrr
rr!r/r*rrrrr�sr)
�__all__rrTr�rr	�	Exceptionrrrrrrrrr�<module>sKPK
0�\�ۤ�YmYm$selector_events.cpython-38.opt-2.pycnu�[���U

e5dT��@s*dZddlZddlZddlZddlZddlZddlZddlZzddlZWne	k
r`dZYnXddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddlmZd
d�Zdd�ZGdd�dej�ZGdd�dejej�ZGdd�de�ZGdd�de�ZdS))�BaseSelectorEventLoop�N�)�base_events)�	constants)�events)�futures)�	protocols)�sslproto)�
transports)�trsock)�loggercCs8z|�|�}Wntk
r$YdSXt|j|@�SdS�NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�//usr/lib64/python3.8/asyncio/selector_events.py�_test_selector_event s
rcCs tdk	rt|tj�rtd��dS)Nz"Socket cannot be of type SSLSocket)�ssl�
isinstanceZ	SSLSocket�	TypeError)�sockrrr�_check_ssl_socket+srcs�eZdZdR�fdd�	ZdSddd�dd�ZdTddddejd�d	d
�ZdUdd�Z�fd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdddejfdd�Zdddejfdd�Zddejfdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dNdO�Z)dPdQ�Z*�Z+S)VrNcsFt���|dkrt��}t�d|jj�||_|�	�t
��|_dS)NzUsing selector: %s)
�super�__init__�	selectorsZDefaultSelectorr�debug�	__class__�__name__�	_selector�_make_self_pipe�weakrefZWeakValueDictionary�_transports)�selfr�r rrr6s
zBaseSelectorEventLoop.__init__��extra�servercCst||||||�S�N)�_SelectorSocketTransport)r&r�protocol�waiterr)r*rrr�_make_socket_transport@s
�z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer)r*�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r2r()r	ZSSLProtocolr,Z_app_transport)r&Zrawsockr-�
sslcontextr.r0r1r)r*r2Zssl_protocolrrr�_make_ssl_transportEs��z)BaseSelectorEventLoop._make_ssl_transportcCst||||||�Sr+)�_SelectorDatagramTransport)r&rr-�addressr.r)rrr�_make_datagram_transportRs
�z.BaseSelectorEventLoop._make_datagram_transportcsL|��rtd��|��rdS|��t���|jdk	rH|j��d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer"�r&r'rrr;Ws


zBaseSelectorEventLoop.closecCsB|�|j���|j��d|_|j��d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor;�_csock�
_internal_fdsr<rrrr:bs

z&BaseSelectorEventLoop._close_self_pipecCsNt��\|_|_|j�d�|j�d�|jd7_|�|j��|j�dS)NFr)	�socketZ
socketpairr>r@�setblockingrA�_add_readerr?�_read_from_selfr<rrrr#js
z%BaseSelectorEventLoop._make_self_pipecCsdSr+r�r&�datarrr�_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|j�d�}|sWqT|�|�Wqtk
r:YqYqtk
rPYqTYqXqdS)Ni)r>�recvrH�InterruptedError�BlockingIOErrorrFrrrrEusz%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|�d�Wn(tk
rH|jrDtjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketT��exc_info)r@�send�OSError�_debugrr)r&Zcsockrrr�_write_to_self�s�z$BaseSelectorEventLoop._write_to_self�dc
Cs"|�|��|j||||||�dSr+)rDr?�_accept_connection)r&�protocol_factoryrr3r*�backlogr2rrr�_start_serving�s�z$BaseSelectorEventLoop._start_servingc
Cst|�D]�}z0|��\}}	|jr0t�d||	|�|�d�Wn�tttfk
rZYdSt	k
r�}
zd|
j
t
jt
jt
j
t
jfkr�|�d|
t�|�d��|�|���|�tj|j||||||�n�W5d}
~
XYqXd|	i}|�||||||�}|�|�qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exceptionrB�peername)�range�acceptrQrrrCrKrJ�ConnectionAbortedErrorrP�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr�TransportSocketr=r?Z
call_laterrZACCEPT_RETRY_DELAYrW�_accept_connection2Zcreate_task)
r&rUrr3r*rVr2�_�conn�addr�excr)r\rrrrT�sV�����z(BaseSelectorEventLoop._accept_connectionc
�s�d}d}zt|�}|��}	|r8|j||||	d|||d�}n|j|||	||d�}z|	IdHWntk
rx|���YnXWntttfk
r��Yn\tk
r�}
z>|jr�d|
d�}|dk	r�||d<|dk	r�||d<|�|�W5d}
~
XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr-�	transport)	�
create_futurer4r/�
BaseExceptionr;�
SystemExit�KeyboardInterruptrQr_)r&rUrcr)r3r*r2r-rfr.re�contextrrrra�sP���z)BaseSelectorEventLoop._accept_connection2c
Cs�|}t|t�sJzt|���}Wn*tttfk
rHtd|���d�YnXz|j|}Wntk
rlYnX|��s�t	d|�d|����dS)NzInvalid file object: zFile descriptor z is used by transport )
r�intr?�AttributeErrorr�
ValueErrorr%r�
is_closingr8)r&rr?rfrrr�_ensure_fd_no_transport�s
�z-BaseSelectorEventLoop._ensure_fd_no_transportc		Gs�|��t�|||d�}z|j�|�}Wn*tk
rR|j�|tj|df�Yn>X|j|j	}\}}|j�
||tjB||f�|dk	r�|��dSr+)�
_check_closedr�Handler"rr�registerr�
EVENT_READrG�modify�cancel�	r&r�callback�argsZhandler�mask�reader�writerrrrrDs�
�z!BaseSelectorEventLoop._add_readercCs�|��rdSz|j�|�}Wntk
r2YdSX|j|j}\}}|tjM}|sd|j�|�n|j�	||d|f�|dk	r�|�
�dSdSdS�NFT)r9r"rrrrGrrt�
unregisterrurv�r&rrrzr{r|rrrr=sz$BaseSelectorEventLoop._remove_readerc		Gs�|��t�|||d�}z|j�|�}Wn*tk
rR|j�|tjd|f�Yn>X|j|j	}\}}|j�
||tjB||f�|dk	r�|��dSr+)rqrrrr"rrrsr�EVENT_WRITErGrurvrwrrr�_add_writer%s�
�z!BaseSelectorEventLoop._add_writercCs�|��rdSz|j�|�}Wntk
r2YdSX|j|j}\}}|tjM}|sd|j�|�n|j�	|||df�|dk	r�|�
�dSdSdSr})r9r"rrrrGrr�r~rurvrrrr�_remove_writer4sz$BaseSelectorEventLoop._remove_writercGs|�|�|j||f|��Sr+)rprD�r&rrxryrrr�
add_readerKs
z BaseSelectorEventLoop.add_readercCs|�|�|�|�Sr+)rpr=�r&rrrr�
remove_readerPs
z#BaseSelectorEventLoop.remove_readercGs|�|�|j||f|��Sr+)rpr�r�rrr�
add_writerUs
z BaseSelectorEventLoop.add_writercCs|�|�|�|�Sr+)rpr�r�rrr�
remove_writerZs
z#BaseSelectorEventLoop.remove_writerc	�s�t|�|jr"|��dkr"td��z|�|�WSttfk
rFYnX|��}|��}|�	||j
|||�|�t�
|j|��|IdHS�Nr�the socket must be non-blocking)rrQ�
gettimeoutrnrIrKrJrgr?r��
_sock_recv�add_done_callback�	functools�partial�_sock_read_done)r&r�n�futrrrr�	sock_recv_s�zBaseSelectorEventLoop.sock_recvcCs|�|�dSr+)r��r&rr�rrrr�tsz%BaseSelectorEventLoop._sock_read_donec
Cs�|��rdSz|�|�}Wn\ttfk
r4YdSttfk
rL�Yn6tk
rv}z|�|�W5d}~XYnX|�|�dSr+)	�donerIrKrJrirjrh�
set_exception�
set_result)r&r�rr�rGrerrrr�wsz BaseSelectorEventLoop._sock_recvc	�s�t|�|jr"|��dkr"td��z|�|�WSttfk
rFYnX|��}|��}|�	||j
|||�|�t�
|j|��|IdHSr�)rrQr�rn�	recv_intorKrJrgr?r��_sock_recv_intor�r�r�r�)r&r�bufr�rrrr�sock_recv_into�s�z$BaseSelectorEventLoop.sock_recv_intoc
Cs�|��rdSz|�|�}Wn\ttfk
r4YdSttfk
rL�Yn6tk
rv}z|�|�W5d}~XYnX|�|�dSr+)	r�r�rKrJrirjrhr�r�)r&r�rr��nbytesrerrrr��sz%BaseSelectorEventLoop._sock_recv_intoc	�s�t|�|jr"|��dkr"td��z|�|�}Wnttfk
rLd}YnX|t|�kr^dS|��}|�	�}|�
t�|j
|��|�||j||t|�|g�|IdHSr�)rrQr�rnrOrKrJ�lenrgr?r�r�r��_sock_write_doner��
_sock_sendall�
memoryview)r&rrGr�r�rrrr�sock_sendall�s&	
��z"BaseSelectorEventLoop.sock_sendallc
Cs�|��rdS|d}z|�||d��}Wnbttfk
rDYdSttfk
r\�Yn2tk
r�}z|�|�WY�dSd}~XYnX||7}|t|�kr�|�	d�n||d<dS)Nr)
r�rOrKrJrirjrhr�r�r�)r&r�rZview�pos�startr�rerrrr��s 
z#BaseSelectorEventLoop._sock_sendallc�s�t|�|jr"|��dkr"td��ttd�r8|jtjkrf|j||j|j	|d�IdH}|d\}}}}}|�
�}|�|||�|IdHS)Nrr��AF_UNIX)�family�proto�loop)rrQr�rn�hasattrrBr�r�Z_ensure_resolvedr�rg�
_sock_connect)r&rr6Zresolvedrbr�rrr�sock_connect�s�z"BaseSelectorEventLoop.sock_connectc
Cs�|��}z|�|�Wn�ttfk
rV|�t�|j|��|�||j	|||�YnNt
tfk
rn�Yn6tk
r�}z|�
|�W5d}~XYnX|�d�dSr+)r?ZconnectrKrJr�r�r�r�r��_sock_connect_cbrirjrhr�r�)r&r�rr6rrerrrr��s�z#BaseSelectorEventLoop._sock_connectcCs|�|�dSr+)r�r�rrrr�sz&BaseSelectorEventLoop._sock_write_donec
Cs�|��rdSz,|�tjtj�}|dkr6t|d|����WnZttfk
rPYnNtt	fk
rh�Yn6t
k
r�}z|�|�W5d}~XYnX|�d�dS)NrzConnect call failed )
r�Z
getsockoptrBZ
SOL_SOCKETZSO_ERRORrPrKrJrirjrhr�r�)r&r�rr6�errrerrrr�sz&BaseSelectorEventLoop._sock_connect_cbc�sBt|�|jr"|��dkr"td��|��}|�|d|�|IdHS)Nrr�F)rrQr�rnrg�_sock_accept)r&rr�rrr�sock_acceptsz!BaseSelectorEventLoop.sock_acceptc
Cs�|��}|r|�|�|��r"dSz|��\}}|�d�Wnnttfk
rh|�||j|d|�YnRt	t
fk
r��Yn:tk
r�}z|�|�W5d}~XYnX|�
||f�dSr})r?r�r�r\rCrKrJr�r�rirjrhr�r�)r&r�Z
registeredrrrcr6rerrrr�*s
z"BaseSelectorEventLoop._sock_acceptc	�sp|j|j=|��}|��|��IdHz |j|j|||dd�IdHW�S|��|r^|��||j|j<XdS)NF)Zfallback)	r%�_sock_fd�
is_reading�
pause_reading�_make_empty_waiter�_reset_empty_waiter�resume_readingZ
sock_sendfile�_sock)r&Ztransp�file�offset�countr�rrr�_sendfile_native<s
�z&BaseSelectorEventLoop._sendfile_nativecCs�|D]v\}}|j|j}\}}|tj@rL|dk	rL|jrB|�|�n
|�|�|tj@r|dk	r|jrp|�|�q|�|�qdSr+)	�fileobjrGrrtZ
_cancelledr=Z
_add_callbackr�r�)r&Z
event_listrrzr�r{r|rrr�_process_eventsJs
z%BaseSelectorEventLoop._process_eventscCs|�|���|��dSr+)r=r?r;)r&rrrr�
_stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN),r!�
__module__�__qualname__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr'rr0s|
����
�
	�
.�
)rcs�eZdZdZeZdZd�fdd�	Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
ejfdd�Zddd�Zdd�Zdd�Zdd�Zdd�Z�ZS) �_SelectorTransportiNcs�t��||�t�|�|jd<z|��|jd<Wntk
rNd|jd<YnXd|jkr�z|��|jd<Wn tj	k
r�d|jd<YnX||_
|��|_d|_
|�|�||_|��|_d|_d|_|jdk	r�|j��||j|j<dS)NrBZsocknamerZFr)rrrr`�_extraZgetsocknamerPZgetpeernamerB�errorr�r?r��_protocol_connected�set_protocol�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr%)r&r�rr-r)r*r'rrris,





z_SelectorTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���|jdk	r�|j��s�t|jj	|jt
j�}|rz|�d�n
|�d�t|jj	|jt
j�}|r�d}nd}|�
�}|�d|�d	|�d
��d�d�|��S)
N�closed�closingzfd=zread=pollingz	read=idle�pollingZidlezwrite=<z
, bufsize=�>z<{}>� )r r!r��appendr�r��_loopr9rr"rrtr��get_write_buffer_size�format�join)r&�infor��state�bufsizerrr�__repr__�s0


�
�z_SelectorTransport.__repr__cCs|�d�dSr+)�_force_closer<rrr�abort�sz_SelectorTransport.abortcCs||_d|_dS�NT)�	_protocolr��r&r-rrrr��sz_SelectorTransport.set_protocolcCs|jSr+)r�r<rrr�get_protocol�sz_SelectorTransport.get_protocolcCs|jSr+)r�r<rrrro�sz_SelectorTransport.is_closingcCsT|jr
dSd|_|j�|j�|jsP|jd7_|j�|j�|j�|jd�dS�NTr)	r�r�r=r�r�r�r��	call_soon�_call_connection_lostr<rrrr;�sz_SelectorTransport.closecCs,|jdk	r(|d|��t|d�|j��dS)Nzunclosed transport )�source)r��ResourceWarningr;)r&Z_warnrrr�__del__�s
z_SelectorTransport.__del__�Fatal error on transportcCsNt|t�r(|j��r@tjd||dd�n|j�||||jd��|�|�dS)Nz%r: %sTrM)rXrYrfr-)	rrPr��	get_debugrrr_r�r�)r&rerXrrr�_fatal_error�s

�z_SelectorTransport._fatal_errorcCsd|jr
dS|jr(|j��|j�|j�|jsBd|_|j�|j�|jd7_|j�|j	|�dSr�)
r�r��clearr�r�r�r�r=r�r��r&rerrrr��s
z_SelectorTransport._force_closecCsVz|jr|j�|�W5|j��d|_d|_d|_|j}|dk	rP|��d|_XdSr+)r�r;r�r�r�Z_detachr�Zconnection_lost)r&rer*rrrr��s
z(_SelectorTransport._call_connection_lostcCs
t|j�Sr+)r�r�r<rrrr��sz(_SelectorTransport.get_write_buffer_sizecGs"|jr
dS|jj||f|��dSr+)r�r�rDr�rrrrD�sz_SelectorTransport._add_reader)NN)r�)r!r�r��max_size�	bytearrayr�r�rr�r�r�r�ror;�warnings�warnr�r�r�r�r�rDr�rrr'rr�]s 

r�cs�eZdZdZejjZd#�fdd�	Z�fdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�fdd�Zdd �Zd!d"�Z�ZS)$r,TNcs~d|_t��|||||�d|_d|_d|_t�|j�|j	�
|jj|�|j	�
|j
|j|j�|dk	rz|j	�
tj|d�dSr
)�_read_ready_cbrr�_eof�_paused�
_empty_waiterrZ_set_nodelayr�r�r�r��connection_maderDr��_read_readyr�_set_result_unless_cancelled)r&r�rr-r.r)r*r'rrr�s 
�
�z!_SelectorSocketTransport.__init__cs.t|tj�r|j|_n|j|_t��|�dSr+)rrZBufferedProtocol�_read_ready__get_bufferr��_read_ready__data_receivedrr�r�r'rrr�	s
z%_SelectorSocketTransport.set_protocolcCs|jo|jSr+)r�r�r<rrrr�sz#_SelectorSocketTransport.is_readingcCs>|js|jrdSd|_|j�|j�|j��r:t�d|�dS)NTz%r pauses reading)r�r�r�r=r�r�rrr<rrrr�s
z&_SelectorSocketTransport.pause_readingcCs@|js|jsdSd|_|�|j|j�|j��r<t�d|�dS)NFz%r resumes reading)	r�r�rDr�r�r�r�rrr<rrrr�s
z'_SelectorSocketTransport.resume_readingcCs|��dSr+)r�r<rrrr�$sz$_SelectorSocketTransport._read_readyc
Cs`|jr
dSz |j�d�}t|�s(td��WnLttfk
rD�Yn4tk
rv}z|�|d�WY�dSd}~XYnXz|j	�
|�}Wndttfk
r�YdSttfk
r��Yn4tk
r�}z|�|d�WY�dSd}~XYnX|�s|�
�dSz|j�|�WnJttfk
�r,�Yn0tk
�rZ}z|�|d�W5d}~XYnXdS)N���z%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.�$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r�r�Z
get_bufferr�r8rirjrhr�r�r�rKrJ�_read_ready__on_eofZbuffer_updated)r&r�rer�rrrr�'sF��z0_SelectorSocketTransport._read_ready__get_bufferc
Cs�|jr
dSz|j�|j�}Wndttfk
r6YdSttfk
rN�Yn4tk
r�}z|�	|d�WY�dSd}~XYnX|s�|�
�dSz|j�|�WnFttfk
r��Yn.tk
r�}z|�	|d�W5d}~XYnXdS)Nr�z2Fatal error: protocol.data_received() call failed.)
r�r�rIr�rKrJrirjrhr�r�r�Z
data_received)r&rGrerrrr�Ls.�z3_SelectorSocketTransport._read_ready__data_receivedc
Cs�|j��rt�d|�z|j��}WnLttfk
r>�Yn4tk
rp}z|�	|d�WY�dSd}~XYnX|r�|j�
|j�n|��dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)
r�r�rrr�Zeof_receivedrirjrhr�r=r�r;)r&Z	keep_openrerrrr�es
�z,_SelectorSocketTransport._read_ready__on_eofc
Cs6t|tttf�s$tdt|�j����|jr2td��|j	dk	rDtd��|sLdS|j
rz|j
tjkrht
�d�|j
d7_
dS|j�sz|j�|�}Wnbttfk
r�Ynbttfk
r��YnJtk
r�}z|�|d�WY�dSd}~XYnX||d�}|�sdS|j�|j|j�|j�|�|��dS)N�/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progress�socket.send() raised exception.r�%Fatal write error on socket transport)r�bytesr�r�r�typer!r�r8r�r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r�rOrKrJrirjrhr�r�r�r��_write_ready�extend�_maybe_pause_protocol)r&rGr�rerrr�writezs:

z_SelectorSocketTransport.writec
Cs|jr
dSz|j�|j�}Wn�ttfk
r4Yn�ttfk
rL�Yn�tk
r�}z>|j	�
|j�|j��|�
|d�|jdk	r�|j�|�W5d}~XYnnX|r�|jd|�=|��|j�s|j	�
|j�|jdk	r�|j�d�|jr�|�d�n|j�r|j�tj�dS)Nr�)r�r�rOr�rKrJrirjrhr�r�r�r�r�r�r��_maybe_resume_protocolr�r�r�r��shutdownrB�SHUT_WR)r&r�rerrrr�s2


z%_SelectorSocketTransport._write_readycCs.|js|jrdSd|_|js*|j�tj�dSr�)r�r�r�r�rrBrr<rrr�	write_eof�s
z"_SelectorSocketTransport.write_eofcCsdSr�rr<rrr�
can_write_eof�sz&_SelectorSocketTransport.can_write_eofcs*t��|�|jdk	r&|j�td��dS)NzConnection is closed by peer)rr�r�r��ConnectionErrorr�r'rrr��s

�z._SelectorSocketTransport._call_connection_lostcCs6|jdk	rtd��|j��|_|js0|j�d�|jS)NzEmpty waiter is already set)r�r8r�rgr�r�r<rrrr��s
z+_SelectorSocketTransport._make_empty_waitercCs
d|_dSr+)r�r<rrrr��sz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!r�r�Z_start_tls_compatiblerZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerr�r�r�r�r�r�r�r�rrrrr�r�r�r�rrr'rr,�s*�%'r,csFeZdZejZd�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r5Ncs^t��||||�||_|j�|jj|�|j�|j|j|j	�|dk	rZ|j�t
j|d�dSr+)rr�_addressr�r�r�r�rDr�r�rr�)r&r�rr-r6r.r)r'rrr�s
�
�z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss|]\}}t|�VqdSr+)r�)�.0rGrbrrr�	<genexpr>�szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�r<rrrr��sz0_SelectorDatagramTransport.get_write_buffer_sizec
Cs�|jr
dSz|j�|j�\}}Wn�ttfk
r8Yn�tk
rd}z|j�|�W5d}~XYnTt	t
fk
r|�Yn<tk
r�}z|�|d�W5d}~XYnX|j�
||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rKrJrPr��error_receivedrirjrhr�Zdatagram_received�r&rGrdrerrrr��sz&_SelectorDatagramTransport._read_readyc
Cs�t|tttf�s$tdt|�j����|s,dS|jrV|d|jfkrPtd|j����|j}|j	r�|jr�|j	t
jkrxt�
d�|j	d7_	dS|j�slz,|jdr�|j�|�n|j�||�WdSttfk
r�|j�|j|j�Yn�tk
�r}z|j�|�WY�dSd}~XYnPttfk
�r6�Yn6tk
�rj}z|�|d�WY�dSd}~XYnX|j� t|�|f�|�!�dS)Nr�z!Invalid address: must be None or r�rrZ�'Fatal write error on datagram transport)"rr�r�r�rr�r!r
rnr�rr�rr�r�r�r�rO�sendtorKrJr�r�r��
_sendto_readyrPr�rrirjrhr�r�rrrrrr�sH
�

�z!_SelectorDatagramTransport.sendtoc
Cs|jr�|j��\}}z*|jdr.|j�|�n|j�||�Wqttfk
rj|j�||f�Yq�Yqt	k
r�}z|j
�|�WY�dSd}~XYqtt
fk
r��Yqtk
r�}z|�|d�WY�dSd}~XYqXq|��|j�s|j�|j�|j�r|�d�dS)NrZr)r��popleftr�r�rOrrKrJ�
appendleftrPr�rrirjrhr�rr�r�r�r�r�rrrrr*s2
�z(_SelectorDatagramTransport._sendto_ready)NNN)N)r!r�r��collections�dequer�rr�r�rrr�rrr'rr5�s�

+r5)�__all__rr^r�rrBr�r$r�ImportError�rrrrrr	r
r�logrrrZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r,r5rrrr�<module>sD
1�oPK
0�\�P�% % trsock.cpython-38.opt-2.pycnu�[���U

e5d��@s"ddlZddlZGdd�d�ZdS)�Nc@s�eZdZdZejd�dd�Zdd�Zedd��Zed	d
��Z	edd��Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$dAdB�Z%dCdD�Z&dEdF�Z'dGdH�Z(dIdJ�Z)dKdL�Z*dMdN�Z+dOdP�Z,dQdR�Z-dSdT�Z.dUdV�Z/dWdX�Z0dYdZ�Z1d[S)\�TransportSocket��_sock)�sockcCs
||_dS�Nr)�selfr�r�&/usr/lib64/python3.8/asyncio/trsock.py�__init__szTransportSocket.__init__cCstjd|�d�t|d�dS)NzUsing z� on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)�source)�warnings�warn�DeprecationWarning)rZwhatrrr	�_nas

�zTransportSocket._nacCs|jjSr)r�family�rrrr	rszTransportSocket.familycCs|jjSr)r�typerrrr	rszTransportSocket.typecCs|jjSr)r�protorrrr	r"szTransportSocket.protocCs�d|���d|j�d|j�d|j��}|��dkr�z|��}|rN|�d|��}Wntjk
rfYnXz|��}|r�|�d|��}Wntjk
r�YnX|�d�S)	Nz<asyncio.TransportSocket fd=z	, family=z, type=z, proto=���z, laddr=z, raddr=�>)�filenorrr�getsockname�socket�error�getpeername)r�sZladdrZraddrrrr	�__repr__&s $�zTransportSocket.__repr__cCstd��dS)Nz/Cannot serialize asyncio.TransportSocket object)�	TypeErrorrrrr	�__getstate__=szTransportSocket.__getstate__cCs
|j��Sr)rrrrrr	r@szTransportSocket.filenocCs
|j��Sr)r�duprrrr	rCszTransportSocket.dupcCs
|j��Sr)r�get_inheritablerrrr	r FszTransportSocket.get_inheritablecCs|j�|�dSr)r�shutdown)rZhowrrr	r!IszTransportSocket.shutdowncOs|jj||�Sr)r�
getsockopt�r�args�kwargsrrr	r"NszTransportSocket.getsockoptcOs|jj||�dSr)r�
setsockoptr#rrr	r&QszTransportSocket.setsockoptcCs
|j��Sr)rrrrrr	rTszTransportSocket.getpeernamecCs
|j��Sr)rrrrrr	rWszTransportSocket.getsocknamecCs
|j��Sr)r�
getsockbynamerrrr	r'ZszTransportSocket.getsockbynamecCs|�d�|j��S)Nzaccept() method)rr�acceptrrrr	r(]s
zTransportSocket.acceptcOs|�d�|jj||�S)Nzconnect() method)rr�connectr#rrr	r)as
zTransportSocket.connectcOs|�d�|jj||�S)Nzconnect_ex() method)rr�
connect_exr#rrr	r*es
zTransportSocket.connect_excOs|�d�|jj||�S)Nz
bind() method)rr�bindr#rrr	r+is
zTransportSocket.bindcOs|�d�|jj||�S)Nzioctl() method)rr�ioctlr#rrr	r,ms
zTransportSocket.ioctlcOs|�d�|jj||�S)Nzlisten() method)rr�listenr#rrr	r-qs
zTransportSocket.listencCs|�d�|j��S)Nzmakefile() method)rr�makefilerrrr	r.us
zTransportSocket.makefilecOs|�d�|jj||�S)Nzsendfile() method)rr�sendfiler#rrr	r/ys
zTransportSocket.sendfilecCs|�d�|j��S)Nzclose() method)rr�closerrrr	r0}s
zTransportSocket.closecCs|�d�|j��S)Nzdetach() method)rr�detachrrrr	r1�s
zTransportSocket.detachcOs|�d�|jj||�S)Nzsendmsg_afalg() method)rr�
sendmsg_afalgr#rrr	r2�s
zTransportSocket.sendmsg_afalgcOs|�d�|jj||�S)Nzsendmsg() method)rr�sendmsgr#rrr	r3�s
zTransportSocket.sendmsgcOs|�d�|jj||�S)Nzsendto() method)rr�sendtor#rrr	r4�s
zTransportSocket.sendtocOs|�d�|jj||�S)Nz
send() method)rr�sendr#rrr	r5�s
zTransportSocket.sendcOs|�d�|jj||�S)Nzsendall() method)rr�sendallr#rrr	r6�s
zTransportSocket.sendallcOs|�d�|jj||�S)Nzset_inheritable() method)rr�set_inheritabler#rrr	r7�s
zTransportSocket.set_inheritablecCs|�d�|j�|�S)Nzshare() method)rr�share)rZ
process_idrrr	r8�s
zTransportSocket.sharecOs|�d�|jj||�S)Nzrecv_into() method)rr�	recv_intor#rrr	r9�s
zTransportSocket.recv_intocOs|�d�|jj||�S)Nzrecvfrom_into() method)rr�
recvfrom_intor#rrr	r:�s
zTransportSocket.recvfrom_intocOs|�d�|jj||�S)Nzrecvmsg_into() method)rr�recvmsg_intor#rrr	r;�s
zTransportSocket.recvmsg_intocOs|�d�|jj||�S)Nzrecvmsg() method)rr�recvmsgr#rrr	r<�s
zTransportSocket.recvmsgcOs|�d�|jj||�S)Nzrecvfrom() method)rr�recvfromr#rrr	r=�s
zTransportSocket.recvfromcOs|�d�|jj||�S)Nz
recv() method)rr�recvr#rrr	r>�s
zTransportSocket.recvcCs|dkrdStd��dS)Nrz<settimeout(): only 0 timeout is allowed on transport sockets��
ValueError)r�valuerrr	�
settimeout�s
�zTransportSocket.settimeoutcCsdS)Nrrrrrr	�
gettimeout�szTransportSocket.gettimeoutcCs|sdStd��dS)Nz3setblocking(): transport sockets cannot be blockingr?)r�flagrrr	�setblocking�s
�zTransportSocket.setblockingcCs|�d�|j��S�Nzcontext manager protocol)rr�	__enter__rrrr	rG�s
zTransportSocket.__enter__cGs|�d�|jj|�SrF)rr�__exit__)r�errrrr	rH�s
zTransportSocket.__exit__N)2�__name__�
__module__�__qualname__�	__slots__rr
r�propertyrrrrrrrr r!r"r&rrr'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>rBrCrErGrHrrrr	rs`	


r)rrrrrrr	�<module>sPK
0�\��?�?locks.cpython-38.pycnu�[���U

e5d|C�@s�dZdZddlZddlZddlZddlmZddlmZddlmZddlm	Z	Gd	d
�d
�Z
Gdd�d�ZGd
d�de�ZGdd�d�Z
Gdd�de�ZGdd�de�ZGdd�de�ZdS)zSynchronization primitives.)�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�events)�futures)�
exceptions)�
coroutinesc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ContextManagera\Context manager.

    This enables the following idiom for acquiring and releasing a
    lock around a block:

        with (yield from lock):
            <block>

    while failing loudly when accidentally using:

        with lock:
            <block>

    Deprecated, use 'async with' statement:
        async with lock:
            <block>
    cCs
||_dS�N)�_lock)�self�lock�r�%/usr/lib64/python3.8/asyncio/locks.py�__init__"sz_ContextManager.__init__cCsdSr
r�rrrr�	__enter__%sz_ContextManager.__enter__cGsz|j��W5d|_XdSr
)r�release�r�argsrrr�__exit__*sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__�__doc__rrrrrrrrsrc@sReZdZdd�Zdd�Zejdd��Zej	e_	dd�Z
d	d
�Zdd�Zd
d�Z
dS)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeErrorrrrrr2s�z_ContextManagerMixin.__enter__cGsdSr
rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd�|��EdHt|�S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead���
stacklevel)�warnings�warn�DeprecationWarning�acquirerrrrr�__iter__;s�z_ContextManagerMixin.__iter__c�s|��IdHt|�Sr
)r&rrrrrZ
__acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd�|����S)Nz='with await lock' is deprecated use 'async with lock' insteadr r!)r#r$r%�!_ContextManagerMixin__acquire_ctx�	__await__rrrrr)Ys
�z_ContextManagerMixin.__await__c�s|��IdHdSr
)r&rrrr�
__aenter__`sz_ContextManagerMixin.__aenter__c�s|��dSr
)r)r�exc_type�exc�tbrrr�	__aexit__fsz_ContextManagerMixin.__aexit__N)rrrrr�types�	coroutiner'rZ
_is_coroutiner(r)r*r.rrrrr1s
rcsNeZdZdZdd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z	�Z
S)ra�Primitive lock objects.

    A primitive lock is a synchronization primitive that is not owned
    by a particular coroutine when locked.  A primitive lock is in one
    of two states, 'locked' or 'unlocked'.

    It is created in the unlocked state.  It has two basic methods,
    acquire() and release().  When the state is unlocked, acquire()
    changes the state to locked and returns immediately.  When the
    state is locked, acquire() blocks until a call to release() in
    another coroutine changes it to unlocked, then the acquire() call
    resets it to locked and returns.  The release() method should only
    be called in the locked state; it changes the state to unlocked
    and returns immediately.  If an attempt is made to release an
    unlocked lock, a RuntimeError will be raised.

    When more than one coroutine is blocked in acquire() waiting for
    the state to turn to unlocked, only one coroutine proceeds when a
    release() call resets the state to unlocked; first coroutine which
    is blocked in acquire() is being processed.

    acquire() is a coroutine and should be called with 'await'.

    Locks also support the asynchronous context management protocol.
    'async with lock' statement should be used.

    Usage:

        lock = Lock()
        ...
        await lock.acquire()
        try:
            ...
        finally:
            lock.release()

    Context manager usage:

        lock = Lock()
        ...
        async with lock:
             ...

    Lock objects can be tested for locking state:

        if not lock.locked():
           await lock.acquire()
        else:
           # lock is acquired
           ...

    N��loopcCs:d|_d|_|dkr t��|_n||_tjdtdd�dS�NF�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r r!)�_waiters�_lockedr�get_event_loop�_loopr#r$r%�rr2rrrr�s�z
Lock.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S�	N�lockedZunlocked�
, waiters:�<r���� [�]>)�super�__repr__r6r5�len�r�resZextra��	__class__rrrB�s

z
Lock.__repr__cCs|jS)z Return True if lock is acquired.)r6rrrrr;�szLock.lockedc	�s�|js.|jdks$tdd�|jD��r.d|_dS|jdkrBt��|_|j��}|j�|�z"z|IdHW5|j�|�XWn&t	j
k
r�|js�|���YnXd|_dS)z�Acquire a lock.

        This method blocks until the lock is unlocked, then sets it to
        locked and returns True.
        Ncss|]}|��VqdSr
)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>T)r6r5�all�collections�dequer8�
create_future�append�remover
�CancelledError�_wake_up_first�r�futrrrr&�s&�


zLock.acquirecCs"|jrd|_|��ntd��dS)aGRelease a lock.

        When the lock is locked, reset it to unlocked, and return.
        If any other coroutines are blocked waiting for the lock to become
        unlocked, allow exactly one of them to proceed.

        When invoked on an unlocked lock, a RuntimeError is raised.

        There is no return value.
        FzLock is not acquired.N)r6rSrrrrrr�s
zLock.releasecCsJ|js
dSztt|j��}Wntk
r2YdSX|��sF|�d�dS)z*Wake up the first waiter if it isn't done.NT)r5�next�iter�
StopIteration�done�
set_resultrTrrrrS�szLock._wake_up_first)rrrrrrBr;r&rrS�
__classcell__rrrFrrjs5 rcsNeZdZdZdd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z	�Z
S)ra#Asynchronous equivalent to threading.Event.

    Class implementing event objects. An event manages a flag that can be set
    to true with the set() method and reset to false with the clear() method.
    The wait() method blocks until the flag is true. The flag is initially
    false.
    Nr1cCs>t��|_d|_|dkr$t��|_n||_tjdt	dd�dSr3)
rMrNr5�_valuerr7r8r#r$r%r9rrrrs
�zEvent.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S)	N�setZunsetr<r=rr>r?r@)rArBr\r5rCrDrFrrrBs

zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.�r\rrrr�is_setszEvent.is_setcCs.|js*d|_|jD]}|��s|�d�qdS)z�Set the internal flag to true. All coroutines waiting for it to
        become true are awakened. Coroutine that call wait() once the flag is
        true will not block at all.
        TN)r\r5rYrZrTrrrr]s

z	Event.setcCs
d|_dS)z�Reset the internal flag to false. Subsequently, coroutines calling
        wait() will block until set() is called to set the internal flag
        to true again.FNr^rrrr�clear"szEvent.clearc	�sF|jr
dS|j��}|j�|�z|IdHW�dS|j�|�XdS)z�Block until the internal flag is true.

        If the internal flag is true on entry, return True
        immediately.  Otherwise, block until another coroutine calls
        set() to set the flag to true, then return True.
        TN)r\r8rOr5rPrQrTrrr�wait(s

z
Event.wait)rrrrrrBr_r]r`rar[rrrFrr�srcsReZdZdZddd�dd�Z�fdd�Zdd	�Zd
d�Zdd
d�Zdd�Z	�Z
S)raAsynchronous equivalent to threading.Condition.

    This class implements condition variable objects. A condition variable
    allows one or more coroutines to wait until they are notified by another
    coroutine.

    A new Lock object is created and used as the underlying lock.
    Nr1cCs~|dkrt��|_n||_tjdtdd�|dkr>t|d�}n|j|jk	rRtd��||_|j	|_	|j
|_
|j|_t�
�|_dS)Nr4r r!r1z"loop argument must agree with lock)rr7r8r#r$r%r�
ValueErrorrr;r&rrMrNr5)rrr2rrrrEs �zCondition.__init__csNt���}|��rdnd}|jr4|�dt|j���}d|dd��d|�d�Sr:)rArBr;r5rCrDrFrrrB[s

zCondition.__repr__c�s�|��std��|��z@|j��}|j�	|�z|IdHW�W�dS|j�
|�XW5d}z|��IdHWq�Wq^tjk
r�d}Yq^Xq^|r�tj�XdS)a�Wait until notified.

        If the calling coroutine has not acquired the lock when this
        method is called, a RuntimeError is raised.

        This method releases the underlying lock, and then blocks
        until it is awakened by a notify() or notify_all() call for
        the same condition variable in another coroutine.  Once
        awakened, it re-acquires the lock and returns True.
        zcannot wait on un-acquired lockFNT)r;rrr&r
rRr8rOr5rPrQ)rrHrUrrrrabs$

zCondition.waitc�s$|�}|s |��IdH|�}q|S)z�Wait until a predicate becomes true.

        The predicate should be a callable which result will be
        interpreted as a boolean value.  The final predicate value is
        the return value.
        N)ra)rZ	predicate�resultrrr�wait_for�s
zCondition.wait_forrcCsJ|��std��d}|jD]*}||kr*qF|��s|d7}|�d�qdS)aBy default, wake up one coroutine waiting on this condition, if any.
        If the calling coroutine has not acquired the lock when this method
        is called, a RuntimeError is raised.

        This method wakes up at most n of the coroutines waiting for the
        condition variable; it is a no-op if no coroutines are waiting.

        Note: an awakened coroutine does not actually return from its
        wait() call until it can reacquire the lock. Since notify() does
        not release the lock, its caller should.
        z!cannot notify on un-acquired lockrrFN)r;rr5rYrZ)r�n�idxrUrrr�notify�s
zCondition.notifycCs|�t|j��dS)aWake up all threads waiting on this condition. This method acts
        like notify(), but wakes up all waiting threads instead of one. If the
        calling thread has not acquired the lock when this method is called,
        a RuntimeError is raised.
        N)rgrCr5rrrr�
notify_all�szCondition.notify_all)N)r)rrrrrrBrardrgrhr[rrrFrr;s	%
rcsPeZdZdZddd�dd�Z�fdd�Zd	d
�Zdd�Zd
d�Zdd�Z	�Z
S)raA Semaphore implementation.

    A semaphore manages an internal counter which is decremented by each
    acquire() call and incremented by each release() call. The counter
    can never go below zero; when acquire() finds that it is zero, it blocks,
    waiting until some other thread calls release().

    Semaphores also support the context management protocol.

    The optional argument gives the initial value for the internal
    counter; it defaults to 1. If the value given is less than 0,
    ValueError is raised.
    rNr1cCsN|dkrtd��||_t��|_|dkr4t��|_n||_tj	dt
dd�dS)Nrz$Semaphore initial value must be >= 0r4r r!)rbr\rMrNr5rr7r8r#r$r%�r�valuer2rrrr�s
�zSemaphore.__init__csVt���}|��rdn
d|j��}|jr<|�dt|j���}d|dd��d|�d�S)	Nr;zunlocked, value:r<r=rr>r?r@)rArBr;r\r5rCrDrFrrrB�s

zSemaphore.__repr__cCs,|jr(|j��}|��s|�d�dSqdSr
)r5�popleftrYrZ)rZwaiterrrr�
_wake_up_next�s


zSemaphore._wake_up_nextcCs
|jdkS)z:Returns True if semaphore can not be acquired immediately.rr^rrrrr;�szSemaphore.lockedc�st|jdkrb|j��}|j�|�z|IdHWq|��|jdkrX|��sX|���YqXq|jd8_dS)a5Acquire a semaphore.

        If the internal counter is larger than zero on entry,
        decrement it by one and return True immediately.  If it is
        zero on entry, block, waiting until some other coroutine has
        called release() to make it larger than 0, and then return
        True.
        rNrT)r\r8rOr5rPZcancelrHrlrTrrrr&�s	


zSemaphore.acquirecCs|jd7_|��dS)z�Release a semaphore, incrementing the internal counter by one.
        When it was zero on entry and another coroutine is waiting for it to
        become larger than zero again, wake up that coroutine.
        rN)r\rlrrrrr�szSemaphore.release)r)rrrrrrBrlr;r&rr[rrrFrr�s
rcs4eZdZdZd	dd��fdd�Z�fdd�Z�ZS)
rz�A bounded semaphore implementation.

    This raises ValueError in release() if it would increase the value
    above the initial value.
    rNr1cs.|rtjdtdd�||_t�j||d�dS)Nr4r r!r1)r#r$r%�_bound_valuerArrirFrrr
s�zBoundedSemaphore.__init__cs"|j|jkrtd��t���dS)Nz(BoundedSemaphore released too many times)r\rmrbrArrrFrrrszBoundedSemaphore.release)r)rrrrrrr[rrrFrrs	r)r�__all__rMr/r#�rr	r
rrrrrrrrrrrr�<module>s "9DzNPK
0�\C��ktTtTsslproto.cpython-38.pycnu�[���U

e5dJj�@s�ddlZddlZzddlZWnek
r4dZYnXddlmZddlmZddlmZddlmZddl	m
Z
dd	�Zd
ZdZ
dZd
ZGdd�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�base_events)�	constants)�	protocols)�
transports)�loggercCs"|rtd��t��}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF)�
ValueError�sslZcreate_default_contextZcheck_hostname)�server_side�server_hostname�
sslcontext�r
�(/usr/lib64/python3.8/asyncio/sslproto.py�_create_transport_contextsrZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@s~eZdZdZdZddd�Zedd��Zedd	��Zed
d��Z	edd
��Z
ddd�Zddd�Zdd�Z
ddd�Zddd�ZdS)�_SSLPipeaAn SSL "Pipe".

    An SSL pipe allows you to communicate with an SSL/TLS protocol instance
    through memory buffers. It can be used to implement a security layer for an
    existing connection where you don't have access to the connection's file
    descriptor, or for some reason you don't want to use it.

    An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode,
    data is passed through untransformed. In wrapped mode, application level
    data is encrypted to SSL record level data and vice versa. The SSL record
    level is the lowest level in the SSL protocol suite and is what travels
    as-is over the wire.

    An SslPipe initially is in "unwrapped" mode. To start SSL, call
    do_handshake(). To shutdown SSL again, call unwrap().
    iNcCsH||_||_||_t|_t��|_t��|_d|_	d|_
d|_d|_dS)a�
        The *context* argument specifies the ssl.SSLContext to use.

        The *server_side* argument indicates whether this is a server side or
        client side transport.

        The optional *server_hostname* argument can be used to specify the
        hostname you are connecting to. You may only specify this parameter if
        the _ssl module supports Server Name Indication (SNI).
        NF)
�_context�_server_side�_server_hostname�
_UNWRAPPED�_stater	Z	MemoryBIO�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextr
rr
r
r�__init__8s

z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)r�rr
r
rrNsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance.

        Return None if the pipe is not wrapped.
        )rrr
r
r�
ssl_objectSsz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake
        that is currently in progress.)rrr
r
r�need_ssldata[sz_SSLPipe.need_ssldatacCs
|jtkS)zj
        Whether a security layer is currently in effect.

        Return False during handshake.
        )r�_WRAPPEDrr
r
r�wrappedasz_SSLPipe.wrappedcCsb|jtkrtd��|jj|j|j|j|jd�|_	t
|_||_|jddd�\}}t
|�dks^t�|S)aLStart the SSL handshake.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the handshake is complete. The callback will be
        called with None if successful, else an exception instance.
        z"handshake in progress or completed)r
r�T)�only_handshaker)rr�RuntimeErrorrZwrap_biorrrrr�
_DO_HANDSHAKEr�feed_ssldata�len�AssertionError�r�callback�ssldata�appdatar
r
r�do_handshakejs	
�z_SSLPipe.do_handshakecCsj|jtkrtd��|jtkr$td��|jttfks6t�t|_||_|�d�\}}|gksf|dgksft�|S)a1Start the SSL shutdown sequence.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the shutdown is complete. The callback will be
        called without arguments.
        zno security layer presentzshutdown in progressr$)	rrr&�	_SHUTDOWNr"r'r*rr(r+r
r
r�shutdowns	

z_SSLPipe.shutdowncCs2|j��|�d�\}}|gks.|dgks.t�dS)z�Send a potentially "ragged" EOF.

        This method will raise an SSL_ERROR_EOF exception if the EOF is
        unexpected.
        r$N)rZ	write_eofr(r*)rr-r.r
r
r�feed_eof�s
z_SSLPipe.feed_eofFc
Cs�|jtkr"|r|g}ng}g|fSd|_|r8|j�|�g}g}z�|jtkrz|j��t|_|j	rl|�	d�|rz||fWS|jtkr�|j�
|j�}|�|�|s�q�q�nJ|jt
kr�|j��d|_t|_|jr�|��n|jtkr�|�|j�
��Wnztjtjfk
�rl}zRt|dd�}|tjtjtjfk�rP|jtk�rN|j	�rN|�	|��|tjk|_W5d}~XYnX|jj�r�|�|j�
��||fS)a�Feed SSL record level data into the pipe.

        The data must be a bytes instance. It is OK to send an empty bytes
        instance. This can be used to get ssldata for a handshake initiated by
        this endpoint.

        Return a (ssldata, appdata) tuple. The ssldata element is a list of
        buffers containing SSL data that needs to be sent to the remote SSL.

        The appdata element is a list of buffers containing plaintext data that
        needs to be forwarded to the application. The appdata list may contain
        an empty buffer indicating an SSL "close_notify" alert. This alert must
        be acknowledged by calling shutdown().
        FN�errno)rrrr�writer'rr/r"r�read�max_size�appendr0Zunwraprr	�SSLError�CertificateError�getattr�SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITE�SSL_ERROR_SYSCALLr�pending)r�datar%r.r-�chunk�exc�	exc_errnor
r
rr(�sZ










�

z_SSLPipe.feed_ssldatarc
Cs4d|krt|�ksnt�|jtkrT|t|�krD||d�g}ng}|t|�fSg}t|�}d|_z(|t|�kr�||j�||d��7}Wnhtj	k
r�}zHt
|dd�}|jdkr�tj}|_
|tjtjtjfkrڂ|tjk|_W5d}~XYnX|jj�r|�|j���|t|�k�s,|jr`�q,q`||fS)aFeed plaintext data into the pipe.

        Return an (ssldata, offset) tuple. The ssldata element is a list of
        buffers containing record level data that needs to be sent to the
        remote SSL instance. The offset is the number of plaintext bytes that
        were processed, which may be less than the length of data.

        NOTE: In case of short writes, this call MUST be retried with the SAME
        buffer passed into the *data* argument (i.e. the id() must be the
        same). This is an OpenSSL requirement. A further particularity is that
        a short write will always have offset == 0, because the _ssl module
        does not enable partial writes. And even though the offset is zero,
        there will still be encrypted data in ssldata.
        rNFr3ZPROTOCOL_IS_SHUTDOWN)r)r*rr�
memoryviewrrr4r	r8r:�reasonr;r3r<r=rr>r7r5)rr?�offsetr-ZviewrArBr
r
r�feed_appdata�s6

�
z_SSLPipe.feed_appdata)N)N)N)F)r)�__name__�
__module__�__qualname__�__doc__r6r�propertyrr r!r#r/r1r2r(rFr
r
r
rr$s 








Krc@s�eZdZejjZdd�Zd"dd�Zdd�Z	dd	�Z
d
d�Zdd
�Ze
jfdd�Zdd�Zdd�Zdd�Zd#dd�Zdd�Zedd��Zdd�Zdd�Zd d!�ZdS)$�_SSLProtocolTransportcCs||_||_d|_dS)NF)�_loop�
_ssl_protocol�_closed)r�loopZssl_protocolr
r
rr!sz_SSLProtocolTransport.__init__NcCs|j�||�S)z#Get optional transport information.)rN�_get_extra_info�r�name�defaultr
r
r�get_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j�|�dS�N)rN�_set_app_protocol)r�protocolr
r
r�set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSrV)rN�
_app_protocolrr
r
r�get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSrV)rOrr
r
r�
is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|j��dS)a
Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) called
        with None as its argument.
        TN)rOrN�_start_shutdownrr
r
r�close4sz_SSLProtocolTransport.closecCs&|js"|d|��t|d�|��dS)Nzunclosed transport )�source)rO�ResourceWarningr^)rZ_warnr
r
r�__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd��|��S)Nz*SSL transport has not been initialized yet)rN�
_transportr&�
is_reading)rZtrr
r
rrcDsz _SSLProtocolTransport.is_readingcCs|jj��dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        N)rNrb�
pause_readingrr
r
rrdJsz#_SSLProtocolTransport.pause_readingcCs|jj��dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        N)rNrb�resume_readingrr
r
rreRsz$_SSLProtocolTransport.resume_readingcCs|jj�||�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        N)rNrb�set_write_buffer_limits)rZhighZlowr
r
rrfZsz-_SSLProtocolTransport.set_write_buffer_limitscCs|jj��S)z,Return the current size of the write buffer.)rNrb�get_write_buffer_sizerr
r
rrgosz+_SSLProtocolTransport.get_write_buffer_sizecCs
|jjjSrV)rNrb�_protocol_pausedrr
r
rrhssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttf�s$tdt|�j����|s,dS|j�|�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        z+data: expecting a bytes-like instance, got N)	�
isinstance�bytes�	bytearrayrC�	TypeError�typerGrN�_write_appdata�rr?r
r
rr4xs
z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr
rr
r
r�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|j��d|_dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        TN)rN�_abortrOrr
r
r�abort�s
z_SSLProtocolTransport.abort)N)NN)rGrHrIrZ
_SendfileModeZFALLBACKZ_sendfile_compatiblerrUrYr[r\r^�warnings�warnrarcrdrerfrgrKrhr4rprrr
r
r
rrLs$



rLc@s�eZdZdZd,dd�Zdd�Zd-d	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zd.dd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd/d&d'�Zd(d)�Zd*d+�ZdS)0�SSLProtocolz�SSL protocol.

    Implementation of SSL on top of a socket using incoming and outgoing
    buffers which are ssl.MemoryBIO objects.
    FNTc		Cs�tdkrtd��|dkr tj}n|dkr6td|����|sDt||�}||_|rZ|sZ||_nd|_||_t	|d�|_
t��|_
d|_||_||_|�|�t|j|�|_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )rF)r	r&rZSSL_HANDSHAKE_TIMEOUTrrrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrMrWrL�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownrb�_call_connection_made�_ssl_handshake_timeout)	rrP�app_protocolrZwaiterr
rZcall_connection_madeZssl_handshake_timeoutr
r
rr�s@��

zSSLProtocol.__init__cCs||_t|tj�|_dSrV)rZrirZBufferedProtocol�_app_protocol_is_buffer)rr�r
r
rrW�s
�zSSLProtocol._set_app_protocolcCsD|jdkrdS|j��s:|dk	r.|j�|�n|j�d�d|_dSrV)r}Z	cancelledZ
set_exceptionZ
set_result�rrAr
r
r�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|��dS)zXCalled when the low-level connection is made.

        Start the SSL handshake.
        N)rbrrvrrr�_start_handshake)r�	transportr
r
r�connection_made�s�zSSLProtocol.connection_madecCsn|jr d|_|j�|jj|�n|jdk	r2d|j_d|_d|_t|dd�rT|j	�
�|�|�d|_d|_dS)z�Called when the low-level connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        FNT�_handshake_timeout_handle)
r�rM�	call_soonrZ�connection_lostr~rOrbr:r��cancelr�rr�r
r
rr��s


zSSLProtocol.connection_lostcCs|j��dS)z\Called when the low-level transport's buffer goes over
        the high-water mark.
        N)rZ�
pause_writingrr
r
rr��szSSLProtocol.pause_writingcCs|j��dS)z^Called when the low-level transport's buffer drains below
        the low-water mark.
        N)rZ�resume_writingrr
r
rr�szSSLProtocol.resume_writingcCs"|jdkrdSz|j�|�\}}WnLttfk
r<�Yn4tk
rn}z|�|d�WY�dSd}~XYnX|D]}|j�|�qt|D]�}|�rz&|jr�t	�
|j|�n|j�|�WnPttfk
r��Yn8tk
�r
}z|�|d�WY�dSd}~XYnXq�|�
��qq�dS)zXCalled when some SSL data is received.

        The argument is a bytes object.
        NzSSL error in data receivedz/application protocol failed to receive SSL data)rr(�
SystemExit�KeyboardInterrupt�
BaseException�_fatal_errorrbr4r�rZ_feed_data_to_buffered_protorZ�
data_receivedr])rr?r-r.�er@Zexr
r
rr�s<
��zSSLProtocol.data_receivedcCsTzB|j��rt�d|�|�t�|js@|j	�
�}|r@t�d�W5|j��XdS)aCalled when the other end of the low-level stream
        is half-closed.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        z%r received EOFz?returning true from eof_received() has no effect when using sslN)rbr^rM�	get_debugr�debugr��ConnectionResetErrorr�rZ�eof_receivedZwarning)rZ	keep_openr
r
rr�-s


zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk	r,|j�||�S|SdSrV)rxrbrUrRr
r
rrQCs



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|��nd|_|�d�dS)NTr$)r�r�rqrnrr
r
rr]Ks
zSSLProtocol._start_shutdowncCs.|j�|df�|jt|�7_|��dS)Nr)r{r7r|r)�_process_write_backlogror
r
rrnTszSSLProtocol._write_appdatacCs\|j��r$t�d|�|j��|_nd|_d|_|j�d�|j�	|j
|j�|_|�
�dS)Nz%r starts SSL handshakeT)r$r)rMr�rr��time�_handshake_start_timer�r{r7Z
call_laterr��_check_handshake_timeoutr�r�rr
r
rr�Ys

��zSSLProtocol._start_handshakecCs*|jdkr&d|j�d�}|�t|��dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)r�r�r��ConnectionAbortedError)r�msgr
r
rr�hs
�z$SSLProtocol._check_handshake_timeoutc
Csd|_|j��|jj}z|dk	r&|�|��}Wnbttfk
rJ�YnJtk
r�}z,t	|t
j�rld}nd}|�||�WY�dSd}~XYnX|j
��r�|j
��|j}t�d||d�|jj||��|��|d�|jr�|j�|j�|��d|_|j
�|j�dS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compressionr T)r�r�r�rr Zgetpeercertr�r�r�rir	r9r�rMr�r�r�rr�rx�updater�r�r�rZr�r~r�r�r�r�)rZ
handshake_excZsslobjr�rAr�Zdtr
r
r�_on_handshake_completeqs8

�z"SSLProtocol._on_handshake_completec
CsP|jdks|jdkrdSz�tt|j��D]�}|jd\}}|rR|j�||�\}}n*|rj|j�|j�}d}n|j�|j	�}d}|D]}|j�
|�q�|t|�kr�||f|jd<|jjs�t�|jj
r�|j��q�|jd=|jt|�8_q(Wn^ttfk
�r�YnDtk
�rJ}z$|j�r.|�|�n|�|d�W5d}~XYnXdS)NrrzFatal error on SSL transport)rbr�ranger)r{rFr/r�r1�	_finalizer4r!r*Z_pausedrer|r�r�r�r�r�)r�ir?rEr-r@rAr
r
rr��s<�
z"SSLProtocol._process_write_backlog�Fatal error on transportcCsVt|t�r(|j��r@tjd||dd�n|j�|||j|d��|jrR|j�|�dS)Nz%r: %sT)�exc_info)�messageZ	exceptionr�rX)	ri�OSErrorrMr�rr�Zcall_exception_handlerrbZ_force_close)rrAr�r
r
rr��s

�zSSLProtocol._fatal_errorcCsd|_|jdk	r|j��dSrV)rrbr^rr
r
rr��s
zSSLProtocol._finalizecCs(z|jdk	r|j��W5|��XdSrV)r�rbrrrr
r
rrq�s
zSSLProtocol._abort)FNTN)N)N)r�)rGrHrIrJrrWr�r�r�r�r�r�r�rQr]rnr�r�r�r�r�r�rqr
r
r
rru�s0�
.

&
		)+
ru)ryrsr	�ImportError�rrrr�logrrrr'r"r0�objectrZ_FlowControlMixinZ	TransportrLZProtocolrur
r
r
r�<module>s*
y�xPK
0�\j�xxconstants.cpython-38.opt-2.pycnu�[���U

e5d��@s8dZZZdZZZdZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6d3Z7d4Z8d5Z9d6Z:d7Z;d8Z<d9Z=d:Z>d;Z?d<Z@d=ZAd>ZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIdFZJdGZKdHZLdIS)J���n�s�w�eZnw�sw�neZse�nsZewZnsew�centerZnone�x�yZboth�left�top�rightZbottomZraisedZsunkenZflatZridgeZgrooveZsolidZ
horizontalZvertical�numeric�charZwordZbaselineZinsideZoutsideZselz	sel.firstzsel.last�end�insertZcurrentZanchor�allZnormalZdisabledZactiveZhiddenZcascadeZcheckbuttonZcommandZradiobuttonZ	separatorZsingleZbrowseZmultipleZextendedZdotboxZ	underlineZpiesliceZchordZarc�firstZlastZbuttZ
projecting�roundZbevelZmiterZmovetoZscrollZunitsZpagesN)MZNOZFALSEZOFFZYESZTRUEZON�N�S�W�EZNWZSWZNEZSEZNSZEWZNSEWZCENTERZNONE�X�YZBOTHZLEFTZTOPZRIGHTZBOTTOMZRAISEDZSUNKENZFLATZRIDGEZGROOVEZSOLIDZ
HORIZONTALZVERTICALZNUMERICZCHARZWORDZBASELINEZINSIDEZOUTSIDEZSELZ	SEL_FIRSTZSEL_LASTZENDZINSERTZCURRENTZANCHORZALLZNORMALZDISABLEDZACTIVEZHIDDENZCASCADEZCHECKBUTTONZCOMMANDZRADIOBUTTONZ	SEPARATORZSINGLEZBROWSEZMULTIPLEZEXTENDEDZDOTBOXZ	UNDERLINEZPIESLICEZCHORDZARCZFIRSTZLASTZBUTTZ
PROJECTINGZROUNDZBEVELZMITERZMOVETOZSCROLLZUNITSZPAGES�rr�)/usr/lib64/python3.8/tkinter/constants.py�<module>s�PK
0�\@c.�
	
	log.cpython-38.pycnu�[���U

e5d��@sldZdZdZdZdZdZddlZGdd	�d	�Ze�Zej	Z	ej
Z
ejZejZej
Z
ejZd
d�Zdd
�ZdS)z,A simple log mechanism styled after PEP 282.������Nc@sPeZdZefdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�LogcCs
||_dS�N)�	threshold)�selfr	�r�%/usr/lib64/python3.8/distutils/log.py�__init__szLog.__init__cCs�|tttttfkr"tdt|���||jkr�|r8||}|tttfkrNtj	}ntj
}z|�d|�Wn:tk
r�|j
}|�|d��|�}|�d|�YnX|��dS)Nz%s wrong log levelz%s
�backslashreplace)�DEBUG�INFO�WARN�ERROR�FATAL�
ValueError�strr	�sys�stderr�stdout�write�UnicodeEncodeError�encoding�encode�decode�flush)r
�level�msg�args�streamrrrr�_logs
zLog._logcGs|�|||�dSr)r#)r
rr r!rrr�log'szLog.logcGs|�t||�dSr)r#r�r
r r!rrr�debug*sz	Log.debugcGs|�t||�dSr)r#rr%rrr�info-szLog.infocGs|�t||�dSr)r#rr%rrr�warn0szLog.warncGs|�t||�dSr)r#rr%rrr�error3sz	Log.errorcGs|�t||�dSr)r#rr%rrr�fatal6sz	Log.fatalN)�__name__�
__module__�__qualname__rr
r#r$r&r'r(r)r*rrrrrsrcCstj}|t_|Sr)�_global_logr	)r�oldrrr�
set_thresholdAsr0cCs8|dkrtt�n"|dkr$tt�n|dkr4tt�dS)Nrrr)r0rrr)�vrrr�
set_verbosityGs

r2)�__doc__rrrrrrrr.r$r&r'r(r)r*r0r2rrrr�<module>s +PK
0�\����coroutines.cpython-38.opt-1.pycnu�[���U

e5d]"�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddlmZdd	�Ze�ZGd
d�d�Zdd
�Ze�Zdd�ZejejejjefZe�Zdd�Zdd�ZdS))�	coroutine�iscoroutinefunction�iscoroutine�N�)�base_futures)�	constants)�format_helpers)�loggercCs"tjjp tjjo ttj�d��S)NZPYTHONASYNCIODEBUG)�sys�flags�dev_mode�ignore_environment�bool�os�environ�get�rr�*/usr/lib64/python3.8/asyncio/coroutines.py�_is_debug_modes�rc@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zddd
�Zdd�Z	e
dd��Ze
dd��Ze
dd��Z
dd�Ze
dd��Zdd�ZdS)�CoroWrapperNcCs>||_||_t�t�d��|_t|dd�|_t|dd�|_	dS)Nr�__name__�__qualname__)
�gen�funcr�
extract_stackr
�	_getframe�_source_traceback�getattrrr)�selfrrrrr�__init__'s
zCoroWrapper.__init__cCsJt|�}|jr4|jd}|d|d�d|d��7}d|jj�d|�d�S)	N���z
, created at r�:r�<� �>)�_format_coroutiner�	__class__r)r�	coro_repr�framerrr�__repr__/s

zCoroWrapper.__repr__cCs|S�Nr�rrrr�__iter__7szCoroWrapper.__iter__cCs|j�d�Sr*�r�sendr+rrr�__next__:szCoroWrapper.__next__cCs|j�|�Sr*r-)r�valuerrrr.=szCoroWrapper.sendcCs|j�|||�Sr*)r�throw)r�typer0�	tracebackrrrr1@szCoroWrapper.throwcCs
|j��Sr*)r�closer+rrrr4CszCoroWrapper.closecCs|jjSr*)r�gi_framer+rrrr5FszCoroWrapper.gi_framecCs|jjSr*)r�
gi_runningr+rrrr6JszCoroWrapper.gi_runningcCs|jjSr*)r�gi_coder+rrrr7NszCoroWrapper.gi_codecCs|Sr*rr+rrr�	__await__RszCoroWrapper.__await__cCs|jjSr*)r�gi_yieldfromr+rrrr9UszCoroWrapper.gi_yieldfromcCs�t|dd�}t|dd�}|dk	r||jdkr||�d�}t|dd�}|rrd�t�|��}|dtj�d	�7}||��7}t�	|�dS)
Nrr5r z was never yielded fromrr�zB
Coroutine object created at (most recent call last, truncated to z last lines):
)
r�f_lasti�joinr3�format_listrZDEBUG_STACK_DEPTH�rstripr	�error)rrr(�msg�tbrrr�__del__Ys
zCoroWrapper.__del__)N)NN)r�
__module__rrr)r,r/r.r1r4�propertyr5r6r7r8r9rBrrrrr$s"





rcsztjdtdd�t���r�St���r.��nt����fdd���t�	���t
sX�}nt�����fdd��}t|_|S)z�Decorator to mark coroutines.

    If the coroutine is not yielded from before it is destroyed,
    an error message is logged.
    zN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead�)�
stacklevelc?sr�||�}t�|�s(t�|�s(t|t�r4|EdH}n:z
|j}Wntk
rRYnXt|tj	j
�rn|�EdH}|Sr*)rZisfuture�inspectZisgenerator�
isinstancerr8�AttributeError�collections�abc�	Awaitable)�args�kw�resZ
await_meth�rrr�corozs
�
zcoroutine.<locals>.corocs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)NrPr rr)rrrrr)rM�kwds�w�rQrrr�wrapper�szcoroutine.<locals>.wrapper)�warnings�warn�DeprecationWarningrGr�isgeneratorfunction�	functools�wraps�typesr�_DEBUG�
_is_coroutine)rrUrrTrris"�


rcCst�|�pt|dd�tkS)z6Return True if func is a decorated coroutine function.r^N)rGrrr^rPrrrr�s
�rcCs@t|�tkrdSt|t�r8tt�dkr4t�t|��dSdSdS)z)Return True if obj is a coroutine object.T�dFN)r2�_iscoroutine_typecacherH�_COROUTINE_TYPES�len�add)�objrrrr�s
rc
sht|t���fdd�}dd�}d}t|d�r:|jr:|j}nt|d�rP|jrP|j}||�}|sr||�rn|�d�S|Sd}t|d�r�|jr�|j}nt|d	�r�|jr�|j}|jp�d
}d}��r$|jdk	�r$t	�
|j��s$t�|j�}|dk	r�|\}}|dk�r|�d|�d
|��}	n|�d|�d
|��}	n@|dk	�rJ|j
}|�d|�d
|��}	n|j}|�d|�d
|��}	|	S)Ncs`�rt�|jdi�St|d�r,|jr,|j}n*t|d�rD|jrD|j}ndt|�j�d�}|�d�S)Nrrrr"z without __name__>z())rZ_format_callbackr�hasattrrrr2)rQ�	coro_name�Zis_corowrapperrr�get_name�sz#_format_coroutine.<locals>.get_namecSsHz|jWStk
rBz|jWYStk
r<YYdSXYnXdS)NF)�
cr_runningrIr6)rQrrr�
is_running�sz%_format_coroutine.<locals>.is_running�cr_coder7z runningr5�cr_framez<empty co_filename>rz done, defined at r!z running, defined at z running at )rHrrerkr7r5rl�co_filenamerrGrYrZ_get_function_source�f_lineno�co_firstlineno)
rQrhrjZ	coro_coderfZ
coro_frame�filename�lineno�sourcer'rrgrr%�sJ
	

�
�

r%) �__all__Zcollections.abcrJrZrGrr
r3r\rVr:rrr�logr	rr]rr�objectr^r�
CoroutineType�
GeneratorTyperK�	Coroutinera�setr`rr%rrrr�<module>s2E8�PK
0�\�с�^�^tasks.cpython-38.opt-1.pycnu�[���U

e5d���@svdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZdd
l
mZe�d�jZdBdd�ZdCd
d�ZdDdd�Zdd�ZGdd�dej�ZeZzddlZWnek
r�YnXejZZdd�dd�Zejj Z ejj!Z!ejj"Z"dde"d�dd�Z#dd�Z$dd�dd�Z%d d!�Z&d"d#�Z'ddd$�d%d&�Z(ej)d'd(��Z*dEdd�d)d*�Z+dd�d+d,�Z,ej)d-d.��Z-ee-_Gd/d0�d0ej.�Z/dd1d2�d3d4�Z0dd�d5d6�Z1d7d8�Z2e
�3�Z4iZ5d9d:�Z6d;d<�Z7d=d>�Z8d?d@�Z9e6Z:e9Z;e7Z<e8Z=z$ddAlm6Z6m9Z9m7Z7m8Z8m4Z4m5Z5Wnek
�r`YnXe6Z>e9Z?e7Z@e8ZAdS)Fz0Support for tasks, coroutines and the scheduler.)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield�
ensure_future�run_coroutine_threadsafe�current_task�	all_tasks�_register_task�_unregister_task�_enter_task�_leave_task�N�)�
base_tasks)�
coroutines)�events)�
exceptions)�futures)�
_is_coroutinecCs|dkrt��}t�|�S)z!Return a currently executed task.N)r�get_running_loop�_current_tasks�get��loop�r!�%/usr/lib64/python3.8/asyncio/tasks.pyr"srcs^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)z'Return a set of all tasks for the loop.Nrr��cs&h|]}t�|��kr|��s|�qSr!)r�	_get_loop�done��.0�trr!r"�	<setcomp><s�zall_tasks.<locals>.<setcomp>)rr�list�
_all_tasks�RuntimeError�r �iZtasksr!rr"r)srcs^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)Nrrr#csh|]}t�|��kr|�qSr!)rr$r&rr!r"r)Usz$_all_tasks_compat.<locals>.<setcomp>)r�get_event_loopr*r+r,r-r!rr"�_all_tasks_compat@sr0cCs4|dk	r0z
|j}Wntk
r&Yn
X||�dS�N)�set_name�AttributeError)�task�namer2r!r!r"�_set_task_nameXs
r6cs�eZdZdZdZed%dd��Zed&dd��Zddd��fd	d
�
Z�fdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�dd�Zddd�dd�Zdd �Zd'�fd!d"�	Zd#d$�Z�ZS)(rz A coroutine wrapped in a Future.TNcCs(tjdtdd�|dkr t��}t|�S)z�Return the currently running task in an event loop or None.

        By default the current task for the current event loop is returned.

        None is returned when called not in the context of a Task.
        zVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead���
stacklevelN)�warnings�warn�DeprecationWarningrr/r��clsr r!r!r"rts�zTask.current_taskcCstjdtdd�t|�S)z|Return a set of all tasks for an event loop.

        By default all tasks for the current event loop are returned.
        zPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r0r=r!r!r"r�s
�zTask.all_tasks)r r5cs�t�j|d�|jr|jd=t�|�s:d|_td|����|dkrRdt���|_n
t	|�|_d|_
d|_||_t
��|_|jj|j|jd�t|�dS)Nr���Fza coroutine was expected, got zTask-��context)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending�	TypeError�_task_name_counter�_name�str�_must_cancel�_fut_waiter�_coro�contextvarsZcopy_context�_context�_loop�	call_soon�_Task__stepr)�self�coror r5��	__class__r!r"rC�s


z
Task.__init__csF|jtjkr8|jr8|dd�}|jr,|j|d<|j�|�t���dS)Nz%Task was destroyed but it is pending!)r4�messageZsource_traceback)	Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB�__del__)rSrArUr!r"rX�s�
zTask.__del__cCs
t�|�Sr1)rZ_task_repr_info�rSr!r!r"�
_repr_info�szTask._repr_infocCs|jSr1)rMrYr!r!r"�get_coro�sz
Task.get_corocCs|jSr1)rIrYr!r!r"�get_name�sz
Task.get_namecCst|�|_dSr1)rJrI)rS�valuer!r!r"r2�sz
Task.set_namecCstd��dS)Nz*Task does not support set_result operation�r,)rS�resultr!r!r"�
set_result�szTask.set_resultcCstd��dS)Nz-Task does not support set_exception operationr^)rS�	exceptionr!r!r"�
set_exception�szTask.set_exception)�limitcCst�||�S)a�Return the list of stack frames for this task's coroutine.

        If the coroutine is not done, this returns the stack where it is
        suspended.  If the coroutine has completed successfully or was
        cancelled, this returns an empty list.  If the coroutine was
        terminated by an exception, this returns the list of traceback
        frames.

        The frames are always ordered from oldest to newest.

        The optional limit gives the maximum number of frames to
        return; by default all available frames are returned.  Its
        meaning differs depending on whether a stack or a traceback is
        returned: the newest frames of a stack are returned, but the
        oldest frames of a traceback are returned.  (This matches the
        behavior of the traceback module.)

        For reasons beyond our control, only one stack frame is
        returned for a suspended coroutine.
        )rZ_task_get_stack)rSrcr!r!r"�	get_stack�szTask.get_stack)rc�filecCst�|||�S)anPrint the stack or traceback for this task's coroutine.

        This produces output similar to that of the traceback module,
        for the frames retrieved by get_stack().  The limit argument
        is passed to get_stack().  The file argument is an I/O stream
        to which the output is written; by default output is written
        to sys.stderr.
        )rZ_task_print_stack)rSrcrer!r!r"�print_stack�s	zTask.print_stackcCs4d|_|��rdS|jdk	r*|j��r*dSd|_dS)a�Request that this task cancel itself.

        This arranges for a CancelledError to be thrown into the
        wrapped coroutine on the next cycle through the event loop.
        The coroutine then has a chance to clean up or even deny
        the request using try/except/finally.

        Unlike Future.cancel, this does not guarantee that the
        task will be cancelled: the exception might be caught and
        acted upon, delaying cancellation of the task or preventing
        cancellation completely.  The task may also return a value or
        raise a different exception.

        Immediately after this method is called, Task.cancelled() will
        not return True (unless the task was already cancelled).  A
        task will be marked as cancelled when the wrapped coroutine
        terminates with a CancelledError exception (even if cancel()
        was not called).
        FNT)Z_log_tracebackr%rL�cancelrKrYr!r!r"rg�s

zTask.cancelc
s�|��rt�d|�d|����|jr>t|tj�s8t��}d|_|j}d|_t|j	|��zfz"|dkrp|�d�}n
|�|�}Wn�t
k
r�}z*|jr�d|_t���nt��|j�W5d}~XY�n�tjk
r�t���Y�n�ttfk
�r}zt��|��W5d}~XY�n�tk
�rL}zt��|�W5d}~XY�npXt|dd�}|dk	�r@t�|�|j	k	�r�td|�d|�d��}|j	j|j||jd�n�|�r||k�r�td	|���}|j	j|j||jd�n8d|_|j|j|jd�||_|j�r>|j���r>d|_n*td
|�d|���}|j	j|j||jd�n||dk�r`|j	j|j|jd�n\t �!|��r�td|�d|���}|j	j|j||jd�n$td
|���}|j	j|j||jd�W5t
|j	|�d}XdS)Nz_step(): already done: z, F�_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r%rZInvalidStateErrorrK�
isinstance�CancelledErrorrMrLrrPr�send�throw�
StopIterationrBrgr`r]�KeyboardInterrupt�
SystemExitrb�
BaseException�getattrrr$r,rQrRrOrh�add_done_callback�
_Task__wakeup�inspectZisgenerator)rS�excrTr_Zblocking�new_excrUr!r"Z__steps��  
��
�����
���
zTask.__stepc
CsJz|��Wn,tk
r8}z|�|�W5d}~XYn
X|��d}dSr1)r_rprR)rS�futurerur!r!r"Z__wakeup[sz
Task.__wakeup)N)N)N)�__name__�
__module__�__qualname__�__doc__rF�classmethodrrrCrXrZr[r\r2r`rbrdrfrgrRrs�
__classcell__r!r!rUr"rbs&
!Tr)r5cCs t��}|�|�}t||�|S)z]Schedule the execution of a coroutine object in a spawn task.

    Return a Task object.
    )rrrr6)rTr5r r4r!r!r"rxs

r)r �timeout�return_whenc�s�t�|�st�|�r(tdt|�j����|s4td��|tt	t
fkrPtd|�����dkrbt���nt
jdtdd��fdd	�t|�D�}t|||��IdHS)
a�Wait for the Futures and coroutines given by fs to complete.

    The fs iterable must not be empty.

    Coroutines will be wrapped in Tasks.

    Returns two sets of Future: (done, pending).

    Usage:

        done, pending = await asyncio.wait(fs)

    Note: This does not raise TimeoutError! Futures that aren't done
    when the timeout occurs are returned in the second set.
    zexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: N�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|�d��qS�r�r�r'�frr!r"r)�szwait.<locals>.<setcomp>)r�isfuturerrErG�typerx�
ValueErrorrrrrrr:r;r<�set�_wait)�fsr r~rr!rr"r�s
�rcGs|��s|�d�dSr1)r%r`)�waiter�argsr!r!r"�_release_waiter�sr�rc
�s�|dkrt��}ntjdtdd�|dkr4|IdHS|dkr�t||d�}|��rX|��St||d�IdHz|��Wn.t	j
k
r�}zt	��|�W5d}~XYn
Xt	���|��}|�
|t|�}t�t|�}t||d�}|�|�z�z|IdHWnPt	j
k
�rF|���r$|��YW�dS|�|�t||d�IdH�YnX|���r^|��W�*S|�|�t||d�IdHt	���W5|��XdS)a�Wait for the single Future or coroutine to complete, with timeout.

    Coroutine will be wrapped in Task.

    Returns result of the Future or coroutine.  When a timeout occurs,
    it cancels the task and raises TimeoutError.  To avoid the task
    cancellation, wrap it in shield().

    If the wait is cancelled, the task is also cancelled.

    This function is a coroutine.
    Nr�r7r8rr)rrr:r;r<rr%r_�_cancel_and_waitrrj�TimeoutError�
create_future�
call_laterr��	functools�partialrrrg�remove_done_callback)�futr~r rur��timeout_handle�cbr!r!r"r�sL

�





rc
�s�|���d�|dk	r"|�|t���t|������fdd�}|D]}|�|�q@z�IdHW5�dk	rp���|D]}|�|�qtXt�t�}}|D]"}|��r�|�	|�q�|�	|�q�||fS)zVInternal helper for wait().

    The fs argument must be a collection of Futures.
    NcsZ�d8��dks4�tks4�tkrV|��sV|��dk	rV�dk	rD������sV��d�dS)Nrr)rr�	cancelledrargr%r`�r��Zcounterrr�r�r!r"�_on_completions���
�z_wait.<locals>._on_completion)
r�r�r��lenrrrgr�r�r%�add)r�r~rr r�r�r%Zpendingr!r�r"r��s(r�c	�sF|��}t�t|�}|�|�z|��|IdHW5|�|�XdS)z<Cancel the *fut* future or task and wait until it completes.N)r�r�r�r�rrr�rg)r�r r�r�r!r!r"r�&s
r�)r r~c#s�t�|�st�|�r(tdt|�j����ddlm}|�d���dkrPt	�
��ntjdt
dd��fd	d
�t|�D��d����fdd�}���fd
d���fdd�}�D]}|���q��r�|dk	r҈�||��tt���D]}|�Vq�dS)a^Return an iterator whose values are coroutines.

    When waiting for the yielded coroutines you'll get the results (or
    exceptions!) of the original Futures (or coroutines), in the order
    in which and as soon as they complete.

    This differs from PEP 3148; the proper way to use this is:

        for f in as_completed(fs):
            result = await f  # The 'await' may raise.
            # Use result.

    If a timeout is specified, the 'await' will raise
    TimeoutError when the timeout occurs before all Futures are done.

    Note: The futures 'f' are not necessarily members of fs.
    z#expect an iterable of futures, not r)�QueuerNr�r7r8csh|]}t|�d��qSr�r�r�rr!r"r)Uszas_completed.<locals>.<setcomp>cs*�D]}|�����d�q���dSr1)r��
put_nowait�clearr�)r�r%�todor!r"�_on_timeoutXs
z!as_completed.<locals>._on_timeoutcs4�sdS��|���|��s0�dk	r0���dSr1)�remover�rgr�)r%r�r�r!r"r�^s

z$as_completed.<locals>._on_completionc�s$���IdH}|dkrtj�|��Sr1)rrr�r_r�)r%r!r"�
_wait_for_onefsz#as_completed.<locals>._wait_for_one)rr�rrErGr�rxZqueuesr�rr/r:r;r<r�rrr��ranger�)r�r r~r�r�r�r��_r!)r�r%r r�r�r"r7s*

�rccs
dVdS)z�Skip one event loop run cycle.

    This is a private helper for 'asyncio.sleep()', used
    when the 'delay' is set to 0.  It uses a bare 'yield'
    expression (which Task.__step knows how to handle)
    instead of creating a Future object.
    Nr!r!r!r!r"�__sleep0us	r�c�sr|dkrt�IdH|S|dkr*t��}ntjdtdd�|��}|�|tj	||�}z|IdHW�S|�
�XdS)z9Coroutine that completes after a given time (in seconds).rNr�r7r8)r�rrr:r;r<r�r�rZ_set_result_unless_cancelledrg)Zdelayr_r rw�hr!r!r"r	�s$
��r	cCs�t�|�r6|dkrt��}|�|�}|jr2|jd=|St�|�rb|dk	r^|t�|�k	r^t	d��|St
�|�r|tt
|�|d�Std��dS)zmWrap a coroutine or an awaitable in a future.

    If the argument is a Future, it is returned directly.
    Nr?zRThe future belongs to a different loop than the one specified as the loop argumentrz:An asyncio.Future, a coroutine or an awaitable is required)rrErr/rrDrr�r$r�rtZisawaitabler�_wrap_awaitablerG)Zcoro_or_futurer r4r!r!r"r�s



rccs|��EdHS)z�Helper for asyncio.ensure_future().

    Wraps awaitable (an object with __await__) into a coroutine
    that will later be wrapped in a Task by ensure_future().
    N)�	__await__)Z	awaitabler!r!r"r��sr�cs.eZdZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFuturez�Helper for gather().

    This overrides cancel() to cancel all the children and act more
    like Task.cancel(), which doesn't immediately mark itself as
    cancelled.
    Nrcst�j|d�||_d|_dS)NrF)rBrC�	_children�_cancel_requested)rS�childrenr rUr!r"rC�sz_GatheringFuture.__init__cCs6|��rdSd}|jD]}|��rd}q|r2d|_|S)NFT)r%r�rgr�)rSZretZchildr!r!r"rg�s
z_GatheringFuture.cancel)rxryrzr{rCrgr}r!r!rUr"r��sr�F)r �return_exceptionscs�|s<|dkrt��}ntjdtdd�|�����g��S�����fdd�}i}g�d�d�|D]f}||kr�t||d�}|dkr�t�	|�}||k	r�d	|_
�d
7�|||<|�|�n||}��|�qdt
�|d���S)a�Return a future aggregating results from the given coroutines/futures.

    Coroutines will be wrapped in a future and scheduled in the event
    loop. They will not necessarily be scheduled in the same order as
    passed in.

    All futures must share the same event loop.  If all the tasks are
    done successfully, the returned future's result is the list of
    results (in the order of the original sequence, not necessarily
    the order of results arrival).  If *return_exceptions* is True,
    exceptions in the tasks are treated the same as successful
    results, and gathered in the result list; otherwise, the first
    raised exception will be immediately propagated to the returned
    future.

    Cancellation: if the outer Future is cancelled, all children (that
    have not completed yet) are also cancelled.  If any child is
    cancelled, this is treated as if it raised CancelledError --
    the outer Future is *not* cancelled in this case.  (This is to
    prevent the cancellation of one child to cause other children to
    be cancelled.)

    If *return_exceptions* is False, cancelling gather() after it
    has been marked done won't cancel any submitted awaitables.
    For instance, gather can be marked done after propagating an
    exception to the caller, therefore, calling ``gather.cancel()``
    after catching an exception (raised by one of the awaitables) from
    gather won't cancel any other awaitables.
    Nr�r7r8cs��d7����r$|��s |��dS�sd|��rFt��}��|�dS|��}|dk	rd��|�dS��kr�g}�D]8}|��r�t��}n|��}|dkr�|��}|�|�qt�jrĈ�t���n
��	|�dS)Nr)
r%r�rarrjrbr_�appendr�r`)r�ruZresults�res�r�Z	nfinishedZnfuts�outerr�r!r"�_done_callbacks4


zgather.<locals>._done_callbackrrFr)rr/r:r;r<r�r`rrr$rFrrr�r�)r r�Zcoros_or_futuresr�Z
arg_to_fut�argr�r!r�r"r
�s:
�
1
r
cst|dk	rtjdtdd�t||d�����r0�St���}|����fdd����fdd	�}������|��S)
a.Wait for a future, shielding it from cancellation.

    The statement

        res = await shield(something())

    is exactly equivalent to the statement

        res = await something()

    *except* that if the coroutine containing it is cancelled, the
    task running in something() is not cancelled.  From the POV of
    something(), the cancellation did not happen.  But its caller is
    still cancelled, so the yield-from expression still raises
    CancelledError.  Note: If something() is cancelled by other means
    this will still cancel shield().

    If you want to completely ignore cancellation (not recommended)
    you can combine shield() with a try/except clause, as follows:

        try:
            res = await shield(something())
        except CancelledError:
            res = None
    Nr�r7r8rcs\���r|��s|��dS|��r.���n*|��}|dk	rJ��|�n��|���dSr1)r�rargrbr`r_)�innerru�r�r!r"�_inner_done_callbackus
z$shield.<locals>._inner_done_callbackcs���s����dSr1)r%r�r�)r�r�r!r"�_outer_done_callback�sz$shield.<locals>._outer_done_callback)	r:r;r<rr%rr$r�rr)r�r r�r!)r�r�r�r"rPs�


rcs:t���std��tj������fdd�}��|��S)zsSubmit a coroutine object to a given event loop.

    Return a concurrent.futures.Future to access the result.
    zA coroutine object is requiredc
slzt�t��d���WnNttfk
r2�Yn6tk
rf}z���rT��|��W5d}~XYnXdS)Nr)rZ
_chain_futurerrornrpZset_running_or_notify_cancelrb)ru�rTrwr r!r"�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rrErG�
concurrentr�FutureZcall_soon_threadsafe)rTr r�r!r�r"r
�s



r
cCst�|�dS)z3Register a new task in asyncio as executed by loop.N)r+r��r4r!r!r"r�srcCs4t�|�}|dk	r(td|�d|�d���|t|<dS)NzCannot enter into task z while another task z is being executed.�rrr,�r r4rr!r!r"r�s
rcCs2t�|�}||k	r(td|�d|�d���t|=dS)Nz
Leaving task z! does not match the current task �.r�r�r!r!r"r�s
rcCst�|�dS)zUnregister a task.N)r+�discardr�r!r!r"r�sr)rrrrr+r)N)N)N)N)Br{�__all__Zconcurrent.futuresr�rNr�rt�	itertools�typesr:�weakref�rrrrrr�count�__next__rHrrr0r6Z	_PyFuturerZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrr�rr�r�r�	coroutiner�r	rr�r�r�r
rr
ZWeakSetr+rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ
_c_enter_taskZ
_c_leave_taskr!r!r!r"�<module>s�	





#H,>

x?$PK
0�\�����coroutines.cpython-38.opt-2.pycnu�[���U

e5d]"�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddlmZdd	�Ze�ZGd
d�d�Zdd
�Ze�Zdd�ZejejejjefZe�Zdd�Zdd�ZdS))�	coroutine�iscoroutinefunction�iscoroutine�N�)�base_futures)�	constants)�format_helpers)�loggercCs"tjjp tjjo ttj�d��S)NZPYTHONASYNCIODEBUG)�sys�flags�dev_mode�ignore_environment�bool�os�environ�get�rr�*/usr/lib64/python3.8/asyncio/coroutines.py�_is_debug_modes�rc@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zddd
�Zdd�Z	e
dd��Ze
dd��Ze
dd��Z
dd�Ze
dd��Zdd�ZdS)�CoroWrapperNcCs>||_||_t�t�d��|_t|dd�|_t|dd�|_	dS)Nr�__name__�__qualname__)
�gen�funcr�
extract_stackr
�	_getframe�_source_traceback�getattrrr)�selfrrrrr�__init__'s
zCoroWrapper.__init__cCsJt|�}|jr4|jd}|d|d�d|d��7}d|jj�d|�d�S)	N���z
, created at r�:r�<� �>)�_format_coroutiner�	__class__r)r�	coro_repr�framerrr�__repr__/s

zCoroWrapper.__repr__cCs|S�Nr�rrrr�__iter__7szCoroWrapper.__iter__cCs|j�d�Sr*�r�sendr+rrr�__next__:szCoroWrapper.__next__cCs|j�|�Sr*r-)r�valuerrrr.=szCoroWrapper.sendcCs|j�|||�Sr*)r�throw)r�typer0�	tracebackrrrr1@szCoroWrapper.throwcCs
|j��Sr*)r�closer+rrrr4CszCoroWrapper.closecCs|jjSr*)r�gi_framer+rrrr5FszCoroWrapper.gi_framecCs|jjSr*)r�
gi_runningr+rrrr6JszCoroWrapper.gi_runningcCs|jjSr*)r�gi_coder+rrrr7NszCoroWrapper.gi_codecCs|Sr*rr+rrr�	__await__RszCoroWrapper.__await__cCs|jjSr*)r�gi_yieldfromr+rrrr9UszCoroWrapper.gi_yieldfromcCs�t|dd�}t|dd�}|dk	r||jdkr||�d�}t|dd�}|rrd�t�|��}|dtj�d	�7}||��7}t�	|�dS)
Nrr5r z was never yielded fromrr�zB
Coroutine object created at (most recent call last, truncated to z last lines):
)
r�f_lasti�joinr3�format_listrZDEBUG_STACK_DEPTH�rstripr	�error)rrr(�msg�tbrrr�__del__Ys
zCoroWrapper.__del__)N)NN)r�
__module__rrr)r,r/r.r1r4�propertyr5r6r7r8r9rBrrrrr$s"





rcsztjdtdd�t���r�St���r.��nt����fdd���t�	���t
sX�}nt�����fdd��}t|_|S)NzN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead�)�
stacklevelc?sr�||�}t�|�s(t�|�s(t|t�r4|EdH}n:z
|j}Wntk
rRYnXt|tj	j
�rn|�EdH}|Sr*)rZisfuture�inspectZisgenerator�
isinstancerr8�AttributeError�collections�abc�	Awaitable)�args�kw�resZ
await_meth�rrr�corozs
�
zcoroutine.<locals>.corocs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)NrPr rr)rrrrr)rM�kwds�w�rQrrr�wrapper�szcoroutine.<locals>.wrapper)�warnings�warn�DeprecationWarningrGr�isgeneratorfunction�	functools�wraps�typesr�_DEBUG�
_is_coroutine)rrUrrTrris"�


rcCst�|�pt|dd�tkS)Nr^)rGrrr^rPrrrr�s
�rcCs@t|�tkrdSt|t�r8tt�dkr4t�t|��dSdSdS)NT�dF)r2�_iscoroutine_typecacherH�_COROUTINE_TYPES�len�add)�objrrrr�s
rc
sht|t���fdd�}dd�}d}t|d�r:|jr:|j}nt|d�rP|jrP|j}||�}|sr||�rn|�d�S|Sd}t|d�r�|jr�|j}nt|d	�r�|jr�|j}|jp�d
}d}��r$|jdk	�r$t	�
|j��s$t�|j�}|dk	r�|\}}|dk�r|�d|�d
|��}	n|�d|�d
|��}	n@|dk	�rJ|j
}|�d|�d
|��}	n|j}|�d|�d
|��}	|	S)Ncs`�rt�|jdi�St|d�r,|jr,|j}n*t|d�rD|jrD|j}ndt|�j�d�}|�d�S)Nrrrr"z without __name__>z())rZ_format_callbackr�hasattrrrr2)rQ�	coro_name�Zis_corowrapperrr�get_name�sz#_format_coroutine.<locals>.get_namecSsHz|jWStk
rBz|jWYStk
r<YYdSXYnXdS)NF)�
cr_runningrIr6)rQrrr�
is_running�sz%_format_coroutine.<locals>.is_running�cr_coder7z runningr5�cr_framez<empty co_filename>rz done, defined at r!z running, defined at z running at )rHrrerkr7r5rl�co_filenamerrGrYrZ_get_function_source�f_lineno�co_firstlineno)
rQrhrjZ	coro_coderfZ
coro_frame�filename�lineno�sourcer'rrgrr%�sJ
	

�
�

r%) �__all__Zcollections.abcrJrZrGrr
r3r\rVr:rrr�logr	rr]rr�objectr^r�
CoroutineType�
GeneratorTyperK�	Coroutinera�setr`rr%rrrr�<module>s2E8�PK
0�\��xxconstants.cpython-38.pycnu�[���U

e5d��@s8dZZZdZZZdZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6d3Z7d4Z8d5Z9d6Z:d7Z;d8Z<d9Z=d:Z>d;Z?d<Z@d=ZAd>ZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIdFZJdGZKdHZLdIS)J���n�s�w�eZnw�sw�neZse�nsZewZnsew�centerZnone�x�yZboth�left�top�rightZbottomZraisedZsunkenZflatZridgeZgrooveZsolidZ
horizontalZverticalZnumeric�charZwordZbaselineZinsideZoutsideZselz	sel.firstzsel.last�end�insertZcurrentZanchor�allZnormalZdisabledZactiveZhiddenZcascadeZcheckbuttonZcommandZradiobuttonZ	separatorZsingleZbrowseZmultipleZextendedZdotboxZ	underlineZpiesliceZchordZarc�firstZlastZbuttZ
projecting�roundZbevelZmiterZmovetoZscrollZunitsZpagesN)MZNOZFALSEZOFFZYESZTRUEZON�N�S�W�EZNWZSWZNEZSEZNSZEWZNSEWZCENTERZNONE�X�YZBOTHZLEFTZTOPZRIGHTZBOTTOMZRAISEDZSUNKENZFLATZRIDGEZGROOVEZSOLIDZ
HORIZONTALZVERTICALZNUMERICZCHARZWORDZBASELINEZINSIDEZOUTSIDEZSELZ	SEL_FIRSTZSEL_LASTZENDZINSERTZCURRENTZANCHORZALLZNORMALZDISABLEDZACTIVEZHIDDENZCASCADEZCHECKBUTTONZCOMMANDZRADIOBUTTONZ	SEPARATORZSINGLEZBROWSEZMULTIPLEZEXTENDEDZDOTBOXZ	UNDERLINEZPIESLICEZCHORDZARCZFIRSTZLASTZBUTTZ
PROJECTINGZROUNDZBEVELZMITERZMOVETOZSCROLLZUNITSZPAGES�rr�)/usr/lib64/python3.8/tkinter/constants.py�<module>s�PK
0�\��+�[�[$proactor_events.cpython-38.opt-2.pycnu�[���U

e5d<}�@sPdZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
dd	lmZdd
lmZddlmZddlmZd
d�ZGdd�dejej�ZGdd�deej�ZGdd�deej�ZGdd�de�ZGdd�de�ZGdd�deeej�ZGdd�deeej�ZGdd�de	j �Z!dS))�BaseProactorEventLoop�N�)�base_events)�	constants)�futures)�
exceptions)�	protocols)�sslproto)�
transports)�trsock)�loggercCs�t�|�|jd<z|��|jd<Wn0tjk
rR|j��rNtj	d|dd�YnXd|jkr�z|�
�|jd<Wn tjk
r�d|jd<YnXdS)N�socketZsocknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extraZgetsocknamer
�error�_loop�	get_debugr�warningZgetpeername)�	transport�sock�r�//usr/lib64/python3.8/asyncio/proactor_events.py�_set_socket_extras
�
rcs~eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jfdd�Zddd�Z
dd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportNcs�t��||�|�|�||_|�|�||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	rl|j�
�|j�|jj|�|dk	r�|j�tj|d�dS)NrF)�super�__init__�
_set_extra�_sock�set_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_eof_writtenZ_attachr�	call_soon�	_protocolZconnection_maderZ_set_result_unless_cancelled��self�loopr�protocol�waiter�extra�server��	__class__rrr2s(




�z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|jdk	rP|�d|j�����|jdk	rl|�d|j���|jdk	r�|�d|j���|jr�|�dt	|j����|j
r�|�d�d�d	�|��S)
N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� )
r4�__name__r �appendr(�filenor$r%r#�lenr)�format�join)r-�inforrr�__repr__Hs 






z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)r�r-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs
||_dS�N�r+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrC�r-rrr�get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr�
is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr
dSd|_|jd7_|js>|jdkr>|j�|jd�|jdk	rX|j��d|_dS)NTr)	r(r'r#r%rr*�_call_connection_lostr$�cancelrDrrr�closefs

z _ProactorBasePipeTransport.closecCs*|jdk	r&|d|��t|d�|��dS)Nzunclosed transport )�source)r �ResourceWarningrI)r-Z_warnrrr�__del__qs
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportc	CsVzDt|t�r*|j��rBtjd||dd�n|j�||||jd��W5|�|�XdS)Nz%r: %sTr)�message�	exceptionrr/)	�_force_close�
isinstance�OSErrorrrr�debug�call_exception_handlerr+)r-�excrNrrr�_fatal_errorvs

�z'_ProactorBasePipeTransport._fatal_errorcCs�|jdk	r6|j��s6|dkr*|j�d�n|j�|�|jr@dSd|_|jd7_|jrj|j��d|_|jr�|j��d|_d|_	d|_
|j�|j
|�dS)NTrr)�
_empty_waiter�done�
set_resultZ
set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrP�s"

z'_ProactorBasePipeTransport._force_closec	Cs^z|j�	|�W5t|jd�r,|j�tj�|j��d|_|j}|dk	rX|��d|_XdS)N�shutdown)
�hasattrr rZr
Z	SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrG�s
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk	r|t|j�7}|SrB)r&r#r;)r-�sizerrr�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8�
__module__�__qualname__rr?rr!rErFrI�warnings�warnrLrVrPrGr]�
__classcell__rrr3rr.s�
rcsPeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zddd�Z	�Z
S)�_ProactorReadPipeTransportNcs:d|_d|_t��||||||�|j�|j�d|_dS)NTF)�
_pending_data�_pausedrrrr*�
_loop_readingr,r3rrr�s
z#_ProactorReadPipeTransport.__init__cCs|jo|jSrB)rer(rDrrr�
is_reading�sz%_ProactorReadPipeTransport.is_readingcCs0|js|jrdSd|_|j��r,t�d|�dS)NTz%r pauses reading)r(rerrrrSrDrrr�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsn|js|jsdSd|_|jdkr0|j�|jd�|j}d|_|dk	rT|j�|j|�|j��rjt	�
d|�dS)NFz%r resumes reading)r(rer$rr*rfrd�_data_receivedrrrS�r-�datarrr�resume_reading�s

z)_ProactorReadPipeTransport.resume_readingc
Cs�|j��rt�d|�z|j��}WnLttfk
r>�Yn4tk
rp}z|�	|d�WY�dSd}~XYnX|s~|�
�dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrrrSr+Zeof_received�
SystemExit�KeyboardInterrupt�
BaseExceptionrVrI)r-Z	keep_openrUrrr�
_eof_received�s
�z(_ProactorReadPipeTransport._eof_receivedc
Cs�|jr||_dS|s |��dSt|jtj�r�zt�|j|�Wq�tt	fk
rZ�Yq�t
k
r�}z|�|d�WY�dSd}~XYq�Xn|j�|�dS)Nz3Fatal error: protocol.buffer_updated() call failed.)
rerdrprQr+rZBufferedProtocolZ_feed_data_to_buffered_protormrnrorVZ
data_received)r-rkrUrrrri�s"�z)_ProactorReadPipeTransport._data_receivedc
Cstd}�zRzp|dk	r2d|_|��r*|��}n|��|jrHd}WW��dS|dkr\WW��dS|jsv|jj�	|j
d�|_Wn�tk
r�}z0|js�|�|d�n|j�
�r�tjddd�W5d}~XYn�tk
r�}z|�|�W5d}~XYnftk
�r}z|�|d�W5d}~XYn8tjk
�r>|j�s:�YnX|j�sV|j�|j�W5|dk	�rn|�|�XdS)N�i�z"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rir$rX�resultrHr(rer�	_proactor�recvr �ConnectionAbortedErrorrVrrrS�ConnectionResetErrorrPrRr�CancelledError�add_done_callbackrf)r-�futrkrUrrrrfs@

�
z(_ProactorReadPipeTransport._loop_reading)NNN)N)r8r^r_rrgrhrlrprirfrbrrr3rrc�s�	rccsZeZdZdZ�fdd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Z�ZS)�_ProactorBaseWritePipeTransportTcst�j||�d|_dSrB)rrrW�r-�args�kwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCs�t|tttf�s$tdt|�j����|jr2td��|j	dk	rDtd��|sLdS|j
rz|j
tjkrht
�d�|j
d7_
dS|jdkr�|jt|�d�n.|js�t|�|_|��n|j�|�|��dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rk)rQ�bytes�	bytearray�
memoryview�	TypeError�typer8r)�RuntimeErrorrWr'r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESrrr%�
_loop_writingr#�_maybe_pause_protocol�extendrjrrr�writeKs,�




z%_ProactorBaseWritePipeTransport.writeNc
CsVz�|dk	r |jdkr |jr WdSd|_d|_|r8|��|dkrL|j}d|_|s�|jrf|j�|jd�|jrz|j	�
tj�|�
�nN|jj�|j	|�|_|j��s�t|�|_|j�|j�|��n|j�|j�|jdk	r�|jdkr�|j�d�Wn\tk
�r"}z|�|�W5d}~XYn0tk
�rP}z|�|d�W5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(r&rrr#rr*rGr)r rZr
�SHUT_WR�_maybe_resume_protocolrs�sendrXr;rxr�r�rWrYrvrPrRrV)r-�frkrUrrrr�qs8



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS�NTrrDrrr�
can_write_eof�sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|��dSrB)rIrDrrr�	write_eof�sz)_ProactorBaseWritePipeTransport.write_eofcCs|�d�dSrB�rPrDrrr�abort�sz%_ProactorBaseWritePipeTransport.abortcCs:|jdk	rtd��|j��|_|jdkr4|j�d�|jS)NzEmpty waiter is already set)rWr�rZ
create_futurer%rYrDrrr�_make_empty_waiter�s

z2_ProactorBaseWritePipeTransport._make_empty_waitercCs
d|_dSrB)rWrDrrr�_reset_empty_waiter�sz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)
r8r^r_Z_start_tls_compatiblerr�r�r�r�r�r�r�rbrrr3rrzAs&
)rzcs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs4t�j||�|jj�|jd�|_|j�|j�dS)N�)	rrrrsrtr r$rx�_pipe_closedr{r3rrr�sz$_ProactorWritePipeTransport.__init__cCs@|��rdS|jrdSd|_|jdk	r4|�t��n|��dSrB)Z	cancelledr(r$r%rP�BrokenPipeErrorrI)r-ryrrrr��s
z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rr�rbrrr3rr��sr�csXeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	ddd�Z
�ZS)�_ProactorDatagramTransportiNcs>||_d|_t�j|||||d�t��|_|j�|j	�dS)N)r0r1)
�_addressrWrr�collections�dequer#rr*rf)r-r.rr/�addressr0r1r3rrr�s

z#_ProactorDatagramTransport.__init__cCst||�dSrB�rrArrrr�sz%_ProactorDatagramTransport._set_extracCstdd�|jD��S)Ncss|]\}}t|�VqdSrB)r;)�.0rk�_rrr�	<genexpr>�szC_ProactorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr#rDrrrr]�sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|�d�dSrBr�rDrrrr��sz _ProactorDatagramTransport.abortcCs�t|tttf�stdt|���|s&dS|jdk	rN|d|jfkrNtd|j����|jr�|jr�|jt	j
krpt�d�|jd7_dS|j
�t|�|f�|jdkr�|��|��dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQr~rr�r�r�r��
ValueErrorr'rr�rrr#r9r%r�r�)r-rk�addrrrr�sendto�s&�
�

z!_ProactorDatagramTransport.sendtoc
Csz�|jrWdSd|_|r |��|jr2|jrN|jrN|jrH|j�|jd�WdS|j�	�\}}|jdk	r||jj
�|j|�|_n|jj
j
|j||d�|_WnZtk
r�}z|j�|�W5d}~XYnDtk
r�}z|�|d�W5d}~XYnX|j�|j�|��dS)N)r�z'Fatal write error on datagram transport)r'r%rrr#r�r(rr*rG�popleftrsr�r r�rRr+�error_received�	ExceptionrVrxr�r�)r-ryrkr�rUrrrr��s2
��z(_ProactorDatagramTransport._loop_writingc
Cs4d}�zz�|jrWW��dSd|_|dk	rf|��}|jrFd}WW��dS|jdk	r^||j}}n|\}}|jrvWW��dS|jdk	r�|jj�	|j
|j�|_n|jj�|j
|j�|_WnJt
k
r�}z|j�|�W5d}~XYn8tjk
r�|js��YnX|jdk	�r|j�|j�W5|�r.|j�||�XdSrB)r+Zdatagram_receivedr'r$rrr(r�rrsrtr �max_sizeZrecvfromrRr�rrwrxrf)r-ryrkr��resrUrrrrfs>



��
z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N)r8r^r_r�rrr]r�r�r�rfrbrrr3rr��s�

!r�c@seZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportcCsdS)NFrrDrrrr�Jsz*_ProactorDuplexPipeTransport.can_write_eofcCst�dSrB)�NotImplementedErrorrDrrrr�Msz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_r�r�rrrrr�Esr�cs>eZdZejjZd
�fdd�	Zdd�Zdd�Z	dd	�Z
�ZS)�_ProactorSocketTransportNcs$t��||||||�t�|�dSrB)rrrZ_set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||�dSrBr�rArrrr]sz#_ProactorSocketTransport._set_extracCsdSr�rrDrrrr�`sz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdkr.|j�tj�dSr�)r(r)r%r rZr
r�rDrrrr�cs

z"_ProactorSocketTransport.write_eof)NNN)r8r^r_rZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerrr�r�rbrrr3rr�Qs�r�cs�eZdZ�fdd�Zd3dd�Zd4dddddd�dd	�Zd5d
d�Zd6dd
�Zd7dd�Zd8dd�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd9d&d'�Zd(d)�Zd:d+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS);rcsht���t�d|jj�||_||_d|_i|_	|�
|�|��t�
�t��krdt�|j���dS)NzUsing proactor: %s)rrrrSr4r8rs�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe�	threading�current_thread�main_thread�signal�
set_wakeup_fd�_csockr:)r-Zproactorr3rrrms

zBaseProactorEventLoop.__init__NcCst||||||�SrB)r�)r-rr/r0r1r2rrr�_make_socket_transportzs
�z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer1r2�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r��r1r2)r	ZSSLProtocolr�Z_app_transport)r-Zrawsockr/�
sslcontextr0r�r�r1r2r�Zssl_protocolrrr�_make_ssl_transports��z)BaseProactorEventLoop._make_ssl_transportcCst||||||�SrB)r�)r-rr/r�r0r1rrr�_make_datagram_transport�s
�z.BaseProactorEventLoop._make_datagram_transportcCst|||||�SrB)r��r-rr/r0r1rrr�_make_duplex_pipe_transport�s�z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�SrB)rcr�rrr�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�SrB)r�r�rrr�_make_write_pipe_transport�s�z0BaseProactorEventLoop._make_write_pipe_transportcsj|��rtd��|��rdSt��t��kr6t�d�|��|�	�|j
��d|_
d|_t
���dS)Nz!Cannot close a running event loop���)Z
is_runningr��	is_closedr�r�r�r�r��_stop_accept_futures�_close_self_pipersrIr�rrDr3rrrI�s

zBaseProactorEventLoop.closec�s|j�||�IdHSrB)rsrt)r-r�nrrr�	sock_recv�szBaseProactorEventLoop.sock_recvc�s|j�||�IdHSrB)rsZ	recv_into)r-rZbufrrr�sock_recv_into�sz$BaseProactorEventLoop.sock_recv_intoc�s|j�||�IdHSrB)rsr�)r-rrkrrr�sock_sendall�sz"BaseProactorEventLoop.sock_sendallc�s|j�||�IdHSrB)rsZconnect)r-rr�rrr�sock_connect�sz"BaseProactorEventLoop.sock_connectc�s|j�|�IdHSrB)rs�acceptrArrr�sock_accept�sz!BaseProactorEventLoop.sock_acceptc
�s(z|��}Wn2ttjfk
r>}zt�d��W5d}~XYnXzt�|�j}Wn,t	k
r|}zt�d��W5d}~XYnX|r�|n|}|s�dSt
|d�}|r�t
|||�n|}	t
||�}d}
zLt
|	||�}|dkr�|
W�0S|j�
||||�IdH||7}|
|7}
q�W5|
dk�r"|�|�XdS)Nznot a regular filerl��)r:�AttributeError�io�UnsupportedOperationrZSendfileNotAvailableError�os�fstat�st_sizerR�min�seekrs�sendfile)r-r�file�offset�countr:�errZfsizeZ	blocksizeZend_posZ
total_sentrrr�_sock_sendfile_native�s0


z+BaseProactorEventLoop._sock_sendfile_nativec�sZ|��}|��|��IdHz |j|j|||dd�IdHW�S|��|rT|��XdS)NF)Zfallback)rgrhr�r�rlZ
sock_sendfiler )r-Ztranspr�r�r�rlrrr�_sendfile_native�s�z&BaseProactorEventLoop._sendfile_nativecCsL|jdk	r|j��d|_|j��d|_|j��d|_|jd8_dS)Nr)r�rH�_ssockrIr��
_internal_fdsrDrrrr��s



z&BaseProactorEventLoop._close_self_pipecCs:t��\|_|_|j�d�|j�d�|jd7_dS)NFr)r
Z
socketpairr�r�Zsetblockingr�rDrrrr��sz%BaseProactorEventLoop._make_self_pipec
Cs�z4|dk	r|��|j|k	r"WdS|j�|jd�}Wnbtjk
rLYdSttfk
rd�YnFt	k
r�}z|�
d||d��W5d}~XYnX||_|�|j�dS)Niz.Error on reading from the event loop self pipe)rNrOr.)
rrr�rsrtr�rrwrmrnrorTrx�_loop_self_reading)r-r�rUrrrr��s$
�z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|�d�Wn(tk
rH|jrDtjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketTr)r�r�rR�_debugrrS)r-Zcsockrrr�_write_to_selfs�z$BaseProactorEventLoop._write_to_self�dcs(d�������fdd�	�����dS)Nc
s,z�|dk	rn|��\}}�jr,t�d�||���}�dk	rX�j||�dd|i��d�n�j||d|i�d����r|WdS�j���}Wn�t	k
r�}zH��
�dkrʈ�d|t�
��d�����n�jr�tjd	�dd
�W5d}~XYn8tjk
�r���YnX|�j��
�<|���dS)Nz#%r got a new connection from %r: %rTr)r�r1r2r�r�r�zAccept failed on a socket)rNrOr
zAccept failed on socket %rr)rrr�rrSr�r�r�rsr�rRr:rTrrrIrrwr�rx)r�Zconnr�r/rU�r.�protocol_factoryr-r2rr�r�rrr./s\����
�z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r*)r-r�rr�r2Zbacklogr�rr�r�_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z
event_listrrr�_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|j��D]}|��q
|j��dSrB)r��valuesrH�clear)r-�futurerrrr�Zs
z*BaseProactorEventLoop._stop_accept_futurescCs6|j�|��d�}|r|��|j�|�|��dSrB)r��popr:rHrs�
_stop_servingrI)r-rr�rrrr�_s
z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNr�N)r8r^r_rr�r�r�r�r�r�rIr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rbrrr3rrks\
�
���
�
�
�


�
+r)"�__all__r�r�r
r`r�r�r��rrrrrr	r
r�logrrZ_FlowControlMixinZ
BaseTransportrZ
ReadTransportrcZWriteTransportrzr�r�Z	Transportr�r�Z
BaseEventLooprrrrr�<module>sP���n��PK
0�\��,�staggered.cpython-38.opt-2.pycnu�[���U

e5dh�
@s�dZddlZddlZddlmZddlmZddlmZddlmZdd�ej	ej
gejfeje
ejejejejeejejefd	�d
d�ZdS))�staggered_race�N�)�events)�
exceptions)�locks)�tasks)�loop)�coro_fns�delayr�returnc	�s��p
t���t|��d�d�g�g�tjtjdd���������fdd�����d��}��|�z<d}|t
��kr�t���IdH\}}t
|�}ql���fW�S�D]}|�	�q�XdS)N)�previous_failedrc	
�s|dk	r6t�tj��t�|����IdHW5QRXzt��\}}Wntk
r\YdSXt	�
�}���|��}��|���d�z|�IdH}WnJt
tfk
r��Yn\tk
r�}z|�|<|��W5d}~XYn,X|�|�t��D]\}}||kr�|��q�dS)N)�
contextlib�suppress�exceptions_mod�TimeoutErrorrZwait_for�wait�next�
StopIterationr�Event�create_task�append�
SystemExit�KeyboardInterrupt�
BaseException�set�	enumerate�cancel)	rZ
this_indexZcoro_fnZthis_failedZ	next_task�result�e�i�t�r
Z
enum_coro_fnsrr�run_one_coroZ
running_tasksZwinner_indexZ
winner_result��)/usr/lib64/python3.8/asyncio/staggered.pyr"Rs. 

z$staggered_race.<locals>.run_one_coror)
rZget_running_loopr�typing�Optionalrrrrr�lenrr)r	r
rZ
first_taskr Z
done_countZdone�_r#r!r$rs(=
�0
r)�__all__r
r%�rrrrr�Iterable�Callable�	Awaitabler&�floatZAbstractEventLoopZTupleZAny�intZList�	Exceptionrr#r#r#r$�<module>s$����PK
0�\�m���8�8streams.cpython-38.opt-2.pycnu�[���U

e5d h�@s&dZddlZddlZddlZddlZeed�r6ed7ZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZd
Zdded�dd�Zd ded�dd�Zeed�r�d!ded�dd�Zd"ded�dd�ZGdd�dej�ZGdd�deej�ZGdd�d�ZGdd�d�ZdS)#)�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�NZAF_UNIX)�open_unix_connection�start_unix_server�)�
coroutines)�events)�
exceptions)�format_helpers)�	protocols)�logger)�sleepi)�loop�limitc	�st|dkrt��}ntjdtdd�t||d�}t||d��|j�fdd�||f|�IdH\}}t|�||�}||fS)N�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.���
stacklevel�rr�rcs�S�N�r��protocolr�'/usr/lib64/python3.8/asyncio/streams.py�<lambda>5�z!open_connection.<locals>.<lambda>)	r�get_event_loop�warnings�warn�DeprecationWarningrrZcreate_connectionr)	�host�portrr�kwds�reader�	transport�_�writerrrrrs"
�
��rc�sJ�dkrt���ntjdtdd����fdd�}�j|||f|�IdHS)Nrrrcst��d�}t|��d�}|S�Nrr�rr�r'r��client_connected_cbrrrr�factoryXs
�zstart_server.<locals>.factory)rr r!r"r#Z
create_server)r/r$r%rrr&r0rr.rr:s
�rc�sr|dkrt��}ntjdtdd�t||d�}t||d��|j�fdd�|f|�IdH\}}t|�||�}||fS)Nrrrrrcs�Srrrrrrrprz&open_unix_connection.<locals>.<lambda>)	rr r!r"r#rrZcreate_unix_connectionr)�pathrrr&r'r(r)r*rrrrds 
�
��rc�sH�dkrt���ntjdtdd����fdd�}�j||f|�IdHS)Nrrrcst��d�}t|��d�}|Sr+r,r-r.rrr0~s
�z"start_unix_server.<locals>.factory)rr r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts
�rc@s>eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�FlowControlMixinNcCs0|dkrt��|_n||_d|_d|_d|_dS�NF)rr �_loop�_paused�
_drain_waiter�_connection_lost)�selfrrrr�__init__�szFlowControlMixin.__init__cCs d|_|j��rt�d|�dS)NTz%r pauses writing)r5r4�	get_debugr�debug�r8rrr�
pause_writing�s
zFlowControlMixin.pause_writingcCsFd|_|j��rt�d|�|j}|dk	rBd|_|��sB|�d�dS)NFz%r resumes writing)r5r4r:rr;r6�done�
set_result�r8�waiterrrr�resume_writing�s
zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|��r4dS|dkrH|�d�n
|�|�dS�NT)r7r5r6r>r?�
set_exception�r8�excrArrr�connection_lost�sz FlowControlMixin.connection_lostc�s<|jrtd��|jsdS|j}|j��}||_|IdHdS)NzConnection lost)r7�ConnectionResetErrorr5r6r4�
create_futurer@rrr�
_drain_helper�s
zFlowControlMixin._drain_helpercCst�dSr)�NotImplementedError�r8�streamrrr�_get_close_waiter�sz"FlowControlMixin._get_close_waiter)N)	�__name__�
__module__�__qualname__r9r=rBrGrJrNrrrrr2�s

	r2csbeZdZdZd�fdd�	Zedd��Zdd�Z�fdd	�Zd
d�Z	dd
�Z
dd�Zdd�Z�Z
S)rNcsnt�j|d�|dk	r,t�|�|_|j|_nd|_|dk	r@||_d|_d|_d|_	||_
d|_|j�
�|_dS)NrF)�superr9�weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer�
_transport�_client_connected_cb�	_over_sslr4rI�_closed)r8Z
stream_readerr/r��	__class__rrr9�s
zStreamReaderProtocol.__init__cCs|jdkrdS|��Sr)rUr<rrr�_stream_reader�s
z#StreamReaderProtocol._stream_readercCs�|jr6ddi}|jr|j|d<|j�|�|��dS||_|j}|dk	rT|�|�|�d�dk	|_	|j
dk	r�t||||j�|_|�
||j�}t
�|�r�|j�|�d|_dS)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ
sslcontext)rXrVr4Zcall_exception_handler�abortrZr`�
set_transport�get_extra_infor\r[rrYr
ZiscoroutineZcreate_taskrW)r8r(�contextr'�resrrr�connection_made�s2�


��
z$StreamReaderProtocol.connection_madecsx|j}|dk	r*|dkr |��n
|�|�|j��sV|dkrJ|j�d�n|j�|�t��|�d|_d|_	d|_
dSr)r`�feed_eofrDr]r>r?rRrGrUrYrZ)r8rFr'r^rrrG
s


z$StreamReaderProtocol.connection_lostcCs|j}|dk	r|�|�dSr)r`�	feed_data)r8�datar'rrr�
data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk	r|��|jr dSdS)NFT)r`rhr\)r8r'rrr�eof_received sz!StreamReaderProtocol.eof_receivedcCs|jSr)r]rLrrrrN+sz&StreamReaderProtocol._get_close_waitercCs"|j}|��r|��s|��dSr)r]r>�	cancelled�	exception)r8�closedrrr�__del__.szStreamReaderProtocol.__del__)NN)rOrPrQrVr9�propertyr`rgrGrkrlrNrp�
__classcell__rrr^rr�s	
rc@sreZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ddd�Zdd�ZdS)rcCs4||_||_||_||_|j��|_|j�d�dSr)rZ�	_protocol�_readerr4rIZ
_complete_futr?)r8r(rr'rrrrr9@szStreamWriter.__init__cCs@|jjd|j��g}|jdk	r0|�d|j���d�d�|��S)N�
transport=zreader=�<{}>� )r_rOrZrt�append�format�join�r8�inforrr�__repr__Js
zStreamWriter.__repr__cCs|jSr�rZr<rrrr(PszStreamWriter.transportcCs|j�|�dSr)rZ�write�r8rjrrrrTszStreamWriter.writecCs|j�|�dSr)rZ�
writelinesr�rrrr�WszStreamWriter.writelinescCs
|j��Sr)rZ�	write_eofr<rrrr�ZszStreamWriter.write_eofcCs
|j��Sr)rZ�
can_write_eofr<rrrr�]szStreamWriter.can_write_eofcCs
|j��Sr)rZ�closer<rrrr�`szStreamWriter.closecCs
|j��Sr)rZ�
is_closingr<rrrr�cszStreamWriter.is_closingc�s|j�|�IdHdSr)rsrNr<rrr�wait_closedfszStreamWriter.wait_closedNcCs|j�||�Sr)rZrd)r8�name�defaultrrrrdiszStreamWriter.get_extra_infoc�sL|jdk	r |j��}|dk	r |�|j��r8td�IdH|j��IdHdS)Nr)rtrnrZr�rrsrJ)r8rFrrr�drainls



zStreamWriter.drain)N)rOrPrQr9r}rqr(rr�r�r�r�r�r�rdr�rrrrr6s



rc@s�eZdZdZedfdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd&dd�Zd'dd�Zd d!�Zd"d#�Zd$d%�ZdS)(rNcCsv|dkrtd��||_|dkr*t��|_n||_t�|_d|_d|_d|_	d|_
d|_|j��rrt
�t�d��|_dS)NrzLimit cannot be <= 0Fr	)�
ValueError�_limitrr r4�	bytearray�_buffer�_eof�_waiter�
_exceptionrZr5r:r
�
extract_stack�sys�	_getframerV)r8rrrrrr9�s 
�zStreamReader.__init__cCs�dg}|jr"|�t|j��d��|jr2|�d�|jtkrN|�d|j���|jrf|�d|j���|jr~|�d|j���|jr�|�d|j���|j	r�|�d�d	�
d
�|��S)Nrz bytes�eofzlimit=zwaiter=z
exception=ruZpausedrvrw)r�rx�lenr�r��_DEFAULT_LIMITr�r�rZr5ryrzr{rrrr}�s 


zStreamReader.__repr__cCs|jSr)r�r<rrrrn�szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|��s,|�|�dSr)r�r�rmrDrErrrrD�szStreamReader.set_exceptioncCs*|j}|dk	r&d|_|��s&|�d�dSr)r�rmr?r@rrr�_wakeup_waiter�s
zStreamReader._wakeup_waitercCs
||_dSrr~)r8r(rrrrc�szStreamReader.set_transportcCs*|jr&t|j�|jkr&d|_|j��dSr3)r5r�r�r�rZ�resume_readingr<rrr�_maybe_resume_transport�sz$StreamReader._maybe_resume_transportcCsd|_|��dSrC)r�r�r<rrrrh�szStreamReader.feed_eofcCs|jo|jSr)r�r�r<rrr�at_eof�szStreamReader.at_eofcCst|sdS|j�|�|��|jdk	rp|jspt|j�d|jkrpz|j��Wntk
rhd|_YnXd|_dS)NrT)	r��extendr�rZr5r�r�Z
pause_readingrKr�rrrri�s
��zStreamReader.feed_datac�sX|jdk	rt|�d���|jr.d|_|j��|j��|_z|jIdHW5d|_XdS)NzF() called while another coroutine is already waiting for incoming dataF)r��RuntimeErrorr5rZr�r4rI)r8Z	func_namerrr�_wait_for_data�s	
�
zStreamReader._wait_for_datac
�s�d}t|�}z|�|�IdH}Wn�tjk
rN}z|jWY�Sd}~XYnhtjk
r�}zH|j�||j�r�|jd|j|�=n
|j�	�|�
�t|jd��W5d}~XYnX|S)N�
r)
r��	readuntilr�IncompleteReadError�partial�LimitOverrunErrorr��
startswith�consumed�clearr�r��args)r8�sep�seplen�line�errr�readline	s
 zStreamReader.readliner�c�s�t|�}|dkrtd��|jdk	r(|j�d}t|j�}|||kr||j�||�}|dkrZq�|d|}||jkr|t�d|��|jr�t	|j�}|j�
�t�|d��|�d�IdHq,||jkr�t�d|��|jd||�}|jd||�=|�
�t	|�S)Nrz,Separator should be at least one-byte string���r	z2Separator is not found, and chunk exceed the limitr�z2Separator is found, but chunk is longer than limit)r�r�r�r��findr�rr�r��bytesr�r�r�r�)r8Z	separatorr��offsetZbuflenZisep�chunkrrrr�(s>


�


�zStreamReader.readuntilr�c�s�|jdk	r|j�|dkrdS|dkrVg}|�|j�IdH}|s@qL|�|�q(d�|�S|jsr|jsr|�d�IdHt|jd|��}|jd|�=|�	�|S)Nrr�read)
r�r�r�rxrzr�r�r�r�r�)r8�nZblocks�blockrjrrrr��s"

zStreamReader.readc�s�|dkrtd��|jdk	r |j�|dkr,dSt|j�|krr|jr`t|j�}|j��t�||��|�	d�IdHq,t|j�|kr�t|j�}|j��nt|jd|��}|jd|�=|�
�|S)Nrz*readexactly size can not be less than zeror�readexactly)r�r�r�r�r�r�r�rr�r�r�)r8r�Z
incompleterjrrrr��s&



zStreamReader.readexactlycCs|Srrr<rrr�	__aiter__�szStreamReader.__aiter__c�s|��IdH}|dkrt�|S)Nr)r��StopAsyncIteration)r8�valrrr�	__anext__�szStreamReader.__anext__)r�)r�)rOrPrQrVr�r9r}rnrDr�rcr�rhr�rir�r�r�r�r�r�r�rrrrr�s$	
[
2)r)NN)NN)N)N)�__all__Zsocketr�r!rS�hasattr�r
rrr
r�logrZtasksrr�rrrrZProtocolr2rrrrrrr�<module>sF
�!�'
��DkPPK
0�\���b�s�sselector_events.cpython-38.pycnu�[���U

e5dT��@s.dZdZddlZddlZddlZddlZddlZddlZddlZzddl	Z	Wne
k
rddZ	YnXddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZdd�Zdd�ZGdd�dej�ZGdd�dejej�ZGdd�de�ZGdd�de�ZdS)z�Event loop using a selector and related classes.

A selector is a "notify-when-ready" multiplexer.  For a subclass which
also includes support for signal handling, see the unix_events sub-module.
)�BaseSelectorEventLoop�N�)�base_events)�	constants)�events)�futures)�	protocols)�sslproto)�
transports)�trsock)�loggercCs8z|�|�}Wntk
r$YdSXt|j|@�SdS�NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�//usr/lib64/python3.8/asyncio/selector_events.py�_test_selector_event s
rcCs tdk	rt|tj�rtd��dS)Nz"Socket cannot be of type SSLSocket)�ssl�
isinstanceZ	SSLSocket�	TypeError)�sockrrr�_check_ssl_socket+srcs�eZdZdZdS�fdd�	ZdTddd�dd�ZdUddddejd	�d
d�ZdVdd
�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdddejfdd�Zdddejfdd�Zddejfdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+�Z,S)WrzJSelector event loop.

    See events.EventLoop for API specification.
    NcsFt���|dkrt��}t�d|jj�||_|�	�t
��|_dS)NzUsing selector: %s)
�super�__init__�	selectorsZDefaultSelectorr�debug�	__class__�__name__�	_selector�_make_self_pipe�weakrefZWeakValueDictionary�_transports)�selfr�r rrr6s
zBaseSelectorEventLoop.__init__��extra�servercCst||||||�S�N)�_SelectorSocketTransport)r&r�protocol�waiterr)r*rrr�_make_socket_transport@s
�z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer)r*�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r2r()r	ZSSLProtocolr,Z_app_transport)r&Zrawsockr-�
sslcontextr.r0r1r)r*r2Zssl_protocolrrr�_make_ssl_transportEs��z)BaseSelectorEventLoop._make_ssl_transportcCst||||||�Sr+)�_SelectorDatagramTransport)r&rr-�addressr.r)rrr�_make_datagram_transportRs
�z.BaseSelectorEventLoop._make_datagram_transportcsL|��rtd��|��rdS|��t���|jdk	rH|j��d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer"�r&r'rrr;Ws


zBaseSelectorEventLoop.closecCsB|�|j���|j��d|_|j��d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor;�_csock�
_internal_fdsr<rrrr:bs

z&BaseSelectorEventLoop._close_self_pipecCsNt��\|_|_|j�d�|j�d�|jd7_|�|j��|j�dS)NFr)	�socketZ
socketpairr>r@�setblockingrA�_add_readerr?�_read_from_selfr<rrrr#js
z%BaseSelectorEventLoop._make_self_pipecCsdSr+r�r&�datarrr�_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|j�d�}|sWqT|�|�Wqtk
r:YqYqtk
rPYqTYqXqdS)Ni)r>�recvrH�InterruptedError�BlockingIOErrorrFrrrrEusz%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|�d�Wn(tk
rH|jrDtjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketT��exc_info)r@�send�OSError�_debugrr)r&Zcsockrrr�_write_to_self�s�z$BaseSelectorEventLoop._write_to_self�dc
Cs"|�|��|j||||||�dSr+)rDr?�_accept_connection)r&�protocol_factoryrr3r*�backlogr2rrr�_start_serving�s�z$BaseSelectorEventLoop._start_servingc
Cst|�D]�}z0|��\}}	|jr0t�d||	|�|�d�Wn�tttfk
rZYdSt	k
r�}
zd|
j
t
jt
jt
j
t
jfkr�|�d|
t�|�d��|�|���|�tj|j||||||�n�W5d}
~
XYqXd|	i}|�||||||�}|�|�qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exceptionrB�peername)�range�acceptrQrrrCrKrJ�ConnectionAbortedErrorrP�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr�TransportSocketr=r?Z
call_laterrZACCEPT_RETRY_DELAYrW�_accept_connection2Zcreate_task)
r&rUrr3r*rVr2�_�conn�addr�excr)r\rrrrT�sV�����z(BaseSelectorEventLoop._accept_connectionc
�s�d}d}zt|�}|��}	|r8|j||||	d|||d�}n|j|||	||d�}z|	IdHWntk
rx|���YnXWntttfk
r��Yn\tk
r�}
z>|jr�d|
d�}|dk	r�||d<|dk	r�||d<|�|�W5d}
~
XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr-�	transport)	�
create_futurer4r/�
BaseExceptionr;�
SystemExit�KeyboardInterruptrQr_)r&rUrcr)r3r*r2r-rfr.re�contextrrrra�sP���z)BaseSelectorEventLoop._accept_connection2c
Cs�|}t|t�sJzt|���}Wn*tttfk
rHtd|���d�YnXz|j|}Wntk
rlYnX|��s�t	d|�d|����dS)NzInvalid file object: zFile descriptor z is used by transport )
r�intr?�AttributeErrorr�
ValueErrorr%r�
is_closingr8)r&rr?rfrrr�_ensure_fd_no_transport�s
�z-BaseSelectorEventLoop._ensure_fd_no_transportc		Gs�|��t�|||d�}z|j�|�}Wn*tk
rR|j�|tj|df�Yn>X|j|j	}\}}|j�
||tjB||f�|dk	r�|��dSr+)�
_check_closedr�Handler"rr�registerr�
EVENT_READrG�modify�cancel�	r&r�callback�argsZhandler�mask�reader�writerrrrrDs�
�z!BaseSelectorEventLoop._add_readercCs�|��rdSz|j�|�}Wntk
r2YdSX|j|j}\}}|tjM}|sd|j�|�n|j�	||d|f�|dk	r�|�
�dSdSdS�NFT)r9r"rrrrGrrt�
unregisterrurv�r&rrrzr{r|rrrr=sz$BaseSelectorEventLoop._remove_readerc		Gs�|��t�|||d�}z|j�|�}Wn*tk
rR|j�|tjd|f�Yn>X|j|j	}\}}|j�
||tjB||f�|dk	r�|��dSr+)rqrrrr"rrrsr�EVENT_WRITErGrurvrwrrr�_add_writer%s�
�z!BaseSelectorEventLoop._add_writercCs�|��rdSz|j�|�}Wntk
r2YdSX|j|j}\}}|tjM}|sd|j�|�n|j�	|||df�|dk	r�|�
�dSdSdS)�Remove a writer callback.FNT)r9r"rrrrGrr�r~rurvrrrr�_remove_writer4sz$BaseSelectorEventLoop._remove_writercGs|�|�|j||f|��S)zAdd a reader callback.)rprD�r&rrxryrrr�
add_readerKs
z BaseSelectorEventLoop.add_readercCs|�|�|�|�S)zRemove a reader callback.)rpr=�r&rrrr�
remove_readerPs
z#BaseSelectorEventLoop.remove_readercGs|�|�|j||f|��S)zAdd a writer callback..)rpr�r�rrr�
add_writerUs
z BaseSelectorEventLoop.add_writercCs|�|�|�|�S)r�)rpr�r�rrr�
remove_writerZs
z#BaseSelectorEventLoop.remove_writerc	�s�t|�|jr"|��dkr"td��z|�|�WSttfk
rFYnX|��}|��}|�	||j
|||�|�t�
|j|��|IdHS)z�Receive data from the socket.

        The return value is a bytes object representing the data received.
        The maximum amount of data to be received at once is specified by
        nbytes.
        r�the socket must be non-blockingN)rrQ�
gettimeoutrnrIrKrJrgr?r��
_sock_recv�add_done_callback�	functools�partial�_sock_read_done)r&r�n�futrrrr�	sock_recv_s�zBaseSelectorEventLoop.sock_recvcCs|�|�dSr+)r��r&rr�rrrr�tsz%BaseSelectorEventLoop._sock_read_donec
Cs�|��rdSz|�|�}Wn\ttfk
r4YdSttfk
rL�Yn6tk
rv}z|�|�W5d}~XYnX|�|�dSr+)	�donerIrKrJrirjrh�
set_exception�
set_result)r&r�rr�rGrerrrr�wsz BaseSelectorEventLoop._sock_recvc	�s�t|�|jr"|��dkr"td��z|�|�WSttfk
rFYnX|��}|��}|�	||j
|||�|�t�
|j|��|IdHS)z�Receive data from the socket.

        The received data is written into *buf* (a writable buffer).
        The return value is the number of bytes written.
        rr�N)rrQr�rn�	recv_intorKrJrgr?r��_sock_recv_intor�r�r�r�)r&r�bufr�rrrr�sock_recv_into�s�z$BaseSelectorEventLoop.sock_recv_intoc
Cs�|��rdSz|�|�}Wn\ttfk
r4YdSttfk
rL�Yn6tk
rv}z|�|�W5d}~XYnX|�|�dSr+)	r�r�rKrJrirjrhr�r�)r&r�rr��nbytesrerrrr��sz%BaseSelectorEventLoop._sock_recv_intoc	�s�t|�|jr"|��dkr"td��z|�|�}Wnttfk
rLd}YnX|t|�kr^dS|��}|�	�}|�
t�|j
|��|�||j||t|�|g�|IdHS)a�Send data to the socket.

        The socket must be connected to a remote socket. This method continues
        to send data from data until either all data has been sent or an
        error occurs. None is returned on success. On error, an exception is
        raised, and there is no way to determine how much data, if any, was
        successfully processed by the receiving end of the connection.
        rr�N)rrQr�rnrOrKrJ�lenrgr?r�r�r��_sock_write_doner��
_sock_sendall�
memoryview)r&rrGr�r�rrrr�sock_sendall�s&	
��z"BaseSelectorEventLoop.sock_sendallc
Cs�|��rdS|d}z|�||d��}Wnbttfk
rDYdSttfk
r\�Yn2tk
r�}z|�|�WY�dSd}~XYnX||7}|t|�kr�|�	d�n||d<dS)Nr)
r�rOrKrJrirjrhr�r�r�)r&r�rZview�pos�startr�rerrrr��s 
z#BaseSelectorEventLoop._sock_sendallc�s�t|�|jr"|��dkr"td��ttd�r8|jtjkrf|j||j|j	|d�IdH}|d\}}}}}|�
�}|�|||�|IdHS)zTConnect to a remote socket at address.

        This method is a coroutine.
        rr��AF_UNIX)�family�proto�loopN)rrQr�rn�hasattrrBr�r�Z_ensure_resolvedr�rg�
_sock_connect)r&rr6Zresolvedrbr�rrr�sock_connect�s�z"BaseSelectorEventLoop.sock_connectc
Cs�|��}z|�|�Wn�ttfk
rV|�t�|j|��|�||j	|||�YnNt
tfk
rn�Yn6tk
r�}z|�
|�W5d}~XYnX|�d�dSr+)r?ZconnectrKrJr�r�r�r�r��_sock_connect_cbrirjrhr�r�)r&r�rr6rrerrrr��s�z#BaseSelectorEventLoop._sock_connectcCs|�|�dSr+)r�r�rrrr�sz&BaseSelectorEventLoop._sock_write_donec
Cs�|��rdSz,|�tjtj�}|dkr6t|d|����WnZttfk
rPYnNtt	fk
rh�Yn6t
k
r�}z|�|�W5d}~XYnX|�d�dS)NrzConnect call failed )
r�Z
getsockoptrBZ
SOL_SOCKETZSO_ERRORrPrKrJrirjrhr�r�)r&r�rr6�errrerrrr�sz&BaseSelectorEventLoop._sock_connect_cbc�sBt|�|jr"|��dkr"td��|��}|�|d|�|IdHS)aWAccept a connection.

        The socket must be bound to an address and listening for connections.
        The return value is a pair (conn, address) where conn is a new socket
        object usable to send and receive data on the connection, and address
        is the address bound to the socket on the other end of the connection.
        rr�FN)rrQr�rnrg�_sock_accept)r&rr�rrr�sock_acceptsz!BaseSelectorEventLoop.sock_acceptc
Cs�|��}|r|�|�|��r"dSz|��\}}|�d�Wnnttfk
rh|�||j|d|�YnRt	t
fk
r��Yn:tk
r�}z|�|�W5d}~XYnX|�
||f�dSr})r?r�r�r\rCrKrJr�r�rirjrhr�r�)r&r�Z
registeredrrrcr6rerrrr�*s
z"BaseSelectorEventLoop._sock_acceptc	�sp|j|j=|��}|��|��IdHz |j|j|||dd�IdHW�S|��|r^|��||j|j<XdS)NF)Zfallback)	r%�_sock_fd�
is_reading�
pause_reading�_make_empty_waiter�_reset_empty_waiter�resume_readingZ
sock_sendfile�_sock)r&Ztransp�file�offset�countr�rrr�_sendfile_native<s
�z&BaseSelectorEventLoop._sendfile_nativecCs�|D]v\}}|j|j}\}}|tj@rL|dk	rL|jrB|�|�n
|�|�|tj@r|dk	r|jrp|�|�q|�|�qdSr+)	�fileobjrGrrtZ
_cancelledr=Z
_add_callbackr�r�)r&Z
event_listrrzr�r{r|rrr�_process_eventsJs
z%BaseSelectorEventLoop._process_eventscCs|�|���|��dSr+)r=r?r;)r&rrrr�
_stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)-r!�
__module__�__qualname__�__doc__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr'rr0s~
����
�
	�
.�
)rcs�eZdZdZeZdZd�fdd�	Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
ejfdd�Zddd�Zdd�Zdd�Zdd�Zdd�Z�ZS) �_SelectorTransportiNcs�t��||�t�|�|jd<z|��|jd<Wntk
rNd|jd<YnXd|jkr�z|��|jd<Wn tj	k
r�d|jd<YnX||_
|��|_d|_
|�|�||_|��|_d|_d|_|jdk	r�|j��||j|j<dS)NrBZsocknamerZFr)rrrr`�_extraZgetsocknamerPZgetpeernamerB�errorr�r?r��_protocol_connected�set_protocol�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr%)r&r�rr-r)r*r'rrris,





z_SelectorTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���|jdk	r�|j��s�t|jj	|jt
j�}|rz|�d�n
|�d�t|jj	|jt
j�}|r�d}nd}|�
�}|�d|�d	|�d
��d�d�|��S)
N�closed�closingzfd=zread=pollingz	read=idle�pollingZidlezwrite=<z
, bufsize=�>z<{}>� )r r!r��appendr�r��_loopr9rr"rrtr��get_write_buffer_size�format�join)r&�infor��state�bufsizerrr�__repr__�s0


�
�z_SelectorTransport.__repr__cCs|�d�dSr+)�_force_closer<rrr�abort�sz_SelectorTransport.abortcCs||_d|_dS�NT)�	_protocolr��r&r-rrrr��sz_SelectorTransport.set_protocolcCs|jSr+)r�r<rrr�get_protocol�sz_SelectorTransport.get_protocolcCs|jSr+)r�r<rrrro�sz_SelectorTransport.is_closingcCsT|jr
dSd|_|j�|j�|jsP|jd7_|j�|j�|j�|jd�dS�NTr)	r�r�r=r�r�r�r��	call_soon�_call_connection_lostr<rrrr;�sz_SelectorTransport.closecCs,|jdk	r(|d|��t|d�|j��dS)Nzunclosed transport )�source)r��ResourceWarningr;)r&Z_warnrrr�__del__�s
z_SelectorTransport.__del__�Fatal error on transportcCsNt|t�r(|j��r@tjd||dd�n|j�||||jd��|�|�dS)Nz%r: %sTrM)rXrYrfr-)	rrPr��	get_debugrrr_r�r�)r&rerXrrr�_fatal_error�s

�z_SelectorTransport._fatal_errorcCsd|jr
dS|jr(|j��|j�|j�|jsBd|_|j�|j�|jd7_|j�|j	|�dSr�)
r�r��clearr�r�r�r�r=r�r��r&rerrrr��s
z_SelectorTransport._force_closecCsVz|jr|j�|�W5|j��d|_d|_d|_|j}|dk	rP|��d|_XdSr+)r�r;r�r�r�Z_detachr�Zconnection_lost)r&rer*rrrr��s
z(_SelectorTransport._call_connection_lostcCs
t|j�Sr+)r�r�r<rrrr��sz(_SelectorTransport.get_write_buffer_sizecGs"|jr
dS|jj||f|��dSr+)r�r�rDr�rrrrD�sz_SelectorTransport._add_reader)NN)r�)r!r�r��max_size�	bytearrayr�r�rr�r�r�r�ror;�warnings�warnr�r�r�r�r�rDr�rrr'rr�]s 

r�cs�eZdZdZejjZd#�fdd�	Z�fdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�fdd�Zdd �Zd!d"�Z�ZS)$r,TNcs~d|_t��|||||�d|_d|_d|_t�|j�|j	�
|jj|�|j	�
|j
|j|j�|dk	rz|j	�
tj|d�dSr
)�_read_ready_cbrr�_eof�_paused�
_empty_waiterrZ_set_nodelayr�r�r�r��connection_maderDr��_read_readyr�_set_result_unless_cancelled)r&r�rr-r.r)r*r'rrr�s 
�
�z!_SelectorSocketTransport.__init__cs.t|tj�r|j|_n|j|_t��|�dSr+)rrZBufferedProtocol�_read_ready__get_bufferr��_read_ready__data_receivedrr�r�r'rrr�	s
z%_SelectorSocketTransport.set_protocolcCs|jo|jSr+)r�r�r<rrrr�sz#_SelectorSocketTransport.is_readingcCs>|js|jrdSd|_|j�|j�|j��r:t�d|�dS)NTz%r pauses reading)r�r�r�r=r�r�rrr<rrrr�s
z&_SelectorSocketTransport.pause_readingcCs@|js|jsdSd|_|�|j|j�|j��r<t�d|�dS)NFz%r resumes reading)	r�r�rDr�r�r�r�rrr<rrrr�s
z'_SelectorSocketTransport.resume_readingcCs|��dSr+)r�r<rrrr�$sz$_SelectorSocketTransport._read_readyc
Cs`|jr
dSz |j�d�}t|�s(td��WnLttfk
rD�Yn4tk
rv}z|�|d�WY�dSd}~XYnXz|j	�
|�}Wndttfk
r�YdSttfk
r��Yn4tk
r�}z|�|d�WY�dSd}~XYnX|�s|�
�dSz|j�|�WnJttfk
�r,�Yn0tk
�rZ}z|�|d�W5d}~XYnXdS)N���z%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.�$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r�r�Z
get_bufferr�r8rirjrhr�r�r�rKrJ�_read_ready__on_eofZbuffer_updated)r&r�rer�rrrr�'sF��z0_SelectorSocketTransport._read_ready__get_bufferc
Cs�|jr
dSz|j�|j�}Wndttfk
r6YdSttfk
rN�Yn4tk
r�}z|�	|d�WY�dSd}~XYnX|s�|�
�dSz|j�|�WnFttfk
r��Yn.tk
r�}z|�	|d�W5d}~XYnXdS)Nr�z2Fatal error: protocol.data_received() call failed.)
r�r�rIr�rKrJrirjrhr�r�r�Z
data_received)r&rGrerrrr�Ls.�z3_SelectorSocketTransport._read_ready__data_receivedc
Cs�|j��rt�d|�z|j��}WnLttfk
r>�Yn4tk
rp}z|�	|d�WY�dSd}~XYnX|r�|j�
|j�n|��dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)
r�r�rrr�Zeof_receivedrirjrhr�r=r�r;)r&Z	keep_openrerrrr�es
�z,_SelectorSocketTransport._read_ready__on_eofc
Cs6t|tttf�s$tdt|�j����|jr2td��|j	dk	rDtd��|sLdS|j
rz|j
tjkrht
�d�|j
d7_
dS|j�sz|j�|�}Wnbttfk
r�Ynbttfk
r��YnJtk
r�}z|�|d�WY�dSd}~XYnX||d�}|�sdS|j�|j|j�|j�|�|��dS)N�/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progress�socket.send() raised exception.r�%Fatal write error on socket transport)r�bytesr�r�r�typer!r�r8r�r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r�rOrKrJrirjrhr�r�r�r��_write_ready�extend�_maybe_pause_protocol)r&rGr�rerrr�writezs:

z_SelectorSocketTransport.writec
Cs(|jstd��|jrdSz|j�|j�}Wn�ttfk
rBYn�ttfk
rZ�Yn�t	k
r�}z>|j
�|j�|j�
�|�|d�|jdk	r�|j�|�W5d}~XYnpX|r�|jd|�=|��|j�s$|j
�|j�|jdk	r�|j�d�|j�r|�d�n|j�r$|j�tj�dS)NzData should not be emptyr�)r��AssertionErrorr�r�rOrKrJrirjrhr�r�r�r�r�r�r��_maybe_resume_protocolr�r�r�r��shutdownrB�SHUT_WR)r&r�rerrrr�s4


z%_SelectorSocketTransport._write_readycCs.|js|jrdSd|_|js*|j�tj�dSr�)r�r�r�r�rrBrr<rrr�	write_eof�s
z"_SelectorSocketTransport.write_eofcCsdSr�rr<rrr�
can_write_eof�sz&_SelectorSocketTransport.can_write_eofcs*t��|�|jdk	r&|j�td��dS)NzConnection is closed by peer)rr�r�r��ConnectionErrorr�r'rrr��s

�z._SelectorSocketTransport._call_connection_lostcCs6|jdk	rtd��|j��|_|js0|j�d�|jS)NzEmpty waiter is already set)r�r8r�rgr�r�r<rrrr��s
z+_SelectorSocketTransport._make_empty_waitercCs
d|_dSr+)r�r<rrrr��sz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!r�r�Z_start_tls_compatiblerZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerr�r�r�r�r�r�r�r�rrr	r
r�r�r�r�rrr'rr,�s*�%'r,csFeZdZejZd�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r5Ncs^t��||||�||_|j�|jj|�|j�|j|j|j	�|dk	rZ|j�t
j|d�dSr+)rr�_addressr�r�r�r�rDr�r�rr�)r&r�rr-r6r.r)r'rrr�s
�
�z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss|]\}}t|�VqdSr+)r�)�.0rGrbrrr�	<genexpr>�szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�r<rrrr��sz0_SelectorDatagramTransport.get_write_buffer_sizec
Cs�|jr
dSz|j�|j�\}}Wn�ttfk
r8Yn�tk
rd}z|j�|�W5d}~XYnTt	t
fk
r|�Yn<tk
r�}z|�|d�W5d}~XYnX|j�
||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rKrJrPr��error_receivedrirjrhr�Zdatagram_received�r&rGrdrerrrr��sz&_SelectorDatagramTransport._read_readyc
Cs�t|tttf�s$tdt|�j����|s,dS|jrV|d|jfkrPtd|j����|j}|j	r�|jr�|j	t
jkrxt�
d�|j	d7_	dS|j�slz,|jdr�|j�|�n|j�||�WdSttfk
r�|j�|j|j�Yn�tk
�r}z|j�|�WY�dSd}~XYnPttfk
�r6�Yn6tk
�rj}z|�|d�WY�dSd}~XYnX|j� t|�|f�|�!�dS)Nr�z!Invalid address: must be None or r�rrZ�'Fatal write error on datagram transport)"rr�r�r�rr�r!rrnr�rr�rrr�r�r�rO�sendtorKrJr�r�r��
_sendto_readyrPr�rrirjrhr�r�rrrrrr�sH
�

�z!_SelectorDatagramTransport.sendtoc
Cs|jr�|j��\}}z*|jdr.|j�|�n|j�||�Wqttfk
rj|j�||f�Yq�Yqt	k
r�}z|j
�|�WY�dSd}~XYqtt
fk
r��Yqtk
r�}z|�|d�WY�dSd}~XYqXq|��|j�s|j�|j�|j�r|�d�dS)NrZr)r��popleftr�r�rOrrKrJ�
appendleftrPr�rrirjrhr�rr�r�r�r�r�rrrrr*s2
�z(_SelectorDatagramTransport._sendto_ready)NNN)N)r!r�r��collections�dequer�rr�r�rrr�rrr'rr5�s�

+r5)r��__all__rr^r�rrBr�r$r�ImportError�rrrrrr	r
r�logrrrZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r,r5rrrr�<module>sF
1�oPK
0�\2�
��transports.cpython-38.opt-2.pycnu�[���U

e5d�(�@sxdZGdd�d�ZGdd�de�ZGdd�de�ZGdd�dee�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZdS))�
BaseTransport�
ReadTransport�WriteTransport�	Transport�DatagramTransport�SubprocessTransportc@sDeZdZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r��_extraNcCs|dkri}||_dS�Nr)�self�extra�r�*/usr/lib64/python3.8/asyncio/transports.py�__init__szBaseTransport.__init__cCs|j�||�Sr	)r�get)r
�name�defaultrrr
�get_extra_infoszBaseTransport.get_extra_infocCst�dSr	��NotImplementedError�r
rrr
�
is_closingszBaseTransport.is_closingcCst�dSr	rrrrr
�closeszBaseTransport.closecCst�dSr	r)r
�protocolrrr
�set_protocol%szBaseTransport.set_protocolcCst�dSr	rrrrr
�get_protocol)szBaseTransport.get_protocol)N)N)
�__name__�
__module__�__qualname__�	__slots__rrrrrrrrrr
r	s


rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rrcCst�dSr	rrrrr
�
is_reading3szReadTransport.is_readingcCst�dSr	rrrrr
�
pause_reading7szReadTransport.pause_readingcCst�dSr	rrrrr
�resume_reading?szReadTransport.resume_readingN)rrrrrr r!rrrr
r.src@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)rrNcCst�dSr	r�r
�high�lowrrr
�set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCst�dSr	rrrrr
�get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCst�dSr	r)r
�datarrr
�writefszWriteTransport.writecCsd�|�}|�|�dS)N�)�joinr()r
Zlist_of_datar'rrr
�
writelinesns
zWriteTransport.writelinescCst�dSr	rrrrr
�	write_eofwszWriteTransport.write_eofcCst�dSr	rrrrr
�
can_write_eof�szWriteTransport.can_write_eofcCst�dSr	rrrrr
�abort�szWriteTransport.abort)NN)rrrrr%r&r(r+r,r-r.rrrr
rHs
		rc@seZdZdZdS)rrN)rrrrrrrr
r�src@s"eZdZdZddd�Zdd�ZdS)rrNcCst�dSr	r)r
r'Zaddrrrr
�sendto�szDatagramTransport.sendtocCst�dSr	rrrrr
r.�szDatagramTransport.abort)N)rrrrr/r.rrrr
r�s

rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rrcCst�dSr	rrrrr
�get_pid�szSubprocessTransport.get_pidcCst�dSr	rrrrr
�get_returncode�sz"SubprocessTransport.get_returncodecCst�dSr	r)r
�fdrrr
�get_pipe_transport�sz&SubprocessTransport.get_pipe_transportcCst�dSr	r)r
�signalrrr
�send_signal�szSubprocessTransport.send_signalcCst�dSr	rrrrr
�	terminate�szSubprocessTransport.terminatecCst�dSr	rrrrr
�kill�s	zSubprocessTransport.killN)
rrrrr0r1r3r5r6r7rrrr
r�srcsVeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	dd�Z
�ZS)�_FlowControlMixin)�_loop�_protocol_paused�_high_water�
_low_waterNcs$t��|�||_d|_|��dS)NF)�superrr9r:�_set_write_buffer_limits)r
rZloop��	__class__rr
rsz_FlowControlMixin.__init__c
Cs�|��}||jkrdS|js�d|_z|j��WnRttfk
rJ�Yn:tk
r�}z|j�	d|||jd��W5d}~XYnXdS)NTzprotocol.pause_writing() failed��messageZ	exceptionZ	transportr)
r&r;r:�	_protocolZ
pause_writing�
SystemExit�KeyboardInterrupt�
BaseExceptionr9�call_exception_handler)r
�size�excrrr
�_maybe_pause_protocols 
�z'_FlowControlMixin._maybe_pause_protocolc
Cs�|jr||��|jkr|d|_z|j��WnRttfk
rB�Yn:tk
rz}z|j�	d|||jd��W5d}~XYnXdS)NFz protocol.resume_writing() failedrA)
r:r&r<rCZresume_writingrDrErFr9rG)r
rIrrr
�_maybe_resume_protocol!s��z(_FlowControlMixin._maybe_resume_protocolcCs|j|jfSr	)r<r;rrrr
�get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|�d|�d���||_||_dS)Ni��zhigh (z) must be >= low (z) must be >= 0)�
ValueErrorr;r<r"rrr
r>4s�z*_FlowControlMixin._set_write_buffer_limitscCs|j||d�|��dS)N)r#r$)r>rJr"rrr
r%Dsz)_FlowControlMixin.set_write_buffer_limitscCst�dSr	rrrrr
r&Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN)rrrrrrJrKrLr>r%r&�
__classcell__rrr?r
r8�s

r8N)�__all__rrrrrrr8rrrr
�<module>s%F6PK
0�\�	�j$j$$base_subprocess.cpython-38.opt-1.pycnu�[���U

e5d�"�@sxddlZddlZddlZddlmZddlmZddlmZGdd�dej�Z	Gdd	�d	ej
�ZGd
d�deej�Z
dS)�N�)�	protocols)�
transports)�loggercs�eZdZd0�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jfdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z�ZS)1�BaseSubprocessTransportNc
	s&t��|
�d|_||_||_d|_d|_d|_g|_t	�
�|_i|_d|_
|tjkr`d|jd<|tjkrtd|jd<|tjkr�d|jd<z"|jf||||||d�|��Wn|���YnX|jj|_|j|jd<|j���rt|ttf�r�|}n|d}t�d||j�|j�|�|	��dS)NFrr�)�args�shell�stdin�stdout�stderr�bufsize�
subprocesszprocess %r created: pid %s)�super�__init__�_closed�	_protocol�_loop�_proc�_pid�_returncode�
_exit_waiters�collections�deque�_pending_calls�_pipes�	_finishedr�PIPE�_start�close�pidZ_extra�	get_debug�
isinstance�bytes�strr�debugZcreate_task�_connect_pipes)
�self�loop�protocolrr	r
rrr
�waiterZextra�kwargsZprogram��	__class__��//usr/lib64/python3.8/asyncio/base_subprocess.pyrsL






��

�z BaseSubprocessTransport.__init__cCs|jjg}|jr|�d�|jdk	r6|�d|j���|jdk	rT|�d|j���n |jdk	rj|�d�n
|�d�|j�d�}|dk	r�|�d|j���|j�d�}|j�d	�}|dk	r�||kr�|�d
|j���n6|dk	r�|�d|j���|dk	�r|�d|j���d
�	d�
|��S)N�closedzpid=zreturncode=Zrunningznot startedrzstdin=rrzstdout=stderr=zstdout=zstderr=z<{}>� )r-�__name__r�appendrrr�get�pipe�format�join)r'�infor
rrr.r.r/�__repr__7s,






z BaseSubprocessTransport.__repr__cKst�dS�N)�NotImplementedError)r'rr	r
rrr
r+r.r.r/rTszBaseSubprocessTransport._startcCs
||_dSr:�r)r'r)r.r.r/�set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<�r'r.r.r/�get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/�
is_closing]sz"BaseSubprocessTransport.is_closingcCs�|jr
dSd|_|j��D]}|dkr(q|j��q|jdk	r�|jdkr�|j��dkr�|j�	�rlt
�d|�z|j��Wnt
k
r�YnXdS)NTz$Close running child process: kill %r)rr�valuesr5rrrZpollrr!rZwarning�kill�ProcessLookupError)r'�protor.r.r/r`s$
��
zBaseSubprocessTransport.closecCs&|js"|d|��t|d�|��dS)Nzunclosed transport )�source)r�ResourceWarningr)r'Z_warnr.r.r/�__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/�get_pid�szBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/�get_returncode�sz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'�fdr.r.r/�get_pipe_transport�s
z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrt��dSr:)rrCr>r.r.r/�_check_proc�s
z#BaseSubprocessTransport._check_proccCs|��|j�|�dSr:)rLr�send_signal)r'�signalr.r.r/rM�sz#BaseSubprocessTransport.send_signalcCs|��|j��dSr:)rLr�	terminater>r.r.r/rO�sz!BaseSubprocessTransport.terminatecCs|��|j��dSr:)rLrrBr>r.r.r/rB�szBaseSubprocessTransport.killc	
�s`z�j}�j}|jdk	rB|��fdd�|j�IdH\}}|�jd<|jdk	rv|��fdd�|j�IdH\}}|�jd<|jdk	r�|��fdd�|j�IdH\}}|�jd<|��j	j
���jD]\}}|j|f|��q�d�_WnZtt
fk
r��Yn`tk
�r<}z"|dk	�r,|���s,|�|�W5d}~XYn X|dk	�r\|���s\|�d�dS)Ncs
t�d�S)Nr)�WriteSubprocessPipeProtor.r>r.r/�<lambda>��z8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>rcs
t�d�S)Nr��ReadSubprocessPipeProtor.r>r.r/rQ�rRrcs
t�d�S)NrrSr.r>r.r/rQ�rRr)rrr
Zconnect_write_piperrZconnect_read_piper�	call_soonr�connection_mader�
SystemExit�KeyboardInterrupt�
BaseException�	cancelledZ
set_exception�
set_result)	r'r*�procr(�_r5�callback�data�excr.r>r/r&�s@

�


�


�

z&BaseSubprocessTransport._connect_pipescGs2|jdk	r|j�||f�n|jj|f|��dSr:)rr3rrU)r'�cbr_r.r.r/�_call�s
zBaseSubprocessTransport._callcCs|�|jj||�|��dSr:)rbrZpipe_connection_lost�_try_finish)r'rJr`r.r.r/�_pipe_connection_lost�sz-BaseSubprocessTransport._pipe_connection_lostcCs|�|jj||�dSr:)rbrZpipe_data_received)r'rJr_r.r.r/�_pipe_data_received�sz+BaseSubprocessTransport._pipe_data_receivedcCsp|j��rt�d||�||_|jjdkr2||j_|�|jj	�|�
�|jD]}|��sN|�
|�qNd|_dS)Nz%r exited with return code %r)rr!rr8rr�
returncoderbrZprocess_exitedrcrrZr[)r'rfr*r.r.r/�_process_exited�s

z'BaseSubprocessTransport._process_exitedc�s0|jdk	r|jS|j��}|j�|�|IdHS)zdWait until the process exit and return the process return code.

        This method is a coroutine.N)rrZ
create_futurerr3)r'r*r.r.r/�_wait�s


zBaseSubprocessTransport._waitcCs>|jdkrdStdd�|j��D��r:d|_|�|jd�dS)Ncss|]}|dk	o|jVqdSr:)�disconnected)�.0�pr.r.r/�	<genexpr>�s�z6BaseSubprocessTransport._try_finish.<locals>.<genexpr>T)r�allrrArrb�_call_connection_lostr>r.r.r/rc�s
�z#BaseSubprocessTransport._try_finishcCs*z|j�|�W5d|_d|_d|_XdSr:)rrr�connection_lost�r'r`r.r.r/rn�s
z-BaseSubprocessTransport._call_connection_lost)NN)r2�
__module__�__qualname__rr9rr=r?r@r�warnings�warnrGrHrIrKrLrMrOrBr&rbrdrergrhrcrn�
__classcell__r.r.r,r/r
s2�+&	rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rPcCs||_||_d|_d|_dS)NF)r\rJr5ri)r'r\rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs
||_dSr:)r5)r'Z	transportr.r.r/rVsz(WriteSubprocessPipeProto.connection_madecCs d|jj�d|j�d|j�d�S)N�<z fd=z pipe=�>)r-r2rJr5r>r.r.r/r9
sz!WriteSubprocessPipeProto.__repr__cCs d|_|j�|j|�d|_dS)NT)rir\rdrJrpr.r.r/ro
sz(WriteSubprocessPipeProto.connection_lostcCs|jj��dSr:)r\r�
pause_writingr>r.r.r/rxsz&WriteSubprocessPipeProto.pause_writingcCs|jj��dSr:)r\r�resume_writingr>r.r.r/rysz'WriteSubprocessPipeProto.resume_writingN)	r2rqrrrrVr9rorxryr.r.r.r/rP�srPc@seZdZdd�ZdS)rTcCs|j�|j|�dSr:)r\rerJ)r'r_r.r.r/�
data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rqrrrzr.r.r.r/rTsrT)rrrs�rr�logrZSubprocessTransportrZBaseProtocolrPZProtocolrTr.r.r.r/�<module>sv�PK
0�\�]������unix_events.cpython-38.pycnu�[���U

e5dۿ�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZdZe
jdkr�ed��dd�ZGdd�dej�ZGdd�dej �Z!Gdd�dej"ej#�Z$Gdd�dej%�Z&Gdd�d�Z'dd�Z(Gd d!�d!e'�Z)Gd"d#�d#e)�Z*Gd$d%�d%e)�Z+Gd&d'�d'e'�Z,Gd(d)�d)e'�Z-Gd*d+�d+ej.�Z/eZ0e/Z1dS),z2Selector event loop for Unix with signal handling.�N�)�base_events)�base_subprocess)�	constants)�
coroutines)�events)�
exceptions)�futures)�selector_events)�tasks)�
transports)�logger)�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�MultiLoopChildWatcher�ThreadedChildWatcher�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N�)�signum�framerr�+/usr/lib64/python3.8/asyncio/unix_events.py�_sighandler_noop*srcs�eZdZdZd)�fdd�	Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
d*dd�Zd+dd�Zd,dd�Z
dd�Zd-ddddd�dd�Zd.dddddd�dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Z�ZS)/�_UnixSelectorEventLoopzdUnix event loop.

    Adds signal handling and UNIX Domain Socket support to SelectorEventLoop.
    Ncst��|�i|_dS�N)�super�__init__�_signal_handlers)�self�selector��	__class__rrr5sz_UnixSelectorEventLoop.__init__csZt���t��s.t|j�D]}|�|�qn(|jrVtjd|�d�t	|d�|j�
�dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal��source)r�close�sys�
is_finalizing�listr�remove_signal_handler�warnings�warn�ResourceWarning�clear�r�sigr!rrr%9s
�z_UnixSelectorEventLoop.closecCs|D]}|sq|�|�qdSr)�_handle_signal)r�datarrrr�_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac
GsLt�|�st�|�rtd��|�|�|��zt�|j�	��Wn2t
tfk
rt}ztt
|���W5d}~XYnXt�|||d�}||j|<zt�|t�t�|d�Wn�tk
�rF}zz|j|=|j�szt�d�Wn4t
tfk
�r}zt�d|�W5d}~XYnX|jtjk�r4td|�d���n�W5d}~XYnXdS)z�Add a handler for a signal.  UNIX only.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        z3coroutines cannot be used with add_signal_handler()NF����set_wakeup_fd(-1) failed: %s�sig � cannot be caught)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signalZ
_check_closed�signal�
set_wakeup_fdZ_csock�fileno�
ValueError�OSError�RuntimeError�strrZHandlerr�siginterruptr
�info�errno�EINVAL)rr/�callback�args�exc�handleZnexcrrr�add_signal_handlerNs2
�

z)_UnixSelectorEventLoop.add_signal_handlercCs8|j�|�}|dkrdS|jr*|�|�n
|�|�dS)z2Internal helper that is the actual signal handler.N)r�getZ
_cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{sz%_UnixSelectorEventLoop._handle_signalc
Cs�|�|�z|j|=Wntk
r,YdSX|tjkr@tj}ntj}zt�||�WnBtk
r�}z$|jtj	kr�t
d|�d���n�W5d}~XYnX|js�zt�d�Wn2ttfk
r�}zt
�d|�W5d}~XYnXdS)zwRemove a handler for a signal.  UNIX only.

        Return True if a signal handler was removed, False if not.
        Fr5r6Nr3r4T)r8r�KeyErrorr9�SIGINT�default_int_handler�SIG_DFLr=rBrCr>r:r<r
rA)rr/�handlerrFrrrr)�s(

z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|t�std|����|t��kr2td|����dS)z�Internal helper to validate a signal.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        zsig must be an int, not zinvalid signal number N)�
isinstance�intr7r9�
valid_signalsr<r.rrrr8�s
z$_UnixSelectorEventLoop._check_signalcCst|||||�Sr)�_UnixReadPipeTransport�r�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�Sr)�_UnixWritePipeTransportrSrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc	

�s�t����}
|
��std��|��}t||||||||f||d�|	��}|
�|��|j|�z|IdHWnDt	t
fk
r��Yn,tk
r�|��|�
�IdH�YnXW5QRX|S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)r�get_child_watcher�	is_activer>�
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�
SystemExit�KeyboardInterrupt�
BaseExceptionr%Z_wait)
rrUrE�shell�stdin�stdout�stderr�bufsizerW�kwargs�watcherrV�transprrr�_make_subprocess_transport�s8

���
�z1_UnixSelectorEventLoop._make_subprocess_transportcCs|�|j|�dSr)�call_soon_threadsafeZ_process_exited)r�pid�
returncoderkrrrr`�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostname�ssl_handshake_timeoutc	�s |dkst|t�st�|r,|dkrLtd��n |dk	r<td��|dk	rLtd��|dk	r�|dk	rdtd��t�|�}t�tjtjd�}z |�	d�|�
||�IdHWq�|���Yq�Xn@|dkr�td��|jtjks�|j
tjkr�td|����|�	d�|j|||||d	�IdH\}}||fS)
Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl�1ssl_handshake_timeout is only meaningful with ssl�3path and sock can not be specified at the same timerFzno path and sock were specified�.A UNIX Domain Stream Socket was expected, got )rs)rOr?�AssertionErrorr<�os�fspath�socket�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr%�family�typeZ_create_connection_transport)	r�protocol_factory�pathrprqrrrs�	transportrUrrr�create_unix_connection�sT���



��
�z-_UnixSelectorEventLoop.create_unix_connection�dT)rq�backlogrprs�
start_servingc
�s�t|t�rtd��|dk	r&|s&td��|dk	�rH|dk	r@td��t�|�}t�tjtj�}|ddkr�z t	�
t�	|�j�r�t�|�WnBt
k
r�Yn0tk
r�}zt�d||�W5d}~XYnXz|�|�Wnltk
�r0}	z8|��|	jtjk�rd|�d�}
ttj|
�d�n�W5d}	~	XYn|���YnXn<|dk�rZtd	��|jtjk�sv|jtjk�r�td
|����|�d�t�||g||||�}|�r�|��tjd|d�IdH|S)
Nz*ssl argument must be an SSLContext or Nonertrur)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrvF)�loop)rO�boolr7r<rxryrzr{r|�stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorr=r
�errorZbindr%rBZ
EADDRINUSEr~rr}rZServerZ_start_servingr�sleep)rr�r�rqr�rprsr��errrF�msgZserverrrr�create_unix_serversn
�
�
�

�
��
�z)_UnixSelectorEventLoop.create_unix_serverc
�s�z
tjWn,tk
r6}zt�d��W5d}~XYnXz|��}Wn2ttjfk
rv}zt�d��W5d}~XYnXzt�|�j	}Wn,t
k
r�}zt�d��W5d}~XYnX|r�|n|}	|	s�dS|��}
|�|
d|||||	d�|
IdHS)Nzos.sendfile() is not availableznot a regular filer)
rx�sendfile�AttributeErrorr�SendfileNotAvailableErrorr;�io�UnsupportedOperation�fstat�st_sizer=r]�_sock_sendfile_native_impl)rrq�file�offset�countrFr;r�Zfsize�	blocksize�futrrr�_sock_sendfile_nativeJs2
��z,_UnixSelectorEventLoop._sock_sendfile_nativec	Cs,|��}	|dk	r|�|�|��r4|�|||�dS|rd||}|dkrd|�|||�|�|�dSzt�|	|||�}
W�nDttfk
r�|dkr�|�	||�|�
|	|j||	||||||�
Y�nbtk
�rj}z�|dk	�r|j
t
jk�rt|�tk	�rtdt
j�}||_|}|dk�rBt�d�}
|�|||�|�|
�n|�|||�|�|�W5d}~XYn�ttfk
�r��Yn�tk
�r�}z|�|||�|�|�W5d}~XYnjX|
dk�r�|�|||�|�|�nD||
7}||
7}|dk�r
|�	||�|�
|	|j||	||||||�
dS)Nrzsocket is not connectedzos.sendfile call failed)r;�
remove_writer�	cancelled�_sock_sendfile_update_fileposZ
set_resultrxr��BlockingIOError�InterruptedError�_sock_add_cancellation_callbackZ
add_writerr�r=rBZENOTCONNr�ConnectionError�	__cause__rr�Z
set_exceptionrarbrc)rr�Z
registered_fdrqr;r�r�r��
total_sent�fdZsentrF�new_excr�rrrr�as�

�


�
��
�

�z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt�||tj�dS�Nr)rx�lseek�SEEK_SET)rr;r�r�rrrr��sz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcs��fdd�}|�|�dS)Ncs&|��r"���}|dkr"��|�dS)Nr3)r�r;r�)r�r��rrqrr�cb�szB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb)Zadd_done_callback)rr�rqr�rr�rr��sz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)�__name__�
__module__�__qualname__�__doc__rr%r2rHr0r)r8rXrZrlr`r�r�r�r�r�r��
__classcell__rrr!rr/sH-
 �
�
�
��.��CFrcs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jfdd�Zddd�Zdd�Zdd�Z�ZS) rRiNcs�t��|�||jd<||_||_|��|_||_d|_d|_	t
�|j�j}t
�|�s�t
�|�s�t
�|�s�d|_d|_d|_td��t
�|jd�|j�|jj|�|j�|jj|j|j�|dk	r�|j�tj|d�dS)NrTFz)Pipe transport is for pipes/sockets only.)rr�_extra�_loop�_piper;�_fileno�	_protocol�_closing�_pausedrxr�r�r��S_ISFIFOr��S_ISCHRr<�set_blocking�	call_soon�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)rr�rTrUrVrW�moder!rrr�s:


���
�z_UnixReadPipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���t|jdd�}|jdk	r�|dk	r�t�	||jt
j�}|r�|�d�q�|�d�n |jdk	r�|�d�n
|�d�d�d	�
|��S)
N�closed�closing�fd=�	_selector�polling�idle�open�<{}>� )r"r�r��appendr�r��getattrr�r
�_test_selector_event�	selectorsZ
EVENT_READ�format�join)rrAr r�rrr�__repr__�s(


�

z_UnixReadPipeTransport.__repr__c
Cs�zt�|j|j�}WnDttfk
r,Yn�tk
rX}z|�|d�W5d}~XYn^X|rl|j�	|�nJ|j
��r�t�
d|�d|_|j
�|j�|j
�|jj�|j
�|jd�dS)Nz"Fatal read error on pipe transport�%r was closed by peerT)rx�readr��max_sizer�r�r=�_fatal_errorr�Z
data_receivedr��	get_debugr
rAr��_remove_readerr�Zeof_received�_call_connection_lost)rr1rFrrrr��s
z"_UnixReadPipeTransport._read_readycCs>|js|jrdSd|_|j�|j�|j��r:t�d|�dS)NTz%r pauses reading)r�r�r�r�r�r�r
�debug�rrrr�
pause_reading�s
z$_UnixReadPipeTransport.pause_readingcCsB|js|jsdSd|_|j�|j|j�|j��r>t�d|�dS)NFz%r resumes reading)	r�r�r�r�r�r�r�r
r�r�rrr�resume_readings
z%_UnixReadPipeTransport.resume_readingcCs
||_dSr�r��rrUrrr�set_protocol
sz#_UnixReadPipeTransport.set_protocolcCs|jSrr�r�rrr�get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSr�r�r�rrr�
is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|�d�dSr)r��_closer�rrrr%sz_UnixReadPipeTransport.closecCs,|jdk	r(|d|��t|d�|j��dS�Nzunclosed transport r#�r�r,r%�r�_warnrrr�__del__s
z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r4|jtjkr4|j��rLtjd||dd�n|j�||||j	d��|�
|�dS�Nz%r: %sT��exc_info)�message�	exceptionr�rU)rOr=rBZEIOr�r�r
r��call_exception_handlerr�r��rrFr�rrrr�s
�z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j�|j�|j�|j|�dS�NT)r�r�r�r�r�r��rrFrrrr�-sz_UnixReadPipeTransport._closecCs4z|j�|�W5|j��d|_d|_d|_XdSr�r�r%r�r�Zconnection_lostr�rrrr�2s
z,_UnixReadPipeTransport._call_connection_lost)NN)r�)r�r�r�r�rr�r�r�r�r�r�r�r%r*r+r�r�r�r�r�rrr!rrR�s
rRcs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejfdd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rYNc
s�t��||�||jd<||_|��|_||_t�|_d|_	d|_
t�|j�j
}t�|�}t�|�}t�|�}	|s�|s�|	s�d|_d|_d|_td��t�|jd�|j�|jj|�|	s�|r�tj�d�s�|j�|jj|j|j�|dk	r�|j�tj|d�dS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrr�r�r;r�r��	bytearray�_buffer�
_conn_lostr�rxr�r�r�r�r�r�r<r�r�r�r�r&�platform�
startswithr�r�r	r�)
rr�rTrUrVrWr�Zis_charZis_fifoZ	is_socketr!rrr?s:




�
�z _UnixWritePipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|�d|j���t|jdd�}|jdk	r�|dk	r�t�	||jt
j�}|r�|�d�n
|�d�|��}|�d|���n |jdk	r�|�d�n
|�d�d	�
d
�|��S)Nr�r�r�r�r�r�zbufsize=r�r�r�)r"r�r�r�r�r�r�r�r
r�r�ZEVENT_WRITE�get_write_buffer_sizer�r�)rrAr r�rhrrrr�ds,


�


z _UnixWritePipeTransport.__repr__cCs
t|j�Sr)�lenr�r�rrrr�|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|j��rt�d|�|jr*|�t��n|��dS)Nr�)r�r�r
rAr�r��BrokenPipeErrorr�rrrr�s

z#_UnixWritePipeTransport._read_readyc
CsRt|tttf�stt|���t|t�r.t|�}|s6dS|jsB|jrj|jtj	krXt
�d�|jd7_dS|j�s8zt
�|j|�}Wntttfk
r�d}YnZttfk
r��YnBtk
r�}z$|jd7_|�|d�WY�dSd}~XYnX|t|�k�rdS|dk�r&t|�|d�}|j�|j|j�|j|7_|��dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr�#Fatal write error on pipe transport)rO�bytesr��
memoryviewrw�reprr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�rx�writer�r�r�rarbrcr�r�r�Z_add_writer�_write_readyZ_maybe_pause_protocol)rr1�nrFrrrr�s8


z_UnixWritePipeTransport.writec
Cs|jstd��zt�|j|j�}Wn�ttfk
r:Yn�ttfk
rR�Yn�t	k
r�}z6|j�
�|jd7_|j�
|j�|�|d�W5d}~XYnhX|t|j�kr�|j�
�|j�
|j�|��|jr�|j�|j�|�d�dS|dk�r|jd|�=dS)NzData should not be emptyrrr)r�rwrxrr�r�r�rarbrcr-r�r��_remove_writerr�r�Z_maybe_resume_protocolr�r�r�)rrrFrrrr�s,



z$_UnixWritePipeTransport._write_readycCsdSr�rr�rrr�
can_write_eof�sz%_UnixWritePipeTransport.can_write_eofcCsB|jr
dS|jst�d|_|js>|j�|j�|j�|jd�dSr�)	r�r�rwr�r�r�r�r�r�r�rrr�	write_eof�s
z!_UnixWritePipeTransport.write_eofcCs
||_dSrr�r�rrrr��sz$_UnixWritePipeTransport.set_protocolcCs|jSrr�r�rrrr��sz$_UnixWritePipeTransport.get_protocolcCs|jSrr�r�rrrr��sz"_UnixWritePipeTransport.is_closingcCs|jdk	r|js|��dSr)r�r�rr�rrrr%�sz_UnixWritePipeTransport.closecCs,|jdk	r(|d|��t|d�|j��dSr�r�r�rrrr��s
z_UnixWritePipeTransport.__del__cCs|�d�dSr)r�r�rrr�abort�sz_UnixWritePipeTransport.abortr�cCsNt|t�r(|j��r@tjd||dd�n|j�||||jd��|�|�dSr�)	rOr=r�r�r
r�r�r�r�r�rrrr��s

�z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|j�|j�|j��|j�|j�|j�|j|�dSr�)	r�r�r�r	r�r-r�r�r�r�rrrr��s
z_UnixWritePipeTransport._closecCs4z|j�|�W5|j��d|_d|_d|_XdSrr�r�rrrr��s
z-_UnixWritePipeTransport._call_connection_lost)NN)r�)N)r�r�r�rr�r�r�rrr
rr�r�r�r%r*r+r�rr�r�r�r�rrr!rrY<s"%	#	

rYc@seZdZdd�ZdS)r^c		Ks�d}|tjkrt��\}}zPtj|f||||d|d�|��|_|dk	rh|��t|��d|d�|j_	d}W5|dk	r�|��|��XdS)NF)rdrerfrgZuniversal_newlinesrh�wb)�	buffering)
�
subprocess�PIPErzZ
socketpairr%�Popen�_procr��detachre)	rrErdrerfrgrhriZstdin_wrrr�_starts.
���z_UnixSubprocessTransport._startN)r�r�r�rrrrrr^	sr^c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)raHAbstract base class for monitoring child processes.

    Objects derived from this class monitor a collection of subprocesses and
    report their termination or interruption by a signal.

    New callbacks are registered with .add_child_handler(). Starting a new
    process must be done within a 'with' block to allow the watcher to suspend
    its activity until the new process if fully registered (this is needed to
    prevent a race condition in some implementations).

    Example:
        with watcher:
            proc = subprocess.Popen("sleep 1")
            watcher.add_child_handler(proc.pid, callback)

    Notes:
        Implementations of this class must be thread-safe.

        Since child watcher objects may catch the SIGCHLD signal and call
        waitpid(-1), there should be only one active object per process.
    cGs
t��dS)aRegister a new child handler.

        Arrange for callback(pid, returncode, *args) to be called when
        process 'pid' terminates. Specifying another callback for the same
        process replaces the previous handler.

        Note: callback() must be thread-safe.
        N��NotImplementedError�rrnrDrErrrr_9s	z&AbstractChildWatcher.add_child_handlercCs
t��dS)z�Removes the handler for process 'pid'.

        The function returns True if the handler was successfully removed,
        False if there was nothing to remove.Nr�rrnrrr�remove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs
t��dS)z�Attach the watcher to an event loop.

        If the watcher was previously attached to an event loop, then it is
        first detached before attaching to the new loop.

        Note: loop may be None.
        Nr�rr�rrr�attach_loopLsz AbstractChildWatcher.attach_loopcCs
t��dS)zlClose the watcher.

        This must be called to make sure that any underlying resource is freed.
        Nrr�rrrr%VszAbstractChildWatcher.closecCs
t��dS)z�Return ``True`` if the watcher is active and is used by the event loop.

        Return True if the watcher is installed and ready to handle process exit
        notifications.

        Nrr�rrrr\]szAbstractChildWatcher.is_activecCs
t��dS)zdEnter the watcher's context and allow starting new processes

        This function must return selfNrr�rrr�	__enter__fszAbstractChildWatcher.__enter__cCs
t��dS)zExit the watcher's contextNr�r�a�b�crrr�__exit__lszAbstractChildWatcher.__exit__N)r�r�r�r�r_rrr%r\rr!rrrrr"s
	rcCs2t�|�rt�|�St�|�r*t�|�S|SdSr)rx�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)�statusrrr�_compute_returncodeqs



r'c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dSr)r��
_callbacksr�rrrr�szBaseChildWatcher.__init__cCs|�d�dSr)rr�rrrr%�szBaseChildWatcher.closecCs|jdk	o|j��Sr)r�Z
is_runningr�rrrr\�szBaseChildWatcher.is_activecCs
t��dSrr)r�expected_pidrrr�_do_waitpid�szBaseChildWatcher._do_waitpidcCs
t��dSrrr�rrr�_do_waitpid_all�sz BaseChildWatcher._do_waitpid_allcCs~|dkst|tj�st�|jdk	r<|dkr<|jr<t�dt�|jdk	rT|j�	t
j�||_|dk	rz|�t
j|j
�|��dS)NzCA loop is being detached from a child watcher with pending handlers)rOrZAbstractEventLooprwr�r)r*r+�RuntimeWarningr)r9�SIGCHLDrH�	_sig_chldr,rrrrr�s�
zBaseChildWatcher.attach_loopc
Cs^z|��WnLttfk
r&�Yn4tk
rX}z|j�d|d��W5d}~XYnXdS)N�$Unknown exception in SIGCHLD handler)r�r�)r,rarbrcr�r�r�rrrr/�s�zBaseChildWatcher._sig_chldN)
r�r�r�rr%r\r+r,rr/rrrrr(sr(csPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)rad'Safe' child watcher implementation.

    This implementation avoids disrupting other code spawning processes by
    polling explicitly each process in the SIGCHLD handler instead of calling
    os.waitpid(-1).

    This is a safe solution but it has a significant overhead when handling a
    big number of children (O(n) each time SIGCHLD is raised)
    cs|j��t���dSr)r)r-rr%r�r!rrr%�s
zSafeChildWatcher.closecCs|Srrr�rrrr�szSafeChildWatcher.__enter__cCsdSrrrrrrr!�szSafeChildWatcher.__exit__cGs||f|j|<|�|�dSr)r)r+rrrrr_�sz"SafeChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdS�NTF�r)rJrrrrr�s
z%SafeChildWatcher.remove_child_handlercCst|j�D]}|�|�q
dSr�r(r)r+rrrrr,�sz SafeChildWatcher._do_waitpid_allcCs�|dkst�zt�|tj�\}}Wn(tk
rJ|}d}t�d|�Yn.X|dkrXdSt|�}|j�	�rxt�
d||�z|j�|�\}}Wn.t
k
r�|j�	�r�tjd|dd�YnX|||f|��dS)Nr��8Unknown child process pid %d, will report returncode 255�$process %s exited with returncode %s�'Child watcher got an unexpected pid: %rTr�)rwrx�waitpid�WNOHANG�ChildProcessErrorr
rr'r�r�r�r)�poprJ)rr*rnr&rorDrErrrr+�s6�

�
�zSafeChildWatcher._do_waitpid)r�r�r�r�r%rr!r_rr,r+r�rrr!rr�s
rcsTeZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)raW'Fast' child watcher implementation.

    This implementation reaps every terminated processes by calling
    os.waitpid(-1) directly, possibly breaking other code spawning processes
    and waiting for their termination.

    There is no noticeable overhead when handling a big number of children
    (O(1) each time a child terminates).
    cs$t���t��|_i|_d|_dSr�)rr�	threadingZLock�_lock�_zombies�_forksr�r!rrrs

zFastChildWatcher.__init__cs"|j��|j��t���dSr)r)r-r>rr%r�r!rrr%s

zFastChildWatcher.closec
Cs0|j� |jd7_|W5QR�SQRXdS)Nr)r=r?r�rrrrszFastChildWatcher.__enter__c	Cs^|j�B|jd8_|js"|js0W5QR�dSt|j�}|j��W5QRXt�d|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)r=r?r>r?r-r
r)rrrr Zcollateral_victimsrrrr!s
�zFastChildWatcher.__exit__c	Gst|jstd��|j�Fz|j�|�}Wn.tk
rT||f|j|<YW5QR�dSXW5QRX|||f|��dS)NzMust use the context manager)r?rwr=r>r;rJr))rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdSr1r2rrrrr5s
z%FastChildWatcher.remove_child_handlerc	Cs�zt�dtj�\}}Wntk
r,YdSX|dkr:dSt|�}|j��z|j�|�\}}WnNtk
r�|j	r�||j
|<|j��r�t
�d||�YW5QR�qd}YnX|j��r�t
�d||�W5QRX|dkr�t
�d||�q|||f|��qdS)Nr3rz,unknown process %s exited with returncode %sr6z8Caught subprocess termination from unknown pid: %d -> %d)rxr8r9r:r'r=r)r;rJr?r>r�r�r
r�r)rrnr&rorDrErrrr,<s@

�

��z FastChildWatcher._do_waitpid_all)r�r�r�r�rr%rr!r_rr,r�rrr!rr�s	rc@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)ra~A watcher that doesn't require running loop in the main thread.

    This implementation registers a SIGCHLD signal handler on
    instantiation (which may conflict with other code that
    install own handler for this signal).

    The solution is safe but it has a significant overhead when
    handling a big number of processes (*O(n)* each time a
    SIGCHLD is received).
    cCsi|_d|_dSr)r)�_saved_sighandlerr�rrrrzszMultiLoopChildWatcher.__init__cCs
|jdk	Sr)r@r�rrrr\~szMultiLoopChildWatcher.is_activecCsT|j��|jdkrdSt�tj�}||jkr:t�d�nt�tj|j�d|_dS)Nz+SIGCHLD handler was changed by outside code)	r)r-r@r9�	getsignalr.r/r
r)rrNrrrr%�s


zMultiLoopChildWatcher.closecCs|Srrr�rrrr�szMultiLoopChildWatcher.__enter__cCsdSrr�r�exc_typeZexc_valZexc_tbrrrr!�szMultiLoopChildWatcher.__exit__cGs&t��}|||f|j|<|�|�dSr)r�get_running_loopr)r+)rrnrDrEr�rrrr_�sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk
r$YdSXdSr1r2rrrrr�s
z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk	rdSt�tj|j�|_|jdkr<t�d�tj|_t�tjd�dS)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)r@r9r.r/r
rrMr@rrrrr�s


z!MultiLoopChildWatcher.attach_loopcCst|j�D]}|�|�q
dSrr3rrrrr,�sz%MultiLoopChildWatcher._do_waitpid_allc	Cs�|dkst�zt�|tj�\}}Wn,tk
rN|}d}t�d|�d}YnX|dkr\dSt|�}d}z|j�	|�\}}}Wn$t
k
r�tjd|dd�YnHX|��r�t�d||�n.|r�|��r�t�
d	||�|j|||f|��dS)
Nrr4r5FTr7r��%Loop %r that handles pid %r is closedr6)rwrxr8r9r:r
rr'r)r;rJ�	is_closedr�r�rm)	rr*rnr&roZ	debug_logr�rDrErrrr+�s<�
��z!MultiLoopChildWatcher._do_waitpidc	CsLz|��Wn:ttfk
r&�Yn"tk
rFtjddd�YnXdS)Nr0Tr�)r,rarbrcr
r)rrrrrrr/�szMultiLoopChildWatcher._sig_chldN)r�r�r�r�rr\r%rr!r_rrr,r+r/rrrrrgs%rc@sneZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
jfdd�Zdd�Z
dd�Zdd�Zdd�ZdS)raAThreaded child watcher implementation.

    The watcher uses a thread per process
    for waiting for the process finish.

    It doesn't require subscription on POSIX signal
    but a thread creation is not free.

    The watcher has O(1) complexity, its performance doesn't depend
    on amount of spawn processes.
    cCst�d�|_i|_dSr�)�	itertoolsr��_pid_counter�_threadsr�rrrr�szThreadedChildWatcher.__init__cCsdSr�rr�rrrr\�szThreadedChildWatcher.is_activecCs|��dSr)�
_join_threadsr�rrrr%�szThreadedChildWatcher.closecCs.dd�t|j���D�}|D]}|��qdS)z%Internal: Join all non-daemon threadscSsg|]}|��r|js|�qSr)�is_alive�daemon��.0�threadrrr�
<listcomp>�s�z6ThreadedChildWatcher._join_threads.<locals>.<listcomp>N)r(rI�valuesr�)r�threadsrOrrrrJ�sz"ThreadedChildWatcher._join_threadscCs|Srrr�rrrrszThreadedChildWatcher.__enter__cCsdSrrrBrrrr!szThreadedChildWatcher.__exit__cCs6dd�t|j���D�}|r2||j�d�t|d�dS)NcSsg|]}|��r|�qSr)rKrMrrrrP	s�z0ThreadedChildWatcher.__del__.<locals>.<listcomp>z0 has registered but not finished child processesr#)r(rIrQr"r,)rr�rRrrrr�s�zThreadedChildWatcher.__del__cGsFt��}tj|jdt|j���||||fdd�}||j|<|��dS)Nzwaitpid-T)�target�namerErL)	rrDr<ZThreadr+�nextrHrI�start)rrnrDrEr�rOrrrr_s
�
z&ThreadedChildWatcher.add_child_handlercCsdSr�rrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCs�|dkst�zt�|d�\}}Wn(tk
rH|}d}t�d|�Yn Xt|�}|��rht�d||�|�	�r�t�d||�n|j
|||f|��|j�|�dS)Nrr4r5r6rE)
rwrxr8r:r
rr'r�r�rFrmrIr;)rr�r*rDrErnr&rorrrr+"s(�
�z ThreadedChildWatcher._do_waitpidN)r�r�r�r�rr\r%rJrr!r*r+r�r_rrr+rrrrr�s	rcsHeZdZdZeZ�fdd�Zdd�Z�fdd�Zdd	�Z	d
d�Z
�ZS)�_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cst���d|_dSr)rr�_watcherr�r!rrrAs
z$_UnixDefaultEventLoopPolicy.__init__c	CsHtj�8|jdkr:t�|_tt��tj�r:|j�|j	j
�W5QRXdSr)rr=rXrrOr<�current_thread�_MainThreadr�_localr�r�rrr�
_init_watcherEs
�z)_UnixDefaultEventLoopPolicy._init_watchercs6t��|�|jdk	r2tt��tj�r2|j�|�dS)z�Set the event loop.

        As a side effect, if a child watcher was set before, then calling
        .set_event_loop() from the main thread will call .attach_loop(loop) on
        the child watcher.
        N)r�set_event_looprXrOr<rYrZrrr!rrr]Ms

�z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|��|jS)z~Get the watcher for child processes.

        If not yet set, a ThreadedChildWatcher object is automatically created.
        N)rXr\r�rrrr[[s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs4|dkst|t�st�|jdk	r*|j��||_dS)z$Set the watcher for child processes.N)rOrrwrXr%)rrjrrr�set_child_watcheres

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�r�rZ
_loop_factoryrr\r]r[r^r�rrr!rrW=s
rW)2r�rBr�rGrxr�r9rzr�rr&r<r*�rrrrrrr	r
rr�logr
�__all__r��ImportErrorrZBaseSelectorEventLooprZ
ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr'r(rrrrZBaseDefaultEventLoopPolicyrWrrrrrr�<module>s`	
	�NO5Ji}Y3PK
0�\�	u�

protocols.cpython-38.opt-2.pycnu�[���U

e5d��@s^dZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
e�Zdd�Zd
S))�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocol�BufferedProtocolc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�cCsdS�Nr)�selfZ	transportrr�)/usr/lib64/python3.8/asyncio/protocols.py�connection_madeszBaseProtocol.connection_madecCsdSrr�r�excrrr	�connection_lostszBaseProtocol.connection_lostcCsdSrr�rrrr	�
pause_writing%szBaseProtocol.pause_writingcCsdSrrrrrr	�resume_writing;szBaseProtocol.resume_writingN)�__name__�
__module__�__qualname__�	__slots__r
r
rrrrrr	r	s

rc@s eZdZdZdd�Zdd�ZdS)rrcCsdSrr)r�datarrr	�
data_received^szProtocol.data_receivedcCsdSrrrrrr	�eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrr	rBsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rrcCsdSrr)r�sizehintrrr	�
get_buffer�szBufferedProtocol.get_buffercCsdSrr)r�nbytesrrr	�buffer_updated�szBufferedProtocol.buffer_updatedcCsdSrrrrrr	r�szBufferedProtocol.eof_receivedN)rrrrrrrrrrr	rmsrc@s eZdZdZdd�Zdd�ZdS)rrcCsdSrr)rrZaddrrrr	�datagram_received�sz"DatagramProtocol.datagram_receivedcCsdSrrrrrr	�error_received�szDatagramProtocol.error_receivedN)rrrrrrrrrr	r�src@s(eZdZdZdd�Zdd�Zdd�ZdS)	rrcCsdSrr)r�fdrrrr	�pipe_data_received�sz%SubprocessProtocol.pipe_data_receivedcCsdSrr)rrrrrr	�pipe_connection_lost�sz'SubprocessProtocol.pipe_connection_lostcCsdSrrrrrr	�process_exited�sz!SubprocessProtocol.process_exitedN)rrrrrr r!rrrr	r�srcCs�t|�}|r�|�|�}t|�}|s*td��||krL||d|�<|�|�dS|d|�|d|�<|�|�||d�}t|�}qdS)Nz%get_buffer() returned an empty buffer)�lenr�RuntimeErrorr)�protorZdata_lenZbufZbuf_lenrrr	�_feed_data_to_buffered_proto�s


r%N)�__all__rrrrrr%rrrr	�<module>s9+9PK
0�\7�!�!protocols.cpython-38.pycnu�[���U

e5d��@sbdZdZGdd�d�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de�Zdd
�ZdS)zAbstract Protocol base classes.)�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocol�BufferedProtocolc@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)raCommon base class for protocol interfaces.

    Usually user implements protocols that derived from BaseProtocol
    like Protocol or ProcessProtocol.

    The only case when BaseProtocol should be implemented directly is
    write-only transport like write pipe
    �cCsdS)z�Called when a connection is made.

        The argument is the transport representing the pipe connection.
        To receive data, wait for data_received() calls.
        When the connection is closed, connection_lost() is called.
        Nr)�selfZ	transportrr�)/usr/lib64/python3.8/asyncio/protocols.py�connection_madeszBaseProtocol.connection_madecCsdS)z�Called when the connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        Nr�r�excrrr�connection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark.

        Pause and resume calls are paired -- pause_writing() is called
        once when the buffer goes strictly over the high-water mark
        (even if subsequent writes increases the buffer size even
        more), and eventually resume_writing() is called once when the
        buffer size reaches the low-water mark.

        Note that if the buffer size equals the high-water mark,
        pause_writing() is not called -- it must go strictly over.
        Conversely, resume_writing() is called when the buffer size is
        equal or lower than the low-water mark.  These end conditions
        are important to ensure that things go as expected when either
        mark is zero.

        NOTE: This is the only Protocol callback that is not called
        through EventLoop.call_soon() -- if it were, it would have no
        effect when it's most needed (when the app keeps writing
        without yielding until pause_writing() is called).
        Nr�rrrr�
pause_writing%szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark.

        See pause_writing() for details.
        Nrr
rrr�resume_writing;szBaseProtocol.resume_writingN)	�__name__�
__module__�__qualname__�__doc__�	__slots__r	rrrrrrrr	s	rc@s$eZdZdZdZdd�Zdd�ZdS)ranInterface for stream protocol.

    The user should implement this interface.  They can inherit from
    this class but don't need to.  The implementations here do
    nothing (they don't raise exceptions).

    When the user wants to requests a transport, they pass a protocol
    factory to a utility function (e.g., EventLoop.create_connection()).

    When the connection is made successfully, connection_made() is
    called with a suitable transport object.  Then data_received()
    will be called 0 or more times with data (bytes) received from the
    transport; finally, connection_lost() will be called exactly once
    with either an exception object or None as an argument.

    State machine of calls:

      start -> CM [-> DR*] [-> ER?] -> CL -> end

    * CM: connection_made()
    * DR: data_received()
    * ER: eof_received()
    * CL: connection_lost()
    rcCsdS)zTCalled when some data is received.

        The argument is a bytes object.
        Nr)r�datarrr�
data_received^szProtocol.data_receivedcCsdS�z�Called when the other end calls write_eof() or equivalent.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        Nrr
rrr�eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrrrrBsrc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
ra�Interface for stream protocol with manual buffer control.

    Important: this has been added to asyncio in Python 3.7
    *on a provisional basis*!  Consider it as an experimental API that
    might be changed or removed in Python 3.8.

    Event methods, such as `create_server` and `create_connection`,
    accept factories that return protocols that implement this interface.

    The idea of BufferedProtocol is that it allows to manually allocate
    and control the receive buffer.  Event loops can then use the buffer
    provided by the protocol to avoid unnecessary data copies.  This
    can result in noticeable performance improvement for protocols that
    receive big amounts of data.  Sophisticated protocols can allocate
    the buffer only once at creation time.

    State machine of calls:

      start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end

    * CM: connection_made()
    * GB: get_buffer()
    * BU: buffer_updated()
    * ER: eof_received()
    * CL: connection_lost()
    rcCsdS)aPCalled to allocate a new receive buffer.

        *sizehint* is a recommended minimal size for the returned
        buffer.  When set to -1, the buffer size can be arbitrary.

        Must return an object that implements the
        :ref:`buffer protocol <bufferobjects>`.
        It is an error to return a zero-sized buffer.
        Nr)r�sizehintrrr�
get_buffer�szBufferedProtocol.get_buffercCsdS)z�Called when the buffer was updated with the received data.

        *nbytes* is the total number of bytes that were written to
        the buffer.
        Nr)r�nbytesrrr�buffer_updated�szBufferedProtocol.buffer_updatedcCsdSrrr
rrrr�szBufferedProtocol.eof_receivedN)rrrrrrrrrrrrrms
rc@s$eZdZdZdZdd�Zdd�ZdS)rz Interface for datagram protocol.rcCsdS)z&Called when some datagram is received.Nr)rrZaddrrrr�datagram_received�sz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError.

        (Other than BlockingIOError or InterruptedError.)
        Nrr
rrr�error_received�szDatagramProtocol.error_receivedN)rrrrrrrrrrrr�src@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
rz,Interface for protocol for subprocess calls.rcCsdS)z�Called when the subprocess writes data into stdout/stderr pipe.

        fd is int file descriptor.
        data is bytes object.
        Nr)r�fdrrrr�pipe_data_received�sz%SubprocessProtocol.pipe_data_receivedcCsdS)z�Called when a file descriptor associated with the child process is
        closed.

        fd is the int file descriptor that was closed.
        Nr)rrrrrr�pipe_connection_lost�sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nrr
rrr�process_exited�sz!SubprocessProtocol.process_exitedN)rrrrrr r!r"rrrrr�s
rcCs�t|�}|r�|�|�}t|�}|s*td��||krL||d|�<|�|�dS|d|�|d|�<|�|�||d�}t|�}qdS)Nz%get_buffer() returned an empty buffer)�lenr�RuntimeErrorr)�protorZdata_lenZbufZbuf_lenrrr�_feed_data_to_buffered_proto�s


r&N)r�__all__rrrrrr&rrrr�<module>s9+9PK
0�\$��'��base_tasks.cpython-38.pycnu�[���U

e5d�	�@sDddlZddlZddlmZddlmZdd�Zdd�Zd	d
�ZdS)�N�)�base_futures)�
coroutinescCsnt�|�}|jrd|d<|�dd|���t�|j�}|�dd|�d��|jdk	rj|�dd	|j���|S)
NZ
cancellingrrzname=%r�zcoro=<�>�z	wait_for=)	rZ_future_repr_infoZ_must_cancel�insertZget_namerZ_format_coroutine�_coroZ_fut_waiter)�task�info�coro�r
�*/usr/lib64/python3.8/asyncio/base_tasks.py�_task_repr_infos

rcCs�g}t|jd�r|jj}n0t|jd�r0|jj}nt|jd�rF|jj}nd}|dk	r�|dk	r�|dk	rt|dkrlq�|d8}|�|�|j}qR|��nH|jdk	r�|jj	}|dk	r�|dk	r�|dkr�q�|d8}|�|j
�|j}q�|S)N�cr_frame�gi_frame�ag_framerr)�hasattrr	rrr�append�f_back�reverse�
_exception�
__traceback__�tb_frame�tb_next)r
�limitZframes�f�tbr
r
r�_task_get_stacks6





rcCs�g}t�}|j|d�D]Z}|j}|j}|j}|j}	||krN|�|�t�|�t�	|||j
�}
|�|||	|
f�q|j}|s�t
d|��|d�n2|dk	r�t
d|�d�|d�nt
d|�d�|d�tj||d�|dk	r�t�|j|�D]}
t
|
|dd�q�dS)	N)rz
No stack for )�filezTraceback for z (most recent call last):z
Stack for �)r�end)�setZ	get_stack�f_lineno�f_code�co_filename�co_name�add�	linecache�
checkcache�getline�	f_globalsrr�print�	traceback�
print_list�format_exception_only�	__class__)r
rr�extracted_list�checkedr�lineno�co�filename�name�line�excr
r
r�_task_print_stack<s,

r9)r(r-r rrrrr9r
r
r
r�<module>s#PK
0�\�ar�$�$base_subprocess.cpython-38.pycnu�[���U

e5d�"�@sxddlZddlZddlZddlmZddlmZddlmZGdd�dej�Z	Gdd	�d	ej
�ZGd
d�deej�Z
dS)�N�)�	protocols)�
transports)�loggercs�eZdZd0�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jfdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z�ZS)1�BaseSubprocessTransportNc
	s&t��|
�d|_||_||_d|_d|_d|_g|_t	�
�|_i|_d|_
|tjkr`d|jd<|tjkrtd|jd<|tjkr�d|jd<z"|jf||||||d�|��Wn|���YnX|jj|_|j|jd<|j���rt|ttf�r�|}n|d}t�d||j�|j�|�|	��dS)NFrr�)�args�shell�stdin�stdout�stderr�bufsize�
subprocesszprocess %r created: pid %s)�super�__init__�_closed�	_protocol�_loop�_proc�_pid�_returncode�
_exit_waiters�collections�deque�_pending_calls�_pipes�	_finishedr�PIPE�_start�close�pidZ_extra�	get_debug�
isinstance�bytes�strr�debugZcreate_task�_connect_pipes)
�self�loop�protocolrr	r
rrr
�waiterZextra�kwargsZprogram��	__class__��//usr/lib64/python3.8/asyncio/base_subprocess.pyrsL






��

�z BaseSubprocessTransport.__init__cCs|jjg}|jr|�d�|jdk	r6|�d|j���|jdk	rT|�d|j���n |jdk	rj|�d�n
|�d�|j�d�}|dk	r�|�d|j���|j�d�}|j�d	�}|dk	r�||kr�|�d
|j���n6|dk	r�|�d|j���|dk	�r|�d|j���d
�	d�
|��S)N�closedzpid=zreturncode=Zrunningznot startedrzstdin=rrzstdout=stderr=zstdout=zstderr=z<{}>� )r-�__name__r�appendrrr�get�pipe�format�join)r'�infor
rrr.r.r/�__repr__7s,






z BaseSubprocessTransport.__repr__cKst�dS�N)�NotImplementedError)r'rr	r
rrr
r+r.r.r/rTszBaseSubprocessTransport._startcCs
||_dSr:�r)r'r)r.r.r/�set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<�r'r.r.r/�get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/�
is_closing]sz"BaseSubprocessTransport.is_closingcCs�|jr
dSd|_|j��D]}|dkr(q|j��q|jdk	r�|jdkr�|j��dkr�|j�	�rlt
�d|�z|j��Wnt
k
r�YnXdS)NTz$Close running child process: kill %r)rr�valuesr5rrrZpollrr!rZwarning�kill�ProcessLookupError)r'�protor.r.r/r`s$
��
zBaseSubprocessTransport.closecCs&|js"|d|��t|d�|��dS)Nzunclosed transport )�source)r�ResourceWarningr)r'Z_warnr.r.r/�__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/�get_pid�szBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/�get_returncode�sz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'�fdr.r.r/�get_pipe_transport�s
z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrt��dSr:)rrCr>r.r.r/�_check_proc�s
z#BaseSubprocessTransport._check_proccCs|��|j�|�dSr:)rLr�send_signal)r'�signalr.r.r/rM�sz#BaseSubprocessTransport.send_signalcCs|��|j��dSr:)rLr�	terminater>r.r.r/rO�sz!BaseSubprocessTransport.terminatecCs|��|j��dSr:)rLrrBr>r.r.r/rB�szBaseSubprocessTransport.killc	
�spz�j}�j}|jdk	rB|��fdd�|j�IdH\}}|�jd<|jdk	rv|��fdd�|j�IdH\}}|�jd<|jdk	r�|��fdd�|j�IdH\}}|�jd<�jdk	s�t	�|�
�jj���jD]\}}|j
|f|��q�d�_Wn\t
tfk
�r�Yn`tk
�rL}z"|dk	�r<|���s<|�|�W5d}~XYn X|dk	�rl|���sl|�d�dS)Ncs
t�d�S)Nr)�WriteSubprocessPipeProtor.r>r.r/�<lambda>��z8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>rcs
t�d�S)Nr��ReadSubprocessPipeProtor.r>r.r/rQ�rRrcs
t�d�S)NrrSr.r>r.r/rQ�rRr)rrr
Zconnect_write_piperrZconnect_read_piperr�AssertionError�	call_soonr�connection_made�
SystemExit�KeyboardInterrupt�
BaseException�	cancelledZ
set_exception�
set_result)	r'r*�procr(�_r5�callback�data�excr.r>r/r&�sB

�


�


�

z&BaseSubprocessTransport._connect_pipescGs2|jdk	r|j�||f�n|jj|f|��dSr:)rr3rrV)r'�cbr`r.r.r/�_call�s
zBaseSubprocessTransport._callcCs|�|jj||�|��dSr:)rcrZpipe_connection_lost�_try_finish)r'rJrar.r.r/�_pipe_connection_lost�sz-BaseSubprocessTransport._pipe_connection_lostcCs|�|jj||�dSr:)rcrZpipe_data_received)r'rJr`r.r.r/�_pipe_data_received�sz+BaseSubprocessTransport._pipe_data_receivedcCs�|dk	st|��|jdks$t|j��|j��r<t�d||�||_|jjdkrV||j_|�|j	j
�|��|jD]}|�
�sr|�|�qrd|_dS)Nz%r exited with return code %r)rUrrr!rr8r�
returncodercrZprocess_exitedrdrr[r\)r'rgr*r.r.r/�_process_exited�s

z'BaseSubprocessTransport._process_exitedc�s0|jdk	r|jS|j��}|j�|�|IdHS)zdWait until the process exit and return the process return code.

        This method is a coroutine.N)rrZ
create_futurerr3)r'r*r.r.r/�_wait�s


zBaseSubprocessTransport._waitcCsH|jr
t�|jdkrdStdd�|j��D��rDd|_|�|jd�dS)Ncss|]}|dk	o|jVqdSr:)�disconnected)�.0�pr.r.r/�	<genexpr>�s�z6BaseSubprocessTransport._try_finish.<locals>.<genexpr>T)rrUr�allrrArc�_call_connection_lostr>r.r.r/rd�s

�z#BaseSubprocessTransport._try_finishcCs*z|j�|�W5d|_d|_d|_XdSr:)rrr�connection_lost�r'rar.r.r/ro�s
z-BaseSubprocessTransport._call_connection_lost)NN)r2�
__module__�__qualname__rr9rr=r?r@r�warnings�warnrGrHrIrKrLrMrOrBr&rcrerfrhrirdro�
__classcell__r.r.r,r/r
s2�+&	rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rPcCs||_||_d|_d|_dS)NF)r]rJr5rj)r'r]rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs
||_dSr:)r5)r'Z	transportr.r.r/rWsz(WriteSubprocessPipeProto.connection_madecCs d|jj�d|j�d|j�d�S)N�<z fd=z pipe=�>)r-r2rJr5r>r.r.r/r9
sz!WriteSubprocessPipeProto.__repr__cCs d|_|j�|j|�d|_dS)NT)rjr]rerJrqr.r.r/rp
sz(WriteSubprocessPipeProto.connection_lostcCs|jj��dSr:)r]r�
pause_writingr>r.r.r/rysz&WriteSubprocessPipeProto.pause_writingcCs|jj��dSr:)r]r�resume_writingr>r.r.r/rzsz'WriteSubprocessPipeProto.resume_writingN)	r2rrrsrrWr9rpryrzr.r.r.r/rP�srPc@seZdZdd�ZdS)rTcCs|j�|j|�dSr:)r]rfrJ)r'r`r.r.r/�
data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rrrsr{r.r.r.r/rTsrT)rrrt�rr�logrZSubprocessTransportrZBaseProtocolrPZProtocolrTr.r.r.r/�<module>sv�PK
0�\�;j%%"windows_utils.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZddlZejdkred��ddlZddlZddlZddlZddlZddl	Z	ddl
Z
dZdZej
Z
ejZe��Zdded	�d
d�ZGdd
�d
�ZGdd�dej�ZdS)z)Various Windows specific bits and pieces.�NZwin32z
win32 only)�pipe�Popen�PIPE�
PipeHandlei F)TT)�duplex�
overlapped�bufsizec
Cs$tjd�t��tt��d�}|r>tj}tj	tj
B}||}}ntj}tj
}d|}}|tjO}|drp|tj
O}|dr�tj
}nd}d}	}
z\t�||tjd||tjtj�}	t�||dtjtj|tj�}
tj|	dd�}|�d�|	|
fWS|	dk	�rt�|	�|
dk	�rt�|
��YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�NT�r)�tempfileZmktemp�format�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ	PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2Zov�r�-/usr/lib64/python3.8/asyncio/windows_utils.pyr sb��


��





rc@sbeZdZdZdd�Zdd�Zedd��Zdd	�Ze	j
d
�dd�Zej
fd
d�Zdd�Zdd�ZdS)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like.

    The IOCP event loop can use these instead of socket objects.
    cCs
||_dS�N��_handle��self�handlerrr�__init__VszPipeHandle.__init__cCs2|jdk	rd|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r�	__class__�__name__rrrr�__repr__Ys
zPipeHandle.__repr__cCs|jSrr�rrrrr`szPipeHandle.handlecCs|jdkrtd��|jS)NzI/O operation on closed pipe)r�
ValueErrorr%rrr�filenods
zPipeHandle.fileno)rcCs|jdk	r||j�d|_dSrr)rrrrr�closeis

zPipeHandle.closecCs*|jdk	r&|d|��t|d�|��dS)Nz	unclosed )�source)r�ResourceWarningr()rZ_warnrrr�__del__ns
zPipeHandle.__del__cCs|Srrr%rrr�	__enter__sszPipeHandle.__enter__cCs|��dSr)r()r�t�v�tbrrr�__exit__vszPipeHandle.__exit__N)r#�
__module__�__qualname__�__doc__rr$�propertyrr'rrr(�warnings�warnr+r,r0rrrrrQs
rcs"eZdZdZd�fdd�	Z�ZS)rz�Replacement for subprocess.Popen using overlapped pipe handles.

    The stdin, stdout, stderr are None or instances of PipeHandle.
    Nc	sxd}}}d}	}
}|tkr@tddd�\}}	t�|tj�}n|}|tkrhtdd�\}
}
t�|
d�}n|}|tkr�tdd�\}}t�|d�}n|tkr�|}n|}z�z t�j	|f|||d�|��Wn0|	|
|fD]}|dk	r�t
�|�qւYn>X|	dk	�r
t|	�|_
|
dk	�rt|
�|_|dk	�r2t|�|_W5|tk�rJt�|�|tk�r^t�|�|tk�rrt�|�XdS)N)FTT)rr)TFrr)�stdin�stdout�stderr)rr�msvcrtZopen_osfhandler�O_RDONLY�STDOUTr(�superrrrrr7r8r9)r�argsr7r8r9�kwdsZ	stdin_rfdZ
stdout_wfdZ
stderr_wfdZstdin_whZ	stdout_rhZ	stderr_rhZstdin_rhZ	stdout_whZ	stderr_wh�h�r"rrr�sN��










zPopen.__init__)NNN)r#r1r2r3r�
__classcell__rrrArr}sr)r3�sys�platform�ImportErrorr�	itertoolsr:r�
subprocessrr5�__all__ZBUFSIZErr<�countrrrrrrrr�<module>s$
1,PK
0�\)��(&(&locks.cpython-38.opt-2.pycnu�[���U

e5d|C�@s�dZddlZddlZddlZddlmZddlmZddlmZddlmZGdd	�d	�Z	Gd
d�d�Z
Gdd
�d
e
�ZGdd�d�ZGdd�de
�Z
Gdd�de
�ZGdd�de�ZdS))�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�events)�futures)�
exceptions)�
coroutinesc@s$eZdZdd�Zdd�Zdd�ZdS)�_ContextManagercCs
||_dS�N)�_lock)�self�lock�r�%/usr/lib64/python3.8/asyncio/locks.py�__init__"sz_ContextManager.__init__cCsdSr
r�rrrr�	__enter__%sz_ContextManager.__enter__cGsz|j��W5d|_XdSr
)r�release�r�argsrrr�__exit__*sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__rrrrrrrrsrc@sReZdZdd�Zdd�Zejdd��Zej	e_	dd�Z
d	d
�Zdd�Zd
d�Z
dS)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeErrorrrrrr2s�z_ContextManagerMixin.__enter__cGsdSr
rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd�|��EdHt|�S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead���
stacklevel)�warnings�warn�DeprecationWarning�acquirerrrrr�__iter__;s�z_ContextManagerMixin.__iter__c�s|��IdHt|�Sr
)r%rrrrrZ
__acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd�|����S)Nz='with await lock' is deprecated use 'async with lock' insteadrr )r"r#r$�!_ContextManagerMixin__acquire_ctx�	__await__rrrrr(Ys
�z_ContextManagerMixin.__await__c�s|��IdHdSr
)r%rrrr�
__aenter__`sz_ContextManagerMixin.__aenter__c�s|��dSr
)r)r�exc_type�exc�tbrrr�	__aexit__fsz_ContextManagerMixin.__aexit__N)rrrrr�types�	coroutiner&rZ
_is_coroutiner'r(r)r-rrrrr1s
rcsJeZdZdd�dd�Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z�Z	S)rN��loopcCs:d|_d|_|dkr t��|_n||_tjdtdd�dS�NF�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.rr )�_waiters�_lockedr�get_event_loop�_loopr"r#r$�rr1rrrr�s�z
Lock.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S�	N�lockedZunlocked�
, waiters:�<r���� [�]>)�super�__repr__r5r4�len�r�resZextra��	__class__rrrA�s

z
Lock.__repr__cCs|jSr
)r5rrrrr:�szLock.lockedc	�s�|js.|jdks$tdd�|jD��r.d|_dS|jdkrBt��|_|j��}|j�|�z"z|IdHW5|j�|�XWn&t	j
k
r�|js�|���YnXd|_dS)Ncss|]}|��VqdSr
)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>T)r5r4�all�collections�dequer7�
create_future�append�remover
�CancelledError�_wake_up_first�r�futrrrr%�s&�


zLock.acquirecCs"|jrd|_|��ntd��dS)NFzLock is not acquired.)r5rRrrrrrr�s
zLock.releasecCsJ|js
dSztt|j��}Wntk
r2YdSX|��sF|�d�dS�NT)r4�next�iter�
StopIteration�done�
set_resultrSrrrrR�szLock._wake_up_first)
rrrrrAr:r%rrR�
__classcell__rrrErrjs6 rcsJeZdZdd�dd�Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z�Z	S)rNr0cCs>t��|_d|_|dkr$t��|_n||_tjdt	dd�dSr2)
rLrMr4�_valuerr6r7r"r#r$r8rrrrs
�zEvent.__init__csLt���}|jrdnd}|jr2|�dt|j���}d|dd��d|�d�S)	N�setZunsetr;r<rr=r>r?)r@rAr\r4rBrCrErrrAs

zEvent.__repr__cCs|jSr
�r\rrrr�is_setszEvent.is_setcCs.|js*d|_|jD]}|��s|�d�qdSrU)r\r4rYrZrSrrrr]s

z	Event.setcCs
d|_dS)NFr^rrrr�clear"szEvent.clearc	�sF|jr
dS|j��}|j�|�z|IdHW�dS|j�|�XdSrU)r\r7rNr4rOrPrSrrr�wait(s

z
Event.wait)
rrrrrAr_r]r`rar[rrrErr�s	rcsNeZdZddd�dd�Z�fdd�Zdd�Zd	d
�Zddd
�Zdd�Z�Z	S)rNr0cCs~|dkrt��|_n||_tjdtdd�|dkr>t|d�}n|j|jk	rRtd��||_|j	|_	|j
|_
|j|_t�
�|_dS)Nr3rr r0z"loop argument must agree with lock)rr6r7r"r#r$r�
ValueErrorrr:r%rrLrMr4)rrr1rrrrEs �zCondition.__init__csNt���}|��rdnd}|jr4|�dt|j���}d|dd��d|�d�Sr9)r@rAr:r4rBrCrErrrA[s

zCondition.__repr__c�s�|��std��|��z@|j��}|j�	|�z|IdHW�W�dS|j�
|�XW5d}z|��IdHWq�Wq^tjk
r�d}Yq^Xq^|r�tj�XdS)Nzcannot wait on un-acquired lockFT)r:rrr%r
rQr7rNr4rOrP)rrGrTrrrrabs$

zCondition.waitc�s$|�}|s |��IdH|�}q|Sr
)ra)rZ	predicate�resultrrr�wait_for�s
zCondition.wait_forrcCsJ|��std��d}|jD]*}||kr*qF|��s|d7}|�d�qdS)Nz!cannot notify on un-acquired lockrrF)r:rr4rYrZ)r�n�idxrTrrr�notify�s
zCondition.notifycCs|�t|j��dSr
)rgrBr4rrrr�
notify_all�szCondition.notify_all)N)r)
rrrrrArardrgrhr[rrrErr;s
%
rcsLeZdZddd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z�Z	S)rrNr0cCsN|dkrtd��||_t��|_|dkr4t��|_n||_tj	dt
dd�dS)Nrz$Semaphore initial value must be >= 0r3rr )rbr\rLrMr4rr6r7r"r#r$�r�valuer1rrrr�s
�zSemaphore.__init__csVt���}|��rdn
d|j��}|jr<|�dt|j���}d|dd��d|�d�S)	Nr:zunlocked, value:r;r<rr=r>r?)r@rAr:r\r4rBrCrErrrA�s

zSemaphore.__repr__cCs,|jr(|j��}|��s|�d�dSqdSr
)r4�popleftrYrZ)rZwaiterrrr�
_wake_up_next�s


zSemaphore._wake_up_nextcCs
|jdkS)Nrr^rrrrr:�szSemaphore.lockedc�st|jdkrb|j��}|j�|�z|IdHWq|��|jdkrX|��sX|���YqXq|jd8_dS)NrrT)r\r7rNr4rOZcancelrGrlrSrrrr%�s	


zSemaphore.acquirecCs|jd7_|��dS)Nr)r\rlrrrrr�szSemaphore.release)r)
rrrrrArlr:r%rr[rrrErr�s
rcs0eZdZddd��fdd�Z�fdd�Z�ZS)	rrNr0cs.|rtjdtdd�||_t�j||d�dS)Nr3rr r0)r"r#r$�_bound_valuer@rrirErrr
s�zBoundedSemaphore.__init__cs"|j|jkrtd��t���dS)Nz(BoundedSemaphore released too many times)r\rmrbr@rrrErrrszBoundedSemaphore.release)r)rrrrrr[rrrErrs	r)�__all__rLr.r"�rr	r
rrrrrrrrrrrr�<module>s"9DzNPK
0�\i�.CHHqueues.cpython-38.opt-2.pycnu�[���U

e5d �@s�dZddlZddlZddlZddlmZddlmZGdd�de�ZGdd	�d	e�Z	Gd
d�d�Z
Gdd
�d
e
�ZGdd�de
�ZdS))�Queue�
PriorityQueue�	LifoQueue�	QueueFull�
QueueEmpty�N�)�events)�locksc@seZdZdS)rN��__name__�
__module__�__qualname__�rr�&/usr/lib64/python3.8/asyncio/queues.pyrsrc@seZdZdS)rNr
rrrrrsrc@s�eZdZd(dd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zedd��Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�ZdS))rrN��loopcCsp|dkrt��|_n||_tjdtdd�||_t��|_	t��|_
d|_tj
|d�|_|j��|�|�dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.�)�
stacklevelrr)rZget_event_loop�_loop�warnings�warn�DeprecationWarning�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr	ZEvent�	_finished�set�_init)�self�maxsizerrrr�__init__!s�


zQueue.__init__cCst��|_dS�N)rr�_queue�r!r"rrrr 6szQueue._initcCs
|j��Sr$)r%�popleft�r!rrr�_get9sz
Queue._getcCs|j�|�dSr$�r%�append�r!�itemrrr�_put<sz
Queue._putcCs&|r"|��}|��s|�d�q"qdSr$)r'ZdoneZ
set_result)r!�waitersZwaiterrrr�_wakeup_nextAs

zQueue._wakeup_nextcCs(dt|�j�dt|�d�d|���d�S)N�<z at z#x� �>)�typer�id�_formatr(rrr�__repr__IszQueue.__repr__cCsdt|�j�d|���d�S)Nr1r2r3)r4rr6r(rrr�__str__Lsz
Queue.__str__cCs~d|j��}t|dd�r,|dt|j���7}|jrH|dt|j��d�7}|jrd|dt|j��d�7}|jrz|d|j��7}|S)Nzmaxsize=r%z _queue=z
 _getters[�]z
 _putters[z tasks=)r�getattr�listr%r�lenrr)r!�resultrrrr6Osz
Queue._formatcCs
t|j�Sr$)r<r%r(rrr�qsize[szQueue.qsizecCs|jSr$)rr(rrrr"_sz
Queue.maxsizecCs|jSr$�r%r(rrr�emptydszQueue.emptycCs |jdkrdS|��|jkSdS)NrF)rr>r(rrr�fullhs
z
Queue.fullc�s�|��r�|j��}|j�|�z|IdHWq|��z|j�|�Wntk
r`YnX|��s~|��s~|�	|j��YqXq|�
|�Sr$)rAr�
create_futurerr+�cancel�remove�
ValueError�	cancelledr0�
put_nowait)r!r-Zputterrrr�putss

z	Queue.putcCs>|��rt�|�|�|jd7_|j��|�|j�dS)Nr)rArr.rr�clearr0rr,rrrrG�s

zQueue.put_nowaitc�s�|��r�|j��}|j�|�z|IdHWq|��z|j�|�Wntk
r`YnX|��s~|��s~|�	|j��YqXq|�
�Sr$)r@rrBrr+rCrDrErFr0�
get_nowait)r!�getterrrr�get�s

z	Queue.getcCs$|��rt�|��}|�|j�|Sr$)r@rr)r0rr,rrrrJ�s
zQueue.get_nowaitcCs8|jdkrtd��|jd8_|jdkr4|j��dS)Nrz!task_done() called too many timesr)rrErrr(rrr�	task_done�s


zQueue.task_donec�s|jdkr|j��IdHdS)Nr)rr�waitr(rrr�join�s
z
Queue.join)r)rrr
r#r r)r.r0r7r8r6r>�propertyr"r@rArHrGrLrJrMrOrrrrrs&
rc@s0eZdZdd�Zejfdd�Zejfdd�ZdS)rcCs
g|_dSr$r?r&rrrr �szPriorityQueue._initcCs||j|�dSr$r?)r!r-�heappushrrrr.�szPriorityQueue._putcCs
||j�Sr$r?)r!�heappoprrrr)�szPriorityQueue._getN)	rrr
r �heapqrQr.rRr)rrrrr�src@s$eZdZdd�Zdd�Zdd�ZdS)rcCs
g|_dSr$r?r&rrrr �szLifoQueue._initcCs|j�|�dSr$r*r,rrrr.�szLifoQueue._putcCs
|j��Sr$)r%�popr(rrrr)�szLifoQueue._getN)rrr
r r.r)rrrrr�sr)
�__all__rrSr�rr	�	Exceptionrrrrrrrrr�<module>sKPK
0�\r׉nn!base_futures.cpython-38.opt-2.pycnu�[���U

e5d
�@sRdZddlZddlmZddlmZdZdZdZd	d
�Z	dd�Z
e�Zd
d�Z
dS)��N)�	get_ident�)�format_helpersZPENDINGZ	CANCELLEDZFINISHEDcCst|jd�o|jdk	S)N�_asyncio_future_blocking)�hasattr�	__class__r)�objrr�,/usr/lib64/python3.8/asyncio/base_futures.py�isfutures�rcCs�t|�}|sd}dd�}|dkr2||dd�}n`|dkr`d�||dd�||dd��}n2|dkr�d�||dd�|d||d	d��}d
|�d�S)N�cSst�|d�S)Nr)rZ_format_callback_source)�callbackrrr
�	format_cbsz$_format_callbacks.<locals>.format_cbrr�z{}, {}z{}, <{} more>, {}���zcb=[�])�len�format)�cb�sizerrrr
�_format_callbackss&�rc	Cs�|j��g}|jtkr�|jdk	r4|�d|j���nTt|�t�f}|tkrPd}n(t�|�zt
�|j�}W5t�	|�X|�d|���|j
r�|�t|j
��|jr�|jd}|�d|d�d|d���|S)	Nz
exception=z...zresult=rzcreated at r�:r)Z_state�lower�	_FINISHEDZ
_exception�append�idr�
_repr_running�add�discard�reprlib�reprZ_resultZ
_callbacksrZ_source_traceback)Zfuture�info�key�result�framerrr
�_future_repr_info7s$



r%)�__all__r�_threadrrrZ_PENDINGZ
_CANCELLEDrrr�setrr%rrrr
�<module>sPK
0�\@c.�
	
	log.cpython-38.opt-1.pycnu�[���U

e5d��@sldZdZdZdZdZdZddlZGdd	�d	�Ze�Zej	Z	ej
Z
ejZejZej
Z
ejZd
d�Zdd
�ZdS)z,A simple log mechanism styled after PEP 282.������Nc@sPeZdZefdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�LogcCs
||_dS�N)�	threshold)�selfr	�r�%/usr/lib64/python3.8/distutils/log.py�__init__szLog.__init__cCs�|tttttfkr"tdt|���||jkr�|r8||}|tttfkrNtj	}ntj
}z|�d|�Wn:tk
r�|j
}|�|d��|�}|�d|�YnX|��dS)Nz%s wrong log levelz%s
�backslashreplace)�DEBUG�INFO�WARN�ERROR�FATAL�
ValueError�strr	�sys�stderr�stdout�write�UnicodeEncodeError�encoding�encode�decode�flush)r
�level�msg�args�streamrrrr�_logs
zLog._logcGs|�|||�dSr)r#)r
rr r!rrr�log'szLog.logcGs|�t||�dSr)r#r�r
r r!rrr�debug*sz	Log.debugcGs|�t||�dSr)r#rr%rrr�info-szLog.infocGs|�t||�dSr)r#rr%rrr�warn0szLog.warncGs|�t||�dSr)r#rr%rrr�error3sz	Log.errorcGs|�t||�dSr)r#rr%rrr�fatal6sz	Log.fatalN)�__name__�
__module__�__qualname__rr
r#r$r&r'r(r)r*rrrrrsrcCstj}|t_|Sr)�_global_logr	)r�oldrrr�
set_thresholdAsr0cCs8|dkrtt�n"|dkr$tt�n|dkr4tt�dS)Nrrr)r0rrr)�vrrr�
set_verbosityGs

r2)�__doc__rrrrrrrr.r$r&r'r(r)r*r0r2rrrr�<module>s +PK
0�\ߋ�ѢP�Pstreams.cpython-38.pycnu�[���U

e5d h�@s&dZddlZddlZddlZddlZeed�r6ed7ZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZd
Zdded�dd�Zd ded�dd�Zeed�r�d!ded�dd�Zd"ded�dd�ZGdd�dej�ZGdd�deej�ZGdd�d�ZGdd�d�ZdS)#)�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�NZAF_UNIX)�open_unix_connection�start_unix_server�)�
coroutines)�events)�
exceptions)�format_helpers)�	protocols)�logger)�sleepi)�loop�limitc	�st|dkrt��}ntjdtdd�t||d�}t||d��|j�fdd�||f|�IdH\}}t|�||�}||fS)	a�A wrapper for create_connection() returning a (reader, writer) pair.

    The reader returned is a StreamReader instance; the writer is a
    StreamWriter instance.

    The arguments are all the usual arguments to create_connection()
    except protocol_factory; most common are positional host and port,
    with various optional keyword arguments following.

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    (If you want to customize the StreamReader and/or
    StreamReaderProtocol classes, just copy the code -- there's
    really nothing special here except some convenience.)
    N�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.���
stacklevel�rr�rcs�S�N�r��protocolr�'/usr/lib64/python3.8/asyncio/streams.py�<lambda>5�z!open_connection.<locals>.<lambda>)	r�get_event_loop�warnings�warn�DeprecationWarningrrZcreate_connectionr)	�host�portrr�kwds�reader�	transport�_�writerrrrrs"
�
��rc�sJ�dkrt���ntjdtdd����fdd�}�j|||f|�IdHS)a�Start a socket server, call back for each client connected.

    The first parameter, `client_connected_cb`, takes two parameters:
    client_reader, client_writer.  client_reader is a StreamReader
    object, while client_writer is a StreamWriter object.  This
    parameter can either be a plain callback function or a coroutine;
    if it is a coroutine, it will be automatically converted into a
    Task.

    The rest of the arguments are all the usual arguments to
    loop.create_server() except protocol_factory; most common are
    positional host and port, with various optional keyword arguments
    following.  The return value is the same as loop.create_server().

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    The return value is the same as loop.create_server(), i.e. a
    Server object which can be used to stop the service.
    Nrrrcst��d�}t|��d�}|S�Nrr�rr�r'r��client_connected_cbrrrr�factoryXs
�zstart_server.<locals>.factory)rr r!r"r#Z
create_server)r/r$r%rrr&r0rr.rr:s
�rc�sr|dkrt��}ntjdtdd�t||d�}t||d��|j�fdd�|f|�IdH\}}t|�||�}||fS)	z@Similar to `open_connection` but works with UNIX Domain Sockets.Nrrrrrcs�Srrrrrrrprz&open_unix_connection.<locals>.<lambda>)	rr r!r"r#rrZcreate_unix_connectionr)�pathrrr&r'r(r)r*rrrrds 
�
��rc�sH�dkrt���ntjdtdd����fdd�}�j||f|�IdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Nrrrcst��d�}t|��d�}|Sr+r,r-r.rrr0~s
�z"start_unix_server.<locals>.factory)rr r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts
�rc@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�FlowControlMixina)Reusable flow control logic for StreamWriter.drain().

    This implements the protocol methods pause_writing(),
    resume_writing() and connection_lost().  If the subclass overrides
    these it must call the super methods.

    StreamWriter.drain() must wait for _drain_helper() coroutine.
    NcCs0|dkrt��|_n||_d|_d|_d|_dS�NF)rr �_loop�_paused�
_drain_waiter�_connection_lost)�selfrrrr�__init__�szFlowControlMixin.__init__cCs*|jr
t�d|_|j��r&t�d|�dS)NTz%r pauses writing)r5�AssertionErrorr4�	get_debugr�debug�r8rrr�
pause_writing�s

zFlowControlMixin.pause_writingcCsP|js
t�d|_|j��r&t�d|�|j}|dk	rLd|_|��sL|�d�dS)NFz%r resumes writing)	r5r:r4r;rr<r6�done�
set_result�r8�waiterrrr�resume_writing�s

zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|��r4dS|dkrH|�d�n
|�|�dS�NT)r7r5r6r?r@�
set_exception�r8�excrBrrr�connection_lost�sz FlowControlMixin.connection_lostc�sP|jrtd��|jsdS|j}|dks2|��s2t�|j��}||_|IdHdS)NzConnection lost)r7�ConnectionResetErrorr5r6�	cancelledr:r4�
create_futurerArrr�
_drain_helper�s
zFlowControlMixin._drain_helpercCst�dSr)�NotImplementedError�r8�streamrrr�_get_close_waiter�sz"FlowControlMixin._get_close_waiter)N)
�__name__�
__module__�__qualname__�__doc__r9r>rCrHrLrPrrrrr2�s	
	r2csfeZdZdZdZd�fdd�	Zedd��Zdd�Z�fd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
�ZS)ra=Helper class to adapt between Protocol and StreamReader.

    (This is a helper class instead of making StreamReader itself a
    Protocol subclass, because the StreamReader has other potential
    uses, and to prevent the user of the StreamReader to accidentally
    call inappropriate methods of the protocol.)
    Ncsnt�j|d�|dk	r,t�|�|_|j|_nd|_|dk	r@||_d|_d|_d|_	||_
d|_|j�
�|_dS)NrF)�superr9�weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer�
_transport�_client_connected_cb�	_over_sslr4rK�_closed)r8Z
stream_readerr/r��	__class__rrr9�s
zStreamReaderProtocol.__init__cCs|jdkrdS|��Sr)rXr=rrr�_stream_reader�s
z#StreamReaderProtocol._stream_readercCs�|jr6ddi}|jr|j|d<|j�|�|��dS||_|j}|dk	rT|�|�|�d�dk	|_	|j
dk	r�t||||j�|_|�
||j�}t
�|�r�|j�|�d|_dS)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ
sslcontext)r[rYr4Zcall_exception_handler�abortr]rc�
set_transport�get_extra_infor_r^rr\r
ZiscoroutineZcreate_taskrZ)r8r(�contextr'�resrrr�connection_made�s2�


��
z$StreamReaderProtocol.connection_madecsx|j}|dk	r*|dkr |��n
|�|�|j��sV|dkrJ|j�d�n|j�|�t��|�d|_d|_	d|_
dSr)rc�feed_eofrEr`r?r@rUrHrXr\r])r8rGr'rarrrH
s


z$StreamReaderProtocol.connection_lostcCs|j}|dk	r|�|�dSr)rc�	feed_data)r8�datar'rrr�
data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk	r|��|jr dSdS)NFT)rcrkr_)r8r'rrr�eof_received sz!StreamReaderProtocol.eof_receivedcCs|jSr)r`rNrrrrP+sz&StreamReaderProtocol._get_close_waitercCs"|j}|��r|��s|��dSr)r`r?rJ�	exception)r8�closedrrr�__del__.szStreamReaderProtocol.__del__)NN)rQrRrSrTrYr9�propertyrcrjrHrnrorPrr�
__classcell__rrrarr�s
rc@sveZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zddd�Zdd�ZdS)ra'Wraps a Transport.

    This exposes write(), writelines(), [can_]write_eof(),
    get_extra_info() and close().  It adds drain() which returns an
    optional Future on which you can wait for flow control.  It also
    adds a transport property which references the Transport
    directly.
    cCsJ||_||_|dks"t|t�s"t�||_||_|j��|_|j�	d�dSr)
r]�	_protocol�
isinstancerr:�_readerr4rKZ
_complete_futr@)r8r(rr'rrrrr9@szStreamWriter.__init__cCs@|jjd|j��g}|jdk	r0|�d|j���d�d�|��S)N�
transport=zreader=�<{}>� )rbrQr]rw�append�format�join�r8�inforrr�__repr__Js
zStreamWriter.__repr__cCs|jSr)r]r=rrrr(PszStreamWriter.transportcCs|j�|�dSr)r]�write�r8rmrrrr�TszStreamWriter.writecCs|j�|�dSr)r]�
writelinesr�rrrr�WszStreamWriter.writelinescCs
|j��Sr)r]�	write_eofr=rrrr�ZszStreamWriter.write_eofcCs
|j��Sr)r]�
can_write_eofr=rrrr�]szStreamWriter.can_write_eofcCs
|j��Sr)r]�closer=rrrr�`szStreamWriter.closecCs
|j��Sr)r]�
is_closingr=rrrr�cszStreamWriter.is_closingc�s|j�|�IdHdSr)rurPr=rrr�wait_closedfszStreamWriter.wait_closedNcCs|j�||�Sr)r]rg)r8�name�defaultrrrrgiszStreamWriter.get_extra_infoc�sL|jdk	r |j��}|dk	r |�|j��r8td�IdH|j��IdHdS)zyFlush the write buffer.

        The intended use is to write

          w.write(data)
          await w.drain()
        Nr)rwrpr]r�rrurL)r8rGrrr�drainls



zStreamWriter.drain)N)rQrRrSrTr9r�rsr(r�r�r�r�r�r�r�rgr�rrrrr6s	


rc@s�eZdZdZedfdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd&dd�Zd'dd�Zd d!�Zd"d#�Zd$d%�ZdS)(rNcCsv|dkrtd��||_|dkr*t��|_n||_t�|_d|_d|_d|_	d|_
d|_|j��rrt
�t�d��|_dS)NrzLimit cannot be <= 0Fr	)�
ValueError�_limitrr r4�	bytearray�_buffer�_eof�_waiter�
_exceptionr]r5r;r
�
extract_stack�sys�	_getframerY)r8rrrrrr9�s 
�zStreamReader.__init__cCs�dg}|jr"|�t|j��d��|jr2|�d�|jtkrN|�d|j���|jrf|�d|j���|jr~|�d|j���|jr�|�d|j���|j	r�|�d�d	�
d
�|��S)Nrz bytes�eofzlimit=zwaiter=z
exception=rxZpausedryrz)r�r{�lenr�r��_DEFAULT_LIMITr�r�r]r5r|r}r~rrrr��s 


zStreamReader.__repr__cCs|jSr)r�r=rrrrp�szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|��s,|�|�dSr)r�r�rJrErFrrrrE�szStreamReader.set_exceptioncCs*|j}|dk	r&d|_|��s&|�d�dS)z1Wakeup read*() functions waiting for data or EOF.N)r�rJr@rArrr�_wakeup_waiter�s
zStreamReader._wakeup_waitercCs|jdkstd��||_dS)NzTransport already set)r]r:)r8r(rrrrf�szStreamReader.set_transportcCs*|jr&t|j�|jkr&d|_|j��dSr3)r5r�r�r�r]�resume_readingr=rrr�_maybe_resume_transport�sz$StreamReader._maybe_resume_transportcCsd|_|��dSrD)r�r�r=rrrrk�szStreamReader.feed_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)r�r�r=rrr�at_eof�szStreamReader.at_eofcCs�|jrtd��|sdS|j�|�|��|jdk	r~|js~t|j�d|jkr~z|j�	�Wnt
k
rvd|_YnXd|_dS)Nzfeed_data after feed_eofrT)r�r:r��extendr�r]r5r�r�Z
pause_readingrMr�rrrrl�s
��zStreamReader.feed_datac�sf|jdk	rt|�d���|jr&td��|jr<d|_|j��|j��|_z|jIdHW5d|_XdS)zpWait until feed_data() or feed_eof() is called.

        If stream was paused, automatically resume it.
        NzF() called while another coroutine is already waiting for incoming dataz_wait_for_data after EOFF)	r��RuntimeErrorr�r:r5r]r�r4rK)r8Z	func_namerrr�_wait_for_data�s	
�
zStreamReader._wait_for_datac
�s�d}t|�}z|�|�IdH}Wn�tjk
rN}z|jWY�Sd}~XYnhtjk
r�}zH|j�||j�r�|jd|j|�=n
|j�	�|�
�t|jd��W5d}~XYnX|S)a�Read chunk of data from the stream until newline (b'
') is found.

        On success, return chunk that ends with newline. If only partial
        line can be read due to EOF, return incomplete line without
        terminating newline. When EOF was reached while no bytes read, empty
        bytes object is returned.

        If limit is reached, ValueError will be raised. In that case, if
        newline was found, complete line including newline will be removed
        from internal buffer. Else, internal buffer will be cleared. Limit is
        compared against part of the line without newline.

        If stream was paused, this function will automatically resume it if
        needed.
        �
Nr)
r��	readuntilr�IncompleteReadError�partial�LimitOverrunErrorr��
startswith�consumed�clearr�r��args)r8�sep�seplen�line�errr�readline	s
 zStreamReader.readliner�c�s�t|�}|dkrtd��|jdk	r(|j�d}t|j�}|||kr||j�||�}|dkrZq�|d|}||jkr|t�d|��|jr�t	|j�}|j�
�t�|d��|�d�IdHq,||jkr�t�d|��|jd||�}|jd||�=|�
�t	|�S)	aVRead data from the stream until ``separator`` is found.

        On success, the data and separator will be removed from the
        internal buffer (consumed). Returned data will include the
        separator at the end.

        Configured stream limit is used to check result. Limit sets the
        maximal length of data that can be returned, not counting the
        separator.

        If an EOF occurs and the complete separator is still not found,
        an IncompleteReadError exception will be raised, and the internal
        buffer will be reset.  The IncompleteReadError.partial attribute
        may contain the separator partially.

        If the data cannot be read because of over limit, a
        LimitOverrunError exception  will be raised, and the data
        will be left in the internal buffer, so it can be read again.
        rz,Separator should be at least one-byte stringN���r	z2Separator is not found, and chunk exceed the limitr�z2Separator is found, but chunk is longer than limit)r�r�r�r��findr�rr�r��bytesr�r�r�r�)r8Z	separatorr��offsetZbuflenZisep�chunkrrrr�(s>


�


�zStreamReader.readuntilr�c�s�|jdk	r|j�|dkrdS|dkrVg}|�|j�IdH}|s@qL|�|�q(d�|�S|jsr|jsr|�d�IdHt|jd|��}|jd|�=|�	�|S)a�Read up to `n` bytes from the stream.

        If n is not provided, or set to -1, read until EOF and return all read
        bytes. If the EOF was received and the internal buffer is empty, return
        an empty bytes object.

        If n is zero, return empty bytes object immediately.

        If n is positive, this function try to read `n` bytes, and may return
        less or equal bytes than requested, but at least one byte. If EOF was
        received before any byte is read, this function returns empty byte
        object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        Nrr�read)
r�r�r�r{r}r�r�r�r�r�)r8�nZblocks�blockrmrrrr��s"

zStreamReader.readc�s�|dkrtd��|jdk	r |j�|dkr,dSt|j�|krr|jr`t|j�}|j��t�||��|�	d�IdHq,t|j�|kr�t|j�}|j��nt|jd|��}|jd|�=|�
�|S)a�Read exactly `n` bytes.

        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.

        if n is zero, return empty bytes object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        rz*readexactly size can not be less than zeroNr�readexactly)r�r�r�r�r�r�r�rr�r�r�)r8r�Z
incompletermrrrr��s&



zStreamReader.readexactlycCs|Srrr=rrr�	__aiter__�szStreamReader.__aiter__c�s|��IdH}|dkrt�|S)Nr)r��StopAsyncIteration)r8�valrrr�	__anext__�szStreamReader.__anext__)r�)r�)rQrRrSrYr�r9r�rprEr�rfr�rkr�rlr�r�r�r�r�r�r�rrrrr�s$	
[
2)r)NN)NN)N)N)�__all__Zsocketr�r!rV�hasattr�r
rrr
r�logrZtasksrr�rrrrZProtocolr2rrrrrrr�<module>sF
�!�'
��DkPPK
0�\�?�`��runners.cpython-38.opt-2.pycnu�[���U

e5d�@sBdZddlmZddlmZddlmZdd�dd�Zd	d
�ZdS))�run�)�
coroutines)�events)�tasksN)�debugcCs�t��dk	rtd��t�|�s,td�|���t��}z*t�|�|dk	rR|�
|�|�|�W�Szt
|�|�|���W5t�d�|�	�XXdS)Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop�RuntimeErrorrZiscoroutine�
ValueError�formatZnew_event_loopZset_event_loop�close�_cancel_all_tasks�run_until_completeZshutdown_asyncgensZ	set_debug)�mainr�loop�r�'/usr/lib64/python3.8/asyncio/runners.pyrs"�



rcCsvt�|�}|sdS|D]}|��q|�tj||dd���|D]0}|��rNq@|��dk	r@|�d|��|d��q@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)�message�	exception�task)rZ	all_tasksZcancelrZgatherZ	cancelledrZcall_exception_handler)rZ	to_cancelrrrrr6s"

��r)�__all__�rrrrrrrrr�<module>s
.PK
0�\ft�,S^S^proactor_events.cpython-38.pycnu�[���U

e5d<}�@sTdZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
dd	l	mZdd
l	mZddl	mZddl	mZdd
lmZdd�ZGdd�dejej�ZGdd�deej�ZGdd�deej�ZGdd�de�ZGdd�de�ZGdd�deeej�ZGdd�deeej�Z Gdd�de
j!�Z"dS) z�Event loop using a proactor and related classes.

A proactor is a "notify-on-completion" multiplexer.  Currently a
proactor is only implemented on Windows with IOCP.
)�BaseProactorEventLoop�N�)�base_events)�	constants)�futures)�
exceptions)�	protocols)�sslproto)�
transports)�trsock)�loggercCs�t�|�|jd<z|��|jd<Wn0tjk
rR|j��rNtj	d|dd�YnXd|jkr�z|�
�|jd<Wn tjk
r�d|jd<YnXdS)N�socketZsocknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extraZgetsocknamer
�error�_loop�	get_debugr�warningZgetpeername)�	transport�sock�r�//usr/lib64/python3.8/asyncio/proactor_events.py�_set_socket_extras
�
rcs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejfdd�Z
ddd�Zdd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncs�t��||�|�|�||_|�|�||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	rl|j�
�|j�|jj|�|dk	r�|j�tj|d�dS)NrF)�super�__init__�
_set_extra�_sock�set_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_eof_writtenZ_attachr�	call_soon�	_protocolZconnection_maderZ_set_result_unless_cancelled��self�loopr�protocol�waiter�extra�server��	__class__rrr2s(




�z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdkr |�d�n|jr0|�d�|jdk	rP|�d|j�����|jdk	rl|�d|j���|jdk	r�|�d|j���|jr�|�dt	|j����|j
r�|�d�d�d	�|��S)
N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� )
r4�__name__r �appendr(�filenor$r%r#�lenr)�format�join)r-�inforrr�__repr__Hs 






z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)r�r-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs
||_dS�N�r+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrC�r-rrr�get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr�
is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr
dSd|_|jd7_|js>|jdkr>|j�|jd�|jdk	rX|j��d|_dS)NTr)	r(r'r#r%rr*�_call_connection_lostr$�cancelrDrrr�closefs

z _ProactorBasePipeTransport.closecCs*|jdk	r&|d|��t|d�|��dS)Nzunclosed transport )�source)r �ResourceWarningrI)r-Z_warnrrr�__del__qs
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportc	CsVzDt|t�r*|j��rBtjd||dd�n|j�||||jd��W5|�|�XdS)Nz%r: %sTr)�message�	exceptionrr/)	�_force_close�
isinstance�OSErrorrrr�debug�call_exception_handlerr+)r-�excrNrrr�_fatal_errorvs

�z'_ProactorBasePipeTransport._fatal_errorcCs�|jdk	r6|j��s6|dkr*|j�d�n|j�|�|jr@dSd|_|jd7_|jrj|j��d|_|jr�|j��d|_d|_	d|_
|j�|j
|�dS)NTrr)�
_empty_waiter�done�
set_resultZ
set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrP�s"

z'_ProactorBasePipeTransport._force_closec	Cs^z|j�	|�W5t|jd�r,|j�tj�|j��d|_|j}|dk	rX|��d|_XdS)N�shutdown)
�hasattrr rZr
Z	SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrG�s
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk	r|t|j�7}|SrB)r&r#r;)r-�sizerrr�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8�
__module__�__qualname__�__doc__rr?rr!rErFrI�warnings�warnrLrVrPrGr]�
__classcell__rrr3rr.s �
rcsTeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
�ZS)�_ProactorReadPipeTransportzTransport for read pipes.Ncs:d|_d|_t��||||||�|j�|j�d|_dS)NTF)�
_pending_data�_pausedrrrr*�
_loop_readingr,r3rrr�s
z#_ProactorReadPipeTransport.__init__cCs|jo|jSrB)rfr(rDrrr�
is_reading�sz%_ProactorReadPipeTransport.is_readingcCs0|js|jrdSd|_|j��r,t�d|�dS)NTz%r pauses reading)r(rfrrrrSrDrrr�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsn|js|jsdSd|_|jdkr0|j�|jd�|j}d|_|dk	rT|j�|j|�|j��rjt	�
d|�dS)NFz%r resumes reading)r(rfr$rr*rgre�_data_receivedrrrS�r-�datarrr�resume_reading�s

z)_ProactorReadPipeTransport.resume_readingc
Cs�|j��rt�d|�z|j��}WnLttfk
r>�Yn4tk
rp}z|�	|d�WY�dSd}~XYnX|s~|�
�dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrrrSr+Zeof_received�
SystemExit�KeyboardInterrupt�
BaseExceptionrVrI)r-Z	keep_openrUrrr�
_eof_received�s
�z(_ProactorReadPipeTransport._eof_receivedc
Cs�|jr|jdkst�||_dS|s.|��dSt|jtj�r�zt�|j|�Wq�t	t
fk
rh�Yq�tk
r�}z|�|d�WY�dSd}~XYq�Xn|j�
|�dS)Nz3Fatal error: protocol.buffer_updated() call failed.)rfre�AssertionErrorrqrQr+rZBufferedProtocolZ_feed_data_to_buffered_protornrorprVZ
data_received)r-rlrUrrrrj�s$�z)_ProactorReadPipeTransport._data_receivedc
Cs�d}�zrz�|dk	rP|j|ks0|jdkr,|js0t�d|_|��rH|��}n|��|jrfd}WW��dS|dkrzWW��dS|js�|jj	�
|jd�|_Wn�tk
r�}z0|js�|�
|d�n|j��r�tjddd�W5d}~XYn�tk
�r}z|�|�W5d}~XYnftk
�r>}z|�
|d�W5d}~XYn8tjk
�r^|j�sZ�YnX|j�sv|j�|j�W5|dk	�r�|�|�XdS)N�i�z"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rjr$r(rrrX�resultrHrfr�	_proactor�recvr �ConnectionAbortedErrorrVrrrS�ConnectionResetErrorrPrRr�CancelledError�add_done_callbackrg)r-�futrlrUrrrrgsF�

�
z(_ProactorReadPipeTransport._loop_reading)NNN)N)r8r^r_r`rrhrirmrqrjrgrcrrr3rrd�s�	rdcs^eZdZdZdZ�fdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)�_ProactorBaseWritePipeTransportzTransport for write pipes.Tcst�j||�d|_dSrB)rrrW�r-�args�kwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCs�t|tttf�s$tdt|�j����|jr2td��|j	dk	rDtd��|sLdS|j
rz|j
tjkrht
�d�|j
d7_
dS|jdkr�|jdks�t�|jt|�d�n.|js�t|�|_|��n|j�|�|��dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rl)rQ�bytes�	bytearray�
memoryview�	TypeError�typer8r)�RuntimeErrorrWr'r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESrrr%r#rr�
_loop_writing�_maybe_pause_protocol�extendrkrrr�writeKs.�




z%_ProactorBaseWritePipeTransport.writeNc
Csx�z|dk	r"|jdkr"|jr"WdS||jks0t�d|_d|_|rH|��|dkr\|j}d|_|s�|jrv|j�|jd�|j	r�|j
�tj
�|��n\|jj�|j
|�|_|j��s�|jdks�t�t|�|_|j�|j�|��n|j�|j�|jdk	�r|jdk�r|j�d�Wn\tk
�rD}z|�|�W5d}~XYn0tk
�rr}z|�|d�W5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(rrr&rtr#rr*rGr)r rZr
�SHUT_WR�_maybe_resume_protocolru�sendrXr;rzr�r�rWrYrxrPrRrV)r-�frlrUrrrr�qs<



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS�NTrrDrrr�
can_write_eof�sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|��dSrB)rIrDrrr�	write_eof�sz)_ProactorBaseWritePipeTransport.write_eofcCs|�d�dSrB�rPrDrrr�abort�sz%_ProactorBaseWritePipeTransport.abortcCs:|jdk	rtd��|j��|_|jdkr4|j�d�|jS)NzEmpty waiter is already set)rWr�rZ
create_futurer%rYrDrrr�_make_empty_waiter�s

z2_ProactorBaseWritePipeTransport._make_empty_waitercCs
d|_dSrB)rWrDrrr�_reset_empty_waiter�sz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)r8r^r_r`Z_start_tls_compatiblerr�r�r�r�r�r�r�rcrrr3rr|As&
)r|cs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs4t�j||�|jj�|jd�|_|j�|j�dS)N�)	rrrrurvr r$rz�_pipe_closedr}r3rrr�sz$_ProactorWritePipeTransport.__init__cCsv|��rdS|��dkst�|jr4|jdks0t�dS||jksLt||jf��d|_|jdk	rj|�t��n|��dS)Nrs)	Z	cancelledrtrrr(r$r%rP�BrokenPipeErrorrI)r-r{rrrr��s
z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rr�rcrrr3rr��sr�csXeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	ddd�Z
�ZS)�_ProactorDatagramTransportiNcs>||_d|_t�j|||||d�t��|_|j�|j	�dS)N)r0r1)
�_addressrWrr�collections�dequer#rr*rg)r-r.rr/�addressr0r1r3rrr�s

z#_ProactorDatagramTransport.__init__cCst||�dSrB�rrArrrr�sz%_ProactorDatagramTransport._set_extracCstdd�|jD��S)Ncss|]\}}t|�VqdSrB)r;)�.0rl�_rrr�	<genexpr>�szC_ProactorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr#rDrrrr]�sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|�d�dSrBr�rDrrrr��sz _ProactorDatagramTransport.abortcCs�t|tttf�stdt|���|s&dS|jdk	rN|d|jfkrNtd|j����|jr�|jr�|jt	j
krpt�d�|jd7_dS|j
�t|�|f�|jdkr�|��|��dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQr�r�r�r�r�r��
ValueErrorr'rr�rrr#r9r%r�r�)r-rl�addrrrr�sendto�s&�
�

z!_ProactorDatagramTransport.sendtoc
Csz�|jrWdS||jkst�d|_|r.|��|jr@|jr\|jr\|jrV|j�|j	d�WdS|j�
�\}}|jdk	r�|jj�|j
|�|_n|jjj|j
||d�|_WnZtk
r�}z|j�|�W5d}~XYnDtk
r�}z|�|d�W5d}~XYnX|j�|j�|��dS)N)r�z'Fatal write error on datagram transport)r'r%rrrtr#r�r(rr*rG�popleftrur�r r�rRr+�error_received�	ExceptionrVrzr�r�)r-r{rlr�rUrrrr��s4
��z(_ProactorDatagramTransport._loop_writingc
CsVd}�z4z�|jrWW��$dS|j|ks:|jdkr6|js:t�d|_|dk	r�|��}|jrdd}WW��dS|jdk	r|||j}}n|\}}|jr�WW��dS|jdk	r�|jj	�
|j|j�|_n|jj	�
|j|j�|_WnNtk
r�}z|j�|�W5d}~XYn<tjk
�r|j�s�YnX|jdk	�r8|j�|j�W5|�rP|j�||�XdSrB)r+Zdatagram_receivedr'r$r(rrrtr�rrurvr �max_sizeZrecvfromrRr�rryrzrg)r-r{rlr��resrUrrrrgsD�



��
z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N)r8r^r_r�rrr]r�r�r�rgrcrrr3rr��s�

!r�c@s eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFrrDrrrr�Jsz*_ProactorDuplexPipeTransport.can_write_eofcCst�dSrB)�NotImplementedErrorrDrrrr�Msz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_r`r�r�rrrrr�Esr�csBeZdZdZejjZd�fdd�	Zdd�Z	dd�Z
d	d
�Z�ZS)�_ProactorSocketTransportz Transport for connected sockets.Ncs$t��||||||�t�|�dSrB)rrrZ_set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||�dSrBr�rArrrr]sz#_ProactorSocketTransport._set_extracCsdSr�rrDrrrr�`sz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdkr.|j�tj�dSr�)r(r)r%r rZr
r�rDrrrr�cs

z"_ProactorSocketTransport.write_eof)NNN)
r8r^r_r`rZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerrr�r�rcrrr3rr�Qs�r�cs�eZdZ�fdd�Zd3dd�Zd4dddddd�dd	�Zd5d
d�Zd6dd
�Zd7dd�Zd8dd�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd9d&d'�Zd(d)�Zd:d+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS);rcsht���t�d|jj�||_||_d|_i|_	|�
|�|��t�
�t��krdt�|j���dS)NzUsing proactor: %s)rrrrSr4r8ru�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe�	threading�current_thread�main_thread�signal�
set_wakeup_fd�_csockr:)r-Zproactorr3rrrms

zBaseProactorEventLoop.__init__NcCst||||||�SrB)r�)r-rr/r0r1r2rrr�_make_socket_transportzs
�z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer1r2�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r��r1r2)r	ZSSLProtocolr�Z_app_transport)r-Zrawsockr/�
sslcontextr0r�r�r1r2r�Zssl_protocolrrr�_make_ssl_transports��z)BaseProactorEventLoop._make_ssl_transportcCst||||||�SrB)r�)r-rr/r�r0r1rrr�_make_datagram_transport�s
�z.BaseProactorEventLoop._make_datagram_transportcCst|||||�SrB)r��r-rr/r0r1rrr�_make_duplex_pipe_transport�s�z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�SrB)rdr�rrr�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�SrB)r�r�rrr�_make_write_pipe_transport�s�z0BaseProactorEventLoop._make_write_pipe_transportcsj|��rtd��|��rdSt��t��kr6t�d�|��|�	�|j
��d|_
d|_t
���dS)Nz!Cannot close a running event loop���)Z
is_runningr��	is_closedr�r�r�r�r��_stop_accept_futures�_close_self_piperurIr�rrDr3rrrI�s

zBaseProactorEventLoop.closec�s|j�||�IdHSrB)rurv)r-r�nrrr�	sock_recv�szBaseProactorEventLoop.sock_recvc�s|j�||�IdHSrB)ruZ	recv_into)r-rZbufrrr�sock_recv_into�sz$BaseProactorEventLoop.sock_recv_intoc�s|j�||�IdHSrB)rur�)r-rrlrrr�sock_sendall�sz"BaseProactorEventLoop.sock_sendallc�s|j�||�IdHSrB)ruZconnect)r-rr�rrr�sock_connect�sz"BaseProactorEventLoop.sock_connectc�s|j�|�IdHSrB)ru�acceptrArrr�sock_accept�sz!BaseProactorEventLoop.sock_acceptc
�s(z|��}Wn2ttjfk
r>}zt�d��W5d}~XYnXzt�|�j}Wn,t	k
r|}zt�d��W5d}~XYnX|r�|n|}|s�dSt
|d�}|r�t
|||�n|}	t
||�}d}
zLt
|	||�}|dkr�|
W�0S|j�
||||�IdH||7}|
|7}
q�W5|
dk�r"|�|�XdS)Nznot a regular filerl��)r:�AttributeError�io�UnsupportedOperationrZSendfileNotAvailableError�os�fstat�st_sizerR�min�seekru�sendfile)r-r�file�offset�countr:�errZfsizeZ	blocksizeZend_posZ
total_sentrrr�_sock_sendfile_native�s0


z+BaseProactorEventLoop._sock_sendfile_nativec�sZ|��}|��|��IdHz |j|j|||dd�IdHW�S|��|rT|��XdS)NF)Zfallback)rhrir�r�rmZ
sock_sendfiler )r-Ztranspr�r�r�rmrrr�_sendfile_native�s�z&BaseProactorEventLoop._sendfile_nativecCsL|jdk	r|j��d|_|j��d|_|j��d|_|jd8_dS)Nr)r�rH�_ssockrIr��
_internal_fdsrDrrrr��s



z&BaseProactorEventLoop._close_self_pipecCs:t��\|_|_|j�d�|j�d�|jd7_dS)NFr)r
Z
socketpairr�r�Zsetblockingr�rDrrrr��sz%BaseProactorEventLoop._make_self_pipec
Cs�z4|dk	r|��|j|k	r"WdS|j�|jd�}Wnbtjk
rLYdSttfk
rd�YnFt	k
r�}z|�
d||d��W5d}~XYnX||_|�|j�dS)Niz.Error on reading from the event loop self pipe)rNrOr.)
rtr�rurvr�rryrnrorprTrz�_loop_self_reading)r-r�rUrrrr��s$
�z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|�d�Wn(tk
rH|jrDtjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketTr)r�r�rR�_debugrrS)r-Zcsockrrr�_write_to_selfs�z$BaseProactorEventLoop._write_to_self�dcs(d�������fdd�	�����dS)Nc
s,z�|dk	rn|��\}}�jr,t�d�||���}�dk	rX�j||�dd|i��d�n�j||d|i�d����r|WdS�j���}Wn�t	k
r�}zH��
�dkrʈ�d|t�
��d�����n�jr�tjd	�dd
�W5d}~XYn8tjk
�r���YnX|�j��
�<|���dS)Nz#%r got a new connection from %r: %rTr)r�r1r2r�r�r�zAccept failed on a socket)rNrOr
zAccept failed on socket %rr)rtr�rrSr�r�r�rur�rRr:rTrrrIrryr�rz)r�Zconnr�r/rU�r.�protocol_factoryr-r2rr�r�rrr./s\����
�z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r*)r-r�rr�r2Zbacklogr�rr�r�_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z
event_listrrr�_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|j��D]}|��q
|j��dSrB)r��valuesrH�clear)r-�futurerrrr�Zs
z*BaseProactorEventLoop._stop_accept_futurescCs6|j�|��d�}|r|��|j�|�|��dSrB)r��popr:rHru�
_stop_servingrI)r-rr�rrrr�_s
z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNr�N)r8r^r_rr�r�r�r�r�r�rIr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rcrrr3rrks\
�
���
�
�
�


�
+r)#r`�__all__r�r�r
rar�r�r��rrrrrr	r
r�logrrZ_FlowControlMixinZ
BaseTransportrZ
ReadTransportrdZWriteTransportr|r�r�Z	Transportr�r�Z
BaseEventLooprrrrr�<module>sR���n��PK0�\��M�""subprocess.cpython-38.opt-2.pycnu�[���U

e5d��@s�dZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ej
Z
ejZejZGd	d
�d
ej
ej�ZGdd�d�Zddddejfd
d�Zddddejd�dd�ZdS))�create_subprocess_exec�create_subprocess_shell�N�)�events)�	protocols)�streams)�tasks)�loggercsTeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�SubprocessStreamProtocolcsHt�j|d�||_d|_|_|_d|_d|_g|_|j	�
�|_dS)N��loopF)�super�__init__�_limit�stdin�stdout�stderr�
_transport�_process_exited�	_pipe_fds�_loopZ
create_future�
_stdin_closed)�self�limitr��	__class__��*/usr/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk	r&|�d|j���|jdk	rB|�d|j���|jdk	r^|�d|j���d�d�|��S)Nzstdin=zstdout=zstderr=z<{}>� )r�__name__r�appendrr�format�join)r�inforrr�__repr__s



z!SubprocessStreamProtocol.__repr__cCs�||_|�d�}|dk	rDtj|j|jd�|_|j�|�|j�	d�|�d�}|dk	r�tj|j|jd�|_
|j
�|�|j�	d�|�d�}|dk	r�tj||d|jd�|_dS)Nr�rr�r)�protocol�readerr)
r�get_pipe_transportr�StreamReaderrrrZ
set_transportrr r�StreamWriterr)r�	transportZstdout_transportZstderr_transportZstdin_transportrrr�connection_made)s,
�
�
�z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk	r6|�|�dS)Nrr&)rrZ	feed_data)r�fd�datar(rrr�pipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs�|dkrN|j}|dk	r|��|�|�|dkr>|j�d�n|j�|�dS|dkr^|j}n|dkrn|j}nd}|dk	r�|dkr�|��n
|�|�||j	kr�|j	�
|�|��dS)Nrrr&)r�closeZconnection_lostrZ
set_resultZ
set_exceptionrrZfeed_eofr�remove�_maybe_close_transport)rr.�exc�piper(rrr�pipe_connection_lostKs*



z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|��dS)NT)rr3�rrrr�process_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|j�dkr$|jr$|j��d|_dS)Nr)�lenrrrr1r7rrrr3js
z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdS�N)rr)r�streamrrr�_get_close_waiteros
z*SubprocessStreamProtocol._get_close_waiter)r�
__module__�__qualname__rr$r-r0r6r8r3r<�
__classcell__rrrrr
s	

r
c@sjeZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ddd�ZdS)�ProcesscCs8||_||_||_|j|_|j|_|j|_|��|_dSr:)rZ	_protocolrrrrZget_pid�pid)rr,r'rrrrruszProcess.__init__cCsd|jj�d|j�d�S)N�<r�>)rrrAr7rrrr$~szProcess.__repr__cCs
|j��Sr:)rZget_returncoder7rrr�
returncode�szProcess.returncodec�s|j��IdHSr:)rZ_waitr7rrr�wait�szProcess.waitcCs|j�|�dSr:)r�send_signal)r�signalrrrrF�szProcess.send_signalcCs|j��dSr:)r�	terminater7rrrrH�szProcess.terminatecCs|j��dSr:)r�killr7rrrrI�szProcess.killc
�s�|j��}|j�|�|r,t�d|t|��z|j��IdHWn8tt	fk
rx}z|rht�d||�W5d}~XYnX|r�t�d|�|j�
�dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r�	get_debugr�writer	�debugr9Zdrain�BrokenPipeError�ConnectionResetErrorr1)r�inputrLr4rrr�_feed_stdin�s 
� zProcess._feed_stdinc�sdSr:rr7rrr�_noop�sz
Process._noopc�s�|j�|�}|dkr|j}n|j}|j��rJ|dkr8dnd}t�d||�|��IdH}|j��r�|dkrndnd}t�d||�|�	�|S)Nr&rrrz%r communicate: read %sz%r communicate: close %s)
rr)rrrrJr	rL�readr1)rr.r,r;�name�outputrrr�_read_stream�s

zProcess._read_streamNc�s�|dk	r|�|�}n|��}|jdk	r2|�d�}n|��}|jdk	rP|�d�}n|��}tj||||jd�IdH\}}}|��IdH||fS)Nrr&r)	rPrQrrUrrZgatherrrE)rrOrrrrrr�communicate�s


�zProcess.communicate)N)rr=r>rr$�propertyrDrErFrHrIrPrQrUrVrrrrr@ts	
r@c
�sb�dkrt���ntjdtdd���fdd�}�j||f|||d�|��IdH\}}	t||	��S)N�ZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r&��
stacklevelcst��d�S�Nr%�r
rr%rr�<lambda>�s�z)create_subprocess_shell.<locals>.<lambda>�rrr)r�get_event_loop�warnings�warn�DeprecationWarningZsubprocess_shellr@)
�cmdrrrrr�kwds�protocol_factoryr,r'rr%rr�s$
����r)rrrrrc�sf�dkrt���ntjdtdd���fdd�}�j||f|�|||d�|��IdH\}	}
t|	|
��S)NrXr&rYcst��d�Sr[r\rr%rrr]�s�z(create_subprocess_exec.<locals>.<lambda>r^)rr_r`rarbZsubprocess_execr@)Zprogramrrrrr�argsrdrer,r'rr%rr�s(
�����r)�__all__�
subprocessr`�rrrr�logr	�PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr
r@Z_DEFAULT_LIMITrrrrrr�<module>s.�bV�
�PK0�\��q�ll!base_futures.cpython-38.opt-1.pycnu�[���U

e5d
�@sRdZddlZddlmZddlmZdZdZdZd	d
�Z	dd�Z
e�Zd
d�Z
dS)��N)�	get_ident�)�format_helpersZPENDINGZ	CANCELLEDZFINISHEDcCst|jd�o|jdk	S)z�Check for a Future.

    This returns True when obj is a Future instance or is advertising
    itself as duck-type compatible by setting _asyncio_future_blocking.
    See comment in Future for more details.
    �_asyncio_future_blockingN)�hasattr�	__class__r)�objrr�,/usr/lib64/python3.8/asyncio/base_futures.py�isfutures�rcCs�t|�}|sd}dd�}|dkr2||dd�}n`|dkr`d�||dd�||dd��}n2|dkr�d�||dd�|d||d	d��}d
|�d�S)�#helper function for Future.__repr__�cSst�|d�S)Nr)rZ_format_callback_source)�callbackrrr
�	format_cbsz$_format_callbacks.<locals>.format_cbrr�z{}, {}z{}, <{} more>, {}���zcb=[�])�len�format)�cb�sizerrrr
�_format_callbackss&�rc	Cs�|j��g}|jtkr�|jdk	r4|�d|j���nTt|�t�f}|tkrPd}n(t�|�zt
�|j�}W5t�	|�X|�d|���|j
r�|�t|j
��|jr�|jd}|�d|d�d|d	���|S)
rNz
exception=z...zresult=rzcreated at r�:r)Z_state�lower�	_FINISHEDZ
_exception�append�idr�
_repr_running�add�discard�reprlib�reprZ_resultZ
_callbacksrZ_source_traceback)Zfuture�info�key�result�framerrr
�_future_repr_info7s$



r&)�__all__r �_threadrr
rZ_PENDINGZ
_CANCELLEDrrr�setrr&rrrr
�<module>sPK0�\��yywindows_utils.cpython-38.pycnu�[���U

e5d��@s�dZddlZejdkred��ddlZddlZddlZddlZddlZddl	Z	ddl
Z
dZdZej
Z
ejZe��Zdded	�d
d�ZGdd
�d
�ZGdd�dej�ZdS)z)Various Windows specific bits and pieces.�NZwin32z
win32 only)�pipe�Popen�PIPE�
PipeHandlei F)TT)�duplex�
overlapped�bufsizec
Cs$tjd�t��tt��d�}|r>tj}tj	tj
B}||}}ntj}tj
}d|}}|tjO}|drp|tj
O}|dr�tj
}nd}d}	}
z\t�||tjd||tjtj�}	t�||dtjtj|tj�}
tj|	dd�}|�d�|	|
fWS|	dk	�rt�|	�|
dk	�rt�|
��YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�NT�r)�tempfileZmktemp�format�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ	PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2Zov�r�-/usr/lib64/python3.8/asyncio/windows_utils.pyr sb��


��





rc@sbeZdZdZdd�Zdd�Zedd��Zdd	�Ze	j
d
�dd�Zej
fd
d�Zdd�Zdd�ZdS)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like.

    The IOCP event loop can use these instead of socket objects.
    cCs
||_dS�N��_handle��self�handlerrr�__init__VszPipeHandle.__init__cCs2|jdk	rd|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r�	__class__�__name__rrrr�__repr__Ys
zPipeHandle.__repr__cCs|jSrr�rrrrr`szPipeHandle.handlecCs|jdkrtd��|jS)NzI/O operation on closed pipe)r�
ValueErrorr%rrr�filenods
zPipeHandle.fileno)rcCs|jdk	r||j�d|_dSrr)rrrrr�closeis

zPipeHandle.closecCs*|jdk	r&|d|��t|d�|��dS)Nz	unclosed )�source)r�ResourceWarningr()rZ_warnrrr�__del__ns
zPipeHandle.__del__cCs|Srrr%rrr�	__enter__sszPipeHandle.__enter__cCs|��dSr)r()r�t�v�tbrrr�__exit__vszPipeHandle.__exit__N)r#�
__module__�__qualname__�__doc__rr$�propertyrr'rrr(�warnings�warnr+r,r0rrrrrQs
rcs"eZdZdZd�fdd�	Z�ZS)rz�Replacement for subprocess.Popen using overlapped pipe handles.

    The stdin, stdout, stderr are None or instances of PipeHandle.
    Nc	s�|�d�rt�|�dd�dks"t�d}}}d}	}
}|tkrbtddd�\}}	t�|tj�}n|}|tkr�tdd�\}
}
t�|
d�}n|}|tkr�tdd�\}}t�|d�}n|tkr�|}n|}z�z t
�j|f|||d	�|��Wn0|	|
|fD]}|dk	r�t�
|�q��Yn>X|	dk	�r,t|	�|_|
dk	�r@t|
�|_|dk	�rTt|�|_W5|tk�rlt�	|�|tk�r�t�	|�|tk�r�t�	|�XdS)
NZuniversal_newlinesrr)FTT)rr)TFr)�stdin�stdout�stderr)�get�AssertionErrorrr�msvcrtZopen_osfhandler�O_RDONLY�STDOUTr(�superrrrrr7r8r9)r�argsr7r8r9�kwdsZ	stdin_rfdZ
stdout_wfdZ
stderr_wfdZstdin_whZ	stdout_rhZ	stderr_rhZstdin_rhZ	stdout_whZ	stderr_wh�h�r"rrr�sR��










zPopen.__init__)NNN)r#r1r2r3r�
__classcell__rrrCrr}sr)r3�sys�platform�ImportErrorr�	itertoolsr<r�
subprocessrr5�__all__ZBUFSIZErr>�countrrrrrrrr�<module>s$
1,PK0�\�h���runners.cpython-38.pycnu�[���U

e5d�@sBdZddlmZddlmZddlmZdd�dd�Zd	d
�ZdS))�run�)�
coroutines)�events)�tasksN)�debugcCs�t��dk	rtd��t�|�s,td�|���t��}z*t�|�|dk	rR|�
|�|�|�W�Szt
|�|�|���W5t�d�|�	�XXdS)a�Execute the coroutine and return the result.

    This function runs the passed coroutine, taking care of
    managing the asyncio event loop and finalizing asynchronous
    generators.

    This function cannot be called when another asyncio event loop is
    running in the same thread.

    If debug is True, the event loop will be run in debug mode.

    This function always creates a new event loop and closes it at the end.
    It should be used as a main entry point for asyncio programs, and should
    ideally only be called once.

    Example:

        async def main():
            await asyncio.sleep(1)
            print('hello')

        asyncio.run(main())
    Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop�RuntimeErrorrZiscoroutine�
ValueError�formatZnew_event_loopZset_event_loop�close�_cancel_all_tasks�run_until_completeZshutdown_asyncgensZ	set_debug)�mainr�loop�r�'/usr/lib64/python3.8/asyncio/runners.pyrs"�



rcCsvt�|�}|sdS|D]}|��q|�tj||dd���|D]0}|��rNq@|��dk	r@|�d|��|d��q@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)�message�	exception�task)rZ	all_tasksZcancelrZgatherZ	cancelledrZcall_exception_handler)rZ	to_cancelrrrrr6s"

��r)�__all__�rrrrrrrrr�<module>s
.PK0�\���/$$$base_subprocess.cpython-38.opt-2.pycnu�[���U

e5d�"�@sxddlZddlZddlZddlmZddlmZddlmZGdd�dej�Z	Gdd	�d	ej
�ZGd
d�deej�Z
dS)�N�)�	protocols)�
transports)�loggercs�eZdZd0�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jfdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z�ZS)1�BaseSubprocessTransportNc
	s&t��|
�d|_||_||_d|_d|_d|_g|_t	�
�|_i|_d|_
|tjkr`d|jd<|tjkrtd|jd<|tjkr�d|jd<z"|jf||||||d�|��Wn|���YnX|jj|_|j|jd<|j���rt|ttf�r�|}n|d}t�d||j�|j�|�|	��dS)NFrr�)�args�shell�stdin�stdout�stderr�bufsize�
subprocesszprocess %r created: pid %s)�super�__init__�_closed�	_protocol�_loop�_proc�_pid�_returncode�
_exit_waiters�collections�deque�_pending_calls�_pipes�	_finishedr�PIPE�_start�close�pidZ_extra�	get_debug�
isinstance�bytes�strr�debugZcreate_task�_connect_pipes)
�self�loop�protocolrr	r
rrr
�waiterZextra�kwargsZprogram��	__class__��//usr/lib64/python3.8/asyncio/base_subprocess.pyrsL






��

�z BaseSubprocessTransport.__init__cCs|jjg}|jr|�d�|jdk	r6|�d|j���|jdk	rT|�d|j���n |jdk	rj|�d�n
|�d�|j�d�}|dk	r�|�d|j���|j�d�}|j�d	�}|dk	r�||kr�|�d
|j���n6|dk	r�|�d|j���|dk	�r|�d|j���d
�	d�
|��S)N�closedzpid=zreturncode=Zrunningznot startedrzstdin=rrzstdout=stderr=zstdout=zstderr=z<{}>� )r-�__name__r�appendrrr�get�pipe�format�join)r'�infor
rrr.r.r/�__repr__7s,






z BaseSubprocessTransport.__repr__cKst�dS�N)�NotImplementedError)r'rr	r
rrr
r+r.r.r/rTszBaseSubprocessTransport._startcCs
||_dSr:�r)r'r)r.r.r/�set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<�r'r.r.r/�get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/�
is_closing]sz"BaseSubprocessTransport.is_closingcCs�|jr
dSd|_|j��D]}|dkr(q|j��q|jdk	r�|jdkr�|j��dkr�|j�	�rlt
�d|�z|j��Wnt
k
r�YnXdS)NTz$Close running child process: kill %r)rr�valuesr5rrrZpollrr!rZwarning�kill�ProcessLookupError)r'�protor.r.r/r`s$
��
zBaseSubprocessTransport.closecCs&|js"|d|��t|d�|��dS)Nzunclosed transport )�source)r�ResourceWarningr)r'Z_warnr.r.r/�__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/�get_pid�szBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/�get_returncode�sz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'�fdr.r.r/�get_pipe_transport�s
z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrt��dSr:)rrCr>r.r.r/�_check_proc�s
z#BaseSubprocessTransport._check_proccCs|��|j�|�dSr:)rLr�send_signal)r'�signalr.r.r/rM�sz#BaseSubprocessTransport.send_signalcCs|��|j��dSr:)rLr�	terminater>r.r.r/rO�sz!BaseSubprocessTransport.terminatecCs|��|j��dSr:)rLrrBr>r.r.r/rB�szBaseSubprocessTransport.killc	
�s`z�j}�j}|jdk	rB|��fdd�|j�IdH\}}|�jd<|jdk	rv|��fdd�|j�IdH\}}|�jd<|jdk	r�|��fdd�|j�IdH\}}|�jd<|��j	j
���jD]\}}|j|f|��q�d�_WnZtt
fk
r��Yn`tk
�r<}z"|dk	�r,|���s,|�|�W5d}~XYn X|dk	�r\|���s\|�d�dS)Ncs
t�d�S)Nr)�WriteSubprocessPipeProtor.r>r.r/�<lambda>��z8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>rcs
t�d�S)Nr��ReadSubprocessPipeProtor.r>r.r/rQ�rRrcs
t�d�S)NrrSr.r>r.r/rQ�rRr)rrr
Zconnect_write_piperrZconnect_read_piper�	call_soonr�connection_mader�
SystemExit�KeyboardInterrupt�
BaseException�	cancelledZ
set_exception�
set_result)	r'r*�procr(�_r5�callback�data�excr.r>r/r&�s@

�


�


�

z&BaseSubprocessTransport._connect_pipescGs2|jdk	r|j�||f�n|jj|f|��dSr:)rr3rrU)r'�cbr_r.r.r/�_call�s
zBaseSubprocessTransport._callcCs|�|jj||�|��dSr:)rbrZpipe_connection_lost�_try_finish)r'rJr`r.r.r/�_pipe_connection_lost�sz-BaseSubprocessTransport._pipe_connection_lostcCs|�|jj||�dSr:)rbrZpipe_data_received)r'rJr_r.r.r/�_pipe_data_received�sz+BaseSubprocessTransport._pipe_data_receivedcCsp|j��rt�d||�||_|jjdkr2||j_|�|jj	�|�
�|jD]}|��sN|�
|�qNd|_dS)Nz%r exited with return code %r)rr!rr8rr�
returncoderbrZprocess_exitedrcrrZr[)r'rfr*r.r.r/�_process_exited�s

z'BaseSubprocessTransport._process_exitedc�s0|jdk	r|jS|j��}|j�|�|IdHSr:)rrZ
create_futurerr3)r'r*r.r.r/�_wait�s


zBaseSubprocessTransport._waitcCs>|jdkrdStdd�|j��D��r:d|_|�|jd�dS)Ncss|]}|dk	o|jVqdSr:)�disconnected)�.0�pr.r.r/�	<genexpr>�s�z6BaseSubprocessTransport._try_finish.<locals>.<genexpr>T)r�allrrArrb�_call_connection_lostr>r.r.r/rc�s
�z#BaseSubprocessTransport._try_finishcCs*z|j�|�W5d|_d|_d|_XdSr:)rrr�connection_lost�r'r`r.r.r/rn�s
z-BaseSubprocessTransport._call_connection_lost)NN)r2�
__module__�__qualname__rr9rr=r?r@r�warnings�warnrGrHrIrKrLrMrOrBr&rbrdrergrhrcrn�
__classcell__r.r.r,r/r
s2�+&	rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rPcCs||_||_d|_d|_dS)NF)r\rJr5ri)r'r\rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs
||_dSr:)r5)r'Z	transportr.r.r/rVsz(WriteSubprocessPipeProto.connection_madecCs d|jj�d|j�d|j�d�S)N�<z fd=z pipe=�>)r-r2rJr5r>r.r.r/r9
sz!WriteSubprocessPipeProto.__repr__cCs d|_|j�|j|�d|_dS)NT)rir\rdrJrpr.r.r/ro
sz(WriteSubprocessPipeProto.connection_lostcCs|jj��dSr:)r\r�
pause_writingr>r.r.r/rxsz&WriteSubprocessPipeProto.pause_writingcCs|jj��dSr:)r\r�resume_writingr>r.r.r/rysz'WriteSubprocessPipeProto.resume_writingN)	r2rqrrrrVr9rorxryr.r.r.r/rP�srPc@seZdZdd�ZdS)rTcCs|j�|j|�dSr:)r\rerJ)r'r_r.r.r/�
data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rqrrrzr.r.r.r/rTsrT)rrrs�rr�logrZSubprocessTransportrZBaseProtocolrPZProtocolrTr.r.r.r/�<module>sv�PK0�\���
		#format_helpers.cpython-38.opt-1.pycnu�[���U

e5dd	�@sdddlZddlZddlZddlZddlZddlmZdd�Zdd�Zdd	�Z	ddd�Z
dd
d�ZdS)�N�)�	constantscCsVt�|�}t�|�r&|j}|j|jfSt|tj�r<t	|j
�St|tj�rRt	|j
�SdS�N)�inspectZunwrapZ
isfunction�__code__�co_filename�co_firstlineno�
isinstance�	functools�partial�_get_function_source�func�
partialmethod)r
�code�r�./usr/lib64/python3.8/asyncio/format_helpers.pyr
s



rcCs8t||d�}t|�}|r4|d|d�d|d��7}|S)Nz at r�:r)�_format_callbackr)r
�args�	func_repr�sourcerrr�_format_callback_sources
rcCsHg}|r|�dd�|D��|r8|�dd�|��D��d�d�|��S)z�Format function arguments and keyword arguments.

    Special case for a single parameter: ('hello',) is formatted as ('hello').
    css|]}t�|�VqdSr��reprlib�repr)�.0�argrrr�	<genexpr>&sz*_format_args_and_kwargs.<locals>.<genexpr>css&|]\}}|�dt�|���VqdS)�=Nr)r�k�vrrrr(sz({})z, )�extend�items�format�join)r�kwargsr"rrr�_format_args_and_kwargssr&�cCs�t|tj�r.t||�|}t|j|j|j|�St|d�rF|j	rF|j	}n t|d�r^|j
r^|j
}nt|�}|t||�7}|r�||7}|S)N�__qualname__�__name__)r	r
rr&rr
r�keywords�hasattrr(r)r)r
rr%�suffixrrrrr,srcCsD|dkrt��j}|dkr tj}tjjt�|�|dd�}|�	�|S)zlReplacement for traceback.extract_stack() that only does the
    necessary work for asyncio debug mode.
    NF)�limit�lookup_lines)
�sys�	_getframe�f_backrZDEBUG_STACK_DEPTH�	traceback�StackSummary�extract�
walk_stack�reverse)�fr-�stackrrr�
extract_stack>s
�r9)r')NN)r
rrr/r2r'rrrr&rr9rrrr�<module>s
PK0�\g<2��^�^tasks.cpython-38.pycnu�[���U

e5d���@svdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZdd
l
mZe�d�jZdBdd�ZdCd
d�ZdDdd�Zdd�ZGdd�dej�ZeZzddlZWnek
r�YnXejZZdd�dd�Zejj Z ejj!Z!ejj"Z"dde"d�dd�Z#dd�Z$dd�dd�Z%d d!�Z&d"d#�Z'ddd$�d%d&�Z(ej)d'd(��Z*dEdd�d)d*�Z+dd�d+d,�Z,ej)d-d.��Z-ee-_Gd/d0�d0ej.�Z/dd1d2�d3d4�Z0dd�d5d6�Z1d7d8�Z2e
�3�Z4iZ5d9d:�Z6d;d<�Z7d=d>�Z8d?d@�Z9e6Z:e9Z;e7Z<e8Z=z$ddAlm6Z6m9Z9m7Z7m8Z8m4Z4m5Z5Wnek
�r`YnXe6Z>e9Z?e7Z@e8ZAdS)Fz0Support for tasks, coroutines and the scheduler.)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield�
ensure_future�run_coroutine_threadsafe�current_task�	all_tasks�_register_task�_unregister_task�_enter_task�_leave_task�N�)�
base_tasks)�
coroutines)�events)�
exceptions)�futures)�
_is_coroutinecCs|dkrt��}t�|�S)z!Return a currently executed task.N)r�get_running_loop�_current_tasks�get��loop�r!�%/usr/lib64/python3.8/asyncio/tasks.pyr"srcs^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)z'Return a set of all tasks for the loop.Nrr��cs&h|]}t�|��kr|��s|�qSr!)r�	_get_loop�done��.0�trr!r"�	<setcomp><s�zall_tasks.<locals>.<setcomp>)rr�list�
_all_tasks�RuntimeError�r �iZtasksr!rr"r)srcs^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)Nrrr#csh|]}t�|��kr|�qSr!)rr$r&rr!r"r)Usz$_all_tasks_compat.<locals>.<setcomp>)r�get_event_loopr*r+r,r-r!rr"�_all_tasks_compat@sr0cCs4|dk	r0z
|j}Wntk
r&Yn
X||�dS�N)�set_name�AttributeError)�task�namer2r!r!r"�_set_task_nameXs
r6cs�eZdZdZdZed%dd��Zed&dd��Zddd��fd	d
�
Z�fdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�dd�Zddd�dd�Zdd �Zd'�fd!d"�	Zd#d$�Z�ZS)(rz A coroutine wrapped in a Future.TNcCs(tjdtdd�|dkr t��}t|�S)z�Return the currently running task in an event loop or None.

        By default the current task for the current event loop is returned.

        None is returned when called not in the context of a Task.
        zVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead���
stacklevelN)�warnings�warn�DeprecationWarningrr/r��clsr r!r!r"rts�zTask.current_taskcCstjdtdd�t|�S)z|Return a set of all tasks for an event loop.

        By default all tasks for the current event loop are returned.
        zPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r0r=r!r!r"r�s
�zTask.all_tasks)r r5cs�t�j|d�|jr|jd=t�|�s:d|_td|����|dkrRdt���|_n
t	|�|_d|_
d|_||_t
��|_|jj|j|jd�t|�dS)Nr���Fza coroutine was expected, got zTask-��context)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending�	TypeError�_task_name_counter�_name�str�_must_cancel�_fut_waiter�_coro�contextvarsZcopy_context�_context�_loop�	call_soon�_Task__stepr)�self�coror r5��	__class__r!r"rC�s


z
Task.__init__csF|jtjkr8|jr8|dd�}|jr,|j|d<|j�|�t���dS)Nz%Task was destroyed but it is pending!)r4�messageZsource_traceback)	Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB�__del__)rSrArUr!r"rX�s�
zTask.__del__cCs
t�|�Sr1)rZ_task_repr_info�rSr!r!r"�
_repr_info�szTask._repr_infocCs|jSr1)rMrYr!r!r"�get_coro�sz
Task.get_corocCs|jSr1)rIrYr!r!r"�get_name�sz
Task.get_namecCst|�|_dSr1)rJrI)rS�valuer!r!r"r2�sz
Task.set_namecCstd��dS)Nz*Task does not support set_result operation�r,)rS�resultr!r!r"�
set_result�szTask.set_resultcCstd��dS)Nz-Task does not support set_exception operationr^)rS�	exceptionr!r!r"�
set_exception�szTask.set_exception)�limitcCst�||�S)a�Return the list of stack frames for this task's coroutine.

        If the coroutine is not done, this returns the stack where it is
        suspended.  If the coroutine has completed successfully or was
        cancelled, this returns an empty list.  If the coroutine was
        terminated by an exception, this returns the list of traceback
        frames.

        The frames are always ordered from oldest to newest.

        The optional limit gives the maximum number of frames to
        return; by default all available frames are returned.  Its
        meaning differs depending on whether a stack or a traceback is
        returned: the newest frames of a stack are returned, but the
        oldest frames of a traceback are returned.  (This matches the
        behavior of the traceback module.)

        For reasons beyond our control, only one stack frame is
        returned for a suspended coroutine.
        )rZ_task_get_stack)rSrcr!r!r"�	get_stack�szTask.get_stack)rc�filecCst�|||�S)anPrint the stack or traceback for this task's coroutine.

        This produces output similar to that of the traceback module,
        for the frames retrieved by get_stack().  The limit argument
        is passed to get_stack().  The file argument is an I/O stream
        to which the output is written; by default output is written
        to sys.stderr.
        )rZ_task_print_stack)rSrcrer!r!r"�print_stack�s	zTask.print_stackcCs4d|_|��rdS|jdk	r*|j��r*dSd|_dS)a�Request that this task cancel itself.

        This arranges for a CancelledError to be thrown into the
        wrapped coroutine on the next cycle through the event loop.
        The coroutine then has a chance to clean up or even deny
        the request using try/except/finally.

        Unlike Future.cancel, this does not guarantee that the
        task will be cancelled: the exception might be caught and
        acted upon, delaying cancellation of the task or preventing
        cancellation completely.  The task may also return a value or
        raise a different exception.

        Immediately after this method is called, Task.cancelled() will
        not return True (unless the task was already cancelled).  A
        task will be marked as cancelled when the wrapped coroutine
        terminates with a CancelledError exception (even if cancel()
        was not called).
        FNT)Z_log_tracebackr%rL�cancelrKrYr!r!r"rg�s

zTask.cancelc
s�|��rt�d|�d|����|jr>t|tj�s8t��}d|_|j}d|_t|j	|��zfz"|dkrp|�d�}n
|�|�}Wn�t
k
r�}z*|jr�d|_t���nt��|j�W5d}~XY�n�tjk
r�t���Y�n�ttfk
�r}zt��|��W5d}~XY�n�tk
�rL}zt��|�W5d}~XY�npXt|dd�}|dk	�r@t�|�|j	k	�r�td|�d|�d��}|j	j|j||jd�n�|�r||k�r�td	|���}|j	j|j||jd�n8d|_|j|j|jd�||_|j�r>|j���r>d|_n*td
|�d|���}|j	j|j||jd�n||dk�r`|j	j|j|jd�n\t �!|��r�td|�d|���}|j	j|j||jd�n$td
|���}|j	j|j||jd�W5t
|j	|�d}XdS)Nz_step(): already done: z, F�_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r%rZInvalidStateErrorrK�
isinstance�CancelledErrorrMrLrrPr�send�throw�
StopIterationrBrgr`r]�KeyboardInterrupt�
SystemExitrb�
BaseException�getattrrr$r,rQrRrOrh�add_done_callback�
_Task__wakeup�inspectZisgenerator)rS�excrTr_Zblocking�new_excrUr!r"Z__steps��  
��
�����
���
zTask.__stepc
CsJz|��Wn,tk
r8}z|�|�W5d}~XYn
X|��d}dSr1)r_rprR)rS�futurerur!r!r"Z__wakeup[sz
Task.__wakeup)N)N)N)�__name__�
__module__�__qualname__�__doc__rF�classmethodrrrCrXrZr[r\r2r`rbrdrfrgrRrs�
__classcell__r!r!rUr"rbs&
!Tr)r5cCs t��}|�|�}t||�|S)z]Schedule the execution of a coroutine object in a spawn task.

    Return a Task object.
    )rrrr6)rTr5r r4r!r!r"rxs

r)r �timeout�return_whenc�s�t�|�st�|�r(tdt|�j����|s4td��|tt	t
fkrPtd|�����dkrbt���nt
jdtdd��fdd	�t|�D�}t|||��IdHS)
a�Wait for the Futures and coroutines given by fs to complete.

    The fs iterable must not be empty.

    Coroutines will be wrapped in Tasks.

    Returns two sets of Future: (done, pending).

    Usage:

        done, pending = await asyncio.wait(fs)

    Note: This does not raise TimeoutError! Futures that aren't done
    when the timeout occurs are returned in the second set.
    zexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: N�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|�d��qS�r�r�r'�frr!r"r)�szwait.<locals>.<setcomp>)r�isfuturerrErG�typerx�
ValueErrorrrrrrr:r;r<�set�_wait)�fsr r~rr!rr"r�s
�rcGs|��s|�d�dSr1)r%r`)�waiter�argsr!r!r"�_release_waiter�sr�rc
�s�|dkrt��}ntjdtdd�|dkr4|IdHS|dkr�t||d�}|��rX|��St||d�IdHz|��Wn.t	j
k
r�}zt	��|�W5d}~XYn
Xt	���|��}|�
|t|�}t�t|�}t||d�}|�|�z�z|IdHWnPt	j
k
�rF|���r$|��YW�dS|�|�t||d�IdH�YnX|���r^|��W�*S|�|�t||d�IdHt	���W5|��XdS)a�Wait for the single Future or coroutine to complete, with timeout.

    Coroutine will be wrapped in Task.

    Returns result of the Future or coroutine.  When a timeout occurs,
    it cancels the task and raises TimeoutError.  To avoid the task
    cancellation, wrap it in shield().

    If the wait is cancelled, the task is also cancelled.

    This function is a coroutine.
    Nr�r7r8rr)rrr:r;r<rr%r_�_cancel_and_waitrrj�TimeoutError�
create_future�
call_laterr��	functools�partialrrrg�remove_done_callback)�futr~r rur��timeout_handle�cbr!r!r"r�sL

�





rc
�s�|std��|���d�|dk	r.|�|t���t|������fdd�}|D]}|�|�qLz�IdHW5�dk	r|���|D]}|�|�q�Xt�t�}}|D]"}|�	�r�|�
|�q�|�
|�q�||fS)zVInternal helper for wait().

    The fs argument must be a collection of Futures.
    zSet of Futures is empty.NcsZ�d8��dks4�tks4�tkrV|��sV|��dk	rV�dk	rD������sV��d�dS)Nrr)rr�	cancelledrargr%r`�r��Zcounterrr�r�r!r"�_on_completions���
�z_wait.<locals>._on_completion)�AssertionErrorr�r�r��lenrrrgr�r�r%�add)r�r~rr r�r�r%Zpendingr!r�r"r��s*r�c	�sF|��}t�t|�}|�|�z|��|IdHW5|�|�XdS)z<Cancel the *fut* future or task and wait until it completes.N)r�r�r�r�rrr�rg)r�r r�r�r!r!r"r�&s
r�)r r~c#s�t�|�st�|�r(tdt|�j����ddlm}|�d���dkrPt	�
��ntjdt
dd��fd	d
�t|�D��d����fdd�}���fd
d���fdd�}�D]}|���q��r�|dk	r҈�||��tt���D]}|�Vq�dS)a^Return an iterator whose values are coroutines.

    When waiting for the yielded coroutines you'll get the results (or
    exceptions!) of the original Futures (or coroutines), in the order
    in which and as soon as they complete.

    This differs from PEP 3148; the proper way to use this is:

        for f in as_completed(fs):
            result = await f  # The 'await' may raise.
            # Use result.

    If a timeout is specified, the 'await' will raise
    TimeoutError when the timeout occurs before all Futures are done.

    Note: The futures 'f' are not necessarily members of fs.
    z#expect an iterable of futures, not r)�QueuerNr�r7r8csh|]}t|�d��qSr�r�r�rr!r"r)Uszas_completed.<locals>.<setcomp>cs*�D]}|�����d�q���dSr1)r��
put_nowait�clearr�)r�r%�todor!r"�_on_timeoutXs
z!as_completed.<locals>._on_timeoutcs4�sdS��|���|��s0�dk	r0���dSr1)�remover�rgr�)r%r�r�r!r"r�^s

z$as_completed.<locals>._on_completionc�s$���IdH}|dkrtj�|��Sr1)rrr�r_r�)r%r!r"�
_wait_for_onefsz#as_completed.<locals>._wait_for_one)rr�rrErGr�rxZqueuesr�rr/r:r;r<r�rrr��ranger�)r�r r~r�r�r�r��_r!)r�r%r r�r�r"r7s*

�rccs
dVdS)z�Skip one event loop run cycle.

    This is a private helper for 'asyncio.sleep()', used
    when the 'delay' is set to 0.  It uses a bare 'yield'
    expression (which Task.__step knows how to handle)
    instead of creating a Future object.
    Nr!r!r!r!r"�__sleep0us	r�c�sr|dkrt�IdH|S|dkr*t��}ntjdtdd�|��}|�|tj	||�}z|IdHW�S|�
�XdS)z9Coroutine that completes after a given time (in seconds).rNr�r7r8)r�rrr:r;r<r�r�rZ_set_result_unless_cancelledrg)Zdelayr_r rw�hr!r!r"r	�s$
��r	cCs�t�|�r6|dkrt��}|�|�}|jr2|jd=|St�|�rb|dk	r^|t�|�k	r^t	d��|St
�|�r|tt
|�|d�Std��dS)zmWrap a coroutine or an awaitable in a future.

    If the argument is a Future, it is returned directly.
    Nr?zRThe future belongs to a different loop than the one specified as the loop argumentrz:An asyncio.Future, a coroutine or an awaitable is required)rrErr/rrDrr�r$r�rtZisawaitabler�_wrap_awaitablerG)Zcoro_or_futurer r4r!r!r"r�s



rccs|��EdHS)z�Helper for asyncio.ensure_future().

    Wraps awaitable (an object with __await__) into a coroutine
    that will later be wrapped in a Task by ensure_future().
    N)�	__await__)Z	awaitabler!r!r"r��sr�cs.eZdZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFuturez�Helper for gather().

    This overrides cancel() to cancel all the children and act more
    like Task.cancel(), which doesn't immediately mark itself as
    cancelled.
    Nrcst�j|d�||_d|_dS)NrF)rBrC�	_children�_cancel_requested)rS�childrenr rUr!r"rC�sz_GatheringFuture.__init__cCs6|��rdSd}|jD]}|��rd}q|r2d|_|S)NFT)r%r�rgr�)rSZretZchildr!r!r"rg�s
z_GatheringFuture.cancel)rxryrzr{rCrgr}r!r!rUr"r��sr�F)r �return_exceptionscs�|s<|dkrt��}ntjdtdd�|�����g��S�����fdd�}i}g�d�d�|D]f}||kr�t||d�}|dkr�t�	|�}||k	r�d	|_
�d
7�|||<|�|�n||}��|�qdt
�|d���S)a�Return a future aggregating results from the given coroutines/futures.

    Coroutines will be wrapped in a future and scheduled in the event
    loop. They will not necessarily be scheduled in the same order as
    passed in.

    All futures must share the same event loop.  If all the tasks are
    done successfully, the returned future's result is the list of
    results (in the order of the original sequence, not necessarily
    the order of results arrival).  If *return_exceptions* is True,
    exceptions in the tasks are treated the same as successful
    results, and gathered in the result list; otherwise, the first
    raised exception will be immediately propagated to the returned
    future.

    Cancellation: if the outer Future is cancelled, all children (that
    have not completed yet) are also cancelled.  If any child is
    cancelled, this is treated as if it raised CancelledError --
    the outer Future is *not* cancelled in this case.  (This is to
    prevent the cancellation of one child to cause other children to
    be cancelled.)

    If *return_exceptions* is False, cancelling gather() after it
    has been marked done won't cancel any submitted awaitables.
    For instance, gather can be marked done after propagating an
    exception to the caller, therefore, calling ``gather.cancel()``
    after catching an exception (raised by one of the awaitables) from
    gather won't cancel any other awaitables.
    Nr�r7r8cs��d7����r$|��s |��dS�sd|��rFt��}��|�dS|��}|dk	rd��|�dS��kr�g}�D]8}|��r�t��}n|��}|dkr�|��}|�|�qt�jrĈ�t���n
��	|�dS)Nr)
r%r�rarrjrbr_�appendr�r`)r�ruZresults�res�r�Z	nfinishedZnfuts�outerr�r!r"�_done_callbacks4


zgather.<locals>._done_callbackrrFr)rr/r:r;r<r�r`rrr$rFrrr�r�)r r�Zcoros_or_futuresr�Z
arg_to_fut�argr�r!r�r"r
�s:
�
1
r
cst|dk	rtjdtdd�t||d�����r0�St���}|����fdd����fdd	�}������|��S)
a.Wait for a future, shielding it from cancellation.

    The statement

        res = await shield(something())

    is exactly equivalent to the statement

        res = await something()

    *except* that if the coroutine containing it is cancelled, the
    task running in something() is not cancelled.  From the POV of
    something(), the cancellation did not happen.  But its caller is
    still cancelled, so the yield-from expression still raises
    CancelledError.  Note: If something() is cancelled by other means
    this will still cancel shield().

    If you want to completely ignore cancellation (not recommended)
    you can combine shield() with a try/except clause, as follows:

        try:
            res = await shield(something())
        except CancelledError:
            res = None
    Nr�r7r8rcs\���r|��s|��dS|��r.���n*|��}|dk	rJ��|�n��|���dSr1)r�rargrbr`r_)�innerru�r�r!r"�_inner_done_callbackus
z$shield.<locals>._inner_done_callbackcs���s����dSr1)r%r�r�)r�r�r!r"�_outer_done_callback�sz$shield.<locals>._outer_done_callback)	r:r;r<rr%rr$r�rr)r�r r�r!)r�r�r�r"rPs�


rcs:t���std��tj������fdd�}��|��S)zsSubmit a coroutine object to a given event loop.

    Return a concurrent.futures.Future to access the result.
    zA coroutine object is requiredc
slzt�t��d���WnNttfk
r2�Yn6tk
rf}z���rT��|��W5d}~XYnXdS)Nr)rZ
_chain_futurerrornrpZset_running_or_notify_cancelrb)ru�rTrwr r!r"�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rrErG�
concurrentr�FutureZcall_soon_threadsafe)rTr r�r!r�r"r
�s



r
cCst�|�dS)z3Register a new task in asyncio as executed by loop.N)r+r��r4r!r!r"r�srcCs4t�|�}|dk	r(td|�d|�d���|t|<dS)NzCannot enter into task z while another task z is being executed.�rrr,�r r4rr!r!r"r�s
rcCs2t�|�}||k	r(td|�d|�d���t|=dS)Nz
Leaving task z! does not match the current task �.r�r�r!r!r"r�s
rcCst�|�dS)zUnregister a task.N)r+�discardr�r!r!r"r�sr)rrrrr+r)N)N)N)N)Br{�__all__Zconcurrent.futuresr�rNr�rt�	itertools�typesr:�weakref�rrrrrr�count�__next__rHrrr0r6Z	_PyFuturerZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrr�rr�r�r�	coroutiner�r	rr�r�r�r
rr
ZWeakSetr+rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ
_c_enter_taskZ
_c_leave_taskr!r!r!r"�<module>s�	





#H,>

x?$PK0�\����subprocess.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ej
Z
ejZejZGd	d
�d
ej
ej�ZGdd�d�Zddddejfd
d�Zddddejd�dd�ZdS))�create_subprocess_exec�create_subprocess_shell�N�)�events)�	protocols)�streams)�tasks)�loggercsXeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Z�ZS)�SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.csHt�j|d�||_d|_|_|_d|_d|_g|_|j	�
�|_dS)N��loopF)�super�__init__�_limit�stdin�stdout�stderr�
_transport�_process_exited�	_pipe_fds�_loopZ
create_future�
_stdin_closed)�self�limitr��	__class__��*/usr/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk	r&|�d|j���|jdk	rB|�d|j���|jdk	r^|�d|j���d�d�|��S)Nzstdin=zstdout=zstderr=z<{}>� )r�__name__r�appendrr�format�join)r�inforrr�__repr__s



z!SubprocessStreamProtocol.__repr__cCs�||_|�d�}|dk	rDtj|j|jd�|_|j�|�|j�	d�|�d�}|dk	r�tj|j|jd�|_
|j
�|�|j�	d�|�d�}|dk	r�tj||d|jd�|_dS)Nr�rr�r)�protocol�readerr)
r�get_pipe_transportr�StreamReaderrrrZ
set_transportrr r�StreamWriterr)r�	transportZstdout_transportZstderr_transportZstdin_transportrrr�connection_made)s,
�
�
�z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk	r6|�|�dS)Nrr&)rrZ	feed_data)r�fd�datar(rrr�pipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs�|dkrN|j}|dk	r|��|�|�|dkr>|j�d�n|j�|�dS|dkr^|j}n|dkrn|j}nd}|dk	r�|dkr�|��n
|�|�||j	kr�|j	�
|�|��dS)Nrrr&)r�closeZconnection_lostrZ
set_resultZ
set_exceptionrrZfeed_eofr�remove�_maybe_close_transport)rr.�exc�piper(rrr�pipe_connection_lostKs*



z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|��dS)NT)rr3�rrrr�process_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|j�dkr$|jr$|j��d|_dS)Nr)�lenrrrr1r7rrrr3js
z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdS�N)rr)r�streamrrr�_get_close_waiteros
z*SubprocessStreamProtocol._get_close_waiter)
r�
__module__�__qualname__�__doc__rr$r-r0r6r8r3r<�
__classcell__rrrrr
s	

r
c@sjeZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ddd�ZdS)�ProcesscCs8||_||_||_|j|_|j|_|j|_|��|_dSr:)rZ	_protocolrrrrZget_pid�pid)rr,r'rrrrruszProcess.__init__cCsd|jj�d|j�d�S)N�<r�>)rrrBr7rrrr$~szProcess.__repr__cCs
|j��Sr:)rZget_returncoder7rrr�
returncode�szProcess.returncodec�s|j��IdHS)z?Wait until the process exit and return the process return code.N)rZ_waitr7rrr�wait�szProcess.waitcCs|j�|�dSr:)r�send_signal)r�signalrrrrG�szProcess.send_signalcCs|j��dSr:)r�	terminater7rrrrI�szProcess.terminatecCs|j��dSr:)r�killr7rrrrJ�szProcess.killc
�s�|j��}|j�|�|r,t�d|t|��z|j��IdHWn8tt	fk
rx}z|rht�d||�W5d}~XYnX|r�t�d|�|j�
�dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r�	get_debugr�writer	�debugr9Zdrain�BrokenPipeError�ConnectionResetErrorr1)r�inputrMr4rrr�_feed_stdin�s 
� zProcess._feed_stdinc�sdSr:rr7rrr�_noop�sz
Process._noopc�s�|j�|�}|dkr|j}n|j}|j��rJ|dkr8dnd}t�d||�|��IdH}|j��r�|dkrndnd}t�d||�|�	�|S)Nr&rrrz%r communicate: read %sz%r communicate: close %s)
rr)rrrrKr	rM�readr1)rr.r,r;�name�outputrrr�_read_stream�s

zProcess._read_streamNc�s�|dk	r|�|�}n|��}|jdk	r2|�d�}n|��}|jdk	rP|�d�}n|��}tj||||jd�IdH\}}}|��IdH||fS)Nrr&r)	rQrRrrVrrZgatherrrF)rrPrrrrrr�communicate�s


�zProcess.communicate)N)rr=r>rr$�propertyrErFrGrIrJrQrRrVrWrrrrrAts	
rAc
�sb�dkrt���ntjdtdd���fdd�}�j||f|||d�|��IdH\}}	t||	��S)N�ZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r&��
stacklevelcst��d�S�Nr%�r
rr%rr�<lambda>�s�z)create_subprocess_shell.<locals>.<lambda>�rrr)r�get_event_loop�warnings�warn�DeprecationWarningZsubprocess_shellrA)
�cmdrrrrr�kwds�protocol_factoryr,r'rr%rr�s$
����r)rrrrrc�sf�dkrt���ntjdtdd���fdd�}�j||f|�|||d�|��IdH\}	}
t|	|
��S)NrYr&rZcst��d�Sr\r]rr%rrr^�s�z(create_subprocess_exec.<locals>.<lambda>r_)rr`rarbrcZsubprocess_execrA)Zprogramrrrrr�argsrerfr,r'rr%rr�s(
�����r)�__all__�
subprocessra�rrrr�logr	�PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr
rAZ_DEFAULT_LIMITrrrrrr�<module>s.�bV�
�PK0�\��q�llbase_futures.cpython-38.pycnu�[���U

e5d
�@sRdZddlZddlmZddlmZdZdZdZd	d
�Z	dd�Z
e�Zd
d�Z
dS)��N)�	get_ident�)�format_helpersZPENDINGZ	CANCELLEDZFINISHEDcCst|jd�o|jdk	S)z�Check for a Future.

    This returns True when obj is a Future instance or is advertising
    itself as duck-type compatible by setting _asyncio_future_blocking.
    See comment in Future for more details.
    �_asyncio_future_blockingN)�hasattr�	__class__r)�objrr�,/usr/lib64/python3.8/asyncio/base_futures.py�isfutures�rcCs�t|�}|sd}dd�}|dkr2||dd�}n`|dkr`d�||dd�||dd��}n2|dkr�d�||dd�|d||d	d��}d
|�d�S)�#helper function for Future.__repr__�cSst�|d�S)Nr)rZ_format_callback_source)�callbackrrr
�	format_cbsz$_format_callbacks.<locals>.format_cbrr�z{}, {}z{}, <{} more>, {}���zcb=[�])�len�format)�cb�sizerrrr
�_format_callbackss&�rc	Cs�|j��g}|jtkr�|jdk	r4|�d|j���nTt|�t�f}|tkrPd}n(t�|�zt
�|j�}W5t�	|�X|�d|���|j
r�|�t|j
��|jr�|jd}|�d|d�d|d	���|S)
rNz
exception=z...zresult=rzcreated at r�:r)Z_state�lower�	_FINISHEDZ
_exception�append�idr�
_repr_running�add�discard�reprlib�reprZ_resultZ
_callbacksrZ_source_traceback)Zfuture�info�key�result�framerrr
�_future_repr_info7s$



r&)�__all__r �_threadrr
rZ_PENDINGZ
_CANCELLEDrrr�setrr&rrrr
�<module>sPK0�\?��O�Ostreams.cpython-38.opt-1.pycnu�[���U

e5d h�@s&dZddlZddlZddlZddlZeed�r6ed7ZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZd
Zdded�dd�Zd ded�dd�Zeed�r�d!ded�dd�Zd"ded�dd�ZGdd�dej�ZGdd�deej�ZGdd�d�ZGdd�d�ZdS)#)�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�NZAF_UNIX)�open_unix_connection�start_unix_server�)�
coroutines)�events)�
exceptions)�format_helpers)�	protocols)�logger)�sleepi)�loop�limitc	�st|dkrt��}ntjdtdd�t||d�}t||d��|j�fdd�||f|�IdH\}}t|�||�}||fS)	a�A wrapper for create_connection() returning a (reader, writer) pair.

    The reader returned is a StreamReader instance; the writer is a
    StreamWriter instance.

    The arguments are all the usual arguments to create_connection()
    except protocol_factory; most common are positional host and port,
    with various optional keyword arguments following.

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    (If you want to customize the StreamReader and/or
    StreamReaderProtocol classes, just copy the code -- there's
    really nothing special here except some convenience.)
    N�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.���
stacklevel�rr�rcs�S�N�r��protocolr�'/usr/lib64/python3.8/asyncio/streams.py�<lambda>5�z!open_connection.<locals>.<lambda>)	r�get_event_loop�warnings�warn�DeprecationWarningrrZcreate_connectionr)	�host�portrr�kwds�reader�	transport�_�writerrrrrs"
�
��rc�sJ�dkrt���ntjdtdd����fdd�}�j|||f|�IdHS)a�Start a socket server, call back for each client connected.

    The first parameter, `client_connected_cb`, takes two parameters:
    client_reader, client_writer.  client_reader is a StreamReader
    object, while client_writer is a StreamWriter object.  This
    parameter can either be a plain callback function or a coroutine;
    if it is a coroutine, it will be automatically converted into a
    Task.

    The rest of the arguments are all the usual arguments to
    loop.create_server() except protocol_factory; most common are
    positional host and port, with various optional keyword arguments
    following.  The return value is the same as loop.create_server().

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    The return value is the same as loop.create_server(), i.e. a
    Server object which can be used to stop the service.
    Nrrrcst��d�}t|��d�}|S�Nrr�rr�r'r��client_connected_cbrrrr�factoryXs
�zstart_server.<locals>.factory)rr r!r"r#Z
create_server)r/r$r%rrr&r0rr.rr:s
�rc�sr|dkrt��}ntjdtdd�t||d�}t||d��|j�fdd�|f|�IdH\}}t|�||�}||fS)	z@Similar to `open_connection` but works with UNIX Domain Sockets.Nrrrrrcs�Srrrrrrrprz&open_unix_connection.<locals>.<lambda>)	rr r!r"r#rrZcreate_unix_connectionr)�pathrrr&r'r(r)r*rrrrds 
�
��rc�sH�dkrt���ntjdtdd����fdd�}�j||f|�IdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Nrrrcst��d�}t|��d�}|Sr+r,r-r.rrr0~s
�z"start_unix_server.<locals>.factory)rr r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts
�rc@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�FlowControlMixina)Reusable flow control logic for StreamWriter.drain().

    This implements the protocol methods pause_writing(),
    resume_writing() and connection_lost().  If the subclass overrides
    these it must call the super methods.

    StreamWriter.drain() must wait for _drain_helper() coroutine.
    NcCs0|dkrt��|_n||_d|_d|_d|_dS�NF)rr �_loop�_paused�
_drain_waiter�_connection_lost)�selfrrrr�__init__�szFlowControlMixin.__init__cCs d|_|j��rt�d|�dS)NTz%r pauses writing)r5r4�	get_debugr�debug�r8rrr�
pause_writing�s
zFlowControlMixin.pause_writingcCsFd|_|j��rt�d|�|j}|dk	rBd|_|��sB|�d�dS)NFz%r resumes writing)r5r4r:rr;r6�done�
set_result�r8�waiterrrr�resume_writing�s
zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|��r4dS|dkrH|�d�n
|�|�dS�NT)r7r5r6r>r?�
set_exception�r8�excrArrr�connection_lost�sz FlowControlMixin.connection_lostc�s<|jrtd��|jsdS|j}|j��}||_|IdHdS)NzConnection lost)r7�ConnectionResetErrorr5r6r4�
create_futurer@rrr�
_drain_helper�s
zFlowControlMixin._drain_helpercCst�dSr)�NotImplementedError�r8�streamrrr�_get_close_waiter�sz"FlowControlMixin._get_close_waiter)N)
�__name__�
__module__�__qualname__�__doc__r9r=rBrGrJrNrrrrr2�s	
	r2csfeZdZdZdZd�fdd�	Zedd��Zdd�Z�fd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
�ZS)ra=Helper class to adapt between Protocol and StreamReader.

    (This is a helper class instead of making StreamReader itself a
    Protocol subclass, because the StreamReader has other potential
    uses, and to prevent the user of the StreamReader to accidentally
    call inappropriate methods of the protocol.)
    Ncsnt�j|d�|dk	r,t�|�|_|j|_nd|_|dk	r@||_d|_d|_d|_	||_
d|_|j�
�|_dS)NrF)�superr9�weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer�
_transport�_client_connected_cb�	_over_sslr4rI�_closed)r8Z
stream_readerr/r��	__class__rrr9�s
zStreamReaderProtocol.__init__cCs|jdkrdS|��Sr)rVr<rrr�_stream_reader�s
z#StreamReaderProtocol._stream_readercCs�|jr6ddi}|jr|j|d<|j�|�|��dS||_|j}|dk	rT|�|�|�d�dk	|_	|j
dk	r�t||||j�|_|�
||j�}t
�|�r�|j�|�d|_dS)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ
sslcontext)rYrWr4Zcall_exception_handler�abortr[ra�
set_transport�get_extra_infor]r\rrZr
ZiscoroutineZcreate_taskrX)r8r(�contextr'�resrrr�connection_made�s2�


��
z$StreamReaderProtocol.connection_madecsx|j}|dk	r*|dkr |��n
|�|�|j��sV|dkrJ|j�d�n|j�|�t��|�d|_d|_	d|_
dSr)ra�feed_eofrDr^r>r?rSrGrVrZr[)r8rFr'r_rrrG
s


z$StreamReaderProtocol.connection_lostcCs|j}|dk	r|�|�dSr)ra�	feed_data)r8�datar'rrr�
data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk	r|��|jr dSdS)NFT)rarir])r8r'rrr�eof_received sz!StreamReaderProtocol.eof_receivedcCs|jSr)r^rLrrrrN+sz&StreamReaderProtocol._get_close_waitercCs"|j}|��r|��s|��dSr)r^r>�	cancelled�	exception)r8�closedrrr�__del__.szStreamReaderProtocol.__del__)NN)rOrPrQrRrWr9�propertyrarhrGrlrmrNrq�
__classcell__rrr_rr�s
rc@sveZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zddd�Zdd�ZdS)ra'Wraps a Transport.

    This exposes write(), writelines(), [can_]write_eof(),
    get_extra_info() and close().  It adds drain() which returns an
    optional Future on which you can wait for flow control.  It also
    adds a transport property which references the Transport
    directly.
    cCs4||_||_||_||_|j��|_|j�d�dSr)r[�	_protocol�_readerr4rIZ
_complete_futr?)r8r(rr'rrrrr9@szStreamWriter.__init__cCs@|jjd|j��g}|jdk	r0|�d|j���d�d�|��S)N�
transport=zreader=�<{}>� )r`rOr[ru�append�format�join�r8�inforrr�__repr__Js
zStreamWriter.__repr__cCs|jSr�r[r<rrrr(PszStreamWriter.transportcCs|j�|�dSr)r[�write�r8rkrrrr�TszStreamWriter.writecCs|j�|�dSr)r[�
writelinesr�rrrr�WszStreamWriter.writelinescCs
|j��Sr)r[�	write_eofr<rrrr�ZszStreamWriter.write_eofcCs
|j��Sr)r[�
can_write_eofr<rrrr�]szStreamWriter.can_write_eofcCs
|j��Sr)r[�closer<rrrr�`szStreamWriter.closecCs
|j��Sr)r[�
is_closingr<rrrr�cszStreamWriter.is_closingc�s|j�|�IdHdSr)rtrNr<rrr�wait_closedfszStreamWriter.wait_closedNcCs|j�||�Sr)r[re)r8�name�defaultrrrreiszStreamWriter.get_extra_infoc�sL|jdk	r |j��}|dk	r |�|j��r8td�IdH|j��IdHdS)zyFlush the write buffer.

        The intended use is to write

          w.write(data)
          await w.drain()
        Nr)ruror[r�rrtrJ)r8rFrrr�drainls



zStreamWriter.drain)N)rOrPrQrRr9r~rrr(r�r�r�r�r�r�r�rer�rrrrr6s	


rc@s�eZdZdZedfdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd&dd�Zd'dd�Zd d!�Zd"d#�Zd$d%�ZdS)(rNcCsv|dkrtd��||_|dkr*t��|_n||_t�|_d|_d|_d|_	d|_
d|_|j��rrt
�t�d��|_dS)NrzLimit cannot be <= 0Fr	)�
ValueError�_limitrr r4�	bytearray�_buffer�_eof�_waiter�
_exceptionr[r5r:r
�
extract_stack�sys�	_getframerW)r8rrrrrr9�s 
�zStreamReader.__init__cCs�dg}|jr"|�t|j��d��|jr2|�d�|jtkrN|�d|j���|jrf|�d|j���|jr~|�d|j���|jr�|�d|j���|j	r�|�d�d	�
d
�|��S)Nrz bytes�eofzlimit=zwaiter=z
exception=rvZpausedrwrx)r�ry�lenr�r��_DEFAULT_LIMITr�r�r[r5rzr{r|rrrr~�s 


zStreamReader.__repr__cCs|jSr)r�r<rrrro�szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|��s,|�|�dSr)r�r�rnrDrErrrrD�szStreamReader.set_exceptioncCs*|j}|dk	r&d|_|��s&|�d�dS)z1Wakeup read*() functions waiting for data or EOF.N)r�rnr?r@rrr�_wakeup_waiter�s
zStreamReader._wakeup_waitercCs
||_dSrr)r8r(rrrrd�szStreamReader.set_transportcCs*|jr&t|j�|jkr&d|_|j��dSr3)r5r�r�r�r[�resume_readingr<rrr�_maybe_resume_transport�sz$StreamReader._maybe_resume_transportcCsd|_|��dSrC)r�r�r<rrrri�szStreamReader.feed_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)r�r�r<rrr�at_eof�szStreamReader.at_eofcCst|sdS|j�|�|��|jdk	rp|jspt|j�d|jkrpz|j��Wntk
rhd|_YnXd|_dS)NrT)	r��extendr�r[r5r�r�Z
pause_readingrKr�rrrrj�s
��zStreamReader.feed_datac�sX|jdk	rt|�d���|jr.d|_|j��|j��|_z|jIdHW5d|_XdS)zpWait until feed_data() or feed_eof() is called.

        If stream was paused, automatically resume it.
        NzF() called while another coroutine is already waiting for incoming dataF)r��RuntimeErrorr5r[r�r4rI)r8Z	func_namerrr�_wait_for_data�s	
�
zStreamReader._wait_for_datac
�s�d}t|�}z|�|�IdH}Wn�tjk
rN}z|jWY�Sd}~XYnhtjk
r�}zH|j�||j�r�|jd|j|�=n
|j�	�|�
�t|jd��W5d}~XYnX|S)a�Read chunk of data from the stream until newline (b'
') is found.

        On success, return chunk that ends with newline. If only partial
        line can be read due to EOF, return incomplete line without
        terminating newline. When EOF was reached while no bytes read, empty
        bytes object is returned.

        If limit is reached, ValueError will be raised. In that case, if
        newline was found, complete line including newline will be removed
        from internal buffer. Else, internal buffer will be cleared. Limit is
        compared against part of the line without newline.

        If stream was paused, this function will automatically resume it if
        needed.
        �
Nr)
r��	readuntilr�IncompleteReadError�partial�LimitOverrunErrorr��
startswith�consumed�clearr�r��args)r8�sep�seplen�line�errr�readline	s
 zStreamReader.readliner�c�s�t|�}|dkrtd��|jdk	r(|j�d}t|j�}|||kr||j�||�}|dkrZq�|d|}||jkr|t�d|��|jr�t	|j�}|j�
�t�|d��|�d�IdHq,||jkr�t�d|��|jd||�}|jd||�=|�
�t	|�S)	aVRead data from the stream until ``separator`` is found.

        On success, the data and separator will be removed from the
        internal buffer (consumed). Returned data will include the
        separator at the end.

        Configured stream limit is used to check result. Limit sets the
        maximal length of data that can be returned, not counting the
        separator.

        If an EOF occurs and the complete separator is still not found,
        an IncompleteReadError exception will be raised, and the internal
        buffer will be reset.  The IncompleteReadError.partial attribute
        may contain the separator partially.

        If the data cannot be read because of over limit, a
        LimitOverrunError exception  will be raised, and the data
        will be left in the internal buffer, so it can be read again.
        rz,Separator should be at least one-byte stringN���r	z2Separator is not found, and chunk exceed the limitr�z2Separator is found, but chunk is longer than limit)r�r�r�r��findr�rr�r��bytesr�r�r�r�)r8Z	separatorr��offsetZbuflenZisep�chunkrrrr�(s>


�


�zStreamReader.readuntilr�c�s�|jdk	r|j�|dkrdS|dkrVg}|�|j�IdH}|s@qL|�|�q(d�|�S|jsr|jsr|�d�IdHt|jd|��}|jd|�=|�	�|S)a�Read up to `n` bytes from the stream.

        If n is not provided, or set to -1, read until EOF and return all read
        bytes. If the EOF was received and the internal buffer is empty, return
        an empty bytes object.

        If n is zero, return empty bytes object immediately.

        If n is positive, this function try to read `n` bytes, and may return
        less or equal bytes than requested, but at least one byte. If EOF was
        received before any byte is read, this function returns empty byte
        object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        Nrr�read)
r�r�r�ryr{r�r�r�r�r�)r8�nZblocks�blockrkrrrr��s"

zStreamReader.readc�s�|dkrtd��|jdk	r |j�|dkr,dSt|j�|krr|jr`t|j�}|j��t�||��|�	d�IdHq,t|j�|kr�t|j�}|j��nt|jd|��}|jd|�=|�
�|S)a�Read exactly `n` bytes.

        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.

        if n is zero, return empty bytes object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        rz*readexactly size can not be less than zeroNr�readexactly)r�r�r�r�r�r�r�rr�r�r�)r8r�Z
incompleterkrrrr��s&



zStreamReader.readexactlycCs|Srrr<rrr�	__aiter__�szStreamReader.__aiter__c�s|��IdH}|dkrt�|S)Nr)r��StopAsyncIteration)r8�valrrr�	__anext__�szStreamReader.__anext__)r�)r�)rOrPrQrWr�r9r~rorDr�rdr�rir�rjr�r�r�r�r�r�r�rrrrr�s$	
[
2)r)NN)NN)N)N)�__all__Zsocketr�r!rT�hasattr�r
rrr
r�logrZtasksrr�rrrrZProtocolr2rrrrrrr�<module>sF
�!�'
��DkPPK0�\l[˅	`	`windows_events.cpython-38.pycnu�[���U

e5di��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddlmZd
ZdZdZdZdZdZdZGdd�de
j�ZGdd�de
j�ZGdd�de�ZGdd�de�Z Gdd�de!�Z"Gdd�dej#�Z$Gdd �d ej%�Z&Gd!d"�d"�Z'Gd#d$�d$ej(�Z)e$Z*Gd%d&�d&ej+�Z,Gd'd(�d(ej+�Z-e-Z.dS))z.Selector and proactor event loops for Windows.�N�)�events)�base_subprocess)�futures)�
exceptions)�proactor_events)�selector_events)�tasks)�
windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicy���i�i�g����MbP?g�������?cs^eZdZdZdd��fdd�
Z�fdd�Zdd	�Z�fd
d�Z�fdd
�Z�fdd�Z	�Z
S)�_OverlappedFuturez�Subclass of Future which represents an overlapped operation.

    Cancelling it will immediately cancel the overlapped operation.
    N��loopcs&t�j|d�|jr|jd=||_dS�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr��	__class__��./usr/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt���}|jdk	rD|jjr dnd}|�dd|�d|jjd�d��|S)N�pendingZ	completedrzoverlapped=<z, �#x�>)r�
_repr_inforr"�insert�address�r�info�staterr r!r%7s


 z_OverlappedFuture._repr_infoc
Csr|jdkrdSz|j��WnJtk
rf}z,d||d�}|jrJ|j|d<|j�|�W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failed��message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextr r r!�_cancel_overlapped>s
�
z$_OverlappedFuture._cancel_overlappedcs|��t���S�N)r6rr0�rrr r!r0Nsz_OverlappedFuture.cancelcst��|�|��dSr7)r�
set_exceptionr6�rr-rr r!r9Rsz_OverlappedFuture.set_exceptioncst��|�d|_dSr7)r�
set_resultr�r�resultrr r!r;Vsz_OverlappedFuture.set_result)�__name__�
__module__�__qualname__�__doc__rr%r6r0r9r;�
__classcell__r r rr!r+srcsneZdZdZdd��fdd�
Zdd�Z�fdd	�Zd
d�Zdd
�Z�fdd�Z	�fdd�Z
�fdd�Z�ZS)�_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrcs8t�j|d�|jr|jd=||_||_||_d|_dS)NrrT)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst�|jd�tjkS�Nr)�_winapiZWaitForSingleObjectrDZ
WAIT_OBJECT_0r8r r r!�_pollls�z_BaseWaitHandleFuture._pollcsdt���}|�d|jd���|jdk	rB|��r4dnd}|�|�|jdk	r`|�d|jd���|S)Nzhandle=r#ZsignaledZwaitingzwait_handle=)rr%�appendrDrKrEr(rr r!r%qs



z _BaseWaitHandleFuture._repr_infocCs
d|_dSr7)r�r�futr r r!�_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�|�Wn`tk
r�}zB|jtjkrzd||d�}|jrd|j|d<|j�	|�WY�dSW5d}~XYnX|�
d�dS�NFz$Failed to unregister the wait handler+r/)rFrE�_overlappedZUnregisterWaitr1�winerror�ERROR_IO_PENDINGrr2r3rO�rrHr4r5r r r!�_unregister_wait�s$�
z&_BaseWaitHandleFuture._unregister_waitcs|��t���Sr7)rUrr0r8rr r!r0�sz_BaseWaitHandleFuture.cancelcs|��t��|�dSr7)rUrr9r:rr r!r9�sz#_BaseWaitHandleFuture.set_exceptioncs|��t��|�dSr7)rUrr;r<rr r!r;�sz _BaseWaitHandleFuture.set_result)
r>r?r@rArrKr%rOrUr0r9r;rBr r rr!rC[s
rCcsFeZdZdZdd��fdd�
Zdd�Z�fdd	�Z�fd
d�Z�ZS)�_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a
    _WaitHandleFuture using an event.
    Nrcst�j||||d�d|_dS)Nr)rr�_done_callback)rr�eventrHrrr r!r�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr8r r r!r0�sz_WaitCancelFuture.cancelcs$t��|�|jdk	r |�|�dSr7)rr;rWr<rr r!r;�s
z_WaitCancelFuture.set_resultcs$t��|�|jdk	r |�|�dSr7)rr9rWr:rr r!r9�s
z_WaitCancelFuture.set_exception)	r>r?r@rArr0r;r9rBr r rr!rV�s
rVcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureNrcs<t�j||||d�||_d|_t�dddd�|_d|_dS)NrTF)rr�	_proactorZ_unregister_proactorrQZCreateEvent�_event�
_event_fut)rrrGrH�proactorrrr r!r�s
z_WaitHandleFuture.__init__csF|jdk	r"t�|j�d|_d|_|j�|j�d|_t��|�dSr7)	r\rJ�CloseHandler]r[�_unregisterrrrOrMrr r!rO�s
	z%_WaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�||j�Wn`tk
r�}zB|jtjkr~d||d�}|jrh|j|d<|j	�
|�WY�dSW5d}~XYnX|j�|j|j
�|_dSrP)rFrErQZUnregisterWaitExr\r1rRrSrr2r3r[�_wait_cancelrOr]rTr r r!rU�s(�

�z"_WaitHandleFuture._unregister_wait)r>r?r@rrOrUrBr r rr!rZ�srZc@s<eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZeZ	dS)
�
PipeServerzXClass representing a pipe server.

    This is much like a bound, listening socket.
    cCs,||_t��|_d|_d|_|�d�|_dS�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr'r r r!r�s

zPipeServer.__init__cCs|j|�d�}|_|S)NF)rhrj)r�tmpr r r!�_get_unconnected_pipesz PipeServer._get_unconnected_pipec
Csr|��rdStjtjB}|r&|tjO}t�|j|tjtjBtj	Btj
tjtjtj
tj�}t�|�}|j�|�|Sr7)�closedrJZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperdZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr
ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerg�add)r�first�flags�h�piper r r!rjs(

��
zPipeServer._server_pipe_handlecCs
|jdkSr7)rdr8r r r!rmszPipeServer.closedcCsR|jdk	r|j��d|_|jdk	rN|jD]}|��q*d|_d|_|j��dSr7)rir0rdrg�closerh�clear)rrtr r r!rus




zPipeServer.closeN)
r>r?r@rArrlrjrmru�__del__r r r r!rb�s
rbc@seZdZdZdS)�_WindowsSelectorEventLoopz'Windows version of selector event loop.N)r>r?r@rAr r r r!rx,srxcsHeZdZdZd
�fdd�	Z�fdd�Zdd�Zd	d
�Zddd�Z�Z	S)r
z2Windows version of proactor event loop using IOCP.Ncs|dkrt�}t��|�dSr7)rrr)rr^rr r!r3szProactorEventLoop.__init__c	sfz(|jdkst�|�|j�t��	�W5|jdk	r`|jj}|j��|dk	rZ|j�|�d|_XdSr7)
Z_self_reading_futurerr0r[r`�AssertionError�	call_soonZ_loop_self_readingr�run_forever�rrrr r!r{8s

zProactorEventLoop.run_foreverc�s8|j�|�}|IdH}|�}|j||d|id�}||fS)N�addr��extra)r[�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr'�frt�protocol�transr r r!�create_pipe_connectionKs
�z(ProactorEventLoop.create_pipe_connectionc�s.t���d�����fdd�	������gS)Nc
sd}zn|rN|��}�j�|����r4|��WdS��}�j||d�id����}|dkrdWdS�j�|�}Wn�t	k
r�}zF|r�|�
�dkr���d||d��|��n�jr�t
jd|dd�W5d}~XYn2tjk
r�|r�|��YnX|�_|���dS)	Nr}r~rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)�exc_info)r=rg�discardrmrur�rlr[�accept_piper1�filenor3Z_debugrZwarningr�CancelledErrorri�add_done_callback)r�rtr�r4�r'�loop_accept_piper�rZserverr r!r�VsH��
�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rbrz)rr�r'r r�r!�start_serving_pipeSs(
z$ProactorEventLoop.start_serving_pipec		�s�|��}
t||||||||f|
|d�|	��}z|
IdHWnDttfk
rT�Yn,tk
r~|��|��IdH�YnX|S)N)�waiterr)�
create_future�_WindowsSubprocessTransport�
SystemExit�KeyboardInterrupt�
BaseExceptionruZ_wait)rr��args�shell�stdin�stdout�stderr�bufsizer�kwargsr�Ztranspr r r!�_make_subprocess_transport�s*
���z,ProactorEventLoop._make_subprocess_transport)N)N)
r>r?r@rArr{r�r�r�rBr r rr!r
0s0�r
c@s�eZdZdZd;dd�Zdd�Zdd�Zd	d
�Zd<dd
�Zdd�Z	d=dd�Z
d>dd�Zd?dd�Zd@dd�Z
dAdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdBd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZdCd3d4�Zd5d6�Zd7d8�Zd9d:�ZdS)Drz#Proactor implementation using IOCP.rcCsDd|_g|_t�tjtd|�|_i|_t�	�|_
g|_t�	�|_dSrI)
r2�_resultsrQ�CreateIoCompletionPort�INVALID_HANDLE_VALUErn�_iocp�_cachererfrF�
_unregistered�_stopped_serving)rZconcurrencyr r r!r�s�
zIocpProactor.__init__cCs|jdkrtd��dS)NzIocpProactor is closed)r�rYr8r r r!�
_check_closed�s
zIocpProactor._check_closedcCsFdt|j�dt|j�g}|jdkr0|�d�d|jjd�|�fS)Nzoverlapped#=%sz
result#=%srmz<%s %s>� )�lenr�r�r�rLrr>�join)rr)r r r!�__repr__�s�

zIocpProactor.__repr__cCs
||_dSr7)r2)rrr r r!�set_loop�szIocpProactor.set_loopNcCs |js|�|�|j}g|_|Sr7)r�rK)r�timeoutrkr r r!�select�s

zIocpProactor.selectcCs|j��}|�|�|Sr7)r2r�r;)r�valuerNr r r!�_result�s

zIocpProactor._resultrcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)N�c
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7��	getresultr1rRrQZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTED�ConnectionResetErrorr��r��keyrr4r r r!�finish_recv�s
�z&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocprQ�
Overlappedrn�
isinstance�socketZWSARecvr�ZReadFile�BrokenPipeErrorr��	_register�r�conn�nbytesrrrr�r r r!�recv�s


zIocpProactor.recvcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)Nrc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z+IocpProactor.recv_into.<locals>.finish_recv)r�rQr�rnr�r�ZWSARecvIntor�ZReadFileIntor�r�r�)rr��bufrrrr�r r r!�	recv_into�s


zIocpProactor.recv_intocCs`|�|�t�t�}z|�|��||�Wntk
rH|�d�YSXdd�}|�|||�S)N)r�Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z*IocpProactor.recvfrom.<locals>.finish_recv)	r�rQr�rnZWSARecvFromr�r�r�r�r�r r r!�recvfrom�s


zIocpProactor.recvfromcCs>|�|�t�t�}|�|��|||�dd�}|�|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sends
�z(IocpProactor.sendto.<locals>.finish_send)r�rQr�rnZ	WSASendTor�r�)rr�r�rrr}rr�r r r!�sendto�s



zIocpProactor.sendtocCsZ|�|�t�t�}t|tj�r4|�|��||�n|�|��|�dd�}|�	|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r�s
�z&IocpProactor.send.<locals>.finish_send)
r�rQr�rnr�r�ZWSASendr�Z	WriteFiler�)rr�r�rrrr�r r r!�sends


zIocpProactor.sendcsv|���|��j��t�t�}|����������fdd�}dd�}|�|�|�}||��}t	j
||jd�|S)NcsD|��t�d����}��tjtj|���	��
������fS)Nz@P)r��structZpackr��
setsockoptr��
SOL_SOCKETrQZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)r�r�rr��r��listenerr r!�
finish_accept*s�z*IocpProactor.accept.<locals>.finish_acceptc�s4z|IdHWn tjk
r.|���YnXdSr7)rr�ru)r.r�r r r!�accept_coro3s
z(IocpProactor.accept.<locals>.accept_coror)r��_get_accept_socket�familyrQr�rnZAcceptExr�r�r	Z
ensure_futurer2)rr�rr�r�r.�coror r�r!�accept$s

	
zIocpProactor.acceptc
s��jtjkr4t����|�|j��}|�d�|S|�	��zt�
����j�WnBtk
r�}z$|j
tjkrt����ddkr��W5d}~XYnXt�t�}|����|��fdd�}|�|�|�S)Nrrcs|����tjtjd��SrI)r�r�r�r�rQZSO_UPDATE_CONNECT_CONTEXT�r�r�r�r�r r!�finish_connectVs�z,IocpProactor.connect.<locals>.finish_connect)�typer�Z
SOCK_DGRAMrQZ
WSAConnectr�r2r�r;r�Z	BindLocalr�r1rR�errnoZ	WSAEINVALZgetsocknamer�rnZ	ConnectExr�)rr�r'rN�err�r r�r!�connect@s"



zIocpProactor.connectc		Csb|�|�t�t�}|d@}|d?d@}|�|��t�|���|||dd�dd�}|�|||�S)Nr� rc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sendfileis
�z.IocpProactor.sendfile.<locals>.finish_sendfile)	r�rQr�rnZTransmitFiler��msvcrtZ
get_osfhandler�)	rZsock�file�offset�countrZ
offset_lowZoffset_highr�r r r!�sendfile_s


�	zIocpProactor.sendfilecsJ|���t�t�}|�����}|r0|���S�fdd�}|�|�|�S)Ncs|���Sr7)r�r��rtr r!�finish_accept_pipesz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�rQr�rnZConnectNamedPiper�r�r�)rrtrZ	connectedr�r r�r!r�ts


zIocpProactor.accept_pipec
�srt}zt�|�}WqhWn0tk
rF}z|jtjkr6�W5d}~XYnXt|dt�}t�	|�IdHqt
�|�S)N�)�CONNECT_PIPE_INIT_DELAYrQZConnectPiper1rRZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr	�sleepr
ro)rr'ZdelayrGr4r r r!r��s
zIocpProactor.connect_pipecCs|�||d�S)z�Wait for a handle.

        Return a Future object. The result of the future is True if the wait
        completed, or False if the wait did not complete (on timeout).
        F)�_wait_for_handle)rrGr�r r r!�wait_for_handle�szIocpProactor.wait_for_handlecCs|�|dd�}||_|Src)r�rW)rrXZ
done_callbackrNr r r!ra�szIocpProactor._wait_cancelcs�|��|dkrtj}nt�|d�}t�t�}t�||j	|j
|�}|r\t||||jd��nt
|||||jd���jr~�jd=�fdd�}�|d|f|j|j
<�S)N�@�@rrcs���Sr7)rKr��r�r r!�finish_wait_for_handle�sz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handler)r�rJ�INFINITE�math�ceilrQr�rnZRegisterWaitWithQueuer�r'rVr2rZrr�)rrGr�Z
_is_cancel�msrrHr�r r�r!r��s*
�
�	zIocpProactor._wait_for_handlecCs0||jkr,|j�|�t�|��|jdd�dSrI)rFrprQr�r�r��r�objr r r!r��s
z IocpProactor._register_with_iocpc
Cs�|��t||jd�}|jr$|jd=|jsrz|dd|�}Wn,tk
rf}z|�|�W5d}~XYnX|�|�||||f|j|j	<|Sr)
r�rr2rr"r1r9r;r�r')rrr��callbackr�r�r�r r r!r��s

zIocpProactor._registercCs|��|j�|�dS)a
Unregister an overlapped object.

        Call this method when its future has been cancelled. The event can
        already be signalled (pending in the proactor event queue). It is also
        safe if the event is never signalled (because it was cancelled).
        N)r�r�rLr|r r r!r`�szIocpProactor._unregistercCst�|�}|�d�|SrI)r�r�)rr��sr r r!r��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��nt�|d�}|tkr>td��t�|j|�}|dkrX�qZd}|\}}}}z|j�|�\}}	}
}WnXt	k
r�|j
��r�|j
�dd||||fd��|dtj
fkr�t�|�Yq>YnX|
|jkr�|��q>|��s>z||||	�}Wn:tk
�r@}
z|�|
�|j�|�W5d}
~
XYq>X|�|�|j�|�q>|jD]}	|j�|	jd��q`|j��dS)Nrznegative timeoutr�ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,�status)r��
ValueErrorr�r�rQZGetQueuedCompletionStatusr�r��pop�KeyErrorr2Z	get_debugr3r�rJr_r�r0Zdoner1r9r�rLr;r�r'rv)rr�r�r��errZtransferredr�r'r�rr�r�r�r�r r r!rKsL


��	






zIocpProactor._pollcCs|j�|�dSr7)r�rpr�r r r!�
_stop_serving9szIocpProactor._stop_servingcCs|jdkrdSt|j���D]�\}\}}}}|��r6qt|t�rBqz|��Wqtk
r�}z6|j	dk	r�d||d�}|j
r�|j
|d<|j	�|�W5d}~XYqXqd}t�
�}	|	|}
|jr�|
t�
�kr�t�d|t�
�|	�t�
�|}
|�|�q�g|_t�|j�d|_dS)NzCancelling a future failedr+r/g�?z,%r is running after closing for %.1f seconds)r��listr��itemsZ	cancelledr�rVr0r1r2rr3�time�	monotonicr�debugrKr�rJr_)rr'rNrr�r�r4r5Z
msg_updateZ
start_timeZnext_msgr r r!ru?s@


�
 
�zIocpProactor.closecCs|��dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rArr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rar�r�r�r`r�rKr�rurwr r r r!r�s8








"
 

7/rc@seZdZdd�ZdS)r�c
sPtj|f|||||d�|���_�fdd�}�jj�t�jj��}	|	�|�dS)N)r�r�r�r�r�cs�j��}��|�dSr7)�_procZpollZ_process_exited)r��
returncoder8r r!r�ys
z4_WindowsSubprocessTransport._start.<locals>.callback)	r
�Popenr�r2r[r��intrDr�)
rr�r�r�r�r�r�r�r�r�r r8r!�_startts���z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!r�rsr�c@seZdZeZdS)rN)r>r?r@r�
_loop_factoryr r r r!r�src@seZdZeZdS)rN)r>r?r@r
rr r r r!r�sr)/rArQrJr�r�r�r�r�r�re�rrrrrrr	r
�logr�__all__rnr�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerrCrVrZ�objectrbZBaseSelectorEventLooprxZBaseProactorEventLoopr
rZBaseSubprocessTransportr�rZBaseDefaultEventLoopPolicyrrrr r r r!�<module>sR0J4;e`PK0�\	�?�/m/mevents.cpython-38.opt-1.pycnu�[���U

e5d4f�@s|dZdZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
Gdd�d�ZGd	d
�d
e�ZGdd�d�Z
Gd
d�d�ZGdd�d�ZGdd�de�Zdae��ZGdd�dej�Ze�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Z d)d*�Z!eZ"eZ#eZ$eZ%zdd+l&mZmZmZmZWne'k
�rfYnXeZ(eZ)eZ*eZ+dS),z!Event loop and event loop policy.)�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�get_running_loop�_get_running_loop�N�)�format_helpers)�
exceptionsc@sFeZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)rz1Object returned by callback registration methods.)�	_callback�_args�
_cancelled�_loop�_source_traceback�_repr�__weakref__�_contextNcCs\|dkrt��}||_||_||_||_d|_d|_|j��rRt	�
t�d��|_
nd|_
dS)NFr)�contextvarsZcopy_contextrrrrrr�	get_debugr�
extract_stack�sys�	_getframer)�self�callback�args�loop�context�r&�&/usr/lib64/python3.8/asyncio/events.py�__init__ s
�zHandle.__init__cCsl|jjg}|jr|�d�|jdk	r:|�t�|j|j��|jrh|jd}|�d|d�d|d���|S)N�	cancelled���zcreated at r�:r)	�	__class__�__name__r�appendrr�_format_callback_sourcerr)r!�info�framer&r&r'�
_repr_info/s


�
zHandle._repr_infocCs(|jdk	r|jS|��}d�d�|��S)Nz<{}>� )rr2�format�join)r!r0r&r&r'�__repr__;s
zHandle.__repr__cCs0|js,d|_|j��r t|�|_d|_d|_dS�NT)rrr�reprrrr�r!r&r&r'�cancelAs

z
Handle.cancelcCs|jS�N)rr9r&r&r'r)LszHandle.cancelledc
Cs�z|jj|jf|j��Wn|ttfk
r4�Yndtk
r�}zFt�|j|j�}d|��}|||d�}|j	rz|j	|d<|j
�|�W5d}~XYnXd}dS)NzException in callback )�messageZ	exception�handleZsource_traceback)r�runrr�
SystemExit�KeyboardInterrupt�
BaseExceptionrr/rr�call_exception_handler)r!�exc�cb�msgr%r&r&r'�_runOs$�
�
zHandle._run)N)r-�
__module__�__qualname__�__doc__�	__slots__r(r2r6r:r)rFr&r&r&r'rs
rcs�eZdZdZddgZd�fdd�	Z�fdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�fdd�Zdd�Z�ZS)rz7Object returned by timed callback registration methods.�
_scheduled�_whenNcs0t��||||�|jr |jd=||_d|_dS)Nr*F)�superr(rrLrK)r!�whenr"r#r$r%�r,r&r'r(hs
zTimerHandle.__init__cs0t���}|jrdnd}|�|d|j���|S)N�rzwhen=)rMr2r�insertrL)r!r0�posrOr&r'r2ps
zTimerHandle._repr_infocCs
t|j�Sr;)�hashrLr9r&r&r'�__hash__vszTimerHandle.__hash__cCs|j|jkSr;�rL�r!�otherr&r&r'�__lt__yszTimerHandle.__lt__cCs|j|jkrdS|�|�Sr7�rL�__eq__rVr&r&r'�__le__|szTimerHandle.__le__cCs|j|jkSr;rUrVr&r&r'�__gt__�szTimerHandle.__gt__cCs|j|jkrdS|�|�Sr7rYrVr&r&r'�__ge__�szTimerHandle.__ge__cCs>t|t�r:|j|jko8|j|jko8|j|jko8|j|jkStSr;)�
isinstancerrLrrr�NotImplementedrVr&r&r'rZ�s

�
�
�zTimerHandle.__eq__cCs|�|�}|tkrtS|Sr;)rZr_)r!rWZequalr&r&r'�__ne__�s
zTimerHandle.__ne__cs |js|j�|�t���dSr;)rr�_timer_handle_cancelledrMr:r9rOr&r'r:�szTimerHandle.cancelcCs|jS)z�Return a scheduled callback time.

        The time is an absolute timestamp, using the same time
        reference as loop.time().
        rUr9r&r&r'rN�szTimerHandle.when)N)r-rGrHrIrJr(r2rTrXr[r\r]rZr`r:rN�
__classcell__r&r&rOr'rcsrc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)rz,Abstract server returned by create_server().cCst�dS)z5Stop serving.  This leaves existing connections open.N��NotImplementedErrorr9r&r&r'�close�szAbstractServer.closecCst�dS)z4Get the event loop the Server object is attached to.Nrcr9r&r&r'�get_loop�szAbstractServer.get_loopcCst�dS)z3Return True if the server is accepting connections.Nrcr9r&r&r'�
is_serving�szAbstractServer.is_servingc�st�dS)z�Start accepting connections.

        This method is idempotent, so it can be called when
        the server is already being serving.
        Nrcr9r&r&r'�
start_serving�szAbstractServer.start_servingc�st�dS)z�Start accepting connections until the coroutine is cancelled.

        The server is closed when the coroutine is cancelled.
        Nrcr9r&r&r'�
serve_forever�szAbstractServer.serve_foreverc�st�dS)z*Coroutine to wait until service is closed.Nrcr9r&r&r'�wait_closed�szAbstractServer.wait_closedc�s|Sr;r&r9r&r&r'�
__aenter__�szAbstractServer.__aenter__c�s|��|��IdHdSr;)rerj)r!rCr&r&r'�	__aexit__�szAbstractServer.__aexit__N)r-rGrHrIrerfrgrhrirjrkrlr&r&r&r'r�src@sVeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�dd�Zd d!�Zd"d#�Zd$d%�Zd&d&d&d&d'�d(d)�Zdud*d+�Zdvdd&d&d&ddddddd,�
d-d.�Zdwejejdd/ddddd0d1�	d2d3�Zdxd0d4�d5d6�Zd7ddd8�d9d:�Zdyddddd;�d<d=�Zdzdd/ddd0d>�d?d@�Zd{d&d&d&dddddA�dBdC�Z dDdE�Z!dFdG�Z"e#j$e#j$e#j$dH�dIdJ�Z%e#j$e#j$e#j$dH�dKdL�Z&dMdN�Z'dOdP�Z(dQdR�Z)dSdT�Z*dUdV�Z+dWdX�Z,dYdZ�Z-d[d\�Z.d]d^�Z/d|dd4�d_d`�Z0dadb�Z1dcdd�Z2dedf�Z3dgdh�Z4didj�Z5dkdl�Z6dmdn�Z7dodp�Z8dqdr�Z9dsdt�Z:dS)}rzAbstract event loop.cCst�dS)z*Run the event loop until stop() is called.Nrcr9r&r&r'�run_forever�szAbstractEventLoop.run_forevercCst�dS)zpRun the event loop until a Future is done.

        Return the Future's result, or raise its exception.
        Nrc)r!Zfuturer&r&r'�run_until_complete�sz$AbstractEventLoop.run_until_completecCst�dS)z�Stop the event loop as soon as reasonable.

        Exactly how soon that is may depend on the implementation, but
        no more I/O callbacks should be scheduled.
        Nrcr9r&r&r'�stop�szAbstractEventLoop.stopcCst�dS)z3Return whether the event loop is currently running.Nrcr9r&r&r'�
is_running�szAbstractEventLoop.is_runningcCst�dS)z*Returns True if the event loop was closed.Nrcr9r&r&r'�	is_closed�szAbstractEventLoop.is_closedcCst�dS)z�Close the loop.

        The loop should not be running.

        This is idempotent and irreversible.

        No other methods should be called after this one.
        Nrcr9r&r&r're�s	zAbstractEventLoop.closec�st�dS)z,Shutdown all active asynchronous generators.Nrcr9r&r&r'�shutdown_asyncgens�sz$AbstractEventLoop.shutdown_asyncgenscCst�dS)z3Notification that a TimerHandle has been cancelled.Nrc)r!r=r&r&r'ra�sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|��S)Nr)�
call_later�r!r"r#r&r&r'�	call_soonszAbstractEventLoop.call_sooncGst�dSr;rc)r!Zdelayr"r#r&r&r'rsszAbstractEventLoop.call_latercGst�dSr;rc)r!rNr"r#r&r&r'�call_atszAbstractEventLoop.call_atcCst�dSr;rcr9r&r&r'�timeszAbstractEventLoop.timecCst�dSr;rcr9r&r&r'�
create_futureszAbstractEventLoop.create_futureN)�namecCst�dSr;rc)r!�cororyr&r&r'�create_taskszAbstractEventLoop.create_taskcGst�dSr;rcrtr&r&r'�call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGst�dSr;rc)r!�executor�funcr#r&r&r'�run_in_executorsz!AbstractEventLoop.run_in_executorcCst�dSr;rc)r!r}r&r&r'�set_default_executorsz&AbstractEventLoop.set_default_executorr)�family�type�proto�flagsc�st�dSr;rc)r!�host�portr�r�r�r�r&r&r'�getaddrinfo#szAbstractEventLoop.getaddrinfoc�st�dSr;rc)r!Zsockaddrr�r&r&r'�getnameinfo'szAbstractEventLoop.getnameinfo)
�sslr�r�r��sock�
local_addr�server_hostname�ssl_handshake_timeout�happy_eyeballs_delay�
interleavec
�st�dSr;rc)r!�protocol_factoryr�r�r�r�r�r�r�r�r�r�r�r�r&r&r'�create_connection*sz#AbstractEventLoop.create_connection�dT)	r�r�r��backlogr��
reuse_address�
reuse_portr�rhc	
�st�dS)adA coroutine which creates a TCP server bound to host and port.

        The return value is a Server object which can be used to stop
        the service.

        If host is an empty string or None all interfaces are assumed
        and a list of multiple sockets will be returned (most likely
        one for IPv4 and another one for IPv6). The host parameter can also be
        a sequence (e.g. list) of hosts to bind to.

        family can be set to either AF_INET or AF_INET6 to force the
        socket to use IPv4 or IPv6. If not set it will be determined
        from host (defaults to AF_UNSPEC).

        flags is a bitmask for getaddrinfo().

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows.

        ssl_handshake_timeout is the time in seconds that an SSL server
        will wait for completion of the SSL handshake before aborting the
        connection. Default is 60s.

        start_serving set to True (default) causes the created server
        to start accepting connections immediately.  When set to False,
        the user should await Server.start_serving() or Server.serve_forever()
        to make the server to start accepting connections.
        Nrc)
r!r�r�r�r�r�r�r�r�r�r�r�rhr&r&r'�
create_server3s3zAbstractEventLoop.create_server)�fallbackc�st�dS)zRSend a file through a transport.

        Return an amount of sent bytes.
        Nrc)r!�	transport�file�offset�countr�r&r&r'�sendfilehszAbstractEventLoop.sendfileF)�server_sider�r�c�st�dS)z|Upgrade a transport to TLS.

        Return a new transport that *protocol* should start using
        immediately.
        Nrc)r!r�ZprotocolZ
sslcontextr�r�r�r&r&r'�	start_tlsps	zAbstractEventLoop.start_tls)r�r�r�r�c�st�dSr;rc)r!r��pathr�r�r�r�r&r&r'�create_unix_connection{sz(AbstractEventLoop.create_unix_connection)r�r�r�r�rhc�st�dS)a�A coroutine which creates a UNIX Domain Socket server.

        The return value is a Server object, which can be used to stop
        the service.

        path is a str, representing a file systsem path to bind the
        server socket to.

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.

        ssl_handshake_timeout is the time in seconds that an SSL server
        will wait for the SSL handshake to complete (defaults to 60s).

        start_serving set to True (default) causes the created server
        to start accepting connections immediately.  When set to False,
        the user should await Server.start_serving() or Server.serve_forever()
        to make the server to start accepting connections.
        Nrc)r!r�r�r�r�r�r�rhr&r&r'�create_unix_server�sz$AbstractEventLoop.create_unix_server)r�r�r�r�r��allow_broadcastr�c�st�dS)a�A coroutine which creates a datagram endpoint.

        This method will try to establish the endpoint in the background.
        When successful, the coroutine returns a (transport, protocol) pair.

        protocol_factory must be a callable returning a protocol instance.

        socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on
        host (or family if specified), socket type SOCK_DGRAM.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified it will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows and some UNIX's. If the
        :py:data:`~socket.SO_REUSEPORT` constant is not defined then this
        capability is unsupported.

        allow_broadcast tells the kernel to allow this endpoint to send
        messages to the broadcast address.

        sock can optionally be specified in order to use a preexisting
        socket object.
        Nrc)r!r�r�Zremote_addrr�r�r�r�r�r�r�r&r&r'�create_datagram_endpoint�s!z*AbstractEventLoop.create_datagram_endpointc�st�dS)aRegister read pipe in event loop. Set the pipe to non-blocking mode.

        protocol_factory should instantiate object with Protocol interface.
        pipe is a file-like object.
        Return pair (transport, protocol), where transport supports the
        ReadTransport interface.Nrc�r!r��piper&r&r'�connect_read_pipe�sz#AbstractEventLoop.connect_read_pipec�st�dS)aRegister write pipe in event loop.

        protocol_factory should instantiate object with BaseProtocol interface.
        Pipe is file-like object already switched to nonblocking.
        Return pair (transport, protocol), where transport support
        WriteTransport interface.Nrcr�r&r&r'�connect_write_pipe�sz$AbstractEventLoop.connect_write_pipe)�stdin�stdout�stderrc�st�dSr;rc)r!r��cmdr�r�r��kwargsr&r&r'�subprocess_shell�sz"AbstractEventLoop.subprocess_shellc�st�dSr;rc)r!r�r�r�r�r#r�r&r&r'�subprocess_exec�sz!AbstractEventLoop.subprocess_execcGst�dSr;rc�r!�fdr"r#r&r&r'�
add_reader�szAbstractEventLoop.add_readercCst�dSr;rc�r!r�r&r&r'�
remove_reader�szAbstractEventLoop.remove_readercGst�dSr;rcr�r&r&r'�
add_writer�szAbstractEventLoop.add_writercCst�dSr;rcr�r&r&r'�
remove_writer�szAbstractEventLoop.remove_writerc�st�dSr;rc)r!r��nbytesr&r&r'�	sock_recvszAbstractEventLoop.sock_recvc�st�dSr;rc)r!r�Zbufr&r&r'�sock_recv_intosz AbstractEventLoop.sock_recv_intoc�st�dSr;rc)r!r��datar&r&r'�sock_sendallszAbstractEventLoop.sock_sendallc�st�dSr;rc)r!r�Zaddressr&r&r'�sock_connectszAbstractEventLoop.sock_connectc�st�dSr;rc)r!r�r&r&r'�sock_acceptszAbstractEventLoop.sock_acceptc�st�dSr;rc)r!r�r�r�r�r�r&r&r'�
sock_sendfileszAbstractEventLoop.sock_sendfilecGst�dSr;rc)r!�sigr"r#r&r&r'�add_signal_handlersz$AbstractEventLoop.add_signal_handlercCst�dSr;rc)r!r�r&r&r'�remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCst�dSr;rc)r!�factoryr&r&r'�set_task_factorysz"AbstractEventLoop.set_task_factorycCst�dSr;rcr9r&r&r'�get_task_factory"sz"AbstractEventLoop.get_task_factorycCst�dSr;rcr9r&r&r'�get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCst�dSr;rc)r!Zhandlerr&r&r'�set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCst�dSr;rc�r!r%r&r&r'�default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCst�dSr;rcr�r&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCst�dSr;rcr9r&r&r'r5szAbstractEventLoop.get_debugcCst�dSr;rc)r!Zenabledr&r&r'�	set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN);r-rGrHrIrmrnrorprqrerrrarursrvrwrxr{r|rr�r�r�r��socketZ	AF_UNSPECZ
AI_PASSIVEr�r�r�r�r�r�r�r��
subprocess�PIPEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rBrr�r&r&r&r'r�s��
��
��5�	�����!��%
���rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rz-Abstract policy for accessing the event loop.cCst�dS)a:Get the event loop for the current context.

        Returns an event loop object implementing the BaseEventLoop interface,
        or raises an exception in case no event loop has been set for the
        current context and the current policy does not specify to create one.

        It should never return None.Nrcr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCst�dS)z3Set the event loop for the current context to loop.Nrc�r!r$r&r&r'r	Isz&AbstractEventLoopPolicy.set_event_loopcCst�dS)z�Create and return a new event loop object according to this
        policy's rules. If there's need to set this loop as the event loop for
        the current context, set_event_loop must be called explicitly.Nrcr9r&r&r'r
Msz&AbstractEventLoopPolicy.new_event_loopcCst�dS)z$Get the watcher for child processes.Nrcr9r&r&r'rUsz)AbstractEventLoopPolicy.get_child_watchercCst�dS)z$Set the watcher for child processes.Nrc)r!�watcherr&r&r'rYsz)AbstractEventLoopPolicy.set_child_watcherN)	r-rGrHrIrr	r
rrr&r&r&r'r<s
rc@sFeZdZdZdZGdd�dej�Zdd�Zdd�Z	d	d
�Z
dd�ZdS)
�BaseDefaultEventLoopPolicya�Default policy implementation for accessing the event loop.

    In this policy, each thread has its own event loop.  However, we
    only automatically create an event loop by default for the main
    thread; other threads by default have no event loop.

    Other policies may have different rules (e.g. a single global
    event loop, or automatically creating an event loop per thread, or
    using some other notion of context to which an event loop is
    associated).
    Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr�_set_calledr&r&r&r'�_Localmsr�cCs|��|_dSr;)r��_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tt��tj�r2|�|���|jjdkrPt	dt��j
��|jjS)zvGet the event loop for the current context.

        Returns an instance of EventLoop or raises an exception.
        Nz,There is no current event loop in thread %r.)r�rr�r^�	threadingZcurrent_threadZ_MainThreadr	r
�RuntimeErrorryr9r&r&r'rts���z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)zSet the event loop.TN)r�r�rr�r&r&r'r	�sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|��S)zvCreate a new event loop.

        You must call set_event_loop() to make this the current event
        loop.
        )�
_loop_factoryr9r&r&r'r
�sz)BaseDefaultEventLoopPolicy.new_event_loop)r-rGrHrIr�r��localr�r(rr	r
r&r&r&r'r�^sr�c@seZdZdZdS)�_RunningLoop)NNN)r-rGrH�loop_pidr&r&r&r'r��sr�cCst�}|dkrtd��|S)zrReturn the running event loop.  Raise a RuntimeError if there is none.

    This function is thread-specific.
    Nzno running event loop)rr��r$r&r&r'r�srcCs&tj\}}|dk	r"|t��kr"|SdS)z�Return the running event loop or None.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)�
_running_loopr��os�getpid)Zrunning_loop�pidr&r&r'r�s
rcCs|t��ft_dS)z�Set the running event loop.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)r�r�r�r�r�r&r&r'r
�sr
c	Cs.t� tdkr ddlm}|�aW5QRXdS)Nr��DefaultEventLoopPolicy)�_lock�_event_loop_policy�r�r�r&r&r'�_init_event_loop_policy�sr�cCstdkrt�tS)z"Get the current event loop policy.N)r�r�r&r&r&r'r�srcCs|adS)zZSet the current event loop policy.

    If policy is None, the default policy is restored.N)r�)Zpolicyr&r&r'r�srcCst�}|dk	r|St���S)aGReturn an asyncio event loop.

    When called from a coroutine or a callback (e.g. scheduled with call_soon
    or similar API), this function will always return the running event loop.

    If there is no running event loop set, the function will return
    the result of `get_event_loop_policy().get_event_loop()` call.
    N)rrr)Zcurrent_loopr&r&r'r�s
rcCst��|�dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr	r�r&r&r'r	�sr	cCs
t���S)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr
r&r&r&r'r
�sr
cCs
t���S)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rrr&r&r&r'r�srcCst��|�S)zMEquivalent to calling
    get_event_loop_policy().set_child_watcher(watcher).)rr)r�r&r&r'r�sr)rr
rr),rI�__all__rr�r�r�rr�r�rrrrrrrr�r�ZLockr�r�r�r�rrr
r�rrrr	r
rrZ_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio�ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'�<module>sXJ@*q"9
	PK0�\$��'��base_tasks.cpython-38.opt-2.pycnu�[���U

e5d�	�@sDddlZddlZddlmZddlmZdd�Zdd�Zd	d
�ZdS)�N�)�base_futures)�
coroutinescCsnt�|�}|jrd|d<|�dd|���t�|j�}|�dd|�d��|jdk	rj|�dd	|j���|S)
NZ
cancellingrrzname=%r�zcoro=<�>�z	wait_for=)	rZ_future_repr_infoZ_must_cancel�insertZget_namerZ_format_coroutine�_coroZ_fut_waiter)�task�info�coro�r
�*/usr/lib64/python3.8/asyncio/base_tasks.py�_task_repr_infos

rcCs�g}t|jd�r|jj}n0t|jd�r0|jj}nt|jd�rF|jj}nd}|dk	r�|dk	r�|dk	rt|dkrlq�|d8}|�|�|j}qR|��nH|jdk	r�|jj	}|dk	r�|dk	r�|dkr�q�|d8}|�|j
�|j}q�|S)N�cr_frame�gi_frame�ag_framerr)�hasattrr	rrr�append�f_back�reverse�
_exception�
__traceback__�tb_frame�tb_next)r
�limitZframes�f�tbr
r
r�_task_get_stacks6





rcCs�g}t�}|j|d�D]Z}|j}|j}|j}|j}	||krN|�|�t�|�t�	|||j
�}
|�|||	|
f�q|j}|s�t
d|��|d�n2|dk	r�t
d|�d�|d�nt
d|�d�|d�tj||d�|dk	r�t�|j|�D]}
t
|
|dd�q�dS)	N)rz
No stack for )�filezTraceback for z (most recent call last):z
Stack for �)r�end)�setZ	get_stack�f_lineno�f_code�co_filename�co_name�add�	linecache�
checkcache�getline�	f_globalsrr�print�	traceback�
print_list�format_exception_only�	__class__)r
rr�extracted_list�checkedr�lineno�co�filename�name�line�excr
r
r�_task_print_stack<s,

r9)r(r-r rrrrr9r
r
r
r�<module>s#PK0�\U�u��log.cpython-38.opt-2.pycnu�[���U

e5d��@shdZdZdZdZdZddlZGdd�d�Ze�ZejZej	Z	ej
Z
ejZejZej
Z
d	d
�Zdd�ZdS)
������Nc@sPeZdZefdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�LogcCs
||_dS�N)�	threshold)�selfr	�r�%/usr/lib64/python3.8/distutils/log.py�__init__szLog.__init__cCs�|tttttfkr"tdt|���||jkr�|r8||}|tttfkrNtj	}ntj
}z|�d|�Wn:tk
r�|j
}|�|d��|�}|�d|�YnX|��dS)Nz%s wrong log levelz%s
�backslashreplace)�DEBUG�INFO�WARN�ERROR�FATAL�
ValueError�strr	�sys�stderr�stdout�write�UnicodeEncodeError�encoding�encode�decode�flush)r
�level�msg�args�streamrrrr�_logs
zLog._logcGs|�|||�dSr)r#)r
rr r!rrr�log'szLog.logcGs|�t||�dSr)r#r�r
r r!rrr�debug*sz	Log.debugcGs|�t||�dSr)r#rr%rrr�info-szLog.infocGs|�t||�dSr)r#rr%rrr�warn0szLog.warncGs|�t||�dSr)r#rr%rrr�error3sz	Log.errorcGs|�t||�dSr)r#rr%rrr�fatal6sz	Log.fatalN)�__name__�
__module__�__qualname__rr
r#r$r&r'r(r)r*rrrrrsrcCstj}|t_|Sr)�_global_logr	)r�oldrrr�
set_thresholdAsr0cCs8|dkrtt�n"|dkr$tt�n|dkr4tt�dS)Nrrr)r0rrr)�vrrr�
set_verbosityGs

r2)rrrrrrrr.r$r&r'r(r)r*r0r2rrrr�<module>s+PK12�\�ht+�9�9msvccompiler.cpython-38.pycnu�[���U

e5d\�@s�dZddlZddlZddlmZmZmZmZmZddl	m
Z
mZmZddl
mZdZz,ddlZdZeZejZejZejZejZWnhek
r�z4ddlZddlZdZeZejZejZejZejZWnek
r�e�d�YnXYnXe�rejejej ej!fZ"d	d
�Z#dd�Z$d
d�Z%Gdd�d�Z&dd�Z'dd�Z(dd�Z)Gdd�de
�Z*e'�dk�r�e�+d�e*Z,ddl-m*Z*ddl-m&Z&dS)z�distutils.msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�logFTz�Warning: Can't read registry to find the necessary compiler setting
Make sure that Python modules winreg, win32api or win32con are installed.cCsnzt||�}Wntk
r$YdSXg}d}zt||�}Wntk
rTYqjYnX|�|�|d7}q.|S)zReturn list of registry keys.Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)�base�key�handle�L�i�k�r�./usr/lib64/python3.8/distutils/msvccompiler.py�	read_keys7s


rcCs�zt||�}Wntk
r$YdSXi}d}zt||�\}}}Wntk
rZYq~YnX|��}t|�|t|�<|d7}q.|S)zXReturn dict of registry keys and values.

    All names are converted to lowercase.
    Nrr)rr
�RegEnumValue�lower�convert_mbcs)rrr�dr�name�value�typerrr�read_valuesHs

r cCs:t|dd�}|dk	r6z|d�}Wntk
r4YnX|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr]src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_|�|�dS�N)�macros�load_macros)�self�versionrrr�__init__gszMacroExpander.__init__cCs2tD](}t||�}|r|||jd|<q.qdS)Nz$(%s))�HKEYSr r()r*Zmacro�pathrrrrrr�	set_macroks

zMacroExpander.set_macroc

Cs�d|}|�d|dd�|�d|dd�d}|�d|d	�z*|d
krX|�d|d�n|�d|d
�Wn*tk
r�}ztd��W5d}~XYnXd}tD]V}zt||�}Wntk
r�Yq�YnXt|d�}t|d||f�}	|	d|jd<q�dS)Nz%Software\Microsoft\VisualStudio\%0.1fZVCInstallDirz	\Setup\VCZ
productdirZVSInstallDirz	\Setup\VSz Software\Microsoft\.NETFrameworkZFrameworkDirZinstallrootg@ZFrameworkSDKDirzsdkinstallrootv1.1ZsdkinstallrootaPython was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.z.Software\Microsoft\NET Framework Setup\Productrz%s\%sr+z$(FrameworkVersion))	r/�KeyErrorrr-rr
rr r()
r*r+ZvsbaseZnet�exc�pr�hrrrrrr)rs,�

zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q
|Sr')r(�items�replace)r*r%r�vrrr�sub�szMacroExpander.subN)�__name__�
__module__�__qualname__r,r/r)r7rrrrr&fsr&cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|d	d
��d}|dkr�d}|dkr�||SdS)
z�Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    zMSC v.����N� r����
��g$@r)�sysr+�find�len�split�int)�prefixrr%�restZmajorVersionZminorVersionrrr�get_build_version�srIcCs@d}tj�|�}|dkrdStj�d|�}tj|t|�|�S)zUReturn the processor architecture.

    Possible results are "Intel" or "AMD64".
    z bit (r;�Intel�))rBr+rCrD)rGr�jrrr�get_build_architecture�srMcCs0g}|D]"}tj�|�}||kr|�|�q|S)znReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    )�osr.�normpathr)�pathsZ
reduced_pathsr2Znprrr�normalize_and_reduce_paths�srQc
@s�eZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd-dd�Zdd�Zd.dd�Zd/dd�Zd0dd�Zd1dd�Zdd�Zd d!�Zd"d#�Zd2d$d%�Zd&d'�Zd3d)d*�Zd+d,�ZdS)4�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCsvt�||||�t�|_t�|_|jdkr\|jdkrHd|_t|j�|_nd|_d|j|_	nd|jd|_	d|_
dS)	NrJ�zSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr<F)rr,rI�_MSVCCompiler__versionrM�_MSVCCompiler__arch�_MSVCCompiler__rootr&�_MSVCCompiler__macros�_MSVCCompiler__product�initialized)r*�verboseZdry_runZforcerrrr,�s

zMSVCCompiler.__init__cCs�g|_dtjkrDdtjkrD|�d�rDd|_d|_d|_d|_d|_nx|�	d�|_t
|j�d	krltd
|j��|�d�|_|�d�|_|�d�|_|�d�|_|�d�|_|�
d�|�
d�z&tjd�d
�D]}|j�|�q�Wntk
r�YnXt|j�|_d
�|j�tjd<d|_|jdk�rPddddddg|_dddddddg|_n&ddddddg|_dddddddg|_dddg|_|jdk�r�ddddg|_ndddddg|_dg|_d |_dS)!NZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer.rzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�libZinclude�;rJz/nologoz/Oxz/MDz/W3z/GXz/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NOrTz/INCREMENTAL:noz/DEBUGz	/pdb:NoneT)�_MSVCCompiler__pathsrN�environ�find_exe�cc�linkerr\�rc�mc�get_msvc_pathsrDrrY�set_path_env_varrErr0rQ�joinZpreprocess_optionsrV�compile_options�compile_options_debug�ldflags_sharedrU�ldflags_shared_debugZldflags_staticrZ)r*r2rrr�
initialize�sr�


�
�
�
���zMSVCCompiler.initialize�cCs�|dkrd}g}|D]�}tj�|�\}}tj�|�d}|tj�|�d�}||jkrbtd|��|rrtj�|�}||jkr�|�	tj�
|||j��q||jkr�|�	tj�
|||j��q|�	tj�
|||j
��q|S)NrmrzDon't know how to compile %s)rNr.�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsrrg�
res_extension�_mc_extensions�
obj_extension)r*Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames8s.

�
��zMSVCCompiler.object_filenamesNc	Csp|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�|
D�]}z||\}}Wntk
r�YqdYnX|r�tj	�
|�}||jkr�d|}�nT||jkr�d|}�n>||j
k�r<|}d|}z"|�|jg||g|g�Wqdtk
�r6}zt|��W5d}~XYqdXqdn�||jk�r�tj	�|�}tj	�|�}zl|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wqdtk
�r�}zt|��W5d}~XYqdXqdntd||f��d	|}z&|�|jg|
|||g|�Wqdtk
�rh}zt|��W5d}~XYqdXqd|
S)
Nz/cz/Tcz/Tpz/foz-hz-rrSz"Don't know how to compile %s to %sz/Fo)rZrlZ_setup_compiler�extendrirhr0rNr.�abspath�
_c_extensions�_cpp_extensionsrs�spawnrcrrru�dirnamerdrnrrrgra)r*Zsourcesrwr(Zinclude_dirs�debug�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcrxZ	input_optZ
output_opt�msgZh_dirZrc_dirr�_Zrc_filerrr�compileWs�
�




��


��
��
���
zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz|�|jg|�Wq�tk
r�}zt|��W5d}~XYq�Xnt	�
d|�dS)N)rw�/OUT:�skipping %s (up-to-date))rZrl�_fix_object_args�library_filename�
_need_linkr~r\rrr
r�)	r*r�Zoutput_libnamerwr��target_lang�output_filenameZlib_argsr�rrr�create_static_lib�s�zMSVCCompiler.create_static_libc
Cs�|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��r�|tjkr�|	r�|j
dd�}q�|jdd�}n|	r�|j
}n|j}g}|p�gD]}|�d|�q�||||d|g}|dk	�rHtj�tj�|��\}}tj�	tj�|d�|�|��}|�d|�|
�rZ|
|dd�<|�rj|�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:r�rz/IMPLIB:r�)rZrlr�Z
_fix_lib_args�warn�strr	rNr.rgr�rZ
EXECUTABLErkrjrrnrrrr�rzZmkpathr~rbrrr
r�)r*Ztarget_descr�r�rwZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr�r�r�Z
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsymZld_argsZdll_nameZdll_extZimplib_filer�rrr�link�sj�
��

��

��
zMSVCCompiler.linkcCsd|S)Nz	/LIBPATH:r�r*�dirrrr�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)rr�rrr�runtime_library_dir_options�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�Sr')r�)r*r\rrr�library_optionszMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rNr.rgr��exists)r*�dirsr\r�Z	try_namesr�rZlibfilerrr�find_library_file#szMSVCCompiler.find_library_filecCsz|jD].}tj�tj�|�|�}tj�|�r|Sqtjd�d�D].}tj�tj�|�|�}tj�|�rF|SqF|S)a�Return path to an MSVC executable program.

        Tries to find the program in several places: first, one of the
        MSVC program search paths from the registry; next, the directories
        in the PATH environment variable.  If any of those work, return an
        absolute path that is known to exist.  If none of them work, just
        return the original program name, 'exe'.
        �Pathr])r^rNr.rgr{�isfiler_rE)r*Zexer2�fnrrrr`5s	


zMSVCCompiler.find_exe�x86cCs�tsgS|d}|jdkr,d|j|jf}nd|j|f}tD]H}t||�}|r>|jdkrt|j�||��d�S||�d�Sq>|jdkr�tD]&}t|d|j�dk	r�|�d	�q�q�gS)
z�Get a list of devstudio directories (include, lib or path).

        Return a list of strings.  The list will be empty if unable to
        access the registry or appropriate registry keys not found.
        z dirsrTz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr]r<z%s\6.0Nz�It seems you have Visual Studio 6 installed, but the expected registry settings are not present.
You must at least run the Visual Studio GUI once so that these entries are created.)	�
_can_read_regrUrWr-r rXr7rEr�)r*r.�platformrrrrrrreKs,

��



zMSVCCompiler.get_msvc_pathscCs6|dkr|�d�}n
|�|�}|r2d�|�tj|<dS)z�Set environment variable 'name' to an MSVC path type value.

        This is equivalent to a SET command prior to execution of spawned
        commands.
        r\Zlibraryr]N)rergrNr_)r*rr2rrrrfos

zMSVCCompiler.set_path_env_var)rrr)rrm)NNNrNNN)NrN)
NNNNNrNNNN)r)r�)r8r9r:�__doc__Z
compiler_typeZexecutablesr|r}rsrurqrtrvZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr,rlryr�r�r�r�r�r�r�r`rerfrrrrrR�sj
��
B�
 �
X�
�
S

$rRg @z3Importing new compiler from distutils.msvc9compiler)rR)r&).r�rBrNZdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
r��winregZhkey_modZ	OpenKeyExrZEnumKeyrZ	EnumValuer�errorr
�ImportErrorZwin32apiZwin32con�infoZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr-rr rr&rIrMrQrRr�ZOldMSVCCompilerZdistutils.msvc9compilerrrrr�<module>s`



�	-
9
PK12�\�5����core.cpython-38.pycnu�[���U

e5d�"�@s�dZddlZddlZddlmZddlTddlmZddlm	Z	ddl
mZddlm
Z
d	Zd
d�ZdadadZd
Zdd�Zddd�ZdS)a#distutils.core

The only module that needs to be imported to use the Distutils; provides
the 'setup' function (which is to be called from the setup script).  Also
indirectly provides the Distribution and Command classes, although they are
really defined in distutils.dist and distutils.cmd.
�N)�DEBUG)�*)�Distribution)�Command)�
PyPIRCCommand)�	Extensionz�usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: %(script)s --help [cmd1 cmd2 ...]
   or: %(script)s --help-commands
   or: %(script)s cmd --help
cCstj�|�}tt�S)N)�os�path�basename�USAGE�vars)�script_nameZscript�r�&/usr/lib64/python3.8/distutils/core.py�	gen_usage sr)�	distclassr
�script_argsZoptions�name�versionZauthorZauthor_emailZ
maintainerZmaintainer_emailZurl�licenseZdescriptionZlong_description�keywordsZ	platformsZclassifiersZdownload_urlZrequiresZprovidesZ	obsoletes)rZsourcesZinclude_dirsZ
define_macrosZundef_macrosZlibrary_dirsZ	librariesZruntime_library_dirsZ
extra_objectsZextra_compile_argsZextra_link_argsZ	swig_optsZexport_symbolsZdependsZlanguagec
Ks|�d�}|r|d=nt}d|kr8tj�tjd�|d<d|krRtjdd�|d<z||�a}WnLtk
r�}z.d|kr�t	d|��nt	d	|d|f��W5d}~XYnXt
d
kr�|S|��tr�t
d�|��t
dkr�|Sz|��}Wn:tk
�r*}zt	t|j�d
|��W5d}~XYnXt�rBt
d�|��t
dk�rP|S|�rz|��Wn�tk
�r�t	d��Yn�tk
�r�}z.t�r�tj�d|f��nt	d|f��W5d}~XYnBttfk
�r}zt�r�nt	dt|���W5d}~XYnX|S)a�The gateway to the Distutils: do everything your setup script needs
    to do, in a highly flexible and user-driven way.  Briefly: create a
    Distribution instance; find and parse config files; parse the command
    line; run each Distutils command found there, customized by the options
    supplied to 'setup()' (as keyword arguments), in config files, and on
    the command line.

    The Distribution instance might be an instance of a class supplied via
    the 'distclass' keyword argument to 'setup'; if no such class is
    supplied, then the Distribution class (in dist.py) is instantiated.
    All other arguments to 'setup' (except for 'cmdclass') are used to set
    attributes of the Distribution instance.

    The 'cmdclass' argument, if supplied, is a dictionary mapping command
    names to command classes.  Each command encountered on the command line
    will be turned into a command class, which is in turn instantiated; any
    class found in 'cmdclass' is used in place of the default, which is
    (for command 'foo_bar') class 'foo_bar' in module
    'distutils.command.foo_bar'.  The command class must provide a
    'user_options' attribute which is a list of option specifiers for
    'distutils.fancy_getopt'.  Any command-line options between the current
    and the next command are used to set attributes of the current command
    object.

    When the entire command-line has been successfully parsed, calls the
    'run()' method on each command object in turn.  This method will be
    driven entirely by the Distribution object (which each command object
    has a reference to, thanks to its constructor), and the
    command-specific options that became attributes of each command
    object.
    rr
rr�Nrzerror in setup command: %szerror in %s setup command: %s�initz%options (after parsing config files):�configz

error: %sz%options (after parsing command line):�commandlineZinterruptedz
error: %s
z	error: %szerror: )�getrrr	r
�sys�argv�_setup_distributionZDistutilsSetupError�
SystemExit�_setup_stop_afterZparse_config_filesr�printZdump_option_dictsZparse_command_lineZDistutilsArgErrorrr
Zrun_commands�KeyboardInterrupt�OSError�stderr�writeZDistutilsErrorZCCompilerError�str)�attrs�klassZdist�msg�ok�excrrr�setup9sd%

�(
�"r,�runc	Cs�|dkrtd|f��|atj��}d|i}zZzH|tjd<|dk	rP|tjdd�<t|d��}t|��|�W5QRXW5|t_daXWntk
r�YnXt	dkr�t
d|��t	S)	a.Run a setup script in a somewhat controlled environment, and
    return the Distribution instance that drives things.  This is useful
    if you need to find out the distribution meta-data (passed as
    keyword args from 'script' to 'setup()', or the contents of the
    config files or command-line.

    'script_name' is a file that will be read and run with 'exec()';
    'sys.argv[0]' will be replaced with 'script' for the duration of the
    call.  'script_args' is a list of strings; if supplied,
    'sys.argv[1:]' will be replaced by 'script_args' for the duration of
    the call.

    'stop_after' tells 'setup()' when to stop processing; possible
    values:
      init
        stop after the Distribution instance has been created and
        populated with the keyword arguments to 'setup()'
      config
        stop after config files have been parsed (and their data
        stored in the Distribution instance)
      commandline
        stop after the command-line ('sys.argv[1:]' or 'script_args')
        have been parsed (and the data stored in the Distribution)
      run [default]
        stop after all commands have been run (the same as if 'setup()'
        had been called in the usual way

    Returns the Distribution instance, which provides all information
    used to drive the Distutils.
    )rrrr-z"invalid value for 'stop_after': %r�__file__Nrr�rbzZ'distutils.core.setup()' was never called -- perhaps '%s' is not a Distutils setup script?)�
ValueErrorr rr�copy�open�exec�readrr�RuntimeError)r
rZ
stop_afterZ	save_argv�g�frrr�	run_setup�s*


�r8)Nr-)�__doc__rrZdistutils.debugrZdistutils.errorsZdistutils.distrZ
distutils.cmdrZdistutils.configrZdistutils.extensionrrrr rZsetup_keywordsZextension_keywordsr,r8rrrr�<module>s 	qPK12�\e9-versionpredicate.cpython-38.pycnu�[���U

e5d
�@s�dZddlZddlZddlZe�dej�Ze�d�Ze�d�Z	dd�Z
ejejej
ejejejd�ZGd	d
�d
�Zdadd�ZdS)
zBModule for parsing and testing package version predicate strings.
�Nz'(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)z^\s*\((.*)\)\s*$z%^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$cCs6t�|�}|std|��|��\}}|tj�|�fS)zVParse a single version comparison.

    Return (comparison string, StrictVersion)
    z"bad package restriction syntax: %r)�re_splitComparison�match�
ValueError�groups�	distutils�version�
StrictVersion)�pred�res�compZverStr�r�2/usr/lib64/python3.8/distutils/versionpredicate.py�splitUps

r)�<z<=z==�>z>=z!=c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�VersionPredicatea�Parse and test package version predicates.

    >>> v = VersionPredicate('pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)')

    The `name` attribute provides the full dotted name that is given::

    >>> v.name
    'pyepat.abc'

    The str() of a `VersionPredicate` provides a normalized
    human-readable version of the expression::

    >>> print(v)
    pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)

    The `satisfied_by()` method can be used to determine with a given
    version number is included in the set described by the version
    restrictions::

    >>> v.satisfied_by('1.1')
    True
    >>> v.satisfied_by('1.4')
    True
    >>> v.satisfied_by('1.0')
    False
    >>> v.satisfied_by('4444.4')
    False
    >>> v.satisfied_by('1555.1b3')
    False

    `VersionPredicate` is flexible in accepting extra whitespace::

    >>> v = VersionPredicate(' pat( ==  0.1  )  ')
    >>> v.name
    'pat'
    >>> v.satisfied_by('0.1')
    True
    >>> v.satisfied_by('0.2')
    False

    If any version numbers passed in do not conform to the
    restrictions of `StrictVersion`, a `ValueError` is raised::

    >>> v = VersionPredicate('p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)')
    Traceback (most recent call last):
      ...
    ValueError: invalid version number '1.2zb3'

    It the module or package name given does not conform to what's
    allowed as a legal module or package name, `ValueError` is
    raised::

    >>> v = VersionPredicate('foo-bar')
    Traceback (most recent call last):
      ...
    ValueError: expected parenthesized list: '-bar'

    >>> v = VersionPredicate('foo bar (12.21)')
    Traceback (most recent call last):
      ...
    ValueError: expected parenthesized list: 'bar (12.21)'

    cCs�|��}|std��t�|�}|s.td|��|��\|_}|��}|r�t�|�}|sbtd|��|��d}dd�|�d�D�|_|js�td|��ng|_d	S)
z*Parse a version predicate string.
        zempty package restrictionzbad package name in %rzexpected parenthesized list: %rrcSsg|]}t|��qSr)r)�.0ZaPredrrr
�
<listcomp>tsz-VersionPredicate.__init__.<locals>.<listcomp>�,zempty parenthesized list in %rN)	�stripr�re_validPackagerr�name�re_paren�splitr	)�selfZversionPredicateStrrZparen�strrrr
�__init__`s&

�zVersionPredicate.__init__cCs8|jr.dd�|jD�}|jdd�|�dS|jSdS)NcSs g|]\}}|dt|��qS)� )r)r�cond�verrrr
r}sz,VersionPredicate.__str__.<locals>.<listcomp>z (z, �))r	r�join)r�seqrrr
�__str__{szVersionPredicate.__str__cCs(|jD]\}}t|||�sdSqdS)z�True if version is compatible with all the predicates in self.
        The parameter version must be acceptable to the StrictVersion
        constructor.  It may be either a string or StrictVersion.
        FT)r	�compmap)rrrrrrr
�satisfied_by�szVersionPredicate.satisfied_byN)�__name__�
__module__�__qualname__�__doc__rr#r%rrrr
rs@rcCsdtdkrt�dtj�a|��}t�|�}|s8td|��|�d�pDd}|rVtj	�
|�}|�d�|fS)a9Return the name and optional version number of a provision.

    The version number, if given, will be returned as a `StrictVersion`
    instance, otherwise it will be `None`.

    >>> split_provision('mypkg')
    ('mypkg', None)
    >>> split_provision(' mypkg( 1.2 ) ')
    ('mypkg', StrictVersion ('1.2'))
    Nz=([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$z"illegal provides specification: %r��)�
_provision_rx�re�compile�ASCIIrrr�grouprrr)�value�mrrrr
�split_provision�s�
r3)r)r-Zdistutils.versionr�operatorr.r/rrrr�lt�le�eq�gt�ge�ner$rr,r3rrrr
�<module>s"�

�nPK12�\�^(�=�="msvc9compiler.cpython-38.opt-2.pycnu�[���U

e5d/w�@sNddlZddlZddlZddlZddlmZmZmZmZm	Z	ddl
mZmZm
Z
ddlmZddlmZddlZejZejZejZejZejejejejfZej dko�ej!dkZ"e"r�dZ#d	Z$d
Z%ndZ#dZ$d
Z%ddd�Z&Gdd�d�Z'Gdd�d�Z(dd�Z)dd�Z*dd�Z+dd�Z,d#dd�Z-e)�Z.e.dk�r:ed e.��Gd!d"�d"e�Z/dS)$�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�log)�get_platform�win32lz1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fz5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowsz,Software\Wow6432Node\Microsoft\.NETFrameworkz%Software\Microsoft\VisualStudio\%0.1fz)Software\Microsoft\Microsoft SDKs\Windowsz Software\Microsoft\.NETFramework�x86Zamd64�rz	win-amd64c@sLeZdZdd�Zee�Zdd�Zee�Zdd�Zee�Zdd�Zee�Zd	S)
�RegcCs:tD](}|�||�}|r||kr||Sqt|��dS�N)�HKEYS�read_values�KeyError)�cls�path�key�base�d�r�//usr/lib64/python3.8/distutils/msvc9compiler.py�	get_value@s
z
Reg.get_valuecCsnzt||�}Wntk
r$YdSXg}d}zt||�}Wntk
rTYqjYnX|�|�|d7}q.|S�Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)rrr�handle�L�i�krrr�	read_keysHs


z
Reg.read_keysc	Cs�zt||�}Wntk
r$YdSXi}d}zt||�\}}}Wntk
rZYq�YnX|��}|�|�||�|�<|d7}q.|Sr)rr�RegEnumValue�lower�convert_mbcs)	rrrr"rr$�name�value�typerrrrZs

zReg.read_valuescCs:t|dd�}|dk	r6z|d�}Wntk
r4YnX|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr)pszReg.convert_mbcsN)	�__name__�
__module__�__qualname__r�classmethodr&rr)�staticmethodrrrrr<src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_t||_|�|�dSr)�macros�VS_BASE�vsbase�load_macros)�self�versionrrr�__init__|s
zMacroExpander.__init__cCst�||�|jd|<dS)Nz$(%s))rrr8)r<Zmacrorrrrr�	set_macro�szMacroExpander.set_macroc	Cs|�d|jdd�|�d|jdd�|�dtd�z$|dkrP|�d	td
�ntd
��Wntk
rvtd��YnX|dkr�|�d
|jd�|�dtd�nbd}tD]X}zt||�}Wntk
r�Yq�YnXt	|d�}t
�|d||f�}|d|jd<q�dS)NZVCInstallDirz	\Setup\VC�
productdirZVSInstallDirz	\Setup\VSZFrameworkDirZinstallroot� @ZFrameworkSDKDirzsdkinstallrootv2.0aPython was built with Visual Studio 2008;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2008 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.g"@ZFrameworkVersionzclr versionZ
WindowsSdkDirZcurrentinstallfolderz.Software\Microsoft\NET Framework Setup\Productrz%s\%sr=z$(FrameworkVersion))
r?r:�NET_BASErr�WINSDK_BASErrrr rrr8)r<r=�pr�hrrrrrr;�s2��


zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q
|Sr)r8�items�replace)r<r1r%�vrrr�sub�szMacroExpander.subN)r2r3r4r>r?r;rIrrrrr7zsr7cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|dd	��d
}|dkr�d}|dkr�||SdS)NzMSC v.����� r����
��g$@r)�sysr=�find�len�split�int)�prefixr$r1�restZmajorVersionZminorVersionrrr�get_build_version�srXcCs0g}|D]"}tj�|�}||kr|�|�q|Sr)�osr�normpathr!)�pathsZ
reduced_pathsrDZnprrr�normalize_and_reduce_paths�sr\cCs<|�tj�}g}|D]}||kr|�|�qtj�|�}|Sr)rTrY�pathsepr!�join)ZvariableZoldListZnewListr$ZnewVariablerrr�removeDuplicates�sr_cCst|}zt�d|d�}Wn"tk
r>t�d�d}YnX|rPtj�|�s�d|}tj	�
|d�}|r�tj�|�r�tj�|tjtjd�}tj�
|�}tj�|�s�t�d|�dSnt�d|�|s�t�d�dStj�|d	�}tj�|�r�|St�d
�dS)Nz%s\Setup\VCr@z%Unable to find productdir in registryzVS%0.f0COMNTOOLSZVCz%s is not a valid directoryz Env var %s is not set or invalidzNo productdir foundz
vcvarsall.bat�Unable to find vcvarsall.bat)r9rrrr
�debugrYr�isdir�environ�getr^�pardir�abspath�isfile)r=r:r@ZtoolskeyZtoolsdir�	vcvarsallrrr�find_vcvarsall�s4
�



ricCs8t|�}ddddh}i}|dkr(td��t�d||�tjd||ftjtjd�}z�|�
�\}}|��d	krzt|�d
���|�d
�}|�
d�D]d}t�|�}d|kr�q�|��}|�
dd
�\}	}
|	��}	|	|kr�|
�tj�r�|
dd�}
t|
�||	<q�W5|j��|j	��Xt|�t|�k�r4ttt|������|S)N�include�libZlibpathrr`z'Calling 'vcvarsall.bat %s' (version=%s)z
"%s" %s & set)�stdout�stderrrr.�
�=rrJ)rirr
ra�
subprocess�Popen�PIPErl�closermZcommunicate�waitr-rTrr)�stripr(�endswithrYr]r_rS�
ValueError�str�list�keys)r=ZarchrhZinteresting�result�popenrlrm�linerr+rrr�query_vcvarsall�s>�


r~rAz(VC %0.1f is not supported by this modulec
@s�eZdZdZiZdgZdddgZdgZdgZeeeeZ	dZ
d	Zd
ZdZ
dZZd
Zd-dd�Zd.dd�Zd/dd�Zd0dd�Zd1dd�Zd2dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd3d)d*�Zd+d,�ZdS)4�MSVCCompilerZmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs8t�||||�t|_d|_g|_d|_d|_d|_dS)NzSoftware\Microsoft\VisualStudioF)	rr>�VERSION�_MSVCCompiler__versionZ_MSVCCompiler__root�_MSVCCompiler__paths�	plat_name�_MSVCCompiler__arch�initialized)r<�verboseZdry_runZforcerrrr>IszMSVCCompiler.__init__NcCs|dkrt�}d}||kr(td|f��dtjkrfdtjkrf|�d�rfd|_d|_d|_d|_d	|_	n�|t�ksx|d
kr�t
|}nt
t�dt
|}tt|�}|d�
tj�|_|d
tjd
<|dtjd<t|j�dkr�td|j��|�d�|_|�d�|_|�d�|_|�d�|_|�d	�|_	z(tjd�
d�D]}|j�|��q:Wntk
�rfYnXt|j�|_d�|j�tjd<d|_|jdk�r�dddddg|_ddddddg|_n&ddddddg|_dddddddg|_dddg|_|jdk�rddd d!g|_dg|_d"|_dS)#Nrz--plat-name must be one of %sZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer�_rrkrjrzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�;r
z/nologoz/Oxz/MDz/W3z/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NO�z/INCREMENTAL:noz/DEBUGT)rrrYrc�find_exe�cc�linkerrk�rc�mc�PLAT_TO_VCVARSr~r�rTr]r�rSZ_MSVCCompiler__productr!rr\r^Zpreprocess_optionsr��compile_options�compile_options_debug�ldflags_sharedr��ldflags_shared_debugZldflags_staticr�)r<r�Zok_platsZ	plat_specZvc_envrDrrr�
initializeTs~�
�
���
�
��zMSVCCompiler.initialize�cCs�|dkrd}g}|D]�}tj�|�\}}tj�|�d}|tj�|�d�}||jkrbtd|��|rrtj�|�}||jkr�|�	tj�
|||j��q||jkr�|�	tj�
|||j��q|�	tj�
|||j
��q|S)Nr�rzDon't know how to compile %s)rYr�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsr!r^�
res_extension�_mc_extensions�
obj_extension)r<Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames�s.

�
��zMSVCCompiler.object_filenamesc	Csp|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�|
D�]}z||\}}Wntk
r�YqdYnX|r�tj	�
|�}||jkr�d|}�nT||jkr�d|}�n>||j
k�r<|}d|}z"|�|jg||g|g�Wqdtk
�r6}zt|��W5d}~XYqdXqdn�||jk�r�tj	�|�}tj	�|�}zl|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wqdtk
�r�}zt|��W5d}~XYqdXqdntd||f��d	|}z&|�|jg|
|||g|�Wqdtk
�rh}zt|��W5d}~XYqdXqd|
S)
Nz/cz/Tcz/Tpz/foz-hz-rr�z"Don't know how to compile %s to %sz/Fo)r�r�Z_setup_compiler!�extendr�r�rrYrrf�
_c_extensions�_cpp_extensionsr��spawnr�rrr��dirnamer�r�r�r^r�)r<Zsourcesr�r8Zinclude_dirsra�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcr�Z	input_optZ
output_opt�msgZh_dirZrc_dirrr�Zrc_filerrr�compile�s�
�




��


��
��
���
zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz|�|jg|�Wq�tk
r�}zt|��W5d}~XYq�Xnt	�
d|�dS)N)r��/OUT:�skipping %s (up-to-date))r�r��_fix_object_args�library_filename�
_need_linkr�rkrrr
ra)	r<r�Zoutput_libnamer�ra�target_lang�output_filenameZlib_argsr�rrr�create_static_libs�zMSVCCompiler.create_static_libc
CsT|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��rD|tjkr�|	r�|j
dd�}q�|jdd�}n|	r�|j
}n|j}g}|p�gD]}|�d|�q�||||d|g}tj�|d�}|dk	�rLtj�tj�|��\}}tj�	||�|��}|�d|�|�|||�|
�rl|
|dd�<|�r||�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnX|�||�}|dk	�rP|\}}d||f}z|�dd	d
||g�Wn,tk
�r@}zt|��W5d}~XYnXnt�d|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:r�rz/IMPLIB:z-outputresource:%s;%szmt.exez-nologoz	-manifestr�)r�r�r�Z
_fix_lib_args�warnrxr	rYrr^r�r�
EXECUTABLEr�r�r!r�r�r�r��manifest_setup_ldargsr�Zmkpathr�r�rr�manifest_get_embed_infor
ra)r<�target_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrar�r��
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsym�ld_argsZdll_nameZdll_extZimplib_filer�ZmfinfoZ
mffilename�mfidZout_argrrr�link6s��
��

��

��


�
zMSVCCompiler.linkcCs,tj�|tj�|�d�}|�d|�dS)Nz	.manifest�/MANIFESTFILE:)rYrr^r�r!)r<r�r�r��
temp_manifestrrrr��s
�z"MSVCCompiler.manifest_setup_ldargscCs^|D]"}|�d�r|�dd�d}q,qdS|tjkr<d}nd}|�|�}|dkrVdS||fS)Nr��:rrO)�
startswithrTrr��_remove_visual_c_ref)r<r�r��argr�r�rrrr��s


z$MSVCCompiler.manifest_get_embed_infocCs�z�t|�}z|��}W5|��Xt�dtj�}t�|d|�}d}t�|d|�}t�dtj�}t�||�dkrtWdSt|d�}z|�|�|W�WS|��XWnt	k
r�YnXdS)NzU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)r�z*<dependentAssembly>\s*</dependentAssembly>zI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)�w)
�openrs�read�rer��DOTALLrI�search�write�OSError)r<Z
manifest_fileZ
manifest_fZmanifest_buf�patternrrrr��s2	
��


z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz	/LIBPATH:r�r<�dirrrr�library_dir_option�szMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)rr�rrr�runtime_library_dir_option�s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�Sr)r�)r<rkrrr�library_option�szMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rYrr^r��exists)r<�dirsrkraZ	try_namesr�r*Zlibfilerrr�find_library_file�szMSVCCompiler.find_library_filecCsz|jD].}tj�tj�|�|�}tj�|�r|Sqtjd�d�D].}tj�tj�|�|�}tj�|�rF|SqF|S)N�Pathr�)r�rYrr^rfrgrcrT)r<ZexerD�fnrrrr�s	


zMSVCCompiler.find_exe)rrr)N)rr�)NNNrNNN)NrN)
NNNNNrNNNN)r)r2r3r4Z
compiler_typeZexecutablesr�r�r�r�r�r�r�Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr>r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr+sj
��

W�
 �
X�
�
_+
r)r
)0rYrprQr�Zdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
Zdistutils.utilr�winregZ	OpenKeyExrZEnumKeyr Z	EnumValuer'�errorrZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr�platform�maxsizeZNATIVE_WIN64r9rCrBr�rr7rXr\r_rir~r�rrrrr�<module>sN��>.#
)
PK12�\
R4���cmd.cpython-38.opt-2.pycnu�[���U

e5d�F�@s^ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmZGdd�d�ZdS)�N)�DistutilsOptionError)�util�dir_util�	file_util�archive_util�dep_util��logc@seZdZgZdd�Zdd�Zdd�Zdd�Zd	d
�ZdBd
d�Z	dd�Z
dCdd�Zdd�ZdDdd�Z
dEdd�Zdd�ZdFdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdGd&d'�ZdHd)d*�Zd+d,�Zd-d.�Zd/d0�ZdId1d2�ZdJd4d5�ZdKd6d7�ZdLd8d9�ZdMd:d;�ZdNd<d=�ZdOd>d?�Z dPd@dA�Z!dS)Q�CommandcCsbddlm}t||�std��|jtkr0td��||_|��d|_	|j
|_
d|_d|_d|_
dS)Nr)�Distributionz$dist must be a Distribution instancezCommand is an abstract class)Zdistutils.distr�
isinstance�	TypeError�	__class__r
�RuntimeError�distribution�initialize_optionsZ_dry_run�verbose�force�help�	finalized)�selfZdistr�r�%/usr/lib64/python3.8/distutils/cmd.py�__init__/s


zCommand.__init__cCs<|dkr0t|d|�}|dkr*t|j|�S|Snt|��dS)N�dry_run�_)�getattrr�AttributeError)r�attrZmyvalrrr�__getattr___szCommand.__getattr__cCs|js|��d|_dS)N�)r�finalize_options�rrrr�ensure_finalizediszCommand.ensure_finalizedcCstd|j��dS�Nz,abstract method -- subclass %s must override�rrr"rrrr{s
�zCommand.initialize_optionscCstd|j��dSr$r%r"rrrr!�s�zCommand.finalize_optionsN�cCs�ddlm}|dkr d|��}|j||tjd�|d}|jD]R\}}}|�|�}|ddkrn|dd�}t||�}|j|d||ftjd�qBdS)	Nr)�
longopt_xlatezcommand options for '%s':)�levelz  ����=z%s = %s)	Zdistutils.fancy_getoptr'�get_command_name�announcer	�INFOZuser_options�	translater)r�header�indentr'�optionr�valuerrr�dump_options�s

�zCommand.dump_optionscCstd|j��dSr$r%r"rrr�run�s
�zCommand.runr cCst�||�dS�Nr)r�msgr(rrrr,�szCommand.announcecCs&ddlm}|r"t|�tj��dS)Nr)�DEBUG)Zdistutils.debugr7�print�sys�stdout�flush)rr6r7rrr�debug_print�szCommand.debug_printcCsBt||�}|dkr"t|||�|St|t�s>td|||f��|S)Nz'%s' must be a %s (got `%s`))r�setattrr�strr)rr1�what�default�valrrr�_ensure_stringlike�s

�zCommand._ensure_stringlikecCs|�|d|�dS)N�string)rB)rr1r@rrr�
ensure_string�szCommand.ensure_stringcCspt||�}|dkrdSt|t�r6t||t�d|��n6t|t�rTtdd�|D��}nd}|sltd||f��dS)Nz,\s*|\s+css|]}t|t�VqdSr5)rr>)�.0�vrrr�	<genexpr>�sz-Command.ensure_string_list.<locals>.<genexpr>Fz''%s' must be a list of strings (got %r))	rrr>r=�re�split�list�allr)rr1rA�okrrr�ensure_string_list�s


��zCommand.ensure_string_listcCs6|�|||�}|dk	r2||�s2td|||f��dS)Nzerror in '%s' option: )rBr)rr1Ztesterr?Z	error_fmtr@rArrr�_ensure_tested_string�s
�zCommand._ensure_tested_stringcCs|�|tjjdd�dS)N�filenamez$'%s' does not exist or is not a file)rN�os�path�isfile�rr1rrr�ensure_filename�s�zCommand.ensure_filenamecCs|�|tjjdd�dS)Nzdirectory namez)'%s' does not exist or is not a directory)rNrPrQ�isdirrSrrr�ensure_dirnames�zCommand.ensure_dirnamecCst|d�r|jS|jjSdS)N�command_name)�hasattrrWr�__name__r"rrrr+	s
zCommand.get_command_namecGsF|j�|�}|��|D](\}}t||�dkrt||t||��qdSr5)r�get_command_objr#rr=)rZsrc_cmdZoption_pairsZsrc_cmd_objZ
src_optionZ
dst_optionrrr�set_undefined_optionss
zCommand.set_undefined_optionscCs|j�||�}|��|Sr5)rrZr#)r�commandZcreateZcmd_objrrr�get_finalized_command$szCommand.get_finalized_commandrcCs|j�||�Sr5)r�reinitialize_command)rr\Zreinit_subcommandsrrrr^0s�zCommand.reinitialize_commandcCs|j�|�dSr5)r�run_command)rr\rrrr_4szCommand.run_commandcCs2g}|jD]"\}}|dks"||�r
|�|�q
|Sr5)�sub_commands�append)rZcommandsZcmd_name�methodrrr�get_sub_commands;s
zCommand.get_sub_commandscCst�d|��|�dS)Nzwarning: %s: %s
)r	�warnr+)rr6rrrrdKszCommand.warncCstj||||jd�dS�N�r)r�executer)r�func�argsr6r(rrrrgNszCommand.execute�cCstj|||jd�dSre)r�mkpathr)r�name�moderrrrkQszCommand.mkpathc	Cstj|||||j||jd�Sre)r�	copy_filerr)r�infile�outfile�
preserve_mode�preserve_times�linkr(rrrrnTs
�zCommand.copy_filec	Cstj||||||j|jd�Sre)r�	copy_treerr)rrorprqrrZpreserve_symlinksr(rrrrt]s
�zCommand.copy_treecCstj|||jd�Sre)r�	move_filer)r�srcZdstr(rrrrufszCommand.move_filecCs ddlm}||||jd�dS)Nr)�spawnrf)Zdistutils.spawnrwr)r�cmdZsearch_pathr(rwrrrrwjsz
Command.spawnc	Cstj|||||j||d�S)N)r�owner�group)r�make_archiver)rZ	base_name�formatZroot_dirZbase_dirryrzrrrr{os
�zCommand.make_archivecCs�|dkrd|}t|t�r"|f}nt|ttf�s8td��|dkrRd|d�|�f}|jsdt�||�rv|�	||||�n
t
�|�dS)Nzskipping %s (inputs unchanged)z9'infiles' must be a string, or a list or tuple of stringszgenerating %s from %sz, )rr>rJ�tupler
�joinrrZnewer_grouprgr	�debug)rZinfilesrprhriZexec_msgZskip_msgr(rrr�	make_fileus

�zCommand.make_file)Nr&)r )N)N)N)r )r)Nr )rj)r r Nr )r r rr )r )r r )NNNN)NNr )"rY�
__module__�__qualname__r`rrr#rr!r3r4r,r<rBrDrMrNrTrVr+r[r]r^r_rcrdrgrkrnrtrurwr{r�rrrrr
sX0






�




�
	�
	

�
�r
)
r9rPrHZdistutils.errorsrZ	distutilsrrrrrr	r
rrrr�<module>sPK12�\� ��dep_util.cpython-38.opt-2.pycnu�[���U

e5d�
�@s2ddlZddlmZdd�Zdd�Zd
dd	�ZdS)�N)�DistutilsFileErrorcCs`tj�|�s tdtj�|���tj�|�s0dSddlm}t�|�|}t�|�|}||kS)Nzfile '%s' does not exist�r��ST_MTIME)�os�path�existsr�abspath�statr)�source�targetrZmtime1Zmtime2�r
�*/usr/lib64/python3.8/distutils/dep_util.py�newers
�rcCsht|�t|�krtd��g}g}tt|��D]2}t||||�r,|�||�|�||�q,||fS)Nz+'sources' and 'targets' must be same length)�len�
ValueError�ranger�append)�sourcesZtargetsZ	n_sourcesZ	n_targets�ir
r
r�newer_pairwise sr�errorcCs�tj�|�sdSddlm}t�|�|}|D]P}tj�|�sb|dkrHn|dkrTq.n|dkrbdSt�|�|}||kr.dSq.dS)Nrrrr�ignorer)rrrr
r)rrZmissingrZtarget_mtimer�source_mtimer
r
r�newer_group6s r)r)rZdistutils.errorsrrrrr
r
r
r�<module>sPK22�\�ht+�9�9!msvccompiler.cpython-38.opt-1.pycnu�[���U

e5d\�@s�dZddlZddlZddlmZmZmZmZmZddl	m
Z
mZmZddl
mZdZz,ddlZdZeZejZejZejZejZWnhek
r�z4ddlZddlZdZeZejZejZejZejZWnek
r�e�d�YnXYnXe�rejejej ej!fZ"d	d
�Z#dd�Z$d
d�Z%Gdd�d�Z&dd�Z'dd�Z(dd�Z)Gdd�de
�Z*e'�dk�r�e�+d�e*Z,ddl-m*Z*ddl-m&Z&dS)z�distutils.msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�logFTz�Warning: Can't read registry to find the necessary compiler setting
Make sure that Python modules winreg, win32api or win32con are installed.cCsnzt||�}Wntk
r$YdSXg}d}zt||�}Wntk
rTYqjYnX|�|�|d7}q.|S)zReturn list of registry keys.Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)�base�key�handle�L�i�k�r�./usr/lib64/python3.8/distutils/msvccompiler.py�	read_keys7s


rcCs�zt||�}Wntk
r$YdSXi}d}zt||�\}}}Wntk
rZYq~YnX|��}t|�|t|�<|d7}q.|S)zXReturn dict of registry keys and values.

    All names are converted to lowercase.
    Nrr)rr
�RegEnumValue�lower�convert_mbcs)rrr�dr�name�value�typerrr�read_valuesHs

r cCs:t|dd�}|dk	r6z|d�}Wntk
r4YnX|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr]src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_|�|�dS�N)�macros�load_macros)�self�versionrrr�__init__gszMacroExpander.__init__cCs2tD](}t||�}|r|||jd|<q.qdS)Nz$(%s))�HKEYSr r()r*Zmacro�pathrrrrrr�	set_macroks

zMacroExpander.set_macroc

Cs�d|}|�d|dd�|�d|dd�d}|�d|d	�z*|d
krX|�d|d�n|�d|d
�Wn*tk
r�}ztd��W5d}~XYnXd}tD]V}zt||�}Wntk
r�Yq�YnXt|d�}t|d||f�}	|	d|jd<q�dS)Nz%Software\Microsoft\VisualStudio\%0.1fZVCInstallDirz	\Setup\VCZ
productdirZVSInstallDirz	\Setup\VSz Software\Microsoft\.NETFrameworkZFrameworkDirZinstallrootg@ZFrameworkSDKDirzsdkinstallrootv1.1ZsdkinstallrootaPython was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.z.Software\Microsoft\NET Framework Setup\Productrz%s\%sr+z$(FrameworkVersion))	r/�KeyErrorrr-rr
rr r()
r*r+ZvsbaseZnet�exc�pr�hrrrrrr)rs,�

zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q
|Sr')r(�items�replace)r*r%r�vrrr�sub�szMacroExpander.subN)�__name__�
__module__�__qualname__r,r/r)r7rrrrr&fsr&cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|d	d
��d}|dkr�d}|dkr�||SdS)
z�Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    zMSC v.����N� r����
��g$@r)�sysr+�find�len�split�int)�prefixrr%�restZmajorVersionZminorVersionrrr�get_build_version�srIcCs@d}tj�|�}|dkrdStj�d|�}tj|t|�|�S)zUReturn the processor architecture.

    Possible results are "Intel" or "AMD64".
    z bit (r;�Intel�))rBr+rCrD)rGr�jrrr�get_build_architecture�srMcCs0g}|D]"}tj�|�}||kr|�|�q|S)znReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    )�osr.�normpathr)�pathsZ
reduced_pathsr2Znprrr�normalize_and_reduce_paths�srQc
@s�eZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd-dd�Zdd�Zd.dd�Zd/dd�Zd0dd�Zd1dd�Zdd�Zd d!�Zd"d#�Zd2d$d%�Zd&d'�Zd3d)d*�Zd+d,�ZdS)4�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCsvt�||||�t�|_t�|_|jdkr\|jdkrHd|_t|j�|_nd|_d|j|_	nd|jd|_	d|_
dS)	NrJ�zSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr<F)rr,rI�_MSVCCompiler__versionrM�_MSVCCompiler__arch�_MSVCCompiler__rootr&�_MSVCCompiler__macros�_MSVCCompiler__product�initialized)r*�verboseZdry_runZforcerrrr,�s

zMSVCCompiler.__init__cCs�g|_dtjkrDdtjkrD|�d�rDd|_d|_d|_d|_d|_nx|�	d�|_t
|j�d	krltd
|j��|�d�|_|�d�|_|�d�|_|�d�|_|�d�|_|�
d�|�
d�z&tjd�d
�D]}|j�|�q�Wntk
r�YnXt|j�|_d
�|j�tjd<d|_|jdk�rPddddddg|_dddddddg|_n&ddddddg|_dddddddg|_dddg|_|jdk�r�ddddg|_ndddddg|_dg|_d |_dS)!NZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer.rzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�libZinclude�;rJz/nologoz/Oxz/MDz/W3z/GXz/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NOrTz/INCREMENTAL:noz/DEBUGz	/pdb:NoneT)�_MSVCCompiler__pathsrN�environ�find_exe�cc�linkerr\�rc�mc�get_msvc_pathsrDrrY�set_path_env_varrErr0rQ�joinZpreprocess_optionsrV�compile_options�compile_options_debug�ldflags_sharedrU�ldflags_shared_debugZldflags_staticrZ)r*r2rrr�
initialize�sr�


�
�
�
���zMSVCCompiler.initialize�cCs�|dkrd}g}|D]�}tj�|�\}}tj�|�d}|tj�|�d�}||jkrbtd|��|rrtj�|�}||jkr�|�	tj�
|||j��q||jkr�|�	tj�
|||j��q|�	tj�
|||j
��q|S)NrmrzDon't know how to compile %s)rNr.�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsrrg�
res_extension�_mc_extensions�
obj_extension)r*Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames8s.

�
��zMSVCCompiler.object_filenamesNc	Csp|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�|
D�]}z||\}}Wntk
r�YqdYnX|r�tj	�
|�}||jkr�d|}�nT||jkr�d|}�n>||j
k�r<|}d|}z"|�|jg||g|g�Wqdtk
�r6}zt|��W5d}~XYqdXqdn�||jk�r�tj	�|�}tj	�|�}zl|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wqdtk
�r�}zt|��W5d}~XYqdXqdntd||f��d	|}z&|�|jg|
|||g|�Wqdtk
�rh}zt|��W5d}~XYqdXqd|
S)
Nz/cz/Tcz/Tpz/foz-hz-rrSz"Don't know how to compile %s to %sz/Fo)rZrlZ_setup_compiler�extendrirhr0rNr.�abspath�
_c_extensions�_cpp_extensionsrs�spawnrcrrru�dirnamerdrnrrrgra)r*Zsourcesrwr(Zinclude_dirs�debug�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcrxZ	input_optZ
output_opt�msgZh_dirZrc_dirr�_Zrc_filerrr�compileWs�
�




��


��
��
���
zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz|�|jg|�Wq�tk
r�}zt|��W5d}~XYq�Xnt	�
d|�dS)N)rw�/OUT:�skipping %s (up-to-date))rZrl�_fix_object_args�library_filename�
_need_linkr~r\rrr
r�)	r*r�Zoutput_libnamerwr��target_lang�output_filenameZlib_argsr�rrr�create_static_lib�s�zMSVCCompiler.create_static_libc
Cs�|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��r�|tjkr�|	r�|j
dd�}q�|jdd�}n|	r�|j
}n|j}g}|p�gD]}|�d|�q�||||d|g}|dk	�rHtj�tj�|��\}}tj�	tj�|d�|�|��}|�d|�|
�rZ|
|dd�<|�rj|�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:r�rz/IMPLIB:r�)rZrlr�Z
_fix_lib_args�warn�strr	rNr.rgr�rZ
EXECUTABLErkrjrrnrrrr�rzZmkpathr~rbrrr
r�)r*Ztarget_descr�r�rwZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr�r�r�Z
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsymZld_argsZdll_nameZdll_extZimplib_filer�rrr�link�sj�
��

��

��
zMSVCCompiler.linkcCsd|S)Nz	/LIBPATH:r�r*�dirrrr�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)rr�rrr�runtime_library_dir_options�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�Sr')r�)r*r\rrr�library_optionszMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rNr.rgr��exists)r*�dirsr\r�Z	try_namesr�rZlibfilerrr�find_library_file#szMSVCCompiler.find_library_filecCsz|jD].}tj�tj�|�|�}tj�|�r|Sqtjd�d�D].}tj�tj�|�|�}tj�|�rF|SqF|S)a�Return path to an MSVC executable program.

        Tries to find the program in several places: first, one of the
        MSVC program search paths from the registry; next, the directories
        in the PATH environment variable.  If any of those work, return an
        absolute path that is known to exist.  If none of them work, just
        return the original program name, 'exe'.
        �Pathr])r^rNr.rgr{�isfiler_rE)r*Zexer2�fnrrrr`5s	


zMSVCCompiler.find_exe�x86cCs�tsgS|d}|jdkr,d|j|jf}nd|j|f}tD]H}t||�}|r>|jdkrt|j�||��d�S||�d�Sq>|jdkr�tD]&}t|d|j�dk	r�|�d	�q�q�gS)
z�Get a list of devstudio directories (include, lib or path).

        Return a list of strings.  The list will be empty if unable to
        access the registry or appropriate registry keys not found.
        z dirsrTz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr]r<z%s\6.0Nz�It seems you have Visual Studio 6 installed, but the expected registry settings are not present.
You must at least run the Visual Studio GUI once so that these entries are created.)	�
_can_read_regrUrWr-r rXr7rEr�)r*r.�platformrrrrrrreKs,

��



zMSVCCompiler.get_msvc_pathscCs6|dkr|�d�}n
|�|�}|r2d�|�tj|<dS)z�Set environment variable 'name' to an MSVC path type value.

        This is equivalent to a SET command prior to execution of spawned
        commands.
        r\Zlibraryr]N)rergrNr_)r*rr2rrrrfos

zMSVCCompiler.set_path_env_var)rrr)rrm)NNNrNNN)NrN)
NNNNNrNNNN)r)r�)r8r9r:�__doc__Z
compiler_typeZexecutablesr|r}rsrurqrtrvZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr,rlryr�r�r�r�r�r�r�r`rerfrrrrrR�sj
��
B�
 �
X�
�
S

$rRg @z3Importing new compiler from distutils.msvc9compiler)rR)r&).r�rBrNZdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
r��winregZhkey_modZ	OpenKeyExrZEnumKeyrZ	EnumValuer�errorr
�ImportErrorZwin32apiZwin32con�infoZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr-rr rr&rIrMrQrRr�ZOldMSVCCompilerZdistutils.msvc9compilerrrrr�<module>s`



�	-
9
PK22�\��))!fancy_getopt.cpython-38.opt-1.pycnu�[���U

e5dxE�@s�dZddlZddlZddlZddlZddlTdZe�de�Ze�deef�Z	e
�dd�ZGd	d
�d
�Z
dd�Zd
d�ejD�Zdd�Zdd�ZGdd�d�Zedkr�dZdD]*Zede�ed�eee���e�q�dS)a6distutils.fancy_getopt

Wrapper around the standard getopt module that provides the following
additional features:
  * short and long options are tied together
  * options have help strings, so fancy_getopt could potentially
    create a complete usage summary
  * options set attributes of a passed-in object
�N)�*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(%s)=!(%s)$�-�_c@s�eZdZdZddd�Zdd�Zdd�Zd d	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
d!dd�Zdd�Zd"dd�Zd#dd�ZdS)$�FancyGetopta�Wrapper around the standard 'getopt()' module that provides some
    handy extra functionality:
      * short and long options are tied together
      * options have help strings, and help text can be assembled
        from them
      * options set attributes of a passed-in object
      * boolean options can have "negative aliases" -- eg. if
        --quiet is the "negative alias" of --verbose, then "--quiet"
        on the command line sets 'verbose' to false
    NcCsN||_i|_|jr|��i|_i|_g|_g|_i|_i|_i|_	g|_
dS�N)�option_table�option_index�_build_index�alias�negative_alias�
short_opts�	long_opts�
short2long�	attr_name�	takes_arg�option_order��selfr�r�./usr/lib64/python3.8/distutils/fancy_getopt.py�__init__)s	zFancyGetopt.__init__cCs(|j��|jD]}||j|d<qdS)Nr)r�clearr)r�optionrrrr	Qs

zFancyGetopt._build_indexcCs||_|��dSr)rr	rrrr�set_option_tableVszFancyGetopt.set_option_tablecCs<||jkrtd|��n |||f}|j�|�||j|<dS)Nz'option conflict: already an option '%s')r�DistutilsGetoptErrorr�append)r�long_optionZshort_optionZhelp_stringrrrr�
add_optionZs
�
zFancyGetopt.add_optioncCs
||jkS)zcReturn true if the option table for this parser has an
        option with long name 'long_option'.)r�rrrrr�
has_optioncszFancyGetopt.has_optioncCs
|�t�S)z�Translate long option name 'long_option' to the form it
        has as an attribute of some object: ie., translate hyphens
        to underscores.��	translate�
longopt_xlaterrrr�
get_attr_namehszFancyGetopt.get_attr_namecCsN|��D]@\}}||jkr,td|||f��||jkrtd|||f��qdS)Nz(invalid %s '%s': option '%s' not definedz0invalid %s '%s': aliased option '%s' not defined)�itemsrr)r�aliasesZwhatr
�optrrr�_check_alias_dictns
�
�zFancyGetopt._check_alias_dictcCs|�|d�||_dS)z'Set the aliases for this option parser.r
N)r'r
)rr
rrr�set_aliasesxszFancyGetopt.set_aliasescCs|�|d�||_dS)z�Set the negative aliases for this option parser.
        'negative_alias' should be a dictionary mapping option names to
        option names, both the key and value must already be defined
        in the option table.znegative aliasN)r'r)rrrrr�set_negative_aliases}sz FancyGetopt.set_negative_aliasescCs�g|_g|_|j��i|_|jD�]�}t|�dkrD|\}}}d}n(t|�dkr^|\}}}}ntd|f��t|t	�r�t|�dkr�t
d|��|dks�t|t	�r�t|�dks�t
d	|��||j|<|j�|�|d
dkr�|r�|d}|dd
�}d|j|<nF|j
�|�}|dk	�r:|j|�r0t
d
||f��||jd
<d|j|<|j�|�}|dk	�r�|j||j|k�r�t
d||f��t�|��s�t
d|��|�|�|j|<|r"|j�|�||j|d<q"dS)z�Populate the various data structures that keep tabs on the
        option table.  Called by 'getopt()' before it can do anything
        worthwhile.
        �r�zinvalid option tuple: %r�z9invalid long option '%s': must be a string of length >= 2N�z:invalid short option '%s': must a single character or None����=�:z>invalid negative alias '%s': aliased option '%s' takes a valuezginvalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'tzEinvalid long option name '%s' (must be letters, numbers, hyphens only)r
rrr�repeatr�len�
ValueError�
isinstance�strrrrr�getr
�
longopt_re�matchr#r)rr�long�short�helpr1Zalias_torrr�_grok_option_table�st

��
��

��


��
��zFancyGetopt._grok_option_tablec
Csn|dkrtjdd�}|dkr*t�}d}nd}|��d�|j�}zt�|||j�\}}Wn,tjk
r�}zt	|��W5d}~XYnX|D]�\}}t
|�dkr�|ddkr�|j|d}n|dd�}|j�
|�}	|	r�|	}|j|�s|j�
|�}	|	�r|	}d}nd}|j|}
|�r:|j�
|
�dk	�r:t||
d�d}t||
|�|j�||f�q�|�rf||fS|SdS)	aParse command-line options in args. Store as attributes on object.

        If 'args' is None or not supplied, uses 'sys.argv[1:]'.  If
        'object' is None or not supplied, creates a new OptionDummy
        object, stores option values there, and returns a tuple (args,
        object).  If 'object' is supplied, it is modified in place and
        'getopt()' just returns 'args'; in both cases, the returned
        'args' is a modified copy of the passed-in 'args' list, which
        is left untouched.
        Nr-TF� r,rr)�sys�argv�OptionDummyr<�joinr�getoptr
�errorZDistutilsArgErrorr2rr
r6rrrr1�getattr�setattrrr)r�args�objectZcreated_objectrZopts�msgr&�valr
�attrrrrrB�sB
zFancyGetopt.getoptcCs|jdkrtd��n|jSdS)z�Returns the list of (option, value) tuples processed by the
        previous run of 'getopt()'.  Raises RuntimeError if
        'getopt()' hasn't been called yet.
        Nz!'getopt()' hasn't been called yet)r�RuntimeError)rrrr�get_option_orders

zFancyGetopt.get_option_ordercCsjd}|jD]L}|d}|d}t|�}|ddkr:|d}|dk	rJ|d}||kr
|}q
|ddd}d}||}	d	|}
|r�|g}nd
g}|jD]�}|dd�\}}}t||	�}
|ddkr�|dd�}|dk�r|
r�|�d|||
df�n|�d
||f�n:d||f}|
�r4|�d|||
df�n|�d|�|
dd�D]}|�|
|��qNq�|S)z�Generate help text (a list of strings, one per suggested line of
        output) from the option table for this FancyGetopt object.
        rr-r.r/N�r,�Nr=zOption summary:r*z  --%-*s  %sz
  --%-*s  z%s (-%s)z  --%-*s)rr2�	wrap_textr)r�headerZmax_optrr9r:�lZ	opt_widthZ
line_widthZ
text_widthZ
big_indent�linesr;�textZ	opt_namesrrr�
generate_helpsH



�zFancyGetopt.generate_helpcCs0|dkrtj}|�|�D]}|�|d�qdS)N�
)r>�stdoutrT�write)rrP�file�linerrr�
print_helphszFancyGetopt.print_help)N)NN)NN)N)NN)�__name__�
__module__�__qualname__�__doc__rr	rrrr#r'r(r)r<rBrLrTrZrrrrrs
(
	
M
=

OrcCst|�}|�|�|�||�Sr)rr)rB)�optionsZnegative_optrGrF�parserrrr�fancy_getoptos
racCsi|]}t|�d�qS)r=)�ord)�.0Z_wscharrrr�
<dictcomp>usrdcCs|dkrgSt|�|kr|gS|��}|�t�}t�d|�}dd�|D�}g}|�rg}d}|r�t|d�}|||kr�|�|d�|d=||}q\|r�|dddkr�|d=q�q\|�r|dkr�|�|dd|��|d|d�|d<|dddk�r|d=|�d�|��qN|S)	z�wrap_text(text : string, width : int) -> [string]

    Split 'text' into multiple lines of no more than 'width' characters
    each, and return the list of strings that results.
    Nz( +|-+)cSsg|]}|r|�qSrr)rcZchrrr�
<listcomp>�szwrap_text.<locals>.<listcomp>rr.r=�)r2�
expandtabsr!�WS_TRANS�re�splitrrA)rS�widthZchunksrRZcur_lineZcur_lenrQrrrrOws:

rOcCs
|�t�S)zXConvert a long option name to a valid Python identifier by
    changing "-" to "_".
    r )r&rrr�translate_longopt�srlc@seZdZdZgfdd�ZdS)r@z_Dummy class just used as a place to hold command-line option
    values as instance attributes.cCs|D]}t||d�qdS)zkCreate a new OptionDummy instance.  The attributes listed in
        'options' will be initialized to None.N)rE)rr_r&rrrr�szOptionDummy.__init__N)r[r\r]r^rrrrrr@�sr@�__main__z�Tra-la-la, supercalifragilisticexpialidocious.
How *do* you spell that odd word, anyways?
(Someone ask Mary -- she'll know [or she'll
say, "How should I know?"].))�
���(z	width: %drU)r^r>�stringrirBZdistutils.errorsZlongopt_pat�compiler7Zneg_alias_rer5�	maketransr"rraZ
whitespacerhrOrlr@r[rS�w�printrArrrr�<module>s*
T6PK22�\I��core.cpython-38.opt-2.pycnu�[���U

e5d�"�@s�ddlZddlZddlmZddlTddlmZddlmZddl	m
Z
ddlmZdZ
d	d
�ZdadadZdZd
d�Zddd�ZdS)�N)�DEBUG)�*)�Distribution)�Command)�
PyPIRCCommand)�	Extensionz�usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: %(script)s --help [cmd1 cmd2 ...]
   or: %(script)s --help-commands
   or: %(script)s cmd --help
cCstj�|�}tt�S)N)�os�path�basename�USAGE�vars)�script_nameZscript�r�&/usr/lib64/python3.8/distutils/core.py�	gen_usage sr)�	distclassr
�script_argsZoptions�name�versionZauthorZauthor_emailZ
maintainerZmaintainer_emailZurl�licenseZdescriptionZlong_description�keywordsZ	platformsZclassifiersZdownload_urlZrequiresZprovidesZ	obsoletes)rZsourcesZinclude_dirsZ
define_macrosZundef_macrosZlibrary_dirsZ	librariesZruntime_library_dirsZ
extra_objectsZextra_compile_argsZextra_link_argsZ	swig_optsZexport_symbolsZdependsZlanguagec
Ks|�d�}|r|d=nt}d|kr8tj�tjd�|d<d|krRtjdd�|d<z||�a}WnLtk
r�}z.d|kr�t	d|��nt	d|d|f��W5d}~XYnXt
d	kr�|S|��tr�t
d
�|��t
dkr�|Sz|��}Wn:tk
�r*}zt	t|j�d|��W5d}~XYnXt�rBt
d
�|��t
dk�rP|S|�rz|��Wn�tk
�r�t	d��Yn�tk
�r�}z.t�r�tj�d|f��nt	d|f��W5d}~XYnBttfk
�r}zt�r�nt	dt|���W5d}~XYnX|S)Nrr
rr�rzerror in setup command: %szerror in %s setup command: %s�initz%options (after parsing config files):�configz

error: %sz%options (after parsing command line):�commandlineZinterruptedz
error: %s
z	error: %szerror: )�getrrr	r
�sys�argv�_setup_distributionZDistutilsSetupError�
SystemExit�_setup_stop_afterZparse_config_filesr�printZdump_option_dictsZparse_command_lineZDistutilsArgErrorrr
Zrun_commands�KeyboardInterrupt�OSError�stderr�writeZDistutilsErrorZCCompilerError�str)�attrs�klassZdist�msg�ok�excrrr�setup9sd%

�(
�"r,�runc	Cs�|dkrtd|f��|atj��}d|i}zZzH|tjd<|dk	rP|tjdd�<t|d��}t|��|�W5QRXW5|t_daXWntk
r�YnXt	dkr�t
d|��t	S)N)rrrr-z"invalid value for 'stop_after': %r�__file__rr�rbzZ'distutils.core.setup()' was never called -- perhaps '%s' is not a Distutils setup script?)�
ValueErrorr rr�copy�open�exec�readrr�RuntimeError)r
rZ
stop_afterZ	save_argv�g�frrr�	run_setup�s*


�r8)Nr-)rrZdistutils.debugrZdistutils.errorsZdistutils.distrZ
distutils.cmdrZdistutils.configrZdistutils.extensionrrrr rZsetup_keywordsZextension_keywordsr,r8rrrr�<module>	s	qPK22�\�~��//file_util.cpython-38.opt-1.pycnu�[���U

e5d��@sZdZddlZddlmZddlmZdddd�Zdd
d�Zdd
d�Zddd�Z	dd�Z
dS)zFdistutils.file_util

Utility functions for operating on single files.
�N)�DistutilsFileError)�logZcopyingzhard linkingzsymbolically linking)N�hard�sym�@c
Cs�d}d}�ztzt|d�}Wn4tk
rN}ztd||jf��W5d}~XYnXtj�|�r�zt�|�Wn4tk
r�}ztd||jf��W5d}~XYnXzt|d�}Wn4tk
r�}ztd||jf��W5d}~XYnXz|�	|�}Wn6tk
�r(}ztd||jf��W5d}~XYnX|�s4�q|z|�
|�Wq�tk
�rx}ztd||jf��W5d}~XYq�Xq�W5|�r�|��|�r�|��XdS)	a5Copy the file 'src' to 'dst'; both must be filenames.  Any error
    opening either file, reading from 'src', or writing to 'dst', raises
    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
    bytes (default 16k).  No attempt is made to handle anything apart from
    regular files.
    N�rbzcould not open '%s': %szcould not delete '%s': %s�wbzcould not create '%s': %szcould not read from '%s': %szcould not write to '%s': %s)�close�open�OSErrorr�strerror�os�path�exists�unlink�read�write)�src�dstZbuffer_sizeZfsrcZfdst�eZbuf�r�+/usr/lib64/python3.8/distutils/file_util.py�_copy_file_contentssL	$����r�cCsddlm}ddlm}	m}
m}m}tj�	|�s<t
d|��tj�|�rd|}
tj�|tj�
|��}ntj�|�}
|r�|||�s�|dkr�t�d|�|dfSzt|}Wn tk
r�td|��YnX|dk�rtj�
|�tj�
|�kr�t�d|||
�nt�d|||�|�r|dfS|d	k�rrtj�|��rBtj�||��s�zt�||�|dfWStk
�rnYnXn<|d
k�r�tj�|��r�tj�||��s�t�||�|dfSt||�|�s�|�rt�|�}|�r�t�|||	||
f�|�rt�||||��|dfS)aCopy a file 'src' to 'dst'.  If 'dst' is a directory, then 'src' is
    copied there with the same name; otherwise, it must be a filename.  (If
    the file exists, it will be ruthlessly clobbered.)  If 'preserve_mode'
    is true (the default), the file's mode (type and permission bits, or
    whatever is analogous on the current platform) is copied.  If
    'preserve_times' is true (the default), the last-modified and
    last-access times are copied as well.  If 'update' is true, 'src' will
    only be copied if 'dst' does not exist, or if 'dst' does exist but is
    older than 'src'.

    'link' allows you to make hard links (os.link) or symbolic links
    (os.symlink) instead of copying: set it to "hard" or "sym"; if it is
    None (the default), files are copied.  Don't set 'link' on systems that
    don't support it: 'copy_file()' doesn't check if hard or symbolic
    linking is available. If hardlink fails, falls back to
    _copy_file_contents().

    Under Mac OS, uses the native file copy function in macostools; on
    other systems, uses '_copy_file_contents()' to copy file contents.

    Return a tuple (dest_name, copied): 'dest_name' is the actual name of
    the output file, and 'copied' is true if the file was copied (or would
    have been copied, if 'dry_run' true).
    r)�newer)�ST_ATIME�ST_MTIME�ST_MODE�S_IMODEz4can't copy '%s': doesn't exist or not a regular filerz"not copying %s (output up-to-date)z&invalid value '%s' for 'link' argumentz%s %s -> %srr)Zdistutils.dep_utilr�statrrrrr
r�isfiler�isdir�join�basename�dirnamer�debug�_copy_action�KeyError�
ValueError�infor�samefile�linkr�symlinkr�utime�chmod)rrZ
preserve_modeZpreserve_times�updater+�verbose�dry_runrrrrr�dir�action�strrr�	copy_fileCsV!�





r5cCs�ddlm}m}m}m}m}ddl}	|dkr:t�d||�|rB|S||�sVt	d|��||�rrt
j�|||��}n||�r�t	d||f��|||��s�t	d||f��d	}
zt
�
||�WnPtk
�r
}z0|j\}}
||	jkr�d
}
nt	d|||
f��W5d}~XYnX|
�r�t|||d�zt
�|�Wnhtk
�r�}zH|j\}}
zt
�|�Wntk
�rpYnXt	d
||||
f��W5d}~XYnX|S)a%Move a file 'src' to 'dst'.  If 'dst' is a directory, the file will
    be moved into it with the same name; otherwise, 'src' is just renamed
    to 'dst'.  Return the new full name of the file.

    Handles cross-device moves on Unix using 'copy_file()'.  What about
    other systems???
    r)rr r!r#r$Nrzmoving %s -> %sz#can't move '%s': not a regular filez0can't move '%s': destination '%s' already existsz2can't move '%s': destination '%s' not a valid pathFTzcouldn't move '%s' to '%s': %s)r0zAcouldn't move '%s' to '%s' by copy/delete: delete '%s' failed: %s)Zos.pathrr r!r#r$�errnorr)rr
rr"�renamer�argsZEXDEVr5r)rrr0r1rr r!r#r$r6Zcopy_itrZnum�msgrrr�	move_file�s`����

�

��r:cCs6t|d�}z|D]}|�|d�qW5|��XdS)z{Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    �w�
N)r
r	r)�filename�contents�f�linerrr�
write_file�s

rA)r)rrrNrr)rr)�__doc__r
Zdistutils.errorsrZ	distutilsrr&rr5r:rArrrr�<module>s"�
3�
d�
?PK22�\��cE!fancy_getopt.cpython-38.opt-2.pycnu�[���U

e5dxE�@s�ddlZddlZddlZddlZddlTdZe�de�Ze�deef�Ze	�
dd�ZGdd	�d	�Zd
d�Z
dd
�ejD�Zdd�Zdd�ZGdd�d�Zedkr�dZdD]*Zede�ed�eee���e�q�dS)�N)�*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(%s)=!(%s)$�-�_c@s�eZdZddd�Zdd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zd dd�Z
dd�Zd!dd�Zd"dd�ZdS)#�FancyGetoptNcCsN||_i|_|jr|��i|_i|_g|_g|_i|_i|_i|_	g|_
dS�N)�option_table�option_index�_build_index�alias�negative_alias�
short_opts�	long_opts�
short2long�	attr_name�	takes_arg�option_order��selfr�r�./usr/lib64/python3.8/distutils/fancy_getopt.py�__init__)s	zFancyGetopt.__init__cCs(|j��|jD]}||j|d<qdS)Nr)r�clearr)r�optionrrrr	Qs

zFancyGetopt._build_indexcCs||_|��dSr)rr	rrrr�set_option_tableVszFancyGetopt.set_option_tablecCs<||jkrtd|��n |||f}|j�|�||j|<dS)Nz'option conflict: already an option '%s')r�DistutilsGetoptErrorr�append)r�long_optionZshort_optionZhelp_stringrrrr�
add_optionZs
�
zFancyGetopt.add_optioncCs
||jkSr)r�rrrrr�
has_optioncszFancyGetopt.has_optioncCs
|�t�Sr��	translate�
longopt_xlaterrrr�
get_attr_namehszFancyGetopt.get_attr_namecCsN|��D]@\}}||jkr,td|||f��||jkrtd|||f��qdS)Nz(invalid %s '%s': option '%s' not definedz0invalid %s '%s': aliased option '%s' not defined)�itemsrr)r�aliasesZwhatr
�optrrr�_check_alias_dictns
�
�zFancyGetopt._check_alias_dictcCs|�|d�||_dS)Nr
)r'r
)rr
rrr�set_aliasesxszFancyGetopt.set_aliasescCs|�|d�||_dS)Nznegative alias)r'r)rrrrr�set_negative_aliases}sz FancyGetopt.set_negative_aliasescCs�g|_g|_|j��i|_|jD�]�}t|�dkrD|\}}}d}n(t|�dkr^|\}}}}ntd|f��t|t	�r�t|�dkr�t
d|��|dks�t|t	�r�t|�dks�t
d|��||j|<|j�|�|d	d
kr�|r�|d}|dd	�}d|j|<nF|j
�|�}|dk	�r:|j|�r0t
d||f��||jd	<d|j|<|j�|�}|dk	�r�|j||j|k�r�t
d
||f��t�|��s�t
d|��|�|�|j|<|r"|j�|�||j|d<q"dS)N�r�zinvalid option tuple: %r�z9invalid long option '%s': must be a string of length >= 2�z:invalid short option '%s': must a single character or None����=�:z>invalid negative alias '%s': aliased option '%s' takes a valuezginvalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'tzEinvalid long option name '%s' (must be letters, numbers, hyphens only)r
rrr�repeatr�len�
ValueError�
isinstance�strrrrr�getr
�
longopt_re�matchr#r)rr�long�short�helpr1Zalias_torrr�_grok_option_table�st

��
��

��


��
��zFancyGetopt._grok_option_tablec
Csn|dkrtjdd�}|dkr*t�}d}nd}|��d�|j�}zt�|||j�\}}Wn,tjk
r�}zt	|��W5d}~XYnX|D]�\}}t
|�dkr�|ddkr�|j|d}n|dd�}|j�
|�}	|	r�|	}|j|�s|j�
|�}	|	�r|	}d}nd}|j|}
|�r:|j�
|
�dk	�r:t||
d�d}t||
|�|j�||f�q�|�rf||fS|SdS)Nr-TF� r,rr)�sys�argv�OptionDummyr<�joinr�getoptr
�errorZDistutilsArgErrorr2rr
r6rrrr1�getattr�setattrrr)r�args�objectZcreated_objectrZopts�msgr&�valr
�attrrrrrB�sB
zFancyGetopt.getoptcCs|jdkrtd��n|jSdS)Nz!'getopt()' hasn't been called yet)r�RuntimeError)rrrr�get_option_orders

zFancyGetopt.get_option_ordercCsjd}|jD]L}|d}|d}t|�}|ddkr:|d}|dk	rJ|d}||kr
|}q
|ddd}d}||}	d|}
|r�|g}nd	g}|jD]�}|dd
�\}}}t||	�}
|ddkr�|dd�}|dk�r|
r�|�d|||
df�n|�d||f�n:d
||f}|
�r4|�d|||
df�n|�d|�|
dd�D]}|�|
|��qNq�|S)Nrr-r.r/�r,�Nr=zOption summary:r*z  --%-*s  %sz
  --%-*s  z%s (-%s)z  --%-*s)rr2�	wrap_textr)r�headerZmax_optrr9r:�lZ	opt_widthZ
line_widthZ
text_widthZ
big_indent�linesr;�textZ	opt_namesrrr�
generate_helpsH



�zFancyGetopt.generate_helpcCs0|dkrtj}|�|�D]}|�|d�qdS)N�
)r>�stdoutrT�write)rrP�file�linerrr�
print_helphszFancyGetopt.print_help)N)NN)NN)N)NN)�__name__�
__module__�__qualname__rr	rrrr#r'r(r)r<rBrLrTrZrrrrrs
(
	
M
=

OrcCst|�}|�|�|�||�Sr)rr)rB)�optionsZnegative_optrGrF�parserrrr�fancy_getoptos
r`cCsi|]}t|�d�qS)r=)�ord)�.0Z_wscharrrr�
<dictcomp>usrccCs|dkrgSt|�|kr|gS|��}|�t�}t�d|�}dd�|D�}g}|�rg}d}|r�t|d�}|||kr�|�|d�|d=||}q\|r�|dddkr�|d=q�q\|�r|dkr�|�|dd|��|d|d�|d<|dddk�r|d=|�d�|��qN|S)Nz( +|-+)cSsg|]}|r|�qSrr)rbZchrrr�
<listcomp>�szwrap_text.<locals>.<listcomp>rr.r=�)r2�
expandtabsr!�WS_TRANS�re�splitrrA)rS�widthZchunksrRZcur_lineZcur_lenrQrrrrOws:

rOcCs
|�t�Srr )r&rrr�translate_longopt�srkc@seZdZgfdd�ZdS)r@cCs|D]}t||d�qdSr)rE)rr^r&rrrr�szOptionDummy.__init__N)r[r\r]rrrrrr@�sr@�__main__z�Tra-la-la, supercalifragilisticexpialidocious.
How *do* you spell that odd word, anyways?
(Someone ask Mary -- she'll know [or she'll
say, "How should I know?"].))�
���(z	width: %drU)r>�stringrhrBZdistutils.errorsZlongopt_pat�compiler7Zneg_alias_rer5�	maketransr"rr`Z
whitespacergrOrkr@r[rS�w�printrArrrr�<module>s(T6PK22�\�g:-D-D"msvc9compiler.cpython-38.opt-1.pycnu�[���U

e5d/w�@sRdZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
mZddlmZddlmZddlZejZejZejZejZejejejejfZ ej!dko�ej"dkZ#e#r�d	Z$d
Z%dZ&ndZ$d
Z%dZ&ddd�Z'Gdd�d�Z(Gdd�d�Z)dd�Z*dd�Z+dd�Z,dd�Z-d$dd�Z.e*�Z/e/d k�r>ed!e/��Gd"d#�d#e�Z0dS)%adistutils.msvc9compiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio 2008.

The module is compatible with VS 2005 and VS 2008. You can find legacy support
for older versions of VS in distutils.msvccompiler.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�log)�get_platform�win32lz1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fz5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowsz,Software\Wow6432Node\Microsoft\.NETFrameworkz%Software\Microsoft\VisualStudio\%0.1fz)Software\Microsoft\Microsoft SDKs\Windowsz Software\Microsoft\.NETFramework�x86Zamd64�rz	win-amd64c@sPeZdZdZdd�Zee�Zdd�Zee�Zdd�Zee�Zdd	�Ze	e�Zd
S)�Regz2Helper class to read values from the registry
    cCs:tD](}|�||�}|r||kr||Sqt|��dS�N)�HKEYS�read_values�KeyError)�cls�path�key�base�d�r�//usr/lib64/python3.8/distutils/msvc9compiler.py�	get_value@s
z
Reg.get_valuecCsnzt||�}Wntk
r$YdSXg}d}zt||�}Wntk
rTYqjYnX|�|�|d7}q.|S)zReturn list of registry keys.Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)rrr�handle�L�i�krrr�	read_keysHs


z
Reg.read_keysc	Cs�zt||�}Wntk
r$YdSXi}d}zt||�\}}}Wntk
rZYq�YnX|��}|�|�||�|�<|d7}q.|S)z`Return dict of registry keys and values.

        All names are converted to lowercase.
        Nrr)rr�RegEnumValue�lower�convert_mbcs)	rrrr!rr#�name�value�typerrrrZs

zReg.read_valuescCs:t|dd�}|dk	r6z|d�}Wntk
r4YnX|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr(pszReg.convert_mbcsN)
�__name__�
__module__�__qualname__�__doc__r�classmethodr%rr(�staticmethodrrrrr<src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_t||_|�|�dSr)�macros�VS_BASE�vsbase�load_macros)�self�versionrrr�__init__|s
zMacroExpander.__init__cCst�||�|jd|<dS)Nz$(%s))rrr8)r<Zmacrorrrrr�	set_macro�szMacroExpander.set_macroc	Cs|�d|jdd�|�d|jdd�|�dtd�z$|dkrP|�d	td
�ntd
��Wntk
rvtd��YnX|dkr�|�d
|jd�|�dtd�nbd}tD]X}zt||�}Wntk
r�Yq�YnXt	|d�}t
�|d||f�}|d|jd<q�dS)NZVCInstallDirz	\Setup\VC�
productdirZVSInstallDirz	\Setup\VSZFrameworkDirZinstallroot� @ZFrameworkSDKDirzsdkinstallrootv2.0aPython was built with Visual Studio 2008;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2008 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.g"@ZFrameworkVersionzclr versionZ
WindowsSdkDirZcurrentinstallfolderz.Software\Microsoft\NET Framework Setup\Productrz%s\%sr=z$(FrameworkVersion))
r?r:�NET_BASErr�WINSDK_BASErrrrrrr8)r<r=�pr�hrrrrrr;�s2��


zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q
|Sr)r8�items�replace)r<r0r$�vrrr�sub�szMacroExpander.subN)r1r2r3r>r?r;rIrrrrr7zsr7cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|d	d
��d}|dkr�d}|dkr�||SdS)
z�Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    zMSC v.����N� r����
��g$@r)�sysr=�find�len�split�int)�prefixr#r0�restZmajorVersionZminorVersionrrr�get_build_version�srXcCs0g}|D]"}tj�|�}||kr|�|�q|S)znReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    )�osr�normpathr )�pathsZ
reduced_pathsrDZnprrr�normalize_and_reduce_paths�sr\cCs<|�tj�}g}|D]}||kr|�|�qtj�|�}|S)z8Remove duplicate values of an environment variable.
    )rTrY�pathsepr �join)ZvariableZoldListZnewListr#ZnewVariablerrr�removeDuplicates�sr_cCst|}zt�d|d�}Wn"tk
r>t�d�d}YnX|rPtj�|�s�d|}tj	�
|d�}|r�tj�|�r�tj�|tjtjd�}tj�
|�}tj�|�s�t�d|�dSnt�d|�|s�t�d	�dStj�|d
�}tj�|�r�|St�d�dS)z�Find the vcvarsall.bat file

    At first it tries to find the productdir of VS 2008 in the registry. If
    that fails it falls back to the VS90COMNTOOLS env var.
    z%s\Setup\VCr@z%Unable to find productdir in registryNzVS%0.f0COMNTOOLSZVCz%s is not a valid directoryz Env var %s is not set or invalidzNo productdir foundz
vcvarsall.bat�Unable to find vcvarsall.bat)r9rrrr
�debugrYr�isdir�environ�getr^�pardir�abspath�isfile)r=r:r@ZtoolskeyZtoolsdir�	vcvarsallrrr�find_vcvarsall�s4
�



ricCs8t|�}ddddh}i}|dkr(td��t�d||�tjd||ftjtjd	�}z�|�
�\}}|��d
krzt|�d���|�d�}|�
d�D]d}t�|�}d
|kr�q�|��}|�
d
d�\}	}
|	��}	|	|kr�|
�tj�r�|
dd�}
t|
�||	<q�W5|j��|j	��Xt|�t|�k�r4ttt|������|S)zDLaunch vcvarsall.bat and read the settings from its environment
    �include�libZlibpathrNr`z'Calling 'vcvarsall.bat %s' (version=%s)z
"%s" %s & set)�stdout�stderrrr-�
�=rrJ)rirr
ra�
subprocess�Popen�PIPErl�closermZcommunicate�waitr,rTrr(�stripr'�endswithrYr]r_rS�
ValueError�str�list�keys)r=ZarchrhZinteresting�result�popenrlrm�linerr*rrr�query_vcvarsall�s>�


r~rAz(VC %0.1f is not supported by this modulec
@s�eZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd.dd�Zd/dd�Zd0dd�Zd1dd�Zd2dd�Zd3dd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd4d*d+�Zd,d-�ZdS)5�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs8t�||||�t|_d|_g|_d|_d|_d|_dS)NzSoftware\Microsoft\VisualStudioF)	rr>�VERSION�_MSVCCompiler__versionZ_MSVCCompiler__root�_MSVCCompiler__paths�	plat_name�_MSVCCompiler__arch�initialized)r<�verboseZdry_runZforcerrrr>IszMSVCCompiler.__init__NcCs|dkrt�}d}||kr(td|f��dtjkrfdtjkrf|�d�rfd|_d|_d|_d|_d	|_	n�|t�ksx|d
kr�t
|}nt
t�dt
|}tt|�}|d�
tj�|_|d
tjd
<|dtjd<t|j�dkr�td|j��|�d�|_|�d�|_|�d�|_|�d�|_|�d	�|_	z(tjd�
d�D]}|j�|��q:Wntk
�rfYnXt|j�|_d�|j�tjd<d|_|jdk�r�dddddg|_ddddddg|_n&ddddddg|_dddddddg|_dddg|_|jdk�rddd d!g|_dg|_d"|_dS)#Nrz--plat-name must be one of %sZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer�_rrkrjrzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�;r
z/nologoz/Oxz/MDz/W3z/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NO�z/INCREMENTAL:noz/DEBUGT)rrrYrc�find_exe�cc�linkerrk�rc�mc�PLAT_TO_VCVARSr~r�rTr]r�rSZ_MSVCCompiler__productr rr\r^Zpreprocess_optionsr��compile_options�compile_options_debug�ldflags_sharedr��ldflags_shared_debugZldflags_staticr�)r<r�Zok_platsZ	plat_specZvc_envrDrrr�
initializeTs~�
�
���
�
��zMSVCCompiler.initialize�cCs�|dkrd}g}|D]�}tj�|�\}}tj�|�d}|tj�|�d�}||jkrbtd|��|rrtj�|�}||jkr�|�	tj�
|||j��q||jkr�|�	tj�
|||j��q|�	tj�
|||j
��q|S)Nr�rzDon't know how to compile %s)rYr�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsr r^�
res_extension�_mc_extensions�
obj_extension)r<Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames�s.

�
��zMSVCCompiler.object_filenamesc	Csp|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�|
D�]}z||\}}Wntk
r�YqdYnX|r�tj	�
|�}||jkr�d|}�nT||jkr�d|}�n>||j
k�r<|}d|}z"|�|jg||g|g�Wqdtk
�r6}zt|��W5d}~XYqdXqdn�||jk�r�tj	�|�}tj	�|�}zl|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wqdtk
�r�}zt|��W5d}~XYqdXqdntd||f��d	|}z&|�|jg|
|||g|�Wqdtk
�rh}zt|��W5d}~XYqdXqd|
S)
Nz/cz/Tcz/Tpz/foz-hz-rr�z"Don't know how to compile %s to %sz/Fo)r�r�Z_setup_compiler �extendr�r�rrYrrf�
_c_extensions�_cpp_extensionsr��spawnr�rrr��dirnamer�r�r�r^r�)r<Zsourcesr�r8Zinclude_dirsra�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcr�Z	input_optZ
output_opt�msgZh_dirZrc_dirrr�Zrc_filerrr�compile�s�
�




��


��
��
���
zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz|�|jg|�Wq�tk
r�}zt|��W5d}~XYq�Xnt	�
d|�dS)N)r��/OUT:�skipping %s (up-to-date))r�r��_fix_object_args�library_filename�
_need_linkr�rkrrr
ra)	r<r�Zoutput_libnamer�ra�target_lang�output_filenameZlib_argsr�rrr�create_static_libs�zMSVCCompiler.create_static_libc
CsT|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��rD|tjkr�|	r�|j
dd�}q�|jdd�}n|	r�|j
}n|j}g}|p�gD]}|�d|�q�||||d|g}tj�|d�}|dk	�rLtj�tj�|��\}}tj�	||�|��}|�d|�|�|||�|
�rl|
|dd�<|�r||�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnX|�||�}|dk	�rP|\}}d||f}z|�dd	d
||g�Wn,tk
�r@}zt|��W5d}~XYnXnt�d|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:r�rz/IMPLIB:z-outputresource:%s;%szmt.exez-nologoz	-manifestr�)r�r�r�Z
_fix_lib_args�warnrxr	rYrr^r�r�
EXECUTABLEr�r�r r�r�r�r��manifest_setup_ldargsr�Zmkpathr�r�rr�manifest_get_embed_infor
ra)r<�target_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrar�r��
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsym�ld_argsZdll_nameZdll_extZimplib_filer�ZmfinfoZ
mffilename�mfidZout_argrrr�link6s��
��

��

��


�
zMSVCCompiler.linkcCs,tj�|tj�|�d�}|�d|�dS)Nz	.manifest�/MANIFESTFILE:)rYrr^r�r )r<r�r�r��
temp_manifestrrrr��s
�z"MSVCCompiler.manifest_setup_ldargscCs^|D]"}|�d�r|�dd�d}q,qdS|tjkr<d}nd}|�|�}|dkrVdS||fS)Nr��:rrO)�
startswithrTrr��_remove_visual_c_ref)r<r�r��argr�r�rrrr��s


z$MSVCCompiler.manifest_get_embed_infocCs�z�t|�}z|��}W5|��Xt�dtj�}t�|d|�}d}t�|d|�}t�dtj�}t�||�dkrtWdSt|d�}z|�|�|W�WS|��XWnt	k
r�YnXdS)NzU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)r�z*<dependentAssembly>\s*</dependentAssembly>zI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)�w)
�openrs�read�rer��DOTALLrI�search�write�OSError)r<Z
manifest_fileZ
manifest_fZmanifest_buf�patternrrrr��s2	
��


z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz	/LIBPATH:r�r<�dirrrr�library_dir_option�szMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)rr�rrr�runtime_library_dir_option�s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�Sr)r�)r<rkrrr�library_option�szMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rYrr^r��exists)r<�dirsrkraZ	try_namesr�r)Zlibfilerrr�find_library_file�szMSVCCompiler.find_library_filecCsz|jD].}tj�tj�|�|�}tj�|�r|Sqtjd�d�D].}tj�tj�|�|�}tj�|�rF|SqF|S)a�Return path to an MSVC executable program.

        Tries to find the program in several places: first, one of the
        MSVC program search paths from the registry; next, the directories
        in the PATH environment variable.  If any of those work, return an
        absolute path that is known to exist.  If none of them work, just
        return the original program name, 'exe'.
        �Pathr�)r�rYrr^rfrgrcrT)r<ZexerD�fnrrrr�s	


zMSVCCompiler.find_exe)rrr)N)rr�)NNNrNNN)NrN)
NNNNNrNNNN)r) r1r2r3r4Z
compiler_typeZexecutablesr�r�r�r�r�r�r�Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr>r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr+sl
��

W�
 �
X�
�
_+
r)r
)1r4rYrprQr�Zdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
Zdistutils.utilr�winregZ	OpenKeyExrZEnumKeyrZ	EnumValuer&�errorrZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr�platform�maxsizeZNATIVE_WIN64r9rCrBr�rr7rXr\r_rir~r�rrrrr�<module>sP��>.#
)
PK22�\�
�,JJ"unixccompiler.cpython-38.opt-1.pycnu�[���U

&�.e�;�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
mZmZmZddlmZejdkr~ddlZGd	d
�d
e	�ZdS)a9distutils.unixccompiler

Contains the UnixCCompiler class, a subclass of CCompiler that handles
the "typical" Unix-style command-line C compiler:
  * macros defined with -Dname[=value]
  * macros undefined with -Uname
  * include search directories specified with -Idir
  * libraries specified with -lllib
  * library search directories specified with -Ldir
  * compile handled by 'cc' (or similar) executable with -c option:
    compiles .c to .o
  * link static library handled by 'ar' command (possibly with 'ranlib')
  * link shared library handled by 'cc -shared'
�N)�	sysconfig)�newer)�	CCompiler�gen_preprocess_options�gen_lib_options)�DistutilsExecError�CompileError�LibError�	LinkError)�log�darwinc
s�eZdZdZddgdgdgddgdgddgdd�Zejdd�d	krNd
ged
<ddd
dddgZdZdZ	dZ
dZdZdZ
ZZeZejdkr�dZ�fdd�Zd.dd�Zdd�Zd/d d!�Zd0d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd1d,d-�Z�ZS)2�
UnixCCompilerZunixNZccz-sharedZarz-cr)�preprocessor�compiler�compiler_so�compiler_cxx�	linker_so�
linker_exe�archiver�ranlib�rrz.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%s�cygwinz.execs@t��|||�\}}}t�d�}|r6||kr6|�|�|||fS)z'Remove standard library path from rpathZLIBDIR)�super�
_fix_lib_argsr�get_config_var�remove)�self�	libraries�library_dirs�runtime_library_dirsZlibdir��	__class__��//usr/lib64/python3.8/distutils/unixccompiler.pyrUs�


zUnixCCompiler._fix_lib_argsc
Cs�|�d||�}|\}}}t||�}	|j|	}
|r>|
�d|g�|rN||
dd�<|r\|
�|�|
�|�|js~|dks~t||�r�|r�|�tj	�
|��z|�|
�Wn*tk
r�}zt
|��W5d}~XYnXdS)N�-or)Z_fix_compile_argsrr�extend�appendZforcer�mkpath�os�path�dirname�spawnrr)r�sourceZoutput_fileZmacrosZinclude_dirs�
extra_preargs�extra_postargs�
fixed_args�ignore�pp_optsZpp_args�msgr"r"r#�
preprocess^s$




zUnixCCompiler.preprocessc	
Csp|j}tjdkr t�|||�}z |�|||d|g|�Wn*tk
rj}zt|��W5d}~XYnXdS)Nrr$)r�sys�platform�_osx_support�compiler_fixupr+rr)	r�obj�srcZextZcc_argsr.r1rr2r"r"r#�_compilexs
��
zUnixCCompiler._compilerc
Cs�|�||�\}}|j||d�}|�||�r�|�tj�|��|�|j|g||j	�|j
r�z|�|j
|g�Wq�tk
r�}zt|��W5d}~XYq�Xnt
�d|�dS)N)�
output_dir�skipping %s (up-to-date))�_fix_object_args�library_filename�
_need_linkr'r(r)r*r+r�objectsrrr	r�debug)rr@Zoutput_libnamer;rA�target_lang�output_filenamer2r"r"r#�create_static_lib�s$����	zUnixCCompiler.create_static_libc
Cs�|�||�\}}|�|||�}|\}}}t||||�}t|ttd�f�sPtd��|dk	rftj�	||�}|�
||��r�||j|d|g}|	r�dg|dd�<|
r�|
|dd�<|r�|�|�|�
tj�|��z�|tjkr�|jdd�}n|jdd�}|
dk�rr|j�rrd}tj�|d�dk�r@d}d||k�r@|d7}�q&tj�||�d	k�r\d}nd}|j||||<tjd
k�r�t�||�}|�||�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz%'output_dir' must be a string or Noner$z-grzc++�env��=Z	ld_so_aixrr<)r=rr�
isinstance�str�type�	TypeErrorr(r)�joinr?r@r%r'r*rZ
EXECUTABLErrr�basenamer4r5r6r7r+rr
rrA)rZtarget_descr@rCr;rrrZexport_symbolsrAr-r.Z
build_temprBr/Zlib_optsZld_argsZlinker�i�offsetr2r"r"r#�link�sZ�
���

zUnixCCompiler.linkcCsd|S)N�-Lr")r�dirr"r"r#�library_dir_option�sz UnixCCompiler.library_dir_optioncCsd|kpd|kS)NZgcczg++r")rZ
compiler_namer"r"r#�_is_gcc�szUnixCCompiler._is_gcccCs�tj�t�d��}tjdd�dkr,d|Stjdd�dkrFd|Stjdd�d	krz|�|�rnd
d|gSdd|gS|�|�r�t�d�d
kr�d|Sd|Snd|SdS)N�CCrrrQ�Zfreebsdz-Wl,-rpath=�zhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r(r)rMrrr4r5rT)rrRrr"r"r#�runtime_library_dir_option�s


z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr")r�libr"r"r#�library_optionszUnixCCompiler.library_optioncCs�|j|dd�}|j|dd�}|j|dd�}|j|dd�}tjdkr|t�d�}t�d|�}	|	dkrrt�t�d	��}
n
|	�	d
�}
|D�] }t
j�||�}t
j�||�}
t
j�||�}t
j�||�}tjdk�rL|�
d�s�|�
d��rL|�
d
��sLt
j�|
|d
d�|�}t
j�|
|d
d�|�}
t
j�|
|d
d�|�}t
j�|
|d
d�|�}t
j�|
��rb|
St
j�|��rx|St
j�|��r�|St
j�|�r�|Sq�dS)N�shared)Zlib_type�dylib�
xcode_stub�staticrZCFLAGSz-isysroot\s*(\S+)rUrFz/System/z/usr/z/usr/local/)r>r4r5rr�re�searchr6Z_default_sysroot�groupr(r)rL�
startswith�exists)r�dirsrYrAZshared_fZdylib_fZxcode_stub_fZstatic_fZcflags�mZsysrootrRr[r\r^r]r"r"r#�find_library_filesF



���
zUnixCCompiler.find_library_file)NNNNN)NrN)
NNNNNrNNNN)r)�__name__�
__module__�__qualname__Z
compiler_typeZexecutablesr4r5Zsrc_extensionsZ
obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ
exe_extensionrr3r:rDrPrSrTrXrZrf�
__classcell__r"r"r r#r
-sb�


	�
�
�
B*r
)�__doc__r(r4r_Z	distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr	r
rr5r6r
r"r"r"r#�<module>s
PK22�\4��!�
�
config.cpython-38.opt-1.pycnu�[���U

e5d��@s<dZddlZddlmZddlmZdZGdd�de�ZdS)z�distutils.pypirc

Provides the PyPIRCCommand class, the base class for the command classes
that uses .pypirc in the distutils.command package.
�N)�RawConfigParser)�CommandzE[distutils]
index-servers =
    pypi

[pypi]
username:%s
password:%s
c@sheZdZdZdZdZdZdZdddefdgZd	gZ	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�ZdS)�
PyPIRCCommandz;Base command that knows how to handle the .pypirc file
    zhttps://upload.pypi.org/legacy/�pypiNzrepository=�rzurl of repository [default: %s])�
show-responseNz&display full response text from serverrcCstj�tj�d�d�S)zReturns rc file path.�~z.pypirc)�os�path�join�
expanduser��self�r�(/usr/lib64/python3.8/distutils/config.py�_get_rc_file&szPyPIRCCommand._get_rc_filec	CsH|��}t�t�|tjtjBd�d��}|�t||f�W5QRXdS)zCreates a default .pypirc file.i��wN)rr	�fdopen�open�O_CREAT�O_WRONLY�write�DEFAULT_PYPIRC)r�username�password�rc�frrr�
_store_pypirc*s zPyPIRCCommand._store_pypirccCs�|��}tj�|��r�|�d|�|jp.|j}t�}|�|�|�	�}d|k�rF|�
dd�}dd�|�d�D�}|gkr�d|kr�dg}niS|D]�}d|i}|�
|d	�|d	<d
|jfd|jfdfD].\}	}
|�
||	�r�|�
||	�||	<q�|
||	<q�|dk�r ||jdfk�r |j|d
<|S|d|k�s:|d
|kr�|Sq�nRd
|k�r�d
}|�
|d
��rp|�
|d
�}n|j}|�
|d	�|�
|d�|||jd�SiS)zReads the .pypirc file.zUsing PyPI login from %sZ	distutilsz
index-serverscSs g|]}|��dkr|���qS)�)�strip)�.0�serverrrr�
<listcomp>=s�z.PyPIRCCommand._read_pypirc.<locals>.<listcomp>�
rr!r�
repository�realm)rNzserver-loginr)rrr$r!r%)rr	r
�existsZannouncer$�DEFAULT_REPOSITORYr�read�sections�get�split�
DEFAULT_REALMZ
has_option)rrr$Zconfigr)Z
index_serversZ_serversr!Zcurrent�key�defaultrrr�_read_pypirc0sb

���

�

�


�zPyPIRCCommand._read_pypirccCs8ddl}|�dd�}|�|�d�dd�}|���|�S)z%Read and decode a PyPI HTTP response.rNzcontent-typez
text/plain��charset�ascii)�cgiZ	getheaderZparse_headerr*r(�decode)rZresponser3Zcontent_type�encodingrrr�_read_pypi_responsepsz!PyPIRCCommand._read_pypi_responsecCsd|_d|_d|_dS)zInitialize options.Nr)r$r%Z
show_responser
rrr�initialize_optionswsz PyPIRCCommand.initialize_optionscCs(|jdkr|j|_|jdkr$|j|_dS)zFinalizes options.N)r$r'r%r,r
rrr�finalize_options}s

zPyPIRCCommand.finalize_options)�__name__�
__module__�__qualname__�__doc__r'r,r$r%Zuser_optionsZboolean_optionsrrr/r6r7r8rrrrrs&���@r)r<r	ZconfigparserrZ
distutils.cmdrrrrrrr�<module>s

PK22�\��V����ccompiler.cpython-38.opt-1.pycnu�[���U

e5dI��@s�dZddlZddlZddlZddlTddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZdd	lmZGd
d�d�ZdZdd
d�Zdddddd�Zdd�Zddd�Zdd�Zdd�ZdS)z�distutils.ccompiler

Contains CCompiler, an abstract base class that defines the interface
for the Distutils compiler abstraction model.�N)�*)�spawn)�	move_file)�mkpath)�newer_pairwise�newer_group)�split_quoted�execute)�logc
@seZdZdZdZdZdZdZdZdZ	dZ
dZdddddd�ZdddgZ
dqdd	�Zd
d�Zdd
�Zdd�Zdd�Zdrdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d.d/�Z!dsd0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&dtd:d;�Z'dud<d=�Z(d>d?�Z)dvd@dA�Z*dBZ+dCZ,dDZ-dwdEdF�Z.dxdGdH�Z/dydIdJ�Z0dzdKdL�Z1dMdN�Z2dOdP�Z3dQdR�Z4d{dSdT�Z5d|dUdV�Z6d}dXdY�Z7d~dZd[�Z8dd\d]�Z9d�d_d`�Z:d�dbdc�Z;ddde�Z<dfdg�Z=d�dhdi�Z>djdk�Z?dldm�Z@d�dodp�ZAdS)��	CCompilera�Abstract base class to define the interface that must be implemented
    by real compiler classes.  Also has some utility methods used by
    several compiler classes.

    The basic idea behind a compiler abstraction class is that each
    instance can be used for all the compile/link steps in building a
    single project.  Thus, attributes common to all of those compile and
    link steps -- include directories, macros to define, libraries to link
    against, etc. -- are attributes of the compiler instance.  To allow for
    variability in how individual files are treated, most of those
    attributes may be varied on a per-compilation or per-link basis.
    N�czc++Zobjc)�.cz.ccz.cppz.cxxz.mrcCsb||_||_||_d|_g|_g|_g|_g|_g|_g|_	|j
��D]}|�||j
|�qFdS�N)
�dry_run�force�verbose�
output_dir�macros�include_dirs�	libraries�library_dirs�runtime_library_dirs�objects�executables�keys�set_executable)�selfrrr�key�r�+/usr/lib64/python3.8/distutils/ccompiler.py�__init__UszCCompiler.__init__cKs<|D]2}||jkr&td||jjf��|�|||�qdS)a�Define the executables (and options for them) that will be run
        to perform the various stages of compilation.  The exact set of
        executables that may be specified here depends on the compiler
        class (via the 'executables' class attribute), but most will have:
          compiler      the C/C++ compiler
          linker_so     linker used to create shared objects and libraries
          linker_exe    linker used to create binary executables
          archiver      static library creator

        On platforms with a command-line (Unix, DOS/Windows), each of these
        is a string that will be split into executable name and (optional)
        list of arguments.  (Splitting the string is done similarly to how
        Unix shells operate: words are delimited by spaces, but quotes and
        backslashes can override this.  See
        'distutils.util.split_quoted()'.)
        z$unknown executable '%s' for class %sN)r�
ValueError�	__class__�__name__r)r�kwargsrrrr�set_executablesys

�zCCompiler.set_executablescCs,t|t�rt||t|��nt|||�dSr)�
isinstance�str�setattrr)rr�valuerrrr�s
zCCompiler.set_executablecCs0d}|jD] }|d|kr"|S|d7}q
dS)Nr�)r)r�name�i�defnrrr�_find_macro�s

zCCompiler._find_macrocCs`|D]V}t|t�rFt|�dkrFt|dt�s8|ddkrFt|dt�std|dd��qdS)z�Ensures that every element of 'definitions' is a valid macro
        definition, ie. either (name,value) 2-tuple or a (name,) tuple.  Do
        nothing if all definitions are OK, raise TypeError otherwise.
        )r*�r*Nrzinvalid macro definition '%s': z.must be tuple (string,), (string, string), or z(string, None))r&�tuple�lenr'�	TypeError)rZdefinitionsr-rrr�_check_macro_definitions�s

��
����z"CCompiler._check_macro_definitionscCs.|�|�}|dk	r|j|=|j�||f�dS)a_Define a preprocessor macro for all compilations driven by this
        compiler object.  The optional parameter 'value' should be a
        string; if it is not supplied, then the macro will be defined
        without an explicit value and the exact outcome depends on the
        compiler used (XXX true? does ANSI say anything about this?)
        N�r.r�append)rr+r)r,rrr�define_macro�s	
zCCompiler.define_macrocCs0|�|�}|dk	r|j|=|f}|j�|�dS)a�Undefine a preprocessor macro for all compilations driven by
        this compiler object.  If the same macro is defined by
        'define_macro()' and undefined by 'undefine_macro()' the last call
        takes precedence (including multiple redefinitions or
        undefinitions).  If the macro is redefined/undefined on a
        per-compilation basis (ie. in the call to 'compile()'), then that
        takes precedence.
        Nr4)rr+r,Zundefnrrr�undefine_macro�s

zCCompiler.undefine_macrocCs|j�|�dS)z�Add 'dir' to the list of directories that will be searched for
        header files.  The compiler is instructed to search directories in
        the order in which they are supplied by successive calls to
        'add_include_dir()'.
        N)rr5�r�dirrrr�add_include_dir�szCCompiler.add_include_dircCs|dd�|_dS)aySet the list of directories that will be searched to 'dirs' (a
        list of strings).  Overrides any preceding calls to
        'add_include_dir()'; subsequence calls to 'add_include_dir()' add
        to the list passed to 'set_include_dirs()'.  This does not affect
        any list of standard include directories that the compiler may
        search by default.
        N�r�r�dirsrrr�set_include_dirs�szCCompiler.set_include_dirscCs|j�|�dS)a�Add 'libname' to the list of libraries that will be included in
        all links driven by this compiler object.  Note that 'libname'
        should *not* be the name of a file containing a library, but the
        name of the library itself: the actual filename will be inferred by
        the linker, the compiler, or the compiler class (depending on the
        platform).

        The linker will be instructed to link against libraries in the
        order they were supplied to 'add_library()' and/or
        'set_libraries()'.  It is perfectly valid to duplicate library
        names; the linker will be instructed to link against libraries as
        many times as they are mentioned.
        N)rr5)r�libnamerrr�add_library�szCCompiler.add_librarycCs|dd�|_dS)z�Set the list of libraries to be included in all links driven by
        this compiler object to 'libnames' (a list of strings).  This does
        not affect any standard system libraries that the linker may
        include by default.
        N)r)rZlibnamesrrr�
set_libraries�szCCompiler.set_librariescCs|j�|�dS)a'Add 'dir' to the list of directories that will be searched for
        libraries specified to 'add_library()' and 'set_libraries()'.  The
        linker will be instructed to search for libraries in the order they
        are supplied to 'add_library_dir()' and/or 'set_library_dirs()'.
        N)rr5r8rrr�add_library_dirszCCompiler.add_library_dircCs|dd�|_dS)z�Set the list of library search directories to 'dirs' (a list of
        strings).  This does not affect any standard library search path
        that the linker may search by default.
        N)rr<rrr�set_library_dirsszCCompiler.set_library_dirscCs|j�|�dS)zlAdd 'dir' to the list of directories that will be searched for
        shared libraries at runtime.
        N)rr5r8rrr�add_runtime_library_dirsz!CCompiler.add_runtime_library_dircCs|dd�|_dS)z�Set the list of directories to search for shared libraries at
        runtime to 'dirs' (a list of strings).  This does not affect any
        standard search path that the runtime linker may search by
        default.
        N)rr<rrr�set_runtime_library_dirssz"CCompiler.set_runtime_library_dirscCs|j�|�dS)z�Add 'object' to the list of object files (or analogues, such as
        explicitly named library files or the output of "resource
        compilers") to be included in every link driven by this compiler
        object.
        N)rr5)r�objectrrr�add_link_object szCCompiler.add_link_objectcCs|dd�|_dS)z�Set the list of object files (or analogues) to be included in
        every link to 'objects'.  This does not affect any standard object
        files that the linker may include by default (such as system
        libraries).
        N)r)rrrrr�set_link_objects(szCCompiler.set_link_objectscCs|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|dkr�g}|j|d|d�}t	||�}i}	t
t|��D]B}
||
}||
}tj
�|�d}
|�tj
�|��||
f|	|<q�|||||	fS)z;Process arguments and decide which source files to compile.N�%'output_dir' must be a string or None�/'macros' (if supplied) must be a list of tuples�6'include_dirs' (if supplied) must be a list of stringsr)�	strip_dirrr*)rr&r'r2r�listrr0�object_filenames�gen_preprocess_options�ranger1�os�path�splitextr�dirname)rZoutdirrZincdirs�sources�dependsZextrar�pp_opts�buildr,�src�obj�extrrr�_setup_compile6s<

��
zCCompiler._setup_compilecCs0|dg}|rdg|dd�<|r,||dd�<|S)Nz-cz-grr)rrW�debugZbefore�cc_argsrrr�_get_cc_argsas
zCCompiler._get_cc_argscCs�|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)a'Typecheck and fix-up some of the arguments to the 'compile()'
        method, and return fixed-up values.  Specifically: if 'output_dir'
        is None, replaces it with 'self.output_dir'; ensures that 'macros'
        is a list, and augments it with 'self.macros'; ensures that
        'include_dirs' is a list, and augments it with 'self.include_dirs'.
        Guarantees that the returned values are of the correct type,
        i.e. for 'output_dir' either string or None, and for 'macros' and
        'include_dirs' either list or None.
        NrIrJrK)rr&r'r2rrMrr0)rrrrrrr�_fix_compile_argsjs"


�zCCompiler._fix_compile_argscCs|j||d�}|ifS)a+Decide which souce files must be recompiled.

        Determine the list of object files corresponding to 'sources',
        and figure out which ones really need to be recompiled.
        Return a list of all object files and a dictionary telling
        which source files can be skipped.
        )r)rN)rrUrrVrrrr�
_prep_compile�s	zCCompiler._prep_compilecCsHt|ttf�std��t|�}|dkr.|j}nt|t�s@td��||fS)z�Typecheck and fix up some arguments supplied to various methods.
        Specifically: ensure that 'objects' is a list; if output_dir is
        None, replace with self.output_dir.  Return fixed versions of
        'objects' and 'output_dir'.
        z,'objects' must be a list or tuple of stringsNrI)r&rMr0r2rr')rrrrrr�_fix_object_args�s
zCCompiler._fix_object_argscCs�|dkr|j}n*t|ttf�r2t|�|jp,g}ntd��|dkrJ|j}n*t|ttf�rlt|�|jpfg}ntd��|dkr�|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)a;Typecheck and fix up some of the arguments supplied to the
        'link_*' methods.  Specifically: ensure that all arguments are
        lists, and augment them with their permanent versions
        (eg. 'self.libraries' augments 'libraries').  Return a tuple with
        fixed versions of all arguments.
        Nz3'libraries' (if supplied) must be a list of stringsz6'library_dirs' (if supplied) must be a list of stringsz>'runtime_library_dirs' (if supplied) must be a list of strings)rr&rMr0r2rr)rrrrrrr�
_fix_lib_args�s,���zCCompiler._fix_lib_argscCs2|jr
dS|jr t||dd�}n
t||�}|SdS)zjReturn true if we need to relink the files listed in 'objects'
        to recreate 'output_file'.
        T�newer)ZmissingN)rrr)rr�output_filerdrrr�
_need_link�s
zCCompiler._need_linkc		Cs~t|t�s|g}d}t|j�}|D]V}tj�|�\}}|j�|�}z |j�	|�}||kr`|}|}Wq"t
k
rvYq"Xq"|S)z|Detect the language of a given file, or list of files. Uses
        language_map, and language_order to do the job.
        N)r&rMr1�language_orderrQrRrS�language_map�get�indexr!)	rrUZlangrj�source�baser[ZextlangZextindexrrr�detect_language�s

zCCompiler.detect_languagecCsdS)a�Preprocess a single C/C++ source file, named in 'source'.
        Output will be written to file named 'output_file', or stdout if
        'output_file' not supplied.  'macros' is a list of macro
        definitions as for 'compile()', which will augment the macros set
        with 'define_macro()' and 'undefine_macro()'.  'include_dirs' is a
        list of directory names that will be added to the default list.

        Raises PreprocessError on failure.
        Nr)rrkrerr�
extra_preargs�extra_postargsrrr�
preprocess�szCCompiler.preprocessc		Csx|�||||||�\}}	}}
}|�|
||�}|	D]B}
z||
\}}Wntk
r\Yq0YnX|�|
|||||
�q0|	S)aK	Compile one or more source files.

        'sources' must be a list of filenames, most likely C/C++
        files, but in reality anything that can be handled by a
        particular compiler and compiler class (eg. MSVCCompiler can
        handle resource files in 'sources').  Return a list of object
        filenames, one per source filename in 'sources'.  Depending on
        the implementation, not all source files will necessarily be
        compiled, but all corresponding object filenames will be
        returned.

        If 'output_dir' is given, object files will be put under it, while
        retaining their original path component.  That is, "foo/bar.c"
        normally compiles to "foo/bar.o" (for a Unix implementation); if
        'output_dir' is "build", then it would compile to
        "build/foo/bar.o".

        'macros', if given, must be a list of macro definitions.  A macro
        definition is either a (name, value) 2-tuple or a (name,) 1-tuple.
        The former defines a macro; if the value is None, the macro is
        defined without an explicit value.  The 1-tuple case undefines a
        macro.  Later definitions/redefinitions/ undefinitions take
        precedence.

        'include_dirs', if given, must be a list of strings, the
        directories to add to the default include file search path for this
        compilation only.

        'debug' is a boolean; if true, the compiler will be instructed to
        output debug symbols in (or alongside) the object file(s).

        'extra_preargs' and 'extra_postargs' are implementation- dependent.
        On platforms that have the notion of a command-line (e.g. Unix,
        DOS/Windows), they are most likely lists of strings: extra
        command-line arguments to prepend/append to the compiler command
        line.  On other platforms, consult the implementation class
        documentation.  In any event, they are intended as an escape hatch
        for those occasions when the abstract compiler framework doesn't
        cut the mustard.

        'depends', if given, is a list of filenames that all targets
        depend on.  If a source file is older than any file in
        depends, then the source file will be recompiled.  This
        supports dependency tracking, but only at a coarse
        granularity.

        Raises CompileError on failure.
        )r\r_�KeyError�_compile)rrUrrrr]rnrorVrrWrXr^rZrYr[rrr�compile�s6��
zCCompiler.compilecCsdS)zCompile 'src' to product 'obj'.Nr)rrZrYr[r^rorWrrrrrCszCCompiler._compilecCsdS)a&Link a bunch of stuff together to create a static library file.
        The "bunch of stuff" consists of the list of object files supplied
        as 'objects', the extra object files supplied to
        'add_link_object()' and/or 'set_link_objects()', the libraries
        supplied to 'add_library()' and/or 'set_libraries()', and the
        libraries supplied as 'libraries' (if any).

        'output_libname' should be a library name, not a filename; the
        filename will be inferred from the library name.  'output_dir' is
        the directory where the library file will be put.

        'debug' is a boolean; if true, debugging information will be
        included in the library (note that on most platforms, it is the
        compile step where this matters: the 'debug' flag is included here
        just for consistency).

        'target_lang' is the target language for which the given objects
        are being compiled. This allows specific linkage time treatment of
        certain languages.

        Raises LibError on failure.
        Nr)rr�output_libnamerr]�target_langrrr�create_static_libIszCCompiler.create_static_libZ
shared_objectZshared_library�
executablecCst�dS)auLink a bunch of stuff together to create an executable or
        shared library file.

        The "bunch of stuff" consists of the list of object files supplied
        as 'objects'.  'output_filename' should be a filename.  If
        'output_dir' is supplied, 'output_filename' is relative to it
        (i.e. 'output_filename' can provide directory components if
        needed).

        'libraries' is a list of libraries to link against.  These are
        library names, not filenames, since they're translated into
        filenames in a platform-specific way (eg. "foo" becomes "libfoo.a"
        on Unix and "foo.lib" on DOS/Windows).  However, they can include a
        directory component, which means the linker will look in that
        specific directory rather than searching all the normal locations.

        'library_dirs', if supplied, should be a list of directories to
        search for libraries that were specified as bare library names
        (ie. no directory component).  These are on top of the system
        default and those supplied to 'add_library_dir()' and/or
        'set_library_dirs()'.  'runtime_library_dirs' is a list of
        directories that will be embedded into the shared library and used
        to search for other shared libraries that *it* depends on at
        run-time.  (This may only be relevant on Unix.)

        'export_symbols' is a list of symbols that the shared library will
        export.  (This appears to be relevant only on Windows.)

        'debug' is as for 'compile()' and 'create_static_lib()', with the
        slight distinction that it actually matters on most platforms (as
        opposed to 'create_static_lib()', which includes a 'debug' flag
        mostly for form's sake).

        'extra_preargs' and 'extra_postargs' are as for 'compile()' (except
        of course that they supply command-line arguments for the
        particular linker being used).

        'target_lang' is the target language for which the given objects
        are being compiled. This allows specific linkage time treatment of
        certain languages.

        Raises LinkError on failure.
        N��NotImplementedError)rZtarget_descr�output_filenamerrrr�export_symbolsr]rnro�
build_temprurrr�linkis9zCCompiler.linkc

Cs2|�tj||j|dd�|||||||	|
||�
dS)N�shared)�lib_type)r}r�SHARED_LIBRARY�library_filename)
rrrtrrrrr{r]rnror|rurrr�link_shared_lib�s
�zCCompiler.link_shared_libc

Cs(|�tj|||||||||	|
||�
dSr)r}r�
SHARED_OBJECT)
rrrzrrrrr{r]rnror|rurrr�link_shared_object�s
�zCCompiler.link_shared_objectcCs.|�tj||�|�||||d|||	d|
�
dSr)r}r�
EXECUTABLE�executable_filename)rrZoutput_prognamerrrrr]rnrorurrr�link_executable�s
�zCCompiler.link_executablecCst�dS)zkReturn the compiler option to add 'dir' to the list of
        directories searched for libraries.
        Nrxr8rrr�library_dir_option�szCCompiler.library_dir_optioncCst�dS)zsReturn the compiler option to add 'dir' to the list of
        directories searched for runtime libraries.
        Nrxr8rrr�runtime_library_dir_option�sz$CCompiler.runtime_library_dir_optioncCst�dS)zReturn the compiler option to add 'lib' to the list of libraries
        linked into the shared library or executable.
        Nrx)r�librrr�library_option�szCCompiler.library_optionc	Cs�ddl}|dkrg}|dkr g}|dkr,g}|dkr8g}|jd|dd�\}}t�|d�}	z*|D]}
|	�d|
�q^|	�d|�W5|	��Xz|j|g|d	�}Wntk
r�Yd
SXz|j|d||d�Wnt	t
fk
r�Yd
SXdS)
z�Return a boolean indicating whether funcname is supported on
        the current platform.  The optional arguments can be used to
        augment the compilation environment.
        rNr
T)�text�wz#include "%s"
z=int main (int argc, char **argv) {
    %s();
    return 0;
}
r;Fza.out)rr)�tempfileZmkstemprQ�fdopen�close�writersZCompileErrorr�Z	LinkErrorr2)r�funcnameZincludesrrrr��fdZfname�fZinclrrrr�has_function�s<	�

�
zCCompiler.has_functioncCst�dS)aHSearch the specified list of directories for a static or shared
        library file 'lib' and return the full path to that file.  If
        'debug' true, look for a debugging version (if that makes sense on
        the current platform).  Return None if 'lib' wasn't found in any of
        the specified directories.
        Nrx)rr=r�r]rrr�find_library_file$szCCompiler.find_library_file�cCs�|dkrd}g}|D]|}tj�|�\}}tj�|�d}|tj�|�d�}||jkrftd||f��|rvtj�|�}|�tj�	|||j
��q|S)Nr�r*z"unknown file type '%s' (from '%s'))rQrRrS�
splitdrive�isabs�src_extensionsZUnknownFileError�basenamer5�join�
obj_extension)rZsource_filenamesrLrZ	obj_namesZsrc_namerlr[rrrrNOs"

��zCCompiler.object_filenamescCs$|rtj�|�}tj�|||j�Sr)rQrRr�r��shared_lib_extension�rr�rLrrrr�shared_object_filename`sz CCompiler.shared_object_filenamecCs(|rtj�|�}tj�|||jp"d�S)Nr�)rQrRr�r��
exe_extensionr�rrrr�fszCCompiler.executable_filename�staticc
Cs`|dkrtd��t||d�}t||d�}tj�|�\}}|||f}	|rPd}tj�|||	�S)N)r�r~ZdylibZ
xcode_stubz?'lib_type' must be "static", "shared", "dylib", or "xcode_stub"Z_lib_formatZ_lib_extensionr�)r!�getattrrQrR�splitr�)
rr?rrLrZfmtr[r9rl�filenamerrrr�ls�zCCompiler.library_filenamer*cCst�|�dSr)r
r])r�msg�levelrrr�announceszCCompiler.announcecCsddlm}|rt|�dS)Nr)�DEBUG)Zdistutils.debugr��print)rr�r�rrr�debug_print�szCCompiler.debug_printcCstj�d|�dS)Nzwarning: %s
)�sys�stderrr�)rr�rrr�warn�szCCompiler.warncCst||||j�dSr)r	r)r�func�argsr�r�rrrr	�szCCompiler.executecCst||jd�dS�N)r)rr)r�cmdrrrr�szCCompiler.spawncCst|||jd�Sr�)rr)rrYZdstrrrr�szCCompiler.move_file�cCst|||jd�dSr�)rr)rr+�moderrrr�szCCompiler.mkpath)rrr)N)N)NNNNN)NNNrNNN)NrN)
NNNNNrNNNN)
NNNNNrNNNN)
NNNNNrNNNN)NNNNrNNN)NNNN)r)rr�)rr�)rr�)r�rr�)r*)Nr*)r�)Br#�
__module__�__qualname__�__doc__Z
compiler_typer�r�Zstatic_lib_extensionr�Zstatic_lib_formatZshared_lib_formatr�rhrgr r%rr.r3r6r7r:r>r@rArBrCrDrErGrHr\r_r`rarbrcrfrmrprsrrrvr�r�r�r}r�r�r�r�r�r�r�r�rNr�r�r�r�r�r�r	rrrrrrrrs��

$ 

+	 
"
�

�
D�
�
A�
�
�
�
,
+


�


r))zcygwin.*�unix)�posixr�)�nt�msvccCsV|dkrtj}|dkrtj}tD]0\}}t�||�dk	sHt�||�dk	r |Sq dS)akDetermine the default compiler to use for the given platform.

       osname should be one of the standard Python OS names (i.e. the
       ones returned by os.name) and platform the common value
       returned by sys.platform for the platform in question.

       The default values are os.name and sys.platform in case the
       parameters are not given.
    Nr�)rQr+r��platform�_default_compilers�re�match)Zosnamer��pattern�compilerrrr�get_default_compiler�s
�
r�)Z
unixccompilerZ
UnixCCompilerzstandard UNIX-style compiler)Z
_msvccompilerZMSVCCompilerzMicrosoft Visual C++)�cygwinccompilerZCygwinCCompilerz'Cygwin port of GNU C Compiler for Win32)r�ZMingw32CCompilerz(Mingw32 port of GNU C Compiler for Win32)ZbcppcompilerZBCPPCompilerzBorland C++ Compiler)r�r��cygwinZmingw32ZbcppcCsXddlm}g}t��D] }|�d|dt|df�q|��||�}|�d�dS)zyPrint list of available compilers (used by the "--help-compiler"
    options to "build", "build_ext", "build_clib").
    r)�FancyGetoptz	compiler=Nr/zList of available compilers:)Zdistutils.fancy_getoptr��compiler_classrr5�sortZ
print_help)r�Z	compilersr�Zpretty_printerrrr�show_compilers�s
�r�cCs�|dkrtj}z"|dkr t|�}t|\}}}Wn8tk
rhd|}|dk	r\|d|}t|��YnXz*d|}t|�tj|}	t	|	�|}
WnBt
k
r�td|��Yn$tk
r�td||f��YnX|
d||�S)a[Generate an instance of some CCompiler subclass for the supplied
    platform/compiler combination.  'plat' defaults to 'os.name'
    (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
    for that platform.  Currently only 'posix' and 'nt' are supported, and
    the default compilers are "traditional Unix interface" (UnixCCompiler
    class) and Visual C++ (MSVCCompiler class).  Note that it's perfectly
    possible to ask for a Unix compiler object under Windows, and a
    Microsoft compiler object under Unix -- if you supply a value for
    'compiler', 'plat' is ignored.
    Nz5don't know how to compile C/C++ code on platform '%s'z with '%s' compilerz
distutils.z4can't compile C/C++ code: unable to load module '%s'zBcan't compile C/C++ code: unable to find class '%s' in module '%s')rQr+r�r�rqZDistutilsPlatformError�
__import__r��modules�vars�ImportErrorZDistutilsModuleError)Zplatr�rrrZmodule_name�
class_nameZlong_descriptionr��module�klassrrr�new_compiler�s:
����
r�cCs�g}|D]�}t|t�r0dt|�kr.dks<ntd|��t|�dkr\|�d|d�qt|�dkr|ddkr�|�d|d�q|�d|�q|D]}|�d	|�q�|S)
aGenerate C pre-processor options (-D, -U, -I) as used by at least
    two types of compilers: the typical Unix compiler and Visual C++.
    'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
    means undefine (-U) macro 'name', and (name,value) means define (-D)
    macro 'name' to 'value'.  'include_dirs' is just a list of directory
    names to be added to the header file search path (-I).  Returns a list
    of command-line options suitable for either Unix compilers or Visual
    C++.
    r*r/zPbad macro definition '%s': each element of 'macros' list must be a 1- or 2-tuplez-U%srNz-D%sz-D%s=%sz-I%s)r&r0r1r2r5)rrrWZmacror9rrrrOs"$��rOcCs�g}|D]}|�|�|��q|D],}|�|�}t|t�rD||}q"|�|�q"|D]V}tj�|�\}}	|r�|�|g|	�}
|
r�|�|
�q�|�	d|�qT|�|�
|��qT|S)acGenerate linker options for searching library directories and
    linking with specific libraries.  'libraries' and 'library_dirs' are,
    respectively, lists of library names (not filenames!) and search
    directories.  Returns a list of command-line options suitable for use
    with some compiler (depending on the two format strings passed in).
    z6no library file corresponding to '%s' found (skipping))r5r�r�r&rMrQrRr�r�r�r�)r�rrrZlib_optsr9�optr�Zlib_dirZlib_nameZlib_filerrr�gen_lib_options8s&


�r�)NN)NNrrr)r�r�rQr�Zdistutils.errorsZdistutils.spawnrZdistutils.file_utilrZdistutils.dir_utilrZdistutils.dep_utilrrZdistutils.utilrr	Z	distutilsr
rr�r�r�r�r�rOr�rrrr�<module>s8
�
--PK22�\|����spawn.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZddlZddlZddlmZmZddlmZddlm	Z	ddd�Z
d	d
�Zddd�Zej
d
krjdadaddd�Zddd�ZdS)z�distutils.spawn

Provides the 'spawn()' function, a front-end to various platform-
specific functions for launching another program in a sub-process.
Also provides the 'find_executable()' to search the path for a given
executable name.
�N)�DistutilsPlatformError�DistutilsExecError)�DEBUG)�log�cCsNt|�}tjdkr"t|||d�n(tjdkr<t|||d�ntdtj��dS)a�Run another program, specified as a command list 'cmd', in a new process.

    'cmd' is just the argument list for the new process, ie.
    cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
    There is no way to run a program with a name different from that of its
    executable.

    If 'search_path' is true (the default), the system's executable
    search path will be used to find the program; otherwise, cmd[0]
    must be the exact path to the executable.  If 'dry_run' is true,
    the command will not actually be run.

    Raise DistutilsExecError if running the program fails in any way; just
    return on success.
    �posix)�dry_run�ntz1don't know how to spawn programs on platform '%s'N)�list�os�name�_spawn_posix�	_spawn_ntr)�cmd�search_path�verboser�r�'/usr/lib64/python3.8/distutils/spawn.py�spawns

�rcCs*t|�D]\}}d|krd|||<q|S)z�Quote command-line arguments for DOS/Windows conventions.

    Just wraps every argument which contains blanks in double quotes, and
    returns a new argument list.
    � z"%s")�	enumerate)�args�i�argrrr�_nt_quote_args+src
Cs�|d}t|�}|r t|�p|}t�d�|g|dd���|s�zt�tj||�}Wn@tk
r�}z"t	sp|}t
d||jdf��W5d}~XYnX|dkr�t	s�|}t
d||f��dS)Nrrr�command %r failed: %s����%command %r failed with exit status %d)r�find_executabler�info�joinr�spawnv�P_WAIT�OSErrorrrr)rrrr�
executableZrc�excrrrr;s(�
�r�darwinc
Cs|t�d�|��|rdS|d}|r*tjp.tj}d}tjdkr�tdkrxddl	m
}|�d�p^datrxdd�t�d	�D�a
tr�tj�dt�}t
d
d�|�d	�D�kr�d|tf}	t|	��ttj|d�}|r�tjp�tj}t��}
|
dk�r�z$|dkr�|||�n||||�WnNtk
�rX}z.t�s(|}tj�d
||jf�t�d�W5d}~XYnXt�sd|}tj�d|�t�d�n�zt�|
d�\}
}WnDtk
�r�}
z$t�s�|}td||
jdf��W5d}
~
XYnXt�|��rt�s�|}td|t�|�f��nlt� |��rHt�!|�}|dk�r,dSt�s6|}td||f��n,t�"|��rZ�q�nt�sd|}td||f���q�dS)Nrrr&)�	sysconfig�MACOSX_DEPLOYMENT_TARGET�cSsg|]}t|��qSr��int��.0�xrrr�
<listcomp>esz _spawn_posix.<locals>.<listcomp>�.cSsg|]}t|��qSrr*r,rrrr/kszF$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure)r(zunable to execute %r: %s
rz(unable to execute %r for unknown reasonsrrz"command %r terminated by signal %drz1unknown error executing %r: termination status %d)#rrr r�execvp�execv�sys�platform�_cfg_target�	distutilsr'Zget_config_var�split�_cfg_target_split�environ�getr�dict�execvpe�execve�forkr#r�stderr�write�strerror�_exit�waitpidrr�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS�
WIFSTOPPED)rrrrr$Zexec_fn�envr'Z
cur_targetZmy_msg�pid�eZstatusr%Zexit_statusrrrr
Ws�
����
����

����r
c	Cs�tj�|�\}}tjdkr*|dkr*|d}tj�|�r:|S|dkr�tj�dd�}|dkr�zt�d�}Wnt	t
fk
r�tj}YnX|s�dS|�tj
�}|D]&}tj�||�}tj�|�r�|Sq�dS)z�Tries to find 'executable' in the directories listed in 'path'.

    A string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH'].  Returns the complete filename or None if not found.
    Zwin32z.exeN�PATH�CS_PATH)r�path�splitextr3r4�isfiler9r:�confstr�AttributeError�
ValueError�defpathr7�pathsepr )r$rN�_Zext�paths�p�frrrr�s(
r)rrr)rrr)rrr)N)�__doc__r3rZdistutils.errorsrrZdistutils.debugrr6rrrrr4r5r8r
rrrrr�<module>s



RPK22�\0�oa����dist.cpython-38.opt-1.pycnu�[���U

e5d���@s�dZddlZddlZddlZddlmZzddlZWnek
rLdZYnXddlTddl	m
Z
mZddlm
Z
mZmZddlmZddlmZe�d	�Zd
d�ZGdd
�d
�ZGdd�d�Zdd�ZdS)z}distutils.dist

Provides the Distribution class, which represents the module distribution
being built/installed/distributed.
�N)�message_from_file)�*)�FancyGetopt�translate_longopt)�
check_environ�	strtobool�
rfc822_escape��log)�DEBUGz^[a-zA-Z]([a-zA-Z0-9_]*)$cCsLt|t�rn<t|t�sHt|�j}d|�d|�d�}t�tj|�t|�}|S)Nz
Warning: 'z' should be a list, got type '�')�
isinstance�str�list�type�__name__r
ZWARN)�valueZ	fieldname�typename�msg�r�&/usr/lib64/python3.8/distutils/dist.py�_ensure_lists


rc@speZdZdZdddddgZdZdd	d
ddd
dddddddddddddddgZdd�eD�Zdd iZdad"d#�Z	d$d%�Z
dbd'd(�Zd)d*�Zdcd+d,�Z
d-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d5gfd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zd@dA�ZdBdC�ZdddDdE�ZdedFdG�ZdfdIdJ�ZejfdKdL�ZdMdN�ZdOdP�Z dQdR�Z!dSdT�Z"dUdV�Z#dWdX�Z$dYdZ�Z%d[d\�Z&d]d^�Z'd_d`�Z(d!S)g�Distributiona�The core of the Distutils.  Most of the work hiding behind 'setup'
    is really done within a Distribution instance, which farms the work out
    to the Distutils commands specified on the command line.

    Setup scripts will almost never instantiate Distribution directly,
    unless the 'setup()' function is totally inadequate to their needs.
    However, it is conceivable that a setup script might wish to subclass
    Distribution for some specialized purpose, and then pass the subclass
    to 'setup()' as the 'distclass' keyword argument.  If so, it is
    necessary to respect the expectations that 'setup' has of Distribution.
    See the code for 'setup()', in core.py, for details.
    )�verbose�vzrun verbosely (default)�)�quiet�qz!run quietly (turns verbosity off))zdry-run�nzdon't actually do anything)�help�hzshow detailed help message)zno-user-cfgNz-ignore pydistutils.cfg in your home directoryz�Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package
)z
help-commandsNzlist all available commands)�nameNzprint package name)�version�Vzprint package version)�fullnameNzprint <package name>-<version>)�authorNzprint the author's name)�author-emailNz print the author's email address)�
maintainerNzprint the maintainer's name)zmaintainer-emailNz$print the maintainer's email address)�contactNz7print the maintainer's name if known, else the author's)z
contact-emailNz@print the maintainer's email address if known, else the author's)�urlNzprint the URL for this package)�licenseNz print the license of the package)�licenceNzalias for --license)�descriptionNzprint the package description)zlong-descriptionNz"print the long package description)�	platformsNzprint the list of platforms)�classifiersNzprint the list of classifiers)�keywordsNzprint the list of keywords)�providesNz+print the list of packages/modules provided)�requiresNz+print the list of packages/modules required)�	obsoletesNz0print the list of packages/modules made obsoletecCsg|]}t|d��qS)r�r)�.0�xrrr�
<listcomp>�szDistribution.<listcomp>rrNcCs\d|_d|_d|_|jD]}t||d�qt�|_|jjD] }d|}t||t|j|��q:i|_	d|_
d|_d|_i|_
g|_d|_i|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_i|_i|_|�r|�d�}|dk	�r8|d=|��D]4\}}|� |�}|��D]\}	}
d|
f||	<�q�qd|k�r~|d|d	<|d=d
}t!dk	�rnt!�"|�nt#j$�%|d�|��D]�\}}
t&|jd|��r�t|jd|�|
�nNt&|j|��r�t|j||
�n0t&||��r�t|||
�nd
t'|�}t!�"|��q�d|_(|jdk	�rP|jD].}
|
�)d��s6�qP|
dk�r d|_(�qP�q |�*�dS)a0Construct a new Distribution instance: initialize all the
        attributes of a Distribution, and then use 'attrs' (a dictionary
        mapping attribute names to values) to assign some of those
        attributes their "real" values.  (Any attributes not mentioned in
        'attrs' will be assigned to some null value: 0, None, an empty list
        or dictionary, etc.)  Most importantly, initialize the
        'command_obj' attribute to the empty dictionary; this will be
        filled in with real command objects by 'parse_command_line()'.
        rr�get_N��optionszsetup scriptr+r*z:'licence' distribution option is deprecated; use 'license'�
Zset_zUnknown distribution option: %sT�-z
--no-user-cfgF)+r�dry_runr�display_option_names�setattr�DistributionMetadata�metadata�_METHOD_BASENAMES�getattr�cmdclass�command_packages�script_name�script_args�command_optionsZ
dist_files�packagesZpackage_dataZpackage_dir�
py_modules�	libraries�headers�ext_modulesZext_packageZinclude_dirsZ
extra_path�scripts�
data_filesZpassword�command_obj�have_run�get�items�get_option_dict�warnings�warn�sys�stderr�write�hasattr�repr�
want_user_cfg�
startswith�finalize_options)�self�attrs�attr�basenameZmethod_namer9�commandZcmd_options�opt_dict�opt�valr�key�argrrr�__init__�s~








zDistribution.__init__cCs&|j�|�}|dkr"i}|j|<|S)z�Get the option dictionary for a given command.  If that
        command's option dictionary hasn't been created yet, then create it
        and return the new dictionary; otherwise, return the existing
        option dictionary.
        N)rGrQ)r^rb�dictrrrrS&szDistribution.get_option_dictr8c	Cs�ddlm}|dkr"t|j���}|dk	r@|�||�|d}|sV|�|d�dS|D]h}|j�|�}|dkr�|�|d|�qZ|�|d|�||�}|�d�D]}|�|d|�q�qZdS)Nr)�pformatz  zno commands known yetzno option dict for '%s' commandzoption dict for '%s' command:r:)Zpprintrj�sortedrG�keys�announcerQ�split)	r^�header�commands�indentrjZcmd_namerc�out�linerrr�dump_option_dicts1s*��zDistribution.dump_option_dictscCs�g}t�tj�tjdj�}tj�|d�}tj�|�rB|�	|�tj
dkrRd}nd}|jr�tj�tj�d�|�}tj�|�r�|�	|�d}tj�|�r�|�	|�t
r�|�dd	�|��|S)
a�Find as many configuration files as should be processed for this
        platform, and return a list of filenames in the order in which they
        should be parsed.  The filenames returned are guaranteed to exist
        (modulo nasty race conditions).

        There are three possible config files: distutils.cfg in the
        Distutils installation directory (ie. where the top-level
        Distutils __inst__.py file lives), a file in the user's home
        directory named .pydistutils.cfg on Unix and pydistutils.cfg
        on Windows/Mac; and setup.cfg in the current directory.

        The file in the user's home directory can be disabled with the
        --no-user-cfg option.
        �	distutilsz
distutils.cfg�posixz.pydistutils.cfgzpydistutils.cfg�~z	setup.cfgzusing config files: %sz, )r�os�path�dirnamerV�modules�__file__�join�isfile�appendr!r[�
expanduserrrm)r^�filesZsys_dirZsys_fileZ
user_filenameZ	user_fileZ
local_filerrr�find_config_filesMs&



zDistribution.find_config_filesc
Cs�ddlm}tjtjkr8ddddddd	d
ddd
ddg
}ng}t|�}|dkrT|��}trb|�d�|�}|D]�}tr�|�d|�|�	|�|�
�D]V}|�|�}|�|�}|D]8}	|	dkr�|	|kr�|�
||	�}
|	�dd�}	||
f||	<q�q�|��qld|jk�r�|jd��D]�\}	\}}
|j�
|	�}zF|�rDt||t|
��n(|	dk�r`t||	t|
��nt||	|
�Wn,tk
�r�}
zt|
��W5d}
~
XYnX�qdS)Nr)�ConfigParserzinstall-basezinstall-platbasezinstall-libzinstall-platlibzinstall-purelibzinstall-headerszinstall-scriptszinstall-data�prefixzexec-prefix�home�user�rootz"Distribution.parse_config_files():z  reading %srr;�_�global)rr<)Zconfigparserr�rVr��base_prefix�	frozensetr�rrm�readZsectionsr9rSrQ�replacerhrGrR�negative_optr>r�
ValueError�DistutilsOptionError)r^�	filenamesr�Zignore_options�parser�filenameZsectionr9rcrdre�src�aliasrrrr�parse_config_files}s^�





zDistribution.parse_config_filescCs�|��}g|_t||j�}|�|j�|�ddi�|j|j|d�}|�	�}t
�|j�|�
|�rhdS|r�|�||�}|dkrhdSqh|jr�|j|t|j�dk|jd�dS|js�td��dS)	a�Parse the setup script's command line, taken from the
        'script_args' instance attribute (which defaults to 'sys.argv[1:]'
        -- see 'setup()' in core.py).  This list is first processed for
        "global options" -- options that set attributes of the Distribution
        instance.  Then, it is alternately scanned for Distutils commands
        and options for that command.  Each new command terminates the
        options for the previous command.  The allowed options for a
        command are determined by the 'user_options' attribute of the
        command class -- thus, we have to be able to load command classes
        in order to parse the command line.  Any error in that 'options'
        attribute raises DistutilsGetoptError; any error on the
        command-line raises DistutilsArgError.  If no Distutils commands
        were found on the command line, raises DistutilsArgError.  Return
        true if command-line was successfully parsed and we should carry
        on with executing commands; false if no errors but we shouldn't
        execute commands (currently, this only happens if user asks for
        help).
        r+r*)�args�objectNr��display_optionsrpzno commands suppliedT)�_get_toplevel_optionsrprr��set_negative_aliasesr�Zset_aliases�getoptrFZget_option_orderr
Z
set_verbosityr�handle_display_options�_parse_command_optsr�
_show_help�len�DistutilsArgError)r^Ztoplevel_optionsr�r��option_orderrrr�parse_command_line�s.	
�zDistribution.parse_command_linecCs|jdgS)z�Return the non-display options recognized at the top level.

        This includes options that are recognized *only* at the top
        level as well as options recognized for commands.
        )zcommand-packages=Nz0list of packages that provide distutils commands)�global_options�r^rrrr��s�z"Distribution._get_toplevel_optionsc
Cs�ddlm}|d}t�|�s*td|��|j�|�z|�|�}Wn*tk
rn}zt	|��W5d}~XYnXt
||�s�td|��t|d�r�t
|jt�s�d}t||��|j}t|d�r�|��}|�|j�t|d	�r�t
|jt�r�t|j�}ng}|�|j|j|�|�|�|�|d
d��\}}	t|	d��rV|	j�rV|j|d|gd�dSt|d	��r�t
|jt��r�d}
|jD]F\}}}
}t|	|�|���rzd
}
t|��r�|�ntd
||f���qz|
�r�dS|�|�}t|	���D]\}}d|f||<�q�|S)a�Parse the command-line options for a single command.
        'parser' must be a FancyGetopt instance; 'args' must be the list
        of arguments, starting with the current command (whose options
        we are about to parse).  Returns a new version of 'args' with
        the next command at the front of the list; will be the empty
        list if there are no more commands on the command line.  Returns
        None if the user asked for help on this command.
        r��Commandzinvalid command name '%s'Nz&command class %s must subclass Command�user_optionszIcommand class %s must provide 'user_options' attribute (a list of tuples)r��help_optionsrrr�zYinvalid help function %r for help option '%s': must be a callable object (function, etc.)zcommand line) �
distutils.cmdr��
command_re�match�
SystemExitrpr�get_command_class�DistutilsModuleErrorr��
issubclassZDistutilsClassErrorrYr
r�rr��copy�updater��fix_help_options�set_option_tabler�r�r�rr�Z
get_attr_name�callablerS�varsrR)r^r�r�r�rbZ	cmd_classrr�r�ZoptsZhelp_option_foundZhelp_optionZshortZdesc�funcrcr!rrrrr�sr


�

�


���

�
��
z Distribution._parse_command_optscCsPdD]F}t|j|�}|dkrqt|t�rdd�|�d�D�}t|j||�qdS)z�Set final values for all the options on the Distribution
        instance, analogous to the .finalize_options() method of Command
        objects.
        �r/r-NcSsg|]}|���qSr��strip)r4Zelmrrrr6jsz1Distribution.finalize_options.<locals>.<listcomp>�,)rBr@r
rrnr>)r^r`rrrrr]`s
zDistribution.finalize_optionsrc
Csddlm}ddlm}|rR|r*|��}n|j}|�|�|�|jd�t	d�|rt|�|j
�|�d�t	d�|jD]z}t|t
�r�t||�r�|}	n
|�|�}	t|	d�r�t|	jt�r�|�|	jt|	j��n|�|	j�|�d|	j�t	d�qzt	||j��d	S)
abShow help for the setup script command-line in the form of
        several lists of command-line options.  'parser' should be a
        FancyGetopt instance; do not expect it to be returned in the
        same state, as its option table will be reset to make it
        generate the correct help text.

        If 'global_options' is true, lists the global options:
        --verbose, --dry-run, etc.  If 'display_options' is true, lists
        the "display-only" options: --name, --version, etc.  Finally,
        lists per-command help for every command name or command class
        in 'commands'.
        r��	gen_usager�z
Global options:r8zKInformation display options (just display information, ignore any commands)r�zOptions for '%s' command:N)�distutils.corer�r�r�r�r�r�Z
print_help�common_usage�printr�rpr
rr�r�rYr�rr�r�rrE)
r^r�r�r�rpr�r�r9rb�klassrrrr�ms:

�



��
zDistribution._show_helpc	Cs�ddlm}|jr4|��td�t||j��dSd}i}|jD]}d||d<qB|D]l\}}|rX|�|�rXt|�}t	|j
d|��}|dkr�td�|��n |dkr�td	�|��nt|�d}qX|S)
z�If there were any non-global "display-only" options
        (--help-commands or the metadata display options) on the command
        line, display the requested info and return true; else return
        false.
        rr�r8rr7r�r�)r.r0r1r2r:)r�r�Z
help_commands�print_commandsr�rEr�rQrrBr@r})	r^r�r�Zany_display_optionsZis_display_option�optionrdrerrrrr��s*
z#Distribution.handle_display_optionsc	Csjt|d�|D]T}|j�|�}|s.|�|�}z
|j}Wntk
rPd}YnXtd|||f�qdS)zZPrint a subset of the list of all commands -- used by
        'print_commands()'.
        �:�(no description available)z
  %-*s  %sN)r�rCrQr�r,�AttributeError)r^rpro�
max_length�cmdr�r,rrr�print_command_list�s


zDistribution.print_command_listcCs�ddl}|jj}i}|D]}d||<qg}|j��D]}|�|�s4|�|�q4d}||D]}t|�|krZt|�}qZ|�|d|�|r�t	�|�|d|�dS)anPrint out a help message listing all available commands with a
        description of each.  The list is divided into "standard commands"
        (listed in distutils.command.__all__) and "extra commands"
        (mentioned in self.cmdclass, but not a standard command).  The
        descriptions come from the command class attribute
        'description'.
        rNrzStandard commandszExtra commands)
�distutils.commandrb�__all__rCrlrQrr�r�r�)r^ru�std_commands�is_stdr��extra_commandsr�rrrr��s.


��zDistribution.print_commandsc		Cs�ddl}|jj}i}|D]}d||<qg}|j��D]}|�|�s4|�|�q4g}||D]P}|j�|�}|sx|�|�}z
|j}Wnt	k
r�d}YnX|�||f�qZ|S)a>Get a list of (command, description) tuples.
        The list is divided into "standard commands" (listed in
        distutils.command.__all__) and "extra commands" (mentioned in
        self.cmdclass, but not a standard command).  The descriptions come
        from the command class attribute 'description'.
        rNrr�)
r�rbr�rCrlrQrr�r,r�)	r^rur�r�r�r��rvr�r,rrr�get_command_list�s(	




zDistribution.get_command_listcCsN|j}t|t�sJ|dkrd}dd�|�d�D�}d|krD|�dd�||_|S)z9Return a list of packages from which commands are loaded.Nr8cSsg|]}|dkr|���qS)r8r�)r4Zpkgrrrr6!sz5Distribution.get_command_packages.<locals>.<listcomp>r�zdistutils.commandr)rDr
rrn�insert)r^Zpkgsrrr�get_command_packagess
z!Distribution.get_command_packagesc	Cs�|j�|�}|r|S|��D]�}d||f}|}zt|�tj|}Wntk
r^YqYnXzt||�}Wn&tk
r�t	d|||f��YnX||j|<|St	d|��dS)aoReturn the class that implements the Distutils command named by
        'command'.  First we check the 'cmdclass' dictionary; if the
        command is mentioned there, we fetch the class object from the
        dictionary and return it.  Otherwise we load the command module
        ("distutils.command." + command) and fetch the command class from
        the module.  The loaded class is also stored in 'cmdclass'
        to speed future calls to 'get_command_class()'.

        Raises DistutilsModuleError if the expected module could not be
        found, or if that module does not define the expected class.
        z%s.%sz3invalid command '%s' (no class '%s' in module '%s')zinvalid command '%s'N)
rCrQr��
__import__rVr{�ImportErrorrBr�r�)r^rbr�ZpkgnameZmodule_nameZ
klass_name�modulerrrr�'s,
��

zDistribution.get_command_classcCsl|j�|�}|sh|rhtr&|�d|�|�|�}||�}|j|<d|j|<|j�|�}|rh|�||�|S)aReturn the command object for 'command'.  Normally this object
        is cached on a previous call to 'get_command_obj()'; if no command
        object for 'command' is in the cache, then we either create and
        return it (if 'create' is true) or return None.
        z<Distribution.get_command_obj(): creating '%s' command objectr)rOrQrrmr�rPrG�_set_command_options)r^rbZcreate�cmd_objr�r9rrr�get_command_objMs�

zDistribution.get_command_objcCs\|��}|dkr|�|�}tr,|�d|�|��D�] \}\}}trZ|�d|||f�zdd�|jD�}Wntk
r�g}YnXz
|j}Wntk
r�i}YnXz|t|t	�}	||kr�|	r�t
|||t|��nJ||kr�|	r�t
||t|��n,t||��rt
|||�nt
d|||f��Wq4tk
�rT}
zt
|
��W5d}
~
XYq4Xq4dS)aySet the options for 'command_obj' from 'option_dict'.  Basically
        this means copying elements of a dictionary ('option_dict') to
        attributes of an instance ('command').

        'command_obj' must be a Command instance.  If 'option_dict' is not
        supplied, uses the standard option dictionary for this command
        (from 'self.command_options').
        Nz#  setting options for '%s' command:z    %s = %s (from %s)cSsg|]}t|��qSrr3)r4�orrrr6|s�z5Distribution._set_command_options.<locals>.<listcomp>z1error in %s: command '%s' has no such option '%s')�get_command_namerSrrmrRZboolean_optionsr�r�r
rr>rrYr�r�)r^rOZoption_dict�command_namer��sourcerZ	bool_optsZneg_optZ	is_stringrrrrr�hsF	

��




��z!Distribution._set_command_optionsrcCs|ddlm}t||�s&|}|�|�}n|��}|js8|S|��d|_d|j|<|�|�|rx|�	�D]}|�
||�qf|S)a�Reinitializes a command to the state it was in when first
        returned by 'get_command_obj()': ie., initialized but not yet
        finalized.  This provides the opportunity to sneak option
        values in programmatically, overriding or supplementing
        user-supplied values from the config files and command line.
        You'll have to re-finalize the command object (by calling
        'finalize_options()' or 'ensure_finalized()') before using it for
        real.

        'command' should be a command name (string) or command object.  If
        'reinit_subcommands' is true, also reinitializes the command's
        sub-commands, as declared by the 'sub_commands' class attribute (if
        it has one).  See the "install" command for an example.  Only
        reinitializes the sub-commands that actually matter, ie. those
        whose test predicates return true.

        Returns the reinitialized command object.
        rr�)r�r�r
r�r�Z	finalizedZinitialize_optionsrPr�Zget_sub_commands�reinitialize_command)r^rbZreinit_subcommandsr�r��subrrrr��s


z!Distribution.reinitialize_commandcCst�||�dS�Nr	)r^r�levelrrrrm�szDistribution.announcecCs|jD]}|�|�qdS)z�Run each command that was seen on the setup script command line.
        Uses the list of commands found and cache of command objects
        created by 'get_command_obj()'.
        N)rp�run_command)r^r�rrr�run_commands�s
zDistribution.run_commandscCsD|j�|�rdSt�d|�|�|�}|��|��d|j|<dS)a�Do whatever it takes to run a command (including nothing at all,
        if the command has already been run).  Specifically: if we have
        already created and run the command named by 'command', return
        silently without doing anything.  If the command named by 'command'
        doesn't even have a command object yet, create one.  Then invoke
        'run()' on that command object (or an existing one).
        Nz
running %sr)rPrQr
�infor�Zensure_finalized�run)r^rbr�rrrr��s	
zDistribution.run_commandcCst|jp|jpg�dkS�Nr)r�rHrIr�rrr�has_pure_modules�szDistribution.has_pure_modulescCs|jot|j�dkSr�)rLr�r�rrr�has_ext_modules�szDistribution.has_ext_modulescCs|jot|j�dkSr�)rJr�r�rrr�has_c_libraries�szDistribution.has_c_librariescCs|��p|��Sr�)r�r�r�rrr�has_modules�szDistribution.has_modulescCs|jot|j�dkSr�)rKr�r�rrr�has_headers�szDistribution.has_headerscCs|jot|j�dkSr�)rMr�r�rrr�has_scripts�szDistribution.has_scriptscCs|jot|j�dkSr�)rNr�r�rrr�has_data_files�szDistribution.has_data_filescCs|��o|��o|��Sr�)r�r�r�r�rrr�is_pure�s
��zDistribution.is_pure)N)NNr8)N)r)N)r))r�
__module__�__qualname__�__doc__r�r�r�r=r�rhrSrtr�r�r�r�r�r]r�r�r�r�r�r�r�r�r�r�r
�INFOrmr�r�r�r�r�r�r�r�r�r�rrrrr,s��	�,

0
:C[
�
2(!"&

,
)
rc@seZdZdZdZdBdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZeZd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dS)Cr?z]Dummy class to hold the distribution meta-data: name, version,
    author, and so forth.
    )r!r"r%�author_emailr'�maintainer_emailr)r*r,�long_descriptionr/r-r$r(Z
contact_emailr.�download_urlr0r1r2NcCs�|dk	r|�t|��nfd|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_dSr�)�
read_pkg_file�openr!r"r%r�r'r�r)r*r,r�r/r-r.r�r0r1r2)r^ryrrrrh
s&zDistributionMetadata.__init__cst|���fdd�}�fdd�}�d}|d�|_|d�|_|d�|_|d	�|_d
|_|d�|_d
|_|d�|_|d
�|_	d�kr�|d�|_
nd
|_
|d�|_|d�|_d�kr�|d��d�|_
|d�|_|d�|_|dkr�|d�|_|d�|_|d�|_nd
|_d
|_d
|_d
S)z-Reads the metadata values from a file object.cs�|}|dkrdS|S�NZUNKNOWNr)r!r�rrr�_read_field(sz7DistributionMetadata.read_pkg_file.<locals>._read_fieldcs��|d�}|gkrdS|Sr�)Zget_all)r!�valuesr�rr�
_read_list.sz6DistributionMetadata.read_pkg_file.<locals>._read_listzmetadata-versionr!r"Zsummaryr%Nr&z	home-pager*zdownload-urlr,r/r��platformZ
classifier�1.1r1r0r2)rr!r"r,r%r'r�r�r)r*r�r�rnr/r-r.r1r0r2)r^�filer�r�Zmetadata_versionrr�rr�$s:












z"DistributionMetadata.read_pkg_filec	Cs2ttj�|d�ddd��}|�|�W5QRXdS)z7Write the PKG-INFO file into the release tree.
        zPKG-INFO�wzUTF-8)�encodingN)r�rxryr}�write_pkg_file)r^Zbase_dirZpkg_inforrr�write_pkg_infoXs
�z#DistributionMetadata.write_pkg_infocCsbd}|js"|js"|js"|js"|jr&d}|�d|�|�d|���|�d|���|�d|���|�d|�	��|�d|�
��|�d	|���|�d
|���|jr�|�d|j�t
|���}|�d|�d
�|���}|�r|�d|�|�|d|���|�|d|���|�|d|���|�|d|���|�|d|���dS)z9Write the PKG-INFO format data to a file object.
        z1.0r�zMetadata-Version: %s
z	Name: %s
zVersion: %s
zSummary: %s
zHome-page: %s
zAuthor: %s
zAuthor-email: %s
zLicense: %s
zDownload-URL: %s
zDescription: %s
r�z
Keywords: %s
ZPlatformZ
ClassifierZRequiresZProvidesZ	ObsoletesN)r0r1r2r.r�rX�get_name�get_version�get_description�get_url�get_contact�get_contact_email�get_licenser�get_long_descriptionr}�get_keywords�_write_list�
get_platforms�get_classifiers�get_requires�get_provides�
get_obsoletes)r^rr"Z	long_descr/rrrr_s6��z#DistributionMetadata.write_pkg_filecCs |D]}|�d||f�qdS)Nz%s: %s
)rX)r^rr!r�rrrrr�sz DistributionMetadata._write_listcCs
|jpdSr�)r!r�rrrr�szDistributionMetadata.get_namecCs
|jpdS)Nz0.0.0)r"r�rrrr�sz DistributionMetadata.get_versioncCsd|��|��fS)Nz%s-%s)rrr�rrr�get_fullname�sz!DistributionMetadata.get_fullnamecCs
|jpdSr�)r%r�rrr�
get_author�szDistributionMetadata.get_authorcCs
|jpdSr�)r�r�rrr�get_author_email�sz%DistributionMetadata.get_author_emailcCs
|jpdSr�)r'r�rrr�get_maintainer�sz#DistributionMetadata.get_maintainercCs
|jpdSr�)r�r�rrr�get_maintainer_email�sz)DistributionMetadata.get_maintainer_emailcCs|jp|jpdSr�)r'r%r�rrrr	�sz DistributionMetadata.get_contactcCs|jp|jpdSr�)r�r�r�rrrr
�sz&DistributionMetadata.get_contact_emailcCs
|jpdSr�)r)r�rrrr�szDistributionMetadata.get_urlcCs
|jpdSr�)r*r�rrrr�sz DistributionMetadata.get_licensecCs
|jpdSr�)r,r�rrrr�sz$DistributionMetadata.get_descriptioncCs
|jpdSr�)r�r�rrrr�sz)DistributionMetadata.get_long_descriptioncCs
|jpgSr�)r/r�rrrr
�sz!DistributionMetadata.get_keywordscCst|d�|_dS)Nr/)rr/�r^rrrr�set_keywords�sz!DistributionMetadata.set_keywordscCs|jp
dgSr�)r-r�rrrr�sz"DistributionMetadata.get_platformscCst|d�|_dS)Nr-)rr-rrrr�
set_platforms�sz"DistributionMetadata.set_platformscCs
|jpgSr�)r.r�rrrr�sz$DistributionMetadata.get_classifierscCst|d�|_dS)Nr.)rr.rrrr�set_classifiers�sz$DistributionMetadata.set_classifierscCs
|jpdSr�)r�r�rrr�get_download_url�sz%DistributionMetadata.get_download_urlcCs
|jpgSr�)r1r�rrrr�sz!DistributionMetadata.get_requirescCs,ddl}|D]}|j�|�qt|�|_dSr�)�distutils.versionpredicate�versionpredicate�VersionPredicaterr1�r^rrurrrr�set_requires�sz!DistributionMetadata.set_requirescCs
|jpgSr�)r0r�rrrr�sz!DistributionMetadata.get_providescCs6dd�|D�}|D]}ddl}|j�|�q||_dS)NcSsg|]}|���qSrr�)r4rrrrr6�sz5DistributionMetadata.set_provides.<locals>.<listcomp>r)rrZsplit_provisionr0)r^rrrurrr�set_provides�s
z!DistributionMetadata.set_providescCs
|jpgSr�)r2r�rrrr�sz"DistributionMetadata.get_obsoletescCs,ddl}|D]}|j�|�qt|�|_dSr�)rrr rr2r!rrr�
set_obsoletes�sz"DistributionMetadata.set_obsoletes)N)%rr�r�r�rArhr�rrrrrrrrrrr	r
rrZget_licencerrr
rrrrrrrr"rr#rr$rrrrr?�sD	
4"r?cCs$g}|D]}|�|dd��q|S)zConvert a 4-tuple 'help_options' list as found in various command
    classes to the 3-tuple form required by FancyGetopt.
    r�)r)r9Znew_optionsZ
help_tuplerrrr��sr�)r�rVrx�reZemailrrTr�Zdistutils.errorsZdistutils.fancy_getoptrrZdistutils.utilrrrrur
Zdistutils.debugr�compiler�rrr?r�rrrr�<module>s4

ZcPK22�\4#�Z��dir_util.cpython-38.pycnu�[���U

e5db�@spdZddlZddlZddlmZmZddlmZiaddd�Z	dd	d
�Z
ddd�Zd
d�Zddd�Z
dd�ZdS)zWdistutils.dir_util

Utility functions for manipulating directories and directory trees.�N)�DistutilsFileError�DistutilsInternalError)�log��cCsft|t�std|f��tj�|�}g}tj�|�s<|dkr@|St�tj�	|��rV|Stj�
|�\}}|g}|r�|r�tj�|�s�tj�
|�\}}|�d|�ql|D]�}tj�||�}tj�	|�}	t�|	�r�q�|dkr�t
�d|�|�sXzt�||�WnVtk
�rL}
z6|
jtjk�r&tj�|��s<td||
jdf��W5d}
~
XYnX|�|�dt|	<q�|S)	a�Create a directory and any missing ancestor directories.

    If the directory already exists (or if 'name' is the empty string, which
    means the current directory, which of course exists), then do nothing.
    Raise DistutilsFileError if unable to create some directory along the way
    (eg. some sub-path exists, but is a file rather than a directory).
    If 'verbose' is true, print a one-line summary of each mkdir to stdout.
    Return the list of directories actually created.
    z(mkpath: 'name' must be a string (got %r)�rrzcreating %szcould not create '%s': %s���N)�
isinstance�strr�os�path�normpath�isdir�
_path_created�get�abspath�split�insert�joinr�info�mkdir�OSError�errnoZEEXISTr�args�append)�name�mode�verbose�dry_runZcreated_dirs�head�tailZtails�dZabs_head�exc�r#�*/usr/lib64/python3.8/distutils/dir_util.py�mkpathsB
�
�

r%c	CsNt�}|D] }|�tj�|tj�|���q
t|�D]}t||||d�q4dS)a�Create all the empty directories under 'base_dir' needed to put 'files'
    there.

    'base_dir' is just the name of a directory which doesn't necessarily
    exist yet; 'files' is a list of filenames to be interpreted relative to
    'base_dir'.  'base_dir' + the directory portion of every file in 'files'
    will be created if it doesn't already exist.  'mode', 'verbose' and
    'dry_run' flags are as for 'mkpath()'.
    �rrN)�set�addrrr�dirname�sortedr%)Zbase_dir�filesrrrZneed_dir�file�dirr#r#r$�create_treePs
r.c
Cs^ddlm}|s(tj�|�s(td|��zt�|�}	Wn>tk
rt}
z |rRg}	ntd||
jf��W5d}
~
XYnX|s�t	||d�g}|	D]�}tj�
||�}
tj�
||�}|�d�r�q�|�r
tj�|
��r
t�
|
�}|dkr�t�d	||�|s�t�||�|�|�q�tj�|
��r8|�t|
|||||||d
��q�||
||||||d
�|�|�q�|S)aCopy an entire directory tree 'src' to a new location 'dst'.

    Both 'src' and 'dst' must be directory names.  If 'src' is not a
    directory, raise DistutilsFileError.  If 'dst' does not exist, it is
    created with 'mkpath()'.  The end result of the copy is that every
    file in 'src' is copied to 'dst', and directories under 'src' are
    recursively copied to 'dst'.  Return the list of files that were
    copied or might have been copied, using their output name.  The
    return value is unaffected by 'update' or 'dry_run': it is simply
    the list of all files under 'src', with the names changed to be
    under 'dst'.

    'preserve_mode' and 'preserve_times' are the same as for
    'copy_file'; note that they only apply to regular files, not to
    directories.  If 'preserve_symlinks' is true, symlinks will be
    copied as symlinks (on platforms that support them!); otherwise
    (the default), the destination of the symlink will be copied.
    'update' and 'verbose' are the same as for 'copy_file'.
    r)�	copy_filez&cannot copy tree '%s': not a directoryzerror listing files in '%s': %sN)rz.nfsrzlinking %s -> %sr&)Zdistutils.file_utilr/rrrr�listdirr�strerrorr%r�
startswith�islink�readlinkrr�symlinkr�extend�	copy_tree)�srcZdstZ
preserve_modeZpreserve_timesZpreserve_symlinks�updaterrr/�names�eZoutputs�nZsrc_nameZdst_nameZ	link_destr#r#r$r7cs\��

���r7cCsft�|�D]F}tj�||�}tj�|�r@tj�|�s@t||�q
|�tj|f�q
|�tj	|f�dS)zHelper for remove_tree().N)
rr0rrrr3�_build_cmdtupler�remove�rmdir)r�	cmdtuples�fZreal_fr#r#r$r=�sr=cCs�|dkrt�d|�|rdSg}t||�|D]h}z2|d|d�tj�|d�}|tkrbt|=Wq.tk
r�}zt�d||�W5d}~XYq.Xq.dS)z�Recursively remove an entire directory tree.

    Any errors are ignored (apart from being reported to stdout if 'verbose'
    is true).
    rz'removing '%s' (and everything under it)Nrzerror removing %s: %s)	rrr=rrrrr�warn)Z	directoryrrr@�cmdrr"r#r#r$�remove_tree�s

rDcCs6tj�|�\}}|dd�tjkr2||dd�}|S)z�Take the full path 'path', and make it a relative path.

    This is useful to make 'path' the second argument to os.path.join().
    rrN)rr�
splitdrive�sep)rZdriver#r#r$�ensure_relative�srG)rrr)rrr)rrrrrr)rr)�__doc__rrZdistutils.errorsrrZ	distutilsrrr%r.r7r=rDrGr#r#r#r$�<module>s 
?
�
E

PK22�\�uU]]!bcppcompiler.cpython-38.opt-2.pycnu�[���U

e5dW:�@stddlZddlmZmZmZmZmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZddlmZGdd�de	�ZdS)	�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError�UnknownFileError)�	CCompiler�gen_preprocess_options�gen_lib_options)�
write_file)�newer)�logc
@s�eZdZdZiZdgZdddgZeeZdZdZ	dZ
d	ZZd
Z
ddd
�Zddd�Zddd�Zddd�Zd dd�Zd!dd�Zd"dd�ZdS)#�BCPPCompilerZbcppz.cz.ccz.cppz.cxxz.objz.libz.dllz%s%sz.exercCs�t�||||�d|_d|_d|_d|_ddddg|_ddddg|_d	d
ddg|_d	d
ddg|_	g|_
d
ddg|_d
dddg|_dS)
Nz	bcc32.exezilink32.exeztlib.exez/tWMz/O2z/qz/g0z/Odz/Tpdz/Gnz/xz/r)
r�__init__�cc�linker�libZpreprocess_options�compile_options�compile_options_debug�ldflags_shared�ldflags_shared_debugZldflags_static�ldflags_exe�ldflags_exe_debug)�self�verboseZdry_run�force�r�./usr/lib64/python3.8/distutils/bcppcompiler.pyr5szBCPPCompiler.__init__Nc	Cs�|�||||||�\}}	}}
}|p$g}|�d�|rB|�|j�n|�|j�|	D�]<}
z||
\}}Wntk
r�YqRYnXtj�|�}tj�|
�}
|�	tj�
|
��|dkr�qR|dk�rz|�dd|
|g�WqRtk
�r}zt
|��W5d}~XYqRXqR||jk�rd}n||jk�r*d}nd}d|
}z,|�|jg||
||g||g�WqRtk
�r�}zt
|��W5d}~XYqRXqR|	S)	Nz-c�.res�.rcZbrcc32z-fo�z-P�-o)Z_setup_compile�append�extendrr�KeyError�os�path�normpath�mkpath�dirname�spawnrr�
_c_extensions�_cpp_extensionsr)rZsources�
output_dir�macros�include_dirs�debug�
extra_preargs�extra_postargsZdepends�objects�pp_optsZbuildZcompile_opts�obj�src�ext�msgZ	input_optZ
output_optrrr�compileQsV��



���
zBCPPCompiler.compilec	
Cs�|�||�\}}|j||d�}|�||�r~|dg|}|r:z|�|jg|�Wq�tk
rz}zt|��W5d}~XYq�Xnt�d|�dS)N)r-z/u�skipping %s (up-to-date))	�_fix_object_args�library_filename�
_need_linkr*rrrr
r0)	rr3Zoutput_libnamer-r0�target_lang�output_filenameZlib_argsr8rrr�create_static_lib�s�zBCPPCompiler.create_static_libc 
Cs�|�||�\}}|�|||�\}}}|r8t�dt|��|dk	rNtj�||�}|�||��r�|t	j
kr�d}|	r~|jdd�}q�|jdd�}n&d}|	r�|j
dd�}n|jdd�}|dkr�d}n�tj�|�\}}tj�|�\}}tj�|d�}tj�|d|�}dg}|�pgD]}|�d||f��q|�t||fd	|�ttjj|�}|g}g}|D]>}tj�tj�|��\}}|d
k�r�|�|�n
|�|��q`|D]}|�dtj�|���q�|�d�|�|�|�d
|g�|�d�|D]4}|�|||	�}|dk�r|�|�n
|�|��q�|�d�|�d�|�d
|g�|�d
�|�|�|
�rp|
|dd�<|�r�|�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz7I don't know what to do with 'runtime_library_dirs': %sZc0w32Zc0d32r rz%s.defZEXPORTSz  %s=_%sz
writing %srz/L%sz/L.�,z,,Zimport32Zcw32mtr:) r;Z
_fix_lib_argsr
�warn�strr%r&�joinr=rZ
EXECUTABLErrrr�split�splitextr)r"Zexecuter�mapr'�normcaser#�find_library_filer(r*rrrr0) rZtarget_descr3r?r-Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr0r1r2Z
build_tempr>Zstartup_objZld_argsZdef_file�head�tail�modnamer7Ztemp_dir�contentsZsymZobjects2Z	resources�file�base�lr�libfiler8rrr�link�s���
�










zBCPPCompiler.linkc	Csr|r"|d}|d|d||f}n|d|f}|D]:}|D]0}tj�||�|��}tj�|�r:|Sq:q2dS)NZ_dZ_bcpp)r%r&rDr<�exists)	r�dirsrr0ZdlibZ	try_names�dir�namerQrrrrI4s
zBCPPCompiler.find_library_filer cCs�|dkrd}g}|D]�}tj�tj�|��\}}||jddgkrRtd||f��|rbtj�|�}|dkr�|�tj�|||��q|dkr�|�tj�||d��q|�tj�|||j	��q|S)Nr rrz"unknown file type '%s' (from '%s'))
r%r&rFrH�src_extensionsr�basenamer"rD�
obj_extension)rZsource_filenamesZ	strip_dirr-Z	obj_namesZsrc_namerOr7rrr�object_filenamesNs&��zBCPPCompiler.object_filenamesc
Cs�|�d||�\}}}t||�}dg|}	|dk	r>|	�d|�|rN||	dd�<|r\|	�|�|	�|�|js~|dks~t||�r�|r�|�tj�	|��z|�
|	�Wn2tk
r�}
zt|
�t
|
��W5d}
~
XYnXdS)Nz	cpp32.exer!r)Z_fix_compile_argsr	r"r#rrr(r%r&r)r*r�printr)r�sourceZoutput_filer.r/r1r2�_r4Zpp_argsr8rrr�
preprocessis&	�



zBCPPCompiler.preprocess)rrr)NNNrNNN)NrN)
NNNNNrNNNN)r)rr )NNNNN)�__name__�
__module__�__qualname__Z
compiler_typeZexecutablesr+r,rWrYZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionrr9r@rRrIrZr^rrrrrs`
�
�
D�
�


�
�r)r%Zdistutils.errorsrrrrrrZdistutils.ccompilerrr	r
Zdistutils.file_utilrZdistutils.dep_utilrZ	distutilsr
rrrrr�<module>s PK22�\p|t���version.cpython-38.opt-2.pycnu�[���U

e5d90�@s:ddlZGdd�d�ZGdd�de�ZGdd�de�ZdS)�Nc@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�VersionNcCs|r|�|�dS�N��parse��self�vstring�r	�)/usr/lib64/python3.8/distutils/version.py�__init__&szVersion.__init__cCsd|jjt|�fS)Nz	%s ('%s'))�	__class__�__name__�str�rr	r	r
�__repr__*szVersion.__repr__cCs|�|�}|tkr|S|dkS�Nr��_cmp�NotImplemented�r�other�cr	r	r
�__eq__-s
zVersion.__eq__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__lt__3s
zVersion.__lt__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__le__9s
zVersion.__le__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__gt__?s
zVersion.__gt__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__ge__Es
zVersion.__ge__)N)
r
�
__module__�__qualname__rrrrrrrr	r	r	r
rs
rc@s8eZdZe�dejejB�Zdd�Zdd�Z	dd�Z
dS)	�
StrictVersionz)^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$cCs�|j�|�}|std|��|�ddddd�\}}}}}|rTttt|||g��|_nttt||g��d|_|r�|dt|�f|_nd|_dS)	Nzinvalid version number '%s'�����)rr)	�
version_re�match�
ValueError�group�tuple�map�int�version�
prerelease)rrr&�major�minorZpatchr-Zprerelease_numr	r	r
r�s�zStrictVersion.parsecCsb|jddkr*d�tt|jdd���}nd�tt|j��}|jr^||jdt|jd�}|S)Nr!r�.r )r,�joinr*rr-rr	r	r
�__str__�szStrictVersion.__str__cCs�t|t�rt|�}|j|jkr2|j|jkr.dSdS|jsB|jsBdS|jrR|jsRdS|jsb|jrbdS|jr�|jr�|j|jkr~dS|j|jkr�dSdSndS)N���r r)�
isinstancerrr,r-�rrr	r	r
r�s&
zStrictVersion._cmpN)r
rr�re�compile�VERBOSE�ASCIIr%rr2rr	r	r	r
r]s%
�
rc@sDeZdZe�dej�Zd
dd�Zdd�Zdd�Z	d	d
�Z
dd�ZdS)�LooseVersionz(\d+ | [a-z]+ | \.)NcCs|r|�|�dSrrrr	r	r
r.szLooseVersion.__init__c	Cs^||_dd�|j�|�D�}t|�D].\}}zt|�||<Wq$tk
rPYq$Xq$||_dS)NcSsg|]}|r|dkr|�qS)r0r	)�.0�xr	r	r
�
<listcomp>8s�z&LooseVersion.parse.<locals>.<listcomp>)r�component_re�split�	enumerater+r'r,)rrZ
components�i�objr	r	r
r3szLooseVersion.parsecCs|jSr)rrr	r	r
r2CszLooseVersion.__str__cCsdt|�S)NzLooseVersion ('%s'))rrr	r	r
rGszLooseVersion.__repr__cCsFt|t�rt|�}|j|jkr"dS|j|jkr2dS|j|jkrBdSdS)Nrr3r )r4rr:r,r5r	r	r
rKs
zLooseVersion._cmp)N)r
rrr6r7r8r>rrr2rrr	r	r	r
r:s!
r:)r6rrr:r	r	r	r
�<module>s>/PK22�\O�

extension.cpython-38.opt-1.pycnu�[���U

e5d)�@s.dZddlZddlZGdd�d�Zdd�ZdS)zmdistutils.extension

Provides the Extension class, used to describe C/C++ extension
modules in setup scripts.�Nc@s"eZdZdZddd�Zdd�ZdS)�	Extensiona�Just a collection of attributes that describes an extension
    module and everything needed to build it (hopefully in a portable
    way, but there are hooks that let you be as unportable as you need).

    Instance attributes:
      name : string
        the full name of the extension, including any packages -- ie.
        *not* a filename or pathname, but Python dotted name
      sources : [string]
        list of source filenames, relative to the distribution root
        (where the setup script lives), in Unix form (slash-separated)
        for portability.  Source files may be C, C++, SWIG (.i),
        platform-specific resource files, or whatever else is recognized
        by the "build_ext" command as source for a Python extension.
      include_dirs : [string]
        list of directories to search for C/C++ header files (in Unix
        form for portability)
      define_macros : [(name : string, value : string|None)]
        list of macros to define; each macro is defined using a 2-tuple,
        where 'value' is either the string to define it to or None to
        define it without a particular value (equivalent of "#define
        FOO" in source or -DFOO on Unix C compiler command line)
      undef_macros : [string]
        list of macros to undefine explicitly
      library_dirs : [string]
        list of directories to search for C/C++ libraries at link time
      libraries : [string]
        list of library names (not filenames or paths) to link against
      runtime_library_dirs : [string]
        list of directories to search for C/C++ libraries at run time
        (for shared extensions, this is when the extension is loaded)
      extra_objects : [string]
        list of extra files to link with (eg. object files not implied
        by 'sources', static library that must be explicitly specified,
        binary resource files, etc.)
      extra_compile_args : [string]
        any extra platform- and compiler-specific information to use
        when compiling the source files in 'sources'.  For platforms and
        compilers where "command line" makes sense, this is typically a
        list of command-line arguments, but for other platforms it could
        be anything.
      extra_link_args : [string]
        any extra platform- and compiler-specific information to use
        when linking object files together to create the extension (or
        to create a new static Python interpreter).  Similar
        interpretation as for 'extra_compile_args'.
      export_symbols : [string]
        list of symbols to be exported from a shared extension.  Not
        used on all platforms, and not generally necessary for Python
        extensions, which typically export exactly one symbol: "init" +
        extension_name.
      swig_opts : [string]
        any extra options to pass to SWIG if a source file has the .i
        extension.
      depends : [string]
        list of files that the extension depends on
      language : string
        extension language (i.e. "c", "c++", "objc"). Will be detected
        from the source extensions if not provided.
      optional : boolean
        specifies that a build failure in the extension should not abort the
        build process, but simply not install the failing extension.
    NcKst|t�std��t|t�r.tdd�|D��s6td��||_||_|pHg|_|pRg|_|p\g|_	|pfg|_
|ppg|_|pzg|_|	p�g|_
|
p�g|_|p�g|_|p�g|_|
p�g|_|p�g|_||_||_t|�dk�rdd�|D�}d�t|��}d	|}t�|�dS)
Nz'name' must be a stringcss|]}t|t�VqdS)N)�
isinstance�str)�.0�v�r�+/usr/lib64/python3.8/distutils/extension.py�	<genexpr>jsz%Extension.__init__.<locals>.<genexpr>z#'sources' must be a list of stringsrcSsg|]}t|��qSr)�repr)rZoptionrrr�
<listcomp>�sz&Extension.__init__.<locals>.<listcomp>z, zUnknown Extension options: %s)rr�AssertionError�list�all�name�sources�include_dirs�
define_macros�undef_macros�library_dirs�	libraries�runtime_library_dirs�
extra_objects�extra_compile_args�extra_link_args�export_symbols�	swig_opts�depends�language�optional�len�join�sorted�warnings�warn)�selfrrrrrrrrrrrrrrrr�kwZoptions�msgrrr�__init__Vs6

�











zExtension.__init__cCsd|jj|jj|jt|�fS)Nz<%s.%s(%r) at %#x>)�	__class__�
__module__�__qualname__r�id)r$rrr�__repr__�s�zExtension.__repr__)NNNNNNNNNNNNNN)�__name__r)r*�__doc__r'r,rrrrrs"C�
/rcCs�ddlm}m}m}ddlm}ddlm}||�}||dddddd�}�z^g}|�	�}	|	dkrd�q�|�
|	�rpqP|	d|	dkr�d	kr�nn|�d
|	�qP||	|�}	||	�}
|
d}t|g�}d}
|
dd�D�]�}|
dk	r�|
�
|�d}
q�tj�|�d}|dd�}|dd�}|dk�r2|j�
|�q�|d
k�rJ|j�
|�q�|dk�r�|�d�}|dk�rz|j�
|df�n$|j�
|d|�||dd�f�q�|dk�r�|j�
|�q�|dk�r�|j�
|�q�|dk�r�|j�
|�q�|dk�r|j�
|�q�|dk�r|j�
|�q�|dk�r*|j}
q�|dk�r<|j}
q�|dk�rN|j}
q�|dk�rr|j�
|�|�s�|j}
q�|dk�r�|j�
|�q�|�d|�q�|�
|�qPW5|��X|S)z3Reads a Setup file and returns Extension instances.r)�parse_makefile�expand_makefile_vars�_variable_rx)�TextFile)�split_quoted�)Zstrip_commentsZskip_blanksZ
join_linesZ	lstrip_wsZ	rstrip_wsN����*z'%s' lines not handled yet�)z.cz.ccz.cppz.cxxz.c++z.mz.mmz-Iz-D�=z-Uz-Cz-lz-Lz-Rz-rpathz-Xlinkerz
-Xcompilerz-u)z.az.soz.slz.oz.dylibzunrecognized argument '%s')Zdistutils.sysconfigr/r0r1Zdistutils.text_filer2Zdistutils.utilr3�close�readline�matchr#r�append�os�path�splitextrr�findrrrrrrrr)�filenamer/r0r1r2r3�vars�file�
extensions�lineZwords�moduleZextZappend_next_wordZword�suffixZswitch�valueZequalsrrr�read_setup_file�s��
 







�










rI)r.r=r"rrIrrrr�<module>szPK22�\e9-%versionpredicate.cpython-38.opt-1.pycnu�[���U

e5d
�@s�dZddlZddlZddlZe�dej�Ze�d�Ze�d�Z	dd�Z
ejejej
ejejejd�ZGd	d
�d
�Zdadd�ZdS)
zBModule for parsing and testing package version predicate strings.
�Nz'(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)z^\s*\((.*)\)\s*$z%^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$cCs6t�|�}|std|��|��\}}|tj�|�fS)zVParse a single version comparison.

    Return (comparison string, StrictVersion)
    z"bad package restriction syntax: %r)�re_splitComparison�match�
ValueError�groups�	distutils�version�
StrictVersion)�pred�res�compZverStr�r�2/usr/lib64/python3.8/distutils/versionpredicate.py�splitUps

r)�<z<=z==�>z>=z!=c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�VersionPredicatea�Parse and test package version predicates.

    >>> v = VersionPredicate('pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)')

    The `name` attribute provides the full dotted name that is given::

    >>> v.name
    'pyepat.abc'

    The str() of a `VersionPredicate` provides a normalized
    human-readable version of the expression::

    >>> print(v)
    pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)

    The `satisfied_by()` method can be used to determine with a given
    version number is included in the set described by the version
    restrictions::

    >>> v.satisfied_by('1.1')
    True
    >>> v.satisfied_by('1.4')
    True
    >>> v.satisfied_by('1.0')
    False
    >>> v.satisfied_by('4444.4')
    False
    >>> v.satisfied_by('1555.1b3')
    False

    `VersionPredicate` is flexible in accepting extra whitespace::

    >>> v = VersionPredicate(' pat( ==  0.1  )  ')
    >>> v.name
    'pat'
    >>> v.satisfied_by('0.1')
    True
    >>> v.satisfied_by('0.2')
    False

    If any version numbers passed in do not conform to the
    restrictions of `StrictVersion`, a `ValueError` is raised::

    >>> v = VersionPredicate('p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)')
    Traceback (most recent call last):
      ...
    ValueError: invalid version number '1.2zb3'

    It the module or package name given does not conform to what's
    allowed as a legal module or package name, `ValueError` is
    raised::

    >>> v = VersionPredicate('foo-bar')
    Traceback (most recent call last):
      ...
    ValueError: expected parenthesized list: '-bar'

    >>> v = VersionPredicate('foo bar (12.21)')
    Traceback (most recent call last):
      ...
    ValueError: expected parenthesized list: 'bar (12.21)'

    cCs�|��}|std��t�|�}|s.td|��|��\|_}|��}|r�t�|�}|sbtd|��|��d}dd�|�d�D�|_|js�td|��ng|_d	S)
z*Parse a version predicate string.
        zempty package restrictionzbad package name in %rzexpected parenthesized list: %rrcSsg|]}t|��qSr)r)�.0ZaPredrrr
�
<listcomp>tsz-VersionPredicate.__init__.<locals>.<listcomp>�,zempty parenthesized list in %rN)	�stripr�re_validPackagerr�name�re_paren�splitr	)�selfZversionPredicateStrrZparen�strrrr
�__init__`s&

�zVersionPredicate.__init__cCs8|jr.dd�|jD�}|jdd�|�dS|jSdS)NcSs g|]\}}|dt|��qS)� )r)r�cond�verrrr
r}sz,VersionPredicate.__str__.<locals>.<listcomp>z (z, �))r	r�join)r�seqrrr
�__str__{szVersionPredicate.__str__cCs(|jD]\}}t|||�sdSqdS)z�True if version is compatible with all the predicates in self.
        The parameter version must be acceptable to the StrictVersion
        constructor.  It may be either a string or StrictVersion.
        FT)r	�compmap)rrrrrrr
�satisfied_by�szVersionPredicate.satisfied_byN)�__name__�
__module__�__qualname__�__doc__rr#r%rrrr
rs@rcCsdtdkrt�dtj�a|��}t�|�}|s8td|��|�d�pDd}|rVtj	�
|�}|�d�|fS)a9Return the name and optional version number of a provision.

    The version number, if given, will be returned as a `StrictVersion`
    instance, otherwise it will be `None`.

    >>> split_provision('mypkg')
    ('mypkg', None)
    >>> split_provision(' mypkg( 1.2 ) ')
    ('mypkg', StrictVersion ('1.2'))
    Nz=([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$z"illegal provides specification: %r��)�
_provision_rx�re�compile�ASCIIrrr�grouprrr)�value�mrrrr
�split_provision�s�
r3)r)r-Zdistutils.versionr�operatorr.r/rrrr�lt�le�eq�gt�ge�ner$rr,r3rrrr
�<module>s"�

�nPK22�\�{<���archive_util.cpython-38.pycnu�[���U

e5d|!�@sDdZddlZddlmZddlZzddlZWnek
rDdZYnXddlmZddl	m
Z
ddlmZddl
mZzddlmZWnek
r�dZYnXzdd	lmZWnek
r�dZYnXd
d�Zdd
�Zd#dd�Zd$dd�Zedgdfedgdfedgdfedgdfedgdfegdfd�Zdd �Zd%d!d"�ZdS)&zodistutils.archive_util

Utility functions for creating archive files (tarballs, zip files,
that sort of thing).�N)�warn)�DistutilsExecError)�spawn)�mkpath)�log)�getpwnam)�getgrnamcCsNtdks|dkrdSzt|�}Wntk
r8d}YnX|dk	rJ|dSdS)z"Returns a gid, given a group name.N�)r�KeyError��name�result�r�./usr/lib64/python3.8/distutils/archive_util.py�_get_gids
rcCsNtdks|dkrdSzt|�}Wntk
r8d}YnX|dk	rJ|dSdS)z"Returns an uid, given a user name.Nr	)rr
rrrr�_get_uid+s
r�gzipcs.dddddd�}dddd	d
�}|dk	r:||��kr:td��|d
}	|dkrZ|	|�|d�7}	ttj�|	�|d�ddl}
t�	d�t
���t�������fdd�}|s�|
�|	d||�}z|j||d�W5|�
�X|dk�r*tdt�|	||}
tjdk�r||	|
g}n
|d|	g}t||d�|
S|	S)a=Create a (possibly compressed) tar file from all the files under
    'base_dir'.

    'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or
    None.  ("compress" will be deprecated in Python 3.2)

    'owner' and 'group' can be used to define an owner and a group for the
    archive that is being built. If not provided, the current owner and group
    will be used.

    The output tar file will be named 'base_dir' +  ".tar", possibly plus
    the appropriate compression extension (".gz", ".bz2", ".xz" or ".Z").

    Returns the output filename.
    Zgz�bz2�xz�)r�bzip2rN�compressz.gzz.bz2z.xzz.Z)rrrrNzKbad value for 'compress': must be None, 'gzip', 'bzip2', 'xz' or 'compress'z.tarr��dry_runrzCreating tar archivecs,�dk	r�|_�|_�dk	r(�|_�|_|S)N)�gidZgname�uid�uname)Ztarinfo�r�group�ownerrrr�_set_uid_gidasz"make_tarball.<locals>._set_uid_gidzw|%s)�filterz'compress' will be deprecated.Zwin32z-f)�keys�
ValueError�getr�os�path�dirname�tarfiler�inforr�open�close�addr�PendingDeprecationWarning�sys�platformr)�	base_name�base_dirr�verboserrrZtar_compressionZcompress_extZarchive_namer(r �tarZcompressed_name�cmdrrr�make_tarball7sB���
	



r5c
Cs�|d}ttj�|�|d�tdkrp|r.d}nd}ztd|||g|d�Wn tk
rjtd|��YnX�n8t�d||�|�s�ztj	|d	tj
d
�}Wn&tk
r�tj	|d	tjd
�}YnX|��|tj
k�rtj�tj�|d��}|�||�t�d|�t�|�D]�\}}	}
|	D]6}tj�tj�||d��}|�||�t�d|��q|
D]B}tj�tj�||��}tj�|��rV|�||�t�d|��qV�qW5QRX|S)
avCreate a zip file from all the files under 'base_dir'.

    The output zip file will be named 'base_name' + ".zip".  Uses either the
    "zipfile" Python module (if available) or the InfoZIP "zip" utility
    (if installed and found on the default search path).  If neither tool is
    available, raises DistutilsExecError.  Returns the name of the output zip
    file.
    z.ziprNz-rz-rq�zipzkunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utilityz#creating '%s' and adding '%s' to it�w)Zcompressionrzadding '%s')rr%r&r'�zipfilerrrr)ZZipFileZZIP_DEFLATED�RuntimeErrorZ
ZIP_STORED�curdir�normpath�join�write�walk�isfile)r0r1r2rZzip_filenameZ
zipoptionsr6r&�dirpathZdirnames�	filenamesrrrr�make_zipfilesV	�
���
�rB)rrzgzip'ed tar-file)rrzbzip2'ed tar-file)rrzxz'ed tar-file)rrzcompressed tar file)rNzuncompressed tar filezZIP file)ZgztarZbztarZxztarZztarr3r6cCs|D]}|tkr|SqdS)zqReturns the first format from the 'format' list that is unknown.

    If all formats are known, returns None
    N)�ARCHIVE_FORMATS)Zformats�formatrrr�check_archive_formats�s
rEc
Cs�t��}|dk	r6t�d|�tj�|�}|s6t�|�|dkrDtj}d|i}	zt|}
Wn t	k
rxt
d|��YnX|
d}|
dD]\}}
|
|	|<q�|dkr�||	d<||	d	<z|||f|	�}W5|dk	r�t�d
|�t�|�X|S)a�Create an archive file (eg. zip or tar).

    'base_name' is the name of the file to create, minus any format-specific
    extension; 'format' is the archive format: one of "zip", "tar", "gztar",
    "bztar", "xztar", or "ztar".

    'root_dir' is a directory that will be the root directory of the
    archive; ie. we typically chdir into 'root_dir' before creating the
    archive.  'base_dir' is the directory where we start archiving from;
    ie. 'base_dir' will be the common prefix of all files and
    directories in the archive.  'root_dir' and 'base_dir' both default
    to the current directory.  Returns the name of the archive file.

    'owner' and 'group' are used when creating a tar archive. By default,
    uses the current owner and group.
    Nzchanging into '%s'rzunknown archive format '%s'r�r6rrzchanging back to '%s')r%�getcwdr�debugr&�abspath�chdirr:rCr
r#)r0rDZroot_dirr1r2rrrZsave_cwd�kwargsZformat_info�func�arg�val�filenamerrr�make_archive�s2

rP)rrrNN)rr)NNrrNN)�__doc__r%�warningsrr.r8�ImportErrorZdistutils.errorsrZdistutils.spawnrZdistutils.dir_utilrZ	distutilsr�pwdrZgrprrrr5rBrCrErPrrrr�<module>sN


�
H
=




�	
�PK22�\�~��//file_util.cpython-38.pycnu�[���U

e5d��@sZdZddlZddlmZddlmZdddd�Zdd
d�Zdd
d�Zddd�Z	dd�Z
dS)zFdistutils.file_util

Utility functions for operating on single files.
�N)�DistutilsFileError)�logZcopyingzhard linkingzsymbolically linking)N�hard�sym�@c
Cs�d}d}�ztzt|d�}Wn4tk
rN}ztd||jf��W5d}~XYnXtj�|�r�zt�|�Wn4tk
r�}ztd||jf��W5d}~XYnXzt|d�}Wn4tk
r�}ztd||jf��W5d}~XYnXz|�	|�}Wn6tk
�r(}ztd||jf��W5d}~XYnX|�s4�q|z|�
|�Wq�tk
�rx}ztd||jf��W5d}~XYq�Xq�W5|�r�|��|�r�|��XdS)	a5Copy the file 'src' to 'dst'; both must be filenames.  Any error
    opening either file, reading from 'src', or writing to 'dst', raises
    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
    bytes (default 16k).  No attempt is made to handle anything apart from
    regular files.
    N�rbzcould not open '%s': %szcould not delete '%s': %s�wbzcould not create '%s': %szcould not read from '%s': %szcould not write to '%s': %s)�close�open�OSErrorr�strerror�os�path�exists�unlink�read�write)�src�dstZbuffer_sizeZfsrcZfdst�eZbuf�r�+/usr/lib64/python3.8/distutils/file_util.py�_copy_file_contentssL	$����r�cCsddlm}ddlm}	m}
m}m}tj�	|�s<t
d|��tj�|�rd|}
tj�|tj�
|��}ntj�|�}
|r�|||�s�|dkr�t�d|�|dfSzt|}Wn tk
r�td|��YnX|dk�rtj�
|�tj�
|�kr�t�d|||
�nt�d|||�|�r|dfS|d	k�rrtj�|��rBtj�||��s�zt�||�|dfWStk
�rnYnXn<|d
k�r�tj�|��r�tj�||��s�t�||�|dfSt||�|�s�|�rt�|�}|�r�t�|||	||
f�|�rt�||||��|dfS)aCopy a file 'src' to 'dst'.  If 'dst' is a directory, then 'src' is
    copied there with the same name; otherwise, it must be a filename.  (If
    the file exists, it will be ruthlessly clobbered.)  If 'preserve_mode'
    is true (the default), the file's mode (type and permission bits, or
    whatever is analogous on the current platform) is copied.  If
    'preserve_times' is true (the default), the last-modified and
    last-access times are copied as well.  If 'update' is true, 'src' will
    only be copied if 'dst' does not exist, or if 'dst' does exist but is
    older than 'src'.

    'link' allows you to make hard links (os.link) or symbolic links
    (os.symlink) instead of copying: set it to "hard" or "sym"; if it is
    None (the default), files are copied.  Don't set 'link' on systems that
    don't support it: 'copy_file()' doesn't check if hard or symbolic
    linking is available. If hardlink fails, falls back to
    _copy_file_contents().

    Under Mac OS, uses the native file copy function in macostools; on
    other systems, uses '_copy_file_contents()' to copy file contents.

    Return a tuple (dest_name, copied): 'dest_name' is the actual name of
    the output file, and 'copied' is true if the file was copied (or would
    have been copied, if 'dry_run' true).
    r)�newer)�ST_ATIME�ST_MTIME�ST_MODE�S_IMODEz4can't copy '%s': doesn't exist or not a regular filerz"not copying %s (output up-to-date)z&invalid value '%s' for 'link' argumentz%s %s -> %srr)Zdistutils.dep_utilr�statrrrrr
r�isfiler�isdir�join�basename�dirnamer�debug�_copy_action�KeyError�
ValueError�infor�samefile�linkr�symlinkr�utime�chmod)rrZ
preserve_modeZpreserve_times�updater+�verbose�dry_runrrrrr�dir�action�strrr�	copy_fileCsV!�





r5cCs�ddlm}m}m}m}m}ddl}	|dkr:t�d||�|rB|S||�sVt	d|��||�rrt
j�|||��}n||�r�t	d||f��|||��s�t	d||f��d	}
zt
�
||�WnPtk
�r
}z0|j\}}
||	jkr�d
}
nt	d|||
f��W5d}~XYnX|
�r�t|||d�zt
�|�Wnhtk
�r�}zH|j\}}
zt
�|�Wntk
�rpYnXt	d
||||
f��W5d}~XYnX|S)a%Move a file 'src' to 'dst'.  If 'dst' is a directory, the file will
    be moved into it with the same name; otherwise, 'src' is just renamed
    to 'dst'.  Return the new full name of the file.

    Handles cross-device moves on Unix using 'copy_file()'.  What about
    other systems???
    r)rr r!r#r$Nrzmoving %s -> %sz#can't move '%s': not a regular filez0can't move '%s': destination '%s' already existsz2can't move '%s': destination '%s' not a valid pathFTzcouldn't move '%s' to '%s': %s)r0zAcouldn't move '%s' to '%s' by copy/delete: delete '%s' failed: %s)Zos.pathrr r!r#r$�errnorr)rr
rr"�renamer�argsZEXDEVr5r)rrr0r1rr r!r#r$r6Zcopy_itrZnum�msgrrr�	move_file�s`����

�

��r:cCs6t|d�}z|D]}|�|d�qW5|��XdS)z{Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    �w�
N)r
r	r)�filename�contents�f�linerrr�
write_file�s

rA)r)rrrNrr)rr)�__doc__r
Zdistutils.errorsrZ	distutilsrr&rr5r:rArrrr�<module>s"�
3�
d�
?PK22�\
d�"~6~6cmd.cpython-38.opt-1.pycnu�[���U

e5d�F�@sbdZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZddlmZGdd�d�Z
dS)ztdistutils.cmd

Provides the Command class, the base class for the command classes
in the distutils.command package.
�N)�DistutilsOptionError)�util�dir_util�	file_util�archive_util�dep_util��logc@s"eZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dCdd�Z
dd�ZdDdd�Zdd�Z
dEdd�ZdFdd�Zdd�ZdGdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdHd'd(�ZdId*d+�Zd,d-�Zd.d/�Zd0d1�ZdJd2d3�ZdKd5d6�ZdLd7d8�ZdMd9d:�ZdNd;d<�ZdOd=d>�Z dPd?d@�Z!dQdAdB�Z"dS)R�Commanda}Abstract base class for defining command classes, the "worker bees"
    of the Distutils.  A useful analogy for command classes is to think of
    them as subroutines with local variables called "options".  The options
    are "declared" in 'initialize_options()' and "defined" (given their
    final values, aka "finalized") in 'finalize_options()', both of which
    must be defined by every command class.  The distinction between the
    two is necessary because option values might come from the outside
    world (command line, config file, ...), and any options dependent on
    other options must be computed *after* these outside influences have
    been processed -- hence 'finalize_options()'.  The "body" of the
    subroutine, where it does all its work based on the values of its
    options, is the 'run()' method, which must also be implemented by every
    command class.
    cCsbddlm}t||�std��|jtkr0td��||_|��d|_	|j
|_
d|_d|_d|_
dS)z�Create and initialize a new Command object.  Most importantly,
        invokes the 'initialize_options()' method, which is the real
        initializer and depends on the actual command being
        instantiated.
        r)�Distributionz$dist must be a Distribution instancezCommand is an abstract classN)Zdistutils.distr�
isinstance�	TypeError�	__class__r
�RuntimeError�distribution�initialize_optionsZ_dry_run�verbose�force�help�	finalized)�selfZdistr�r�%/usr/lib64/python3.8/distutils/cmd.py�__init__/s


zCommand.__init__cCs<|dkr0t|d|�}|dkr*t|j|�S|Snt|��dS)N�dry_run�_)�getattrr�AttributeError)r�attrZmyvalrrr�__getattr___szCommand.__getattr__cCs|js|��d|_dS)N�)r�finalize_options�rrrr�ensure_finalizediszCommand.ensure_finalizedcCstd|j��dS)a�Set default values for all the options that this command
        supports.  Note that these defaults may be overridden by other
        commands, by the setup script, by config files, or by the
        command-line.  Thus, this is not the place to code dependencies
        between options; generally, 'initialize_options()' implementations
        are just a bunch of "self.foo = None" assignments.

        This method must be implemented by all command classes.
        �,abstract method -- subclass %s must overrideN�rrr"rrrr{s
�zCommand.initialize_optionscCstd|j��dS)aSet final values for all the options that this command supports.
        This is always called as late as possible, ie.  after any option
        assignments from the command-line or from other commands have been
        done.  Thus, this is the place to code option dependencies: if
        'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as
        long as 'foo' still has the same value it was assigned in
        'initialize_options()'.

        This method must be implemented by all command classes.
        r$Nr%r"rrrr!�s�zCommand.finalize_optionsN�cCs�ddlm}|dkr d|��}|j||tjd�|d}|jD]R\}}}|�|�}|ddkrn|dd�}t||�}|j|d||ftjd�qBdS)	Nr)�
longopt_xlatezcommand options for '%s':)�levelz  ����=z%s = %s)	Zdistutils.fancy_getoptr'�get_command_name�announcer	�INFOZuser_options�	translater)r�header�indentr'�optionr�valuerrr�dump_options�s

�zCommand.dump_optionscCstd|j��dS)a�A command's raison d'etre: carry out the action it exists to
        perform, controlled by the options initialized in
        'initialize_options()', customized by other commands, the setup
        script, the command-line, and config files, and finalized in
        'finalize_options()'.  All terminal output and filesystem
        interaction should be done by 'run()'.

        This method must be implemented by all command classes.
        r$Nr%r"rrr�run�s
�zCommand.runr cCst�||�dS)zmIf the current verbosity level is of greater than or equal to
        'level' print 'msg' to stdout.
        Nr)r�msgr(rrrr,�szCommand.announcecCs&ddlm}|r"t|�tj��dS)z~Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        r)�DEBUGN)Zdistutils.debugr6�print�sys�stdout�flush)rr5r6rrr�debug_print�szCommand.debug_printcCsBt||�}|dkr"t|||�|St|t�s>td|||f��|S)Nz'%s' must be a %s (got `%s`))r�setattrr�strr)rr1�what�default�valrrr�_ensure_stringlike�s

�zCommand._ensure_stringlikecCs|�|d|�dS)zWEnsure that 'option' is a string; if not defined, set it to
        'default'.
        �stringN)rA)rr1r?rrr�
ensure_string�szCommand.ensure_stringcCspt||�}|dkrdSt|t�r6t||t�d|��n6t|t�rTtdd�|D��}nd}|sltd||f��dS)z�Ensure that 'option' is a list of strings.  If 'option' is
        currently a string, we split it either on /,\s*/ or /\s+/, so
        "foo bar baz", "foo,bar,baz", and "foo,   bar baz" all become
        ["foo", "bar", "baz"].
        Nz,\s*|\s+css|]}t|t�VqdS�N)rr=)�.0�vrrr�	<genexpr>�sz-Command.ensure_string_list.<locals>.<genexpr>Fz''%s' must be a list of strings (got %r))	rrr=r<�re�split�list�allr)rr1r@�okrrr�ensure_string_list�s


��zCommand.ensure_string_listcCs6|�|||�}|dk	r2||�s2td|||f��dS)Nzerror in '%s' option: )rAr)rr1Ztesterr>Z	error_fmtr?r@rrr�_ensure_tested_string�s
�zCommand._ensure_tested_stringcCs|�|tjjdd�dS)z5Ensure that 'option' is the name of an existing file.�filenamez$'%s' does not exist or is not a fileN)rN�os�path�isfile�rr1rrr�ensure_filename�s�zCommand.ensure_filenamecCs|�|tjjdd�dS)Nzdirectory namez)'%s' does not exist or is not a directory)rNrPrQ�isdirrSrrr�ensure_dirnames�zCommand.ensure_dirnamecCst|d�r|jS|jjSdS)N�command_name)�hasattrrWr�__name__r"rrrr+	s
zCommand.get_command_namecGsF|j�|�}|��|D](\}}t||�dkrt||t||��qdS)a>Set the values of any "undefined" options from corresponding
        option values in some other command object.  "Undefined" here means
        "is None", which is the convention used to indicate that an option
        has not been changed between 'initialize_options()' and
        'finalize_options()'.  Usually called from 'finalize_options()' for
        options that depend on some other command rather than another
        option of the same command.  'src_cmd' is the other command from
        which option values will be taken (a command object will be created
        for it if necessary); the remaining arguments are
        '(src_option,dst_option)' tuples which mean "take the value of
        'src_option' in the 'src_cmd' command object, and copy it to
        'dst_option' in the current command object".
        N)r�get_command_objr#rr<)rZsrc_cmdZoption_pairsZsrc_cmd_objZ
src_optionZ
dst_optionrrr�set_undefined_optionss
zCommand.set_undefined_optionscCs|j�||�}|��|S)z�Wrapper around Distribution's 'get_command_obj()' method: find
        (create if necessary and 'create' is true) the command object for
        'command', call its 'ensure_finalized()' method, and return the
        finalized command object.
        )rrZr#)r�commandZcreateZcmd_objrrr�get_finalized_command$szCommand.get_finalized_commandrcCs|j�||�SrD)r�reinitialize_command)rr\Zreinit_subcommandsrrrr^0s�zCommand.reinitialize_commandcCs|j�|�dS)z�Run some other command: uses the 'run_command()' method of
        Distribution, which creates and finalizes the command object if
        necessary and then invokes its 'run()' method.
        N)r�run_command)rr\rrrr_4szCommand.run_commandcCs2g}|jD]"\}}|dks"||�r
|�|�q
|S)akDetermine the sub-commands that are relevant in the current
        distribution (ie., that need to be run).  This is based on the
        'sub_commands' class attribute: each tuple in that list may include
        a method that we call to determine if the subcommand needs to be
        run for the current distribution.  Return a list of command names.
        N)�sub_commands�append)rZcommandsZcmd_name�methodrrr�get_sub_commands;s
zCommand.get_sub_commandscCst�d|��|�dS)Nzwarning: %s: %s
)r	�warnr+)rr5rrrrdKszCommand.warncCstj||||jd�dS�N�r)r�executer)r�func�argsr5r(rrrrgNszCommand.execute�cCstj|||jd�dSre)r�mkpathr)r�name�moderrrrkQszCommand.mkpathc	Cstj|||||j||jd�S)z�Copy a file respecting verbose, dry-run and force flags.  (The
        former two default to whatever is in the Distribution object, and
        the latter defaults to false for commands that don't define it.)rf)r�	copy_filerr)r�infile�outfile�
preserve_mode�preserve_times�linkr(rrrrnTs
�zCommand.copy_filec	Cstj||||||j|jd�S)z\Copy an entire directory tree respecting verbose, dry-run,
        and force flags.
        rf)r�	copy_treerr)rrorprqrrZpreserve_symlinksr(rrrrt]s
�zCommand.copy_treecCstj|||jd�S)z$Move a file respecting dry-run flag.rf)r�	move_filer)r�srcZdstr(rrrrufszCommand.move_filecCs ddlm}||||jd�dS)z2Spawn an external command respecting dry-run flag.r)�spawnrfN)Zdistutils.spawnrwr)r�cmdZsearch_pathr(rwrrrrwjsz
Command.spawnc	Cstj|||||j||d�S)N)r�owner�group)r�make_archiver)rZ	base_name�formatZroot_dirZbase_dirryrzrrrr{os
�zCommand.make_archivecCs�|dkrd|}t|t�r"|f}nt|ttf�s8td��|dkrRd|d�|�f}|jsdt�||�rv|�	||||�n
t
�|�dS)a�Special case of 'execute()' for operations that process one or
        more input files and generate one output file.  Works just like
        'execute()', except the operation is skipped and a different
        message printed if 'outfile' already exists and is newer than all
        files listed in 'infiles'.  If the command defined 'self.force',
        and it is true, then the command is unconditionally run -- does no
        timestamp checks.
        Nzskipping %s (inputs unchanged)z9'infiles' must be a string, or a list or tuple of stringszgenerating %s from %sz, )rr=rJ�tupler
�joinrrZnewer_grouprgr	�debug)rZinfilesrprhriZexec_msgZskip_msgr(rrr�	make_fileus

�zCommand.make_file)Nr&)r )N)N)N)r )r)Nr )rj)r r Nr )r r rr )r )r r )NNNN)NNr )#rY�
__module__�__qualname__�__doc__r`rrr#rr!r3r4r,r;rArCrMrNrTrVr+r[r]r^r_rcrdrgrkrnrtrurwr{r�rrrrr
sZ0






�




�
	�
	

�
�r
)r�r8rPrHZdistutils.errorsrZ	distutilsrrrrrr	r
rrrr�<module>s
PK32�\xQ%uddversion.cpython-38.opt-1.pycnu�[���U

e5d90�@s>dZddlZGdd�d�ZGdd�de�ZGdd�de�ZdS)	a�Provides classes to represent module version numbers (one class for
each style of version numbering).  There are currently two such classes
implemented: StrictVersion and LooseVersion.

Every version number class implements the following interface:
  * the 'parse' method takes a string and parses it to some internal
    representation; if the string is an invalid version number,
    'parse' raises a ValueError exception
  * the class constructor takes an optional string argument which,
    if supplied, is passed to 'parse'
  * __str__ reconstructs the string that was passed to 'parse' (or
    an equivalent string -- ie. one that will generate an equivalent
    version number instance)
  * __repr__ generates Python code to recreate the version number instance
  * _cmp compares the current instance with either another instance
    of the same class or a string (which will be parsed to an instance
    of the same class, thus must follow the same rules)
�Nc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�Versionz�Abstract base class for version numbering classes.  Just provides
    constructor (__init__) and reproducer (__repr__), because those
    seem to be the same for all version numbering classes; and route
    rich comparisons to _cmp.
    NcCs|r|�|�dS�N��parse��self�vstring�r	�)/usr/lib64/python3.8/distutils/version.py�__init__&szVersion.__init__cCsd|jjt|�fS)Nz	%s ('%s'))�	__class__�__name__�str�rr	r	r
�__repr__*szVersion.__repr__cCs|�|�}|tkr|S|dkS�Nr��_cmp�NotImplemented�r�other�cr	r	r
�__eq__-s
zVersion.__eq__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__lt__3s
zVersion.__lt__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__le__9s
zVersion.__le__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__gt__?s
zVersion.__gt__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__ge__Es
zVersion.__ge__)N)r
�
__module__�__qualname__�__doc__rrrrrrrr	r	r	r
rs
rc@s<eZdZdZe�dejejB�Zdd�Z	dd�Z
dd�Zd	S)
�
StrictVersiona?Version numbering for anal retentives and software idealists.
    Implements the standard interface for version number classes as
    described above.  A version number consists of two or three
    dot-separated numeric components, with an optional "pre-release" tag
    on the end.  The pre-release tag consists of the letter 'a' or 'b'
    followed by a number.  If the numeric components of two version
    numbers are equal, then one with a pre-release tag will always
    be deemed earlier (lesser) than one without.

    The following are valid version numbers (shown in the order that
    would be obtained by sorting according to the supplied cmp function):

        0.4       0.4.0  (these two are equivalent)
        0.4.1
        0.5a1
        0.5b3
        0.5
        0.9.6
        1.0
        1.0.4a3
        1.0.4b1
        1.0.4

    The following are examples of invalid version numbers:

        1
        2.7.2.2
        1.3.a4
        1.3pl1
        1.3c4

    The rationale for this version numbering system will be explained
    in the distutils documentation.
    z)^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$cCs�|j�|�}|std|��|�ddddd�\}}}}}|rTttt|||g��|_nttt||g��d|_|r�|dt|�f|_nd|_dS)	Nzinvalid version number '%s'�����)rr)	�
version_re�match�
ValueError�group�tuple�map�int�version�
prerelease)rrr'�major�minorZpatchr.Zprerelease_numr	r	r
r�s�zStrictVersion.parsecCsb|jddkr*d�tt|jdd���}nd�tt|j��}|jr^||jdt|jd�}|S)Nr"r�.r!)r-�joinr+rr.rr	r	r
�__str__�szStrictVersion.__str__cCs�t|t�rt|�}|j|jkr2|j|jkr.dSdS|jsB|jsBdS|jrR|jsRdS|jsb|jrbdS|jr�|jr�|j|jkr~dS|j|jkr�dSdSndS)N���r!r)�
isinstancerr r-r.�rrr	r	r
r�s&
zStrictVersion._cmpN)r
rrr�re�compile�VERBOSE�ASCIIr&rr3rr	r	r	r
r ]s#
�
r c@sHeZdZdZe�dej�Zddd�Zdd�Z	dd	�Z
d
d�Zdd
�ZdS)�LooseVersiona�Version numbering for anarchists and software realists.
    Implements the standard interface for version number classes as
    described above.  A version number consists of a series of numbers,
    separated by either periods or strings of letters.  When comparing
    version numbers, the numeric components will be compared
    numerically, and the alphabetic components lexically.  The following
    are all valid version numbers, in no particular order:

        1.5.1
        1.5.2b2
        161
        3.10a
        8.02
        3.4j
        1996.07.12
        3.2.pl0
        3.1.1.6
        2g6
        11g
        0.960923
        2.2beta29
        1.13++
        5.5.kw
        2.0b1pl0

    In fact, there is no such thing as an invalid version number under
    this scheme; the rules for comparison are simple and predictable,
    but may not always give the results you want (for some definition
    of "want").
    z(\d+ | [a-z]+ | \.)NcCs|r|�|�dSrrrr	r	r
r.szLooseVersion.__init__c	Cs^||_dd�|j�|�D�}t|�D].\}}zt|�||<Wq$tk
rPYq$Xq$||_dS)NcSsg|]}|r|dkr|�qS)r1r	)�.0�xr	r	r
�
<listcomp>8s�z&LooseVersion.parse.<locals>.<listcomp>)r�component_re�split�	enumerater,r(r-)rrZ
components�i�objr	r	r
r3szLooseVersion.parsecCs|jSr)rrr	r	r
r3CszLooseVersion.__str__cCsdt|�S)NzLooseVersion ('%s'))rrr	r	r
rGszLooseVersion.__repr__cCsFt|t�rt|�}|j|jkr"dS|j|jkr2dS|j|jkrBdSdS)Nrr4r!)r5rr;r-r6r	r	r
rKs
zLooseVersion._cmp)N)
r
rrrr7r8r9r?rrr3rrr	r	r	r
r;s
r;)rr7rr r;r	r	r	r
�<module>
s
>/PK32�\%E�,}}bcppcompiler.cpython-38.pycnu�[���U

e5dW:�@sxdZddlZddlmZmZmZmZmZmZddl	m
Z
mZmZddl
mZddlmZddlmZGdd	�d	e
�ZdS)
z�distutils.bcppcompiler

Contains BorlandCCompiler, an implementation of the abstract CCompiler class
for the Borland C++ compiler.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError�UnknownFileError)�	CCompiler�gen_preprocess_options�gen_lib_options)�
write_file)�newer)�logc
@s�eZdZdZdZiZdgZdddgZeeZdZ	dZ
d	Zd
ZZ
dZdd
d�Zddd�Zddd�Zd dd�Zd!dd�Zd"dd�Zd#dd�ZdS)$�BCPPCompilerzConcrete class that implements an interface to the Borland C/C++
    compiler, as defined by the CCompiler abstract class.
    Zbcppz.cz.ccz.cppz.cxxz.objz.libz.dllz%s%sz.exercCs�t�||||�d|_d|_d|_d|_ddddg|_ddddg|_d	d
ddg|_d	d
ddg|_	g|_
d
ddg|_d
dddg|_dS)
Nz	bcc32.exezilink32.exeztlib.exez/tWMz/O2z/qz/g0z/Odz/Tpdz/Gnz/xz/r)
r�__init__�cc�linker�libZpreprocess_options�compile_options�compile_options_debug�ldflags_shared�ldflags_shared_debugZldflags_static�ldflags_exe�ldflags_exe_debug)�self�verboseZdry_run�force�r�./usr/lib64/python3.8/distutils/bcppcompiler.pyr5szBCPPCompiler.__init__Nc	Cs�|�||||||�\}}	}}
}|p$g}|�d�|rB|�|j�n|�|j�|	D�]<}
z||
\}}Wntk
r�YqRYnXtj�|�}tj�|
�}
|�	tj�
|
��|dkr�qR|dk�rz|�dd|
|g�WqRtk
�r}zt
|��W5d}~XYqRXqR||jk�rd}n||jk�r*d}nd}d|
}z,|�|jg||
||g||g�WqRtk
�r�}zt
|��W5d}~XYqRXqR|	S)	Nz-c�.res�.rcZbrcc32z-fo�z-P�-o)Z_setup_compile�append�extendrr�KeyError�os�path�normpath�mkpath�dirname�spawnrr�
_c_extensions�_cpp_extensionsr)rZsources�
output_dir�macros�include_dirs�debug�
extra_preargs�extra_postargsZdepends�objects�pp_optsZbuildZcompile_opts�obj�src�ext�msgZ	input_optZ
output_optrrr�compileQsV��



���
zBCPPCompiler.compilec	
Cs�|�||�\}}|j||d�}|�||�r~|dg|}|r:z|�|jg|�Wq�tk
rz}zt|��W5d}~XYq�Xnt�d|�dS)N)r-z/u�skipping %s (up-to-date))	�_fix_object_args�library_filename�
_need_linkr*rrrr
r0)	rr3Zoutput_libnamer-r0�target_lang�output_filenameZlib_argsr8rrr�create_static_lib�s�zBCPPCompiler.create_static_libc 
Cs�|�||�\}}|�|||�\}}}|r8t�dt|��|dk	rNtj�||�}|�||��r�|t	j
kr�d}|	r~|jdd�}q�|jdd�}n&d}|	r�|j
dd�}n|jdd�}|dkr�d}n�tj�|�\}}tj�|�\}}tj�|d�}tj�|d|�}dg}|�pgD]}|�d||f��q|�t||fd	|�ttjj|�}|g}g}|D]>}tj�tj�|��\}}|d
k�r�|�|�n
|�|��q`|D]}|�dtj�|���q�|�d�|�|�|�d
|g�|�d�|D]4}|�|||	�}|dk�r|�|�n
|�|��q�|�d�|�d�|�d
|g�|�d
�|�|�|
�rp|
|dd�<|�r�|�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz7I don't know what to do with 'runtime_library_dirs': %sZc0w32Zc0d32r rz%s.defZEXPORTSz  %s=_%sz
writing %srz/L%sz/L.�,z,,Zimport32Zcw32mtr:) r;Z
_fix_lib_argsr
�warn�strr%r&�joinr=rZ
EXECUTABLErrrr�split�splitextr)r"Zexecuter�mapr'�normcaser#�find_library_filer(r*rrrr0) rZtarget_descr3r?r-Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr0r1r2Z
build_tempr>Zstartup_objZld_argsZdef_file�head�tail�modnamer7Ztemp_dir�contentsZsymZobjects2Z	resources�file�base�lr�libfiler8rrr�link�s���
�










zBCPPCompiler.linkc	Csr|r"|d}|d|d||f}n|d|f}|D]:}|D]0}tj�||�|��}tj�|�r:|Sq:q2dS)NZ_dZ_bcpp)r%r&rDr<�exists)	r�dirsrr0ZdlibZ	try_names�dir�namerQrrrrI4s
zBCPPCompiler.find_library_filer cCs�|dkrd}g}|D]�}tj�tj�|��\}}||jddgkrRtd||f��|rbtj�|�}|dkr�|�tj�|||��q|dkr�|�tj�||d��q|�tj�|||j	��q|S)Nr rrz"unknown file type '%s' (from '%s'))
r%r&rFrH�src_extensionsr�basenamer"rD�
obj_extension)rZsource_filenamesZ	strip_dirr-Z	obj_namesZsrc_namerOr7rrr�object_filenamesNs&��zBCPPCompiler.object_filenamesc
Cs�|�d||�\}}}t||�}dg|}	|dk	r>|	�d|�|rN||	dd�<|r\|	�|�|	�|�|js~|dks~t||�r�|r�|�tj�	|��z|�
|	�Wn2tk
r�}
zt|
�t
|
��W5d}
~
XYnXdS)Nz	cpp32.exer!r)Z_fix_compile_argsr	r"r#rrr(r%r&r)r*r�printr)r�sourceZoutput_filer.r/r1r2�_r4Zpp_argsr8rrr�
preprocessis&	�



zBCPPCompiler.preprocess)rrr)NNNrNNN)NrN)
NNNNNrNNNN)r)rr )NNNNN)�__name__�
__module__�__qualname__�__doc__Z
compiler_typeZexecutablesr+r,rWrYZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionrr9r@rRrIrZr^rrrrrsb
�
�
D�
�


�
�r)rbr%Zdistutils.errorsrrrrrrZdistutils.ccompilerrr	r
Zdistutils.file_utilrZdistutils.dep_utilrZ	distutilsr
rrrrr�<module>s PK32�\
d�"~6~6cmd.cpython-38.pycnu�[���U

e5d�F�@sbdZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZddlmZGdd�d�Z
dS)ztdistutils.cmd

Provides the Command class, the base class for the command classes
in the distutils.command package.
�N)�DistutilsOptionError)�util�dir_util�	file_util�archive_util�dep_util��logc@s"eZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dCdd�Z
dd�ZdDdd�Zdd�Z
dEdd�ZdFdd�Zdd�ZdGdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdHd'd(�ZdId*d+�Zd,d-�Zd.d/�Zd0d1�ZdJd2d3�ZdKd5d6�ZdLd7d8�ZdMd9d:�ZdNd;d<�ZdOd=d>�Z dPd?d@�Z!dQdAdB�Z"dS)R�Commanda}Abstract base class for defining command classes, the "worker bees"
    of the Distutils.  A useful analogy for command classes is to think of
    them as subroutines with local variables called "options".  The options
    are "declared" in 'initialize_options()' and "defined" (given their
    final values, aka "finalized") in 'finalize_options()', both of which
    must be defined by every command class.  The distinction between the
    two is necessary because option values might come from the outside
    world (command line, config file, ...), and any options dependent on
    other options must be computed *after* these outside influences have
    been processed -- hence 'finalize_options()'.  The "body" of the
    subroutine, where it does all its work based on the values of its
    options, is the 'run()' method, which must also be implemented by every
    command class.
    cCsbddlm}t||�std��|jtkr0td��||_|��d|_	|j
|_
d|_d|_d|_
dS)z�Create and initialize a new Command object.  Most importantly,
        invokes the 'initialize_options()' method, which is the real
        initializer and depends on the actual command being
        instantiated.
        r)�Distributionz$dist must be a Distribution instancezCommand is an abstract classN)Zdistutils.distr�
isinstance�	TypeError�	__class__r
�RuntimeError�distribution�initialize_optionsZ_dry_run�verbose�force�help�	finalized)�selfZdistr�r�%/usr/lib64/python3.8/distutils/cmd.py�__init__/s


zCommand.__init__cCs<|dkr0t|d|�}|dkr*t|j|�S|Snt|��dS)N�dry_run�_)�getattrr�AttributeError)r�attrZmyvalrrr�__getattr___szCommand.__getattr__cCs|js|��d|_dS)N�)r�finalize_options�rrrr�ensure_finalizediszCommand.ensure_finalizedcCstd|j��dS)a�Set default values for all the options that this command
        supports.  Note that these defaults may be overridden by other
        commands, by the setup script, by config files, or by the
        command-line.  Thus, this is not the place to code dependencies
        between options; generally, 'initialize_options()' implementations
        are just a bunch of "self.foo = None" assignments.

        This method must be implemented by all command classes.
        �,abstract method -- subclass %s must overrideN�rrr"rrrr{s
�zCommand.initialize_optionscCstd|j��dS)aSet final values for all the options that this command supports.
        This is always called as late as possible, ie.  after any option
        assignments from the command-line or from other commands have been
        done.  Thus, this is the place to code option dependencies: if
        'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as
        long as 'foo' still has the same value it was assigned in
        'initialize_options()'.

        This method must be implemented by all command classes.
        r$Nr%r"rrrr!�s�zCommand.finalize_optionsN�cCs�ddlm}|dkr d|��}|j||tjd�|d}|jD]R\}}}|�|�}|ddkrn|dd�}t||�}|j|d||ftjd�qBdS)	Nr)�
longopt_xlatezcommand options for '%s':)�levelz  ����=z%s = %s)	Zdistutils.fancy_getoptr'�get_command_name�announcer	�INFOZuser_options�	translater)r�header�indentr'�optionr�valuerrr�dump_options�s

�zCommand.dump_optionscCstd|j��dS)a�A command's raison d'etre: carry out the action it exists to
        perform, controlled by the options initialized in
        'initialize_options()', customized by other commands, the setup
        script, the command-line, and config files, and finalized in
        'finalize_options()'.  All terminal output and filesystem
        interaction should be done by 'run()'.

        This method must be implemented by all command classes.
        r$Nr%r"rrr�run�s
�zCommand.runr cCst�||�dS)zmIf the current verbosity level is of greater than or equal to
        'level' print 'msg' to stdout.
        Nr)r�msgr(rrrr,�szCommand.announcecCs&ddlm}|r"t|�tj��dS)z~Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        r)�DEBUGN)Zdistutils.debugr6�print�sys�stdout�flush)rr5r6rrr�debug_print�szCommand.debug_printcCsBt||�}|dkr"t|||�|St|t�s>td|||f��|S)Nz'%s' must be a %s (got `%s`))r�setattrr�strr)rr1�what�default�valrrr�_ensure_stringlike�s

�zCommand._ensure_stringlikecCs|�|d|�dS)zWEnsure that 'option' is a string; if not defined, set it to
        'default'.
        �stringN)rA)rr1r?rrr�
ensure_string�szCommand.ensure_stringcCspt||�}|dkrdSt|t�r6t||t�d|��n6t|t�rTtdd�|D��}nd}|sltd||f��dS)z�Ensure that 'option' is a list of strings.  If 'option' is
        currently a string, we split it either on /,\s*/ or /\s+/, so
        "foo bar baz", "foo,bar,baz", and "foo,   bar baz" all become
        ["foo", "bar", "baz"].
        Nz,\s*|\s+css|]}t|t�VqdS�N)rr=)�.0�vrrr�	<genexpr>�sz-Command.ensure_string_list.<locals>.<genexpr>Fz''%s' must be a list of strings (got %r))	rrr=r<�re�split�list�allr)rr1r@�okrrr�ensure_string_list�s


��zCommand.ensure_string_listcCs6|�|||�}|dk	r2||�s2td|||f��dS)Nzerror in '%s' option: )rAr)rr1Ztesterr>Z	error_fmtr?r@rrr�_ensure_tested_string�s
�zCommand._ensure_tested_stringcCs|�|tjjdd�dS)z5Ensure that 'option' is the name of an existing file.�filenamez$'%s' does not exist or is not a fileN)rN�os�path�isfile�rr1rrr�ensure_filename�s�zCommand.ensure_filenamecCs|�|tjjdd�dS)Nzdirectory namez)'%s' does not exist or is not a directory)rNrPrQ�isdirrSrrr�ensure_dirnames�zCommand.ensure_dirnamecCst|d�r|jS|jjSdS)N�command_name)�hasattrrWr�__name__r"rrrr+	s
zCommand.get_command_namecGsF|j�|�}|��|D](\}}t||�dkrt||t||��qdS)a>Set the values of any "undefined" options from corresponding
        option values in some other command object.  "Undefined" here means
        "is None", which is the convention used to indicate that an option
        has not been changed between 'initialize_options()' and
        'finalize_options()'.  Usually called from 'finalize_options()' for
        options that depend on some other command rather than another
        option of the same command.  'src_cmd' is the other command from
        which option values will be taken (a command object will be created
        for it if necessary); the remaining arguments are
        '(src_option,dst_option)' tuples which mean "take the value of
        'src_option' in the 'src_cmd' command object, and copy it to
        'dst_option' in the current command object".
        N)r�get_command_objr#rr<)rZsrc_cmdZoption_pairsZsrc_cmd_objZ
src_optionZ
dst_optionrrr�set_undefined_optionss
zCommand.set_undefined_optionscCs|j�||�}|��|S)z�Wrapper around Distribution's 'get_command_obj()' method: find
        (create if necessary and 'create' is true) the command object for
        'command', call its 'ensure_finalized()' method, and return the
        finalized command object.
        )rrZr#)r�commandZcreateZcmd_objrrr�get_finalized_command$szCommand.get_finalized_commandrcCs|j�||�SrD)r�reinitialize_command)rr\Zreinit_subcommandsrrrr^0s�zCommand.reinitialize_commandcCs|j�|�dS)z�Run some other command: uses the 'run_command()' method of
        Distribution, which creates and finalizes the command object if
        necessary and then invokes its 'run()' method.
        N)r�run_command)rr\rrrr_4szCommand.run_commandcCs2g}|jD]"\}}|dks"||�r
|�|�q
|S)akDetermine the sub-commands that are relevant in the current
        distribution (ie., that need to be run).  This is based on the
        'sub_commands' class attribute: each tuple in that list may include
        a method that we call to determine if the subcommand needs to be
        run for the current distribution.  Return a list of command names.
        N)�sub_commands�append)rZcommandsZcmd_name�methodrrr�get_sub_commands;s
zCommand.get_sub_commandscCst�d|��|�dS)Nzwarning: %s: %s
)r	�warnr+)rr5rrrrdKszCommand.warncCstj||||jd�dS�N�r)r�executer)r�func�argsr5r(rrrrgNszCommand.execute�cCstj|||jd�dSre)r�mkpathr)r�name�moderrrrkQszCommand.mkpathc	Cstj|||||j||jd�S)z�Copy a file respecting verbose, dry-run and force flags.  (The
        former two default to whatever is in the Distribution object, and
        the latter defaults to false for commands that don't define it.)rf)r�	copy_filerr)r�infile�outfile�
preserve_mode�preserve_times�linkr(rrrrnTs
�zCommand.copy_filec	Cstj||||||j|jd�S)z\Copy an entire directory tree respecting verbose, dry-run,
        and force flags.
        rf)r�	copy_treerr)rrorprqrrZpreserve_symlinksr(rrrrt]s
�zCommand.copy_treecCstj|||jd�S)z$Move a file respecting dry-run flag.rf)r�	move_filer)r�srcZdstr(rrrrufszCommand.move_filecCs ddlm}||||jd�dS)z2Spawn an external command respecting dry-run flag.r)�spawnrfN)Zdistutils.spawnrwr)r�cmdZsearch_pathr(rwrrrrwjsz
Command.spawnc	Cstj|||||j||d�S)N)r�owner�group)r�make_archiver)rZ	base_name�formatZroot_dirZbase_dirryrzrrrr{os
�zCommand.make_archivecCs�|dkrd|}t|t�r"|f}nt|ttf�s8td��|dkrRd|d�|�f}|jsdt�||�rv|�	||||�n
t
�|�dS)a�Special case of 'execute()' for operations that process one or
        more input files and generate one output file.  Works just like
        'execute()', except the operation is skipped and a different
        message printed if 'outfile' already exists and is newer than all
        files listed in 'infiles'.  If the command defined 'self.force',
        and it is true, then the command is unconditionally run -- does no
        timestamp checks.
        Nzskipping %s (inputs unchanged)z9'infiles' must be a string, or a list or tuple of stringszgenerating %s from %sz, )rr=rJ�tupler
�joinrrZnewer_grouprgr	�debug)rZinfilesrprhriZexec_msgZskip_msgr(rrr�	make_fileus

�zCommand.make_file)Nr&)r )N)N)N)r )r)Nr )rj)r r Nr )r r rr )r )r r )NNNN)NNr )#rY�
__module__�__qualname__�__doc__r`rrr#rr!r3r4r,r;rArCrMrNrTrVr+r[r]r^r_rcrdrgrkrnrtrurwr{r�rrrrr
sZ0






�




�
	�
	

�
�r
)r�r8rPrHZdistutils.errorsrZ	distutilsrrrrrr	r
rrrr�<module>s
PK32�\�fIx��file_util.cpython-38.opt-2.pycnu�[���U

e5d��@sVddlZddlmZddlmZdddd�Zdd	d
�Zddd
�Zddd�Zdd�Z	dS)�N)�DistutilsFileError)�logZcopyingzhard linkingzsymbolically linking)N�hard�sym�@c
Cs�d}d}�ztzt|d�}Wn4tk
rN}ztd||jf��W5d}~XYnXtj�|�r�zt�|�Wn4tk
r�}ztd||jf��W5d}~XYnXzt|d�}Wn4tk
r�}ztd||jf��W5d}~XYnXz|�	|�}Wn6tk
�r(}ztd||jf��W5d}~XYnX|�s4�q|z|�
|�Wq�tk
�rx}ztd||jf��W5d}~XYq�Xq�W5|�r�|��|�r�|��XdS)N�rbzcould not open '%s': %szcould not delete '%s': %s�wbzcould not create '%s': %szcould not read from '%s': %szcould not write to '%s': %s)�close�open�OSErrorr�strerror�os�path�exists�unlink�read�write)�src�dstZbuffer_sizeZfsrcZfdst�eZbuf�r�+/usr/lib64/python3.8/distutils/file_util.py�_copy_file_contentssL	$����r�cCsddlm}ddlm}	m}
m}m}tj�	|�s<t
d|��tj�|�rd|}
tj�|tj�
|��}ntj�|�}
|r�|||�s�|dkr�t�d|�|dfSzt|}Wn tk
r�td|��YnX|dk�rtj�
|�tj�
|�kr�t�d|||
�nt�d|||�|�r|dfS|d	k�rrtj�|��rBtj�||��s�zt�||�|dfWStk
�rnYnXn<|d
k�r�tj�|��r�tj�||��s�t�||�|dfSt||�|�s�|�rt�|�}|�r�t�|||	||
f�|�rt�||||��|dfS)Nr)�newer)�ST_ATIME�ST_MTIME�ST_MODE�S_IMODEz4can't copy '%s': doesn't exist or not a regular filerz"not copying %s (output up-to-date)z&invalid value '%s' for 'link' argumentz%s %s -> %srr)Zdistutils.dep_utilr�statrrrrr
r�isfiler�isdir�join�basename�dirnamer�debug�_copy_action�KeyError�
ValueError�infor�samefile�linkr�symlinkr�utime�chmod)rrZ
preserve_modeZpreserve_times�updater+�verbose�dry_runrrrrr�dir�action�strrr�	copy_fileCsV!�





r5cCs�ddlm}m}m}m}m}ddl}	|dkr:t�d||�|rB|S||�sVt	d|��||�rrt
j�|||��}n||�r�t	d||f��|||��s�t	d||f��d}
zt
�
||�WnPtk
�r
}z0|j\}}
||	jkr�d	}
nt	d
|||
f��W5d}~XYnX|
�r�t|||d�zt
�|�Wnhtk
�r�}zH|j\}}
zt
�|�Wntk
�rpYnXt	d||||
f��W5d}~XYnX|S)
Nr)rr r!r#r$rzmoving %s -> %sz#can't move '%s': not a regular filez0can't move '%s': destination '%s' already existsz2can't move '%s': destination '%s' not a valid pathFTzcouldn't move '%s' to '%s': %s)r0zAcouldn't move '%s' to '%s' by copy/delete: delete '%s' failed: %s)Zos.pathrr r!r#r$�errnorr)rr
rr"�renamer�argsZEXDEVr5r)rrr0r1rr r!r#r$r6Zcopy_itrZnum�msgrrr�	move_file�s`����

�

��r:cCs6t|d�}z|D]}|�|d�qW5|��XdS)N�w�
)r
r	r)�filename�contents�f�linerrr�
write_file�s

rA)r)rrrNrr)rr)
r
Zdistutils.errorsrZ	distutilsrr&rr5r:rArrrr�<module>s �
3�
d�
?PK32�\|����spawn.cpython-38.pycnu�[���U

e5d��@s�dZddlZddlZddlmZmZddlmZddlm	Z	ddd�Z
d	d
�Zddd�Zej
d
krjdadaddd�Zddd�ZdS)z�distutils.spawn

Provides the 'spawn()' function, a front-end to various platform-
specific functions for launching another program in a sub-process.
Also provides the 'find_executable()' to search the path for a given
executable name.
�N)�DistutilsPlatformError�DistutilsExecError)�DEBUG)�log�cCsNt|�}tjdkr"t|||d�n(tjdkr<t|||d�ntdtj��dS)a�Run another program, specified as a command list 'cmd', in a new process.

    'cmd' is just the argument list for the new process, ie.
    cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
    There is no way to run a program with a name different from that of its
    executable.

    If 'search_path' is true (the default), the system's executable
    search path will be used to find the program; otherwise, cmd[0]
    must be the exact path to the executable.  If 'dry_run' is true,
    the command will not actually be run.

    Raise DistutilsExecError if running the program fails in any way; just
    return on success.
    �posix)�dry_run�ntz1don't know how to spawn programs on platform '%s'N)�list�os�name�_spawn_posix�	_spawn_ntr)�cmd�search_path�verboser�r�'/usr/lib64/python3.8/distutils/spawn.py�spawns

�rcCs*t|�D]\}}d|krd|||<q|S)z�Quote command-line arguments for DOS/Windows conventions.

    Just wraps every argument which contains blanks in double quotes, and
    returns a new argument list.
    � z"%s")�	enumerate)�args�i�argrrr�_nt_quote_args+src
Cs�|d}t|�}|r t|�p|}t�d�|g|dd���|s�zt�tj||�}Wn@tk
r�}z"t	sp|}t
d||jdf��W5d}~XYnX|dkr�t	s�|}t
d||f��dS)Nrrr�command %r failed: %s����%command %r failed with exit status %d)r�find_executabler�info�joinr�spawnv�P_WAIT�OSErrorrrr)rrrr�
executableZrc�excrrrr;s(�
�r�darwinc
Cs|t�d�|��|rdS|d}|r*tjp.tj}d}tjdkr�tdkrxddl	m
}|�d�p^datrxdd�t�d	�D�a
tr�tj�dt�}t
d
d�|�d	�D�kr�d|tf}	t|	��ttj|d�}|r�tjp�tj}t��}
|
dk�r�z$|dkr�|||�n||||�WnNtk
�rX}z.t�s(|}tj�d
||jf�t�d�W5d}~XYnXt�sd|}tj�d|�t�d�n�zt�|
d�\}
}WnDtk
�r�}
z$t�s�|}td||
jdf��W5d}
~
XYnXt�|��rt�s�|}td|t�|�f��nlt� |��rHt�!|�}|dk�r,dSt�s6|}td||f��n,t�"|��rZ�q�nt�sd|}td||f���q�dS)Nrrr&)�	sysconfig�MACOSX_DEPLOYMENT_TARGET�cSsg|]}t|��qSr��int��.0�xrrr�
<listcomp>esz _spawn_posix.<locals>.<listcomp>�.cSsg|]}t|��qSrr*r,rrrr/kszF$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure)r(zunable to execute %r: %s
rz(unable to execute %r for unknown reasonsrrz"command %r terminated by signal %drz1unknown error executing %r: termination status %d)#rrr r�execvp�execv�sys�platform�_cfg_target�	distutilsr'Zget_config_var�split�_cfg_target_split�environ�getr�dict�execvpe�execve�forkr#r�stderr�write�strerror�_exit�waitpidrr�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS�
WIFSTOPPED)rrrrr$Zexec_fn�envr'Z
cur_targetZmy_msg�pid�eZstatusr%Zexit_statusrrrr
Ws�
����
����

����r
c	Cs�tj�|�\}}tjdkr*|dkr*|d}tj�|�r:|S|dkr�tj�dd�}|dkr�zt�d�}Wnt	t
fk
r�tj}YnX|s�dS|�tj
�}|D]&}tj�||�}tj�|�r�|Sq�dS)z�Tries to find 'executable' in the directories listed in 'path'.

    A string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH'].  Returns the complete filename or None if not found.
    Zwin32z.exeN�PATH�CS_PATH)r�path�splitextr3r4�isfiler9r:�confstr�AttributeError�
ValueError�defpathr7�pathsepr )r$rN�_Zext�paths�p�frrrr�s(
r)rrr)rrr)rrr)N)�__doc__r3rZdistutils.errorsrrZdistutils.debugrr6rrrrr4r5r8r
rrrrr�<module>s



RPK32�\�(���A�Accompiler.cpython-38.opt-2.pycnu�[���U

e5dI��@s�ddlZddlZddlZddlTddlmZddlmZddlm	Z	ddl
mZmZddl
mZmZddlmZGd	d
�d
�ZdZddd
�Zdddddd�Zdd�Zddd�Zdd�Zdd�ZdS)�N)�*)�spawn)�	move_file)�mkpath)�newer_pairwise�newer_group)�split_quoted�execute)�logc
@seZdZdZdZdZdZdZdZdZ	dZ
dddddd�ZdddgZdpdd�Z
d	d
�Zdd�Zd
d�Zdd�Zdqdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z drd/d0�Z!d1d2�Z"d3d4�Z#d5d6�Z$d7d8�Z%dsd9d:�Z&dtd;d<�Z'd=d>�Z(dud?d@�Z)dAZ*dBZ+dCZ,dvdDdE�Z-dwdFdG�Z.dxdHdI�Z/dydJdK�Z0dLdM�Z1dNdO�Z2dPdQ�Z3dzdRdS�Z4d{dTdU�Z5d|dWdX�Z6d}dYdZ�Z7d~d[d\�Z8dd^d_�Z9d�dadb�Z:dcdd�Z;dedf�Z<d�dgdh�Z=didj�Z>dkdl�Z?d�dndo�Z@dS)��	CCompilerN�czc++Zobjc)�.cz.ccz.cppz.cxxz.mrcCsb||_||_||_d|_g|_g|_g|_g|_g|_g|_	|j
��D]}|�||j
|�qFdS�N)
�dry_run�force�verbose�
output_dir�macros�include_dirs�	libraries�library_dirs�runtime_library_dirs�objects�executables�keys�set_executable)�selfrrr�key�r�+/usr/lib64/python3.8/distutils/ccompiler.py�__init__UszCCompiler.__init__cKs<|D]2}||jkr&td||jjf��|�|||�qdS)Nz$unknown executable '%s' for class %s)r�
ValueError�	__class__�__name__r)r�kwargsrrrr�set_executablesys

�zCCompiler.set_executablescCs,t|t�rt||t|��nt|||�dSr)�
isinstance�str�setattrr)rr�valuerrrr�s
zCCompiler.set_executablecCs0d}|jD] }|d|kr"|S|d7}q
dS)Nr�)r)r�name�i�defnrrr�_find_macro�s

zCCompiler._find_macrocCs`|D]V}t|t�rFt|�dkrFt|dt�s8|ddkrFt|dt�std|dd��qdS)N)r*�r*rzinvalid macro definition '%s': z.must be tuple (string,), (string, string), or z(string, None))r&�tuple�lenr'�	TypeError)rZdefinitionsr-rrr�_check_macro_definitions�s

��
����z"CCompiler._check_macro_definitionscCs.|�|�}|dk	r|j|=|j�||f�dSr�r.r�append)rr+r)r,rrr�define_macro�s	
zCCompiler.define_macrocCs0|�|�}|dk	r|j|=|f}|j�|�dSrr4)rr+r,Zundefnrrr�undefine_macro�s

zCCompiler.undefine_macrocCs|j�|�dSr)rr5�r�dirrrr�add_include_dir�szCCompiler.add_include_dircCs|dd�|_dSr�r�r�dirsrrr�set_include_dirs�szCCompiler.set_include_dirscCs|j�|�dSr)rr5)r�libnamerrr�add_library�szCCompiler.add_librarycCs|dd�|_dSr)r)rZlibnamesrrr�
set_libraries�szCCompiler.set_librariescCs|j�|�dSr)rr5r8rrr�add_library_dirszCCompiler.add_library_dircCs|dd�|_dSr)rr<rrr�set_library_dirsszCCompiler.set_library_dirscCs|j�|�dSr)rr5r8rrr�add_runtime_library_dirsz!CCompiler.add_runtime_library_dircCs|dd�|_dSr)rr<rrr�set_runtime_library_dirssz"CCompiler.set_runtime_library_dirscCs|j�|�dSr)rr5)r�objectrrr�add_link_object szCCompiler.add_link_objectcCs|dd�|_dSr)r)rrrrr�set_link_objects(szCCompiler.set_link_objectscCs|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|dkr�g}|j|d|d�}t	||�}i}	t
t|��D]B}
||
}||
}tj
�|�d}
|�tj
�|��||
f|	|<q�|||||	fS)N�%'output_dir' must be a string or None�/'macros' (if supplied) must be a list of tuples�6'include_dirs' (if supplied) must be a list of stringsr)�	strip_dirrr*)rr&r'r2r�listrr0�object_filenames�gen_preprocess_options�ranger1�os�path�splitextr�dirname)rZoutdirrZincdirs�sources�dependsZextrar�pp_opts�buildr,�src�obj�extrrr�_setup_compile6s<

��
zCCompiler._setup_compilecCs0|dg}|rdg|dd�<|r,||dd�<|S)Nz-cz-grr)rrW�debugZbefore�cc_argsrrr�_get_cc_argsas
zCCompiler._get_cc_argscCs�|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)NrIrJrK)rr&r'r2rrMrr0)rrrrrrr�_fix_compile_argsjs"


�zCCompiler._fix_compile_argscCs|j||d�}|ifS)N)r)rN)rrUrrVrrrr�
_prep_compile�s	zCCompiler._prep_compilecCsHt|ttf�std��t|�}|dkr.|j}nt|t�s@td��||fS)Nz,'objects' must be a list or tuple of stringsrI)r&rMr0r2rr')rrrrrr�_fix_object_args�s
zCCompiler._fix_object_argscCs�|dkr|j}n*t|ttf�r2t|�|jp,g}ntd��|dkrJ|j}n*t|ttf�rlt|�|jpfg}ntd��|dkr�|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)Nz3'libraries' (if supplied) must be a list of stringsz6'library_dirs' (if supplied) must be a list of stringsz>'runtime_library_dirs' (if supplied) must be a list of strings)rr&rMr0r2rr)rrrrrrr�
_fix_lib_args�s,���zCCompiler._fix_lib_argscCs2|jr
dS|jr t||dd�}n
t||�}|SdS)NT�newer)Zmissing)rrr)rr�output_filerdrrr�
_need_link�s
zCCompiler._need_linkc		Cs~t|t�s|g}d}t|j�}|D]V}tj�|�\}}|j�|�}z |j�	|�}||kr`|}|}Wq"t
k
rvYq"Xq"|Sr)r&rMr1�language_orderrQrRrS�language_map�get�indexr!)	rrUZlangrj�source�baser[ZextlangZextindexrrr�detect_language�s

zCCompiler.detect_languagecCsdSrr)rrkrerr�
extra_preargs�extra_postargsrrr�
preprocess�szCCompiler.preprocessc		Csx|�||||||�\}}	}}
}|�|
||�}|	D]B}
z||
\}}Wntk
r\Yq0YnX|�|
|||||
�q0|	Sr)r\r_�KeyError�_compile)rrUrrrr]rnrorVrrWrXr^rZrYr[rrr�compile�s6��
zCCompiler.compilecCsdSrr)rrZrYr[r^rorWrrrrrCszCCompiler._compilecCsdSrr)rr�output_libnamerr]�target_langrrr�create_static_libIszCCompiler.create_static_libZ
shared_objectZshared_library�
executablecCst�dSr��NotImplementedError)rZtarget_descr�output_filenamerrrr�export_symbolsr]rnro�
build_temprurrr�linkis9zCCompiler.linkc

Cs2|�tj||j|dd�|||||||	|
||�
dS)N�shared)�lib_type)r}r�SHARED_LIBRARY�library_filename)
rrrtrrrrr{r]rnror|rurrr�link_shared_lib�s
�zCCompiler.link_shared_libc

Cs(|�tj|||||||||	|
||�
dSr)r}r�
SHARED_OBJECT)
rrrzrrrrr{r]rnror|rurrr�link_shared_object�s
�zCCompiler.link_shared_objectcCs.|�tj||�|�||||d|||	d|
�
dSr)r}r�
EXECUTABLE�executable_filename)rrZoutput_prognamerrrrr]rnrorurrr�link_executable�s
�zCCompiler.link_executablecCst�dSrrxr8rrr�library_dir_option�szCCompiler.library_dir_optioncCst�dSrrxr8rrr�runtime_library_dir_option�sz$CCompiler.runtime_library_dir_optioncCst�dSrrx)r�librrr�library_option�szCCompiler.library_optionc	Cs�ddl}|dkrg}|dkr g}|dkr,g}|dkr8g}|jd|dd�\}}t�|d�}	z*|D]}
|	�d|
�q^|	�d|�W5|	��Xz|j|g|d�}Wntk
r�Yd	SXz|j|d
||d�Wnt	t
fk
r�Yd	SXdS)Nrr
T)�text�wz#include "%s"
z=int main (int argc, char **argv) {
    %s();
    return 0;
}
r;Fza.out)rr)�tempfileZmkstemprQ�fdopen�close�writersZCompileErrorr�Z	LinkErrorr2)r�funcnameZincludesrrrr��fdZfname�fZinclrrrr�has_function�s<	�

�
zCCompiler.has_functioncCst�dSrrx)rr=r�r]rrr�find_library_file$szCCompiler.find_library_file�cCs�|dkrd}g}|D]|}tj�|�\}}tj�|�d}|tj�|�d�}||jkrftd||f��|rvtj�|�}|�tj�	|||j
��q|S)Nr�r*z"unknown file type '%s' (from '%s'))rQrRrS�
splitdrive�isabs�src_extensionsZUnknownFileError�basenamer5�join�
obj_extension)rZsource_filenamesrLrZ	obj_namesZsrc_namerlr[rrrrNOs"

��zCCompiler.object_filenamescCs$|rtj�|�}tj�|||j�Sr)rQrRr�r��shared_lib_extension�rr�rLrrrr�shared_object_filename`sz CCompiler.shared_object_filenamecCs(|rtj�|�}tj�|||jp"d�S)Nr�)rQrRr�r��
exe_extensionr�rrrr�fszCCompiler.executable_filename�staticc
Cs`|dkrtd��t||d�}t||d�}tj�|�\}}|||f}	|rPd}tj�|||	�S)N)r�r~ZdylibZ
xcode_stubz?'lib_type' must be "static", "shared", "dylib", or "xcode_stub"Z_lib_formatZ_lib_extensionr�)r!�getattrrQrR�splitr�)
rr?rrLrZfmtr[r9rl�filenamerrrr�ls�zCCompiler.library_filenamer*cCst�|�dSr)r
r])r�msg�levelrrr�announceszCCompiler.announcecCsddlm}|rt|�dS)Nr)�DEBUG)Zdistutils.debugr��print)rr�r�rrr�debug_print�szCCompiler.debug_printcCstj�d|�dS)Nzwarning: %s
)�sys�stderrr�)rr�rrr�warn�szCCompiler.warncCst||||j�dSr)r	r)r�func�argsr�r�rrrr	�szCCompiler.executecCst||jd�dS�N)r)rr)r�cmdrrrr�szCCompiler.spawncCst|||jd�Sr�)rr)rrYZdstrrrr�szCCompiler.move_file�cCst|||jd�dSr�)rr)rr+�moderrrr�szCCompiler.mkpath)rrr)N)N)NNNNN)NNNrNNN)NrN)
NNNNNrNNNN)
NNNNNrNNNN)
NNNNNrNNNN)NNNNrNNN)NNNN)r)rr�)rr�)rr�)r�rr�)r*)Nr*)r�)Ar#�
__module__�__qualname__Z
compiler_typer�r�Zstatic_lib_extensionr�Zstatic_lib_formatZshared_lib_formatr�rhrgr r%rr.r3r6r7r:r>r@rArBrCrDrErGrHr\r_r`rarbrcrfrmrprsrrrvr�r�r�r}r�r�r�r�r�r�r�r�rNr�r�r�r�r�r�r	rrrrrrrrs��

$ 

+	 
"
�

�
D�
�
A�
�
�
�
,
+


�


r))zcygwin.*�unix)�posixr�)�nt�msvccCsV|dkrtj}|dkrtj}tD]0\}}t�||�dk	sHt�||�dk	r |Sq dS)Nr�)rQr+r��platform�_default_compilers�re�match)Zosnamer��pattern�compilerrrr�get_default_compiler�s
�
r�)Z
unixccompilerZ
UnixCCompilerzstandard UNIX-style compiler)Z
_msvccompilerZMSVCCompilerzMicrosoft Visual C++)�cygwinccompilerZCygwinCCompilerz'Cygwin port of GNU C Compiler for Win32)r�ZMingw32CCompilerz(Mingw32 port of GNU C Compiler for Win32)ZbcppcompilerZBCPPCompilerzBorland C++ Compiler)r�r��cygwinZmingw32ZbcppcCsXddlm}g}t��D] }|�d|dt|df�q|��||�}|�d�dS)Nr)�FancyGetoptz	compiler=r/zList of available compilers:)Zdistutils.fancy_getoptr��compiler_classrr5�sortZ
print_help)r�Z	compilersr�Zpretty_printerrrr�show_compilers�s
�r�cCs�|dkrtj}z"|dkr t|�}t|\}}}Wn8tk
rhd|}|dk	r\|d|}t|��YnXz*d|}t|�tj|}	t	|	�|}
WnBt
k
r�td|��Yn$tk
r�td||f��YnX|
d||�S)Nz5don't know how to compile C/C++ code on platform '%s'z with '%s' compilerz
distutils.z4can't compile C/C++ code: unable to load module '%s'zBcan't compile C/C++ code: unable to find class '%s' in module '%s')rQr+r�r�rqZDistutilsPlatformError�
__import__r��modules�vars�ImportErrorZDistutilsModuleError)Zplatr�rrrZmodule_name�
class_nameZlong_descriptionr��module�klassrrr�new_compiler�s:
����
r�cCs�g}|D]�}t|t�r0dt|�kr.dks<ntd|��t|�dkr\|�d|d�qt|�dkr|ddkr�|�d|d�q|�d|�q|D]}|�d|�q�|S)	Nr*r/zPbad macro definition '%s': each element of 'macros' list must be a 1- or 2-tuplez-U%srz-D%sz-D%s=%sz-I%s)r&r0r1r2r5)rrrWZmacror9rrrrOs"$��rOcCs�g}|D]}|�|�|��q|D],}|�|�}t|t�rD||}q"|�|�q"|D]V}tj�|�\}}	|r�|�|g|	�}
|
r�|�|
�q�|�	d|�qT|�|�
|��qT|S)Nz6no library file corresponding to '%s' found (skipping))r5r�r�r&rMrQrRr�r�r�r�)r�rrrZlib_optsr9�optr�Zlib_dirZlib_nameZlib_filerrr�gen_lib_options8s&


�r�)NN)NNrrr)r�rQr�Zdistutils.errorsZdistutils.spawnrZdistutils.file_utilrZdistutils.dir_utilrZdistutils.dep_utilrrZdistutils.utilrr	Z	distutilsr
rr�r�r�r�r�rOr�rrrr�<module>s6
�
--PK32�\/h��hDhDmsvc9compiler.cpython-38.pycnu�[���U

e5d/w�@sRdZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
mZddlmZddlmZddlZejZejZejZejZejejejejfZ ej!dko�ej"dkZ#e#r�d	Z$d
Z%dZ&ndZ$d
Z%dZ&ddd�Z'Gdd�d�Z(Gdd�d�Z)dd�Z*dd�Z+dd�Z,dd�Z-d$dd�Z.e*�Z/e/d k�r>ed!e/��Gd"d#�d#e�Z0dS)%adistutils.msvc9compiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio 2008.

The module is compatible with VS 2005 and VS 2008. You can find legacy support
for older versions of VS in distutils.msvccompiler.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�log)�get_platform�win32lz1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fz5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowsz,Software\Wow6432Node\Microsoft\.NETFrameworkz%Software\Microsoft\VisualStudio\%0.1fz)Software\Microsoft\Microsoft SDKs\Windowsz Software\Microsoft\.NETFramework�x86Zamd64�rz	win-amd64c@sPeZdZdZdd�Zee�Zdd�Zee�Zdd�Zee�Zdd	�Ze	e�Zd
S)�Regz2Helper class to read values from the registry
    cCs:tD](}|�||�}|r||kr||Sqt|��dS�N)�HKEYS�read_values�KeyError)�cls�path�key�base�d�r�//usr/lib64/python3.8/distutils/msvc9compiler.py�	get_value@s
z
Reg.get_valuecCsnzt||�}Wntk
r$YdSXg}d}zt||�}Wntk
rTYqjYnX|�|�|d7}q.|S)zReturn list of registry keys.Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)rrr�handle�L�i�krrr�	read_keysHs


z
Reg.read_keysc	Cs�zt||�}Wntk
r$YdSXi}d}zt||�\}}}Wntk
rZYq�YnX|��}|�|�||�|�<|d7}q.|S)z`Return dict of registry keys and values.

        All names are converted to lowercase.
        Nrr)rr�RegEnumValue�lower�convert_mbcs)	rrrr!rr#�name�value�typerrrrZs

zReg.read_valuescCs:t|dd�}|dk	r6z|d�}Wntk
r4YnX|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr(pszReg.convert_mbcsN)
�__name__�
__module__�__qualname__�__doc__r�classmethodr%rr(�staticmethodrrrrr<src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_t||_|�|�dSr)�macros�VS_BASE�vsbase�load_macros)�self�versionrrr�__init__|s
zMacroExpander.__init__cCst�||�|jd|<dS)Nz$(%s))rrr8)r<Zmacrorrrrr�	set_macro�szMacroExpander.set_macroc	Cs|�d|jdd�|�d|jdd�|�dtd�z$|dkrP|�d	td
�ntd
��Wntk
rvtd��YnX|dkr�|�d
|jd�|�dtd�nbd}tD]X}zt||�}Wntk
r�Yq�YnXt	|d�}t
�|d||f�}|d|jd<q�dS)NZVCInstallDirz	\Setup\VC�
productdirZVSInstallDirz	\Setup\VSZFrameworkDirZinstallroot� @ZFrameworkSDKDirzsdkinstallrootv2.0aPython was built with Visual Studio 2008;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2008 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.g"@ZFrameworkVersionzclr versionZ
WindowsSdkDirZcurrentinstallfolderz.Software\Microsoft\NET Framework Setup\Productrz%s\%sr=z$(FrameworkVersion))
r?r:�NET_BASErr�WINSDK_BASErrrrrrr8)r<r=�pr�hrrrrrr;�s2��


zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q
|Sr)r8�items�replace)r<r0r$�vrrr�sub�szMacroExpander.subN)r1r2r3r>r?r;rIrrrrr7zsr7cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|d	d
��d}|dkr�d}|dkr�||SdS)
z�Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    zMSC v.����N� r����
��g$@r)�sysr=�find�len�split�int)�prefixr#r0�restZmajorVersionZminorVersionrrr�get_build_version�srXcCs0g}|D]"}tj�|�}||kr|�|�q|S)znReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    )�osr�normpathr )�pathsZ
reduced_pathsrDZnprrr�normalize_and_reduce_paths�sr\cCs<|�tj�}g}|D]}||kr|�|�qtj�|�}|S)z8Remove duplicate values of an environment variable.
    )rTrY�pathsepr �join)ZvariableZoldListZnewListr#ZnewVariablerrr�removeDuplicates�sr_cCst|}zt�d|d�}Wn"tk
r>t�d�d}YnX|rPtj�|�s�d|}tj	�
|d�}|r�tj�|�r�tj�|tjtjd�}tj�
|�}tj�|�s�t�d|�dSnt�d|�|s�t�d	�dStj�|d
�}tj�|�r�|St�d�dS)z�Find the vcvarsall.bat file

    At first it tries to find the productdir of VS 2008 in the registry. If
    that fails it falls back to the VS90COMNTOOLS env var.
    z%s\Setup\VCr@z%Unable to find productdir in registryNzVS%0.f0COMNTOOLSZVCz%s is not a valid directoryz Env var %s is not set or invalidzNo productdir foundz
vcvarsall.bat�Unable to find vcvarsall.bat)r9rrrr
�debugrYr�isdir�environ�getr^�pardir�abspath�isfile)r=r:r@ZtoolskeyZtoolsdir�	vcvarsallrrr�find_vcvarsall�s4
�



ricCs8t|�}ddddh}i}|dkr(td��t�d||�tjd||ftjtjd	�}z�|�
�\}}|��d
krzt|�d���|�d�}|�
d�D]d}t�|�}d
|kr�q�|��}|�
d
d�\}	}
|	��}	|	|kr�|
�tj�r�|
dd�}
t|
�||	<q�W5|j��|j	��Xt|�t|�k�r4ttt|������|S)zDLaunch vcvarsall.bat and read the settings from its environment
    �include�libZlibpathrNr`z'Calling 'vcvarsall.bat %s' (version=%s)z
"%s" %s & set)�stdout�stderrrr-�
�=rrJ)rirr
ra�
subprocess�Popen�PIPErl�closermZcommunicate�waitr,rTrr(�stripr'�endswithrYr]r_rS�
ValueError�str�list�keys)r=ZarchrhZinteresting�result�popenrlrm�linerr*rrr�query_vcvarsall�s>�


r~rAz(VC %0.1f is not supported by this modulec
@s�eZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd.dd�Zd/dd�Zd0dd�Zd1dd�Zd2dd�Zd3dd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd4d*d+�Zd,d-�ZdS)5�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs8t�||||�t|_d|_g|_d|_d|_d|_dS)NzSoftware\Microsoft\VisualStudioF)	rr>�VERSION�_MSVCCompiler__versionZ_MSVCCompiler__root�_MSVCCompiler__paths�	plat_name�_MSVCCompiler__arch�initialized)r<�verboseZdry_runZforcerrrr>IszMSVCCompiler.__init__NcCs(|jrtd��|dkrt�}d}||kr6td|f��dtjkrtdtjkrt|�d�rtd|_d|_d|_	d	|_
d
|_n�|t�ks�|dkr�t|}ntt�dt|}t
t|�}|d
�tj�|_|dtjd<|dtjd<t|j�dkr�td|j��|�d�|_|�d�|_|�d�|_	|�d	�|_
|�d
�|_z(tjd
�d�D]}|j�|��qHWntk
�rtYnXt|j�|_d�|j�tjd
<d|_|jdk�r�dddddg|_ddddddg|_n&ddddddg|_dddddddg|_dddg|_|jd k�rddd!d"g|_dg|_d#|_dS)$Nzdon't init multiple timesrz--plat-name must be one of %sZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer�_rrkrjrzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�;r
z/nologoz/Oxz/MDz/W3z/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NO�z/INCREMENTAL:noz/DEBUGT) r��AssertionErrorrrrYrc�find_exe�cc�linkerrk�rc�mc�PLAT_TO_VCVARSr~r�rTr]r�rSZ_MSVCCompiler__productr rr\r^Zpreprocess_optionsr��compile_options�compile_options_debug�ldflags_sharedr��ldflags_shared_debugZldflags_static)r<r�Zok_platsZ	plat_specZvc_envrDrrr�
initializeTs��
�
���
�
��zMSVCCompiler.initialize�cCs�|dkrd}g}|D]�}tj�|�\}}tj�|�d}|tj�|�d�}||jkrbtd|��|rrtj�|�}||jkr�|�	tj�
|||j��q||jkr�|�	tj�
|||j��q|�	tj�
|||j
��q|S)Nr�rzDon't know how to compile %s)rYr�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsr r^�
res_extension�_mc_extensions�
obj_extension)r<Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames�s.

�
��zMSVCCompiler.object_filenamesc	Csp|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�|
D�]}z||\}}Wntk
r�YqdYnX|r�tj	�
|�}||jkr�d|}�nT||jkr�d|}�n>||j
k�r<|}d|}z"|�|jg||g|g�Wqdtk
�r6}zt|��W5d}~XYqdXqdn�||jk�r�tj	�|�}tj	�|�}zl|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wqdtk
�r�}zt|��W5d}~XYqdXqdntd||f��d	|}z&|�|jg|
|||g|�Wqdtk
�rh}zt|��W5d}~XYqdXqd|
S)
Nz/cz/Tcz/Tpz/foz-hz-rr�z"Don't know how to compile %s to %sz/Fo)r�r�Z_setup_compiler �extendr�r�rrYrrf�
_c_extensions�_cpp_extensionsr��spawnr�rrr��dirnamer�r�r�r^r�)r<Zsourcesr�r8Zinclude_dirsra�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcr�Z	input_optZ
output_opt�msgZh_dirZrc_dirrr�Zrc_filerrr�compile�s�
�




��


��
��
���
zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz|�|jg|�Wq�tk
r�}zt|��W5d}~XYq�Xnt	�
d|�dS)N)r��/OUT:�skipping %s (up-to-date))r�r��_fix_object_args�library_filename�
_need_linkr�rkrrr
ra)	r<r�Zoutput_libnamer�ra�target_lang�output_filenameZlib_argsr�rrr�create_static_libs�zMSVCCompiler.create_static_libc
CsT|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��rD|tjkr�|	r�|j
dd�}q�|jdd�}n|	r�|j
}n|j}g}|p�gD]}|�d|�q�||||d|g}tj�|d�}|dk	�rLtj�tj�|��\}}tj�	||�|��}|�d|�|�|||�|
�rl|
|dd�<|�r||�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnX|�||�}|dk	�rP|\}}d||f}z|�dd	d
||g�Wn,tk
�r@}zt|��W5d}~XYnXnt�d|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:r�rz/IMPLIB:z-outputresource:%s;%szmt.exez-nologoz	-manifestr�)r�r�r�Z
_fix_lib_args�warnrxr	rYrr^r�r�
EXECUTABLEr�r�r r�r�r�r��manifest_setup_ldargsr�Zmkpathr�r�rr�manifest_get_embed_infor
ra)r<�target_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrar�r��
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsym�ld_argsZdll_nameZdll_extZimplib_filer�ZmfinfoZ
mffilename�mfidZout_argrrr�link6s��
��

��

��


�
zMSVCCompiler.linkcCs,tj�|tj�|�d�}|�d|�dS)Nz	.manifest�/MANIFESTFILE:)rYrr^r�r )r<r�r�r��
temp_manifestrrrr��s
�z"MSVCCompiler.manifest_setup_ldargscCs^|D]"}|�d�r|�dd�d}q,qdS|tjkr<d}nd}|�|�}|dkrVdS||fS)Nr��:rrO)�
startswithrTrr��_remove_visual_c_ref)r<r�r��argr�r�rrrr��s


z$MSVCCompiler.manifest_get_embed_infocCs�z�t|�}z|��}W5|��Xt�dtj�}t�|d|�}d}t�|d|�}t�dtj�}t�||�dkrtWdSt|d�}z|�|�|W�WS|��XWnt	k
r�YnXdS)NzU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)r�z*<dependentAssembly>\s*</dependentAssembly>zI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)�w)
�openrs�read�rer��DOTALLrI�search�write�OSError)r<Z
manifest_fileZ
manifest_fZmanifest_buf�patternrrrr��s2	
��


z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz	/LIBPATH:r�r<�dirrrr�library_dir_option�szMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)rr�rrr�runtime_library_dir_option�s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�Sr)r�)r<rkrrr�library_option�szMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rYrr^r��exists)r<�dirsrkraZ	try_namesr�r)Zlibfilerrr�find_library_file�szMSVCCompiler.find_library_filecCsz|jD].}tj�tj�|�|�}tj�|�r|Sqtjd�d�D].}tj�tj�|�|�}tj�|�rF|SqF|S)a�Return path to an MSVC executable program.

        Tries to find the program in several places: first, one of the
        MSVC program search paths from the registry; next, the directories
        in the PATH environment variable.  If any of those work, return an
        absolute path that is known to exist.  If none of them work, just
        return the original program name, 'exe'.
        �Pathr�)r�rYrr^rfrgrcrT)r<ZexerD�fnrrrr�s	


zMSVCCompiler.find_exe)rrr)N)rr�)NNNrNNN)NrN)
NNNNNrNNNN)r) r1r2r3r4Z
compiler_typeZexecutablesr�r�r�r�r�r�r�Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr>r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr+sl
��

W�
 �
X�
�
_+
r)r
)1r4rYrprQr�Zdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
Zdistutils.utilr�winregZ	OpenKeyExrZEnumKeyrZ	EnumValuer&�errorrZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr�platform�maxsizeZNATIVE_WIN64r9rCrBr�rr7rXr\r_rir~r�rrrrr�<module>sP��>.#
)
PK32�\6��1�2�2_msvccompiler.cpython-38.pycnu�[���U

e5dRN�@s�dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZddlm
Z
mZddlmZddlmZddlmZdd	�Zd
d�Zdd
ddd�Zdd�Zdd�Zddd�Zddddd�ZGdd�de
�ZdS)adistutils._msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for Microsoft Visual Studio 2015.

The module is compatible with VS 2015 and later. You can find legacy support
for older versions in distutils.msvc9compiler and distutils.msvccompiler.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_lib_options)�log)�get_platform)�countcCsztjtjdtjtjBd�}Wn tk
r>t�d�YdSXd}d}|��t�D]�}zt�	||�\}}}Wntk
r�Yq�YnX|rT|tj
krTtj�
|�rTztt|��}Wnttfk
r�YqTYnX|dkrT||krT||}}qTW5QRX||fS)Nz'Software\Microsoft\VisualStudio\SxS\VC7)�accesszVisual C++ is not registered�NNr�)�winregZ	OpenKeyEx�HKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEY�OSErrorr	�debugrZ	EnumValueZREG_SZ�os�path�isdir�int�float�
ValueError�	TypeError)�key�best_version�best_dir�i�vZvc_dirZvt�version�r �//usr/lib64/python3.8/distutils/_msvccompiler.py�_find_vc2015s2
�



r"c
Cs�ddl}tj�d�ptj�d�}|s(dSz8tjtj�|ddd�d	d
ddd
dddg	ddd���}Wntj	t
tfk
r~YdSXtj�|ddd�}tj�|�r�d|fSdS)aJReturns "15, path" based on the result of invoking vswhere.exe
    If no install is found, returns "None, None"

    The version is returned to avoid unnecessarily changing the function
    result. It may be ignored when the path is not None.

    If vswhere.exe is not available, by definition, VS 2017 is not
    installed.
    rNzProgramFiles(x86)ZProgramFilesr
zMicrosoft Visual StudioZ	Installerzvswhere.exez-latestz-prereleasez	-requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z	-propertyZinstallationPathz	-products�*�mbcs�strict)�encoding�errorsZVCZ	AuxiliaryZBuild�)
�jsonr�environ�get�
subprocess�check_outputr�join�strip�CalledProcessErrorr�UnicodeDecodeErrorr)r)�rootrr r r!�_find_vc2017:s2
��r3�x86Zx64ZarmZarm64)r4�	x86_amd64�x86_arm�	x86_arm64cCs\t�\}}|st�\}}|s*t�d�dStj�|d�}tj�|�sTt�d|�dS|dfS)Nz$No suitable Visual C++ version foundr
z
vcvarsall.batz%s cannot be found)r3r"r	rrrr.�isfile)�	plat_spec�_rr�	vcvarsallr r r!�_find_vcvarsallcs


r<c
Cs�t�d�rdd�tj��D�St|�\}}|s6td��z&tjd�||�tj	d�j
ddd	�}Wn@tjk
r�}z t�
|j�td
�|j���W5d}~XYnXdd�dd
�|��D�D�}|S)NZDISTUTILS_USE_SDKcSsi|]\}}|��|�qSr ��lower)�.0r�valuer r r!�
<dictcomp>ws�z_get_vc_env.<locals>.<dictcomp>zUnable to find vcvarsall.batzcmd /u /c "{}" {} && set)�stderrzutf-16le�replace)r'zError executing {}cSs$i|]\}}}|r|r|��|�qSr r=)r?rr:r@r r r!rA�s
�css|]}|�d�VqdS)�=N)�	partition)r?�liner r r!�	<genexpr>�sz_get_vc_env.<locals>.<genexpr>)r�getenvr*�itemsr<rr,r-�formatZSTDOUT�decoder0r	�error�output�cmd�
splitlines)r9r;r:�out�exc�envr r r!�_get_vc_envus0
�
��
��rScCsN|st�d��tj�}|D].}tj�tj�|�|�}tj�|�r|Sq|S)atReturn path to an MSVC executable program.

    Tries to find the program in several places: first, one of the
    MSVC program search paths from the registry; next, the directories
    in the PATH environment variable.  If any of those work, return an
    absolute path that is known to exist.  If none of them work, just
    return the original program name, 'exe'.
    r)rrH�split�pathseprr.�abspathr8)Zexe�paths�p�fnr r r!�	_find_exe�s	
rZr5r6r7)Zwin32z	win-amd64z	win-arm32z	win-arm64c
s�eZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd(dd�Zd)dd�Zd*dd�Zd+dd�Zd,dd�Zd-dd�Z�fdd�Zd d!�Zd"d#�Zd$d%�Zd.d&d'�Z�ZS)/�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs t�||||�d|_d|_dS)NF)r�__init__�	plat_name�initialized)�self�verboseZdry_runZforcer r r!r]�szMSVCCompiler.__init__NcCs
|jrtd��|dkrt�}|tkr6td�tt����t|}t|�}|sRtd��|�dd�|_	|j	�
tj�}t
d|�|_t
d|�|_t
d|�|_t
d	|�|_t
d
|�|_t
d|�|_|�dd��
tj�D]}|r�|�|�tj��q�|�d
d��
tj�D]}|r�|�|�tj��q�d|_ddddddg|_ddddddg|_dddg}ddddg}|d!�|_|d"�|_|d#�|_|d$�|_|�|_|�|_ t!j"df|jt!j"df|jt!j"d f|jt!j#df|jt!j#df|jt!j#d f|jt!j$df|jt!j$df|jt!j$d f|j i	|_%d |_dS)%Nzdon't init multiple timesz--plat-name must be one of {}z7Unable to find a compatible Visual Studio installation.r�zcl.exezlink.exezlib.exezrc.exezmc.exezmt.exeZinclude�libz/nologoz/Oxz/W3z/GLz/DNDEBUGz/MDz/Odz/MDdz/Ziz/D_DEBUGz/INCREMENTAL:NOz/LTCGz/DEBUG:FULL�/MANIFEST:EMBED,ID=1�/DLL�/MANIFEST:EMBED,ID=2�/MANIFESTUAC:NOFT)rd)rd)rerfrg)rerfrg)&r_�AssertionErrorr
�PLAT_TO_VCVARSrrJ�tuplerSr+�_pathsrTrrUrZ�cc�linkerrc�rc�mcZmtZadd_include_dir�rstrip�sepZadd_library_dirZpreprocess_options�compile_options�compile_options_debugZldflags_exeZldflags_exe_debugZldflags_sharedZldflags_shared_debugZldflags_staticZldflags_static_debugrZ
EXECUTABLEZ
SHARED_OBJECTZSHARED_LIBRARY�_ldflags)r`r^r9Zvc_envrW�dir�ldflagsZ
ldflags_debugr r r!�
initialize�s������



�zMSVCCompiler.initializerbcsT�fdd��jD��fdd��j�jD����p4d����fdd�}tt||��S)Ncsi|]}|�j�qSr )�
obj_extension�r?�ext�r`r r!rA&sz1MSVCCompiler.object_filenames.<locals>.<dictcomp>csi|]}|�j�qSr )�
res_extensionryr{r r!rA'srbcs�tj�|�\}}�r"tj�|�}n2tj�|�\}}|�tjjtjjf�rT|dd�}ztj��|�|�WSt	k
r�t
d�|���YnXdS)N�zDon't know how to compile {})rr�splitext�basename�
splitdrive�
startswithrq�altsepr.�LookupErrorrrJ)rX�baserzr:)�ext_map�
output_dir�	strip_dirr r!�
make_out_path,sz4MSVCCompiler.object_filenames.<locals>.make_out_path)�src_extensions�_rc_extensions�_mc_extensions�list�map)r`Zsource_filenamesr�r�r�r )r�r�r`r�r!�object_filenames!s�zMSVCCompiler.object_filenamesc	Cs�|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�d}|
D�]}z||\}}Wntk
r�YqhYnX|r�tj	�
|�}||jkr�d|}�nD||jkr�d|}d}�n*||j
k�r@|}d|}z|�|jg|||g�Wqhtk
�r:}zt|��W5d}~XYqhXqhn�||jk�r�tj	�|�}tj	�|�}z\|�|jd|d||g�tj	�tj	�|��\}}tj	�||d	�}|�|jd||g�Wqhtk
�r�}zt|��W5d}~XYqhXqhntd
�||���|jg|
|}|�r"|�d�|�|�|�d|�|�|�z|�|�Wqhtk
�r~}zt|��W5d}~XYqhXqh|
S)
Nz/cFz/Tcz/TpTz/foz-hz-rr\z"Don't know how to compile {} to {}z/EHscz/Fo)r_rwZ_setup_compile�append�extendrsrr�KeyErrorrrrV�
_c_extensions�_cpp_extensionsr��spawnrnrrr��dirnameror~rr.rJrl)r`Zsourcesr�ZmacrosZinclude_dirsr�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_optsZadd_cpp_opts�obj�srcrzZ	input_optZ
output_opt�msgZh_dirZrc_dirr�r:Zrc_file�argsr r r!�compileBsx
�




�


zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz,t�d|jd�|��|�	|jg|�Wq�t
k
r�}zt|��W5d}~XYq�Xnt�d|�dS)N)r��/OUT:�Executing "%s" %s� �skipping %s (up-to-date))r_rw�_fix_object_args�library_filename�
_need_linkr	rrcr.r�rr)	r`r�Zoutput_libnamer�r�target_lang�output_filenameZlib_argsr�r r r!�create_static_lib�s�zMSVCCompiler.create_static_libc
Cs�|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��r�|j||	f}dd�|p�gD�}||||d|g}tj�|d�}|dk	�rtj�
tj�|��\}}tj�	||�|��}|�d|�|
�r|
|dd�<|�r.|�|�tj�tj�|��}|�|�z,t�d|jd�	|��|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d	|�dS)
Nz5I don't know what to do with 'runtime_library_dirs': cSsg|]}d|�qS)z/EXPORT:r )r?Zsymr r r!�
<listcomp>�sz%MSVCCompiler.link.<locals>.<listcomp>r�rz/IMPLIB:r�r�r�)r_rwr�Z
_fix_lib_args�warn�strrrrr.r�rtr�r~rr�r�r�rVZmkpathr	rrmr�rr)r`Ztarget_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrr�r�Z
build_tempr�Z
fixed_argsZlib_optsrvZexport_optsZld_argsZdll_nameZdll_extZimplib_filer�r r r!�link�s`�
��
��

��

zMSVCCompiler.linkc	s8t�d�}z|jtjd<t��|�W�S|tjd<XdS)Nr)rrHr*rk�superr�)r`rNZold_path��	__class__r r!r��s

zMSVCCompiler.spawncCsd|S)Nz	/LIBPATH:r �r`rur r r!�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz:don't know how to set runtime library search path for MSVC)rr�r r r!�runtime_library_dir_option
s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�S)N)r�)r`rcr r r!�library_optionszMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rrr.r�r8)r`�dirsrcrZ	try_namesru�nameZlibfiler r r!�find_library_fileszMSVCCompiler.find_library_file)rrr)N)rrb)NNNrNNN)NrN)
NNNNNrNNNN)r)�__name__�
__module__�__qualname__�__doc__Z
compiler_typeZexecutablesr�r�r�r�r�r|rxZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr]rwr�r�r�r�r�r�r�r�r��
__classcell__r r r�r!r[�sf
��

P�
"�
]�
�
Er[)N)r�rZshutil�statr,rZdistutils.errorsrrrrrZdistutils.ccompilerrrZ	distutilsr	Zdistutils.utilr
�	itertoolsrr"r3ZPLAT_SPEC_TO_RUNTIMEr<rSrZrir[r r r r!�<module>s4#�
�PK32�\�Z@+n/n/sysconfig.cpython-38.pycnu�[���U

��.eP�@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ej
�ej�Z
ej
�ej�Zej
�ej�Zej
�ej�Zdejkr�ej
�ejd�Zn&ejr�ej
�ej
�ej��Zne��Zdd�Zeed	d�Zejd
kr�dd�Zee�Zee�Zd
d�Ze�Z dZ!ze �sej"Z!Wne#k
�r*YnXdd�Z$d-dd�Z%d.dd�Z&dd�Z'dd�Z(dd�Z)d/dd�Z*e�+d�Z,e�+d�Z-e�+d �Z.d0d!d"�Z/d#d$�Z0da1d%d&�Z2d'd(�Z3d)d*�Z4d+d,�Z5dS)1a�Provide access to Python's configuration information.  The specific
configuration variables available depend heavily on the platform and
configuration.  The values may be retrieved using
get_config_var(name), and the list of variables is available via
get_config_vars().keys().  Additional convenience functions are also
available.

Written by:   Fred L. Drake, Jr.
Email:        <fdrake@acm.org>
�N�)�DistutilsPlatformError)�get_platform�get_host_platformZ_PYTHON_PROJECT_BASEcCs,dD]"}tj�tj�|d|��rdSqdS)N)ZSetupzSetup.localZModulesTF)�os�path�isfile�join)�d�fn�r�+/usr/lib64/python3.8/distutils/sysconfig.py�_is_python_source_dir+sr�_home�ntcCs0|r,tj�|��tj�tj�td���r,tS|S)NZPCbuild)rr�normcase�
startswithr	�PREFIX)r
rrr
�_fix_pcbuild4s
�rcCstrtt�Stt�S)N)�	_sys_homer�project_baserrrr
�
_python_build<sr�cCsdtjdd�S)z�Return a string containing the major and minor Python version,
    leaving off the patchlevel.  Sample return values could be '1.5'
    or '2.2'.
    z%d.%dN�)�sys�version_inforrrr
�get_python_versionPsrcCs�|dkr|rtpt}tjdkrjtrL|r.tp,tStj�t	d�d�}tj�
|�Sdt�t}tj�|d|�Stjdkr�tr�tj�|d�tjj
tj�|d�Stj�|d�Std	tj��dS)
a�Return the directory containing installed Python header files.

    If 'plat_specific' is false (the default), this is the path to the
    non-platform-specific header files, i.e. Python.h and so on;
    otherwise, this is the path to platform-specific header files
    (namely pyconfig.h).

    If 'prefix' is supplied, use it instead of sys.base_prefix or
    sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
    N�posix�srcdirZInclude�pythonZincluder�PCzFI don't know where Python installs its C header files on platform '%s')�BASE_EXEC_PREFIX�BASE_PREFIXr�name�python_buildrrrr	�get_config_var�normpathr�build_flags�pathsepr)�
plat_specific�prefixZincdirZ
python_dirrrr
�get_python_incXs*

���r+cCs�|dkr&|r|rtpt}n|r"tp$t}tjdkrp|s8|r>d}nd}tj�||dt��}|r`|Stj�|d�Sn<tjdkr�|r�tj�|d�Stj�|dd�Snt	d	tj��dS)
aSReturn the directory containing the Python library (standard or
    site additions).

    If 'plat_specific' is true, return the directory containing
    platform-specific modules, i.e. any module from a non-pure-Python
    module distribution; otherwise, return the platform-shared library
    directory.  If 'standard_lib' is true, return the directory
    containing standard Python library modules; otherwise, return the
    directory for site-specific modules.

    If 'prefix' is supplied, use it instead of sys.base_prefix or
    sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
    Nr�lib64�librz
site-packagesrZLibz?I don't know where Python installs its library on platform '%s')
r!r"�EXEC_PREFIXrrr#rr	rr)r)�standard_libr*r-Z	libpythonrrr
�get_python_lib�s0
�
��r0c	Cs�|jdk�r�tjdkr8td�s8ddl}|�t�dtd<tddd	d
ddd
d�\}}}}}}}}	dtj	kr�tj	d}
tjdkr�dtj	kr�|�
|�r�|
|t|�d�}|
}dtj	kr�tj	d}dtj	kr�tj	d}dtj	kr�tj	d}n|d}dtj	k�r|dtj	d}d	tj	k�r<|dtj	d	}|dtj	d	}dtj	k�r~|dtj	d}|dtj	d}|dtj	d}d
tj	k�r�tj	d
}dtj	k�r�|dtj	d}n|d|	}|d|}
|j||
|
d|||||d�||_
dS)z�Do any platform-specific customization of a CCompiler instance.

    Mainly needed on Unix, so we can plug in the information that
    varies across Unices and is stored in Python's Makefile.
    Zunix�darwinZCUSTOMIZED_OSX_COMPILERrN�TrueZCCZCXX�CFLAGSZCCSHAREDZLDSHAREDZSHLIB_SUFFIXZARZARFLAGSZCPPz -E�LDFLAGS� �CPPFLAGS)Zpreprocessor�compilerZcompiler_soZcompiler_cxxZ	linker_soZ
linker_exe�archiver)Z
compiler_typer�platformr%�_osx_support�customize_compiler�_config_vars�get_config_varsr�environr�lenZset_executablesZshared_lib_extension)r7r:ZccZcxxZcflagsZccsharedZldsharedZshlib_suffixZarZar_flagsZnewccZcppr8Zcc_cmdrrr
r;�sn

��


��






�	r;cCsDtr,tjdkr"tj�tptd�}q6tp(t}n
tdd�}tj�|d�S)z2Return full pathname of installed pyconfig.h file.rr r�r)z
pyconfig-64.h)r$rr#rr	rrr+)Zinc_dirrrr
�get_config_h_filename�s


rAcCs\trtj�tptd�Stddd�}d�t�t	�}t
tjd�rL|dtjj
7}tj�||d�S)zAReturn full pathname of installed Makefile from the Python build.ZMakefilerr�r)r/zconfig-{}{}�
_multiarchz-%s)r$rrr	rrr0�formatrr'�hasattrr�implementationrC)Zlib_dirZconfig_filerrr
�get_makefile_filenamesrGcCs�|dkri}t�d�}t�d�}|��}|s.q�|�|�}|rx|�dd�\}}zt|�}Wntk
rlYnX|||<q |�|�}|r d||�d�<q |S)z�Parse a config.h-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    Nz"#define ([A-Z][A-Za-z0-9_]+) (.*)
z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/
rrr)�re�compile�readline�match�group�int�
ValueError)�fp�gZ	define_rxZundef_rx�line�m�n�vrrr
�parse_config_hs&




rUz"([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)z\$\(([A-Za-z][A-Za-z0-9_]*)\)z\${([A-Za-z][A-Za-z0-9_]*)}c	Cs�ddlm}||ddddd�}|dkr*i}i}i}|��}|dkrDq�t�|�}|r2|�dd�\}}	|	��}	|	�dd	�}
d
|
kr�|	||<q2zt|	�}	Wn$t	k
r�|	�dd
�||<Yq2X|	||<q2d}|�rtt
|�D�]�}||}
t�|
�p�t
�|
�}|�rj|�d�}d}||k�r$t||�}n�||k�r4d
}nx|tjk�rLtj|}n`||k�r�|�d��rz|dd�|k�rzd	}n$d||k�r�d
}nt|d|�}nd	||<}|�rp|
|��d�}|
d|���||}
d
|k�r�|
||<nzzt|
�}
Wn"t	k
�r|
��||<Yn
X|
||<||=|�d��rp|dd�|k�rp|dd�}||k�rp|
||<q�||=q�q�|��|��D]"\}}	t|	t��r�|	��||<�q�|�|�|S)z�Parse a Makefile-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    r)�TextFiler�surrogateescape)Zstrip_commentsZskip_blanksZ
join_lines�errorsNrz$$r�$)r3r4r6TFZPY_�)Zdistutils.text_filerVrJ�_variable_rxrKrL�strip�replacerMrN�list�_findvar1_rx�search�_findvar2_rx�strrr>r�end�start�close�items�
isinstance�update)rrPrVrOZdoneZnotdonerQrRrSrTZtmpvZrenamed_variablesr#�value�found�itemZafter�krrr
�parse_makefile/s�








�



rmcCsVt�|�pt�|�}|rR|��\}}|d|�|�|�d��||d�}qqRq|S)a�Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
    'string' according to 'vars' (a dictionary mapping variable names to
    values).  Variables not present in 'vars' are silently expanded to the
    empty string.  The variable values in 'vars' should not contain further
    variable expansions; if 'vars' is the output of 'parse_makefile()',
    you're fine.  Returns a variable-expanded version of 's'.
    rrN)r_r`ra�span�getrL)�s�varsrRZbegrcrrr
�expand_makefile_vars�s*rrc
CsVtj�ddjtjtjttjdd�d��}t	|t
�t�dgd�}|j}ia
t
�|�dS)	z7Initialize the module as appropriate for POSIX systems.Z_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}rCr)Zabir9Z	multiarch�build_time_varsrN)rr>rorDr�abiflagsr9�getattrrF�
__import__�globals�localsrsr<rh)r#Z_temprsrrr
�_init_posix�s��rycCs~i}tddd�|d<tddd�|d<tdd�|d<t��d|d<d	|d
<t��dd�|d
<tj�tj�	t
j��|d<|adS)z+Initialize the module as appropriate for NTrrrBZLIBDESTZ
BINLIBDESTr@Z	INCLUDEPY�
EXT_SUFFIXz.exeZEXE�.rZVERSIONZBINDIRN)
r0r+�_imp�extension_suffixesrr]rr�dirname�abspathr�
executabler<)rPrrr
�_init_nt�sr�cGs\tdk�r*t��dtj�}|r(|�niattd<ttd<t�d�}|dk	rV|td<t�dt�}tjdkr�tr�tj	�
t��}tj	�||�}ntj	�
t��}tj	�
tj	�|��td<t�rtjdk�rt}tj	�td��s|t��k�rtj	�|td�}tj	�|�td<tjd	k�r*d
dl}|�t�|�rTg}|D]}|�t�|���q8|StSdS)a�With no arguments, return a dictionary of all configuration
    variables relevant for the current platform.  Generally this includes
    everything needed to build extensions and install both pure modules and
    extensions.  On Unix, this means every variable defined in Python's
    installed Makefile; on Windows it's a much smaller set.

    With arguments, return a list of values that result from looking up
    each argument in the configuration variable dictionary.
    NZ_init_r*�exec_prefixrz�SOrrr1r)r<rwrorr#rr.rr$rr~rGr	rr&�isabs�getcwdrr9r:Zcustomize_config_vars�append)�args�funcr�r�baser:Zvalsr#rrr
r=�sB



�
r=cCs*|dkrddl}|�dtd�t��|�S)z�Return the value of a single variable using the dictionary
    returned by 'get_config_vars()'.  Equivalent to
    get_config_vars().get(name)
    r�rNz SO is deprecated, use EXT_SUFFIXr)�warnings�warn�DeprecationWarningr=ro)r#r�rrr
r%!sr%)rN)rrN)N)N)6�__doc__r|rrHrrXr�utilrrrr&r*rr�r.�base_prefixr"�base_exec_prefixr!r>rrr�r~r�rrurr#rrr$r'rt�AttributeErrorrr+r0r;rArGrUrIr[r_rarmrrr<ryr�r=r%rrrr
�<module>s\



(
+I





jJPK32�\�v��
�
dep_util.cpython-38.opt-1.pycnu�[���U

e5d�
�@s6dZddlZddlmZdd�Zdd�Zdd	d
�ZdS)z�distutils.dep_util

Utility functions for simple, timestamp-based dependency of files
and groups of files; also, function based entirely on such
timestamp dependency analysis.�N)�DistutilsFileErrorcCs`tj�|�s tdtj�|���tj�|�s0dSddlm}t�|�|}t�|�|}||kS)aReturn true if 'source' exists and is more recently modified than
    'target', or if 'source' exists and 'target' doesn't.  Return false if
    both exist and 'target' is the same age or younger than 'source'.
    Raise DistutilsFileError if 'source' does not exist.
    zfile '%s' does not exist�r��ST_MTIME)�os�path�existsr�abspath�statr)�source�targetrZmtime1Zmtime2�r
�*/usr/lib64/python3.8/distutils/dep_util.py�newers
�rcCsht|�t|�krtd��g}g}tt|��D]2}t||||�r,|�||�|�||�q,||fS)z�Walk two filename lists in parallel, testing if each source is newer
    than its corresponding target.  Return a pair of lists (sources,
    targets) where source is newer than target, according to the semantics
    of 'newer()'.
    z+'sources' and 'targets' must be same length)�len�
ValueError�ranger�append)�sourcesZtargetsZ	n_sourcesZ	n_targets�ir
r
r�newer_pairwise sr�errorcCs�tj�|�sdSddlm}t�|�|}|D]P}tj�|�sb|dkrHn|dkrTq.n|dkrbdSt�|�|}||kr.dSq.dS)a�Return true if 'target' is out-of-date with respect to any file
    listed in 'sources'.  In other words, if 'target' exists and is newer
    than every file in 'sources', return false; otherwise return true.
    'missing' controls what we do when a source file is missing; the
    default ("error") is to blow up with an OSError from inside 'stat()';
    if it is "ignore", we silently drop any missing source files; if it is
    "newer", any missing source files make us assume that 'target' is
    out-of-date (this is handy in "dry-run" mode: it'll make you pretend to
    carry out commands that wouldn't work because inputs are missing, but
    that doesn't matter because you're not actually going to run the
    commands).
    rrrr�ignorerN)rrrr
r)rrZmissingrZtarget_mtimer�source_mtimer
r
r�newer_group6s r)r)�__doc__rZdistutils.errorsrrrrr
r
r
r�<module>s
PK32�\��˰��spawn.cpython-38.opt-2.pycnu�[���U

e5d��@s~ddlZddlZddlmZmZddlmZddlmZddd�Z	dd	�Z
dd
d�Zejdkrfda
dadd
d�Zddd�ZdS)�N)�DistutilsPlatformError�DistutilsExecError)�DEBUG)�log�cCsNt|�}tjdkr"t|||d�n(tjdkr<t|||d�ntdtj��dS)N�posix)�dry_run�ntz1don't know how to spawn programs on platform '%s')�list�os�name�_spawn_posix�	_spawn_ntr)�cmd�search_path�verboser�r�'/usr/lib64/python3.8/distutils/spawn.py�spawns

�rcCs*t|�D]\}}d|krd|||<q|S)N� z"%s")�	enumerate)�args�i�argrrr�_nt_quote_args+src
Cs�|d}t|�}|r t|�p|}t�d�|g|dd���|s�zt�tj||�}Wn@tk
r�}z"t	sp|}t
d||jdf��W5d}~XYnX|dkr�t	s�|}t
d||f��dS)Nrrr�command %r failed: %s����%command %r failed with exit status %d)r�find_executabler�info�joinr�spawnv�P_WAIT�OSErrorrrr)rrrr�
executableZrc�excrrrr;s(�
�r�darwinc
Cs|t�d�|��|rdS|d}|r*tjp.tj}d}tjdkr�tdkrxddl	m
}|�d�p^datrxdd�t�d	�D�a
tr�tj�dt�}t
d
d�|�d	�D�kr�d|tf}	t|	��ttj|d�}|r�tjp�tj}t��}
|
dk�r�z$|dkr�|||�n||||�WnNtk
�rX}z.t�s(|}tj�d
||jf�t�d�W5d}~XYnXt�sd|}tj�d|�t�d�n�zt�|
d�\}
}WnDtk
�r�}
z$t�s�|}td||
jdf��W5d}
~
XYnXt�|��rt�s�|}td|t�|�f��nlt� |��rHt�!|�}|dk�r,dSt�s6|}td||f��n,t�"|��rZ�q�nt�sd|}td||f���q�dS)Nrrr&)�	sysconfig�MACOSX_DEPLOYMENT_TARGET�cSsg|]}t|��qSr��int��.0�xrrr�
<listcomp>esz _spawn_posix.<locals>.<listcomp>�.cSsg|]}t|��qSrr*r,rrrr/kszF$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure)r(zunable to execute %r: %s
rz(unable to execute %r for unknown reasonsrrz"command %r terminated by signal %drz1unknown error executing %r: termination status %d)#rrr r�execvp�execv�sys�platform�_cfg_target�	distutilsr'Zget_config_var�split�_cfg_target_split�environ�getr�dict�execvpe�execve�forkr#r�stderr�write�strerror�_exit�waitpidrr�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS�
WIFSTOPPED)rrrrr$Zexec_fn�envr'Z
cur_targetZmy_msg�pid�eZstatusr%Zexit_statusrrrr
Ws�
����
����

����r
c	Cs�tj�|�\}}tjdkr*|dkr*|d}tj�|�r:|S|dkr�tj�dd�}|dkr�zt�d�}Wnt	t
fk
r�tj}YnX|s�dS|�tj
�}|D]&}tj�||�}tj�|�r�|Sq�dS)NZwin32z.exe�PATH�CS_PATH)r�path�splitextr3r4�isfiler9r:�confstr�AttributeError�
ValueError�defpathr7�pathsepr )r$rN�_Zext�paths�p�frrrr�s(
r)rrr)rrr)rrr)N)r3rZdistutils.errorsrrZdistutils.debugrr6rrrrr4r5r8r
rrrrr�<module>	s



RPK32�\����)�)fancy_getopt.cpython-38.pycnu�[���U

e5dxE�@s�dZddlZddlZddlZddlZddlTdZe�de�Ze�deef�Z	e
�dd�ZGd	d
�d
�Z
dd�Zd
d�ejD�Zdd�Zdd�ZGdd�d�Zedkr�dZdD]*Zede�ed�eee���e�q�dS)a6distutils.fancy_getopt

Wrapper around the standard getopt module that provides the following
additional features:
  * short and long options are tied together
  * options have help strings, so fancy_getopt could potentially
    create a complete usage summary
  * options set attributes of a passed-in object
�N)�*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(%s)=!(%s)$�-�_c@s�eZdZdZddd�Zdd�Zdd�Zd d	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
d!dd�Zdd�Zd"dd�Zd#dd�ZdS)$�FancyGetopta�Wrapper around the standard 'getopt()' module that provides some
    handy extra functionality:
      * short and long options are tied together
      * options have help strings, and help text can be assembled
        from them
      * options set attributes of a passed-in object
      * boolean options can have "negative aliases" -- eg. if
        --quiet is the "negative alias" of --verbose, then "--quiet"
        on the command line sets 'verbose' to false
    NcCsN||_i|_|jr|��i|_i|_g|_g|_i|_i|_i|_	g|_
dS�N)�option_table�option_index�_build_index�alias�negative_alias�
short_opts�	long_opts�
short2long�	attr_name�	takes_arg�option_order��selfr�r�./usr/lib64/python3.8/distutils/fancy_getopt.py�__init__)s	zFancyGetopt.__init__cCs(|j��|jD]}||j|d<qdS)Nr)r�clearr)r�optionrrrr	Qs

zFancyGetopt._build_indexcCs||_|��dSr)rr	rrrr�set_option_tableVszFancyGetopt.set_option_tablecCs<||jkrtd|��n |||f}|j�|�||j|<dS)Nz'option conflict: already an option '%s')r�DistutilsGetoptErrorr�append)r�long_optionZshort_optionZhelp_stringrrrr�
add_optionZs
�
zFancyGetopt.add_optioncCs
||jkS)zcReturn true if the option table for this parser has an
        option with long name 'long_option'.)r�rrrrr�
has_optioncszFancyGetopt.has_optioncCs
|�t�S)z�Translate long option name 'long_option' to the form it
        has as an attribute of some object: ie., translate hyphens
        to underscores.��	translate�
longopt_xlaterrrr�
get_attr_namehszFancyGetopt.get_attr_namecCs\t|t�st�|��D]@\}}||jkr:td|||f��||jkrtd|||f��qdS)Nz(invalid %s '%s': option '%s' not definedz0invalid %s '%s': aliased option '%s' not defined)�
isinstance�dict�AssertionError�itemsrr)r�aliasesZwhatr
�optrrr�_check_alias_dictns
�
�zFancyGetopt._check_alias_dictcCs|�|d�||_dS)z'Set the aliases for this option parser.r
N)r*r
)rr
rrr�set_aliasesxszFancyGetopt.set_aliasescCs|�|d�||_dS)z�Set the negative aliases for this option parser.
        'negative_alias' should be a dictionary mapping option names to
        option names, both the key and value must already be defined
        in the option table.znegative aliasN)r*r)rrrrr�set_negative_aliases}sz FancyGetopt.set_negative_aliasescCs�g|_g|_|j��i|_|jD�]�}t|�dkrD|\}}}d}n(t|�dkr^|\}}}}ntd|f��t|t	�r�t|�dkr�t
d|��|dks�t|t	�r�t|�dks�t
d	|��||j|<|j�|�|d
dkr�|r�|d}|dd
�}d|j|<nF|j
�|�}|dk	�r:|j|�r0t
d
||f��||jd
<d|j|<|j�|�}|dk	�r�|j||j|k�r�t
d||f��t�|��s�t
d|��|�|�|j|<|r"|j�|�||j|d<q"dS)z�Populate the various data structures that keep tabs on the
        option table.  Called by 'getopt()' before it can do anything
        worthwhile.
        �r�zinvalid option tuple: %r�z9invalid long option '%s': must be a string of length >= 2N�z:invalid short option '%s': must a single character or None����=�:z>invalid negative alias '%s': aliased option '%s' takes a valuezginvalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'tzEinvalid long option name '%s' (must be letters, numbers, hyphens only)r
rrr�repeatr�len�
ValueErrorr$�strrrrr�getr
�
longopt_re�matchr#r)rr�long�short�helpr4Zalias_torrr�_grok_option_table�st

��
��

��


��
��zFancyGetopt._grok_option_tablec
Cs�|dkrtjdd�}|dkr*t�}d}nd}|��d�|j�}zt�|||j�\}}Wn,tjk
r�}zt	|��W5d}~XYnX|D]�\}}t
|�dkr�|ddkr�|j|d}n,t
|�dkr�|dd�d	ks�t�|dd�}|j
�|�}	|	r�|	}|j|�s:|d
k�std��|j�|�}	|	�r6|	}d}nd}|j|}
|�rl|j�|
�dk	�rlt||
d�d}t||
|�|j�||f�q�|�r�||fS|SdS)aParse command-line options in args. Store as attributes on object.

        If 'args' is None or not supplied, uses 'sys.argv[1:]'.  If
        'object' is None or not supplied, creates a new OptionDummy
        object, stores option values there, and returns a tuple (args,
        object).  If 'object' is supplied, it is modified in place and
        'getopt()' just returns 'args'; in both cases, the returned
        'args' is a modified copy of the passed-in 'args' list, which
        is left untouched.
        Nr0TF� r/rrz--�zboolean option can't have value)�sys�argv�OptionDummyr>�joinr�getoptr
�errorZDistutilsArgErrorr5rr&r
r8rrrr4�getattr�setattrrr)r�args�objectZcreated_objectrZopts�msgr)�valr
�attrrrrrE�sF 
zFancyGetopt.getoptcCs|jdkrtd��n|jSdS)z�Returns the list of (option, value) tuples processed by the
        previous run of 'getopt()'.  Raises RuntimeError if
        'getopt()' hasn't been called yet.
        Nz!'getopt()' hasn't been called yet)r�RuntimeError)rrrr�get_option_orders

zFancyGetopt.get_option_ordercCsjd}|jD]L}|d}|d}t|�}|ddkr:|d}|dk	rJ|d}||kr
|}q
|ddd}d}||}	d	|}
|r�|g}nd
g}|jD]�}|dd�\}}}t||	�}
|ddkr�|dd�}|dk�r|
r�|�d|||
df�n|�d
||f�n:d||f}|
�r4|�d|||
df�n|�d|�|
dd�D]}|�|
|��qNq�|S)z�Generate help text (a list of strings, one per suggested line of
        output) from the option table for this FancyGetopt object.
        rr0r1r2N�r/�Nr?zOption summary:r-z  --%-*s  %sz
  --%-*s  z%s (-%s)z  --%-*s)rr5�	wrap_textr)r�headerZmax_optrr;r<�lZ	opt_widthZ
line_widthZ
text_widthZ
big_indent�linesr=�textZ	opt_namesrrr�
generate_helpsH



�zFancyGetopt.generate_helpcCs0|dkrtj}|�|�D]}|�|d�qdS)N�
)rA�stdoutrW�write)rrS�file�linerrr�
print_helphszFancyGetopt.print_help)N)NN)NN)N)NN)�__name__�
__module__�__qualname__�__doc__rr	rrrr#r*r+r,r>rErOrWr]rrrrrs
(
	
M
=

OrcCst|�}|�|�|�||�Sr)rr,rE)�optionsZnegative_optrJrI�parserrrr�fancy_getoptos
rdcCsi|]}t|�d�qS)r?)�ord)�.0Z_wscharrrr�
<dictcomp>usrgcCs|dkrgSt|�|kr|gS|��}|�t�}t�d|�}dd�|D�}g}|�rg}d}|r�t|d�}|||kr�|�|d�|d=||}q\|r�|dddkr�|d=q�q\|�r|dkr�|�|dd|��|d|d�|d<|dddk�r|d=|�d�|��qN|S)	z�wrap_text(text : string, width : int) -> [string]

    Split 'text' into multiple lines of no more than 'width' characters
    each, and return the list of strings that results.
    Nz( +|-+)cSsg|]}|r|�qSrr)rfZchrrr�
<listcomp>�szwrap_text.<locals>.<listcomp>rr1r?r@)r5�
expandtabsr!�WS_TRANS�re�splitrrD)rV�widthZchunksrUZcur_lineZcur_lenrTrrrrRws:

rRcCs
|�t�S)zXConvert a long option name to a valid Python identifier by
    changing "-" to "_".
    r )r)rrr�translate_longopt�srnc@seZdZdZgfdd�ZdS)rCz_Dummy class just used as a place to hold command-line option
    values as instance attributes.cCs|D]}t||d�qdS)zkCreate a new OptionDummy instance.  The attributes listed in
        'options' will be initialized to None.N)rH)rrbr)rrrr�szOptionDummy.__init__N)r^r_r`rarrrrrrC�srC�__main__z�Tra-la-la, supercalifragilisticexpialidocious.
How *do* you spell that odd word, anyways?
(Someone ask Mary -- she'll know [or she'll
say, "How should I know?"].))�
���(z	width: %drX)rarA�stringrkrEZdistutils.errorsZlongopt_pat�compiler9Zneg_alias_rer7�	maketransr"rrdZ
whitespacerjrRrnrCr^rV�w�printrDrrrr�<module>s*
T6PK32�\O�

extension.cpython-38.pycnu�[���U

e5d)�@s.dZddlZddlZGdd�d�Zdd�ZdS)zmdistutils.extension

Provides the Extension class, used to describe C/C++ extension
modules in setup scripts.�Nc@s"eZdZdZddd�Zdd�ZdS)�	Extensiona�Just a collection of attributes that describes an extension
    module and everything needed to build it (hopefully in a portable
    way, but there are hooks that let you be as unportable as you need).

    Instance attributes:
      name : string
        the full name of the extension, including any packages -- ie.
        *not* a filename or pathname, but Python dotted name
      sources : [string]
        list of source filenames, relative to the distribution root
        (where the setup script lives), in Unix form (slash-separated)
        for portability.  Source files may be C, C++, SWIG (.i),
        platform-specific resource files, or whatever else is recognized
        by the "build_ext" command as source for a Python extension.
      include_dirs : [string]
        list of directories to search for C/C++ header files (in Unix
        form for portability)
      define_macros : [(name : string, value : string|None)]
        list of macros to define; each macro is defined using a 2-tuple,
        where 'value' is either the string to define it to or None to
        define it without a particular value (equivalent of "#define
        FOO" in source or -DFOO on Unix C compiler command line)
      undef_macros : [string]
        list of macros to undefine explicitly
      library_dirs : [string]
        list of directories to search for C/C++ libraries at link time
      libraries : [string]
        list of library names (not filenames or paths) to link against
      runtime_library_dirs : [string]
        list of directories to search for C/C++ libraries at run time
        (for shared extensions, this is when the extension is loaded)
      extra_objects : [string]
        list of extra files to link with (eg. object files not implied
        by 'sources', static library that must be explicitly specified,
        binary resource files, etc.)
      extra_compile_args : [string]
        any extra platform- and compiler-specific information to use
        when compiling the source files in 'sources'.  For platforms and
        compilers where "command line" makes sense, this is typically a
        list of command-line arguments, but for other platforms it could
        be anything.
      extra_link_args : [string]
        any extra platform- and compiler-specific information to use
        when linking object files together to create the extension (or
        to create a new static Python interpreter).  Similar
        interpretation as for 'extra_compile_args'.
      export_symbols : [string]
        list of symbols to be exported from a shared extension.  Not
        used on all platforms, and not generally necessary for Python
        extensions, which typically export exactly one symbol: "init" +
        extension_name.
      swig_opts : [string]
        any extra options to pass to SWIG if a source file has the .i
        extension.
      depends : [string]
        list of files that the extension depends on
      language : string
        extension language (i.e. "c", "c++", "objc"). Will be detected
        from the source extensions if not provided.
      optional : boolean
        specifies that a build failure in the extension should not abort the
        build process, but simply not install the failing extension.
    NcKst|t�std��t|t�r.tdd�|D��s6td��||_||_|pHg|_|pRg|_|p\g|_	|pfg|_
|ppg|_|pzg|_|	p�g|_
|
p�g|_|p�g|_|p�g|_|
p�g|_|p�g|_||_||_t|�dk�rdd�|D�}d�t|��}d	|}t�|�dS)
Nz'name' must be a stringcss|]}t|t�VqdS)N)�
isinstance�str)�.0�v�r�+/usr/lib64/python3.8/distutils/extension.py�	<genexpr>jsz%Extension.__init__.<locals>.<genexpr>z#'sources' must be a list of stringsrcSsg|]}t|��qSr)�repr)rZoptionrrr�
<listcomp>�sz&Extension.__init__.<locals>.<listcomp>z, zUnknown Extension options: %s)rr�AssertionError�list�all�name�sources�include_dirs�
define_macros�undef_macros�library_dirs�	libraries�runtime_library_dirs�
extra_objects�extra_compile_args�extra_link_args�export_symbols�	swig_opts�depends�language�optional�len�join�sorted�warnings�warn)�selfrrrrrrrrrrrrrrrr�kwZoptions�msgrrr�__init__Vs6

�











zExtension.__init__cCsd|jj|jj|jt|�fS)Nz<%s.%s(%r) at %#x>)�	__class__�
__module__�__qualname__r�id)r$rrr�__repr__�s�zExtension.__repr__)NNNNNNNNNNNNNN)�__name__r)r*�__doc__r'r,rrrrrs"C�
/rcCs�ddlm}m}m}ddlm}ddlm}||�}||dddddd�}�z^g}|�	�}	|	dkrd�q�|�
|	�rpqP|	d|	dkr�d	kr�nn|�d
|	�qP||	|�}	||	�}
|
d}t|g�}d}
|
dd�D�]�}|
dk	r�|
�
|�d}
q�tj�|�d}|dd�}|dd�}|dk�r2|j�
|�q�|d
k�rJ|j�
|�q�|dk�r�|�d�}|dk�rz|j�
|df�n$|j�
|d|�||dd�f�q�|dk�r�|j�
|�q�|dk�r�|j�
|�q�|dk�r�|j�
|�q�|dk�r|j�
|�q�|dk�r|j�
|�q�|dk�r*|j}
q�|dk�r<|j}
q�|dk�rN|j}
q�|dk�rr|j�
|�|�s�|j}
q�|dk�r�|j�
|�q�|�d|�q�|�
|�qPW5|��X|S)z3Reads a Setup file and returns Extension instances.r)�parse_makefile�expand_makefile_vars�_variable_rx)�TextFile)�split_quoted�)Zstrip_commentsZskip_blanksZ
join_linesZ	lstrip_wsZ	rstrip_wsN����*z'%s' lines not handled yet�)z.cz.ccz.cppz.cxxz.c++z.mz.mmz-Iz-D�=z-Uz-Cz-lz-Lz-Rz-rpathz-Xlinkerz
-Xcompilerz-u)z.az.soz.slz.oz.dylibzunrecognized argument '%s')Zdistutils.sysconfigr/r0r1Zdistutils.text_filer2Zdistutils.utilr3�close�readline�matchr#r�append�os�path�splitextrr�findrrrrrrrr)�filenamer/r0r1r2r3�vars�file�
extensions�lineZwords�moduleZextZappend_next_wordZword�suffixZswitch�valueZequalsrrr�read_setup_file�s��
 







�










rI)r.r=r"rrIrrrr�<module>szPK32�\�u�3&3&filelist.cpython-38.opt-1.pycnu�[���U

e5d 2�@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZGdd�d�Zdd	�Z
ejfd
d�Zdd
�Zddd�ZdS)zsdistutils.filelist

Provides the FileList class, used for poking about the filesystem
and building lists of files.
�N��convert_path)�DistutilsTemplateError�DistutilsInternalError)�logc@s|eZdZdZddd�Zdd�Zejfdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zddd�Zddd�ZdS) �FileLista�A list of files built by on exploring the filesystem and filtered by
    applying various patterns to what we find there.

    Instance attributes:
      dir
        directory from which files will be taken -- only used if
        'allfiles' not supplied to constructor
      files
        list of filenames currently being built/filtered/manipulated
      allfiles
        complete list of files under consideration (ie. without any
        filtering applied)
    NcCsd|_g|_dS�N)�allfiles�files)�self�warn�debug_print�r�*/usr/lib64/python3.8/distutils/filelist.py�__init__szFileList.__init__cCs
||_dSr)r	)rr	rrr�set_allfiles#szFileList.set_allfilescCst|�|_dSr)�findallr	)r�dirrrrr&szFileList.findallcCsddlm}|rt|�dS)z~Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        r)�DEBUGN)Zdistutils.debugr�print)r�msgrrrrr
)szFileList.debug_printcCs|j�|�dSr)r
�append)r�itemrrrr3szFileList.appendcCs|j�|�dSr)r
�extend)r�itemsrrrr6szFileList.extendcCs<tttjj|j��}g|_|D]}|j�tjj|��qdSr)�sorted�map�os�path�splitr
r�join)rZsortable_filesZ
sort_tuplerrr�sort9sz
FileList.sortcCs@tt|j�ddd�D]$}|j||j|dkr|j|=qdS)N�r���)�range�lenr
)r�irrr�remove_duplicatesCszFileList.remove_duplicatescCs�|��}|d}d}}}|dkrTt|�dkr<td|��dd�|dd�D�}n~|dkr�t|�d	krttd
|��t|d�}dd�|dd�D�}n:|dkr�t|�dkr�td
|��t|d�}ntd|��||||fS)Nr)�include�exclude�global-include�global-exclude�z&'%s' expects <pattern1> <pattern2> ...cSsg|]}t|��qSrr��.0�wrrr�
<listcomp>Wsz1FileList._parse_template_line.<locals>.<listcomp>r")�recursive-include�recursive-exclude�z,'%s' expects <dir> <pattern1> <pattern2> ...cSsg|]}t|��qSrrr-rrrr0]s)�graft�prunez#'%s' expects a single <dir_pattern>zunknown action '%s')rr%rr)r�lineZwords�action�patternsr�dir_patternrrr�_parse_template_lineLs0���zFileList._parse_template_linecCs@|�|�\}}}}|dkrV|�dd�|��|D]}|j|dd�s2t�d|�q2�n�|dkr�|�dd�|��|D]}|j|dd�svt�d	|�qv�n�|d
kr�|�dd�|��|D]}|j|dd�s�t�d
|�q��n^|dk�r(|�dd�|��|D]"}|j|dd��st�d|��q�n|dk�rv|�d|d�|�f�|D]$}|j||d��sNt�d||��qNn�|dk�r�|�d|d�|�f�|D]$}|j||d��s�t�d||��q�nx|dk�r�|�d|�|jd|d��s<t�d|�nB|dk�r0|�d|�|jd|d��s<t�d|�ntd|��dS)Nr(zinclude � r")�anchorz%warning: no files found matching '%s'r)zexclude z9warning: no previously-included files found matching '%s'r*zglobal-include rz>warning: no files found matching '%s' anywhere in distributionr+zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionr1zrecursive-include %s %s)�prefixz:warning: no files found matching '%s' under directory '%s'r2zrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'r4zgraft z+warning: no directories found matching '%s'r5zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r:r
r �include_patternrr�exclude_patternr)rr6r7r8rr9�patternrrr�process_template_linehs��
�
�

�
��

��

�
��zFileList.process_template_liner"rcCsld}t||||�}|�d|j�|jdkr4|��|jD],}|�|�r:|�d|�|j�|�d}q:|S)a�Select strings (presumably filenames) from 'self.files' that
        match 'pattern', a Unix-style wildcard (glob) pattern.  Patterns
        are not quite the same as implemented by the 'fnmatch' module: '*'
        and '?'  match non-special characters, where "special" is platform-
        dependent: slash on Unix; colon, slash, and backslash on
        DOS/Windows; and colon on Mac OS.

        If 'anchor' is true (the default), then the pattern match is more
        stringent: "*.py" will match "foo.py" but not "foo/bar.py".  If
        'anchor' is false, both of these will match.

        If 'prefix' is supplied, then only filenames starting with 'prefix'
        (itself a pattern) and ending with 'pattern', with anything in between
        them, will match.  'anchor' is ignored in this case.

        If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and
        'pattern' is assumed to be either a string containing a regex or a
        regex object -- no translation is done, the regex is just compiled
        and used as-is.

        Selected strings will be added to self.files.

        Return True if files are found, False otherwise.
        Fz%include_pattern: applying regex r'%s'Nz adding T)�translate_patternr
r@r	r�searchr
r)rr@r<r=�is_regex�files_found�
pattern_re�namerrrr>�s�


zFileList.include_patterncCsrd}t||||�}|�d|j�tt|j�ddd�D]4}|�|j|�r8|�d|j|�|j|=d}q8|S)aRemove strings (presumably filenames) from 'files' that match
        'pattern'.  Other parameters are the same as for
        'include_pattern()', above.
        The list 'self.files' is modified in place.
        Return True if files are found, False otherwise.
        Fz%exclude_pattern: applying regex r'%s'r"r#z
 removing T)rBr
r@r$r%r
rC)rr@r<r=rDrErFr&rrrr?�s�zFileList.exclude_pattern)NN)r"Nr)r"Nr)�__name__�
__module__�__qualname__�__doc__rrr�curdirrr
rrr!r'r:rAr>r?rrrrrs 


	L
,�rcCs&dd�tj|dd�D�}ttjj|�S)z%
    Find all files under 'path'
    css,|]$\}}}|D]}tj�||�VqqdSr)rrr )r.�base�dirsr
�filerrr�	<genexpr>�s�z#_find_all_simple.<locals>.<genexpr>T)�followlinks)r�walk�filterr�isfile)rZresultsrrr�_find_all_simple�s�rUcCs6t|�}|tjkr.tjtjj|d�}t||�}t|�S)z�
    Find all files under 'dir' and return the list of full filenames.
    Unless dir is '.', return full filenames with dir prepended.
    )�start)	rUrrL�	functools�partialr�relpathr�list)rr
Zmake_relrrrrs


rcCs8t�|�}tj}tjdkrd}d|}t�d||�}|S)z�Translate a shell-like glob pattern to a regular expression; return
    a string containing the regex.  Differs from 'fnmatch.translate()' in
    that '*' does not match "special characters" (which are
    platform-specific).
    �\z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)�fnmatch�	translater�sep�re�sub)r@rFr^Zescapedrrr�
glob_to_res

rar"c
Cs�|rt|t�rt�|�S|Std��d�\}}}|r>t|�}nd}|dk	r�t|�}|t|�t|�t|��}tj}	tjdkr�d}	|t|�t|�t|��}d|||	||f}n|r�d||t|�d�f}t�|�S)aTranslate a shell-like wildcard pattern to a compiled regular
    expression.  Return the compiled regex.  If 'is_regex' true,
    then 'pattern' is directly compiled to a regex (if it's a string)
    or just returned as-is (assumes it's a regex object).
    �_�Nr[z\\z%s\A%s%s.*%s%sz%s\A%s)	�
isinstance�strr_�compilera�	partitionr%rr^)
r@r<r=rDrVrb�endrFZ	prefix_rer^rrrrB%s(


rB)r"Nr)rKrr_r\rWZdistutils.utilrZdistutils.errorsrrZ	distutilsrrrUrLrrarBrrrr�<module>siPK32�\4#�Z��dir_util.cpython-38.opt-1.pycnu�[���U

e5db�@spdZddlZddlZddlmZmZddlmZiaddd�Z	dd	d
�Z
ddd�Zd
d�Zddd�Z
dd�ZdS)zWdistutils.dir_util

Utility functions for manipulating directories and directory trees.�N)�DistutilsFileError�DistutilsInternalError)�log��cCsft|t�std|f��tj�|�}g}tj�|�s<|dkr@|St�tj�	|��rV|Stj�
|�\}}|g}|r�|r�tj�|�s�tj�
|�\}}|�d|�ql|D]�}tj�||�}tj�	|�}	t�|	�r�q�|dkr�t
�d|�|�sXzt�||�WnVtk
�rL}
z6|
jtjk�r&tj�|��s<td||
jdf��W5d}
~
XYnX|�|�dt|	<q�|S)	a�Create a directory and any missing ancestor directories.

    If the directory already exists (or if 'name' is the empty string, which
    means the current directory, which of course exists), then do nothing.
    Raise DistutilsFileError if unable to create some directory along the way
    (eg. some sub-path exists, but is a file rather than a directory).
    If 'verbose' is true, print a one-line summary of each mkdir to stdout.
    Return the list of directories actually created.
    z(mkpath: 'name' must be a string (got %r)�rrzcreating %szcould not create '%s': %s���N)�
isinstance�strr�os�path�normpath�isdir�
_path_created�get�abspath�split�insert�joinr�info�mkdir�OSError�errnoZEEXISTr�args�append)�name�mode�verbose�dry_runZcreated_dirs�head�tailZtails�dZabs_head�exc�r#�*/usr/lib64/python3.8/distutils/dir_util.py�mkpathsB
�
�

r%c	CsNt�}|D] }|�tj�|tj�|���q
t|�D]}t||||d�q4dS)a�Create all the empty directories under 'base_dir' needed to put 'files'
    there.

    'base_dir' is just the name of a directory which doesn't necessarily
    exist yet; 'files' is a list of filenames to be interpreted relative to
    'base_dir'.  'base_dir' + the directory portion of every file in 'files'
    will be created if it doesn't already exist.  'mode', 'verbose' and
    'dry_run' flags are as for 'mkpath()'.
    �rrN)�set�addrrr�dirname�sortedr%)Zbase_dir�filesrrrZneed_dir�file�dirr#r#r$�create_treePs
r.c
Cs^ddlm}|s(tj�|�s(td|��zt�|�}	Wn>tk
rt}
z |rRg}	ntd||
jf��W5d}
~
XYnX|s�t	||d�g}|	D]�}tj�
||�}
tj�
||�}|�d�r�q�|�r
tj�|
��r
t�
|
�}|dkr�t�d	||�|s�t�||�|�|�q�tj�|
��r8|�t|
|||||||d
��q�||
||||||d
�|�|�q�|S)aCopy an entire directory tree 'src' to a new location 'dst'.

    Both 'src' and 'dst' must be directory names.  If 'src' is not a
    directory, raise DistutilsFileError.  If 'dst' does not exist, it is
    created with 'mkpath()'.  The end result of the copy is that every
    file in 'src' is copied to 'dst', and directories under 'src' are
    recursively copied to 'dst'.  Return the list of files that were
    copied or might have been copied, using their output name.  The
    return value is unaffected by 'update' or 'dry_run': it is simply
    the list of all files under 'src', with the names changed to be
    under 'dst'.

    'preserve_mode' and 'preserve_times' are the same as for
    'copy_file'; note that they only apply to regular files, not to
    directories.  If 'preserve_symlinks' is true, symlinks will be
    copied as symlinks (on platforms that support them!); otherwise
    (the default), the destination of the symlink will be copied.
    'update' and 'verbose' are the same as for 'copy_file'.
    r)�	copy_filez&cannot copy tree '%s': not a directoryzerror listing files in '%s': %sN)rz.nfsrzlinking %s -> %sr&)Zdistutils.file_utilr/rrrr�listdirr�strerrorr%r�
startswith�islink�readlinkrr�symlinkr�extend�	copy_tree)�srcZdstZ
preserve_modeZpreserve_timesZpreserve_symlinks�updaterrr/�names�eZoutputs�nZsrc_nameZdst_nameZ	link_destr#r#r$r7cs\��

���r7cCsft�|�D]F}tj�||�}tj�|�r@tj�|�s@t||�q
|�tj|f�q
|�tj	|f�dS)zHelper for remove_tree().N)
rr0rrrr3�_build_cmdtupler�remove�rmdir)r�	cmdtuples�fZreal_fr#r#r$r=�sr=cCs�|dkrt�d|�|rdSg}t||�|D]h}z2|d|d�tj�|d�}|tkrbt|=Wq.tk
r�}zt�d||�W5d}~XYq.Xq.dS)z�Recursively remove an entire directory tree.

    Any errors are ignored (apart from being reported to stdout if 'verbose'
    is true).
    rz'removing '%s' (and everything under it)Nrzerror removing %s: %s)	rrr=rrrrr�warn)Z	directoryrrr@�cmdrr"r#r#r$�remove_tree�s

rDcCs6tj�|�\}}|dd�tjkr2||dd�}|S)z�Take the full path 'path', and make it a relative path.

    This is useful to make 'path' the second argument to os.path.join().
    rrN)rr�
splitdrive�sep)rZdriver#r#r$�ensure_relative�srG)rrr)rrr)rrrrrr)rr)�__doc__rrZdistutils.errorsrrZ	distutilsrrr%r.r7r=rDrGr#r#r#r$�<module>s 
?
�
E

PK32�\��ES��debug.cpython-38.pycnu�[���U

e5d��@sddlZej�d�ZdS)�NZDISTUTILS_DEBUG)�os�environ�get�DEBUG�rr�'/usr/lib64/python3.8/distutils/debug.py�<module>sPK32�\�Ɓ�k
k
extension.cpython-38.opt-2.pycnu�[���U

e5d)�@s*ddlZddlZGdd�d�Zdd�ZdS)�Nc@seZdZddd�Zdd�ZdS)�	ExtensionNcKst|t�std��t|t�r.tdd�|D��s6td��||_||_|pHg|_|pRg|_|p\g|_	|pfg|_
|ppg|_|pzg|_|	p�g|_
|
p�g|_|p�g|_|p�g|_|
p�g|_|p�g|_||_||_t|�dk�rdd�|D�}d�t|��}d	|}t�|�dS)
Nz'name' must be a stringcss|]}t|t�VqdS)N)�
isinstance�str)�.0�v�r�+/usr/lib64/python3.8/distutils/extension.py�	<genexpr>jsz%Extension.__init__.<locals>.<genexpr>z#'sources' must be a list of stringsrcSsg|]}t|��qSr)�repr)rZoptionrrr�
<listcomp>�sz&Extension.__init__.<locals>.<listcomp>z, zUnknown Extension options: %s)rr�AssertionError�list�all�name�sources�include_dirs�
define_macros�undef_macros�library_dirs�	libraries�runtime_library_dirs�
extra_objects�extra_compile_args�extra_link_args�export_symbols�	swig_opts�depends�language�optional�len�join�sorted�warnings�warn)�selfrrrrrrrrrrrrrrrr�kwZoptions�msgrrr�__init__Vs6

�











zExtension.__init__cCsd|jj|jj|jt|�fS)Nz<%s.%s(%r) at %#x>)�	__class__�
__module__�__qualname__r�id)r$rrr�__repr__�s�zExtension.__repr__)NNNNNNNNNNNNNN)�__name__r)r*r'r,rrrrrs D�
/rcCs�ddlm}m}m}ddlm}ddlm}||�}||dddddd�}�z^g}|�	�}	|	dkrd�q�|�
|	�rpqP|	d|	dkr�dkr�nn|�d	|	�qP||	|�}	||	�}
|
d}t|g�}d}
|
dd�D�]�}|
dk	r�|
�
|�d}
q�tj�|�d}|dd
�}|d
d�}|dk�r2|j�
|�q�|dk�rJ|j�
|�q�|d
k�r�|�d�}|dk�rz|j�
|df�n$|j�
|d|�||d
d�f�q�|dk�r�|j�
|�q�|dk�r�|j�
|�q�|dk�r�|j�
|�q�|dk�r|j�
|�q�|dk�r|j�
|�q�|dk�r*|j}
q�|dk�r<|j}
q�|dk�rN|j}
q�|dk�rr|j�
|�|�s�|j}
q�|dk�r�|j�
|�q�|�d|�q�|�
|�qPW5|��X|S)Nr)�parse_makefile�expand_makefile_vars�_variable_rx)�TextFile)�split_quoted�)Zstrip_commentsZskip_blanksZ
join_linesZ	lstrip_wsZ	rstrip_ws����*z'%s' lines not handled yet�)z.cz.ccz.cppz.cxxz.c++z.mz.mmz-Iz-D�=z-Uz-Cz-lz-Lz-Rz-rpathz-Xlinkerz
-Xcompilerz-u)z.az.soz.slz.oz.dylibzunrecognized argument '%s')Zdistutils.sysconfigr.r/r0Zdistutils.text_filer1Zdistutils.utilr2�close�readline�matchr#r�append�os�path�splitextrr�findrrrrrrrr)�filenamer.r/r0r1r2�vars�file�
extensions�lineZwords�moduleZextZappend_next_wordZword�suffixZswitch�valueZequalsrrr�read_setup_file�s��
 







�










rH)r<r"rrHrrrr�<module>szPK32�\���G��ccompiler.cpython-38.pycnu�[���U

e5dI��@s�dZddlZddlZddlZddlTddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZdd	lmZGd
d�d�ZdZdd
d�Zdddddd�Zdd�Zddd�Zdd�Zdd�ZdS)z�distutils.ccompiler

Contains CCompiler, an abstract base class that defines the interface
for the Distutils compiler abstraction model.�N)�*)�spawn)�	move_file)�mkpath)�newer_pairwise�newer_group)�split_quoted�execute)�logc
@seZdZdZdZdZdZdZdZdZ	dZ
dZdddddd�ZdddgZ
dqdd	�Zd
d�Zdd
�Zdd�Zdd�Zdrdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d.d/�Z!dsd0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&dtd:d;�Z'dud<d=�Z(d>d?�Z)dvd@dA�Z*dBZ+dCZ,dDZ-dwdEdF�Z.dxdGdH�Z/dydIdJ�Z0dzdKdL�Z1dMdN�Z2dOdP�Z3dQdR�Z4d{dSdT�Z5d|dUdV�Z6d}dXdY�Z7d~dZd[�Z8dd\d]�Z9d�d_d`�Z:d�dbdc�Z;ddde�Z<dfdg�Z=d�dhdi�Z>djdk�Z?dldm�Z@d�dodp�ZAdS)��	CCompilera�Abstract base class to define the interface that must be implemented
    by real compiler classes.  Also has some utility methods used by
    several compiler classes.

    The basic idea behind a compiler abstraction class is that each
    instance can be used for all the compile/link steps in building a
    single project.  Thus, attributes common to all of those compile and
    link steps -- include directories, macros to define, libraries to link
    against, etc. -- are attributes of the compiler instance.  To allow for
    variability in how individual files are treated, most of those
    attributes may be varied on a per-compilation or per-link basis.
    N�czc++Zobjc)�.cz.ccz.cppz.cxxz.mrcCsb||_||_||_d|_g|_g|_g|_g|_g|_g|_	|j
��D]}|�||j
|�qFdS�N)
�dry_run�force�verbose�
output_dir�macros�include_dirs�	libraries�library_dirs�runtime_library_dirs�objects�executables�keys�set_executable)�selfrrr�key�r�+/usr/lib64/python3.8/distutils/ccompiler.py�__init__UszCCompiler.__init__cKs<|D]2}||jkr&td||jjf��|�|||�qdS)a�Define the executables (and options for them) that will be run
        to perform the various stages of compilation.  The exact set of
        executables that may be specified here depends on the compiler
        class (via the 'executables' class attribute), but most will have:
          compiler      the C/C++ compiler
          linker_so     linker used to create shared objects and libraries
          linker_exe    linker used to create binary executables
          archiver      static library creator

        On platforms with a command-line (Unix, DOS/Windows), each of these
        is a string that will be split into executable name and (optional)
        list of arguments.  (Splitting the string is done similarly to how
        Unix shells operate: words are delimited by spaces, but quotes and
        backslashes can override this.  See
        'distutils.util.split_quoted()'.)
        z$unknown executable '%s' for class %sN)r�
ValueError�	__class__�__name__r)r�kwargsrrrr�set_executablesys

�zCCompiler.set_executablescCs,t|t�rt||t|��nt|||�dSr)�
isinstance�str�setattrr)rr�valuerrrr�s
zCCompiler.set_executablecCs0d}|jD] }|d|kr"|S|d7}q
dS)Nr�)r)r�name�i�defnrrr�_find_macro�s

zCCompiler._find_macrocCs`|D]V}t|t�rFt|�dkrFt|dt�s8|ddkrFt|dt�std|dd��qdS)z�Ensures that every element of 'definitions' is a valid macro
        definition, ie. either (name,value) 2-tuple or a (name,) tuple.  Do
        nothing if all definitions are OK, raise TypeError otherwise.
        )r*�r*Nrzinvalid macro definition '%s': z.must be tuple (string,), (string, string), or z(string, None))r&�tuple�lenr'�	TypeError)rZdefinitionsr-rrr�_check_macro_definitions�s

��
����z"CCompiler._check_macro_definitionscCs.|�|�}|dk	r|j|=|j�||f�dS)a_Define a preprocessor macro for all compilations driven by this
        compiler object.  The optional parameter 'value' should be a
        string; if it is not supplied, then the macro will be defined
        without an explicit value and the exact outcome depends on the
        compiler used (XXX true? does ANSI say anything about this?)
        N�r.r�append)rr+r)r,rrr�define_macro�s	
zCCompiler.define_macrocCs0|�|�}|dk	r|j|=|f}|j�|�dS)a�Undefine a preprocessor macro for all compilations driven by
        this compiler object.  If the same macro is defined by
        'define_macro()' and undefined by 'undefine_macro()' the last call
        takes precedence (including multiple redefinitions or
        undefinitions).  If the macro is redefined/undefined on a
        per-compilation basis (ie. in the call to 'compile()'), then that
        takes precedence.
        Nr4)rr+r,Zundefnrrr�undefine_macro�s

zCCompiler.undefine_macrocCs|j�|�dS)z�Add 'dir' to the list of directories that will be searched for
        header files.  The compiler is instructed to search directories in
        the order in which they are supplied by successive calls to
        'add_include_dir()'.
        N)rr5�r�dirrrr�add_include_dir�szCCompiler.add_include_dircCs|dd�|_dS)aySet the list of directories that will be searched to 'dirs' (a
        list of strings).  Overrides any preceding calls to
        'add_include_dir()'; subsequence calls to 'add_include_dir()' add
        to the list passed to 'set_include_dirs()'.  This does not affect
        any list of standard include directories that the compiler may
        search by default.
        N�r�r�dirsrrr�set_include_dirs�szCCompiler.set_include_dirscCs|j�|�dS)a�Add 'libname' to the list of libraries that will be included in
        all links driven by this compiler object.  Note that 'libname'
        should *not* be the name of a file containing a library, but the
        name of the library itself: the actual filename will be inferred by
        the linker, the compiler, or the compiler class (depending on the
        platform).

        The linker will be instructed to link against libraries in the
        order they were supplied to 'add_library()' and/or
        'set_libraries()'.  It is perfectly valid to duplicate library
        names; the linker will be instructed to link against libraries as
        many times as they are mentioned.
        N)rr5)r�libnamerrr�add_library�szCCompiler.add_librarycCs|dd�|_dS)z�Set the list of libraries to be included in all links driven by
        this compiler object to 'libnames' (a list of strings).  This does
        not affect any standard system libraries that the linker may
        include by default.
        N)r)rZlibnamesrrr�
set_libraries�szCCompiler.set_librariescCs|j�|�dS)a'Add 'dir' to the list of directories that will be searched for
        libraries specified to 'add_library()' and 'set_libraries()'.  The
        linker will be instructed to search for libraries in the order they
        are supplied to 'add_library_dir()' and/or 'set_library_dirs()'.
        N)rr5r8rrr�add_library_dirszCCompiler.add_library_dircCs|dd�|_dS)z�Set the list of library search directories to 'dirs' (a list of
        strings).  This does not affect any standard library search path
        that the linker may search by default.
        N)rr<rrr�set_library_dirsszCCompiler.set_library_dirscCs|j�|�dS)zlAdd 'dir' to the list of directories that will be searched for
        shared libraries at runtime.
        N)rr5r8rrr�add_runtime_library_dirsz!CCompiler.add_runtime_library_dircCs|dd�|_dS)z�Set the list of directories to search for shared libraries at
        runtime to 'dirs' (a list of strings).  This does not affect any
        standard search path that the runtime linker may search by
        default.
        N)rr<rrr�set_runtime_library_dirssz"CCompiler.set_runtime_library_dirscCs|j�|�dS)z�Add 'object' to the list of object files (or analogues, such as
        explicitly named library files or the output of "resource
        compilers") to be included in every link driven by this compiler
        object.
        N)rr5)r�objectrrr�add_link_object szCCompiler.add_link_objectcCs|dd�|_dS)z�Set the list of object files (or analogues) to be included in
        every link to 'objects'.  This does not affect any standard object
        files that the linker may include by default (such as system
        libraries).
        N)r)rrrrr�set_link_objects(szCCompiler.set_link_objectscCs*|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|dkr�g}|j|d|d�}t	|�t	|�ks�t
�t||�}i}	tt	|��D]B}
||
}||
}t
j�|�d}
|�t
j�|��||
f|	|<q�|||||	fS)z;Process arguments and decide which source files to compile.N�%'output_dir' must be a string or None�/'macros' (if supplied) must be a list of tuples�6'include_dirs' (if supplied) must be a list of stringsr)�	strip_dirrr*)rr&r'r2r�listrr0�object_filenamesr1�AssertionError�gen_preprocess_options�range�os�path�splitextr�dirname)rZoutdirrZincdirs�sources�dependsZextrar�pp_opts�buildr,�src�obj�extrrr�_setup_compile6s>

��
zCCompiler._setup_compilecCs0|dg}|rdg|dd�<|r,||dd�<|S)Nz-cz-grr)rrX�debugZbefore�cc_argsrrr�_get_cc_argsas
zCCompiler._get_cc_argscCs�|dkr|j}nt|t�s"td��|dkr2|j}n"t|t�rL||jpFg}ntd��|dkrd|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)a'Typecheck and fix-up some of the arguments to the 'compile()'
        method, and return fixed-up values.  Specifically: if 'output_dir'
        is None, replaces it with 'self.output_dir'; ensures that 'macros'
        is a list, and augments it with 'self.macros'; ensures that
        'include_dirs' is a list, and augments it with 'self.include_dirs'.
        Guarantees that the returned values are of the correct type,
        i.e. for 'output_dir' either string or None, and for 'macros' and
        'include_dirs' either list or None.
        NrIrJrK)rr&r'r2rrMrr0)rrrrrrr�_fix_compile_argsjs"


�zCCompiler._fix_compile_argscCs*|j||d�}t|�t|�ks"t�|ifS)a+Decide which souce files must be recompiled.

        Determine the list of object files corresponding to 'sources',
        and figure out which ones really need to be recompiled.
        Return a list of all object files and a dictionary telling
        which source files can be skipped.
        )r)rNr1rO)rrVrrWrrrr�
_prep_compile�s	zCCompiler._prep_compilecCsHt|ttf�std��t|�}|dkr.|j}nt|t�s@td��||fS)z�Typecheck and fix up some arguments supplied to various methods.
        Specifically: ensure that 'objects' is a list; if output_dir is
        None, replace with self.output_dir.  Return fixed versions of
        'objects' and 'output_dir'.
        z,'objects' must be a list or tuple of stringsNrI)r&rMr0r2rr')rrrrrr�_fix_object_args�s
zCCompiler._fix_object_argscCs�|dkr|j}n*t|ttf�r2t|�|jp,g}ntd��|dkrJ|j}n*t|ttf�rlt|�|jpfg}ntd��|dkr�|j}n*t|ttf�r�t|�|jp�g}ntd��|||fS)a;Typecheck and fix up some of the arguments supplied to the
        'link_*' methods.  Specifically: ensure that all arguments are
        lists, and augment them with their permanent versions
        (eg. 'self.libraries' augments 'libraries').  Return a tuple with
        fixed versions of all arguments.
        Nz3'libraries' (if supplied) must be a list of stringsz6'library_dirs' (if supplied) must be a list of stringsz>'runtime_library_dirs' (if supplied) must be a list of strings)rr&rMr0r2rr)rrrrrrr�
_fix_lib_args�s,���zCCompiler._fix_lib_argscCs2|jr
dS|jr t||dd�}n
t||�}|SdS)zjReturn true if we need to relink the files listed in 'objects'
        to recreate 'output_file'.
        T�newer)ZmissingN)rrr)rr�output_filererrr�
_need_link�s
zCCompiler._need_linkc		Cs~t|t�s|g}d}t|j�}|D]V}tj�|�\}}|j�|�}z |j�	|�}||kr`|}|}Wq"t
k
rvYq"Xq"|S)z|Detect the language of a given file, or list of files. Uses
        language_map, and language_order to do the job.
        N)r&rMr1�language_orderrRrSrT�language_map�get�indexr!)	rrVZlangrk�source�baser\ZextlangZextindexrrr�detect_language�s

zCCompiler.detect_languagecCsdS)a�Preprocess a single C/C++ source file, named in 'source'.
        Output will be written to file named 'output_file', or stdout if
        'output_file' not supplied.  'macros' is a list of macro
        definitions as for 'compile()', which will augment the macros set
        with 'define_macro()' and 'undefine_macro()'.  'include_dirs' is a
        list of directory names that will be added to the default list.

        Raises PreprocessError on failure.
        Nr)rrlrfrr�
extra_preargs�extra_postargsrrr�
preprocess�szCCompiler.preprocessc		Csx|�||||||�\}}	}}
}|�|
||�}|	D]B}
z||
\}}Wntk
r\Yq0YnX|�|
|||||
�q0|	S)aK	Compile one or more source files.

        'sources' must be a list of filenames, most likely C/C++
        files, but in reality anything that can be handled by a
        particular compiler and compiler class (eg. MSVCCompiler can
        handle resource files in 'sources').  Return a list of object
        filenames, one per source filename in 'sources'.  Depending on
        the implementation, not all source files will necessarily be
        compiled, but all corresponding object filenames will be
        returned.

        If 'output_dir' is given, object files will be put under it, while
        retaining their original path component.  That is, "foo/bar.c"
        normally compiles to "foo/bar.o" (for a Unix implementation); if
        'output_dir' is "build", then it would compile to
        "build/foo/bar.o".

        'macros', if given, must be a list of macro definitions.  A macro
        definition is either a (name, value) 2-tuple or a (name,) 1-tuple.
        The former defines a macro; if the value is None, the macro is
        defined without an explicit value.  The 1-tuple case undefines a
        macro.  Later definitions/redefinitions/ undefinitions take
        precedence.

        'include_dirs', if given, must be a list of strings, the
        directories to add to the default include file search path for this
        compilation only.

        'debug' is a boolean; if true, the compiler will be instructed to
        output debug symbols in (or alongside) the object file(s).

        'extra_preargs' and 'extra_postargs' are implementation- dependent.
        On platforms that have the notion of a command-line (e.g. Unix,
        DOS/Windows), they are most likely lists of strings: extra
        command-line arguments to prepend/append to the compiler command
        line.  On other platforms, consult the implementation class
        documentation.  In any event, they are intended as an escape hatch
        for those occasions when the abstract compiler framework doesn't
        cut the mustard.

        'depends', if given, is a list of filenames that all targets
        depend on.  If a source file is older than any file in
        depends, then the source file will be recompiled.  This
        supports dependency tracking, but only at a coarse
        granularity.

        Raises CompileError on failure.
        )r]r`�KeyError�_compile)rrVrrrr^rorprWrrXrYr_r[rZr\rrr�compile�s6��
zCCompiler.compilecCsdS)zCompile 'src' to product 'obj'.Nr)rr[rZr\r_rprXrrrrsCszCCompiler._compilecCsdS)a&Link a bunch of stuff together to create a static library file.
        The "bunch of stuff" consists of the list of object files supplied
        as 'objects', the extra object files supplied to
        'add_link_object()' and/or 'set_link_objects()', the libraries
        supplied to 'add_library()' and/or 'set_libraries()', and the
        libraries supplied as 'libraries' (if any).

        'output_libname' should be a library name, not a filename; the
        filename will be inferred from the library name.  'output_dir' is
        the directory where the library file will be put.

        'debug' is a boolean; if true, debugging information will be
        included in the library (note that on most platforms, it is the
        compile step where this matters: the 'debug' flag is included here
        just for consistency).

        'target_lang' is the target language for which the given objects
        are being compiled. This allows specific linkage time treatment of
        certain languages.

        Raises LibError on failure.
        Nr)rr�output_libnamerr^�target_langrrr�create_static_libIszCCompiler.create_static_libZ
shared_objectZshared_library�
executablecCst�dS)auLink a bunch of stuff together to create an executable or
        shared library file.

        The "bunch of stuff" consists of the list of object files supplied
        as 'objects'.  'output_filename' should be a filename.  If
        'output_dir' is supplied, 'output_filename' is relative to it
        (i.e. 'output_filename' can provide directory components if
        needed).

        'libraries' is a list of libraries to link against.  These are
        library names, not filenames, since they're translated into
        filenames in a platform-specific way (eg. "foo" becomes "libfoo.a"
        on Unix and "foo.lib" on DOS/Windows).  However, they can include a
        directory component, which means the linker will look in that
        specific directory rather than searching all the normal locations.

        'library_dirs', if supplied, should be a list of directories to
        search for libraries that were specified as bare library names
        (ie. no directory component).  These are on top of the system
        default and those supplied to 'add_library_dir()' and/or
        'set_library_dirs()'.  'runtime_library_dirs' is a list of
        directories that will be embedded into the shared library and used
        to search for other shared libraries that *it* depends on at
        run-time.  (This may only be relevant on Unix.)

        'export_symbols' is a list of symbols that the shared library will
        export.  (This appears to be relevant only on Windows.)

        'debug' is as for 'compile()' and 'create_static_lib()', with the
        slight distinction that it actually matters on most platforms (as
        opposed to 'create_static_lib()', which includes a 'debug' flag
        mostly for form's sake).

        'extra_preargs' and 'extra_postargs' are as for 'compile()' (except
        of course that they supply command-line arguments for the
        particular linker being used).

        'target_lang' is the target language for which the given objects
        are being compiled. This allows specific linkage time treatment of
        certain languages.

        Raises LinkError on failure.
        N��NotImplementedError)rZtarget_descr�output_filenamerrrr�export_symbolsr^rorp�
build_temprvrrr�linkis9zCCompiler.linkc

Cs2|�tj||j|dd�|||||||	|
||�
dS)N�shared)�lib_type)r~r�SHARED_LIBRARY�library_filename)
rrrurrrrr|r^rorpr}rvrrr�link_shared_lib�s
�zCCompiler.link_shared_libc

Cs(|�tj|||||||||	|
||�
dSr)r~r�
SHARED_OBJECT)
rrr{rrrrr|r^rorpr}rvrrr�link_shared_object�s
�zCCompiler.link_shared_objectcCs.|�tj||�|�||||d|||	d|
�
dSr)r~r�
EXECUTABLE�executable_filename)rrZoutput_prognamerrrrr^rorprvrrr�link_executable�s
�zCCompiler.link_executablecCst�dS)zkReturn the compiler option to add 'dir' to the list of
        directories searched for libraries.
        Nryr8rrr�library_dir_option�szCCompiler.library_dir_optioncCst�dS)zsReturn the compiler option to add 'dir' to the list of
        directories searched for runtime libraries.
        Nryr8rrr�runtime_library_dir_option�sz$CCompiler.runtime_library_dir_optioncCst�dS)zReturn the compiler option to add 'lib' to the list of libraries
        linked into the shared library or executable.
        Nry)r�librrr�library_option�szCCompiler.library_optionc	Cs�ddl}|dkrg}|dkr g}|dkr,g}|dkr8g}|jd|dd�\}}t�|d�}	z*|D]}
|	�d|
�q^|	�d|�W5|	��Xz|j|g|d	�}Wntk
r�Yd
SXz|j|d||d�Wnt	t
fk
r�Yd
SXdS)
z�Return a boolean indicating whether funcname is supported on
        the current platform.  The optional arguments can be used to
        augment the compilation environment.
        rNr
T)�text�wz#include "%s"
z=int main (int argc, char **argv) {
    %s();
    return 0;
}
r;Fza.out)rr)�tempfileZmkstemprR�fdopen�close�writertZCompileErrorr�Z	LinkErrorr2)r�funcnameZincludesrrrr��fdZfname�fZinclrrrr�has_function�s<	�

�
zCCompiler.has_functioncCst�dS)aHSearch the specified list of directories for a static or shared
        library file 'lib' and return the full path to that file.  If
        'debug' true, look for a debugging version (if that makes sense on
        the current platform).  Return None if 'lib' wasn't found in any of
        the specified directories.
        Nry)rr=r�r^rrr�find_library_file$szCCompiler.find_library_file�cCs�|dkrd}g}|D]|}tj�|�\}}tj�|�d}|tj�|�d�}||jkrftd||f��|rvtj�|�}|�tj�	|||j
��q|S)Nr�r*z"unknown file type '%s' (from '%s'))rRrSrT�
splitdrive�isabs�src_extensionsZUnknownFileError�basenamer5�join�
obj_extension)rZsource_filenamesrLrZ	obj_namesZsrc_namermr\rrrrNOs"

��zCCompiler.object_filenamescCs0|dk	st�|rtj�|�}tj�|||j�Sr)rOrRrSr�r��shared_lib_extension�rr�rLrrrr�shared_object_filename`sz CCompiler.shared_object_filenamecCs4|dk	st�|rtj�|�}tj�|||jp.d�S)Nr�)rOrRrSr�r��
exe_extensionr�rrrr�fszCCompiler.executable_filename�staticc
Csl|dk	st�|dkrtd��t||d�}t||d�}tj�|�\}}|||f}	|r\d}tj�|||	�S)N)r�rZdylibZ
xcode_stubz?'lib_type' must be "static", "shared", "dylib", or "xcode_stub"Z_lib_formatZ_lib_extensionr�)rOr!�getattrrRrS�splitr�)
rr?r�rLrZfmtr\r9rm�filenamerrrr�ls�zCCompiler.library_filenamer*cCst�|�dSr)r
r^)r�msg�levelrrr�announceszCCompiler.announcecCsddlm}|rt|�dS)Nr)�DEBUG)Zdistutils.debugr��print)rr�r�rrr�debug_print�szCCompiler.debug_printcCstj�d|�dS)Nzwarning: %s
)�sys�stderrr�)rr�rrr�warn�szCCompiler.warncCst||||j�dSr)r	r)r�func�argsr�r�rrrr	�szCCompiler.executecCst||jd�dS�N)r)rr)r�cmdrrrr�szCCompiler.spawncCst|||jd�Sr�)rr)rrZZdstrrrr�szCCompiler.move_file�cCst|||jd�dSr�)rr)rr+�moderrrr�szCCompiler.mkpath)rrr)N)N)NNNNN)NNNrNNN)NrN)
NNNNNrNNNN)
NNNNNrNNNN)
NNNNNrNNNN)NNNNrNNN)NNNN)r)rr�)rr�)rr�)r�rr�)r*)Nr*)r�)Br#�
__module__�__qualname__�__doc__Z
compiler_typer�r�Zstatic_lib_extensionr�Zstatic_lib_formatZshared_lib_formatr�rirhr r%rr.r3r6r7r:r>r@rArBrCrDrErGrHr]r`rarbrcrdrgrnrqrtrsrwr�r�r�r~r�r�r�r�r�r�r�r�rNr�r�r�r�r�r�r	rrrrrrrrs��

$ 

+	 
"
�

�
D�
�
A�
�
�
�
,
+


�


r))zcygwin.*�unix)�posixr�)�nt�msvccCsV|dkrtj}|dkrtj}tD]0\}}t�||�dk	sHt�||�dk	r |Sq dS)akDetermine the default compiler to use for the given platform.

       osname should be one of the standard Python OS names (i.e. the
       ones returned by os.name) and platform the common value
       returned by sys.platform for the platform in question.

       The default values are os.name and sys.platform in case the
       parameters are not given.
    Nr�)rRr+r��platform�_default_compilers�re�match)Zosnamer��pattern�compilerrrr�get_default_compiler�s
�
r�)Z
unixccompilerZ
UnixCCompilerzstandard UNIX-style compiler)Z
_msvccompilerZMSVCCompilerzMicrosoft Visual C++)�cygwinccompilerZCygwinCCompilerz'Cygwin port of GNU C Compiler for Win32)r�ZMingw32CCompilerz(Mingw32 port of GNU C Compiler for Win32)ZbcppcompilerZBCPPCompilerzBorland C++ Compiler)r�r��cygwinZmingw32ZbcppcCsXddlm}g}t��D] }|�d|dt|df�q|��||�}|�d�dS)zyPrint list of available compilers (used by the "--help-compiler"
    options to "build", "build_ext", "build_clib").
    r)�FancyGetoptz	compiler=Nr/zList of available compilers:)Zdistutils.fancy_getoptr��compiler_classrr5�sortZ
print_help)r�Z	compilersr�Zpretty_printerrrr�show_compilers�s
�r�cCs�|dkrtj}z"|dkr t|�}t|\}}}Wn8tk
rhd|}|dk	r\|d|}t|��YnXz*d|}t|�tj|}	t	|	�|}
WnBt
k
r�td|��Yn$tk
r�td||f��YnX|
d||�S)a[Generate an instance of some CCompiler subclass for the supplied
    platform/compiler combination.  'plat' defaults to 'os.name'
    (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
    for that platform.  Currently only 'posix' and 'nt' are supported, and
    the default compilers are "traditional Unix interface" (UnixCCompiler
    class) and Visual C++ (MSVCCompiler class).  Note that it's perfectly
    possible to ask for a Unix compiler object under Windows, and a
    Microsoft compiler object under Unix -- if you supply a value for
    'compiler', 'plat' is ignored.
    Nz5don't know how to compile C/C++ code on platform '%s'z with '%s' compilerz
distutils.z4can't compile C/C++ code: unable to load module '%s'zBcan't compile C/C++ code: unable to find class '%s' in module '%s')rRr+r�r�rrZDistutilsPlatformError�
__import__r��modules�vars�ImportErrorZDistutilsModuleError)Zplatr�rrrZmodule_name�
class_nameZlong_descriptionr��module�klassrrr�new_compiler�s:
����
r�cCs�g}|D]�}t|t�r0dt|�kr.dks<ntd|��t|�dkr\|�d|d�qt|�dkr|ddkr�|�d|d�q|�d|�q|D]}|�d	|�q�|S)
aGenerate C pre-processor options (-D, -U, -I) as used by at least
    two types of compilers: the typical Unix compiler and Visual C++.
    'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
    means undefine (-U) macro 'name', and (name,value) means define (-D)
    macro 'name' to 'value'.  'include_dirs' is just a list of directory
    names to be added to the header file search path (-I).  Returns a list
    of command-line options suitable for either Unix compilers or Visual
    C++.
    r*r/zPbad macro definition '%s': each element of 'macros' list must be a 1- or 2-tuplez-U%srNz-D%sz-D%s=%sz-I%s)r&r0r1r2r5)rrrXZmacror9rrrrPs"$��rPcCs�g}|D]}|�|�|��q|D],}|�|�}t|t�rD||}q"|�|�q"|D]V}tj�|�\}}	|r�|�|g|	�}
|
r�|�|
�q�|�	d|�qT|�|�
|��qT|S)acGenerate linker options for searching library directories and
    linking with specific libraries.  'libraries' and 'library_dirs' are,
    respectively, lists of library names (not filenames!) and search
    directories.  Returns a list of command-line options suitable for use
    with some compiler (depending on the two format strings passed in).
    z6no library file corresponding to '%s' found (skipping))r5r�r�r&rMrRrSr�r�r�r�)r�rrrZlib_optsr9�optr�Zlib_dirZlib_nameZlib_filerrr�gen_lib_options8s&


�r�)NN)NNrrr)r�r�rRr�Zdistutils.errorsZdistutils.spawnrZdistutils.file_utilrZdistutils.dir_utilrZdistutils.dep_utilrrZdistutils.utilrr	Z	distutilsr
rr�r�r�r�r�rPr�rrrr�<module>s8
�
--PK32�\�5����core.cpython-38.opt-1.pycnu�[���U

e5d�"�@s�dZddlZddlZddlmZddlTddlmZddlm	Z	ddl
mZddlm
Z
d	Zd
d�ZdadadZd
Zdd�Zddd�ZdS)a#distutils.core

The only module that needs to be imported to use the Distutils; provides
the 'setup' function (which is to be called from the setup script).  Also
indirectly provides the Distribution and Command classes, although they are
really defined in distutils.dist and distutils.cmd.
�N)�DEBUG)�*)�Distribution)�Command)�
PyPIRCCommand)�	Extensionz�usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: %(script)s --help [cmd1 cmd2 ...]
   or: %(script)s --help-commands
   or: %(script)s cmd --help
cCstj�|�}tt�S)N)�os�path�basename�USAGE�vars)�script_nameZscript�r�&/usr/lib64/python3.8/distutils/core.py�	gen_usage sr)�	distclassr
�script_argsZoptions�name�versionZauthorZauthor_emailZ
maintainerZmaintainer_emailZurl�licenseZdescriptionZlong_description�keywordsZ	platformsZclassifiersZdownload_urlZrequiresZprovidesZ	obsoletes)rZsourcesZinclude_dirsZ
define_macrosZundef_macrosZlibrary_dirsZ	librariesZruntime_library_dirsZ
extra_objectsZextra_compile_argsZextra_link_argsZ	swig_optsZexport_symbolsZdependsZlanguagec
Ks|�d�}|r|d=nt}d|kr8tj�tjd�|d<d|krRtjdd�|d<z||�a}WnLtk
r�}z.d|kr�t	d|��nt	d	|d|f��W5d}~XYnXt
d
kr�|S|��tr�t
d�|��t
dkr�|Sz|��}Wn:tk
�r*}zt	t|j�d
|��W5d}~XYnXt�rBt
d�|��t
dk�rP|S|�rz|��Wn�tk
�r�t	d��Yn�tk
�r�}z.t�r�tj�d|f��nt	d|f��W5d}~XYnBttfk
�r}zt�r�nt	dt|���W5d}~XYnX|S)a�The gateway to the Distutils: do everything your setup script needs
    to do, in a highly flexible and user-driven way.  Briefly: create a
    Distribution instance; find and parse config files; parse the command
    line; run each Distutils command found there, customized by the options
    supplied to 'setup()' (as keyword arguments), in config files, and on
    the command line.

    The Distribution instance might be an instance of a class supplied via
    the 'distclass' keyword argument to 'setup'; if no such class is
    supplied, then the Distribution class (in dist.py) is instantiated.
    All other arguments to 'setup' (except for 'cmdclass') are used to set
    attributes of the Distribution instance.

    The 'cmdclass' argument, if supplied, is a dictionary mapping command
    names to command classes.  Each command encountered on the command line
    will be turned into a command class, which is in turn instantiated; any
    class found in 'cmdclass' is used in place of the default, which is
    (for command 'foo_bar') class 'foo_bar' in module
    'distutils.command.foo_bar'.  The command class must provide a
    'user_options' attribute which is a list of option specifiers for
    'distutils.fancy_getopt'.  Any command-line options between the current
    and the next command are used to set attributes of the current command
    object.

    When the entire command-line has been successfully parsed, calls the
    'run()' method on each command object in turn.  This method will be
    driven entirely by the Distribution object (which each command object
    has a reference to, thanks to its constructor), and the
    command-specific options that became attributes of each command
    object.
    rr
rr�Nrzerror in setup command: %szerror in %s setup command: %s�initz%options (after parsing config files):�configz

error: %sz%options (after parsing command line):�commandlineZinterruptedz
error: %s
z	error: %szerror: )�getrrr	r
�sys�argv�_setup_distributionZDistutilsSetupError�
SystemExit�_setup_stop_afterZparse_config_filesr�printZdump_option_dictsZparse_command_lineZDistutilsArgErrorrr
Zrun_commands�KeyboardInterrupt�OSError�stderr�writeZDistutilsErrorZCCompilerError�str)�attrs�klassZdist�msg�ok�excrrr�setup9sd%

�(
�"r,�runc	Cs�|dkrtd|f��|atj��}d|i}zZzH|tjd<|dk	rP|tjdd�<t|d��}t|��|�W5QRXW5|t_daXWntk
r�YnXt	dkr�t
d|��t	S)	a.Run a setup script in a somewhat controlled environment, and
    return the Distribution instance that drives things.  This is useful
    if you need to find out the distribution meta-data (passed as
    keyword args from 'script' to 'setup()', or the contents of the
    config files or command-line.

    'script_name' is a file that will be read and run with 'exec()';
    'sys.argv[0]' will be replaced with 'script' for the duration of the
    call.  'script_args' is a list of strings; if supplied,
    'sys.argv[1:]' will be replaced by 'script_args' for the duration of
    the call.

    'stop_after' tells 'setup()' when to stop processing; possible
    values:
      init
        stop after the Distribution instance has been created and
        populated with the keyword arguments to 'setup()'
      config
        stop after config files have been parsed (and their data
        stored in the Distribution instance)
      commandline
        stop after the command-line ('sys.argv[1:]' or 'script_args')
        have been parsed (and the data stored in the Distribution)
      run [default]
        stop after all commands have been run (the same as if 'setup()'
        had been called in the usual way

    Returns the Distribution instance, which provides all information
    used to drive the Distutils.
    )rrrr-z"invalid value for 'stop_after': %r�__file__Nrr�rbzZ'distutils.core.setup()' was never called -- perhaps '%s' is not a Distutils setup script?)�
ValueErrorr rr�copy�open�exec�readrr�RuntimeError)r
rZ
stop_afterZ	save_argv�g�frrr�	run_setup�s*


�r8)Nr-)�__doc__rrZdistutils.debugrZdistutils.errorsZdistutils.distrZ
distutils.cmdrZdistutils.configrZdistutils.extensionrrrr rZsetup_keywordsZextension_keywordsr,r8rrrr�<module>s 	qPK32�\`=x��!archive_util.cpython-38.opt-2.pycnu�[���U

e5d|!�@s@ddlZddlmZddlZzddlZWnek
r@dZYnXddlmZddlm	Z	ddl
mZddlm
Z
zddlmZWnek
r�dZYnXzddlmZWnek
r�dZYnXd	d
�Zdd�Zd"dd�Zd#dd�Zedgdfedgdfedgdfedgdfedgdfegdfd�Zdd�Zd$d d!�ZdS)%�N)�warn)�DistutilsExecError)�spawn)�mkpath)�log)�getpwnam)�getgrnamcCsNtdks|dkrdSzt|�}Wntk
r8d}YnX|dk	rJ|dSdS�N�)r�KeyError��name�result�r�./usr/lib64/python3.8/distutils/archive_util.py�_get_gids
rcCsNtdks|dkrdSzt|�}Wntk
r8d}YnX|dk	rJ|dSdSr	)rrrrrr�_get_uid+s
r�gzipcs.dddddd�}dddd	d
�}|dk	r:||��kr:td��|d}	|d
krZ|	|�|d�7}	ttj�|	�|d�ddl}
t�	d�t
���t�������fdd�}|s�|
�|	d||�}z|j||d�W5|�
�X|d
k�r*tdt�|	||}
tjdk�r||	|
g}n
|d|	g}t||d�|
S|	S)NZgz�bz2�xz�)r�bzip2rN�compressz.gzz.bz2z.xzz.Z)rrrrzKbad value for 'compress': must be None, 'gzip', 'bzip2', 'xz' or 'compress'z.tarr��dry_runrzCreating tar archivecs,�dk	r�|_�|_�dk	r(�|_�|_|S�N)�gidZgname�uid�uname)Ztarinfo�r�group�ownerrrr�_set_uid_gidasz"make_tarball.<locals>._set_uid_gidzw|%s)�filterz'compress' will be deprecated.Zwin32z-f)�keys�
ValueError�getr�os�path�dirname�tarfiler�inforr�open�close�addr�PendingDeprecationWarning�sys�platformr)�	base_name�base_dirr�verboserr!r Ztar_compressionZcompress_extZarchive_namer*r"�tarZcompressed_name�cmdrrr�make_tarball7sB���
	



r7c
Cs�|d}ttj�|�|d�tdkrp|r.d}nd}ztd|||g|d�Wn tk
rjtd|��YnX�n8t�d||�|�s�ztj	|dtj
d	�}Wn&tk
r�tj	|dtjd	�}YnX|��|tj
k�rtj�tj�|d
��}|�||�t�d|�t�|�D]�\}}	}
|	D]6}tj�tj�||d
��}|�||�t�d|��q|
D]B}tj�tj�||��}tj�|��rV|�||�t�d|��qV�qW5QRX|S)Nz.ziprz-rz-rq�zipzkunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utilityz#creating '%s' and adding '%s' to it�w)Zcompressionrzadding '%s')rr'r(r)�zipfilerrrr+ZZipFileZZIP_DEFLATED�RuntimeErrorZ
ZIP_STORED�curdir�normpath�join�write�walk�isfile)r2r3r4rZzip_filenameZ
zipoptionsr8r(�dirpathZdirnames�	filenamesr
rrr�make_zipfilesV	�
���
�rD)rrzgzip'ed tar-file)rrzbzip2'ed tar-file)rrzxz'ed tar-file)rrzcompressed tar file)rNzuncompressed tar filezZIP file)ZgztarZbztarZxztarZztarr5r8cCs|D]}|tkr|SqdSr)�ARCHIVE_FORMATS)Zformats�formatrrr�check_archive_formats�s
rGc
Cs�t��}|dk	r6t�d|�tj�|�}|s6t�|�|dkrDtj}d|i}	zt|}
Wn t	k
rxt
d|��YnX|
d}|
dD]\}}
|
|	|<q�|dkr�||	d<||	d<z|||f|	�}W5|dk	r�t�d	|�t�|�X|S)
Nzchanging into '%s'rzunknown archive format '%s'r�r8r!r zchanging back to '%s')r'�getcwdr�debugr(�abspath�chdirr<rErr%)r2rFZroot_dirr3r4rr!r Zsave_cwd�kwargsZformat_info�func�arg�val�filenamerrr�make_archive�s2

rR)rrrNN)rr)NNrrNN)r'�warningsrr0r:�ImportErrorZdistutils.errorsrZdistutils.spawnrZdistutils.dir_utilrZ	distutilsr�pwdrZgrprrrr7rDrErGrRrrrr�<module>sL


�
H
=




�	
�PK32�\�VH9�-�-"_msvccompiler.cpython-38.opt-2.pycnu�[���U

e5dRN�@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
ddlmZddlmZddlmZdd�Zd	d
�Zddd
dd�Zdd�Zdd�Zddd�Zddddd�ZGdd�de�ZdS)�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_lib_options)�log)�get_platform)�countcCsztjtjdtjtjBd�}Wn tk
r>t�d�YdSXd}d}|��t�D]�}zt�	||�\}}}Wntk
r�Yq�YnX|rT|tj
krTtj�
|�rTztt|��}Wnttfk
r�YqTYnX|dkrT||krT||}}qTW5QRX||fS)Nz'Software\Microsoft\VisualStudio\SxS\VC7)�accesszVisual C++ is not registered�NNr�)�winregZ	OpenKeyEx�HKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEY�OSErrorr	�debugrZ	EnumValueZREG_SZ�os�path�isdir�int�float�
ValueError�	TypeError)�key�best_version�best_dir�i�vZvc_dirZvt�version�r �//usr/lib64/python3.8/distutils/_msvccompiler.py�_find_vc2015s2
�



r"c
Cs�ddl}tj�d�ptj�d�}|s(dSz8tjtj�|ddd�dd	d
ddd
ddg	ddd���}Wntj	t
tfk
r~YdSXtj�|ddd�}tj�|�r�d|fSdS)NrzProgramFiles(x86)ZProgramFilesr
zMicrosoft Visual StudioZ	Installerzvswhere.exez-latestz-prereleasez	-requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z	-propertyZinstallationPathz	-products�*�mbcs�strict)�encoding�errorsZVCZ	AuxiliaryZBuild�)
�jsonr�environ�get�
subprocess�check_outputr�join�strip�CalledProcessErrorr�UnicodeDecodeErrorr)r)�rootrr r r!�_find_vc2017:s2
��r3�x86Zx64ZarmZarm64)r4�	x86_amd64�x86_arm�	x86_arm64cCs\t�\}}|st�\}}|s*t�d�dStj�|d�}tj�|�sTt�d|�dS|dfS)Nz$No suitable Visual C++ version foundr
z
vcvarsall.batz%s cannot be found)r3r"r	rrrr.�isfile)�	plat_spec�_rr�	vcvarsallr r r!�_find_vcvarsallcs


r<c
Cs�t�d�rdd�tj��D�St|�\}}|s6td��z&tjd�||�tj	d�j
ddd	�}Wn@tjk
r�}z t�
|j�td
�|j���W5d}~XYnXdd�dd
�|��D�D�}|S)NZDISTUTILS_USE_SDKcSsi|]\}}|��|�qSr ��lower)�.0r�valuer r r!�
<dictcomp>ws�z_get_vc_env.<locals>.<dictcomp>zUnable to find vcvarsall.batzcmd /u /c "{}" {} && set)�stderrzutf-16le�replace)r'zError executing {}cSs$i|]\}}}|r|r|��|�qSr r=)r?rr:r@r r r!rA�s
�css|]}|�d�VqdS)�=N)�	partition)r?�liner r r!�	<genexpr>�sz_get_vc_env.<locals>.<genexpr>)r�getenvr*�itemsr<rr,r-�formatZSTDOUT�decoder0r	�error�output�cmd�
splitlines)r9r;r:�out�exc�envr r r!�_get_vc_envus0
�
��
��rScCsN|st�d��tj�}|D].}tj�tj�|�|�}tj�|�r|Sq|S�Nr)rrH�split�pathseprr.�abspathr8)Zexe�paths�p�fnr r r!�	_find_exe�s	
r[r5r6r7)Zwin32z	win-amd64z	win-arm32z	win-arm64c
s�eZdZdZiZdgZdddgZdgZdgZeeeeZ	dZ
d	Zd
ZdZ
dZZd
Zd'dd�Zd(dd�Zd)dd�Zd*dd�Zd+dd�Zd,dd�Z�fdd�Zdd �Zd!d"�Zd#d$�Zd-d%d&�Z�ZS).�MSVCCompilerZmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs t�||||�d|_d|_dS)NF)r�__init__�	plat_name�initialized)�self�verboseZdry_runZforcer r r!r^�szMSVCCompiler.__init__NcCs�|dkrt�}|tkr(td�tt����t|}t|�}|sDtd��|�dd�|_|j�t	j
�}td|�|_td|�|_
td|�|_td|�|_td	|�|_td
|�|_|�dd��t	j
�D]}|r�|�|�t	j��q�|�dd��t	j
�D]}|r�|�|�t	j��q�d|_d
dddddg|_d
dddddg|_d
ddg}d
dddg}|d �|_|d!�|_|d"�|_|d#�|_|�|_|�|_tj df|jtj df|jtj df|jtj!df|jtj!df|jtj!df|jtj"df|jtj"df|jtj"df|ji	|_#d|_$dS)$Nz--plat-name must be one of {}z7Unable to find a compatible Visual Studio installation.r�zcl.exezlink.exezlib.exezrc.exezmc.exezmt.exeZinclude�libz/nologoz/Oxz/W3z/GLz/DNDEBUGz/MDz/Odz/MDdz/Ziz/D_DEBUGz/INCREMENTAL:NOz/LTCGz/DEBUG:FULL�/MANIFEST:EMBED,ID=1�/DLL�/MANIFEST:EMBED,ID=2�/MANIFESTUAC:NOFT)re)re)rfrgrh)rfrgrh)%r
�PLAT_TO_VCVARSrrJ�tuplerSr+�_pathsrUrrVr[�cc�linkerrd�rc�mcZmtZadd_include_dir�rstrip�sepZadd_library_dirZpreprocess_options�compile_options�compile_options_debugZldflags_exeZldflags_exe_debugZldflags_sharedZldflags_shared_debugZldflags_staticZldflags_static_debugrZ
EXECUTABLEZ
SHARED_OBJECTZSHARED_LIBRARY�_ldflagsr`)rar_r9Zvc_envrX�dir�ldflagsZ
ldflags_debugr r r!�
initialize�s������



�zMSVCCompiler.initializerccsT�fdd��jD��fdd��j�jD����p4d����fdd�}tt||��S)Ncsi|]}|�j�qSr )�
obj_extension�r?�ext�rar r!rA&sz1MSVCCompiler.object_filenames.<locals>.<dictcomp>csi|]}|�j�qSr )�
res_extensionryr{r r!rA'srccs�tj�|�\}}�r"tj�|�}n2tj�|�\}}|�tjjtjjf�rT|dd�}ztj��|�|�WSt	k
r�t
d�|���YnXdS)N�zDon't know how to compile {})rr�splitext�basename�
splitdrive�
startswithrq�altsepr.�LookupErrorrrJ)rY�baserzr:)�ext_map�
output_dir�	strip_dirr r!�
make_out_path,sz4MSVCCompiler.object_filenames.<locals>.make_out_path)�src_extensions�_rc_extensions�_mc_extensions�list�map)raZsource_filenamesr�r�r�r )r�r�rar�r!�object_filenames!s�zMSVCCompiler.object_filenamesc	Cs�|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�d}|
D�]}z||\}}Wntk
r�YqhYnX|r�tj	�
|�}||jkr�d|}�nD||jkr�d|}d}�n*||j
k�r@|}d|}z|�|jg|||g�Wqhtk
�r:}zt|��W5d}~XYqhXqhn�||jk�r�tj	�|�}tj	�|�}z\|�|jd|d||g�tj	�tj	�|��\}}tj	�||d	�}|�|jd||g�Wqhtk
�r�}zt|��W5d}~XYqhXqhntd
�||���|jg|
|}|�r"|�d�|�|�|�d|�|�|�z|�|�Wqhtk
�r~}zt|��W5d}~XYqhXqh|
S)
Nz/cFz/Tcz/TpTz/foz-hz-rr]z"Don't know how to compile {} to {}z/EHscz/Fo)r`rwZ_setup_compile�append�extendrsrr�KeyErrorrrrW�
_c_extensions�_cpp_extensionsr��spawnrnrrr��dirnameror~rr.rJrl)raZsourcesr�ZmacrosZinclude_dirsr�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_optsZadd_cpp_opts�obj�srcrzZ	input_optZ
output_opt�msgZh_dirZrc_dirr�r:Zrc_file�argsr r r!�compileBsx
�




�


zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz,t�d|jd�|��|�	|jg|�Wq�t
k
r�}zt|��W5d}~XYq�Xnt�d|�dS)N)r��/OUT:�Executing "%s" %s� �skipping %s (up-to-date))r`rw�_fix_object_args�library_filename�
_need_linkr	rrdr.r�rr)	rar�Zoutput_libnamer�r�target_lang�output_filenameZlib_argsr�r r r!�create_static_lib�s�zMSVCCompiler.create_static_libc
Cs�|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��r�|j||	f}dd�|p�gD�}||||d|g}tj�|d�}|dk	�rtj�
tj�|��\}}tj�	||�|��}|�d|�|
�r|
|dd�<|�r.|�|�tj�tj�|��}|�|�z,t�d|jd�	|��|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d	|�dS)
Nz5I don't know what to do with 'runtime_library_dirs': cSsg|]}d|�qS)z/EXPORT:r )r?Zsymr r r!�
<listcomp>�sz%MSVCCompiler.link.<locals>.<listcomp>r�rz/IMPLIB:r�r�r�)r`rwr�Z
_fix_lib_args�warn�strrrrr.r�rtr�r~rr�r�r�rWZmkpathr	rrmr�rr)raZtarget_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrr�r�Z
build_tempr�Z
fixed_argsZlib_optsrvZexport_optsZld_argsZdll_nameZdll_extZimplib_filer�r r r!�link�s`�
��
��

��

zMSVCCompiler.linkc	s8t�d�}z|jtjd<t��|�W�S|tjd<XdSrT)rrHr*rk�superr�)rarNZold_path��	__class__r r!r��s

zMSVCCompiler.spawncCsd|S)Nz	/LIBPATH:r �rarur r r!�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz:don't know how to set runtime library search path for MSVC)rr�r r r!�runtime_library_dir_option
s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�S)N)r�)rardr r r!�library_optionszMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rrr.r�r8)ra�dirsrdrZ	try_namesru�nameZlibfiler r r!�find_library_fileszMSVCCompiler.find_library_file)rrr)N)rrc)NNNrNNN)NrN)
NNNNNrNNNN)r)�__name__�
__module__�__qualname__Z
compiler_typeZexecutablesr�r�r�r�r�r|rxZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr^rwr�r�r�r�r�r�r�r�r��
__classcell__r r r�r!r\�sd
��

P�
"�
]�
�
Er\)N)rZshutil�statr,rZdistutils.errorsrrrrrZdistutils.ccompilerrrZ	distutilsr	Zdistutils.utilr
�	itertoolsrr"r3ZPLAT_SPEC_TO_RUNTIMEr<rSr[rir\r r r r!�<module>s2#�
�PK42�\�$�

text_file.cpython-38.opt-2.pycnu�[���U

e5d�0�@s"ddlZddlZGdd�d�ZdS)�Nc@speZdZdddddddd�Zddd�Zdd	�Zd
d�Zddd
�Zddd�Zddd�Z	dd�Z
dd�Zdd�ZdS)�TextFile�r�strict)�strip_comments�skip_blanks�	lstrip_ws�	rstrip_ws�
join_lines�
collapse_join�errorsNcKs�|dkr|dkrtd��|j��D]0}||kr@t||||�q"t|||j|�q"|��D]}||jkr\td|��q\|dkr�|�|�n||_||_d|_g|_	dS)Nz7you must supply either or both of 'filename' and 'file'zinvalid TextFile option '%s'r)
�RuntimeError�default_options�keys�setattr�KeyError�open�filename�file�current_line�linebuf)�selfrrZoptions�opt�r�+/usr/lib64/python3.8/distutils/text_file.py�__init__Ns
zTextFile.__init__cCs&||_tj|jd|jd�|_d|_dS)N�r)rr)r�iorrrr)rrrrrrosz
TextFile.opencCs$|j}d|_d|_d|_|��dS�N)rrr�close)rrrrrrvs
zTextFile.closecCsjg}|dkr|j}|�|jd�t|ttf�rD|�dt|��n|�d|�|�t|��d�|�S)Nz, z
lines %d-%d: z	line %d: �)r�appendr�
isinstance�list�tuple�str�join)r�msg�lineZoutmsgrrr�	gen_errorszTextFile.gen_errorcCstd|�||���dS)Nzerror: )�
ValueErrorr(�rr&r'rrr�error�szTextFile.errorcCs tj�d|�||�d�dS)Nz	warning: �
)�sys�stderr�writer(r*rrr�warn�sz
TextFile.warncCs�|jr|jd}|jd=|Sd}|j��}|dkr6d}|jr�|r�|�d�}|dkrTnX|dksl||ddkr�|ddkr|dp~d}|d|�|}|��dkr�q n|�dd�}|j�r|�r|dkr�|�d	�|S|j	r�|�
�}||}t|jt
��r
|jdd|jd<n|j|jdg|_n:|dk�r,dSt|jt
��rL|jdd|_n|jd|_|j�rr|j�rr|��}n"|j�r�|�
�}n|j�r�|��}|dk�s�|dk�r�|j�r�q |j�r�|ddk�r�|dd�}q |d
d�dk�r�|dd
�d}q |S)N���r�#rr�\r,z\#z2continuation line immediately precedes end-of-file���z\
)rr�readliner�find�strip�replacer	r0r
�lstripr!rr"rr�rstripr)rr'Zbuildup_line�posZeolrrrr5�sf




	
�


zTextFile.readlinecCs(g}|��}|dkr|S|�|�qdSr)r5r )r�linesr'rrr�	readliness
zTextFile.readlinescCs|j�|�dSr)rr )rr'rrr�
unreadlineszTextFile.unreadline)NN)N)N)N)
�__name__�
__module__�__qualname__r
rrrr(r+r0r5r=r>rrrrr
s";�	
!	



x
r)r-rrrrrr�<module>sPK42�\�x�a
a
%versionpredicate.cpython-38.opt-2.pycnu�[���U

e5d
�@s~ddlZddlZddlZe�dej�Ze�d�Ze�d�Zdd�Z	ej
ejejej
ejejd�ZGdd	�d	�Zdad
d�ZdS)�Nz'(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)z^\s*\((.*)\)\s*$z%^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$cCs6t�|�}|std|��|��\}}|tj�|�fS)Nz"bad package restriction syntax: %r)�re_splitComparison�match�
ValueError�groups�	distutils�version�
StrictVersion)�pred�res�compZverStr�r�2/usr/lib64/python3.8/distutils/versionpredicate.py�splitUps

r)�<z<=z==�>z>=z!=c@s$eZdZdd�Zdd�Zdd�ZdS)�VersionPredicatecCs�|��}|std��t�|�}|s.td|��|��\|_}|��}|r�t�|�}|sbtd|��|��d}dd�|�d�D�|_|js�td|��ng|_dS)	Nzempty package restrictionzbad package name in %rzexpected parenthesized list: %rrcSsg|]}t|��qSr)r)�.0ZaPredrrr
�
<listcomp>tsz-VersionPredicate.__init__.<locals>.<listcomp>�,zempty parenthesized list in %r)	�stripr�re_validPackagerr�name�re_paren�splitr	)�selfZversionPredicateStrrZparen�strrrr
�__init__`s&

�zVersionPredicate.__init__cCs8|jr.dd�|jD�}|jdd�|�dS|jSdS)NcSs g|]\}}|dt|��qS)� )r)r�cond�verrrr
r}sz,VersionPredicate.__str__.<locals>.<listcomp>z (z, �))r	r�join)r�seqrrr
�__str__{szVersionPredicate.__str__cCs(|jD]\}}t|||�sdSqdS)NFT)r	�compmap)rrrrrrr
�satisfied_by�szVersionPredicate.satisfied_byN)�__name__�
__module__�__qualname__rr#r%rrrr
rsArcCsdtdkrt�dtj�a|��}t�|�}|s8td|��|�d�pDd}|rVtj	�
|�}|�d�|fS)Nz=([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$z"illegal provides specification: %r��)�
_provision_rx�re�compile�ASCIIrrr�grouprrr)�value�mrrrr
�split_provision�s�
r2)r,Zdistutils.versionr�operatorr-r.rrrr�lt�le�eq�gt�ge�ner$rr+r2rrrr
�<module>s �

�nPK42�\
8$ow
w
dir_util.cpython-38.opt-2.pycnu�[���U

e5db�@slddlZddlZddlmZmZddlmZiaddd�Zddd	�Z	dd
d�Z
dd
�Zddd�Zdd�Z
dS)�N)�DistutilsFileError�DistutilsInternalError)�log��cCsft|t�std|f��tj�|�}g}tj�|�s<|dkr@|St�tj�	|��rV|Stj�
|�\}}|g}|r�|r�tj�|�s�tj�
|�\}}|�d|�ql|D]�}tj�||�}tj�	|�}	t�|	�r�q�|dkr�t
�d|�|�sXzt�||�WnVtk
�rL}
z6|
jtjk�r&tj�|��s<td||
jdf��W5d}
~
XYnX|�|�dt|	<q�|S)Nz(mkpath: 'name' must be a string (got %r)�rrzcreating %szcould not create '%s': %s���)�
isinstance�strr�os�path�normpath�isdir�
_path_created�get�abspath�split�insert�joinr�info�mkdir�OSError�errnoZEEXISTr�args�append)�name�mode�verbose�dry_runZcreated_dirs�head�tailZtails�dZabs_head�exc�r#�*/usr/lib64/python3.8/distutils/dir_util.py�mkpathsB
�
�

r%c	CsNt�}|D] }|�tj�|tj�|���q
t|�D]}t||||d�q4dS)N�rr)�set�addrrr�dirname�sortedr%)Zbase_dir�filesrrrZneed_dir�file�dirr#r#r$�create_treePs
r.c
Cs^ddlm}|s(tj�|�s(td|��zt�|�}	Wn>tk
rt}
z |rRg}	ntd||
jf��W5d}
~
XYnX|s�t	||d�g}|	D]�}tj�
||�}
tj�
||�}|�d�r�q�|�r
tj�|
��r
t�
|
�}|dkr�t�d||�|s�t�||�|�|�q�tj�|
��r8|�t|
|||||||d	��q�||
||||||d	�|�|�q�|S)
Nr)�	copy_filez&cannot copy tree '%s': not a directoryzerror listing files in '%s': %s)rz.nfsrzlinking %s -> %sr&)Zdistutils.file_utilr/rrrr�listdirr�strerrorr%r�
startswith�islink�readlinkrr�symlinkr�extend�	copy_tree)�srcZdstZ
preserve_modeZpreserve_timesZpreserve_symlinks�updaterrr/�names�eZoutputs�nZsrc_nameZdst_nameZ	link_destr#r#r$r7cs\��

���r7cCsft�|�D]F}tj�||�}tj�|�r@tj�|�s@t||�q
|�tj|f�q
|�tj	|f�dS)N)
rr0rrrr3�_build_cmdtupler�remove�rmdir)r�	cmdtuples�fZreal_fr#r#r$r=�sr=cCs�|dkrt�d|�|rdSg}t||�|D]h}z2|d|d�tj�|d�}|tkrbt|=Wq.tk
r�}zt�d||�W5d}~XYq.Xq.dS)Nrz'removing '%s' (and everything under it)rzerror removing %s: %s)	rrr=rrrrr�warn)Z	directoryrrr@�cmdrr"r#r#r$�remove_tree�s

rDcCs6tj�|�\}}|dd�tjkr2||dd�}|S)Nrr)rr�
splitdrive�sep)rZdriver#r#r$�ensure_relative�srG)rrr)rrr)rrrrrr)rr)rrZdistutils.errorsrrZ	distutilsrrr%r.r7r=rDrGr#r#r#r$�<module>s
?
�
E

PK42�\�
�,JJunixccompiler.cpython-38.pycnu�[���U

&�.e�;�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
mZmZmZddlmZejdkr~ddlZGd	d
�d
e	�ZdS)a9distutils.unixccompiler

Contains the UnixCCompiler class, a subclass of CCompiler that handles
the "typical" Unix-style command-line C compiler:
  * macros defined with -Dname[=value]
  * macros undefined with -Uname
  * include search directories specified with -Idir
  * libraries specified with -lllib
  * library search directories specified with -Ldir
  * compile handled by 'cc' (or similar) executable with -c option:
    compiles .c to .o
  * link static library handled by 'ar' command (possibly with 'ranlib')
  * link shared library handled by 'cc -shared'
�N)�	sysconfig)�newer)�	CCompiler�gen_preprocess_options�gen_lib_options)�DistutilsExecError�CompileError�LibError�	LinkError)�log�darwinc
s�eZdZdZddgdgdgddgdgddgdd�Zejdd�d	krNd
ged
<ddd
dddgZdZdZ	dZ
dZdZdZ
ZZeZejdkr�dZ�fdd�Zd.dd�Zdd�Zd/d d!�Zd0d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd1d,d-�Z�ZS)2�
UnixCCompilerZunixNZccz-sharedZarz-cr)�preprocessor�compiler�compiler_so�compiler_cxx�	linker_so�
linker_exe�archiver�ranlib�rrz.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%s�cygwinz.execs@t��|||�\}}}t�d�}|r6||kr6|�|�|||fS)z'Remove standard library path from rpathZLIBDIR)�super�
_fix_lib_argsr�get_config_var�remove)�self�	libraries�library_dirs�runtime_library_dirsZlibdir��	__class__��//usr/lib64/python3.8/distutils/unixccompiler.pyrUs�


zUnixCCompiler._fix_lib_argsc
Cs�|�d||�}|\}}}t||�}	|j|	}
|r>|
�d|g�|rN||
dd�<|r\|
�|�|
�|�|js~|dks~t||�r�|r�|�tj	�
|��z|�|
�Wn*tk
r�}zt
|��W5d}~XYnXdS)N�-or)Z_fix_compile_argsrr�extend�appendZforcer�mkpath�os�path�dirname�spawnrr)r�sourceZoutput_fileZmacrosZinclude_dirs�
extra_preargs�extra_postargs�
fixed_args�ignore�pp_optsZpp_args�msgr"r"r#�
preprocess^s$




zUnixCCompiler.preprocessc	
Csp|j}tjdkr t�|||�}z |�|||d|g|�Wn*tk
rj}zt|��W5d}~XYnXdS)Nrr$)r�sys�platform�_osx_support�compiler_fixupr+rr)	r�obj�srcZextZcc_argsr.r1rr2r"r"r#�_compilexs
��
zUnixCCompiler._compilerc
Cs�|�||�\}}|j||d�}|�||�r�|�tj�|��|�|j|g||j	�|j
r�z|�|j
|g�Wq�tk
r�}zt|��W5d}~XYq�Xnt
�d|�dS)N)�
output_dir�skipping %s (up-to-date))�_fix_object_args�library_filename�
_need_linkr'r(r)r*r+r�objectsrrr	r�debug)rr@Zoutput_libnamer;rA�target_lang�output_filenamer2r"r"r#�create_static_lib�s$����	zUnixCCompiler.create_static_libc
Cs�|�||�\}}|�|||�}|\}}}t||||�}t|ttd�f�sPtd��|dk	rftj�	||�}|�
||��r�||j|d|g}|	r�dg|dd�<|
r�|
|dd�<|r�|�|�|�
tj�|��z�|tjkr�|jdd�}n|jdd�}|
dk�rr|j�rrd}tj�|d�dk�r@d}d||k�r@|d7}�q&tj�||�d	k�r\d}nd}|j||||<tjd
k�r�t�||�}|�||�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz%'output_dir' must be a string or Noner$z-grzc++�env��=Z	ld_so_aixrr<)r=rr�
isinstance�str�type�	TypeErrorr(r)�joinr?r@r%r'r*rZ
EXECUTABLErrr�basenamer4r5r6r7r+rr
rrA)rZtarget_descr@rCr;rrrZexport_symbolsrAr-r.Z
build_temprBr/Zlib_optsZld_argsZlinker�i�offsetr2r"r"r#�link�sZ�
���

zUnixCCompiler.linkcCsd|S)N�-Lr")r�dirr"r"r#�library_dir_option�sz UnixCCompiler.library_dir_optioncCsd|kpd|kS)NZgcczg++r")rZ
compiler_namer"r"r#�_is_gcc�szUnixCCompiler._is_gcccCs�tj�t�d��}tjdd�dkr,d|Stjdd�dkrFd|Stjdd�d	krz|�|�rnd
d|gSdd|gS|�|�r�t�d�d
kr�d|Sd|Snd|SdS)N�CCrrrQ�Zfreebsdz-Wl,-rpath=�zhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r(r)rMrrr4r5rT)rrRrr"r"r#�runtime_library_dir_option�s


z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr")r�libr"r"r#�library_optionszUnixCCompiler.library_optioncCs�|j|dd�}|j|dd�}|j|dd�}|j|dd�}tjdkr|t�d�}t�d|�}	|	dkrrt�t�d	��}
n
|	�	d
�}
|D�] }t
j�||�}t
j�||�}
t
j�||�}t
j�||�}tjdk�rL|�
d�s�|�
d��rL|�
d
��sLt
j�|
|d
d�|�}t
j�|
|d
d�|�}
t
j�|
|d
d�|�}t
j�|
|d
d�|�}t
j�|
��rb|
St
j�|��rx|St
j�|��r�|St
j�|�r�|Sq�dS)N�shared)Zlib_type�dylib�
xcode_stub�staticrZCFLAGSz-isysroot\s*(\S+)rUrFz/System/z/usr/z/usr/local/)r>r4r5rr�re�searchr6Z_default_sysroot�groupr(r)rL�
startswith�exists)r�dirsrYrAZshared_fZdylib_fZxcode_stub_fZstatic_fZcflags�mZsysrootrRr[r\r^r]r"r"r#�find_library_filesF



���
zUnixCCompiler.find_library_file)NNNNN)NrN)
NNNNNrNNNN)r)�__name__�
__module__�__qualname__Z
compiler_typeZexecutablesr4r5Zsrc_extensionsZ
obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ
exe_extensionrr3r:rDrPrSrTrXrZrf�
__classcell__r"r"r r#r
-sb�


	�
�
�
B*r
)�__doc__r(r4r_Z	distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr	r
rr5r6r
r"r"r"r#�<module>s
PK42�\\�p���version.cpython-38.pycnu�[���U

e5d90�@s>dZddlZGdd�d�ZGdd�de�ZGdd�de�ZdS)	a�Provides classes to represent module version numbers (one class for
each style of version numbering).  There are currently two such classes
implemented: StrictVersion and LooseVersion.

Every version number class implements the following interface:
  * the 'parse' method takes a string and parses it to some internal
    representation; if the string is an invalid version number,
    'parse' raises a ValueError exception
  * the class constructor takes an optional string argument which,
    if supplied, is passed to 'parse'
  * __str__ reconstructs the string that was passed to 'parse' (or
    an equivalent string -- ie. one that will generate an equivalent
    version number instance)
  * __repr__ generates Python code to recreate the version number instance
  * _cmp compares the current instance with either another instance
    of the same class or a string (which will be parsed to an instance
    of the same class, thus must follow the same rules)
�Nc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�Versionz�Abstract base class for version numbering classes.  Just provides
    constructor (__init__) and reproducer (__repr__), because those
    seem to be the same for all version numbering classes; and route
    rich comparisons to _cmp.
    NcCs|r|�|�dS�N��parse��self�vstring�r	�)/usr/lib64/python3.8/distutils/version.py�__init__&szVersion.__init__cCsd|jjt|�fS)Nz	%s ('%s'))�	__class__�__name__�str�rr	r	r
�__repr__*szVersion.__repr__cCs|�|�}|tkr|S|dkS�Nr��_cmp�NotImplemented�r�other�cr	r	r
�__eq__-s
zVersion.__eq__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__lt__3s
zVersion.__lt__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__le__9s
zVersion.__le__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__gt__?s
zVersion.__gt__cCs|�|�}|tkr|S|dkSrrrr	r	r
�__ge__Es
zVersion.__ge__)N)r
�
__module__�__qualname__�__doc__rrrrrrrr	r	r	r
rs
rc@s<eZdZdZe�dejejB�Zdd�Z	dd�Z
dd�Zd	S)
�
StrictVersiona?Version numbering for anal retentives and software idealists.
    Implements the standard interface for version number classes as
    described above.  A version number consists of two or three
    dot-separated numeric components, with an optional "pre-release" tag
    on the end.  The pre-release tag consists of the letter 'a' or 'b'
    followed by a number.  If the numeric components of two version
    numbers are equal, then one with a pre-release tag will always
    be deemed earlier (lesser) than one without.

    The following are valid version numbers (shown in the order that
    would be obtained by sorting according to the supplied cmp function):

        0.4       0.4.0  (these two are equivalent)
        0.4.1
        0.5a1
        0.5b3
        0.5
        0.9.6
        1.0
        1.0.4a3
        1.0.4b1
        1.0.4

    The following are examples of invalid version numbers:

        1
        2.7.2.2
        1.3.a4
        1.3pl1
        1.3c4

    The rationale for this version numbering system will be explained
    in the distutils documentation.
    z)^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$cCs�|j�|�}|std|��|�ddddd�\}}}}}|rTttt|||g��|_nttt||g��d|_|r�|dt|�f|_nd|_dS)	Nzinvalid version number '%s'�����)rr)	�
version_re�match�
ValueError�group�tuple�map�int�version�
prerelease)rrr'�major�minorZpatchr.Zprerelease_numr	r	r
r�s�zStrictVersion.parsecCsb|jddkr*d�tt|jdd���}nd�tt|j��}|jr^||jdt|jd�}|S)Nr"r�.r!)r-�joinr+rr.rr	r	r
�__str__�szStrictVersion.__str__cCs�t|t�rt|�}|j|jkr2|j|jkr.dSdS|jsB|jsBdS|jrR|jsRdS|jsb|jrbdS|jr�|jr�|j|jkr~dS|j|jkr�dSdSnds�td��dS)N���r!rFznever get here)�
isinstancerr r-r.�AssertionError�rrr	r	r
r�s&
zStrictVersion._cmpN)r
rrr�re�compile�VERBOSE�ASCIIr&rr3rr	r	r	r
r ]s#
�
r c@sHeZdZdZe�dej�Zddd�Zdd�Z	dd	�Z
d
d�Zdd
�ZdS)�LooseVersiona�Version numbering for anarchists and software realists.
    Implements the standard interface for version number classes as
    described above.  A version number consists of a series of numbers,
    separated by either periods or strings of letters.  When comparing
    version numbers, the numeric components will be compared
    numerically, and the alphabetic components lexically.  The following
    are all valid version numbers, in no particular order:

        1.5.1
        1.5.2b2
        161
        3.10a
        8.02
        3.4j
        1996.07.12
        3.2.pl0
        3.1.1.6
        2g6
        11g
        0.960923
        2.2beta29
        1.13++
        5.5.kw
        2.0b1pl0

    In fact, there is no such thing as an invalid version number under
    this scheme; the rules for comparison are simple and predictable,
    but may not always give the results you want (for some definition
    of "want").
    z(\d+ | [a-z]+ | \.)NcCs|r|�|�dSrrrr	r	r
r.szLooseVersion.__init__c	Cs^||_dd�|j�|�D�}t|�D].\}}zt|�||<Wq$tk
rPYq$Xq$||_dS)NcSsg|]}|r|dkr|�qS)r1r	)�.0�xr	r	r
�
<listcomp>8s�z&LooseVersion.parse.<locals>.<listcomp>)r�component_re�split�	enumerater,r(r-)rrZ
components�i�objr	r	r
r3szLooseVersion.parsecCs|jSr)rrr	r	r
r3CszLooseVersion.__str__cCsdt|�S)NzLooseVersion ('%s'))rrr	r	r
rGszLooseVersion.__repr__cCsFt|t�rt|�}|j|jkr"dS|j|jkr2dS|j|jkrBdSdS)Nrr4r!)r5rr<r-r7r	r	r
rKs
zLooseVersion._cmp)N)
r
rrrr8r9r:r@rrr3rrr	r	r	r
r<s
r<)rr8rr r<r	r	r	r
�<module>
s
>/PK42�\%E�,}}!bcppcompiler.cpython-38.opt-1.pycnu�[���U

e5dW:�@sxdZddlZddlmZmZmZmZmZmZddl	m
Z
mZmZddl
mZddlmZddlmZGdd	�d	e
�ZdS)
z�distutils.bcppcompiler

Contains BorlandCCompiler, an implementation of the abstract CCompiler class
for the Borland C++ compiler.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError�UnknownFileError)�	CCompiler�gen_preprocess_options�gen_lib_options)�
write_file)�newer)�logc
@s�eZdZdZdZiZdgZdddgZeeZdZ	dZ
d	Zd
ZZ
dZdd
d�Zddd�Zddd�Zd dd�Zd!dd�Zd"dd�Zd#dd�ZdS)$�BCPPCompilerzConcrete class that implements an interface to the Borland C/C++
    compiler, as defined by the CCompiler abstract class.
    Zbcppz.cz.ccz.cppz.cxxz.objz.libz.dllz%s%sz.exercCs�t�||||�d|_d|_d|_d|_ddddg|_ddddg|_d	d
ddg|_d	d
ddg|_	g|_
d
ddg|_d
dddg|_dS)
Nz	bcc32.exezilink32.exeztlib.exez/tWMz/O2z/qz/g0z/Odz/Tpdz/Gnz/xz/r)
r�__init__�cc�linker�libZpreprocess_options�compile_options�compile_options_debug�ldflags_shared�ldflags_shared_debugZldflags_static�ldflags_exe�ldflags_exe_debug)�self�verboseZdry_run�force�r�./usr/lib64/python3.8/distutils/bcppcompiler.pyr5szBCPPCompiler.__init__Nc	Cs�|�||||||�\}}	}}
}|p$g}|�d�|rB|�|j�n|�|j�|	D�]<}
z||
\}}Wntk
r�YqRYnXtj�|�}tj�|
�}
|�	tj�
|
��|dkr�qR|dk�rz|�dd|
|g�WqRtk
�r}zt
|��W5d}~XYqRXqR||jk�rd}n||jk�r*d}nd}d|
}z,|�|jg||
||g||g�WqRtk
�r�}zt
|��W5d}~XYqRXqR|	S)	Nz-c�.res�.rcZbrcc32z-fo�z-P�-o)Z_setup_compile�append�extendrr�KeyError�os�path�normpath�mkpath�dirname�spawnrr�
_c_extensions�_cpp_extensionsr)rZsources�
output_dir�macros�include_dirs�debug�
extra_preargs�extra_postargsZdepends�objects�pp_optsZbuildZcompile_opts�obj�src�ext�msgZ	input_optZ
output_optrrr�compileQsV��



���
zBCPPCompiler.compilec	
Cs�|�||�\}}|j||d�}|�||�r~|dg|}|r:z|�|jg|�Wq�tk
rz}zt|��W5d}~XYq�Xnt�d|�dS)N)r-z/u�skipping %s (up-to-date))	�_fix_object_args�library_filename�
_need_linkr*rrrr
r0)	rr3Zoutput_libnamer-r0�target_lang�output_filenameZlib_argsr8rrr�create_static_lib�s�zBCPPCompiler.create_static_libc 
Cs�|�||�\}}|�|||�\}}}|r8t�dt|��|dk	rNtj�||�}|�||��r�|t	j
kr�d}|	r~|jdd�}q�|jdd�}n&d}|	r�|j
dd�}n|jdd�}|dkr�d}n�tj�|�\}}tj�|�\}}tj�|d�}tj�|d|�}dg}|�pgD]}|�d||f��q|�t||fd	|�ttjj|�}|g}g}|D]>}tj�tj�|��\}}|d
k�r�|�|�n
|�|��q`|D]}|�dtj�|���q�|�d�|�|�|�d
|g�|�d�|D]4}|�|||	�}|dk�r|�|�n
|�|��q�|�d�|�d�|�d
|g�|�d
�|�|�|
�rp|
|dd�<|�r�|�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz7I don't know what to do with 'runtime_library_dirs': %sZc0w32Zc0d32r rz%s.defZEXPORTSz  %s=_%sz
writing %srz/L%sz/L.�,z,,Zimport32Zcw32mtr:) r;Z
_fix_lib_argsr
�warn�strr%r&�joinr=rZ
EXECUTABLErrrr�split�splitextr)r"Zexecuter�mapr'�normcaser#�find_library_filer(r*rrrr0) rZtarget_descr3r?r-Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr0r1r2Z
build_tempr>Zstartup_objZld_argsZdef_file�head�tail�modnamer7Ztemp_dir�contentsZsymZobjects2Z	resources�file�base�lr�libfiler8rrr�link�s���
�










zBCPPCompiler.linkc	Csr|r"|d}|d|d||f}n|d|f}|D]:}|D]0}tj�||�|��}tj�|�r:|Sq:q2dS)NZ_dZ_bcpp)r%r&rDr<�exists)	r�dirsrr0ZdlibZ	try_names�dir�namerQrrrrI4s
zBCPPCompiler.find_library_filer cCs�|dkrd}g}|D]�}tj�tj�|��\}}||jddgkrRtd||f��|rbtj�|�}|dkr�|�tj�|||��q|dkr�|�tj�||d��q|�tj�|||j	��q|S)Nr rrz"unknown file type '%s' (from '%s'))
r%r&rFrH�src_extensionsr�basenamer"rD�
obj_extension)rZsource_filenamesZ	strip_dirr-Z	obj_namesZsrc_namerOr7rrr�object_filenamesNs&��zBCPPCompiler.object_filenamesc
Cs�|�d||�\}}}t||�}dg|}	|dk	r>|	�d|�|rN||	dd�<|r\|	�|�|	�|�|js~|dks~t||�r�|r�|�tj�	|��z|�
|	�Wn2tk
r�}
zt|
�t
|
��W5d}
~
XYnXdS)Nz	cpp32.exer!r)Z_fix_compile_argsr	r"r#rrr(r%r&r)r*r�printr)r�sourceZoutput_filer.r/r1r2�_r4Zpp_argsr8rrr�
preprocessis&	�



zBCPPCompiler.preprocess)rrr)NNNrNNN)NrN)
NNNNNrNNNN)r)rr )NNNNN)�__name__�
__module__�__qualname__�__doc__Z
compiler_typeZexecutablesr+r,rWrYZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionrr9r@rRrIrZr^rrrrrsb
�
�
D�
�


�
�r)rbr%Zdistutils.errorsrrrrrrZdistutils.ccompilerrr	r
Zdistutils.file_utilrZdistutils.dep_utilrZ	distutilsr
rrrrr�<module>s PK42�\4��!�
�
config.cpython-38.pycnu�[���U

e5d��@s<dZddlZddlmZddlmZdZGdd�de�ZdS)z�distutils.pypirc

Provides the PyPIRCCommand class, the base class for the command classes
that uses .pypirc in the distutils.command package.
�N)�RawConfigParser)�CommandzE[distutils]
index-servers =
    pypi

[pypi]
username:%s
password:%s
c@sheZdZdZdZdZdZdZdddefdgZd	gZ	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�ZdS)�
PyPIRCCommandz;Base command that knows how to handle the .pypirc file
    zhttps://upload.pypi.org/legacy/�pypiNzrepository=�rzurl of repository [default: %s])�
show-responseNz&display full response text from serverrcCstj�tj�d�d�S)zReturns rc file path.�~z.pypirc)�os�path�join�
expanduser��self�r�(/usr/lib64/python3.8/distutils/config.py�_get_rc_file&szPyPIRCCommand._get_rc_filec	CsH|��}t�t�|tjtjBd�d��}|�t||f�W5QRXdS)zCreates a default .pypirc file.i��wN)rr	�fdopen�open�O_CREAT�O_WRONLY�write�DEFAULT_PYPIRC)r�username�password�rc�frrr�
_store_pypirc*s zPyPIRCCommand._store_pypirccCs�|��}tj�|��r�|�d|�|jp.|j}t�}|�|�|�	�}d|k�rF|�
dd�}dd�|�d�D�}|gkr�d|kr�dg}niS|D]�}d|i}|�
|d	�|d	<d
|jfd|jfdfD].\}	}
|�
||	�r�|�
||	�||	<q�|
||	<q�|dk�r ||jdfk�r |j|d
<|S|d|k�s:|d
|kr�|Sq�nRd
|k�r�d
}|�
|d
��rp|�
|d
�}n|j}|�
|d	�|�
|d�|||jd�SiS)zReads the .pypirc file.zUsing PyPI login from %sZ	distutilsz
index-serverscSs g|]}|��dkr|���qS)�)�strip)�.0�serverrrr�
<listcomp>=s�z.PyPIRCCommand._read_pypirc.<locals>.<listcomp>�
rr!r�
repository�realm)rNzserver-loginr)rrr$r!r%)rr	r
�existsZannouncer$�DEFAULT_REPOSITORYr�read�sections�get�split�
DEFAULT_REALMZ
has_option)rrr$Zconfigr)Z
index_serversZ_serversr!Zcurrent�key�defaultrrr�_read_pypirc0sb

���

�

�


�zPyPIRCCommand._read_pypirccCs8ddl}|�dd�}|�|�d�dd�}|���|�S)z%Read and decode a PyPI HTTP response.rNzcontent-typez
text/plain��charset�ascii)�cgiZ	getheaderZparse_headerr*r(�decode)rZresponser3Zcontent_type�encodingrrr�_read_pypi_responsepsz!PyPIRCCommand._read_pypi_responsecCsd|_d|_d|_dS)zInitialize options.Nr)r$r%Z
show_responser
rrr�initialize_optionswsz PyPIRCCommand.initialize_optionscCs(|jdkr|j|_|jdkr$|j|_dS)zFinalizes options.N)r$r'r%r,r
rrr�finalize_options}s

zPyPIRCCommand.finalize_options)�__name__�
__module__�__qualname__�__doc__r'r,r$r%Zuser_optionsZboolean_optionsrrr/r6r7r8rrrrrs&���@r)r<r	ZconfigparserrZ
distutils.cmdrrrrrrr�<module>s

PK42�\�T� � text_file.cpython-38.opt-1.pycnu�[���U

e5d�0�@s&dZddlZddlZGdd�d�ZdS)z�text_file

provides the TextFile class, which gives an interface to text files
that (optionally) takes care of stripping comments, ignoring blank
lines, and joining lines with backslashes.�Nc@steZdZdZdddddddd�Zddd�Zd	d
�Zdd�Zdd
d�Zddd�Z	ddd�Z
dd�Zdd�Zdd�Z
dS)�TextFilea�Provides a file-like object that takes care of all the things you
       commonly want to do when processing a text file that has some
       line-by-line syntax: strip comments (as long as "#" is your
       comment character), skip blank lines, join adjacent lines by
       escaping the newline (ie. backslash at end of line), strip
       leading and/or trailing whitespace.  All of these are optional
       and independently controllable.

       Provides a 'warn()' method so you can generate warning messages that
       report physical line number, even if the logical line in question
       spans multiple physical lines.  Also provides 'unreadline()' for
       implementing line-at-a-time lookahead.

       Constructor is called as:

           TextFile (filename=None, file=None, **options)

       It bombs (RuntimeError) if both 'filename' and 'file' are None;
       'filename' should be a string, and 'file' a file object (or
       something that provides 'readline()' and 'close()' methods).  It is
       recommended that you supply at least 'filename', so that TextFile
       can include it in warning messages.  If 'file' is not supplied,
       TextFile creates its own using 'io.open()'.

       The options are all boolean, and affect the value returned by
       'readline()':
         strip_comments [default: true]
           strip from "#" to end-of-line, as well as any whitespace
           leading up to the "#" -- unless it is escaped by a backslash
         lstrip_ws [default: false]
           strip leading whitespace from each line before returning it
         rstrip_ws [default: true]
           strip trailing whitespace (including line terminator!) from
           each line before returning it
         skip_blanks [default: true}
           skip lines that are empty *after* stripping comments and
           whitespace.  (If both lstrip_ws and rstrip_ws are false,
           then some lines may consist of solely whitespace: these will
           *not* be skipped, even if 'skip_blanks' is true.)
         join_lines [default: false]
           if a backslash is the last non-newline character on a line
           after stripping comments and whitespace, join the following line
           to it to form one "logical line"; if N consecutive lines end
           with a backslash, then N+1 physical lines will be joined to
           form one logical line.
         collapse_join [default: false]
           strip leading whitespace from lines that are joined to their
           predecessor; only matters if (join_lines and not lstrip_ws)
         errors [default: 'strict']
           error handler used to decode the file content

       Note that since 'rstrip_ws' can strip the trailing newline, the
       semantics of 'readline()' must differ from those of the builtin file
       object's 'readline()' method!  In particular, 'readline()' returns
       None for end-of-file: an empty string might just be a blank line (or
       an all-whitespace line), if 'rstrip_ws' is true but 'skip_blanks' is
       not.�r�strict)�strip_comments�skip_blanks�	lstrip_ws�	rstrip_ws�
join_lines�
collapse_join�errorsNcKs�|dkr|dkrtd��|j��D]0}||kr@t||||�q"t|||j|�q"|��D]}||jkr\td|��q\|dkr�|�|�n||_||_d|_g|_	dS)z�Construct a new TextFile object.  At least one of 'filename'
           (a string) and 'file' (a file-like object) must be supplied.
           They keyword argument options are described above and affect
           the values returned by 'readline()'.Nz7you must supply either or both of 'filename' and 'file'zinvalid TextFile option '%s'r)
�RuntimeError�default_options�keys�setattr�KeyError�open�filename�file�current_line�linebuf)�selfrrZoptions�opt�r�+/usr/lib64/python3.8/distutils/text_file.py�__init__Ns
zTextFile.__init__cCs&||_tj|jd|jd�|_d|_dS)zyOpen a new file named 'filename'.  This overrides both the
           'filename' and 'file' arguments to the constructor.�r)rrN)r�iorrrr)rrrrrrosz
TextFile.opencCs$|j}d|_d|_d|_|��dS)ziClose the current file and forget everything we know about it
           (filename, current line number).N)rrr�close)rrrrrrvs
zTextFile.closecCsjg}|dkr|j}|�|jd�t|ttf�rD|�dt|��n|�d|�|�t|��d�|�S)Nz, z
lines %d-%d: z	line %d: �)r�appendr�
isinstance�list�tuple�str�join)r�msg�lineZoutmsgrrr�	gen_errorszTextFile.gen_errorcCstd|�||���dS)Nzerror: )�
ValueErrorr'�rr%r&rrr�error�szTextFile.errorcCs tj�d|�||�d�dS)a�Print (to stderr) a warning message tied to the current logical
           line in the current file.  If the current logical line in the
           file spans multiple physical lines, the warning refers to the
           whole range, eg. "lines 3-5".  If 'line' supplied, it overrides
           the current line number; it may be a list or tuple to indicate a
           range of physical lines, or an integer for a single physical
           line.z	warning: �
N)�sys�stderr�writer'r)rrr�warn�sz
TextFile.warncCs�|jr|jd}|jd=|Sd}|j��}|dkr6d}|jr�|r�|�d�}|dkrTnX|dksl||ddkr�|ddkr|dp~d}|d|�|}|��dkr�q n|�d	d�}|j�r|�r|dkr�|�d
�|S|j	r�|�
�}||}t|jt
��r
|jdd|jd<n|j|jdg|_n:|dk�r,dSt|jt
��rL|jdd|_n|jd|_|j�rr|j�rr|��}n"|j�r�|�
�}n|j�r�|��}|dk�s�|dk�r�|j�r�q |j�r�|ddk�r�|dd�}q |dd�dk�r�|dd�d}q |S)
aURead and return a single logical line from the current file (or
           from an internal buffer if lines have previously been "unread"
           with 'unreadline()').  If the 'join_lines' option is true, this
           may involve reading multiple physical lines concatenated into a
           single string.  Updates the current line number, so calling
           'warn()' after 'readline()' emits a warning about the physical
           line(s) just read.  Returns None on end-of-file, since the empty
           string can occur if 'rstrip_ws' is true but 'strip_blanks' is
           not.���rN�#rr�\r+z\#z2continuation line immediately precedes end-of-file���z\
)rr�readliner�find�strip�replacer	r/r
�lstripr rr!rr�rstripr)rr&Zbuildup_line�posZeolrrrr4�sf




	
�


zTextFile.readlinecCs(g}|��}|dkr|S|�|�qdS)zWRead and return the list of all logical lines remaining in the
           current file.N)r4r)r�linesr&rrr�	readliness
zTextFile.readlinescCs|j�|�dS)z�Push 'line' (a string) onto an internal buffer that will be
           checked by future 'readline()' calls.  Handy for implementing
           a parser with line-at-a-time lookahead.N)rr)rr&rrr�
unreadlineszTextFile.unreadline)NN)N)N)N)�__name__�
__module__�__qualname__�__doc__r
rrrr'r*r/r4r<r=rrrrr
s$:�	
!	



x
r)rAr,rrrrrr�<module>sPK42�\�6�m2m2"_msvccompiler.cpython-38.opt-1.pycnu�[���U

e5dRN�@s�dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZddlm
Z
mZddlmZddlmZddlmZdd	�Zd
d�Zdd
ddd�Zdd�Zdd�Zddd�Zddddd�ZGdd�de
�ZdS)adistutils._msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for Microsoft Visual Studio 2015.

The module is compatible with VS 2015 and later. You can find legacy support
for older versions in distutils.msvc9compiler and distutils.msvccompiler.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_lib_options)�log)�get_platform)�countcCsztjtjdtjtjBd�}Wn tk
r>t�d�YdSXd}d}|��t�D]�}zt�	||�\}}}Wntk
r�Yq�YnX|rT|tj
krTtj�
|�rTztt|��}Wnttfk
r�YqTYnX|dkrT||krT||}}qTW5QRX||fS)Nz'Software\Microsoft\VisualStudio\SxS\VC7)�accesszVisual C++ is not registered�NNr�)�winregZ	OpenKeyEx�HKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEY�OSErrorr	�debugrZ	EnumValueZREG_SZ�os�path�isdir�int�float�
ValueError�	TypeError)�key�best_version�best_dir�i�vZvc_dirZvt�version�r �//usr/lib64/python3.8/distutils/_msvccompiler.py�_find_vc2015s2
�



r"c
Cs�ddl}tj�d�ptj�d�}|s(dSz8tjtj�|ddd�d	d
ddd
dddg	ddd���}Wntj	t
tfk
r~YdSXtj�|ddd�}tj�|�r�d|fSdS)aJReturns "15, path" based on the result of invoking vswhere.exe
    If no install is found, returns "None, None"

    The version is returned to avoid unnecessarily changing the function
    result. It may be ignored when the path is not None.

    If vswhere.exe is not available, by definition, VS 2017 is not
    installed.
    rNzProgramFiles(x86)ZProgramFilesr
zMicrosoft Visual StudioZ	Installerzvswhere.exez-latestz-prereleasez	-requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z	-propertyZinstallationPathz	-products�*�mbcs�strict)�encoding�errorsZVCZ	AuxiliaryZBuild�)
�jsonr�environ�get�
subprocess�check_outputr�join�strip�CalledProcessErrorr�UnicodeDecodeErrorr)r)�rootrr r r!�_find_vc2017:s2
��r3�x86Zx64ZarmZarm64)r4�	x86_amd64�x86_arm�	x86_arm64cCs\t�\}}|st�\}}|s*t�d�dStj�|d�}tj�|�sTt�d|�dS|dfS)Nz$No suitable Visual C++ version foundr
z
vcvarsall.batz%s cannot be found)r3r"r	rrrr.�isfile)�	plat_spec�_rr�	vcvarsallr r r!�_find_vcvarsallcs


r<c
Cs�t�d�rdd�tj��D�St|�\}}|s6td��z&tjd�||�tj	d�j
ddd	�}Wn@tjk
r�}z t�
|j�td
�|j���W5d}~XYnXdd�dd
�|��D�D�}|S)NZDISTUTILS_USE_SDKcSsi|]\}}|��|�qSr ��lower)�.0r�valuer r r!�
<dictcomp>ws�z_get_vc_env.<locals>.<dictcomp>zUnable to find vcvarsall.batzcmd /u /c "{}" {} && set)�stderrzutf-16le�replace)r'zError executing {}cSs$i|]\}}}|r|r|��|�qSr r=)r?rr:r@r r r!rA�s
�css|]}|�d�VqdS)�=N)�	partition)r?�liner r r!�	<genexpr>�sz_get_vc_env.<locals>.<genexpr>)r�getenvr*�itemsr<rr,r-�formatZSTDOUT�decoder0r	�error�output�cmd�
splitlines)r9r;r:�out�exc�envr r r!�_get_vc_envus0
�
��
��rScCsN|st�d��tj�}|D].}tj�tj�|�|�}tj�|�r|Sq|S)atReturn path to an MSVC executable program.

    Tries to find the program in several places: first, one of the
    MSVC program search paths from the registry; next, the directories
    in the PATH environment variable.  If any of those work, return an
    absolute path that is known to exist.  If none of them work, just
    return the original program name, 'exe'.
    r)rrH�split�pathseprr.�abspathr8)Zexe�paths�p�fnr r r!�	_find_exe�s	
rZr5r6r7)Zwin32z	win-amd64z	win-arm32z	win-arm64c
s�eZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd(dd�Zd)dd�Zd*dd�Zd+dd�Zd,dd�Zd-dd�Z�fdd�Zd d!�Zd"d#�Zd$d%�Zd.d&d'�Z�ZS)/�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs t�||||�d|_d|_dS)NF)r�__init__�	plat_name�initialized)�self�verboseZdry_runZforcer r r!r]�szMSVCCompiler.__init__NcCs�|dkrt�}|tkr(td�tt����t|}t|�}|sDtd��|�dd�|_|j�t	j
�}td|�|_td|�|_
td|�|_td|�|_td	|�|_td
|�|_|�dd��t	j
�D]}|r�|�|�t	j��q�|�dd��t	j
�D]}|r�|�|�t	j��q�d|_d
dddddg|_d
dddddg|_d
ddg}d
dddg}|d �|_|d!�|_|d"�|_|d#�|_|�|_|�|_tj df|jtj df|jtj df|jtj!df|jtj!df|jtj!df|jtj"df|jtj"df|jtj"df|ji	|_#d|_$dS)$Nz--plat-name must be one of {}z7Unable to find a compatible Visual Studio installation.r�zcl.exezlink.exezlib.exezrc.exezmc.exezmt.exeZinclude�libz/nologoz/Oxz/W3z/GLz/DNDEBUGz/MDz/Odz/MDdz/Ziz/D_DEBUGz/INCREMENTAL:NOz/LTCGz/DEBUG:FULL�/MANIFEST:EMBED,ID=1�/DLL�/MANIFEST:EMBED,ID=2�/MANIFESTUAC:NOFT)rd)rd)rerfrg)rerfrg)%r
�PLAT_TO_VCVARSrrJ�tuplerSr+�_pathsrTrrUrZ�cc�linkerrc�rc�mcZmtZadd_include_dir�rstrip�sepZadd_library_dirZpreprocess_options�compile_options�compile_options_debugZldflags_exeZldflags_exe_debugZldflags_sharedZldflags_shared_debugZldflags_staticZldflags_static_debugrZ
EXECUTABLEZ
SHARED_OBJECTZSHARED_LIBRARY�_ldflagsr_)r`r^r9Zvc_envrW�dir�ldflagsZ
ldflags_debugr r r!�
initialize�s������



�zMSVCCompiler.initializerbcsT�fdd��jD��fdd��j�jD����p4d����fdd�}tt||��S)Ncsi|]}|�j�qSr )�
obj_extension�r?�ext�r`r r!rA&sz1MSVCCompiler.object_filenames.<locals>.<dictcomp>csi|]}|�j�qSr )�
res_extensionrxrzr r!rA'srbcs�tj�|�\}}�r"tj�|�}n2tj�|�\}}|�tjjtjjf�rT|dd�}ztj��|�|�WSt	k
r�t
d�|���YnXdS)N�zDon't know how to compile {})rr�splitext�basename�
splitdrive�
startswithrp�altsepr.�LookupErrorrrJ)rX�baseryr:)�ext_map�
output_dir�	strip_dirr r!�
make_out_path,sz4MSVCCompiler.object_filenames.<locals>.make_out_path)�src_extensions�_rc_extensions�_mc_extensions�list�map)r`Zsource_filenamesr�r�r�r )r�r�r`r�r!�object_filenames!s�zMSVCCompiler.object_filenamesc	Cs�|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�d}|
D�]}z||\}}Wntk
r�YqhYnX|r�tj	�
|�}||jkr�d|}�nD||jkr�d|}d}�n*||j
k�r@|}d|}z|�|jg|||g�Wqhtk
�r:}zt|��W5d}~XYqhXqhn�||jk�r�tj	�|�}tj	�|�}z\|�|jd|d||g�tj	�tj	�|��\}}tj	�||d	�}|�|jd||g�Wqhtk
�r�}zt|��W5d}~XYqhXqhntd
�||���|jg|
|}|�r"|�d�|�|�|�d|�|�|�z|�|�Wqhtk
�r~}zt|��W5d}~XYqhXqh|
S)
Nz/cFz/Tcz/TpTz/foz-hz-rr\z"Don't know how to compile {} to {}z/EHscz/Fo)r_rvZ_setup_compile�append�extendrrrq�KeyErrorrrrV�
_c_extensions�_cpp_extensionsr��spawnrmrrr��dirnamernr}r~r.rJrk)r`Zsourcesr�ZmacrosZinclude_dirsr�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_optsZadd_cpp_opts�obj�srcryZ	input_optZ
output_opt�msgZh_dirZrc_dirr�r:Zrc_file�argsr r r!�compileBsx
�




�


zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz,t�d|jd�|��|�	|jg|�Wq�t
k
r�}zt|��W5d}~XYq�Xnt�d|�dS)N)r��/OUT:�Executing "%s" %s� �skipping %s (up-to-date))r_rv�_fix_object_args�library_filename�
_need_linkr	rrcr.r�rr)	r`r�Zoutput_libnamer�r�target_lang�output_filenameZlib_argsr�r r r!�create_static_lib�s�zMSVCCompiler.create_static_libc
Cs�|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��r�|j||	f}dd�|p�gD�}||||d|g}tj�|d�}|dk	�rtj�
tj�|��\}}tj�	||�|��}|�d|�|
�r|
|dd�<|�r.|�|�tj�tj�|��}|�|�z,t�d|jd�	|��|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d	|�dS)
Nz5I don't know what to do with 'runtime_library_dirs': cSsg|]}d|�qS)z/EXPORT:r )r?Zsymr r r!�
<listcomp>�sz%MSVCCompiler.link.<locals>.<listcomp>r�rz/IMPLIB:r�r�r�)r_rvr�Z
_fix_lib_args�warn�strrrrr.r�rsr�r}r~r�r�r�rVZmkpathr	rrlr�rr)r`Ztarget_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrr�r�Z
build_tempr�Z
fixed_argsZlib_optsruZexport_optsZld_argsZdll_nameZdll_extZimplib_filer�r r r!�link�s`�
��
��

��

zMSVCCompiler.linkc	s8t�d�}z|jtjd<t��|�W�S|tjd<XdS)Nr)rrHr*rj�superr�)r`rNZold_path��	__class__r r!r��s

zMSVCCompiler.spawncCsd|S)Nz	/LIBPATH:r �r`rtr r r!�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz:don't know how to set runtime library search path for MSVC)rr�r r r!�runtime_library_dir_option
s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�S)N)r�)r`rcr r r!�library_optionszMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rrr.r�r8)r`�dirsrcrZ	try_namesrt�nameZlibfiler r r!�find_library_fileszMSVCCompiler.find_library_file)rrr)N)rrb)NNNrNNN)NrN)
NNNNNrNNNN)r)�__name__�
__module__�__qualname__�__doc__Z
compiler_typeZexecutablesr�r�r�r�r�r{rwZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr]rvr�r�r�r�r�r�r�r�r��
__classcell__r r r�r!r[�sf
��

P�
"�
]�
�
Er[)N)r�rZshutil�statr,rZdistutils.errorsrrrrrZdistutils.ccompilerrrZ	distutilsr	Zdistutils.utilr
�	itertoolsrr"r3ZPLAT_SPEC_TO_RUNTIMEr<rSrZrhr[r r r r!�<module>s4#�
�PK42�\���~�!�!cygwinccompiler.cpython-38.pycnu�[���U

e5d^@�@s�dZddlZddlZddlZddlmZmZmZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZmZmZmZddlmZdd	lmZdd
lmZdd�ZGd
d�de
�ZGdd�de�ZdZdZdZ dd�Z!e�"d�Z#dd�Z$dd�Z%dd�Z&dS)adistutils.cygwinccompiler

Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
handles the Cygwin port of the GNU C compiler to Windows.  It also contains
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
cygwin in no-cygwin mode).
�N)�Popen�PIPE�check_output)�gen_preprocess_options�gen_lib_options)�
UnixCCompiler)�
write_file)�DistutilsExecError�CCompilerError�CompileError�UnknownFileError)�log)�LooseVersion)�find_executablecCs�tj�d�}|dkr|tj|d|d�}|dkr8dgS|dkrFdgS|d	krTd
gS|dkrbdgS|d
krpdgStd|��dS)zaInclude the appropriate MSVC runtime library if Python was built
    with MSVC 7.0 or later.
    zMSC v.�����
Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100zUnknown MS Compiler version %s N)�sys�version�find�
ValueError)Zmsc_posZmsc_ver�r�1/usr/lib64/python3.8/distutils/cygwinccompiler.py�	get_msvcr?src
@sReZdZdZdZdZdZdZdZdZ	dZ
dd
d�Zdd
�Zddd�Z
ddd�ZdS)�CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows.
    �cygwinz.o�.az.dllzlib%s%sz%s%sz.exercCs�t�||||�t�\}}|�d||f�|tk	rB|�d|�t�\|_|_|_	|�|j
d|j|j|j	f�|jdkr�d|_nd|_|jdkr�d}nd	}|jd
ddd
d|j|fd�|jdkr�dg|_
|�d�nt�|_
dS)Nz%Python's GCC status: %s (details: %s)z�Python's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.z: gcc %s, ld %s, dllwrap %s
z2.10.90�gcc�dllwrap�2.13�-shared�
-mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallzgcc -mcygwinz%s -mcygwin %s�Zcompiler�compiler_soZcompiler_cxxZ
linker_exeZ	linker_so�2.91.57Zmsvcrtz,Consider upgrading to a newer version of gcc)r�__init__�check_config_hZdebug_print�CONFIG_H_OK�warn�get_versions�gcc_version�
ld_versionZdllwrap_version�
compiler_type�
linker_dll�set_executables�
dll_librariesr)�self�verbose�dry_run�forceZstatusZdetails�
shared_optionrrrr%dsN
����
��


��
�zCygwinCCompiler.__init__c
Cs�|dks|dkrVz|�dd|d|g�Wq�tk
rR}zt|��W5d}~XYq�XnNz"|�|j||d|g|�Wn*tk
r�}zt|��W5d}~XYnXdS)z:Compiles the source by spawning GCC and windres if needed.�.rc�.resZwindresz-iz-oN)Zspawnr	rr#)r0�obj�src�extZcc_args�extra_postargsZpp_opts�msgrrr�_compile�s�
zCygwinCCompiler._compileNcCsPt�|
p
g�}
t�|pg�}t�|p&g�}|�|j�|dk	�r||jksV|jdk�rtj�|d�}tj�tj�	|��\}}tj�
||d�}tj�
|d|d�}dtj�	|�dg}|D]}|�|�q�|�t
||fd	|�|jd
k�r|
�d|g�|
�d|g�n
|�|�|	�s(|
�d
�t�||||||||d|	|
|||
�dS)zLink the objects.Nrrz.def�librz
LIBRARY %sZEXPORTSz
writing %srz--output-libz--defz-s)�copy�extendr/Z
EXECUTABLEr-�os�path�dirname�splitext�basename�join�appendZexecuterr�link)r0Ztarget_descZobjectsZoutput_filename�
output_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbols�debugZ
extra_preargsr:Z
build_tempZtarget_langZtemp_dirZdll_nameZ
dll_extensionZdef_fileZlib_file�contentsZsymrrrrG�sR
��

���

�zCygwinCCompiler.link�cCs�|dkrd}g}|D]�}tj�tj�|��\}}||jddgkrRtd||f��|rbtj�|�}|dkr�|�tj�||||j	��q|�tj�|||j	��q|S)z#Adds supports for rc and res files.NrKr5r6z"unknown file type '%s' (from '%s'))r6r5)
r@rArC�normcaseZsrc_extensionsrrDrFrE�
obj_extension)r0Zsource_filenamesZ	strip_dirrHZ	obj_namesZsrc_name�baser9rrr�object_filenames�s&���z CygwinCCompiler.object_filenames)rrr)
NNNNNrNNNN)rrK)�__name__�
__module__�__qualname__�__doc__r,rMZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr%r<rGrOrrrrrYs,
;�
Nrc@seZdZdZdZddd�ZdS)�Mingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows.
    Zmingw32rc	Csxt�||||�|jdkr d}nd}|jdkr4d}nd}t�rFtd��|jdd	d
dd|j||fd
�g|_t	�|_dS)Nrr r!r$z--entry _DllMain@12rKz1Cygwin gcc cannot be used with --compiler=mingw32zgcc -O -Wallzgcc -mdll -O -Wallzg++ -O -Wallrz%s %s %sr")
rr%r+r*�is_cygwingccr
r.r-r/r)r0r1r2r3r4Zentry_pointrrrr%s.

����zMingw32CCompiler.__init__N)rrr)rPrQrRrSr,r%rrrrrTsrT�okznot okZ	uncertainc
Cs�ddlm}dtjkrtdfS|��}zLt|�}z4d|��krPtd|fW�WSt	d|fW�WSW5|��XWn8t
k
r�}ztd||jffWY�Sd	}~XYnXd	S)
awCheck if the current Python installation appears amenable to building
    extensions with GCC.

    Returns a tuple (status, details), where 'status' is one of the following
    constants:

    - CONFIG_H_OK: all is well, go ahead and compile
    - CONFIG_H_NOTOK: doesn't look good
    - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h

    'details' is a human-readable string explaining the situation.

    Note there are two ways to conclude "OK": either 'sys.version' contains
    the string "GCC" (implying that this Python was built with GCC), or the
    installed "pyconfig.h" contains the string "__GNUC__".
    r)�	sysconfigZGCCzsys.version mentions 'GCC'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '%s': %sN)
�	distutilsrWrrr'Zget_config_h_filename�open�close�read�CONFIG_H_NOTOK�OSError�CONFIG_H_UNCERTAIN�strerror)rW�fnZconfig_h�excrrrr&Hs
�r&s(\d+\.\d+(\.\d+)*)cCsl|��d}t|�dkrdSt|dtd�j}z|��}W5|��Xt�|�}|dkrZdSt	|�
d����S)z�Find the version of an executable by running `cmd` in the shell.

    If the command is not found, or the output does not match
    `RE_VERSION`, returns None.
    rNT)�shell�stdout�)�splitrrrrcrZr[�
RE_VERSION�searchr�group�decode)�cmd�
executable�out�
out_string�resultrrr�_find_exe_versionus

rocCsdddg}tdd�|D��S)zg Try to find out the versions of gcc, ld and dllwrap.

    If not possible it returns None for it.
    zgcc -dumpversionzld -vzdllwrap --versioncSsg|]}t|��qSr)ro)�.0rjrrr�
<listcomp>�sz get_versions.<locals>.<listcomp>)�tuple)Zcommandsrrrr)�s
r)cCstddg�}|���d�S)z>Try to determine if the gcc that would be used is from cygwin.rz-dumpmachinescygwin)r�strip�endswith)rmrrrrU�srU)'rSr@rr>�
subprocessrrr�reZdistutils.ccompilerrrZdistutils.unixccompilerrZdistutils.file_utilrZdistutils.errorsr	r
rrrXr
Zdistutils.versionrZdistutils.spawnrrrrTr'r\r^r&�compilerfror)rUrrrr�<module>s0/;1+
PK42�\�{<���!archive_util.cpython-38.opt-1.pycnu�[���U

e5d|!�@sDdZddlZddlmZddlZzddlZWnek
rDdZYnXddlmZddl	m
Z
ddlmZddl
mZzddlmZWnek
r�dZYnXzdd	lmZWnek
r�dZYnXd
d�Zdd
�Zd#dd�Zd$dd�Zedgdfedgdfedgdfedgdfedgdfegdfd�Zdd �Zd%d!d"�ZdS)&zodistutils.archive_util

Utility functions for creating archive files (tarballs, zip files,
that sort of thing).�N)�warn)�DistutilsExecError)�spawn)�mkpath)�log)�getpwnam)�getgrnamcCsNtdks|dkrdSzt|�}Wntk
r8d}YnX|dk	rJ|dSdS)z"Returns a gid, given a group name.N�)r�KeyError��name�result�r�./usr/lib64/python3.8/distutils/archive_util.py�_get_gids
rcCsNtdks|dkrdSzt|�}Wntk
r8d}YnX|dk	rJ|dSdS)z"Returns an uid, given a user name.Nr	)rr
rrrr�_get_uid+s
r�gzipcs.dddddd�}dddd	d
�}|dk	r:||��kr:td��|d
}	|dkrZ|	|�|d�7}	ttj�|	�|d�ddl}
t�	d�t
���t�������fdd�}|s�|
�|	d||�}z|j||d�W5|�
�X|dk�r*tdt�|	||}
tjdk�r||	|
g}n
|d|	g}t||d�|
S|	S)a=Create a (possibly compressed) tar file from all the files under
    'base_dir'.

    'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or
    None.  ("compress" will be deprecated in Python 3.2)

    'owner' and 'group' can be used to define an owner and a group for the
    archive that is being built. If not provided, the current owner and group
    will be used.

    The output tar file will be named 'base_dir' +  ".tar", possibly plus
    the appropriate compression extension (".gz", ".bz2", ".xz" or ".Z").

    Returns the output filename.
    Zgz�bz2�xz�)r�bzip2rN�compressz.gzz.bz2z.xzz.Z)rrrrNzKbad value for 'compress': must be None, 'gzip', 'bzip2', 'xz' or 'compress'z.tarr��dry_runrzCreating tar archivecs,�dk	r�|_�|_�dk	r(�|_�|_|S)N)�gidZgname�uid�uname)Ztarinfo�r�group�ownerrrr�_set_uid_gidasz"make_tarball.<locals>._set_uid_gidzw|%s)�filterz'compress' will be deprecated.Zwin32z-f)�keys�
ValueError�getr�os�path�dirname�tarfiler�inforr�open�close�addr�PendingDeprecationWarning�sys�platformr)�	base_name�base_dirr�verboserrrZtar_compressionZcompress_extZarchive_namer(r �tarZcompressed_name�cmdrrr�make_tarball7sB���
	



r5c
Cs�|d}ttj�|�|d�tdkrp|r.d}nd}ztd|||g|d�Wn tk
rjtd|��YnX�n8t�d||�|�s�ztj	|d	tj
d
�}Wn&tk
r�tj	|d	tjd
�}YnX|��|tj
k�rtj�tj�|d��}|�||�t�d|�t�|�D]�\}}	}
|	D]6}tj�tj�||d��}|�||�t�d|��q|
D]B}tj�tj�||��}tj�|��rV|�||�t�d|��qV�qW5QRX|S)
avCreate a zip file from all the files under 'base_dir'.

    The output zip file will be named 'base_name' + ".zip".  Uses either the
    "zipfile" Python module (if available) or the InfoZIP "zip" utility
    (if installed and found on the default search path).  If neither tool is
    available, raises DistutilsExecError.  Returns the name of the output zip
    file.
    z.ziprNz-rz-rq�zipzkunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utilityz#creating '%s' and adding '%s' to it�w)Zcompressionrzadding '%s')rr%r&r'�zipfilerrrr)ZZipFileZZIP_DEFLATED�RuntimeErrorZ
ZIP_STORED�curdir�normpath�join�write�walk�isfile)r0r1r2rZzip_filenameZ
zipoptionsr6r&�dirpathZdirnames�	filenamesrrrr�make_zipfilesV	�
���
�rB)rrzgzip'ed tar-file)rrzbzip2'ed tar-file)rrzxz'ed tar-file)rrzcompressed tar file)rNzuncompressed tar filezZIP file)ZgztarZbztarZxztarZztarr3r6cCs|D]}|tkr|SqdS)zqReturns the first format from the 'format' list that is unknown.

    If all formats are known, returns None
    N)�ARCHIVE_FORMATS)Zformats�formatrrr�check_archive_formats�s
rEc
Cs�t��}|dk	r6t�d|�tj�|�}|s6t�|�|dkrDtj}d|i}	zt|}
Wn t	k
rxt
d|��YnX|
d}|
dD]\}}
|
|	|<q�|dkr�||	d<||	d	<z|||f|	�}W5|dk	r�t�d
|�t�|�X|S)a�Create an archive file (eg. zip or tar).

    'base_name' is the name of the file to create, minus any format-specific
    extension; 'format' is the archive format: one of "zip", "tar", "gztar",
    "bztar", "xztar", or "ztar".

    'root_dir' is a directory that will be the root directory of the
    archive; ie. we typically chdir into 'root_dir' before creating the
    archive.  'base_dir' is the directory where we start archiving from;
    ie. 'base_dir' will be the common prefix of all files and
    directories in the archive.  'root_dir' and 'base_dir' both default
    to the current directory.  Returns the name of the archive file.

    'owner' and 'group' are used when creating a tar archive. By default,
    uses the current owner and group.
    Nzchanging into '%s'rzunknown archive format '%s'r�r6rrzchanging back to '%s')r%�getcwdr�debugr&�abspath�chdirr:rCr
r#)r0rDZroot_dirr1r2rrrZsave_cwd�kwargsZformat_info�func�arg�val�filenamerrr�make_archive�s2

rP)rrrNN)rr)NNrrNN)�__doc__r%�warningsrr.r8�ImportErrorZdistutils.errorsrZdistutils.spawnrZdistutils.dir_utilrZ	distutilsr�pwdrZgrprrrr5rBrCrErPrrrr�<module>sN


�
H
=




�	
�PK42�\0�oa����dist.cpython-38.pycnu�[���U

e5d���@s�dZddlZddlZddlZddlmZzddlZWnek
rLdZYnXddlTddl	m
Z
mZddlm
Z
mZmZddlmZddlmZe�d	�Zd
d�ZGdd
�d
�ZGdd�d�Zdd�ZdS)z}distutils.dist

Provides the Distribution class, which represents the module distribution
being built/installed/distributed.
�N)�message_from_file)�*)�FancyGetopt�translate_longopt)�
check_environ�	strtobool�
rfc822_escape��log)�DEBUGz^[a-zA-Z]([a-zA-Z0-9_]*)$cCsLt|t�rn<t|t�sHt|�j}d|�d|�d�}t�tj|�t|�}|S)Nz
Warning: 'z' should be a list, got type '�')�
isinstance�str�list�type�__name__r
ZWARN)�valueZ	fieldname�typename�msg�r�&/usr/lib64/python3.8/distutils/dist.py�_ensure_lists


rc@speZdZdZdddddgZdZdd	d
ddd
dddddddddddddddgZdd�eD�Zdd iZdad"d#�Z	d$d%�Z
dbd'd(�Zd)d*�Zdcd+d,�Z
d-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d5gfd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zd@dA�ZdBdC�ZdddDdE�ZdedFdG�ZdfdIdJ�ZejfdKdL�ZdMdN�ZdOdP�Z dQdR�Z!dSdT�Z"dUdV�Z#dWdX�Z$dYdZ�Z%d[d\�Z&d]d^�Z'd_d`�Z(d!S)g�Distributiona�The core of the Distutils.  Most of the work hiding behind 'setup'
    is really done within a Distribution instance, which farms the work out
    to the Distutils commands specified on the command line.

    Setup scripts will almost never instantiate Distribution directly,
    unless the 'setup()' function is totally inadequate to their needs.
    However, it is conceivable that a setup script might wish to subclass
    Distribution for some specialized purpose, and then pass the subclass
    to 'setup()' as the 'distclass' keyword argument.  If so, it is
    necessary to respect the expectations that 'setup' has of Distribution.
    See the code for 'setup()', in core.py, for details.
    )�verbose�vzrun verbosely (default)�)�quiet�qz!run quietly (turns verbosity off))zdry-run�nzdon't actually do anything)�help�hzshow detailed help message)zno-user-cfgNz-ignore pydistutils.cfg in your home directoryz�Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package
)z
help-commandsNzlist all available commands)�nameNzprint package name)�version�Vzprint package version)�fullnameNzprint <package name>-<version>)�authorNzprint the author's name)�author-emailNz print the author's email address)�
maintainerNzprint the maintainer's name)zmaintainer-emailNz$print the maintainer's email address)�contactNz7print the maintainer's name if known, else the author's)z
contact-emailNz@print the maintainer's email address if known, else the author's)�urlNzprint the URL for this package)�licenseNz print the license of the package)�licenceNzalias for --license)�descriptionNzprint the package description)zlong-descriptionNz"print the long package description)�	platformsNzprint the list of platforms)�classifiersNzprint the list of classifiers)�keywordsNzprint the list of keywords)�providesNz+print the list of packages/modules provided)�requiresNz+print the list of packages/modules required)�	obsoletesNz0print the list of packages/modules made obsoletecCsg|]}t|d��qS)r�r)�.0�xrrr�
<listcomp>�szDistribution.<listcomp>rrNcCs\d|_d|_d|_|jD]}t||d�qt�|_|jjD] }d|}t||t|j|��q:i|_	d|_
d|_d|_i|_
g|_d|_i|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_i|_i|_|�r|�d�}|dk	�r8|d=|��D]4\}}|� |�}|��D]\}	}
d|
f||	<�q�qd|k�r~|d|d	<|d=d
}t!dk	�rnt!�"|�nt#j$�%|d�|��D]�\}}
t&|jd|��r�t|jd|�|
�nNt&|j|��r�t|j||
�n0t&||��r�t|||
�nd
t'|�}t!�"|��q�d|_(|jdk	�rP|jD].}
|
�)d��s6�qP|
dk�r d|_(�qP�q |�*�dS)a0Construct a new Distribution instance: initialize all the
        attributes of a Distribution, and then use 'attrs' (a dictionary
        mapping attribute names to values) to assign some of those
        attributes their "real" values.  (Any attributes not mentioned in
        'attrs' will be assigned to some null value: 0, None, an empty list
        or dictionary, etc.)  Most importantly, initialize the
        'command_obj' attribute to the empty dictionary; this will be
        filled in with real command objects by 'parse_command_line()'.
        rr�get_N��optionszsetup scriptr+r*z:'licence' distribution option is deprecated; use 'license'�
Zset_zUnknown distribution option: %sT�-z
--no-user-cfgF)+r�dry_runr�display_option_names�setattr�DistributionMetadata�metadata�_METHOD_BASENAMES�getattr�cmdclass�command_packages�script_name�script_args�command_optionsZ
dist_files�packagesZpackage_dataZpackage_dir�
py_modules�	libraries�headers�ext_modulesZext_packageZinclude_dirsZ
extra_path�scripts�
data_filesZpassword�command_obj�have_run�get�items�get_option_dict�warnings�warn�sys�stderr�write�hasattr�repr�
want_user_cfg�
startswith�finalize_options)�self�attrs�attr�basenameZmethod_namer9�commandZcmd_options�opt_dict�opt�valr�key�argrrr�__init__�s~








zDistribution.__init__cCs&|j�|�}|dkr"i}|j|<|S)z�Get the option dictionary for a given command.  If that
        command's option dictionary hasn't been created yet, then create it
        and return the new dictionary; otherwise, return the existing
        option dictionary.
        N)rGrQ)r^rb�dictrrrrS&szDistribution.get_option_dictr8c	Cs�ddlm}|dkr"t|j���}|dk	r@|�||�|d}|sV|�|d�dS|D]h}|j�|�}|dkr�|�|d|�qZ|�|d|�||�}|�d�D]}|�|d|�q�qZdS)Nr)�pformatz  zno commands known yetzno option dict for '%s' commandzoption dict for '%s' command:r:)Zpprintrj�sortedrG�keys�announcerQ�split)	r^�header�commands�indentrjZcmd_namerc�out�linerrr�dump_option_dicts1s*��zDistribution.dump_option_dictscCs�g}t�tj�tjdj�}tj�|d�}tj�|�rB|�	|�tj
dkrRd}nd}|jr�tj�tj�d�|�}tj�|�r�|�	|�d}tj�|�r�|�	|�t
r�|�dd	�|��|S)
a�Find as many configuration files as should be processed for this
        platform, and return a list of filenames in the order in which they
        should be parsed.  The filenames returned are guaranteed to exist
        (modulo nasty race conditions).

        There are three possible config files: distutils.cfg in the
        Distutils installation directory (ie. where the top-level
        Distutils __inst__.py file lives), a file in the user's home
        directory named .pydistutils.cfg on Unix and pydistutils.cfg
        on Windows/Mac; and setup.cfg in the current directory.

        The file in the user's home directory can be disabled with the
        --no-user-cfg option.
        �	distutilsz
distutils.cfg�posixz.pydistutils.cfgzpydistutils.cfg�~z	setup.cfgzusing config files: %sz, )r�os�path�dirnamerV�modules�__file__�join�isfile�appendr!r[�
expanduserrrm)r^�filesZsys_dirZsys_fileZ
user_filenameZ	user_fileZ
local_filerrr�find_config_filesMs&



zDistribution.find_config_filesc
Cs�ddlm}tjtjkr8ddddddd	d
ddd
ddg
}ng}t|�}|dkrT|��}trb|�d�|�}|D]�}tr�|�d|�|�	|�|�
�D]V}|�|�}|�|�}|D]8}	|	dkr�|	|kr�|�
||	�}
|	�dd�}	||
f||	<q�q�|��qld|jk�r�|jd��D]�\}	\}}
|j�
|	�}zF|�rDt||t|
��n(|	dk�r`t||	t|
��nt||	|
�Wn,tk
�r�}
zt|
��W5d}
~
XYnX�qdS)Nr)�ConfigParserzinstall-basezinstall-platbasezinstall-libzinstall-platlibzinstall-purelibzinstall-headerszinstall-scriptszinstall-data�prefixzexec-prefix�home�user�rootz"Distribution.parse_config_files():z  reading %srr;�_�global)rr<)Zconfigparserr�rVr��base_prefix�	frozensetr�rrm�readZsectionsr9rSrQ�replacerhrGrR�negative_optr>r�
ValueError�DistutilsOptionError)r^�	filenamesr�Zignore_options�parser�filenameZsectionr9rcrdre�src�aliasrrrr�parse_config_files}s^�





zDistribution.parse_config_filescCs�|��}g|_t||j�}|�|j�|�ddi�|j|j|d�}|�	�}t
�|j�|�
|�rhdS|r�|�||�}|dkrhdSqh|jr�|j|t|j�dk|jd�dS|js�td��dS)	a�Parse the setup script's command line, taken from the
        'script_args' instance attribute (which defaults to 'sys.argv[1:]'
        -- see 'setup()' in core.py).  This list is first processed for
        "global options" -- options that set attributes of the Distribution
        instance.  Then, it is alternately scanned for Distutils commands
        and options for that command.  Each new command terminates the
        options for the previous command.  The allowed options for a
        command are determined by the 'user_options' attribute of the
        command class -- thus, we have to be able to load command classes
        in order to parse the command line.  Any error in that 'options'
        attribute raises DistutilsGetoptError; any error on the
        command-line raises DistutilsArgError.  If no Distutils commands
        were found on the command line, raises DistutilsArgError.  Return
        true if command-line was successfully parsed and we should carry
        on with executing commands; false if no errors but we shouldn't
        execute commands (currently, this only happens if user asks for
        help).
        r+r*)�args�objectNr��display_optionsrpzno commands suppliedT)�_get_toplevel_optionsrprr��set_negative_aliasesr�Zset_aliases�getoptrFZget_option_orderr
Z
set_verbosityr�handle_display_options�_parse_command_optsr�
_show_help�len�DistutilsArgError)r^Ztoplevel_optionsr�r��option_orderrrr�parse_command_line�s.	
�zDistribution.parse_command_linecCs|jdgS)z�Return the non-display options recognized at the top level.

        This includes options that are recognized *only* at the top
        level as well as options recognized for commands.
        )zcommand-packages=Nz0list of packages that provide distutils commands)�global_options�r^rrrr��s�z"Distribution._get_toplevel_optionsc
Cs�ddlm}|d}t�|�s*td|��|j�|�z|�|�}Wn*tk
rn}zt	|��W5d}~XYnXt
||�s�td|��t|d�r�t
|jt�s�d}t||��|j}t|d�r�|��}|�|j�t|d	�r�t
|jt�r�t|j�}ng}|�|j|j|�|�|�|�|d
d��\}}	t|	d��rV|	j�rV|j|d|gd�dSt|d	��r�t
|jt��r�d}
|jD]F\}}}
}t|	|�|���rzd
}
t|��r�|�ntd
||f���qz|
�r�dS|�|�}t|	���D]\}}d|f||<�q�|S)a�Parse the command-line options for a single command.
        'parser' must be a FancyGetopt instance; 'args' must be the list
        of arguments, starting with the current command (whose options
        we are about to parse).  Returns a new version of 'args' with
        the next command at the front of the list; will be the empty
        list if there are no more commands on the command line.  Returns
        None if the user asked for help on this command.
        r��Commandzinvalid command name '%s'Nz&command class %s must subclass Command�user_optionszIcommand class %s must provide 'user_options' attribute (a list of tuples)r��help_optionsrrr�zYinvalid help function %r for help option '%s': must be a callable object (function, etc.)zcommand line) �
distutils.cmdr��
command_re�match�
SystemExitrpr�get_command_class�DistutilsModuleErrorr��
issubclassZDistutilsClassErrorrYr
r�rr��copy�updater��fix_help_options�set_option_tabler�r�r�rr�Z
get_attr_name�callablerS�varsrR)r^r�r�r�rbZ	cmd_classrr�r�ZoptsZhelp_option_foundZhelp_optionZshortZdesc�funcrcr!rrrrr�sr


�

�


���

�
��
z Distribution._parse_command_optscCsPdD]F}t|j|�}|dkrqt|t�rdd�|�d�D�}t|j||�qdS)z�Set final values for all the options on the Distribution
        instance, analogous to the .finalize_options() method of Command
        objects.
        �r/r-NcSsg|]}|���qSr��strip)r4Zelmrrrr6jsz1Distribution.finalize_options.<locals>.<listcomp>�,)rBr@r
rrnr>)r^r`rrrrr]`s
zDistribution.finalize_optionsrc
Csddlm}ddlm}|rR|r*|��}n|j}|�|�|�|jd�t	d�|rt|�|j
�|�d�t	d�|jD]z}t|t
�r�t||�r�|}	n
|�|�}	t|	d�r�t|	jt�r�|�|	jt|	j��n|�|	j�|�d|	j�t	d�qzt	||j��d	S)
abShow help for the setup script command-line in the form of
        several lists of command-line options.  'parser' should be a
        FancyGetopt instance; do not expect it to be returned in the
        same state, as its option table will be reset to make it
        generate the correct help text.

        If 'global_options' is true, lists the global options:
        --verbose, --dry-run, etc.  If 'display_options' is true, lists
        the "display-only" options: --name, --version, etc.  Finally,
        lists per-command help for every command name or command class
        in 'commands'.
        r��	gen_usager�z
Global options:r8zKInformation display options (just display information, ignore any commands)r�zOptions for '%s' command:N)�distutils.corer�r�r�r�r�r�Z
print_help�common_usage�printr�rpr
rr�r�rYr�rr�r�rrE)
r^r�r�r�rpr�r�r9rb�klassrrrr�ms:

�



��
zDistribution._show_helpc	Cs�ddlm}|jr4|��td�t||j��dSd}i}|jD]}d||d<qB|D]l\}}|rX|�|�rXt|�}t	|j
d|��}|dkr�td�|��n |dkr�td	�|��nt|�d}qX|S)
z�If there were any non-global "display-only" options
        (--help-commands or the metadata display options) on the command
        line, display the requested info and return true; else return
        false.
        rr�r8rr7r�r�)r.r0r1r2r:)r�r�Z
help_commands�print_commandsr�rEr�rQrrBr@r})	r^r�r�Zany_display_optionsZis_display_option�optionrdrerrrrr��s*
z#Distribution.handle_display_optionsc	Csjt|d�|D]T}|j�|�}|s.|�|�}z
|j}Wntk
rPd}YnXtd|||f�qdS)zZPrint a subset of the list of all commands -- used by
        'print_commands()'.
        �:�(no description available)z
  %-*s  %sN)r�rCrQr�r,�AttributeError)r^rpro�
max_length�cmdr�r,rrr�print_command_list�s


zDistribution.print_command_listcCs�ddl}|jj}i}|D]}d||<qg}|j��D]}|�|�s4|�|�q4d}||D]}t|�|krZt|�}qZ|�|d|�|r�t	�|�|d|�dS)anPrint out a help message listing all available commands with a
        description of each.  The list is divided into "standard commands"
        (listed in distutils.command.__all__) and "extra commands"
        (mentioned in self.cmdclass, but not a standard command).  The
        descriptions come from the command class attribute
        'description'.
        rNrzStandard commandszExtra commands)
�distutils.commandrb�__all__rCrlrQrr�r�r�)r^ru�std_commands�is_stdr��extra_commandsr�rrrr��s.


��zDistribution.print_commandsc		Cs�ddl}|jj}i}|D]}d||<qg}|j��D]}|�|�s4|�|�q4g}||D]P}|j�|�}|sx|�|�}z
|j}Wnt	k
r�d}YnX|�||f�qZ|S)a>Get a list of (command, description) tuples.
        The list is divided into "standard commands" (listed in
        distutils.command.__all__) and "extra commands" (mentioned in
        self.cmdclass, but not a standard command).  The descriptions come
        from the command class attribute 'description'.
        rNrr�)
r�rbr�rCrlrQrr�r,r�)	r^rur�r�r�r��rvr�r,rrr�get_command_list�s(	




zDistribution.get_command_listcCsN|j}t|t�sJ|dkrd}dd�|�d�D�}d|krD|�dd�||_|S)z9Return a list of packages from which commands are loaded.Nr8cSsg|]}|dkr|���qS)r8r�)r4Zpkgrrrr6!sz5Distribution.get_command_packages.<locals>.<listcomp>r�zdistutils.commandr)rDr
rrn�insert)r^Zpkgsrrr�get_command_packagess
z!Distribution.get_command_packagesc	Cs�|j�|�}|r|S|��D]�}d||f}|}zt|�tj|}Wntk
r^YqYnXzt||�}Wn&tk
r�t	d|||f��YnX||j|<|St	d|��dS)aoReturn the class that implements the Distutils command named by
        'command'.  First we check the 'cmdclass' dictionary; if the
        command is mentioned there, we fetch the class object from the
        dictionary and return it.  Otherwise we load the command module
        ("distutils.command." + command) and fetch the command class from
        the module.  The loaded class is also stored in 'cmdclass'
        to speed future calls to 'get_command_class()'.

        Raises DistutilsModuleError if the expected module could not be
        found, or if that module does not define the expected class.
        z%s.%sz3invalid command '%s' (no class '%s' in module '%s')zinvalid command '%s'N)
rCrQr��
__import__rVr{�ImportErrorrBr�r�)r^rbr�ZpkgnameZmodule_nameZ
klass_name�modulerrrr�'s,
��

zDistribution.get_command_classcCsl|j�|�}|sh|rhtr&|�d|�|�|�}||�}|j|<d|j|<|j�|�}|rh|�||�|S)aReturn the command object for 'command'.  Normally this object
        is cached on a previous call to 'get_command_obj()'; if no command
        object for 'command' is in the cache, then we either create and
        return it (if 'create' is true) or return None.
        z<Distribution.get_command_obj(): creating '%s' command objectr)rOrQrrmr�rPrG�_set_command_options)r^rbZcreate�cmd_objr�r9rrr�get_command_objMs�

zDistribution.get_command_objcCs\|��}|dkr|�|�}tr,|�d|�|��D�] \}\}}trZ|�d|||f�zdd�|jD�}Wntk
r�g}YnXz
|j}Wntk
r�i}YnXz|t|t	�}	||kr�|	r�t
|||t|��nJ||kr�|	r�t
||t|��n,t||��rt
|||�nt
d|||f��Wq4tk
�rT}
zt
|
��W5d}
~
XYq4Xq4dS)aySet the options for 'command_obj' from 'option_dict'.  Basically
        this means copying elements of a dictionary ('option_dict') to
        attributes of an instance ('command').

        'command_obj' must be a Command instance.  If 'option_dict' is not
        supplied, uses the standard option dictionary for this command
        (from 'self.command_options').
        Nz#  setting options for '%s' command:z    %s = %s (from %s)cSsg|]}t|��qSrr3)r4�orrrr6|s�z5Distribution._set_command_options.<locals>.<listcomp>z1error in %s: command '%s' has no such option '%s')�get_command_namerSrrmrRZboolean_optionsr�r�r
rr>rrYr�r�)r^rOZoption_dict�command_namer��sourcerZ	bool_optsZneg_optZ	is_stringrrrrr�hsF	

��




��z!Distribution._set_command_optionsrcCs|ddlm}t||�s&|}|�|�}n|��}|js8|S|��d|_d|j|<|�|�|rx|�	�D]}|�
||�qf|S)a�Reinitializes a command to the state it was in when first
        returned by 'get_command_obj()': ie., initialized but not yet
        finalized.  This provides the opportunity to sneak option
        values in programmatically, overriding or supplementing
        user-supplied values from the config files and command line.
        You'll have to re-finalize the command object (by calling
        'finalize_options()' or 'ensure_finalized()') before using it for
        real.

        'command' should be a command name (string) or command object.  If
        'reinit_subcommands' is true, also reinitializes the command's
        sub-commands, as declared by the 'sub_commands' class attribute (if
        it has one).  See the "install" command for an example.  Only
        reinitializes the sub-commands that actually matter, ie. those
        whose test predicates return true.

        Returns the reinitialized command object.
        rr�)r�r�r
r�r�Z	finalizedZinitialize_optionsrPr�Zget_sub_commands�reinitialize_command)r^rbZreinit_subcommandsr�r��subrrrr��s


z!Distribution.reinitialize_commandcCst�||�dS�Nr	)r^r�levelrrrrm�szDistribution.announcecCs|jD]}|�|�qdS)z�Run each command that was seen on the setup script command line.
        Uses the list of commands found and cache of command objects
        created by 'get_command_obj()'.
        N)rp�run_command)r^r�rrr�run_commands�s
zDistribution.run_commandscCsD|j�|�rdSt�d|�|�|�}|��|��d|j|<dS)a�Do whatever it takes to run a command (including nothing at all,
        if the command has already been run).  Specifically: if we have
        already created and run the command named by 'command', return
        silently without doing anything.  If the command named by 'command'
        doesn't even have a command object yet, create one.  Then invoke
        'run()' on that command object (or an existing one).
        Nz
running %sr)rPrQr
�infor�Zensure_finalized�run)r^rbr�rrrr��s	
zDistribution.run_commandcCst|jp|jpg�dkS�Nr)r�rHrIr�rrr�has_pure_modules�szDistribution.has_pure_modulescCs|jot|j�dkSr�)rLr�r�rrr�has_ext_modules�szDistribution.has_ext_modulescCs|jot|j�dkSr�)rJr�r�rrr�has_c_libraries�szDistribution.has_c_librariescCs|��p|��Sr�)r�r�r�rrr�has_modules�szDistribution.has_modulescCs|jot|j�dkSr�)rKr�r�rrr�has_headers�szDistribution.has_headerscCs|jot|j�dkSr�)rMr�r�rrr�has_scripts�szDistribution.has_scriptscCs|jot|j�dkSr�)rNr�r�rrr�has_data_files�szDistribution.has_data_filescCs|��o|��o|��Sr�)r�r�r�r�rrr�is_pure�s
��zDistribution.is_pure)N)NNr8)N)r)N)r))r�
__module__�__qualname__�__doc__r�r�r�r=r�rhrSrtr�r�r�r�r�r]r�r�r�r�r�r�r�r�r�r�r
�INFOrmr�r�r�r�r�r�r�r�r�r�rrrrr,s��	�,

0
:C[
�
2(!"&

,
)
rc@seZdZdZdZdBdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZeZd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dS)Cr?z]Dummy class to hold the distribution meta-data: name, version,
    author, and so forth.
    )r!r"r%�author_emailr'�maintainer_emailr)r*r,�long_descriptionr/r-r$r(Z
contact_emailr.�download_urlr0r1r2NcCs�|dk	r|�t|��nfd|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_dSr�)�
read_pkg_file�openr!r"r%r�r'r�r)r*r,r�r/r-r.r�r0r1r2)r^ryrrrrh
s&zDistributionMetadata.__init__cst|���fdd�}�fdd�}�d}|d�|_|d�|_|d�|_|d	�|_d
|_|d�|_d
|_|d�|_|d
�|_	d�kr�|d�|_
nd
|_
|d�|_|d�|_d�kr�|d��d�|_
|d�|_|d�|_|dkr�|d�|_|d�|_|d�|_nd
|_d
|_d
|_d
S)z-Reads the metadata values from a file object.cs�|}|dkrdS|S�NZUNKNOWNr)r!r�rrr�_read_field(sz7DistributionMetadata.read_pkg_file.<locals>._read_fieldcs��|d�}|gkrdS|Sr�)Zget_all)r!�valuesr�rr�
_read_list.sz6DistributionMetadata.read_pkg_file.<locals>._read_listzmetadata-versionr!r"Zsummaryr%Nr&z	home-pager*zdownload-urlr,r/r��platformZ
classifier�1.1r1r0r2)rr!r"r,r%r'r�r�r)r*r�r�rnr/r-r.r1r0r2)r^�filer�r�Zmetadata_versionrr�rr�$s:












z"DistributionMetadata.read_pkg_filec	Cs2ttj�|d�ddd��}|�|�W5QRXdS)z7Write the PKG-INFO file into the release tree.
        zPKG-INFO�wzUTF-8)�encodingN)r�rxryr}�write_pkg_file)r^Zbase_dirZpkg_inforrr�write_pkg_infoXs
�z#DistributionMetadata.write_pkg_infocCsbd}|js"|js"|js"|js"|jr&d}|�d|�|�d|���|�d|���|�d|���|�d|�	��|�d|�
��|�d	|���|�d
|���|jr�|�d|j�t
|���}|�d|�d
�|���}|�r|�d|�|�|d|���|�|d|���|�|d|���|�|d|���|�|d|���dS)z9Write the PKG-INFO format data to a file object.
        z1.0r�zMetadata-Version: %s
z	Name: %s
zVersion: %s
zSummary: %s
zHome-page: %s
zAuthor: %s
zAuthor-email: %s
zLicense: %s
zDownload-URL: %s
zDescription: %s
r�z
Keywords: %s
ZPlatformZ
ClassifierZRequiresZProvidesZ	ObsoletesN)r0r1r2r.r�rX�get_name�get_version�get_description�get_url�get_contact�get_contact_email�get_licenser�get_long_descriptionr}�get_keywords�_write_list�
get_platforms�get_classifiers�get_requires�get_provides�
get_obsoletes)r^rr"Z	long_descr/rrrr_s6��z#DistributionMetadata.write_pkg_filecCs |D]}|�d||f�qdS)Nz%s: %s
)rX)r^rr!r�rrrrr�sz DistributionMetadata._write_listcCs
|jpdSr�)r!r�rrrr�szDistributionMetadata.get_namecCs
|jpdS)Nz0.0.0)r"r�rrrr�sz DistributionMetadata.get_versioncCsd|��|��fS)Nz%s-%s)rrr�rrr�get_fullname�sz!DistributionMetadata.get_fullnamecCs
|jpdSr�)r%r�rrr�
get_author�szDistributionMetadata.get_authorcCs
|jpdSr�)r�r�rrr�get_author_email�sz%DistributionMetadata.get_author_emailcCs
|jpdSr�)r'r�rrr�get_maintainer�sz#DistributionMetadata.get_maintainercCs
|jpdSr�)r�r�rrr�get_maintainer_email�sz)DistributionMetadata.get_maintainer_emailcCs|jp|jpdSr�)r'r%r�rrrr	�sz DistributionMetadata.get_contactcCs|jp|jpdSr�)r�r�r�rrrr
�sz&DistributionMetadata.get_contact_emailcCs
|jpdSr�)r)r�rrrr�szDistributionMetadata.get_urlcCs
|jpdSr�)r*r�rrrr�sz DistributionMetadata.get_licensecCs
|jpdSr�)r,r�rrrr�sz$DistributionMetadata.get_descriptioncCs
|jpdSr�)r�r�rrrr�sz)DistributionMetadata.get_long_descriptioncCs
|jpgSr�)r/r�rrrr
�sz!DistributionMetadata.get_keywordscCst|d�|_dS)Nr/)rr/�r^rrrr�set_keywords�sz!DistributionMetadata.set_keywordscCs|jp
dgSr�)r-r�rrrr�sz"DistributionMetadata.get_platformscCst|d�|_dS)Nr-)rr-rrrr�
set_platforms�sz"DistributionMetadata.set_platformscCs
|jpgSr�)r.r�rrrr�sz$DistributionMetadata.get_classifierscCst|d�|_dS)Nr.)rr.rrrr�set_classifiers�sz$DistributionMetadata.set_classifierscCs
|jpdSr�)r�r�rrr�get_download_url�sz%DistributionMetadata.get_download_urlcCs
|jpgSr�)r1r�rrrr�sz!DistributionMetadata.get_requirescCs,ddl}|D]}|j�|�qt|�|_dSr�)�distutils.versionpredicate�versionpredicate�VersionPredicaterr1�r^rrurrrr�set_requires�sz!DistributionMetadata.set_requirescCs
|jpgSr�)r0r�rrrr�sz!DistributionMetadata.get_providescCs6dd�|D�}|D]}ddl}|j�|�q||_dS)NcSsg|]}|���qSrr�)r4rrrrr6�sz5DistributionMetadata.set_provides.<locals>.<listcomp>r)rrZsplit_provisionr0)r^rrrurrr�set_provides�s
z!DistributionMetadata.set_providescCs
|jpgSr�)r2r�rrrr�sz"DistributionMetadata.get_obsoletescCs,ddl}|D]}|j�|�qt|�|_dSr�)rrr rr2r!rrr�
set_obsoletes�sz"DistributionMetadata.set_obsoletes)N)%rr�r�r�rArhr�rrrrrrrrrrr	r
rrZget_licencerrr
rrrrrrrr"rr#rr$rrrrr?�sD	
4"r?cCs$g}|D]}|�|dd��q|S)zConvert a 4-tuple 'help_options' list as found in various command
    classes to the 3-tuple form required by FancyGetopt.
    r�)r)r9Znew_optionsZ
help_tuplerrrr��sr�)r�rVrx�reZemailrrTr�Zdistutils.errorsZdistutils.fancy_getoptrrZdistutils.utilrrrrur
Zdistutils.debugr�compiler�rrr?r�rrrr�<module>s4

ZcPK42�\LvV�00config.cpython-38.opt-2.pycnu�[���U

e5d��@s8ddlZddlmZddlmZdZGdd�de�ZdS)�N)�RawConfigParser)�CommandzE[distutils]
index-servers =
    pypi

[pypi]
username:%s
password:%s
c@sdeZdZdZdZdZdZdddefdgZdgZd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�ZdS)�
PyPIRCCommandzhttps://upload.pypi.org/legacy/�pypiNzrepository=�rzurl of repository [default: %s])�
show-responseNz&display full response text from serverrcCstj�tj�d�d�S)N�~z.pypirc)�os�path�join�
expanduser��self�r�(/usr/lib64/python3.8/distutils/config.py�_get_rc_file&szPyPIRCCommand._get_rc_filec	CsH|��}t�t�|tjtjBd�d��}|�t||f�W5QRXdS)Ni��w)rr	�fdopen�open�O_CREAT�O_WRONLY�write�DEFAULT_PYPIRC)r�username�password�rc�frrr�
_store_pypirc*s zPyPIRCCommand._store_pypirccCs�|��}tj�|��r�|�d|�|jp.|j}t�}|�|�|�	�}d|k�rF|�
dd�}dd�|�d�D�}|gkr�d|kr�dg}niS|D]�}d|i}|�
|d	�|d	<d
|jfd|jfdfD].\}	}
|�
||	�r�|�
||	�||	<q�|
||	<q�|dk�r ||jdfk�r |j|d
<|S|d|k�s:|d
|kr�|Sq�nRd
|k�r�d
}|�
|d
��rp|�
|d
�}n|j}|�
|d	�|�
|d�|||jd�SiS)NzUsing PyPI login from %sZ	distutilsz
index-serverscSs g|]}|��dkr|���qS)�)�strip)�.0�serverrrr�
<listcomp>=s�z.PyPIRCCommand._read_pypirc.<locals>.<listcomp>�
rr!r�
repository�realm)rNzserver-loginr)rrr$r!r%)rr	r
�existsZannouncer$�DEFAULT_REPOSITORYr�read�sections�get�split�
DEFAULT_REALMZ
has_option)rrr$Zconfigr)Z
index_serversZ_serversr!Zcurrent�key�defaultrrr�_read_pypirc0sb

���

�

�


�zPyPIRCCommand._read_pypirccCs8ddl}|�dd�}|�|�d�dd�}|���|�S)Nrzcontent-typez
text/plain��charset�ascii)�cgiZ	getheaderZparse_headerr*r(�decode)rZresponser3Zcontent_type�encodingrrr�_read_pypi_responsepsz!PyPIRCCommand._read_pypi_responsecCsd|_d|_d|_dS)Nr)r$r%Z
show_responser
rrr�initialize_optionswsz PyPIRCCommand.initialize_optionscCs(|jdkr|j|_|jdkr$|j|_dS)N)r$r'r%r,r
rrr�finalize_options}s

zPyPIRCCommand.finalize_options)�__name__�
__module__�__qualname__r'r,r$r%Zuser_optionsZboolean_optionsrrr/r6r7r8rrrrrs$���@r)r	ZconfigparserrZ
distutils.cmdrrrrrrr�<module>s
PK42�\kLjGsbsbdist.cpython-38.opt-2.pycnu�[���U

e5d���@s�ddlZddlZddlZddlmZzddlZWnek
rHdZYnXddlTddlm	Z	m
Z
ddlmZm
Z
mZddlmZddlmZe�d�Zd	d
�ZGdd�d�ZGd
d�d�Zdd�ZdS)�N)�message_from_file)�*)�FancyGetopt�translate_longopt)�
check_environ�	strtobool�
rfc822_escape��log)�DEBUGz^[a-zA-Z]([a-zA-Z0-9_]*)$cCsLt|t�rn<t|t�sHt|�j}d|�d|�d�}t�tj|�t|�}|S)Nz
Warning: 'z' should be a list, got type '�')�
isinstance�str�list�type�__name__r
ZWARN)�valueZ	fieldname�typename�msg�r�&/usr/lib64/python3.8/distutils/dist.py�_ensure_lists


rc@sleZdZdddddgZdZddd	d
ddd
ddddddddddddddgZdd�eD�ZddiZd`d!d"�Zd#d$�Z	dad&d'�Z
d(d)�Zdbd*d+�Zd,d-�Z
d.d/�Zd0d1�Zd2d3�Zd4d4gfd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d@�ZdAdB�ZdcdCdD�ZdddEdF�ZdedHdI�ZejfdJdK�ZdLdM�ZdNdO�ZdPdQ�Z dRdS�Z!dTdU�Z"dVdW�Z#dXdY�Z$dZd[�Z%d\d]�Z&d^d_�Z'd S)f�Distribution)�verbose�vzrun verbosely (default)�)�quiet�qz!run quietly (turns verbosity off))zdry-run�nzdon't actually do anything)�help�hzshow detailed help message)zno-user-cfgNz-ignore pydistutils.cfg in your home directoryz�Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package
)z
help-commandsNzlist all available commands)�nameNzprint package name)�version�Vzprint package version)�fullnameNzprint <package name>-<version>)�authorNzprint the author's name)�author-emailNz print the author's email address)�
maintainerNzprint the maintainer's name)zmaintainer-emailNz$print the maintainer's email address)�contactNz7print the maintainer's name if known, else the author's)z
contact-emailNz@print the maintainer's email address if known, else the author's)�urlNzprint the URL for this package)�licenseNz print the license of the package)�licenceNzalias for --license)�descriptionNzprint the package description)zlong-descriptionNz"print the long package description)�	platformsNzprint the list of platforms)�classifiersNzprint the list of classifiers)�keywordsNzprint the list of keywords)�providesNz+print the list of packages/modules provided)�requiresNz+print the list of packages/modules required)�	obsoletesNz0print the list of packages/modules made obsoletecCsg|]}t|d��qS)r�r)�.0�xrrr�
<listcomp>�szDistribution.<listcomp>rrNcCs\d|_d|_d|_|jD]}t||d�qt�|_|jjD] }d|}t||t|j|��q:i|_	d|_
d|_d|_i|_
g|_d|_i|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_i|_i|_|�r|�d�}|dk	�r8|d=|��D]4\}}|� |�}|��D]\}	}
d|
f||	<�q�qd|k�r~|d|d<|d=d	}t!dk	�rnt!�"|�nt#j$�%|d
�|��D]�\}}
t&|jd|��r�t|jd|�|
�nNt&|j|��r�t|j||
�n0t&||��r�t|||
�ndt'|�}t!�"|��q�d
|_(|jdk	�rP|jD].}
|
�)d��s6�qP|
dk�r d|_(�qP�q |�*�dS)Nrr�get_��optionszsetup scriptr+r*z:'licence' distribution option is deprecated; use 'license'�
Zset_zUnknown distribution option: %sT�-z
--no-user-cfgF)+r�dry_runr�display_option_names�setattr�DistributionMetadata�metadata�_METHOD_BASENAMES�getattr�cmdclass�command_packages�script_name�script_args�command_optionsZ
dist_files�packagesZpackage_dataZpackage_dir�
py_modules�	libraries�headers�ext_modulesZext_packageZinclude_dirsZ
extra_path�scripts�
data_filesZpassword�command_obj�have_run�get�items�get_option_dict�warnings�warn�sys�stderr�write�hasattr�repr�
want_user_cfg�
startswith�finalize_options)�self�attrs�attr�basenameZmethod_namer9�commandZcmd_options�opt_dict�opt�valr�key�argrrr�__init__�s~








zDistribution.__init__cCs&|j�|�}|dkr"i}|j|<|S�N)rGrQ)r^rb�dictrrrrS&szDistribution.get_option_dictr8c	Cs�ddlm}|dkr"t|j���}|dk	r@|�||�|d}|sV|�|d�dS|D]h}|j�|�}|dkr�|�|d|�qZ|�|d|�||�}|�d�D]}|�|d|�q�qZdS)Nr)�pformatz  zno commands known yetzno option dict for '%s' commandzoption dict for '%s' command:r:)Zpprintrk�sortedrG�keys�announcerQ�split)	r^�header�commands�indentrkZcmd_namerc�out�linerrr�dump_option_dicts1s*��zDistribution.dump_option_dictscCs�g}t�tj�tjdj�}tj�|d�}tj�|�rB|�	|�tj
dkrRd}nd}|jr�tj�tj�d�|�}tj�|�r�|�	|�d}tj�|�r�|�	|�t
r�|�dd	�|��|S)
N�	distutilsz
distutils.cfg�posixz.pydistutils.cfgzpydistutils.cfg�~z	setup.cfgzusing config files: %sz, )r�os�path�dirnamerV�modules�__file__�join�isfile�appendr!r[�
expanduserrrn)r^�filesZsys_dirZsys_fileZ
user_filenameZ	user_fileZ
local_filerrr�find_config_filesMs&



zDistribution.find_config_filesc
Cs�ddlm}tjtjkr8ddddddd	d
ddd
ddg
}ng}t|�}|dkrT|��}trb|�d�|�}|D]�}tr�|�d|�|�	|�|�
�D]V}|�|�}|�|�}|D]8}	|	dkr�|	|kr�|�
||	�}
|	�dd�}	||
f||	<q�q�|��qld|jk�r�|jd��D]�\}	\}}
|j�
|	�}zF|�rDt||t|
��n(|	dk�r`t||	t|
��nt||	|
�Wn,tk
�r�}
zt|
��W5d}
~
XYnX�qdS)Nr)�ConfigParserzinstall-basezinstall-platbasezinstall-libzinstall-platlibzinstall-purelibzinstall-headerszinstall-scriptszinstall-data�prefixzexec-prefix�home�user�rootz"Distribution.parse_config_files():z  reading %srr;�_�global)rr<)Zconfigparserr�rVr��base_prefix�	frozensetr�rrn�readZsectionsr9rSrQ�replacerhrGrR�negative_optr>r�
ValueError�DistutilsOptionError)r^�	filenamesr�Zignore_options�parser�filenameZsectionr9rcrdre�src�aliasrrrr�parse_config_files}s^�





zDistribution.parse_config_filescCs�|��}g|_t||j�}|�|j�|�ddi�|j|j|d�}|�	�}t
�|j�|�
|�rhdS|r�|�||�}|dkrhdSqh|jr�|j|t|j�dk|jd�dS|js�td��dS)Nr+r*)�args�objectr��display_optionsrqzno commands suppliedT)�_get_toplevel_optionsrqrr��set_negative_aliasesr�Zset_aliases�getoptrFZget_option_orderr
Z
set_verbosityr�handle_display_options�_parse_command_optsr�
_show_help�len�DistutilsArgError)r^Ztoplevel_optionsr�r��option_orderrrr�parse_command_line�s.	
�zDistribution.parse_command_linecCs|jdgS)N)zcommand-packages=Nz0list of packages that provide distutils commands)�global_options�r^rrrr��s�z"Distribution._get_toplevel_optionsc
Cs�ddlm}|d}t�|�s*td|��|j�|�z|�|�}Wn*tk
rn}zt	|��W5d}~XYnXt
||�s�td|��t|d�r�t
|jt�s�d}t||��|j}t|d�r�|��}|�|j�t|d�r�t
|jt�r�t|j�}ng}|�|j|j|�|�|�|�|d	d��\}}	t|	d
��rV|	j�rV|j|d|gd�dSt|d��r�t
|jt��r�d}
|jD]F\}}}
}t|	|�|���rzd	}
t|��r�|�ntd||f���qz|
�r�dS|�|�}t|	���D]\}}d
|f||<�q�|S)Nr��Commandzinvalid command name '%s'z&command class %s must subclass Command�user_optionszIcommand class %s must provide 'user_options' attribute (a list of tuples)r��help_optionsrrr�zYinvalid help function %r for help option '%s': must be a callable object (function, etc.)zcommand line) �
distutils.cmdr��
command_re�match�
SystemExitrqr��get_command_class�DistutilsModuleErrorr��
issubclassZDistutilsClassErrorrYr
r�rr��copy�updater��fix_help_options�set_option_tabler�r�r�rr�Z
get_attr_name�callablerS�varsrR)r^r�r�r�rbZ	cmd_classrr�r�ZoptsZhelp_option_foundZhelp_optionZshortZdesc�funcrcr!rrrrr�sr


�

�


���

�
��
z Distribution._parse_command_optscCsPdD]F}t|j|�}|dkrqt|t�rdd�|�d�D�}t|j||�qdS)N�r/r-cSsg|]}|���qSr��strip)r4Zelmrrrr6jsz1Distribution.finalize_options.<locals>.<listcomp>�,)rBr@r
rror>)r^r`rrrrr]`s
zDistribution.finalize_optionsrc
Csddlm}ddlm}|rR|r*|��}n|j}|�|�|�|jd�t	d�|rt|�|j
�|�d�t	d�|jD]z}t|t
�r�t||�r�|}	n
|�|�}	t|	d�r�t|	jt�r�|�|	jt|	j��n|�|	j�|�d|	j�t	d�qzt	||j��dS)	Nr��	gen_usager�z
Global options:r8zKInformation display options (just display information, ignore any commands)r�zOptions for '%s' command:)�distutils.corer�r�r�r�r�r�Z
print_help�common_usage�printr�rqr
rr�r�rYr�rr�r�rrE)
r^r�r�r�rqr�r�r9rb�klassrrrr�ms:

�



��
zDistribution._show_helpc	Cs�ddlm}|jr4|��td�t||j��dSd}i}|jD]}d||d<qB|D]l\}}|rX|�|�rXt|�}t	|j
d|��}|dkr�td�|��n |dkr�td	�|��nt|�d}qX|S)
Nrr�r8rr7r�r�)r.r0r1r2r:)r�r�Z
help_commands�print_commandsr�rEr�rQrrBr@r~)	r^r�r�Zany_display_optionsZis_display_option�optionrdrerrrrr��s*
z#Distribution.handle_display_optionsc	Csjt|d�|D]T}|j�|�}|s.|�|�}z
|j}Wntk
rPd}YnXtd|||f�qdS)N�:�(no description available)z
  %-*s  %s)r�rCrQr�r,�AttributeError)r^rqrp�
max_length�cmdr�r,rrr�print_command_list�s


zDistribution.print_command_listcCs�ddl}|jj}i}|D]}d||<qg}|j��D]}|�|�s4|�|�q4d}||D]}t|�|krZt|�}qZ|�|d|�|r�t	�|�|d|�dS)NrrzStandard commandszExtra commands)
�distutils.commandrb�__all__rCrmrQr�r�r�r�)r^rv�std_commands�is_stdr��extra_commandsr�rrrr��s.


��zDistribution.print_commandsc		Cs�ddl}|jj}i}|D]}d||<qg}|j��D]}|�|�s4|�|�q4g}||D]P}|j�|�}|sx|�|�}z
|j}Wnt	k
r�d}YnX|�||f�qZ|S)Nrrr�)
r�rbr�rCrmrQr�r�r,r�)	r^rvr�r�r�r��rvr�r,rrr�get_command_list�s(	




zDistribution.get_command_listcCsN|j}t|t�sJ|dkrd}dd�|�d�D�}d|krD|�dd�||_|S)Nr8cSsg|]}|dkr|���qS)r8r�)r4Zpkgrrrr6!sz5Distribution.get_command_packages.<locals>.<listcomp>r�zdistutils.commandr)rDr
rro�insert)r^Zpkgsrrr�get_command_packagess
z!Distribution.get_command_packagesc	Cs�|j�|�}|r|S|��D]�}d||f}|}zt|�tj|}Wntk
r^YqYnXzt||�}Wn&tk
r�t	d|||f��YnX||j|<|St	d|��dS)Nz%s.%sz3invalid command '%s' (no class '%s' in module '%s')zinvalid command '%s')
rCrQr��
__import__rVr|�ImportErrorrBr�r�)r^rbr�ZpkgnameZmodule_nameZ
klass_name�modulerrrr�'s,
��

zDistribution.get_command_classcCsl|j�|�}|sh|rhtr&|�d|�|�|�}||�}|j|<d|j|<|j�|�}|rh|�||�|S)Nz<Distribution.get_command_obj(): creating '%s' command objectr)rOrQrrnr�rPrG�_set_command_options)r^rbZcreate�cmd_objr�r9rrr�get_command_objMs�

zDistribution.get_command_objcCs\|��}|dkr|�|�}tr,|�d|�|��D�] \}\}}trZ|�d|||f�zdd�|jD�}Wntk
r�g}YnXz
|j}Wntk
r�i}YnXz|t|t	�}	||kr�|	r�t
|||t|��nJ||kr�|	r�t
||t|��n,t||��rt
|||�nt
d|||f��Wq4tk
�rT}
zt
|
��W5d}
~
XYq4Xq4dS)Nz#  setting options for '%s' command:z    %s = %s (from %s)cSsg|]}t|��qSrr3)r4�orrrr6|s�z5Distribution._set_command_options.<locals>.<listcomp>z1error in %s: command '%s' has no such option '%s')�get_command_namerSrrnrRZboolean_optionsr�r�r
rr>rrYr�r�)r^rOZoption_dict�command_namer��sourcerZ	bool_optsZneg_optZ	is_stringrrrrr�hsF	

��




��z!Distribution._set_command_optionsrcCs|ddlm}t||�s&|}|�|�}n|��}|js8|S|��d|_d|j|<|�|�|rx|�	�D]}|�
||�qf|S)Nrr�)r�r�r
r�r�Z	finalizedZinitialize_optionsrPr�Zget_sub_commands�reinitialize_command)r^rbZreinit_subcommandsr�r��subrrrr��s


z!Distribution.reinitialize_commandcCst�||�dSrir	)r^r�levelrrrrn�szDistribution.announcecCs|jD]}|�|�qdSri)rq�run_command)r^r�rrr�run_commands�s
zDistribution.run_commandscCsD|j�|�rdSt�d|�|�|�}|��|��d|j|<dS)Nz
running %sr)rPrQr
�infor�Zensure_finalized�run)r^rbr�rrrr��s	
zDistribution.run_commandcCst|jp|jpg�dkS�Nr)r�rHrIr�rrr�has_pure_modules�szDistribution.has_pure_modulescCs|jot|j�dkSr�)rLr�r�rrr�has_ext_modules�szDistribution.has_ext_modulescCs|jot|j�dkSr�)rJr�r�rrr�has_c_libraries�szDistribution.has_c_librariescCs|��p|��Sri)r�r�r�rrr�has_modules�szDistribution.has_modulescCs|jot|j�dkSr�)rKr�r�rrr�has_headers�szDistribution.has_headerscCs|jot|j�dkSr�)rMr�r�rrr�has_scripts�szDistribution.has_scriptscCs|jot|j�dkSr�)rNr�r�rrr�has_data_files�szDistribution.has_data_filescCs|��o|��o|��Sri)r�r�r�r�rrr�is_pure�s
��zDistribution.is_pure)N)NNr8)N)r)N)r)(r�
__module__�__qualname__r�r�r�r=r�rhrSrur�r�r�r�r�r]r�r�r�r�r�r�r�r�r�r�r
�INFOrnr�r�r�r�r�r�r�r�r�r�rrrrr,s��	�,

0
:C[
�
2(!"&

,
)
rc@seZdZdZdAdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�ZeZd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dS)Br?)r!r"r%�author_emailr'�maintainer_emailr)r*r,�long_descriptionr/r-r$r(Z
contact_emailr.�download_urlr0r1r2NcCs�|dk	r|�t|��nfd|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_dSri)�
read_pkg_file�openr!r"r%r�r'r�r)r*r,r�r/r-r.r�r0r1r2)r^rzrrrrh
s&zDistributionMetadata.__init__cst|���fdd�}�fdd�}�d}|d�|_|d�|_|d�|_|d	�|_d|_|d
�|_d|_|d�|_|d�|_	d
�kr�|d
�|_
nd|_
|d�|_|d�|_d�kr�|d��d�|_
|d�|_|d�|_|dkr�|d�|_|d�|_|d�|_nd|_d|_d|_dS)Ncs�|}|dkrdS|S�NZUNKNOWNr)r!r�rrr�_read_field(sz7DistributionMetadata.read_pkg_file.<locals>._read_fieldcs��|d�}|gkrdS|Sri)Zget_all)r!�valuesr�rr�
_read_list.sz6DistributionMetadata.read_pkg_file.<locals>._read_listzmetadata-versionr!r"Zsummaryr%r&z	home-pager*zdownload-urlr,r/r��platformZ
classifier�1.1r1r0r2)rr!r"r,r%r'r�r�r)r*r�r�ror/r-r.r1r0r2)r^�filer�r�Zmetadata_versionrr�rr�$s:












z"DistributionMetadata.read_pkg_filec	Cs2ttj�|d�ddd��}|�|�W5QRXdS)NzPKG-INFO�wzUTF-8)�encoding)r�ryrzr~�write_pkg_file)r^Zbase_dirZpkg_inforrr�write_pkg_infoXs
�z#DistributionMetadata.write_pkg_infocCsbd}|js"|js"|js"|js"|jr&d}|�d|�|�d|���|�d|���|�d|���|�d|�	��|�d|�
��|�d	|���|�d
|���|jr�|�d|j�t
|���}|�d|�d
�|���}|�r|�d|�|�|d|���|�|d|���|�|d|���|�|d|���|�|d|���dS)Nz1.0r�zMetadata-Version: %s
z	Name: %s
zVersion: %s
zSummary: %s
zHome-page: %s
zAuthor: %s
zAuthor-email: %s
zLicense: %s
zDownload-URL: %s
zDescription: %s
r�z
Keywords: %s
ZPlatformZ
ClassifierZRequiresZProvidesZ	Obsoletes)r0r1r2r.r�rX�get_name�get_version�get_description�get_url�get_contact�get_contact_email�get_licenser�get_long_descriptionr~�get_keywords�_write_list�
get_platforms�get_classifiers�get_requires�get_provides�
get_obsoletes)r^r�r"Z	long_descr/rrrr_s6��z#DistributionMetadata.write_pkg_filecCs |D]}|�d||f�qdS)Nz%s: %s
)rX)r^r�r!r�rrrrr
�sz DistributionMetadata._write_listcCs
|jpdSr�)r!r�rrrr�szDistributionMetadata.get_namecCs
|jpdS)Nz0.0.0)r"r�rrrr�sz DistributionMetadata.get_versioncCsd|��|��fS)Nz%s-%s)rrr�rrr�get_fullname�sz!DistributionMetadata.get_fullnamecCs
|jpdSr�)r%r�rrr�
get_author�szDistributionMetadata.get_authorcCs
|jpdSr�)r�r�rrr�get_author_email�sz%DistributionMetadata.get_author_emailcCs
|jpdSr�)r'r�rrr�get_maintainer�sz#DistributionMetadata.get_maintainercCs
|jpdSr�)r�r�rrr�get_maintainer_email�sz)DistributionMetadata.get_maintainer_emailcCs|jp|jpdSr�)r'r%r�rrrr�sz DistributionMetadata.get_contactcCs|jp|jpdSr�)r�r�r�rrrr	�sz&DistributionMetadata.get_contact_emailcCs
|jpdSr�)r)r�rrrr�szDistributionMetadata.get_urlcCs
|jpdSr�)r*r�rrrr
�sz DistributionMetadata.get_licensecCs
|jpdSr�)r,r�rrrr�sz$DistributionMetadata.get_descriptioncCs
|jpdSr�)r�r�rrrr�sz)DistributionMetadata.get_long_descriptioncCs
|jpgSri)r/r�rrrr�sz!DistributionMetadata.get_keywordscCst|d�|_dS)Nr/)rr/�r^rrrr�set_keywords�sz!DistributionMetadata.set_keywordscCs|jp
dgSr�)r-r�rrrr�sz"DistributionMetadata.get_platformscCst|d�|_dS)Nr-)rr-rrrr�
set_platforms�sz"DistributionMetadata.set_platformscCs
|jpgSri)r.r�rrrr�sz$DistributionMetadata.get_classifierscCst|d�|_dS)Nr.)rr.rrrr�set_classifiers�sz$DistributionMetadata.set_classifierscCs
|jpdSr�)r�r�rrr�get_download_url�sz%DistributionMetadata.get_download_urlcCs
|jpgSri)r1r�rrrr�sz!DistributionMetadata.get_requirescCs,ddl}|D]}|j�|�qt|�|_dSr�)�distutils.versionpredicate�versionpredicate�VersionPredicaterr1�r^rrvrrrr�set_requires�sz!DistributionMetadata.set_requirescCs
|jpgSri)r0r�rrrr�sz!DistributionMetadata.get_providescCs6dd�|D�}|D]}ddl}|j�|�q||_dS)NcSsg|]}|���qSrr�)r4rrrrr6�sz5DistributionMetadata.set_provides.<locals>.<listcomp>r)rrZsplit_provisionr0)r^rrrvrrr�set_provides�s
z!DistributionMetadata.set_providescCs
|jpgSri)r2r�rrrr�sz"DistributionMetadata.get_obsoletescCs,ddl}|D]}|j�|�qt|�|_dSr�)rrrrr2r rrr�
set_obsoletes�sz"DistributionMetadata.set_obsoletes)N)$rr�r�rArhr�rrr
rrrrrrrrr	rr
Zget_licencerrrrrrrrrrr!rr"rr#rrrrr?�sB	
4"r?cCs$g}|D]}|�|dd��q|S)Nr�)r�)r9Znew_optionsZ
help_tuplerrrr��sr�)rVry�reZemailrrTr�Zdistutils.errorsZdistutils.fancy_getoptrrZdistutils.utilrrrrvr
Zdistutils.debugr�compiler�rrr?r�rrrr�<module>s2

ZcPK42�\��(S��filelist.cpython-38.opt-2.pycnu�[���U

e5d 2�@s�ddlZddlZddlZddlZddlmZddlmZmZddl	m
Z
Gdd�d�Zdd�Zej
fd	d
�Zdd�Zddd�ZdS)�N��convert_path)�DistutilsTemplateError�DistutilsInternalError)�logc@sxeZdZddd�Zdd�Zejfdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zddd�Zddd�ZdS)�FileListNcCsd|_g|_dS�N)�allfiles�files)�self�warn�debug_print�r�*/usr/lib64/python3.8/distutils/filelist.py�__init__szFileList.__init__cCs
||_dSr)r	)rr	rrr�set_allfiles#szFileList.set_allfilescCst|�|_dSr)�findallr	)r�dirrrrr&szFileList.findallcCsddlm}|rt|�dS)Nr)�DEBUG)Zdistutils.debugr�print)r�msgrrrrr
)szFileList.debug_printcCs|j�|�dSr)r
�append)r�itemrrrr3szFileList.appendcCs|j�|�dSr)r
�extend)r�itemsrrrr6szFileList.extendcCs<tttjj|j��}g|_|D]}|j�tjj|��qdSr)�sorted�map�os�path�splitr
r�join)rZsortable_filesZ
sort_tuplerrr�sort9sz
FileList.sortcCs@tt|j�ddd�D]$}|j||j|dkr|j|=qdS)N�r���)�range�lenr
)r�irrr�remove_duplicatesCszFileList.remove_duplicatescCs�|��}|d}d}}}|dkrTt|�dkr<td|��dd�|dd�D�}n~|dkr�t|�d	krttd
|��t|d�}dd�|dd�D�}n:|dkr�t|�dkr�td
|��t|d�}ntd|��||||fS)Nr)�include�exclude�global-include�global-exclude�z&'%s' expects <pattern1> <pattern2> ...cSsg|]}t|��qSrr��.0�wrrr�
<listcomp>Wsz1FileList._parse_template_line.<locals>.<listcomp>r")�recursive-include�recursive-exclude�z,'%s' expects <dir> <pattern1> <pattern2> ...cSsg|]}t|��qSrrr-rrrr0]s)�graft�prunez#'%s' expects a single <dir_pattern>zunknown action '%s')rr%rr)r�lineZwords�action�patternsr�dir_patternrrr�_parse_template_lineLs0���zFileList._parse_template_linecCs@|�|�\}}}}|dkrV|�dd�|��|D]}|j|dd�s2t�d|�q2�n�|dkr�|�dd�|��|D]}|j|dd�svt�d	|�qv�n�|d
kr�|�dd�|��|D]}|j|dd�s�t�d
|�q��n^|dk�r(|�dd�|��|D]"}|j|dd��st�d|��q�n|dk�rv|�d|d�|�f�|D]$}|j||d��sNt�d||��qNn�|dk�r�|�d|d�|�f�|D]$}|j||d��s�t�d||��q�nx|dk�r�|�d|�|jd|d��s<t�d|�nB|dk�r0|�d|�|jd|d��s<t�d|�ntd|��dS)Nr(zinclude � r")�anchorz%warning: no files found matching '%s'r)zexclude z9warning: no previously-included files found matching '%s'r*zglobal-include rz>warning: no files found matching '%s' anywhere in distributionr+zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionr1zrecursive-include %s %s)�prefixz:warning: no files found matching '%s' under directory '%s'r2zrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'r4zgraft z+warning: no directories found matching '%s'r5zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r:r
r �include_patternrr�exclude_patternr)rr6r7r8rr9�patternrrr�process_template_linehs��
�
�

�
��

��

�
��zFileList.process_template_liner"rcCsld}t||||�}|�d|j�|jdkr4|��|jD],}|�|�r:|�d|�|j�|�d}q:|S)NFz%include_pattern: applying regex r'%s'z adding T)�translate_patternr
r@r	r�searchr
r)rr@r<r=�is_regex�files_found�
pattern_re�namerrrr>�s�


zFileList.include_patterncCsrd}t||||�}|�d|j�tt|j�ddd�D]4}|�|j|�r8|�d|j|�|j|=d}q8|S)NFz%exclude_pattern: applying regex r'%s'r"r#z
 removing T)rBr
r@r$r%r
rC)rr@r<r=rDrErFr&rrrr?�s�zFileList.exclude_pattern)NN)r"Nr)r"Nr)�__name__�
__module__�__qualname__rrr�curdirrr
rrr!r'r:rAr>r?rrrrrs


	L
,�rcCs&dd�tj|dd�D�}ttjj|�S)Ncss,|]$\}}}|D]}tj�||�VqqdSr)rrr )r.�base�dirsr
�filerrr�	<genexpr>�s�z#_find_all_simple.<locals>.<genexpr>T)�followlinks)r�walk�filterr�isfile)rZresultsrrr�_find_all_simple�s�rTcCs6t|�}|tjkr.tjtjj|d�}t||�}t|�S)N)�start)	rTrrK�	functools�partialr�relpathr�list)rr
Zmake_relrrrrs


rcCs8t�|�}tj}tjdkrd}d|}t�d||�}|S)N�\z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)�fnmatch�	translater�sep�re�sub)r@rFr]Zescapedrrr�
glob_to_res

r`r"c
Cs�|rt|t�rt�|�S|Std��d�\}}}|r>t|�}nd}|dk	r�t|�}|t|�t|�t|��}tj}	tjdkr�d}	|t|�t|�t|��}d|||	||f}n|r�d||t|�d�f}t�|�S)N�_�rZz\\z%s\A%s%s.*%s%sz%s\A%s)	�
isinstance�strr^�compiler`�	partitionr%rr])
r@r<r=rDrUra�endrFZ	prefix_rer]rrrrB%s(


rB)r"Nr)rr^r[rVZdistutils.utilrZdistutils.errorsrrZ	distutilsrrrTrKrr`rBrrrr�<module>siPK42�\��ES��debug.cpython-38.opt-2.pycnu�[���U

e5d��@sddlZej�d�ZdS)�NZDISTUTILS_DEBUG)�os�environ�get�DEBUG�rr�'/usr/lib64/python3.8/distutils/debug.py�<module>sPK42�\|�W�!�!sysconfig.cpython-38.opt-2.pycnu�[���U

��.eP�@s�ddlZddlZddlZddlZddlmZddlmZmZej	�
ej�Zej	�
ej
�Zej	�
ej�Zej	�
ej�Zdejkr�ej	�ejd�Zn&ejr�ej	�ej	�ej��Zne��Zdd�Zeedd�Zejd	kr�d
d�Zee�Zee�Zdd
�Ze�ZdZ ze�sej!Z Wne"k
�r&YnXdd�Z#d,dd�Z$d-dd�Z%dd�Z&dd�Z'dd�Z(d.dd�Z)e�*d�Z+e�*d�Z,e�*d�Z-d/d d!�Z.d"d#�Z/da0d$d%�Z1d&d'�Z2d(d)�Z3d*d+�Z4dS)0�N�)�DistutilsPlatformError)�get_platform�get_host_platformZ_PYTHON_PROJECT_BASEcCs,dD]"}tj�tj�|d|��rdSqdS)N)ZSetupzSetup.localZModulesTF)�os�path�isfile�join)�d�fn�r�+/usr/lib64/python3.8/distutils/sysconfig.py�_is_python_source_dir+sr�_home�ntcCs0|r,tj�|��tj�tj�td���r,tS|S)NZPCbuild)rr�normcase�
startswithr	�PREFIX)r
rrr
�_fix_pcbuild4s
�rcCstrtt�Stt�S)N)�	_sys_homer�project_baserrrr
�
_python_build<sr�cCsdtjdd�S)Nz%d.%d�)�sys�version_inforrrr
�get_python_versionPsrcCs�|dkr|rtpt}tjdkrjtrL|r.tp,tStj�t	d�d�}tj�
|�Sdt�t}tj�|d|�Stjdkr�tr�tj�|d�tjj
tj�|d�Stj�|d�Stdtj��dS)	N�posix�srcdirZInclude�pythonZincluder�PCzFI don't know where Python installs its C header files on platform '%s')�BASE_EXEC_PREFIX�BASE_PREFIXr�name�python_buildrrrr	�get_config_var�normpathr�build_flags�pathsepr)�
plat_specific�prefixZincdirZ
python_dirrrr
�get_python_incXs*

���r+cCs�|dkr&|r|rtpt}n|r"tp$t}tjdkrp|s8|r>d}nd}tj�||dt��}|r`|Stj�|d�Sn<tjdkr�|r�tj�|d�Stj�|dd�Snt	dtj��dS)	Nr�lib64�librz
site-packagesrZLibz?I don't know where Python installs its library on platform '%s')
r!r"�EXEC_PREFIXrrr#rr	rr)r)�standard_libr*r-Z	libpythonrrr
�get_python_lib�s0
�
��r0c	Cs�|jdk�r�tjdkr8td�s8ddl}|�t�dtd<tdddd	d
ddd
�\}}}}}}}}	dtj	kr�tj	d}
tjdkr�d
tj	kr�|�
|�r�|
|t|�d�}|
}dtj	kr�tj	d}d
tj	kr�tj	d
}dtj	kr�tj	d}n|d}dtj	k�r|dtj	d}dtj	k�r<|dtj	d}|dtj	d}dtj	k�r~|dtj	d}|dtj	d}|dtj	d}dtj	k�r�tj	d}d
tj	k�r�|dtj	d
}n|d|	}|d|}
|j||
|
d|||||d�||_
dS)NZunix�darwinZCUSTOMIZED_OSX_COMPILERr�TrueZCCZCXX�CFLAGSZCCSHAREDZLDSHAREDZSHLIB_SUFFIXZARZARFLAGSZCPPz -E�LDFLAGS� �CPPFLAGS)Zpreprocessor�compilerZcompiler_soZcompiler_cxxZ	linker_soZ
linker_exe�archiver)Z
compiler_typer�platformr%�_osx_support�customize_compiler�_config_vars�get_config_varsr�environr�lenZset_executablesZshared_lib_extension)r7r:ZccZcxxZcflagsZccsharedZldsharedZshlib_suffixZarZar_flagsZnewccZcppr8Zcc_cmdrrr
r;�sn

��


��






�	r;cCsDtr,tjdkr"tj�tptd�}q6tp(t}n
tdd�}tj�|d�S)Nrr r�r)z
pyconfig-64.h)r$rr#rr	rrr+)Zinc_dirrrr
�get_config_h_filename�s


rAcCs\trtj�tptd�Stddd�}d�t�t	�}t
tjd�rL|dtjj
7}tj�||d�S)NZMakefilerr�r)r/zconfig-{}{}�
_multiarchz-%s)r$rrr	rrr0�formatrr'�hasattrr�implementationrC)Zlib_dirZconfig_filerrr
�get_makefile_filenamesrGcCs�|dkri}t�d�}t�d�}|��}|s.q�|�|�}|rx|�dd�\}}zt|�}Wntk
rlYnX|||<q |�|�}|r d||�d�<q |S)Nz"#define ([A-Z][A-Za-z0-9_]+) (.*)
z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/
rrr)�re�compile�readline�match�group�int�
ValueError)�fp�gZ	define_rxZundef_rx�line�m�n�vrrr
�parse_config_hs&




rUz"([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)z\$\(([A-Za-z][A-Za-z0-9_]*)\)z\${([A-Za-z][A-Za-z0-9_]*)}c	Cs�ddlm}||ddddd�}|dkr*i}i}i}|��}|dkrDq�t�|�}|r2|�dd�\}}	|	��}	|	�dd�}
d	|
kr�|	||<q2zt|	�}	Wn$t	k
r�|	�dd	�||<Yq2X|	||<q2d
}|�rtt
|�D�]�}||}
t�|
�p�t
�|
�}|�rj|�d�}d}||k�r$t||�}n�||k�r4d}nx|tjk�rLtj|}n`||k�r�|�d
��rz|dd�|k�rzd}n$d
||k�r�d}nt|d
|�}nd||<}|�rp|
|��d�}|
d|���||}
d	|k�r�|
||<nzzt|
�}
Wn"t	k
�r|
��||<Yn
X|
||<||=|�d
��rp|dd�|k�rp|dd�}||k�rp|
||<q�||=q�q�|��|��D]"\}}	t|	t��r�|	��||<�q�|�|�|S)Nr)�TextFiler�surrogateescape)Zstrip_commentsZskip_blanksZ
join_lines�errorsrz$$r�$)r3r4r6TFZPY_�)Zdistutils.text_filerVrJ�_variable_rxrKrL�strip�replacerMrN�list�_findvar1_rx�search�_findvar2_rx�strrr>r�end�start�close�items�
isinstance�update)rrPrVrOZdoneZnotdonerQrRrSrTZtmpvZrenamed_variablesr#�value�found�itemZafter�krrr
�parse_makefile/s�








�



rmcCsVt�|�pt�|�}|rR|��\}}|d|�|�|�d��||d�}qqRq|S)Nrr)r_r`ra�span�getrL)�s�varsrRZbegrcrrr
�expand_makefile_vars�s*rrc
CsVtj�ddjtjtjttjdd�d��}t	|t
�t�dgd�}|j}ia
t
�|�dS)NZ_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}rCr)Zabir9Z	multiarch�build_time_varsr)rr>rorDr�abiflagsr9�getattrrF�
__import__�globals�localsrsr<rh)r#Z_temprsrrr
�_init_posix�s��rycCs~i}tddd�|d<tddd�|d<tdd�|d<t��d|d<d	|d
<t��dd�|d
<tj�tj�	t
j��|d<|adS)NrrrBZLIBDESTZ
BINLIBDESTr@Z	INCLUDEPY�
EXT_SUFFIXz.exeZEXE�.rZVERSIONZBINDIR)
r0r+�_imp�extension_suffixesrr]rr�dirname�abspathr�
executabler<)rPrrr
�_init_nt�sr�cGs\tdk�r*t��dtj�}|r(|�niattd<ttd<t�d�}|dk	rV|td<t�dt�}tjdkr�tr�tj	�
t��}tj	�||�}ntj	�
t��}tj	�
tj	�|��td<t�rtjdk�rt}tj	�td��s|t��k�rtj	�|td�}tj	�|�td<tjdk�r*d	dl}|�t�|�rTg}|D]}|�t�|���q8|StSdS)
NZ_init_r*�exec_prefixrz�SOrrr1r)r<rwrorr#rr.rr$rr~rGr	rr&�isabs�getcwdrr9r:Zcustomize_config_vars�append)�args�funcr�r�baser:Zvalsr#rrr
r=�sB



�
r=cCs*|dkrddl}|�dtd�t��|�S)Nr�rz SO is deprecated, use EXT_SUFFIXr)�warnings�warn�DeprecationWarningr=ro)r#r�rrr
r%!sr%)rN)rrN)N)N)5r|rrHrrXr�utilrrrr&r*rr�r.�base_prefixr"�base_exec_prefixr!r>rrr�r~r�rrurr#rrr$r'rt�AttributeErrorrr+r0r;rArGrUrIr[r_rarmrrr<ryr�r=r%rrrr
�<module>sZ



(
+I





jJPK42�\zw�\HH$cygwinccompiler.cpython-38.opt-2.pycnu�[���U

e5d^@�@s�ddlZddlZddlZddlmZmZmZddlZddlm	Z	m
Z
ddlmZddl
mZddlmZmZmZmZddlmZddlmZdd	lmZd
d�ZGdd
�d
e�ZGdd�de�ZdZdZdZdd�Z e�!d�Z"dd�Z#dd�Z$dd�Z%dS)�N)�Popen�PIPE�check_output)�gen_preprocess_options�gen_lib_options)�
UnixCCompiler)�
write_file)�DistutilsExecError�CCompilerError�CompileError�UnknownFileError)�log)�LooseVersion)�find_executablecCs�tj�d�}|dkr|tj|d|d�}|dkr8dgS|dkrFdgS|d	krTd
gS|dkrbdgS|d
krpdgStd|��dS)NzMSC v.�����
Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100zUnknown MS Compiler version %s )�sys�version�find�
ValueError)Zmsc_posZmsc_ver�r�1/usr/lib64/python3.8/distutils/cygwinccompiler.py�	get_msvcr?src
@sNeZdZdZdZdZdZdZdZdZ	dd	d
�Z
dd�Zddd�Zddd�Z
d
S)�CygwinCCompiler�cygwinz.o�.az.dllzlib%s%sz%s%sz.exercCs�t�||||�t�\}}|�d||f�|tk	rB|�d|�t�\|_|_|_	|�|j
d|j|j|j	f�|jdkr�d|_nd|_|jdkr�d}nd	}|jd
ddd
d|j|fd�|jdkr�dg|_
|�d�nt�|_
dS)Nz%Python's GCC status: %s (details: %s)z�Python's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.z: gcc %s, ld %s, dllwrap %s
z2.10.90�gcc�dllwrap�2.13�-shared�
-mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallzgcc -mcygwinz%s -mcygwin %s�Zcompiler�compiler_soZcompiler_cxxZ
linker_exeZ	linker_so�2.91.57Zmsvcrtz,Consider upgrading to a newer version of gcc)r�__init__�check_config_hZdebug_print�CONFIG_H_OK�warn�get_versions�gcc_version�
ld_versionZdllwrap_version�
compiler_type�
linker_dll�set_executables�
dll_librariesr)�self�verbose�dry_run�forceZstatusZdetails�
shared_optionrrrr%dsN
����
��


��
�zCygwinCCompiler.__init__c
Cs�|dks|dkrVz|�dd|d|g�Wq�tk
rR}zt|��W5d}~XYq�XnNz"|�|j||d|g|�Wn*tk
r�}zt|��W5d}~XYnXdS)N�.rc�.resZwindresz-iz-o)Zspawnr	rr#)r0�obj�src�extZcc_args�extra_postargsZpp_opts�msgrrr�_compile�s�
zCygwinCCompiler._compileNcCsPt�|
p
g�}
t�|pg�}t�|p&g�}|�|j�|dk	�r||jksV|jdk�rtj�|d�}tj�tj�	|��\}}tj�
||d�}tj�
|d|d�}dtj�	|�dg}|D]}|�|�q�|�t
||fd|�|jd	k�r|
�d
|g�|
�d|g�n
|�|�|	�s(|
�d�t�||||||||d|	|
|||
�dS)
Nrrz.def�librz
LIBRARY %sZEXPORTSz
writing %srz--output-libz--defz-s)�copy�extendr/Z
EXECUTABLEr-�os�path�dirname�splitext�basename�join�appendZexecuterr�link)r0Ztarget_descZobjectsZoutput_filename�
output_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbols�debugZ
extra_preargsr:Z
build_tempZtarget_langZtemp_dirZdll_nameZ
dll_extensionZdef_fileZlib_file�contentsZsymrrrrG�sR
��

���

�zCygwinCCompiler.link�cCs�|dkrd}g}|D]�}tj�tj�|��\}}||jddgkrRtd||f��|rbtj�|�}|dkr�|�tj�||||j	��q|�tj�|||j	��q|S)NrKr5r6z"unknown file type '%s' (from '%s'))r6r5)
r@rArC�normcaseZsrc_extensionsrrDrFrE�
obj_extension)r0Zsource_filenamesZ	strip_dirrHZ	obj_namesZsrc_name�baser9rrr�object_filenames�s&���z CygwinCCompiler.object_filenames)rrr)
NNNNNrNNNN)rrK)�__name__�
__module__�__qualname__r,rMZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr%r<rGrOrrrrrYs*
;�
Nrc@seZdZdZddd�ZdS)�Mingw32CCompilerZmingw32rc	Csxt�||||�|jdkr d}nd}|jdkr4d}nd}t�rFtd��|jdd	d
dd|j||fd
�g|_t	�|_dS)Nrr r!r$z--entry _DllMain@12rKz1Cygwin gcc cannot be used with --compiler=mingw32zgcc -O -Wallzgcc -mdll -O -Wallzg++ -O -Wallrz%s %s %sr")
rr%r+r*�is_cygwingccr
r.r-r/r)r0r1r2r3r4Zentry_pointrrrr%s.

����zMingw32CCompiler.__init__N)rrr)rPrQrRr,r%rrrrrSsrS�okznot okZ	uncertainc
Cs�ddlm}dtjkrtdfS|��}zLt|�}z4d|��krPtd|fW�WSt	d|fW�WSW5|��XWn8t
k
r�}ztd||jffWY�Sd}~XYnXdS)	Nr)�	sysconfigZGCCzsys.version mentions 'GCC'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '%s': %s)
�	distutilsrVrrr'Zget_config_h_filename�open�close�read�CONFIG_H_NOTOK�OSError�CONFIG_H_UNCERTAIN�strerror)rV�fnZconfig_h�excrrrr&Hs
�r&s(\d+\.\d+(\.\d+)*)cCsl|��d}t|�dkrdSt|dtd�j}z|��}W5|��Xt�|�}|dkrZdSt	|�
d����S)NrT)�shell�stdout�)�splitrrrrbrYrZ�
RE_VERSION�searchr�group�decode)�cmd�
executable�out�
out_string�resultrrr�_find_exe_versionus

rncCsdddg}tdd�|D��S)Nzgcc -dumpversionzld -vzdllwrap --versioncSsg|]}t|��qSr)rn)�.0rirrr�
<listcomp>�sz get_versions.<locals>.<listcomp>)�tuple)Zcommandsrrrr)�s
r)cCstddg�}|���d�S)Nrz-dumpmachinescygwin)r�strip�endswith)rlrrrrT�srT)&r@rr>�
subprocessrrr�reZdistutils.ccompilerrrZdistutils.unixccompilerrZdistutils.file_utilrZdistutils.errorsr	r
rrrWr
Zdistutils.versionrZdistutils.spawnrrrrSr'r[r]r&�compilerernr)rTrrrr�<module>0s.;1+
PK42�\U�����"unixccompiler.cpython-38.opt-2.pycnu�[���U

&�.e�;�@s�ddlZddlZddlZddlmZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZmZddlmZejdkrzddlZGdd	�d	e�ZdS)
�N)�	sysconfig)�newer)�	CCompiler�gen_preprocess_options�gen_lib_options)�DistutilsExecError�CompileError�LibError�	LinkError)�log�darwinc
s�eZdZdZddgdgdgddgdgddgdd�Zejdd�d	krNd
ged
<ddd
dddgZdZdZ	dZ
dZdZdZ
ZZeZejdkr�dZ�fdd�Zd.dd�Zdd�Zd/d d!�Zd0d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd1d,d-�Z�ZS)2�
UnixCCompilerZunixNZccz-sharedZarz-cr)�preprocessor�compiler�compiler_so�compiler_cxx�	linker_so�
linker_exe�archiver�ranlib�rrz.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%s�cygwinz.execs@t��|||�\}}}t�d�}|r6||kr6|�|�|||fS)NZLIBDIR)�super�
_fix_lib_argsr�get_config_var�remove)�self�	libraries�library_dirs�runtime_library_dirsZlibdir��	__class__��//usr/lib64/python3.8/distutils/unixccompiler.pyrUs�


zUnixCCompiler._fix_lib_argsc
Cs�|�d||�}|\}}}t||�}	|j|	}
|r>|
�d|g�|rN||
dd�<|r\|
�|�|
�|�|js~|dks~t||�r�|r�|�tj	�
|��z|�|
�Wn*tk
r�}zt
|��W5d}~XYnXdS)N�-or)Z_fix_compile_argsrr�extend�appendZforcer�mkpath�os�path�dirname�spawnrr)r�sourceZoutput_fileZmacrosZinclude_dirs�
extra_preargs�extra_postargs�
fixed_args�ignore�pp_optsZpp_args�msgr"r"r#�
preprocess^s$




zUnixCCompiler.preprocessc	
Csp|j}tjdkr t�|||�}z |�|||d|g|�Wn*tk
rj}zt|��W5d}~XYnXdS)Nrr$)r�sys�platform�_osx_support�compiler_fixupr+rr)	r�obj�srcZextZcc_argsr.r1rr2r"r"r#�_compilexs
��
zUnixCCompiler._compilerc
Cs�|�||�\}}|j||d�}|�||�r�|�tj�|��|�|j|g||j	�|j
r�z|�|j
|g�Wq�tk
r�}zt|��W5d}~XYq�Xnt
�d|�dS)N)�
output_dir�skipping %s (up-to-date))�_fix_object_args�library_filename�
_need_linkr'r(r)r*r+r�objectsrrr	r�debug)rr@Zoutput_libnamer;rA�target_lang�output_filenamer2r"r"r#�create_static_lib�s$����	zUnixCCompiler.create_static_libc
Cs�|�||�\}}|�|||�}|\}}}t||||�}t|ttd�f�sPtd��|dk	rftj�	||�}|�
||��r�||j|d|g}|	r�dg|dd�<|
r�|
|dd�<|r�|�|�|�
tj�|��z�|tjkr�|jdd�}n|jdd�}|
dk�rr|j�rrd}tj�|d�dk�r@d}d||k�r@|d7}�q&tj�||�d	k�r\d}nd}|j||||<tjd
k�r�t�||�}|�||�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz%'output_dir' must be a string or Noner$z-grzc++�env��=Z	ld_so_aixrr<)r=rr�
isinstance�str�type�	TypeErrorr(r)�joinr?r@r%r'r*rZ
EXECUTABLErrr�basenamer4r5r6r7r+rr
rrA)rZtarget_descr@rCr;rrrZexport_symbolsrAr-r.Z
build_temprBr/Zlib_optsZld_argsZlinker�i�offsetr2r"r"r#�link�sZ�
���

zUnixCCompiler.linkcCsd|S)N�-Lr")r�dirr"r"r#�library_dir_option�sz UnixCCompiler.library_dir_optioncCsd|kpd|kS)NZgcczg++r")rZ
compiler_namer"r"r#�_is_gcc�szUnixCCompiler._is_gcccCs�tj�t�d��}tjdd�dkr,d|Stjdd�dkrFd|Stjdd�d	krz|�|�rnd
d|gSdd|gS|�|�r�t�d�d
kr�d|Sd|Snd|SdS)N�CCrrrQ�Zfreebsdz-Wl,-rpath=�zhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r(r)rMrrr4r5rT)rrRrr"r"r#�runtime_library_dir_option�s


z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr")r�libr"r"r#�library_optionszUnixCCompiler.library_optioncCs�|j|dd�}|j|dd�}|j|dd�}|j|dd�}tjdkr|t�d�}t�d|�}	|	dkrrt�t�d	��}
n
|	�	d
�}
|D�] }t
j�||�}t
j�||�}
t
j�||�}t
j�||�}tjdk�rL|�
d�s�|�
d��rL|�
d
��sLt
j�|
|d
d�|�}t
j�|
|d
d�|�}
t
j�|
|d
d�|�}t
j�|
|d
d�|�}t
j�|
��rb|
St
j�|��rx|St
j�|��r�|St
j�|�r�|Sq�dS)N�shared)Zlib_type�dylib�
xcode_stub�staticrZCFLAGSz-isysroot\s*(\S+)rUrFz/System/z/usr/z/usr/local/)r>r4r5rr�re�searchr6Z_default_sysroot�groupr(r)rL�
startswith�exists)r�dirsrYrAZshared_fZdylib_fZxcode_stub_fZstatic_fZcflags�mZsysrootrRr[r\r^r]r"r"r#�find_library_filesF



���
zUnixCCompiler.find_library_file)NNNNN)NrN)
NNNNNrNNNN)r)�__name__�
__module__�__qualname__Z
compiler_typeZexecutablesr4r5Zsrc_extensionsZ
obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ
exe_extensionrr3r:rDrPrSrTrXrZrf�
__classcell__r"r"r r#r
-sb�


	�
�
�
B*r
)r(r4r_Z	distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr	r
rr5r6r
r"r"r"r#�<module>s
PK42�\�Z@+n/n/sysconfig.cpython-38.opt-1.pycnu�[���U

��.eP�@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ej
�ej�Z
ej
�ej�Zej
�ej�Zej
�ej�Zdejkr�ej
�ejd�Zn&ejr�ej
�ej
�ej��Zne��Zdd�Zeed	d�Zejd
kr�dd�Zee�Zee�Zd
d�Ze�Z dZ!ze �sej"Z!Wne#k
�r*YnXdd�Z$d-dd�Z%d.dd�Z&dd�Z'dd�Z(dd�Z)d/dd�Z*e�+d�Z,e�+d�Z-e�+d �Z.d0d!d"�Z/d#d$�Z0da1d%d&�Z2d'd(�Z3d)d*�Z4d+d,�Z5dS)1a�Provide access to Python's configuration information.  The specific
configuration variables available depend heavily on the platform and
configuration.  The values may be retrieved using
get_config_var(name), and the list of variables is available via
get_config_vars().keys().  Additional convenience functions are also
available.

Written by:   Fred L. Drake, Jr.
Email:        <fdrake@acm.org>
�N�)�DistutilsPlatformError)�get_platform�get_host_platformZ_PYTHON_PROJECT_BASEcCs,dD]"}tj�tj�|d|��rdSqdS)N)ZSetupzSetup.localZModulesTF)�os�path�isfile�join)�d�fn�r�+/usr/lib64/python3.8/distutils/sysconfig.py�_is_python_source_dir+sr�_home�ntcCs0|r,tj�|��tj�tj�td���r,tS|S)NZPCbuild)rr�normcase�
startswithr	�PREFIX)r
rrr
�_fix_pcbuild4s
�rcCstrtt�Stt�S)N)�	_sys_homer�project_baserrrr
�
_python_build<sr�cCsdtjdd�S)z�Return a string containing the major and minor Python version,
    leaving off the patchlevel.  Sample return values could be '1.5'
    or '2.2'.
    z%d.%dN�)�sys�version_inforrrr
�get_python_versionPsrcCs�|dkr|rtpt}tjdkrjtrL|r.tp,tStj�t	d�d�}tj�
|�Sdt�t}tj�|d|�Stjdkr�tr�tj�|d�tjj
tj�|d�Stj�|d�Std	tj��dS)
a�Return the directory containing installed Python header files.

    If 'plat_specific' is false (the default), this is the path to the
    non-platform-specific header files, i.e. Python.h and so on;
    otherwise, this is the path to platform-specific header files
    (namely pyconfig.h).

    If 'prefix' is supplied, use it instead of sys.base_prefix or
    sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
    N�posix�srcdirZInclude�pythonZincluder�PCzFI don't know where Python installs its C header files on platform '%s')�BASE_EXEC_PREFIX�BASE_PREFIXr�name�python_buildrrrr	�get_config_var�normpathr�build_flags�pathsepr)�
plat_specific�prefixZincdirZ
python_dirrrr
�get_python_incXs*

���r+cCs�|dkr&|r|rtpt}n|r"tp$t}tjdkrp|s8|r>d}nd}tj�||dt��}|r`|Stj�|d�Sn<tjdkr�|r�tj�|d�Stj�|dd�Snt	d	tj��dS)
aSReturn the directory containing the Python library (standard or
    site additions).

    If 'plat_specific' is true, return the directory containing
    platform-specific modules, i.e. any module from a non-pure-Python
    module distribution; otherwise, return the platform-shared library
    directory.  If 'standard_lib' is true, return the directory
    containing standard Python library modules; otherwise, return the
    directory for site-specific modules.

    If 'prefix' is supplied, use it instead of sys.base_prefix or
    sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
    Nr�lib64�librz
site-packagesrZLibz?I don't know where Python installs its library on platform '%s')
r!r"�EXEC_PREFIXrrr#rr	rr)r)�standard_libr*r-Z	libpythonrrr
�get_python_lib�s0
�
��r0c	Cs�|jdk�r�tjdkr8td�s8ddl}|�t�dtd<tddd	d
ddd
d�\}}}}}}}}	dtj	kr�tj	d}
tjdkr�dtj	kr�|�
|�r�|
|t|�d�}|
}dtj	kr�tj	d}dtj	kr�tj	d}dtj	kr�tj	d}n|d}dtj	k�r|dtj	d}d	tj	k�r<|dtj	d	}|dtj	d	}dtj	k�r~|dtj	d}|dtj	d}|dtj	d}d
tj	k�r�tj	d
}dtj	k�r�|dtj	d}n|d|	}|d|}
|j||
|
d|||||d�||_
dS)z�Do any platform-specific customization of a CCompiler instance.

    Mainly needed on Unix, so we can plug in the information that
    varies across Unices and is stored in Python's Makefile.
    Zunix�darwinZCUSTOMIZED_OSX_COMPILERrN�TrueZCCZCXX�CFLAGSZCCSHAREDZLDSHAREDZSHLIB_SUFFIXZARZARFLAGSZCPPz -E�LDFLAGS� �CPPFLAGS)Zpreprocessor�compilerZcompiler_soZcompiler_cxxZ	linker_soZ
linker_exe�archiver)Z
compiler_typer�platformr%�_osx_support�customize_compiler�_config_vars�get_config_varsr�environr�lenZset_executablesZshared_lib_extension)r7r:ZccZcxxZcflagsZccsharedZldsharedZshlib_suffixZarZar_flagsZnewccZcppr8Zcc_cmdrrr
r;�sn

��


��






�	r;cCsDtr,tjdkr"tj�tptd�}q6tp(t}n
tdd�}tj�|d�S)z2Return full pathname of installed pyconfig.h file.rr r�r)z
pyconfig-64.h)r$rr#rr	rrr+)Zinc_dirrrr
�get_config_h_filename�s


rAcCs\trtj�tptd�Stddd�}d�t�t	�}t
tjd�rL|dtjj
7}tj�||d�S)zAReturn full pathname of installed Makefile from the Python build.ZMakefilerr�r)r/zconfig-{}{}�
_multiarchz-%s)r$rrr	rrr0�formatrr'�hasattrr�implementationrC)Zlib_dirZconfig_filerrr
�get_makefile_filenamesrGcCs�|dkri}t�d�}t�d�}|��}|s.q�|�|�}|rx|�dd�\}}zt|�}Wntk
rlYnX|||<q |�|�}|r d||�d�<q |S)z�Parse a config.h-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    Nz"#define ([A-Z][A-Za-z0-9_]+) (.*)
z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/
rrr)�re�compile�readline�match�group�int�
ValueError)�fp�gZ	define_rxZundef_rx�line�m�n�vrrr
�parse_config_hs&




rUz"([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)z\$\(([A-Za-z][A-Za-z0-9_]*)\)z\${([A-Za-z][A-Za-z0-9_]*)}c	Cs�ddlm}||ddddd�}|dkr*i}i}i}|��}|dkrDq�t�|�}|r2|�dd�\}}	|	��}	|	�dd	�}
d
|
kr�|	||<q2zt|	�}	Wn$t	k
r�|	�dd
�||<Yq2X|	||<q2d}|�rtt
|�D�]�}||}
t�|
�p�t
�|
�}|�rj|�d�}d}||k�r$t||�}n�||k�r4d
}nx|tjk�rLtj|}n`||k�r�|�d��rz|dd�|k�rzd	}n$d||k�r�d
}nt|d|�}nd	||<}|�rp|
|��d�}|
d|���||}
d
|k�r�|
||<nzzt|
�}
Wn"t	k
�r|
��||<Yn
X|
||<||=|�d��rp|dd�|k�rp|dd�}||k�rp|
||<q�||=q�q�|��|��D]"\}}	t|	t��r�|	��||<�q�|�|�|S)z�Parse a Makefile-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    r)�TextFiler�surrogateescape)Zstrip_commentsZskip_blanksZ
join_lines�errorsNrz$$r�$)r3r4r6TFZPY_�)Zdistutils.text_filerVrJ�_variable_rxrKrL�strip�replacerMrN�list�_findvar1_rx�search�_findvar2_rx�strrr>r�end�start�close�items�
isinstance�update)rrPrVrOZdoneZnotdonerQrRrSrTZtmpvZrenamed_variablesr#�value�found�itemZafter�krrr
�parse_makefile/s�








�



rmcCsVt�|�pt�|�}|rR|��\}}|d|�|�|�d��||d�}qqRq|S)a�Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
    'string' according to 'vars' (a dictionary mapping variable names to
    values).  Variables not present in 'vars' are silently expanded to the
    empty string.  The variable values in 'vars' should not contain further
    variable expansions; if 'vars' is the output of 'parse_makefile()',
    you're fine.  Returns a variable-expanded version of 's'.
    rrN)r_r`ra�span�getrL)�s�varsrRZbegrcrrr
�expand_makefile_vars�s*rrc
CsVtj�ddjtjtjttjdd�d��}t	|t
�t�dgd�}|j}ia
t
�|�dS)	z7Initialize the module as appropriate for POSIX systems.Z_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}rCr)Zabir9Z	multiarch�build_time_varsrN)rr>rorDr�abiflagsr9�getattrrF�
__import__�globals�localsrsr<rh)r#Z_temprsrrr
�_init_posix�s��rycCs~i}tddd�|d<tddd�|d<tdd�|d<t��d|d<d	|d
<t��dd�|d
<tj�tj�	t
j��|d<|adS)z+Initialize the module as appropriate for NTrrrBZLIBDESTZ
BINLIBDESTr@Z	INCLUDEPY�
EXT_SUFFIXz.exeZEXE�.rZVERSIONZBINDIRN)
r0r+�_imp�extension_suffixesrr]rr�dirname�abspathr�
executabler<)rPrrr
�_init_nt�sr�cGs\tdk�r*t��dtj�}|r(|�niattd<ttd<t�d�}|dk	rV|td<t�dt�}tjdkr�tr�tj	�
t��}tj	�||�}ntj	�
t��}tj	�
tj	�|��td<t�rtjdk�rt}tj	�td��s|t��k�rtj	�|td�}tj	�|�td<tjd	k�r*d
dl}|�t�|�rTg}|D]}|�t�|���q8|StSdS)a�With no arguments, return a dictionary of all configuration
    variables relevant for the current platform.  Generally this includes
    everything needed to build extensions and install both pure modules and
    extensions.  On Unix, this means every variable defined in Python's
    installed Makefile; on Windows it's a much smaller set.

    With arguments, return a list of values that result from looking up
    each argument in the configuration variable dictionary.
    NZ_init_r*�exec_prefixrz�SOrrr1r)r<rwrorr#rr.rr$rr~rGr	rr&�isabs�getcwdrr9r:Zcustomize_config_vars�append)�args�funcr�r�baser:Zvalsr#rrr
r=�sB



�
r=cCs*|dkrddl}|�dtd�t��|�S)z�Return the value of a single variable using the dictionary
    returned by 'get_config_vars()'.  Equivalent to
    get_config_vars().get(name)
    r�rNz SO is deprecated, use EXT_SUFFIXr)�warnings�warn�DeprecationWarningr=ro)r#r�rrr
r%!sr%)rN)rrN)N)N)6�__doc__r|rrHrrXr�utilrrrr&r*rr�r.�base_prefixr"�base_exec_prefixr!r>rrr�r~r�rrurr#rrr$r'rt�AttributeErrorrr+r0r;rArGrUrIr[r_rarmrrr<ryr�r=r%rrrr
�<module>s\



(
+I





jJPK42�\�v��
�
dep_util.cpython-38.pycnu�[���U

e5d�
�@s6dZddlZddlmZdd�Zdd�Zdd	d
�ZdS)z�distutils.dep_util

Utility functions for simple, timestamp-based dependency of files
and groups of files; also, function based entirely on such
timestamp dependency analysis.�N)�DistutilsFileErrorcCs`tj�|�s tdtj�|���tj�|�s0dSddlm}t�|�|}t�|�|}||kS)aReturn true if 'source' exists and is more recently modified than
    'target', or if 'source' exists and 'target' doesn't.  Return false if
    both exist and 'target' is the same age or younger than 'source'.
    Raise DistutilsFileError if 'source' does not exist.
    zfile '%s' does not exist�r��ST_MTIME)�os�path�existsr�abspath�statr)�source�targetrZmtime1Zmtime2�r
�*/usr/lib64/python3.8/distutils/dep_util.py�newers
�rcCsht|�t|�krtd��g}g}tt|��D]2}t||||�r,|�||�|�||�q,||fS)z�Walk two filename lists in parallel, testing if each source is newer
    than its corresponding target.  Return a pair of lists (sources,
    targets) where source is newer than target, according to the semantics
    of 'newer()'.
    z+'sources' and 'targets' must be same length)�len�
ValueError�ranger�append)�sourcesZtargetsZ	n_sourcesZ	n_targets�ir
r
r�newer_pairwise sr�errorcCs�tj�|�sdSddlm}t�|�|}|D]P}tj�|�sb|dkrHn|dkrTq.n|dkrbdSt�|�|}||kr.dSq.dS)a�Return true if 'target' is out-of-date with respect to any file
    listed in 'sources'.  In other words, if 'target' exists and is newer
    than every file in 'sources', return false; otherwise return true.
    'missing' controls what we do when a source file is missing; the
    default ("error") is to blow up with an OSError from inside 'stat()';
    if it is "ignore", we silently drop any missing source files; if it is
    "newer", any missing source files make us assume that 'target' is
    out-of-date (this is handy in "dry-run" mode: it'll make you pretend to
    carry out commands that wouldn't work because inputs are missing, but
    that doesn't matter because you're not actually going to run the
    commands).
    rrrr�ignorerN)rrrr
r)rrZmissingrZtarget_mtimer�source_mtimer
r
r�newer_group6s r)r)�__doc__rZdistutils.errorsrrrrr
r
r
r�<module>s
PK42�\�T� � text_file.cpython-38.pycnu�[���U

e5d�0�@s&dZddlZddlZGdd�d�ZdS)z�text_file

provides the TextFile class, which gives an interface to text files
that (optionally) takes care of stripping comments, ignoring blank
lines, and joining lines with backslashes.�Nc@steZdZdZdddddddd�Zddd�Zd	d
�Zdd�Zdd
d�Zddd�Z	ddd�Z
dd�Zdd�Zdd�Z
dS)�TextFilea�Provides a file-like object that takes care of all the things you
       commonly want to do when processing a text file that has some
       line-by-line syntax: strip comments (as long as "#" is your
       comment character), skip blank lines, join adjacent lines by
       escaping the newline (ie. backslash at end of line), strip
       leading and/or trailing whitespace.  All of these are optional
       and independently controllable.

       Provides a 'warn()' method so you can generate warning messages that
       report physical line number, even if the logical line in question
       spans multiple physical lines.  Also provides 'unreadline()' for
       implementing line-at-a-time lookahead.

       Constructor is called as:

           TextFile (filename=None, file=None, **options)

       It bombs (RuntimeError) if both 'filename' and 'file' are None;
       'filename' should be a string, and 'file' a file object (or
       something that provides 'readline()' and 'close()' methods).  It is
       recommended that you supply at least 'filename', so that TextFile
       can include it in warning messages.  If 'file' is not supplied,
       TextFile creates its own using 'io.open()'.

       The options are all boolean, and affect the value returned by
       'readline()':
         strip_comments [default: true]
           strip from "#" to end-of-line, as well as any whitespace
           leading up to the "#" -- unless it is escaped by a backslash
         lstrip_ws [default: false]
           strip leading whitespace from each line before returning it
         rstrip_ws [default: true]
           strip trailing whitespace (including line terminator!) from
           each line before returning it
         skip_blanks [default: true}
           skip lines that are empty *after* stripping comments and
           whitespace.  (If both lstrip_ws and rstrip_ws are false,
           then some lines may consist of solely whitespace: these will
           *not* be skipped, even if 'skip_blanks' is true.)
         join_lines [default: false]
           if a backslash is the last non-newline character on a line
           after stripping comments and whitespace, join the following line
           to it to form one "logical line"; if N consecutive lines end
           with a backslash, then N+1 physical lines will be joined to
           form one logical line.
         collapse_join [default: false]
           strip leading whitespace from lines that are joined to their
           predecessor; only matters if (join_lines and not lstrip_ws)
         errors [default: 'strict']
           error handler used to decode the file content

       Note that since 'rstrip_ws' can strip the trailing newline, the
       semantics of 'readline()' must differ from those of the builtin file
       object's 'readline()' method!  In particular, 'readline()' returns
       None for end-of-file: an empty string might just be a blank line (or
       an all-whitespace line), if 'rstrip_ws' is true but 'skip_blanks' is
       not.�r�strict)�strip_comments�skip_blanks�	lstrip_ws�	rstrip_ws�
join_lines�
collapse_join�errorsNcKs�|dkr|dkrtd��|j��D]0}||kr@t||||�q"t|||j|�q"|��D]}||jkr\td|��q\|dkr�|�|�n||_||_d|_g|_	dS)z�Construct a new TextFile object.  At least one of 'filename'
           (a string) and 'file' (a file-like object) must be supplied.
           They keyword argument options are described above and affect
           the values returned by 'readline()'.Nz7you must supply either or both of 'filename' and 'file'zinvalid TextFile option '%s'r)
�RuntimeError�default_options�keys�setattr�KeyError�open�filename�file�current_line�linebuf)�selfrrZoptions�opt�r�+/usr/lib64/python3.8/distutils/text_file.py�__init__Ns
zTextFile.__init__cCs&||_tj|jd|jd�|_d|_dS)zyOpen a new file named 'filename'.  This overrides both the
           'filename' and 'file' arguments to the constructor.�r)rrN)r�iorrrr)rrrrrrosz
TextFile.opencCs$|j}d|_d|_d|_|��dS)ziClose the current file and forget everything we know about it
           (filename, current line number).N)rrr�close)rrrrrrvs
zTextFile.closecCsjg}|dkr|j}|�|jd�t|ttf�rD|�dt|��n|�d|�|�t|��d�|�S)Nz, z
lines %d-%d: z	line %d: �)r�appendr�
isinstance�list�tuple�str�join)r�msg�lineZoutmsgrrr�	gen_errorszTextFile.gen_errorcCstd|�||���dS)Nzerror: )�
ValueErrorr'�rr%r&rrr�error�szTextFile.errorcCs tj�d|�||�d�dS)a�Print (to stderr) a warning message tied to the current logical
           line in the current file.  If the current logical line in the
           file spans multiple physical lines, the warning refers to the
           whole range, eg. "lines 3-5".  If 'line' supplied, it overrides
           the current line number; it may be a list or tuple to indicate a
           range of physical lines, or an integer for a single physical
           line.z	warning: �
N)�sys�stderr�writer'r)rrr�warn�sz
TextFile.warncCs�|jr|jd}|jd=|Sd}|j��}|dkr6d}|jr�|r�|�d�}|dkrTnX|dksl||ddkr�|ddkr|dp~d}|d|�|}|��dkr�q n|�d	d�}|j�r|�r|dkr�|�d
�|S|j	r�|�
�}||}t|jt
��r
|jdd|jd<n|j|jdg|_n:|dk�r,dSt|jt
��rL|jdd|_n|jd|_|j�rr|j�rr|��}n"|j�r�|�
�}n|j�r�|��}|dk�s�|dk�r�|j�r�q |j�r�|ddk�r�|dd�}q |dd�dk�r�|dd�d}q |S)
aURead and return a single logical line from the current file (or
           from an internal buffer if lines have previously been "unread"
           with 'unreadline()').  If the 'join_lines' option is true, this
           may involve reading multiple physical lines concatenated into a
           single string.  Updates the current line number, so calling
           'warn()' after 'readline()' emits a warning about the physical
           line(s) just read.  Returns None on end-of-file, since the empty
           string can occur if 'rstrip_ws' is true but 'strip_blanks' is
           not.���rN�#rr�\r+z\#z2continuation line immediately precedes end-of-file���z\
)rr�readliner�find�strip�replacer	r/r
�lstripr rr!rr�rstripr)rr&Zbuildup_line�posZeolrrrr4�sf




	
�


zTextFile.readlinecCs(g}|��}|dkr|S|�|�qdS)zWRead and return the list of all logical lines remaining in the
           current file.N)r4r)r�linesr&rrr�	readliness
zTextFile.readlinescCs|j�|�dS)z�Push 'line' (a string) onto an internal buffer that will be
           checked by future 'readline()' calls.  Handy for implementing
           a parser with line-at-a-time lookahead.N)rr)rr&rrr�
unreadlineszTextFile.unreadline)NN)N)N)N)�__name__�
__module__�__qualname__�__doc__r
rrrr'r*r/r4r<r=rrrrr
s$:�	
!	



x
r)rAr,rrrrrr�<module>sPK42�\��ES��debug.cpython-38.opt-1.pycnu�[���U

e5d��@sddlZej�d�ZdS)�NZDISTUTILS_DEBUG)�os�environ�get�DEBUG�rr�'/usr/lib64/python3.8/distutils/debug.py�<module>sPK42�\���~�!�!$cygwinccompiler.cpython-38.opt-1.pycnu�[���U

e5d^@�@s�dZddlZddlZddlZddlmZmZmZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZmZmZmZddlmZdd	lmZdd
lmZdd�ZGd
d�de
�ZGdd�de�ZdZdZdZ dd�Z!e�"d�Z#dd�Z$dd�Z%dd�Z&dS)adistutils.cygwinccompiler

Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
handles the Cygwin port of the GNU C compiler to Windows.  It also contains
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
cygwin in no-cygwin mode).
�N)�Popen�PIPE�check_output)�gen_preprocess_options�gen_lib_options)�
UnixCCompiler)�
write_file)�DistutilsExecError�CCompilerError�CompileError�UnknownFileError)�log)�LooseVersion)�find_executablecCs�tj�d�}|dkr|tj|d|d�}|dkr8dgS|dkrFdgS|d	krTd
gS|dkrbdgS|d
krpdgStd|��dS)zaInclude the appropriate MSVC runtime library if Python was built
    with MSVC 7.0 or later.
    zMSC v.�����
Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100zUnknown MS Compiler version %s N)�sys�version�find�
ValueError)Zmsc_posZmsc_ver�r�1/usr/lib64/python3.8/distutils/cygwinccompiler.py�	get_msvcr?src
@sReZdZdZdZdZdZdZdZdZ	dZ
dd
d�Zdd
�Zddd�Z
ddd�ZdS)�CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows.
    �cygwinz.o�.az.dllzlib%s%sz%s%sz.exercCs�t�||||�t�\}}|�d||f�|tk	rB|�d|�t�\|_|_|_	|�|j
d|j|j|j	f�|jdkr�d|_nd|_|jdkr�d}nd	}|jd
ddd
d|j|fd�|jdkr�dg|_
|�d�nt�|_
dS)Nz%Python's GCC status: %s (details: %s)z�Python's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.z: gcc %s, ld %s, dllwrap %s
z2.10.90�gcc�dllwrap�2.13�-shared�
-mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallzgcc -mcygwinz%s -mcygwin %s�Zcompiler�compiler_soZcompiler_cxxZ
linker_exeZ	linker_so�2.91.57Zmsvcrtz,Consider upgrading to a newer version of gcc)r�__init__�check_config_hZdebug_print�CONFIG_H_OK�warn�get_versions�gcc_version�
ld_versionZdllwrap_version�
compiler_type�
linker_dll�set_executables�
dll_librariesr)�self�verbose�dry_run�forceZstatusZdetails�
shared_optionrrrr%dsN
����
��


��
�zCygwinCCompiler.__init__c
Cs�|dks|dkrVz|�dd|d|g�Wq�tk
rR}zt|��W5d}~XYq�XnNz"|�|j||d|g|�Wn*tk
r�}zt|��W5d}~XYnXdS)z:Compiles the source by spawning GCC and windres if needed.�.rc�.resZwindresz-iz-oN)Zspawnr	rr#)r0�obj�src�extZcc_args�extra_postargsZpp_opts�msgrrr�_compile�s�
zCygwinCCompiler._compileNcCsPt�|
p
g�}
t�|pg�}t�|p&g�}|�|j�|dk	�r||jksV|jdk�rtj�|d�}tj�tj�	|��\}}tj�
||d�}tj�
|d|d�}dtj�	|�dg}|D]}|�|�q�|�t
||fd	|�|jd
k�r|
�d|g�|
�d|g�n
|�|�|	�s(|
�d
�t�||||||||d|	|
|||
�dS)zLink the objects.Nrrz.def�librz
LIBRARY %sZEXPORTSz
writing %srz--output-libz--defz-s)�copy�extendr/Z
EXECUTABLEr-�os�path�dirname�splitext�basename�join�appendZexecuterr�link)r0Ztarget_descZobjectsZoutput_filename�
output_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbols�debugZ
extra_preargsr:Z
build_tempZtarget_langZtemp_dirZdll_nameZ
dll_extensionZdef_fileZlib_file�contentsZsymrrrrG�sR
��

���

�zCygwinCCompiler.link�cCs�|dkrd}g}|D]�}tj�tj�|��\}}||jddgkrRtd||f��|rbtj�|�}|dkr�|�tj�||||j	��q|�tj�|||j	��q|S)z#Adds supports for rc and res files.NrKr5r6z"unknown file type '%s' (from '%s'))r6r5)
r@rArC�normcaseZsrc_extensionsrrDrFrE�
obj_extension)r0Zsource_filenamesZ	strip_dirrHZ	obj_namesZsrc_name�baser9rrr�object_filenames�s&���z CygwinCCompiler.object_filenames)rrr)
NNNNNrNNNN)rrK)�__name__�
__module__�__qualname__�__doc__r,rMZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr%r<rGrOrrrrrYs,
;�
Nrc@seZdZdZdZddd�ZdS)�Mingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows.
    Zmingw32rc	Csxt�||||�|jdkr d}nd}|jdkr4d}nd}t�rFtd��|jdd	d
dd|j||fd
�g|_t	�|_dS)Nrr r!r$z--entry _DllMain@12rKz1Cygwin gcc cannot be used with --compiler=mingw32zgcc -O -Wallzgcc -mdll -O -Wallzg++ -O -Wallrz%s %s %sr")
rr%r+r*�is_cygwingccr
r.r-r/r)r0r1r2r3r4Zentry_pointrrrr%s.

����zMingw32CCompiler.__init__N)rrr)rPrQrRrSr,r%rrrrrTsrT�okznot okZ	uncertainc
Cs�ddlm}dtjkrtdfS|��}zLt|�}z4d|��krPtd|fW�WSt	d|fW�WSW5|��XWn8t
k
r�}ztd||jffWY�Sd	}~XYnXd	S)
awCheck if the current Python installation appears amenable to building
    extensions with GCC.

    Returns a tuple (status, details), where 'status' is one of the following
    constants:

    - CONFIG_H_OK: all is well, go ahead and compile
    - CONFIG_H_NOTOK: doesn't look good
    - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h

    'details' is a human-readable string explaining the situation.

    Note there are two ways to conclude "OK": either 'sys.version' contains
    the string "GCC" (implying that this Python was built with GCC), or the
    installed "pyconfig.h" contains the string "__GNUC__".
    r)�	sysconfigZGCCzsys.version mentions 'GCC'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '%s': %sN)
�	distutilsrWrrr'Zget_config_h_filename�open�close�read�CONFIG_H_NOTOK�OSError�CONFIG_H_UNCERTAIN�strerror)rW�fnZconfig_h�excrrrr&Hs
�r&s(\d+\.\d+(\.\d+)*)cCsl|��d}t|�dkrdSt|dtd�j}z|��}W5|��Xt�|�}|dkrZdSt	|�
d����S)z�Find the version of an executable by running `cmd` in the shell.

    If the command is not found, or the output does not match
    `RE_VERSION`, returns None.
    rNT)�shell�stdout�)�splitrrrrcrZr[�
RE_VERSION�searchr�group�decode)�cmd�
executable�out�
out_string�resultrrr�_find_exe_versionus

rocCsdddg}tdd�|D��S)zg Try to find out the versions of gcc, ld and dllwrap.

    If not possible it returns None for it.
    zgcc -dumpversionzld -vzdllwrap --versioncSsg|]}t|��qSr)ro)�.0rjrrr�
<listcomp>�sz get_versions.<locals>.<listcomp>)�tuple)Zcommandsrrrr)�s
r)cCstddg�}|���d�S)z>Try to determine if the gcc that would be used is from cygwin.rz-dumpmachinescygwin)r�strip�endswith)rmrrrrU�srU)'rSr@rr>�
subprocessrrr�reZdistutils.ccompilerrrZdistutils.unixccompilerrZdistutils.file_utilrZdistutils.errorsr	r
rrrXr
Zdistutils.versionrZdistutils.spawnrrrrTr'r\r^r&�compilerfror)rUrrrr�<module>s0/;1+
PK42�\�YyF�&�&filelist.cpython-38.pycnu�[���U

e5d 2�@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZGdd�d�Zdd	�Z
ejfd
d�Zdd
�Zddd�ZdS)zsdistutils.filelist

Provides the FileList class, used for poking about the filesystem
and building lists of files.
�N��convert_path)�DistutilsTemplateError�DistutilsInternalError)�logc@s|eZdZdZddd�Zdd�Zejfdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zddd�Zddd�ZdS) �FileLista�A list of files built by on exploring the filesystem and filtered by
    applying various patterns to what we find there.

    Instance attributes:
      dir
        directory from which files will be taken -- only used if
        'allfiles' not supplied to constructor
      files
        list of filenames currently being built/filtered/manipulated
      allfiles
        complete list of files under consideration (ie. without any
        filtering applied)
    NcCsd|_g|_dS�N)�allfiles�files)�self�warn�debug_print�r�*/usr/lib64/python3.8/distutils/filelist.py�__init__szFileList.__init__cCs
||_dSr)r	)rr	rrr�set_allfiles#szFileList.set_allfilescCst|�|_dSr)�findallr	)r�dirrrrr&szFileList.findallcCsddlm}|rt|�dS)z~Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        r)�DEBUGN)Zdistutils.debugr�print)r�msgrrrrr
)szFileList.debug_printcCs|j�|�dSr)r
�append)r�itemrrrr3szFileList.appendcCs|j�|�dSr)r
�extend)r�itemsrrrr6szFileList.extendcCs<tttjj|j��}g|_|D]}|j�tjj|��qdSr)�sorted�map�os�path�splitr
r�join)rZsortable_filesZ
sort_tuplerrr�sort9sz
FileList.sortcCs@tt|j�ddd�D]$}|j||j|dkr|j|=qdS)N�r���)�range�lenr
)r�irrr�remove_duplicatesCszFileList.remove_duplicatescCs�|��}|d}d}}}|dkrTt|�dkr<td|��dd�|dd�D�}n~|dkr�t|�d	krttd
|��t|d�}dd�|dd�D�}n:|dkr�t|�dkr�td
|��t|d�}ntd|��||||fS)Nr)�include�exclude�global-include�global-exclude�z&'%s' expects <pattern1> <pattern2> ...cSsg|]}t|��qSrr��.0�wrrr�
<listcomp>Wsz1FileList._parse_template_line.<locals>.<listcomp>r")�recursive-include�recursive-exclude�z,'%s' expects <dir> <pattern1> <pattern2> ...cSsg|]}t|��qSrrr-rrrr0]s)�graft�prunez#'%s' expects a single <dir_pattern>zunknown action '%s')rr%rr)r�lineZwords�action�patternsr�dir_patternrrr�_parse_template_lineLs0���zFileList._parse_template_linecCs@|�|�\}}}}|dkrV|�dd�|��|D]}|j|dd�s2t�d|�q2�n�|dkr�|�dd�|��|D]}|j|dd�svt�d	|�qv�n�|d
kr�|�dd�|��|D]}|j|dd�s�t�d
|�q��n^|dk�r(|�dd�|��|D]"}|j|dd��st�d|��q�n|dk�rv|�d|d�|�f�|D]$}|j||d��sNt�d||��qNn�|dk�r�|�d|d�|�f�|D]$}|j||d��s�t�d||��q�nx|dk�r�|�d|�|jd|d��s<t�d|�nB|dk�r0|�d|�|jd|d��s<t�d|�ntd|��dS)Nr(zinclude � r")�anchorz%warning: no files found matching '%s'r)zexclude z9warning: no previously-included files found matching '%s'r*zglobal-include rz>warning: no files found matching '%s' anywhere in distributionr+zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionr1zrecursive-include %s %s)�prefixz:warning: no files found matching '%s' under directory '%s'r2zrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'r4zgraft z+warning: no directories found matching '%s'r5zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r:r
r �include_patternrr�exclude_patternr)rr6r7r8rr9�patternrrr�process_template_linehs��
�
�

�
��

��

�
��zFileList.process_template_liner"rcCsld}t||||�}|�d|j�|jdkr4|��|jD],}|�|�r:|�d|�|j�|�d}q:|S)a�Select strings (presumably filenames) from 'self.files' that
        match 'pattern', a Unix-style wildcard (glob) pattern.  Patterns
        are not quite the same as implemented by the 'fnmatch' module: '*'
        and '?'  match non-special characters, where "special" is platform-
        dependent: slash on Unix; colon, slash, and backslash on
        DOS/Windows; and colon on Mac OS.

        If 'anchor' is true (the default), then the pattern match is more
        stringent: "*.py" will match "foo.py" but not "foo/bar.py".  If
        'anchor' is false, both of these will match.

        If 'prefix' is supplied, then only filenames starting with 'prefix'
        (itself a pattern) and ending with 'pattern', with anything in between
        them, will match.  'anchor' is ignored in this case.

        If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and
        'pattern' is assumed to be either a string containing a regex or a
        regex object -- no translation is done, the regex is just compiled
        and used as-is.

        Selected strings will be added to self.files.

        Return True if files are found, False otherwise.
        Fz%include_pattern: applying regex r'%s'Nz adding T)�translate_patternr
r@r	r�searchr
r)rr@r<r=�is_regex�files_found�
pattern_re�namerrrr>�s�


zFileList.include_patterncCsrd}t||||�}|�d|j�tt|j�ddd�D]4}|�|j|�r8|�d|j|�|j|=d}q8|S)aRemove strings (presumably filenames) from 'files' that match
        'pattern'.  Other parameters are the same as for
        'include_pattern()', above.
        The list 'self.files' is modified in place.
        Return True if files are found, False otherwise.
        Fz%exclude_pattern: applying regex r'%s'r"r#z
 removing T)rBr
r@r$r%r
rC)rr@r<r=rDrErFr&rrrr?�s�zFileList.exclude_pattern)NN)r"Nr)r"Nr)�__name__�
__module__�__qualname__�__doc__rrr�curdirrr
rrr!r'r:rAr>r?rrrrrs 


	L
,�rcCs&dd�tj|dd�D�}ttjj|�S)z%
    Find all files under 'path'
    css,|]$\}}}|D]}tj�||�VqqdSr)rrr )r.�base�dirsr
�filerrr�	<genexpr>�s�z#_find_all_simple.<locals>.<genexpr>T)�followlinks)r�walk�filterr�isfile)rZresultsrrr�_find_all_simple�s�rUcCs6t|�}|tjkr.tjtjj|d�}t||�}t|�S)z�
    Find all files under 'dir' and return the list of full filenames.
    Unless dir is '.', return full filenames with dir prepended.
    )�start)	rUrrL�	functools�partialr�relpathr�list)rr
Zmake_relrrrrs


rcCs8t�|�}tj}tjdkrd}d|}t�d||�}|S)z�Translate a shell-like glob pattern to a regular expression; return
    a string containing the regex.  Differs from 'fnmatch.translate()' in
    that '*' does not match "special characters" (which are
    platform-specific).
    �\z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)�fnmatch�	translater�sep�re�sub)r@rFr^Zescapedrrr�
glob_to_res

rar"c
Cs
|rt|t�rt�|�S|Std��d�\}}}|rVt|�}|�|�rP|�|�sZt�nd}|dk	r�t|�}|�|�r~|�|�s�t�|t	|�t	|�t	|��}t
j}	t
jdkr�d}	|t	|�t	|�t	|��}d|||	||f}n|�rd||t	|�d�f}t�|�S)aTranslate a shell-like wildcard pattern to a compiled regular
    expression.  Return the compiled regex.  If 'is_regex' true,
    then 'pattern' is directly compiled to a regex (if it's a string)
    or just returned as-is (assumes it's a regex object).
    �_�Nr[z\\z%s\A%s%s.*%s%sz%s\A%s)�
isinstance�strr_�compilera�	partition�
startswith�endswith�AssertionErrorr%rr^)
r@r<r=rDrVrb�endrFZ	prefix_rer^rrrrB%s*


rB)r"Nr)rKrr_r\rWZdistutils.utilrZdistutils.errorsrrZ	distutilsrrrUrLrrarBrrrr�<module>siPK42�\���^3^3!msvccompiler.cpython-38.opt-2.pycnu�[���U

e5d\�@s�ddlZddlZddlmZmZmZmZmZddlm	Z	m
Z
mZddlm
Z
dZz,ddlZdZeZejZejZejZejZWnhek
r�z4ddlZddlZdZeZejZejZejZejZWnek
r�e
�d�YnXYnXer�ejejejej fZ!dd	�Z"d
d�Z#dd
�Z$Gdd�d�Z%dd�Z&dd�Z'dd�Z(Gdd�de	�Z)e&�dk�r~e
�*d�e)Z+ddl,m)Z)ddl,m%Z%dS)�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�logFTz�Warning: Can't read registry to find the necessary compiler setting
Make sure that Python modules winreg, win32api or win32con are installed.cCsnzt||�}Wntk
r$YdSXg}d}zt||�}Wntk
rTYqjYnX|�|�|d7}q.|S�Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)�base�key�handle�L�i�k�r�./usr/lib64/python3.8/distutils/msvccompiler.py�	read_keys7s


rcCs�zt||�}Wntk
r$YdSXi}d}zt||�\}}}Wntk
rZYq~YnX|��}t|�|t|�<|d7}q.|Sr)r
r�RegEnumValue�lower�convert_mbcs)rrr�dr�name�value�typerrr�read_valuesHs

r!cCs:t|dd�}|dk	r6z|d�}Wntk
r4YnX|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr]src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_|�|�dS�N)�macros�load_macros)�self�versionrrr�__init__gszMacroExpander.__init__cCs2tD](}t||�}|r|||jd|<q.qdS)Nz$(%s))�HKEYSr!r))r+Zmacro�pathrrrrrr�	set_macroks

zMacroExpander.set_macroc

Cs�d|}|�d|dd�|�d|dd�d}|�d|d	�z*|d
krX|�d|d�n|�d|d
�Wn*tk
r�}ztd��W5d}~XYnXd}tD]V}zt||�}Wntk
r�Yq�YnXt|d�}t|d||f�}	|	d|jd<q�dS)Nz%Software\Microsoft\VisualStudio\%0.1fZVCInstallDirz	\Setup\VCZ
productdirZVSInstallDirz	\Setup\VSz Software\Microsoft\.NETFrameworkZFrameworkDirZinstallrootg@ZFrameworkSDKDirzsdkinstallrootv1.1ZsdkinstallrootaPython was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.z.Software\Microsoft\NET Framework Setup\Productrz%s\%sr,z$(FrameworkVersion))	r0�KeyErrorrr.r
rrr!r))
r+r,ZvsbaseZnet�exc�pr�hrrrrrr*rs,�

zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q
|Sr()r)�items�replace)r+r&r�vrrr�sub�szMacroExpander.subN)�__name__�
__module__�__qualname__r-r0r*r8rrrrr'fsr'cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|dd	��d
}|dkr�d}|dkr�||SdS)NzMSC v.����� r����
��g$@r)�sysr,�find�len�split�int)�prefixrr&�restZmajorVersionZminorVersionrrr�get_build_version�srJcCs@d}tj�|�}|dkrdStj�d|�}tj|t|�|�S)Nz bit (r<�Intel�))rCr,rDrE)rHr�jrrr�get_build_architecture�srNcCs0g}|D]"}tj�|�}||kr|�|�q|Sr()�osr/�normpathr)�pathsZ
reduced_pathsr3Znprrr�normalize_and_reduce_paths�srRc
@s�eZdZdZiZdgZdddgZdgZdgZeeeeZ	dZ
d	Zd
ZdZ
dZZd
Zd,dd�Zdd�Zd-dd�Zd.dd�Zd/dd�Zd0dd�Zdd�Zdd �Zd!d"�Zd1d#d$�Zd%d&�Zd2d(d)�Zd*d+�ZdS)3�MSVCCompilerZmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCsvt�||||�t�|_t�|_|jdkr\|jdkrHd|_t|j�|_nd|_d|j|_	nd|jd|_	d|_
dS)	NrK�zSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr=F)rr-rJ�_MSVCCompiler__versionrN�_MSVCCompiler__arch�_MSVCCompiler__rootr'�_MSVCCompiler__macros�_MSVCCompiler__product�initialized)r+�verboseZdry_runZforcerrrr-�s

zMSVCCompiler.__init__cCs�g|_dtjkrDdtjkrD|�d�rDd|_d|_d|_d|_d|_nx|�	d�|_t
|j�d	krltd
|j��|�d�|_|�d�|_|�d�|_|�d�|_|�d�|_|�
d�|�
d�z&tjd�d
�D]}|j�|�q�Wntk
r�YnXt|j�|_d
�|j�tjd<d|_|jdk�rPddddddg|_dddddddg|_n&ddddddg|_dddddddg|_dddg|_|jdk�r�ddddg|_ndddddg|_dg|_d |_dS)!NZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer/rzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�libZinclude�;rKz/nologoz/Oxz/MDz/W3z/GXz/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NOrUz/INCREMENTAL:noz/DEBUGz	/pdb:NoneT)�_MSVCCompiler__pathsrO�environ�find_exe�cc�linkerr]�rc�mc�get_msvc_pathsrErrZ�set_path_env_varrFrr1rR�joinZpreprocess_optionsrW�compile_options�compile_options_debug�ldflags_sharedrV�ldflags_shared_debugZldflags_staticr[)r+r3rrr�
initialize�sr�


�
�
�
���zMSVCCompiler.initialize�cCs�|dkrd}g}|D]�}tj�|�\}}tj�|�d}|tj�|�d�}||jkrbtd|��|rrtj�|�}||jkr�|�	tj�
|||j��q||jkr�|�	tj�
|||j��q|�	tj�
|||j
��q|S)NrnrzDon't know how to compile %s)rOr/�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsrrh�
res_extension�_mc_extensions�
obj_extension)r+Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames8s.

�
��zMSVCCompiler.object_filenamesNc	Csp|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�|
D�]}z||\}}Wntk
r�YqdYnX|r�tj	�
|�}||jkr�d|}�nT||jkr�d|}�n>||j
k�r<|}d|}z"|�|jg||g|g�Wqdtk
�r6}zt|��W5d}~XYqdXqdn�||jk�r�tj	�|�}tj	�|�}zl|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wqdtk
�r�}zt|��W5d}~XYqdXqdntd||f��d	|}z&|�|jg|
|||g|�Wqdtk
�rh}zt|��W5d}~XYqdXqd|
S)
Nz/cz/Tcz/Tpz/foz-hz-rrTz"Don't know how to compile %s to %sz/Fo)r[rmZ_setup_compiler�extendrjrir1rOr/�abspath�
_c_extensions�_cpp_extensionsrt�spawnrdrrrv�dirnamererorsrhrb)r+Zsourcesrxr)Zinclude_dirs�debug�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcryZ	input_optZ
output_opt�msgZh_dirZrc_dirr�_Zrc_filerrr�compileWs�
�




��


��
��
���
zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz|�|jg|�Wq�tk
r�}zt|��W5d}~XYq�Xnt	�
d|�dS)N)rx�/OUT:�skipping %s (up-to-date))r[rm�_fix_object_args�library_filename�
_need_linkrr]rrr
r�)	r+r�Zoutput_libnamerxr��target_lang�output_filenameZlib_argsr�rrr�create_static_lib�s�zMSVCCompiler.create_static_libc
Cs�|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��r�|tjkr�|	r�|j
dd�}q�|jdd�}n|	r�|j
}n|j}g}|p�gD]}|�d|�q�||||d|g}|dk	�rHtj�tj�|��\}}tj�	tj�|d�|�|��}|�d|�|
�rZ|
|dd�<|�rj|�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:r�rz/IMPLIB:r�)r[rmr�Z
_fix_lib_args�warn�strr	rOr/rhr�rZ
EXECUTABLErlrkrrorsr�r�r{Zmkpathrrcrrr
r�)r+Ztarget_descr�r�rxZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr�r�r�Z
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsymZld_argsZdll_nameZdll_extZimplib_filer�rrr�link�sj�
��

��

��
zMSVCCompiler.linkcCsd|S)Nz	/LIBPATH:r�r+�dirrrr�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)rr�rrr�runtime_library_dir_options�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�Sr()r�)r+r]rrr�library_optionszMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rOr/rhr��exists)r+�dirsr]r�Z	try_namesr�rZlibfilerrr�find_library_file#szMSVCCompiler.find_library_filecCsz|jD].}tj�tj�|�|�}tj�|�r|Sqtjd�d�D].}tj�tj�|�|�}tj�|�rF|SqF|S)N�Pathr^)r_rOr/rhr|�isfiler`rF)r+Zexer3�fnrrrra5s	


zMSVCCompiler.find_exe�x86cCs�tsgS|d}|jdkr,d|j|jf}nd|j|f}tD]H}t||�}|r>|jdkrt|j�||��d�S||�d�Sq>|jdkr�tD]&}t|d|j�dk	r�|�d�q�q�gS)	Nz dirsrUz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr^r=z%s\6.0z�It seems you have Visual Studio 6 installed, but the expected registry settings are not present.
You must at least run the Visual Studio GUI once so that these entries are created.)	�
_can_read_regrVrXr.r!rYr8rFr�)r+r/�platformrrrrrrrfKs,

��



zMSVCCompiler.get_msvc_pathscCs6|dkr|�d�}n
|�|�}|r2d�|�tj|<dS)Nr]Zlibraryr^)rfrhrOr`)r+rr3rrrrgos

zMSVCCompiler.set_path_env_var)rrr)rrn)NNNrNNN)NrN)
NNNNNrNNNN)r)r�)r9r:r;Z
compiler_typeZexecutablesr}r~rtrvrrrurwZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr-rmrzr�r�r�r�r�r�r�rarfrgrrrrrS�sh
��
B�
 �
X�
�
S

$rSg @z3Importing new compiler from distutils.msvc9compiler)rS)r')-rCrOZdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
r��winregZhkey_modZ	OpenKeyExr
ZEnumKeyrZ	EnumValuer�errorr�ImportErrorZwin32apiZwin32con�infoZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr.rr!rr'rJrNrRrSr�ZOldMSVCCompilerZdistutils.msvc9compilerrrrr�<module>s^


�	-
9
PK=�\ϤУbase_futures.cpython-36.pycnu�[���3


 \�@srgZddlZddlZddlmZejjjZejj	Z	ejj
Z
Gdd�de�ZdZdZ
dZd	d
�Zdd�Zd
d�ZdS)�N�)�eventsc@seZdZdZdS)�InvalidStateErrorz+The operation is not allowed in this state.N)�__name__�
__module__�__qualname__�__doc__�r	r	�,/usr/lib64/python3.6/asyncio/base_futures.pyr
srZPENDINGZ	CANCELLEDZFINISHEDcCst|jd�o|jdk	S)z�Check for a Future.

    This returns True when obj is a Future instance or is advertising
    itself as duck-type compatible by setting _asyncio_future_blocking.
    See comment in Future for more details.
    �_asyncio_future_blockingN)�hasattr�	__class__r)�objr	r	r
�isfuturesrcCs�t|�}|sd}dd�}|dkr.||d�}nP|dkrTdj||d�||d��}n*|dkr~dj||d�|d||d
��}d	|S)z#helper function for Future.__repr__�cSstj|f�S)N)rZ_format_callback_source)�callbackr	r	r
�	format_cb(sz$_format_callbacks.<locals>.format_cbrr�z{}, {}z{}, <{} more>, {}zcb=[%s]���)�len�format)�cb�sizerr	r	r
�_format_callbacks"srcCs�|jj�g}|jtkrP|jdk	r4|jdj|j��ntj|j�}|jdj|��|j	rf|jt
|j	��|jr�|jd}|jd|d|df�|S)z#helper function for Future.__repr__Nzexception={!r}z	result={}rzcreated at %s:%srr)Z_state�lower�	_FINISHEDZ
_exception�appendr�reprlib�reprZ_resultZ
_callbacksrZ_source_traceback)Zfuture�info�result�framer	r	r
�_future_repr_info6s


r")�__all__Zconcurrent.futures._baseZ
concurrentrrrZfuturesZ_base�ErrorZCancelledError�TimeoutErrorrZ_PENDINGZ
_CANCELLEDrrrr"r	r	r	r
�<module>s
PK=�\�������base_events.cpython-36.pycnu�[���3


 \��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZdgZdZd
ZeeefZ e!e	d�Z"d)Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)de	j*ddd�dd�Z+e!e	d ��rRd!d"�Z,nd#d"�Z,d$d%�Z-Gd&d'�d'ej.�Z/Gd(d�dej0�Z1dS)*a�Base implementation of event loop.

The event loop can be broken up into a multiplexer (the part
responsible for notifying us of I/O events) and the event loop proper,
which wraps a multiplexer with functionality for scheduling callbacks,
immediately or at a given time in the future.

Whenever a public API takes a callback, subsequent positional
arguments will be passed to the callback if/when it is called.  This
avoids the proliferation of trivial lambdas implementing closures.
Keyword arguments for the callback are not supported; this is a
conscious design decision, leaving the door open for keyword arguments
to modify the meaning of the API call itself.
�N�)�compat)�
coroutines)�events)�futures)�tasks)�	coroutine)�logger�
BaseEventLoop�dg�?�AF_INET6�icCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�+/usr/lib64/python3.6/asyncio/base_events.py�_format_handle?s
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeHs


rcCsLttd�std��n4y|jtjtjd�Wntk
rFtd��YnXdS)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr�OSError)�sockrrr�_set_reuseportQs

r&cCs&ttd�r|d@tjkS|tjkSdS)N�
SOCK_NONBLOCK�)rr �SOCK_STREAM)�	sock_typerrr�_is_stream_socket\s
r+cCs&ttd�r|d@tjkS|tjkSdS)Nr'r()rr �
SOCK_DGRAM)r*rrr�_is_dgram_sockeths
r-cCsvttd�sdS|dtjtjhks(|dkr,dSt|�r<tj}nt|�rLtj}ndS|dkr^d}nVt|t�rv|dkrvd}n>t|t�r�|dkr�d}n&yt	|�}Wnt
tfk
r�dSX|tjkr�tj
g}tr�|jtj�n|g}t|t�r�|jd�}d|k�rdSxp|D]h}yJtj||�t�r@|tjk�r@|||d||ddffS|||d||ffSWntk
�rjYnX�qWdS)N�	inet_ptonr��Zidna�%)rr �IPPROTO_TCPZIPPROTO_UDPr+r-r�bytesr�int�	TypeErrorr!�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder.r$)�host�port�family�type�protoZafs�afrrr�_ipaddr_infopsL





rA)r=r>r?�flagsc
CsZ|dd�\}}t|||||�}|dk	r@|j�}	|	j|g�|	S|j||||||d�SdS)N�)r=r>r?rB)rA�
create_future�
set_result�getaddrinfo)
�addressr=r>r?rB�loopr;r<�info�futrrr�_ensure_resolved�srK�TCP_NODELAYcCs>|jtjtjhkr:t|j�r:|jtjkr:|jtjtj	d�dS)Nr)
r=r r7rr+r>r?r2r"rL)r%rrr�_set_nodelay�s
rMcCsdS)Nr)r%rrrrM�scCs.|j}t|t�r t|t�r dS|jj�dS)N)Z
_exceptionr�
BaseException�	Exception�_loop�stop)rJ�excrrr�_run_until_complete_cb�s

rSc@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
dS)�ServercCs||_||_d|_g|_dS)Nr)rP�sockets�
_active_count�_waiters)�selfrHrUrrr�__init__�szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>)�	__class__�__name__rU)rXrrr�__repr__�szServer.__repr__cCs |jdk	st�|jd7_dS)Nr)rU�AssertionErrorrV)rXrrr�_attach�szServer._attachcCs<|jdkst�|jd8_|jdkr8|jdkr8|j�dS)Nrr)rVr]rU�_wakeup)rXrrr�_detach�szServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|�qW|jdkrD|j�dS)Nr)rUrPZ
_stop_servingrVr_)rXrUr%rrr�close�s

zServer.closecCs0|j}d|_x|D]}|j�s|j|�qWdS)N)rW�donerE)rX�waiters�waiterrrrr_�s

zServer._wakeupccs<|jdks|jdkrdS|jj�}|jj|�|EdHdS)N)rUrWrPrDr9)rXrdrrr�wait_closed�s

zServer.wait_closedN)r[�
__module__�__qualname__rYr\r^r`rar_rrerrrrrT�s
rTc
@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd�d
d
d�dd�Z	d�dd
d
d
d�dd�Z
d�dd�Zd�dd�Zd�dd�Z
ed�dd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zed'd(��Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zej�r�d3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdMdMdMdN�dOdP�Z*d�dQdR�Z+ed�d
dMdMdMd
d
d
dS�dTdU��Z,ed�dVdW��Z-ed�dMdMdMd
d
d
d
dX�dYdZ��Z.ed[d\��Z/ed�e0j1e0j2d
d]d
d
d
d^�d_d`��Z3ed
da�dbdc��Z4eddde��Z5edfdg��Z6dhdi�Z7ee8j9e8j9e8j9ddjdMdk�dldm��Z:ee8j9e8j9e8j9dddMdk�dndo��Z;dpdq�Z<drds�Z=dtdu�Z>dvdw�Z?dxdy�Z@dzd{�ZAd|d}�ZBd~d�ZCd�d��ZDd�d��ZEd�d��ZFd
S)�r
cCs�d|_d|_d|_tj�|_g|_d|_d|_d|_	t
jd�j|_
d|_|jtjjodttjjd���d|_d|_d|_d|_ttd�r�tj�|_nd|_d|_dS)NrF�	monotonicZPYTHONASYNCIODEBUGg�������?�get_asyncgen_hooks) �_timer_cancelled_count�_closed�	_stopping�collections�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�timeZget_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debug�sysrB�ignore_environment�bool�os�environ�get�slow_callback_duration�_current_handle�
_task_factory�_coroutine_wrapper_setr�weakref�WeakSet�
_asyncgens�_asyncgens_shutdown_called)rXrrrrY�s(

zBaseEventLoop.__init__cCs d|jj|j�|j�|j�fS)Nz"<%s running=%s closed=%s debug=%s>)rZr[�
is_running�	is_closed�	get_debug)rXrrrr\ szBaseEventLoop.__repr__cCstj|d�S)z,Create a Future object attached to the loop.)rH)rZFuture)rXrrrrD%szBaseEventLoop.create_futurecCs@|j�|jdkr0tj||d�}|jr<|jd=n|j||�}|S)zDSchedule a coroutine object.

        Return a task object.
        N)rHr���)�
_check_closedrrr�_source_traceback)rX�coroZtaskrrr�create_task)s

zBaseEventLoop.create_taskcCs$|dk	rt|�rtd��||_dS)awSet a task factory that will be used by loop.create_task().

        If factory is None the default task factory will be set.

        If factory is a callable, it should have a signature matching
        '(loop, coro)', where 'loop' will be a reference to the active
        event loop, 'coro' will be a coroutine object.  The callable
        must return a Future.
        Nz'task factory must be a callable or None)�callabler5r)rX�factoryrrr�set_task_factory7s
zBaseEventLoop.set_task_factorycCs|jS)z<Return a task factory, or None if the default one is in use.)r)rXrrr�get_task_factoryEszBaseEventLoop.get_task_factoryN)�extra�servercCst�dS)zCreate socket transport.N)�NotImplementedError)rXr%�protocolrdr�r�rrr�_make_socket_transportIsz$BaseEventLoop._make_socket_transportF)�server_side�server_hostnamer�r�c	Cst�dS)zCreate SSL transport.N)r�)	rXZrawsockr��
sslcontextrdr�r�r�r�rrr�_make_ssl_transportNsz!BaseEventLoop._make_ssl_transportcCst�dS)zCreate datagram transport.N)r�)rXr%r�rGrdr�rrr�_make_datagram_transportTsz&BaseEventLoop._make_datagram_transportcCst�dS)zCreate read pipe transport.N)r�)rX�piper�rdr�rrr�_make_read_pipe_transportYsz'BaseEventLoop._make_read_pipe_transportcCst�dS)zCreate write pipe transport.N)r�)rXr�r�rdr�rrr�_make_write_pipe_transport^sz(BaseEventLoop._make_write_pipe_transportc	
Kst�dS)zCreate subprocess transport.N)r�)
rXr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transportcsz(BaseEventLoop._make_subprocess_transportcCst�dS)z�Write a byte to self-pipe, to wake up the event loop.

        This may be called from a different thread.

        The subclass is responsible for implementing the self-pipe.
        N)r�)rXrrr�_write_to_selfjszBaseEventLoop._write_to_selfcCst�dS)zProcess selector events.N)r�)rX�
event_listrrr�_process_eventssszBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)rk�RuntimeError)rXrrrr�wszBaseEventLoop._check_closedcCs*|jj|�|j�s&|j|j|j��dS)N)r��discardr��call_soon_threadsafer��aclose)rX�agenrrr�_asyncgen_finalizer_hook{sz&BaseEventLoop._asyncgen_finalizer_hookcCs,|jrtjdj|�t|d�|jj|�dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call)�source)r��warnings�warn�format�ResourceWarningr��add)rXr�rrr�_asyncgen_firstiter_hook�s
z&BaseEventLoop._asyncgen_firstiter_hookccs�d|_|jdkst|j�r dSt|j�}|jj�tjdd�|D�d|d��}|EdH}x8t||�D]*\}}t|t	�rf|j
dj|�||d��qfWdS)z,Shutdown all active asynchronous generators.TNcSsg|]}|j��qSr)r�)�.0Zagrrr�
<listcomp>�sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})�message�	exceptionZasyncgen)r�r��len�list�clearr�gather�ziprrO�call_exception_handlerr�)rXZ
closing_agensZ
shutdown_coroZresults�resultr�rrr�shutdown_asyncgens�s"




z BaseEventLoop.shutdown_asyncgenscCs�|j�|j�rtd��tj�dk	r,td��|j|j�tj�|_	|j
dk	rftj�}tj
|j|jd�z$tj|�x|j�|jrtPqtWWdd|_d|_	tjd�|jd�|j
dk	r�tj
|�XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is running)�	firstiter�	finalizerF)r�r�r�rZ_get_running_loop�_set_coroutine_wrapper�_debug�	threading�	get_identrrr�rwri�set_asyncgen_hooksr�r�Z_set_running_loop�	_run_oncerl)rXZold_agen_hooksrrr�run_forever�s0







zBaseEventLoop.run_forevercCs�|j�tj|�}tj||d�}|r,d|_|jt�z>y|j�Wn,|rj|j	�rj|j
�rj|j��YnXWd|jt�X|j	�s�t
d��|j�S)a\Run until the Future is done.

        If the argument is a coroutine, it is wrapped in a Task.

        WARNING: It would be disastrous to call run_until_complete()
        with the same coroutine twice -- it would wrap it in two
        different Tasks and that can't be good.

        Return the Future's result, or raise its exception.
        )rHFNz+Event loop stopped before Future completed.)r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrSr�rbZ	cancelledr�Zremove_done_callbackr�r�)rXZfutureZnew_taskrrr�run_until_complete�s 
z BaseEventLoop.run_until_completecCs
d|_dS)z�Stop running the event loop.

        Every callback already scheduled will still run.  This simply informs
        run_forever to stop looping after a complete iteration.
        TN)rl)rXrrrrQ�szBaseEventLoop.stopcCsj|j�rtd��|jrdS|jr,tjd|�d|_|jj�|jj�|j	}|dk	rfd|_	|j
dd�dS)z�Close the event loop.

        This clears the queues and shuts down the executor,
        but does not wait for the executor to finish.

        The event loop must not be running.
        z!Cannot close a running event loopNzClose %rTF)�wait)r�r�rkr�r	�debugror�rprqZshutdown)rX�executorrrrra�s

zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rk)rXrrrr�szBaseEventLoop.is_closedcCs0|j�s,tjd|t|d�|j�s,|j�dS)Nzunclosed event loop %r)r�)r�r�r�r�r�ra)rXrrr�__del__s
zBaseEventLoop.__del__cCs
|jdk	S)z*Returns True if the event loop is running.N)rr)rXrrrr�szBaseEventLoop.is_runningcCstj�S)z�Return the time according to the event loop's clock.

        This is a float expressed in seconds since an epoch, but the
        epoch, precision, accuracy and drift are unspecified and may
        differ per event loop.
        )rsrh)rXrrrrsszBaseEventLoop.timecGs,|j|j�||f|��}|jr(|jd=|S)a8Arrange for a callback to be called at a given time.

        Return a Handle: an opaque object with a cancel() method that
        can be used to cancel the call.

        The delay can be an int or float, expressed in seconds.  It is
        always relative to the current time.

        Each callback will be called exactly once.  If two callbacks
        are scheduled for exactly the same time, it undefined which
        will be called first.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        rr�)�call_atrsr�)rXZdelay�callbackr��timerrrr�
call_later szBaseEventLoop.call_latercGsX|j�|jr"|j�|j|d�tj||||�}|jr@|jd=tj|j	|�d|_	|S)z|Like call_later(), but uses an absolute time.

        Absolute time corresponds to the event loop's time() method.
        r�rTr�)
r�r��
_check_thread�_check_callbackr�TimerHandler��heapq�heappushrp)rX�whenr�r�r�rrrr�5szBaseEventLoop.call_atcGs@|j�|jr"|j�|j|d�|j||�}|jr<|jd=|S)aTArrange for a callback to be called as soon as possible.

        This operates as a FIFO queue: callbacks are called in the
        order in which they are registered.  Each callback will be
        called exactly once.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        �	call_soonrr�)r�r�r�r��
_call_soonr�)rXr�r�rrrrr�Es
zBaseEventLoop.call_sooncCs>tj|�stj|�r"tdj|���t|�s:tdj||���dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZiscoroutineZiscoroutinefunctionr5r�r�)rXr��methodrrrr�Xs

zBaseEventLoop._check_callbackcCs,tj|||�}|jr|jd=|jj|�|S)Nrr�)r�Handler�ror9)rXr�r�rrrrr�cs
zBaseEventLoop._call_sooncCs,|jdkrdStj�}||jkr(td��dS)aoCheck that the current thread is the thread running the event loop.

        Non-thread-safe methods of this class make this assumption and will
        likely behave incorrectly when the assumption is violated.

        Should only be called when (self._debug == True).  The caller is
        responsible for checking this condition for performance reasons.
        NzMNon-thread-safe operation invoked on an event loop other than the current one)rrr�r�r�)rXZ	thread_idrrrr�js	

zBaseEventLoop._check_threadcGs@|j�|jr|j|d�|j||�}|jr4|jd=|j�|S)z"Like call_soon(), but thread-safe.r�rr�)r�r�r�r�r�r�)rXr�r�rrrrr�{sz"BaseEventLoop.call_soon_threadsafecGsZ|j�|jr|j|d�|dkr@|j}|dkr@tjj�}||_tj|j|f|��|d�S)N�run_in_executor)rH)	r�r�r�rq�
concurrentrZThreadPoolExecutorZwrap_futureZsubmit)rXr��funcr�rrrr��s
zBaseEventLoop.run_in_executorcCs
||_dS)N)rq)rXr�rrr�set_default_executor�sz"BaseEventLoop.set_default_executorcCs�d||fg}|r |jd|�|r2|jd|�|rD|jd|�|rV|jd|�dj|�}tjd|�|j�}tj||||||�}	|j�|}
d||
d	|	f}|
|jkr�tj|�n
tj|�|	S)
Nz%s:%rz	family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@�@)	r9�joinr	r�rsr rFr}rI)rXr;r<r=r>r?rB�msg�t0Zaddrinfo�dtrrr�_getaddrinfo_debug�s(


z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc	Cs>|jr |jd|j||||||�S|jdtj||||||�SdS)N)r�r�r�r rF)rXr;r<r=r>r?rBrrrrF�s


zBaseEventLoop.getaddrinfocCs|jdtj||�S)N)r�r �getnameinfo)rXZsockaddrrBrrrr��szBaseEventLoop.getnameinfo)�sslr=r?rBr%�
local_addrr�c#s|
dk	r|rtd��|
dkr2|r2|s.td��|}
|dk	sD|dk	�r�|dk	rTtd��t||f|tj|||d�}|g}|	dk	r�t|	|tj|||d�}
|j|
�nd}
tj||d�EdH|j�}|s�td��|
dk	r�|
j�}|s�td��g}�x�|D�]B\}}}}}y�tj|||d�}|j	d	�|
dk	�r�x�|D]j\}}}}}y|j
|�PWnHtk
�r�}z*t|jd
j||j
j���}|j|�WYdd}~XnX�q.W|j�d}w�|j�r�tjd||�|j||�EdHWn^tk
�r}z"|dk	�r�|j�|j|�WYdd}~Xq�|dk	�r,|j��Yq�XPq�Wt|�dk�rR|d
�nJt|d
��t�fdd�|D���r~|d
�tdjdjdd�|D�����n,|dk�r�td��t|j��s�tdj|���|j||||
�EdH\}}|j�r
|jd�}tjd|||||�||fS)a�Connect to a TCP server.

        Create a streaming transport connection to a given Internet host and
        port: socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_STREAM. protocol_factory must be
        a callable returning a protocol instance.

        This method is a coroutine which will try to establish the connection
        in the background.  When successful, the coroutine returns a
        (transport, protocol) pair.
        Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|��kVqdS)N)r)r�rR)�modelrr�	<genexpr>sz2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, css|]}t|�VqdS)N)r)r�rRrrrr�#sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rr�r�r$�setblocking�bind�errnor��strerror�lowerrar�r	r��sock_connectr�r�allr�r+r>�_create_connection_transport�get_extra_info)rX�protocol_factoryr;r<r�r=r?rBr%r�r��f1�fs�f2�infosZladdr_infos�
exceptionsr>ZcnamerG�_ZladdrrR�	transportr�r)r�r�create_connection�s�





"




zBaseEventLoop.create_connectionc
	cs�|jd�|�}|j�}|rFt|t�r*dn|}|j||||||d�}	n|j|||�}	y|EdHWn|	j��YnX|	|fS)NF)r�r�)r�rDrryr�r�ra)
rXr%r�r�r�r�r�rdr�r�rrrr�=s
z*BaseEventLoop._create_connection_transport)r=r?rB�
reuse_address�
reuse_port�allow_broadcastr%c#sZ|
dk	r�t|
j�s tdj|
����s@�s@|s@|s@|s@|s@|s@|	r~t��||||||	d�}djdd�|j�D��}tdj|���|
jd�d}
�nL�p��s�|d	kr�td
��||fdff}n�tj	�}x�d	�fd�ffD]�\}}|dk	r�t
|t��r�t|�dk�st
d
��t||tj|||d�EdH}|�s.td��xB|D]:\}}}}}||f}||k�r`ddg||<||||<�q4Wq�W��fdd�|j�D�}|�s�td��g}|dk�r�tjdk�o�tjdk}�x|D�]\\}}\}}d}
d}
y�tj|tj|d�}
|�r|
jtjtjd�|�rt|
�|	�r4|
jtjtjd�|
jd���rN|
j|���rj|j|
|�EdH|}
Wn^tk
�r�}z"|
dk	�r�|
j�|j|�WYdd}~Xn"|
dk	�r�|
j��YnXP�q�W|d	�|�}|j�}|j |
||
|�}|j!�r,��rt"j#d��||�nt"j$d�||�y|EdHWn|j��YnX||fS)zCreate datagram connection.Nz#A UDP Socket was expected, got {!r})r��remote_addrr=r?rBr�r�rz, css"|]\}}|rdj||�VqdS)z{}={}N)r�)r��k�vrrrr�isz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrrCz2-tuple is expected)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}�r|ddkp*�o*|ddks||f�qS)rNrr)r��keyZ	addr_pair)r�rrrr��sz:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address information�posix�cygwin)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)%r-r>r!r��dictr��itemsr�rm�OrderedDictr�tupler�r]rKr r,r$rz�namerw�platformr"r#�SO_REUSEADDRr&ZSO_BROADCASTr�r�rar9rDr�r�r	rIr�)rXr�r�rr=r?rBr�r�rr%ZoptsZproblemsZr_addrZaddr_pairs_infoZ
addr_infos�idxZaddrr�Zfamr�ZprorGrr�Z
local_addressZremote_addressrRr�rdr�r)r�rr�create_datagram_endpointUs�








z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||d�EdH}|s0tdj|���|S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r�)rXr;r<r=rBr�rrr�_create_server_getaddrinfo�s
z(BaseEventLoop._create_server_getaddrinfor)r=rBr%�backlogr�r�r�c #s�t|t�rtd��|dk	s$�dk	�r|dk	r4td��|	dkrPtjdkoNtjdk}	g}|dkrddg}n$t|t�s|t|t	j
�r�|g}n|}����fdd�|D�}
tj|
d	�i�EdH}t
tjj|��}d
}�z �x|D�]
}|\}}}}}ytj|||�}Wn6tjk
�r2�j�r,tjd|||dd
�w�YnX|j|�|	�rV|jtjtjd�|
�rdt|�t�r�|tjk�r�ttd��r�|jtjtjd�y|j |�Wq�t!k
�r�}z t!|j"d||j#j$�f��WYdd}~Xq�Xq�Wd}Wd|�sx|D]}|j%��q�WXn2|dk�r"td��t&|j'��s<tdj(|���|g}t)�|�}x4|D],}|j*|�|j+d
��j,|||||��qRW�j�r�tj-d|�|S)a1Create a TCP server.

        The host parameter can be a string, in that case the TCP server is bound
        to host and port.

        The host parameter can also be a sequence of strings and in that case
        the TCP server is bound to all hosts of the sequence. If a host
        appears multiple times (possibly indirectly e.g. when hostnames
        resolve to the same IP address), the server is only bound once to that
        host.

        Return a Server object which can be used to stop the service.

        This method is a coroutine.
        z*ssl argument must be an SSLContext or NoneNz8host/port and sock can not be specified at the same timerrr0csg|]}�j|���d��qS))r=rB)r)r�r;)r=rBr<rXrrr�sz/BaseEventLoop.create_server.<locals>.<listcomp>rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)�exc_info�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z
%r is serving).rryr5r!rzrrwrrrm�Iterablerr��set�	itertools�chain�
from_iterabler �errorr�r	�warningr9r"r#r
r&r8rrrZIPV6_V6ONLYr�r$r�r�r�rar+r>r�rTZlistenr�Z_start_servingrI)rXr�r;r<r=rBr%rr�r�r�rUZhostsr�r�Z	completed�resr@Zsocktyper?Z	canonnameZsa�errr�r)r=rBr<rXr�
create_server�s�


(





zBaseEventLoop.create_server)r�ccs^t|j�stdj|���|j|||ddd�EdH\}}|jrV|jd�}tjd|||�||fS)aHandle an accepted connection.

        This is used by servers that accept connections outside of
        asyncio but that use asyncio to handle connections.

        This method is a coroutine.  When completed, the coroutine
        returns a (transport, protocol) pair.
        z&A Stream Socket was expected, got {!r}r0T)r�Nr z%r handled: (%r, %r))	r+r>r!r�r�r�r�r	r�)rXr�r%r�r�r�rrr�connect_accepted_socketAs


z%BaseEventLoop.connect_accepted_socketccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz Read pipe %r connected: (%r, %r))rDr�rar�r	r��fileno)rXr�r�r�rdr�rrr�connect_read_pipeXszBaseEventLoop.connect_read_pipeccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz!Write pipe %r connected: (%r, %r))rDr�rar�r	r�r)rXr�r�r�rdr�rrr�connect_write_pipeisz BaseEventLoop.connect_write_pipecCs�|g}|dk	r |jdt|��|dk	rF|tjkrF|jdt|��n4|dk	r`|jdt|��|dk	rz|jdt|��tjdj|��dS)Nzstdin=%szstdout=stderr=%sz	stdout=%sz	stderr=%s� )r9rrrr	r�r�)rXr�r�r�r�rIrrr�_log_subprocesszszBaseEventLoop._log_subprocessT)r�r�r��universal_newlinesr�r�c
ks�t|ttf�std��|r"td��|s.td��|dkr>td��|�}
d}|jrfd|}|j||||�|j|
|d||||f|	�EdH}|jr�|dk	r�tjd||�||
fS)	Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r)	rr3rr!r�r#r�r	rI)
rXr��cmdr�r�r�r$r�r�r�r��	debug_logr�rrr�subprocess_shell�s$zBaseEventLoop.subprocess_shellcos�|rtd��|rtd��|dkr(td��|f|	}x,|D]$}t|ttf�s8tdt|�j��q8W|�}
d}|jr�d|}|j||||�|j	|
|d||||f|
�EdH}|jr�|dk	r�t
jd||�||
fS)	Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r)r!rrr3r5r>r[r�r#r�r	rI)rXr�Zprogramr�r�r�r$r�r�r�r�Z
popen_args�argr�r&r�rrr�subprocess_exec�s,

zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use.
        )ru)rXrrr�get_exception_handler�sz#BaseEventLoop.get_exception_handlercCs*|dk	r t|�r tdj|���||_dS)a�Set handler as the new event loop exception handler.

        If handler is None, the default exception handler will
        be set.

        If handler is a callable object, it should have a
        signature matching '(loop, context)', where 'loop'
        will be a reference to the active event loop, 'context'
        will be a dict object (see `call_exception_handler()`
        documentation for details about context).
        Nz/A callable object or None is expected, got {!r})r�r5r�ru)rXZhandlerrrr�set_exception_handler�sz#BaseEventLoop.set_exception_handlerc	Cs|jd�}|sd}|jd�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}x�t|�D]�}|dkr~qp||}|dkr�djtj|��}d	}||j	�7}n2|dkr�djtj|��}d
}||j	�7}nt
|�}|jdj||��qpWt
jdj|�|d
�dS)aEDefault exception handler.

        This is called when an exception occurs and no exception
        handler is set, and can be called by a custom exception
        handler that wants to defer to the default behavior.

        This default handler logs the error message and other
        context-dependent information.  In debug mode, a truncated
        stack trace is also appended showing where the given object
        (e.g. a handle or future or task) was created, if any.

        The context parameter has the same meaning as in
        `call_exception_handler()`.
        r�z!Unhandled exception in event loopr�NFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last):
z+Handle created at (most recent call last):
z{}: {}�
)r>r�r�)r|r>�
__traceback__r~r��sortedr��	traceback�format_list�rstriprr9r�r	r)	rX�contextr�r�rZ	log_linesr�value�tbrrr�default_exception_handler�s6


z'BaseEventLoop.default_exception_handlercCs�|jdkr>y|j|�Wq�tk
r:tjddd�Yq�Xnny|j||�Wn\tk
r�}z@y|jd||d��Wn"tk
r�tjddd�YnXWYdd}~XnXdS)aCall the current event loop's exception handler.

        The context argument is a dict containing the following keys:

        - 'message': Error message;
        - 'exception' (optional): Exception object;
        - 'future' (optional): Future instance;
        - 'handle' (optional): Handle instance;
        - 'protocol' (optional): Protocol instance;
        - 'transport' (optional): Transport instance;
        - 'socket' (optional): Socket instance;
        - 'asyncgen' (optional): Asynchronous generator that caused
                                 the exception.

        New keys maybe introduced in the future.

        Note: do not overload this method in an event loop subclass.
        For custom exception handling, use the
        `set_exception_handler()` method.
        Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)r�r�r2zeException in default exception handler while handling an unexpected error in custom exception handler)rur5rOr	r)rXr2rRrrrr�s"
z$BaseEventLoop.call_exception_handlercCs@t|tj�std��|jrdSt|tj�s0t�|jj|�dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrr�r]�
_cancelledr�ror9)rXrrrr�
_add_callback9s
zBaseEventLoop._add_callbackcCs|j|�|j�dS)z6Like _add_callback() but called from a signal handler.N)r7r�)rXrrrr�_add_callback_signalsafeAs
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rprj)rXrrrr�_timer_handle_cancelledFsz%BaseEventLoop._timer_handle_cancelledcCs�t|j�}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|�q,Wtj|�||_d|_n8x6|jr�|jdjr�|jd8_tj	|j�}d|_qfWd}|j
s�|jr�d}n*|jr�|jdj}t
td||j��t�}|jo�|dk�r�|j�}|jj|�}|j�|}|dk�rtj}	ntj}	t|�}
|dk�rLtj|	d|d|
�nD|
�rntj|	d|d|d|
�n"|dk�r�tj|	d	|d|d�n|jj|�}|j|�|j�|j}xD|j�r�|jd}|j|k�r�Ptj	|j�}d|_|j
j|��q�Wt|j
�}x�t|�D]|}
|j
j�}|j�r*�q|j�r�zD||_|j�}|j�|j�|}||jk�rttj d
t!|�|�Wdd|_Xn|j��qWd}dS)z�Run one full iteration of the event loop.

        This calls all currently ready callbacks, polls for I/O,
        schedules the resulting callbacks, and finally schedules
        'call_later' callbacks.
        FrrNg�?zpoll took %.3f ms: %s eventsg@�@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"r�rp�_MIN_SCHEDULED_TIMER_HANDLESrj�%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr6r9r��heapify�heappoprorlZ_when�min�maxrs�MAXIMUM_SELECT_TIMEOUTr�Z	_selectorZselect�logging�INFO�DEBUGr	�logr�rt�range�popleftr~Z_runr}rr)rXZsched_countZ
new_scheduledrZtimeoutr�r�r�r��levelZneventZend_timeZntodo�irrrr�Ks�











zBaseEventLoop._run_oncecCs�ytj}tj}Wntk
r$dSXt|�}|j|kr<dStj}|�}|rz|d|fkrjtj	d|t
�q�||�d|_n,|d|fkr�tj	d|t
�n|d�d|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF)rw�set_coroutine_wrapper�get_coroutine_wrapper�AttributeErrorryr�rZ
debug_wrapperr�r��RuntimeWarning)rX�enabledZset_wrapperZget_wrapper�wrapperZcurrent_wrapperrrrr��s.

z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r�)rXrrrr��szBaseEventLoop.get_debugcCs||_|j�r|j|�dS)N)r�r�r�)rXrMrrrrv�szBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)NN)F)NN)NN)Gr[rfrgrYr\rDr�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�rQrar�rZPY34r�r�rsr�r�r�r�r�r�r�r�r�r�rFr�r�r�rrr r6Z
AI_PASSIVErrr r!r#rrr'r)r*r+r5r�r7r8r9r�r�r�rvrrrrr
�s�!


		%	

u	`
12c!i�Q)2�__doc__rmZconcurrent.futuresr�r��inspectrrArzr rr�rsr/rwr�r�r0rrrrrrrDr	�__all__r:r;�BrokenPipeError�ConnectionResetError�ConnectionAbortedErrorZ_FATAL_ERROR_IGNORErr8r@rrr&r+r-rAr)rKrMrSZAbstractServerrTZAbstractEventLoopr
rrrr�<module>sV
		;


/PK=�\������subprocess.cpython-36.opt-2.pycnu�[���3


 \��@s�ddgZddlZddlmZddlmZddlmZddlmZdd	lmZdd
l	m
Z
ejZejZej
Z
Gdd�dejej�ZGd
d�d�Zeddddejfdd��Zeddddejd�dd��ZdS)�create_subprocess_exec�create_subprocess_shell�N�)�events)�	protocols)�streams)�tasks)�	coroutine)�loggercsLeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�SubprocessStreamProtocolcs<t�j|d�||_d|_|_|_d|_d|_g|_dS)N)�loopF)	�super�__init__�_limit�stdin�stdout�stderr�
_transport�_process_exited�	_pipe_fds)�self�limitr)�	__class__��*/usr/lib64/python3.6/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk	r$|jd|j�|jdk	r>|jd|j�|jdk	rX|jd|j�ddj|�S)Nzstdin=%rz	stdout=%rz	stderr=%rz<%s>� )r�__name__r�appendrr�join)r�inforrr�__repr__s



z!SubprocessStreamProtocol.__repr__cCs�||_|jd�}|dk	rDtj|j|jd�|_|jj|�|jj	d�|jd�}|dk	r�tj|j|jd�|_
|j
j|�|jj	d�|jd�}|dk	r�tj||d|jd�|_dS)Nr)rr�r)�protocol�readerr)
r�get_pipe_transportr�StreamReaderr�_looprZ
set_transportrrr�StreamWriterr)r�	transportZstdout_transportZstderr_transportZstdin_transportrrr�connection_made(s&


z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk	r6|j|�dS)Nrr!)rrZ	feed_data)r�fd�datar#rrr�pipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs�|dkr,|j}|dk	r|j�|j|�dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|j�n
|j|�||jkr�|jj|�|j	�dS)Nrrr!)
r�closeZconnection_lostrrZfeed_eofZ
set_exceptionr�remove�_maybe_close_transport)rr*�exc�piper#rrr�pipe_connection_lostJs$



z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|j�dS)NT)rr/)rrrr�process_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|j�dkr$|jr$|jj�d|_dS)Nr)�lenrrrr-)rrrrr/es
z/SubprocessStreamProtocol._maybe_close_transport)r�
__module__�__qualname__rr r)r,r2r3r/�
__classcell__rr)rrrs

rc@s~eZdZdd�Zdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zedd��Zedd��Z
edd��Zeddd��ZdS)�ProcesscCs8||_||_||_|j|_|j|_|j|_|j�|_dS)N)rZ	_protocolr&rrrZget_pid�pid)rr(r"rrrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr9)rrrrr uszProcess.__repr__cCs
|jj�S)N)rZget_returncode)rrrr�
returncodexszProcess.returncodeccs|jj�EdHS)N)rZ_wait)rrrr�wait|szProcess.waitcCs|jj|�dS)N)r�send_signal)r�signalrrrr<�szProcess.send_signalcCs|jj�dS)N)r�	terminate)rrrrr>�szProcess.terminatecCs|jj�dS)N)r�kill)rrrrr?�szProcess.killccs�|jj�}|jj|�|r,tjd|t|��y|jj�EdHWn8tt	fk
rx}z|rhtjd||�WYdd}~XnX|r�tjd|�|jj
�dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r&�	get_debugr�writer
�debugr4Zdrain�BrokenPipeError�ConnectionResetErrorr-)r�inputrBr0rrr�_feed_stdin�s
 zProcess._feed_stdincCsdS)Nr)rrrr�_noop�sz
Process._noopccs�|jj|�}|dkr|j}n|j}|jj�rJ|dkr8dnd}tjd||�|j�EdH}|jj�r�|dkrndnd}tjd||�|j	�|S)Nr!rrrz%r communicate: read %sz%r communicate: close %s)
rr$rrr&r@r
rB�readr-)rr*r(�stream�name�outputrrr�_read_stream�s

zProcess._read_streamNccs�|dk	r|j|�}n|j�}|jdk	r2|jd�}n|j�}|jdk	rP|jd�}n|j�}tj||||jd�EdH\}}}|j�EdH||fS)Nrr!)r)	rFrGrrLrrZgatherr&r;)rrErrrrrr�communicate�s


zProcess.communicate)N)rr5r6rr �propertyr:r	r;r<r>r?rFrGrLrMrrrrr8ks	r8c
+sP�dkrtj����fdd�}�j||f|||d�|��EdH\}}	t||	��S)Ncst��d�S)N)rr)rr)rrrr�<lambda>�sz)create_subprocess_shell.<locals>.<lambda>)rrr)r�get_event_loopZsubprocess_shellr8)
�cmdrrrrr�kwds�protocol_factoryr(r"r)rrrr�s)rrrrrc/sT�dkrtj����fdd�}�j||f|�|||d�|��EdH\}	}
t|	|
��S)Ncst��d�S)N)rr)rr)rrrrrO�sz(create_subprocess_exec.<locals>.<lambda>)rrr)rrPZsubprocess_execr8)Zprogramrrrrr�argsrRrSr(r"r)rrrr�s)�__all__�
subprocess�rrrrZ
coroutinesr	�logr
�PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolrr8Z_DEFAULT_LIMITrrrrrr�<module>s(X]PK=�\����N�Nsslproto.cpython-36.opt-1.pycnu�[���3


 \�e�
@s�ddlZddlZyddlZWnek
r4dZYnXddlmZddlmZddlmZddlmZddl	m
Z
dd	�Zd
d�ZdZ
d
ZdZdZGdd�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�base_events)�compat)�	protocols)�
transports)�loggercCsj|rtd��ttd�r*tj�}|sfd|_n<tjtj�}|jtjO_|jtj	O_|j
�tj|_|S)Nz(Server side SSL needs a valid SSLContext�create_default_contextF)
�
ValueError�hasattr�sslr�check_hostnameZ
SSLContextZPROTOCOL_SSLv23ZoptionsZOP_NO_SSLv2ZOP_NO_SSLv3Zset_default_verify_pathsZ
CERT_REQUIRED�verify_mode)�server_side�server_hostname�
sslcontext�r�(/usr/lib64/python3.6/asyncio/sslproto.py�_create_transport_contexts
rcCs
ttd�S)N�	MemoryBIO)r
rrrrr�_is_sslproto_available%srZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@s~eZdZdZdZddd�Zedd��Zed	d
��Zedd��Z	ed
d��Z
ddd�Zddd�Zdd�Z
ddd�Zd dd�ZdS)!�_SSLPipeaAn SSL "Pipe".

    An SSL pipe allows you to communicate with an SSL/TLS protocol instance
    through memory buffers. It can be used to implement a security layer for an
    existing connection where you don't have access to the connection's file
    descriptor, or for some reason you don't want to use it.

    An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode,
    data is passed through untransformed. In wrapped mode, application level
    data is encrypted to SSL record level data and vice versa. The SSL record
    level is the lowest level in the SSL protocol suite and is what travels
    as-is over the wire.

    An SslPipe initially is in "unwrapped" mode. To start SSL, call
    do_handshake(). To shutdown SSL again, call unwrap().
    �iNcCsH||_||_||_t|_tj�|_tj�|_d|_	d|_
d|_d|_dS)a�
        The *context* argument specifies the ssl.SSLContext to use.

        The *server_side* argument indicates whether this is a server side or
        client side transport.

        The optional *server_hostname* argument can be used to specify the
        hostname you are connecting to. You may only specify this parameter if
        the _ssl module supports Server Name Indication (SNI).
        NF)
�_context�_server_side�_server_hostname�
_UNWRAPPED�_staterr�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextrrrrr�__init__Ds

z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)r)r#rrrr$Zsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance.

        Return None if the pipe is not wrapped.
        )r)r#rrr�
ssl_object_sz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake
        that is currently in progress.)r )r#rrr�need_ssldatagsz_SSLPipe.need_ssldatacCs
|jtkS)zj
        Whether a security layer is currently in effect.

        Return False during handshake.
        )r�_WRAPPED)r#rrr�wrappedmsz_SSLPipe.wrappedcCsR|jtkrtd��|jj|j|j|j|jd�|_	t
|_||_|jddd�\}}|S)aLStart the SSL handshake.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the handshake is complete. The callback will be
        called with None if successful, else an exception instance.
        z"handshake in progress or completed)rr�T)�only_handshake)
rr�RuntimeErrorrZwrap_biorrrrr�
_DO_HANDSHAKEr!�feed_ssldata)r#�callback�ssldata�appdatarrr�do_handshakevs	
z_SSLPipe.do_handshakecCsB|jtkrtd��|jtkr$td��t|_||_|jd�\}}|S)a1Start the SSL shutdown sequence.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the shutdown is complete. The callback will be
        called without arguments.
        zno security layer presentzshutdown in progressr*)rrr,�	_SHUTDOWNr"r.)r#r/r0r1rrr�shutdown�s	

z_SSLPipe.shutdowncCs|jj�|jd�\}}dS)z�Send a potentially "ragged" EOF.

        This method will raise an SSL_ERROR_EOF exception if the EOF is
        unexpected.
        r*N)rZ	write_eofr.)r#r0r1rrr�feed_eof�s
z_SSLPipe.feed_eofFcCs�|jtkr"|r|g}ng}g|fSd|_|r8|jj|�g}g}y�|jtkrx|jj�t|_|j	rl|j	d�|rx||fS|jtkr�xn|jj
|j�}|j|�|s�Pq�WnJ|jt
kr�|jj�d|_t|_|jr�|j�n|jtkr�|j|jj
��Wnxtjtjfk
�rl}zRt|dd�tjtjtjfk�rN|jtk�rL|j	�rL|j	|��|jtjk|_WYdd}~XnX|jj�r�|j|jj
��||fS)a�Feed SSL record level data into the pipe.

        The data must be a bytes instance. It is OK to send an empty bytes
        instance. This can be used to get ssldata for a handshake initiated by
        this endpoint.

        Return a (ssldata, appdata) tuple. The ssldata element is a list of
        buffers containing SSL data that needs to be sent to the remote SSL.

        The appdata element is a list of buffers containing plaintext data that
        needs to be forwarded to the application. The appdata list may contain
        an empty buffer indicating an SSL "close_notify" alert. This alert must
        be acknowledged by calling shutdown().
        FN�errno)rrr r�writer-rr2r(r!�read�max_size�appendr3Zunwrapr"r�SSLError�CertificateError�getattr�SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITE�SSL_ERROR_SYSCALLr6r�pending)r#�datar+r1r0�chunk�excrrrr.�sV











 
z_SSLPipe.feed_ssldatarcCs|jtkr6|t|�kr&||d�g}ng}|t|�fSg}t|�}x�d|_y(|t|�krp||jj||d��7}Wn\tjk
r�}z>|j	dkr�tj
|_|jtj
tjtj
fkr��|jtj
k|_WYdd}~XnX|jjr�|j|jj��|t|�ks�|jrDPqDW||fS)aFeed plaintext data into the pipe.

        Return an (ssldata, offset) tuple. The ssldata element is a list of
        buffers containing record level data that needs to be sent to the
        remote SSL instance. The offset is the number of plaintext bytes that
        were processed, which may be less than the length of data.

        NOTE: In case of short writes, this call MUST be retried with the SAME
        buffer passed into the *data* argument (i.e. the id() must be the
        same). This is an OpenSSL requirement. A further particularity is that
        a short write will always have offset == 0, because the _ssl module
        does not enable partial writes. And even though the offset is zero,
        there will still be encrypted data in ssldata.
        NFZPROTOCOL_IS_SHUTDOWN)rr�len�
memoryviewr rr7rr;�reasonr>r6r?r@rrAr:r8)r#rB�offsetr0ZviewrDrrr�feed_appdata�s2


 z_SSLPipe.feed_appdatai)N)N)N)F)r)�__name__�
__module__�__qualname__�__doc__r9r%�propertyr$r&r'r)r2r4r5r.rIrrrrr0s
	



Jrc@s�eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Ze	j
rHdd�Zdd�Zdd�Z
ddd�Zdd�Zdd�Zdd�Zdd�ZdS) �_SSLProtocolTransportcCs||_||_d|_dS)NF)�_loop�
_ssl_protocol�_closed)r#�loopZssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||�S)z#Get optional transport information.)rQ�_get_extra_info)r#�name�defaultrrr�get_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs||j_dS)N)rQ�
_app_protocol)r#�protocolrrr�set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rQrX)r#rrr�get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rR)r#rrr�
is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jj�dS)a
Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) called
        with None as its argument.
        TN)rRrQ�_start_shutdown)r#rrr�close<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d�|j�dS)Nzunclosed transport %r)�source)rR�warnings�warn�ResourceWarningr^)r#rrr�__del__Ksz_SSLProtocolTransport.__del__cCs|jjj�dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        N)rQ�
_transport�
pause_reading)r#rrrreQsz#_SSLProtocolTransport.pause_readingcCs|jjj�dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        N)rQrd�resume_reading)r#rrrrfYsz$_SSLProtocolTransport.resume_readingcCs|jjj||�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        N)rQrd�set_write_buffer_limits)r#ZhighZlowrrrrgasz-_SSLProtocolTransport.set_write_buffer_limitscCs|jjj�S)z,Return the current size of the write buffer.)rQrd�get_write_buffer_size)r#rrrrhvsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttf�s$tdjt|�j���|s,dS|jj	|�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        z/data: expecting a bytes-like instance, got {!r}N)
�
isinstance�bytes�	bytearrayrF�	TypeError�format�typerJrQ�_write_appdata)r#rBrrrr7zsz_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|jj�dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        N)rQ�_abort)r#rrr�abort�sz_SSLProtocolTransport.abort)N)NN)rJrKrLr%rWrZr[r\r^rZPY34rcrerfrgrhr7rprrrrrrrO&s


rOc@s�eZdZdZd(dd�Zd)dd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zd*dd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd+d"d#�Zd$d%�Zd&d'�ZdS),�SSLProtocolz�SSL protocol.

    Implementation of SSL on top of a socket using incoming and outgoing
    buffers which are ssl.MemoryBIO objects.
    FNTcCs�tdkrtd��|st||�}||_|r6|r6||_nd|_||_t|d�|_tj	�|_
d|_||_||_
||_t|j
|�|_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)rr,rrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrPrXrO�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownrd�_call_connection_made)r#rSZapp_protocolrZwaiterrrZcall_connection_maderrrr%�s,


zSSLProtocol.__init__cCsD|jdkrdS|jj�s:|dk	r.|jj|�n|jjd�d|_dS)N)r{Z	cancelledZ
set_exceptionZ
set_result)r#rDrrr�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|j�dS)zXCalled when the low-level connection is made.

        Start the SSL handshake.
        N)rdrrtrrr}�_start_handshake)r#�	transportrrr�connection_made�s

zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|�d|_d|_|j|�dS)z�Called when the low-level connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        FN)r~rP�	call_soonrX�connection_lostrdr|r�)r#rDrrrr��szSSLProtocol.connection_lostcCs|jj�dS)z\Called when the low-level transport's buffer goes over
        the high-water mark.
        N)rX�
pause_writing)r#rrrr��szSSLProtocol.pause_writingcCs|jj�dS)z^Called when the low-level transport's buffer drains below
        the low-water mark.
        N)rX�resume_writing)r#rrrr��szSSLProtocol.resume_writingcCs�|jdkrdSy|jj|�\}}WnHtjk
rj}z*|jj�rTtjd||j|j	�|j
�dSd}~XnXx|D]}|jj|�qrWx(|D] }|r�|j
j|�q�|j�Pq�WdS)zXCalled when some SSL data is received.

        The argument is a bytes object.
        Nz%r: SSL error %s (reason %s))r}r.rr;rP�	get_debugr�warningr6rGrqrdr7rX�
data_receivedr])r#rBr0r1�erCrrrr��s"



zSSLProtocol.data_receivedc
CsTzB|jj�rtjd|�|jt�|js@|jj�}|r@tj	d�Wd|j
j�XdS)aCalled when the other end of the low-level stream
        is half-closed.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        z%r received EOFz?returning true from eof_received() has no effect when using sslN)rPr�r�debugr��ConnectionResetErrorrrX�eof_receivedr�rdr^)r#Z	keep_openrrrr�s


zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk	r,|jj||�S|SdS)N)rvrdrW)r#rUrVrrrrT!s



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|j�nd|_|jd�dS)NTr*)r�rrqro)r#rrrr])s
zSSLProtocol._start_shutdowncCs.|jj|df�|jt|�7_|j�dS)Nr)ryr:rzrE�_process_write_backlog)r#rBrrrro2szSSLProtocol._write_appdatacCsH|jj�r$tjd|�|jj�|_nd|_d|_|jjd�|j	�dS)Nz%r starts SSL handshakeTr*r)r*r)
rPr�rr��time�_handshake_start_timerryr:r�)r#rrrr�7s
zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk	r|�|j�}t|jd�sR|jrR|jjtj	krRtj
||j�Wn~tk
r�}zb|jj
�r�t|tj�r�tjd|dd�ntjd|dd�|jj�t|t�r�|j|�dS�WYdd}~XnX|jj
��r|jj�|j}tjd||d�|jj||j�|j�|d	�|j�r4|jj|j �|j�d|_!|jj"|j#�dS)
NFrz5%r: SSL handshake failed on verifying the certificateT)�exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compressionr&)$rr}r&Zgetpeercertr
rtrr
rZ	CERT_NONEZmatch_hostname�
BaseExceptionrPr�rir<rr�rdr^�	Exceptionr�r�r�r�rv�updater�r�r�rXr�r|r~r�r�)r#Z
handshake_excZsslobjr�rDZdtrrr�_on_handshake_completeCsD




z"SSLProtocol._on_handshake_completecCs>|jdks|jdkrdSy�x�tt|j��D]�}|jd\}}|rT|jj||�\}}n*|rl|jj|j�}d}n|jj|j	�}d}x|D]}|jj
|�q�W|t|�kr�||f|jd<|jjr�|jj�P|jd=|j
t|�8_
q*WWnRtk
�r8}z4|j�r|j|�n|j|d�t|t��s(�WYdd}~XnXdS)NrrzFatal error on SSL transport)rdr}�rangerEryrIr2r�r4�	_finalizer7Z_pausedrfrzr�r�_fatal_errorrir�)r#�irBrHr0rCrDrrrr�ws8

z"SSLProtocol._process_write_backlog�Fatal error on transportcCsXt|tj�r*|jj�rBtjd||dd�n|jj|||j|d��|jrT|jj	|�dS)Nz%r: %sT)r�)�messageZ	exceptionr�rY)
rirZ_FATAL_ERROR_IGNORErPr�rr�Zcall_exception_handlerrdZ_force_close)r#rDr�rrrr��s

zSSLProtocol._fatal_errorcCsd|_|jdk	r|jj�dS)N)r}rdr^)r#rrrr��s
zSSLProtocol._finalizec
Cs(z|jdk	r|jj�Wd|j�XdS)N)rdrrr�)r#rrrrq�s
zSSLProtocol._abort)FNT)N)N)r�)rJrKrLrMr%r�r�r�r�r�r�r�rTr]ror�r�r�r�r�rqrrrrrs�s&
"


	4,
rs)rwr`r�ImportError�rrrr�logrrrrr-r(r3�objectrZ_FlowControlMixinZ	TransportrOZProtocolrsrrrr�<module>s*
wnPK=�\�%�O�S�S#windows_events.cpython-36.opt-1.pycnu�[���3


 \�l�@s�dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddddgZdZdZdZdZdZdZGdd�de
j�ZGdd�de
j�ZGdd�de�ZGdd�de�ZGdd �d e �Z!Gd!d"�d"ej"�Z#Gd#d�dej$�Z%Gd$d�d�Z&Gd%d&�d&e	j'�Z(e#Z)Gd'd(�d(ej*�Z+e+Z,dS))z.Selector and proactor event loops for Windows.�N�)�events)�base_subprocess)�futures)�proactor_events)�selector_events)�tasks)�
windows_utils)�_overlapped)�	coroutine)�logger�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicyl��i�i�g����MbP?g�������?cs^eZdZdZdd��fdd�
Z�fdd�Zdd	�Z�fd
d�Z�fdd
�Z�fdd�Z	�Z
S)�_OverlappedFuturez�Subclass of Future which represents an overlapped operation.

    Cancelling it will immediately cancel the overlapped operation.
    N)�loopcs&t�j|d�|jr|jd=||_dS)N)rr���)�super�__init__�_source_traceback�_ov)�self�ovr)�	__class__��./usr/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@t�j�}|jdk	r<|jjr dnd}|jdd||jjf�|S)N�pendingZ	completedrzoverlapped=<%s, %#x>)r�
_repr_inforr�insert�address)r�info�state)rrrr3s


z_OverlappedFuture._repr_infocCsr|jdkrdSy|jj�WnJtk
rf}z.d||d�}|jrJ|j|d<|jj|�WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)�message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextrrr�_cancel_overlapped:s

z$_OverlappedFuture._cancel_overlappedcs|j�t�j�S)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcst�j|�|j�dS)N)r�
set_exceptionr-)rr$)rrrr.Nsz_OverlappedFuture.set_exceptioncst�j|�d|_dS)N)r�
set_resultr)r�result)rrrr/Rsz_OverlappedFuture.set_result)�__name__�
__module__�__qualname__�__doc__rrr-r'r.r/�
__classcell__rr)rrr'srcsneZdZdZdd��fdd�
Zdd�Z�fdd	�Zd
d�Zdd
�Z�fdd�Z	�fdd�Z
�fdd�Z�ZS)�_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.N)rcs8t�j|d�|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jd�tjkS)Nr)�_winapiZWaitForSingleObjectr7Z
WAIT_OBJECT_0)rrrr�_pollhsz_BaseWaitHandleFuture._pollcs\t�j�}|jd|j�|jdk	r>|j�r0dnd}|j|�|jdk	rX|jd|j�|S)Nz
handle=%#xZsignaledZwaitingzwait_handle=%#x)rr�appendr7r=r8)rr!r")rrrrms



z _BaseWaitHandleFuture._repr_infocCs
d|_dS)N)r)r�futrrr�_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs�|js
dSd|_|j}d|_ytj|�WnZtk
r�}z>|jtjkrtd||d�}|jrd|j|d<|jj	|�dSWYdd}~XnX|j
d�dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r
ZUnregisterWaitr(�winerror�ERROR_IO_PENDINGrr)r*r@)rr;r+r,rrr�_unregister_wait|s"
z&_BaseWaitHandleFuture._unregister_waitcs|j�t�j�S)N)rCrr')r)rrrr'�sz_BaseWaitHandleFuture.cancelcs|j�t�j|�dS)N)rCrr.)rr$)rrrr.�sz#_BaseWaitHandleFuture.set_exceptioncs|j�t�j|�dS)N)rCrr/)rr0)rrrr/�sz _BaseWaitHandleFuture.set_result)
r1r2r3r4rr=rr@rCr'r.r/r5rr)rrr6Ws
r6csFeZdZdZdd��fdd�
Zdd�Z�fdd	�Z�fd
d�Z�ZS)�_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a
    _WaitHandleFuture using an event.
    N)rcst�j||||d�d|_dS)N)r)rr�_done_callback)rr�eventr;r)rrrr�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeError)rrrrr'�sz_WaitCancelFuture.cancelcs$t�j|�|jdk	r |j|�dS)N)rr/rE)rr0)rrrr/�s
z_WaitCancelFuture.set_resultcs$t�j|�|jdk	r |j|�dS)N)rr.rE)rr$)rrrr.�s
z_WaitCancelFuture.set_exception)	r1r2r3r4rr'r/r.r5rr)rrrD�s
rDcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureN)rcs<t�j||||d�||_d|_tjdddd�|_d|_dS)N)rTF)rr�	_proactorZ_unregister_proactorr
ZCreateEvent�_event�
_event_fut)rrr:r;�proactorr)rrrr�s
z_WaitHandleFuture.__init__csF|jdk	r"tj|j�d|_d|_|jj|j�d|_t�j|�dS)N)	rJr<�CloseHandlerKrI�_unregisterrrr@)rr?)rrrr@�s
	z%_WaitHandleFuture._unregister_wait_cbcCs�|js
dSd|_|j}d|_ytj||j�WnZtk
r�}z>|jtjkrxd||d�}|jrh|j|d<|j	j
|�dSWYdd}~XnX|jj|j|j
�|_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r
ZUnregisterWaitExrJr(rArBrr)r*rI�_wait_cancelr@rK)rr;r+r,rrrrC�s$

z"_WaitHandleFuture._unregister_wait)r1r2r3rr@rCr5rr)rrrH�srHc@s<eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZeZ	dS)
�
PipeServerzXClass representing a pipe server.

    This is much like a bound, listening socket.
    cCs,||_tj�|_d|_d|_|jd�|_dS)NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr rrrr�s

zPipeServer.__init__cCs|j|jd�}|_|S)NF)rUrW)r�tmprrr�_get_unconnected_pipe�sz PipeServer._get_unconnected_pipec	Csr|j�rdStjtjB}|r&|tjO}tj|j|tjtjBtj	Btj
tjtjtj
tj�}tj|�}|jj|�|S)N)�closedr<ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr	ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerT�add)r�first�flags�h�piperrrrWs


zPipeServer._server_pipe_handlecCs
|jdkS)N)rQ)rrrrrZszPipeServer.closedcCsV|jdk	r|jj�d|_|jdk	rRx|jD]}|j�q,Wd|_d|_|jj�dS)N)rVr'rQrT�closerU�clear)rrarrrrbs


zPipeServer.closeN)
r1r2r3r4rrYrWrZrb�__del__rrrrrP�s
rPc@seZdZdZdd�ZdS)�_WindowsSelectorEventLoopz'Windows version of selector event loop.cCstj�S)N)r	�
socketpair)rrrr�_socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre(srecsPeZdZdZd
�fdd�	Zdd�Zedd��Zed	d
��Zeddd��Z	�Z
S)rz2Windows version of proactor event loop using IOCP.Ncs|dkrt�}t�j|�dS)N)rrr)rrL)rrrr2szProactorEventLoop.__init__cCstj�S)N)r	rf)rrrrrg7szProactorEventLoop._socketpairccs8|jj|�}|EdH}|�}|j||d|id�}||fS)N�addr)�extra)rI�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr �fra�protocol�transrrr�create_pipe_connection:s
z(ProactorEventLoop.create_pipe_connectioncs.t���d�����fdd�	��j���gS)Ncsd}yj|rL|j�}�jj|��j�r2|j�dS��}�j||d�id��j�}|dkr`dS�jj|�}Wn�t	k
r�}zH|r�|j
�d	kr��jd||d��|j�n�jr�t
jd|dd�WYdd}~Xn2tjk
r�|r�|j�YnX|�_|j��dS)
Nrh)rirzPipe accept failed)r#r$razAccept pipe failed on pipe %rT)�exc_infor)r0rT�discardrZrbrkrYrI�accept_piper(�filenor*Z_debugrZwarningr�CancelledErrorrV�add_done_callback)rmrarnr+)r �loop_accept_piperlr�serverrrrwGs<

z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rPZ	call_soon)rrlr r)r rwrlrrxr�start_serving_pipeCs(
z$ProactorEventLoop.start_serving_pipec	ks�|j�}
t||||||||f|
|d�|	��}y|
EdHWn&tk
r`}z
|}
WYdd}~XnXd}
|
dk	r�|j�|j�EdH|
�|S)N)�waiterri)�
create_future�_WindowsSubprocessTransport�	ExceptionrbZ_wait)rrn�args�shell�stdin�stdout�stderr�bufsizeri�kwargsrzZtranspr+�errrrr�_make_subprocess_transportrs

z,ProactorEventLoop._make_subprocess_transport)N)N)r1r2r3r4rrgrrpryr�r5rr)rrr/s	/c@s�eZdZdZd1dd�Zdd�Zdd�Zd2d
d�Zdd
�Zd3dd�Z	d4dd�Z
dd�Zdd�Zdd�Z
edd��Zd5dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd6d)d*�Zd+d,�Zd-d.�Zd/d0�Zd	S)7rz#Proactor implementation using IOCP.���cCsDd|_g|_tjtjtd|�|_i|_tj	�|_
g|_tj	�|_dS)Nr)
r)�_resultsr
�CreateIoCompletionPort�INVALID_HANDLE_VALUEr[�_iocp�_cacherRrSr9�
_unregistered�_stopped_serving)rZconcurrencyrrrr�s
zIocpProactor.__init__cCsd|jjt|j�t|j�fS)Nz<%s overlapped#=%s result#=%s>)rr1�lenr�r�)rrrr�__repr__�szIocpProactor.__repr__cCs
||_dS)N)r))rrrrr�set_loop�szIocpProactor.set_loopNcCs |js|j|�|j}g|_|S)N)r�r=)r�timeoutrXrrr�select�s

zIocpProactor.selectcCs|jj�}|j|�|S)N)r)r{r/)r�valuer?rrr�_result�s

zIocpProactor._resultrcCsz|j|�tjt�}y4t|tj�r6|j|j�||�n|j|j�|�Wnt	k
rb|j
d�SXdd�}|j|||�S)N�cSsJy|j�Stk
rD}z |jtjkr2t|j��n�WYdd}~XnXdS)N)�	getresultr(rAr
�ERROR_NETNAME_DELETED�ConnectionResetErrorr~)ro�keyrr+rrr�finish_recv�sz&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocpr
�
Overlappedr[�
isinstance�socketZWSARecvrtZReadFile�BrokenPipeErrorr��	_register)r�conn�nbytesr_rr�rrr�recv�s

	zIocpProactor.recvcCsZ|j|�tjt�}t|tj�r4|j|j�||�n|j|j�|�dd�}|j	|||�S)NcSsJy|j�Stk
rD}z |jtjkr2t|j��n�WYdd}~XnXdS)N)r�r(rAr
r�r�r~)ror�rr+rrr�finish_send�sz&IocpProactor.send.<locals>.finish_send)
r�r
r�r[r�r�ZWSASendrtZ	WriteFiler�)rr��bufr_rr�rrr�send�s

	zIocpProactor.sendcsz|j��|j�j��tjt�}|j�j��j����fdd�}tdd��}|j	|�|�}||��}t
j||jd�|S)NcsD|j�tjd�j��}�jtjtj|��j	�j
����j�fS)Nz@P)r��structZpackrt�
setsockoptr��
SOL_SOCKETr
ZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)ror�rr�)r��listenerrr�
finish_accept�s
z*IocpProactor.accept.<locals>.finish_acceptcss4y|EdHWn tjk
r.|j��YnXdS)N)rrurb)r%r�rrr�accept_coro�s
z(IocpProactor.accept.<locals>.accept_coro)r)
r��_get_accept_socket�familyr
r�r[ZAcceptExrtrr�rZ
ensure_futurer))rr�rr�r�r%�coror)r�r�r�accept�s

		
zIocpProactor.acceptcs�|j��ytj�j��j�WnBtk
rb}z&|jtjkr@��j	�ddkrR�WYdd}~XnXtj
t�}|j�j�|��fdd�}|j
|�|�S)Nrrcs|j��jtjtjd��S)Nr)r�r�r�r�r
ZSO_UPDATE_CONNECT_CONTEXT)ror�r)r�rr�finish_connects
z,IocpProactor.connect.<locals>.finish_connect)r�r
Z	BindLocalrtr�r(rA�errnoZ	WSAEINVALZgetsocknamer�r[Z	ConnectExr�)rr�r �err�r)r�r�connect�s

zIocpProactor.connectcsJ|j��tjt�}|j�j��}|r0|j��S�fdd�}|j|�|�S)Ncs|j��S)N)r�)ror�r)rarr�finish_accept_pipesz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�r
r�r[ZConnectNamedPipertr�r�)rrarZ	connectedr�r)rarrs
s


zIocpProactor.accept_pipeccszt}xjytj|�}PWn0tk
rF}z|jtjkr6�WYdd}~XnXt|dt�}tj	||j
d�EdHqWtj|�S)N�)r)
�CONNECT_PIPE_INIT_DELAYr
ZConnectPiper(rAZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYrZsleepr)r	r\)rr Zdelayr:r+rrrrjs
zIocpProactor.connect_pipecCs|j||d�S)z�Wait for a handle.

        Return a Future object. The result of the future is True if the wait
        completed, or False if the wait did not complete (on timeout).
        F)�_wait_for_handle)rr:r�rrr�wait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd�}||_|S)NT)r�rE)rrFZ
done_callbackr?rrrrO7szIocpProactor._wait_cancelcs�|dkrtj}ntj|d�}tjt�}tj||j|j	|�}|rTt
||||jd��nt|||||jd���j
rv�j
d=�fdd�}�|d|f|j|j	<�S)Ng@�@)rrcs�j�S)N)r=)ror�r)rmrr�finish_wait_for_handleRsz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handlerr)r<�INFINITE�math�ceilr
r�r[ZRegisterWaitWithQueuer�r rDr)rHrr�)rr:r�Z
_is_cancel�msrr;r�r)rmrr�>s


	zIocpProactor._wait_for_handlecCs0||jkr,|jj|�tj|j�|jdd�dS)Nr)r9r]r
r�rtr�)r�objrrrr�^s
z IocpProactor._register_with_iocpcCs�t||jd�}|jr|jd=|jsjy|dd|�}Wn,tk
r^}z|j|�WYdd}~XnX|j|�||||f|j|j<|S)N)rrr)	rr)rrr(r.r/r�r )rrr��callbackrmr�r�rrrr�hs

zIocpProactor._registercCs|jj|�dS)a
Unregister an overlapped object.

        Call this method when its future has been cancelled. The event can
        already be signalled (pending in the proactor event queue). It is also
        safe if the event is never signalled (because it was cancelled).
        N)r�r>)rrrrrrN�szIocpProactor._unregistercCstj|�}|jd�|S)Nr)r�r�)rr��srrrr��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��ntj|d�}|tkr>td���xtj|j|�}|dkrZPd}|\}}}}y|jj|�\}}	}
}WnVt	k
r�|j
j�r�|j
jdd||||fd��|dtj
fkr�tj|�wBYnX|
|jkr�|j�qB|j�sBy||||	�}Wn:tk
�r@}
z|j|
�|jj|�WYdd}
~
XqBX|j|�|jj|�qBWx |jD]}	|jj|	jd��qdW|jj�dS)Nrznegative timeoutg@�@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#�status)r��
ValueErrorr�r�r
ZGetQueuedCompletionStatusr�r��pop�KeyErrorr)Z	get_debugr*r�r<rMr�r'�doner(r.r�r>r/r�r rc)rr�r�r�r�Ztransferredr�r rmrr�r�r�r�rrrr=�sJ






zIocpProactor._pollcCs|jj|�dS)N)r�r])rr�rrr�
_stop_serving�szIocpProactor._stop_servingcCs�x�t|jj��D]�\}\}}}}|j�r*qt|t�r6qy|j�Wqtk
r�}z8|jdk	r�d||d�}|j	rz|j	|d<|jj
|�WYdd}~XqXqWx|jr�|jd�s�tj
d�q�Wg|_|jdk	r�tj|j�d|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)�listr��itemsZ	cancelledr�rDr'r(r)rr*r=r�debugr�r�r<rM)rr r?rr�r�r+r,rrrrb�s, 


"

zIocpProactor.closecCs|j�dS)N)rb)rrrrrd�szIocpProactor.__del__)r�)N)r)r)N)N)r1r2r3r4rr�r�r�r�r�r�r�r�rsrrjr�rOr�r�r�rNr�r=r�rbrdrrrrr�s.





 
	
7 c@seZdZdd�ZdS)r|c
sPtj|f|||||d�|���_�fdd�}�jjjt�jj��}	|	j|�dS)N)rr�r�r�r�cs�jj�}�j|�dS)N)�_procZpollZ_process_exited)rm�
returncode)rrrr��s
z4_WindowsSubprocessTransport._start.<locals>.callback)	r	�Popenr�r)rIr��intr7rv)
rr~rr�r�r�r�r�r�rmr)rr�_start�sz"_WindowsSubprocessTransport._startN)r1r2r3r�rrrrr|�sr|c@seZdZeZdS)�_WindowsDefaultEventLoopPolicyN)r1r2r3r
Z
_loop_factoryrrrrr�sr�)-r4r<r�r�r�r�rR�rrrrrrr	r
Z
coroutinesr�logr�__all__r[r�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerr6rDrH�objectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r
ZBaseDefaultEventLoopPolicyr�rrrrr�<module>sL0J4;]kPK=�\6߾ê�subprocess.cpython-36.pycnu�[���3


 \��@s�ddgZddlZddlmZddlmZddlmZddlmZdd	lmZdd
l	m
Z
ejZejZej
Z
Gdd�dejej�ZGd
d�d�Zeddddejfdd��Zeddddejd�dd��ZdS)�create_subprocess_exec�create_subprocess_shell�N�)�events)�	protocols)�streams)�tasks)�	coroutine)�loggercsPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)�SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.cs<t�j|d�||_d|_|_|_d|_d|_g|_dS)N)�loopF)	�super�__init__�_limit�stdin�stdout�stderr�
_transport�_process_exited�	_pipe_fds)�self�limitr)�	__class__��*/usr/lib64/python3.6/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk	r$|jd|j�|jdk	r>|jd|j�|jdk	rX|jd|j�ddj|�S)Nzstdin=%rz	stdout=%rz	stderr=%rz<%s>� )r�__name__r�appendrr�join)r�inforrr�__repr__s



z!SubprocessStreamProtocol.__repr__cCs�||_|jd�}|dk	rDtj|j|jd�|_|jj|�|jj	d�|jd�}|dk	r�tj|j|jd�|_
|j
j|�|jj	d�|jd�}|dk	r�tj||d|jd�|_dS)Nr)rr�r)�protocol�readerr)
r�get_pipe_transportr�StreamReaderr�_looprZ
set_transportrrr�StreamWriterr)r�	transportZstdout_transportZstderr_transportZstdin_transportrrr�connection_made(s&


z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk	r6|j|�dS)Nrr!)rrZ	feed_data)r�fd�datar#rrr�pipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs�|dkr,|j}|dk	r|j�|j|�dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|j�n
|j|�||jkr�|jj|�|j	�dS)Nrrr!)
r�closeZconnection_lostrrZfeed_eofZ
set_exceptionr�remove�_maybe_close_transport)rr*�exc�piper#rrr�pipe_connection_lostJs$



z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|j�dS)NT)rr/)rrrr�process_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|j�dkr$|jr$|jj�d|_dS)Nr)�lenrrrr-)rrrrr/es
z/SubprocessStreamProtocol._maybe_close_transport)r�
__module__�__qualname__�__doc__rr r)r,r2r3r/�
__classcell__rr)rrrs

rc@s~eZdZdd�Zdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zedd��Zedd��Z
edd��Zeddd��ZdS)�ProcesscCs8||_||_||_|j|_|j|_|j|_|j�|_dS)N)rZ	_protocolr&rrrZget_pid�pid)rr(r"rrrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr:)rrrrr uszProcess.__repr__cCs
|jj�S)N)rZget_returncode)rrrr�
returncodexszProcess.returncodeccs|jj�EdHS)zdWait until the process exit and return the process return code.

        This method is a coroutine.N)rZ_wait)rrrr�wait|szProcess.waitcCs|jj|�dS)N)r�send_signal)r�signalrrrr=�szProcess.send_signalcCs|jj�dS)N)r�	terminate)rrrrr?�szProcess.terminatecCs|jj�dS)N)r�kill)rrrrr@�szProcess.killccs�|jj�}|jj|�|r,tjd|t|��y|jj�EdHWn8tt	fk
rx}z|rhtjd||�WYdd}~XnX|r�tjd|�|jj
�dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r&�	get_debugr�writer
�debugr4Zdrain�BrokenPipeError�ConnectionResetErrorr-)r�inputrCr0rrr�_feed_stdin�s
 zProcess._feed_stdincCsdS)Nr)rrrr�_noop�sz
Process._noopccs�|jj|�}|dkr|j}n|dks(t�|j}|jj�rV|dkrDdnd}tjd||�|j	�EdH}|jj�r�|dkrzdnd}tjd||�|j
�|S)Nr!rrrz%r communicate: read %sz%r communicate: close %s)rr$r�AssertionErrorrr&rAr
rC�readr-)rr*r(�stream�name�outputrrr�_read_stream�s

zProcess._read_streamNccs�|dk	r|j|�}n|j�}|jdk	r2|jd�}n|j�}|jdk	rP|jd�}n|j�}tj||||jd�EdH\}}}|j�EdH||fS)Nrr!)r)	rGrHrrNrrZgatherr&r<)rrFrrrrrr�communicate�s


zProcess.communicate)N)rr5r6rr �propertyr;r	r<r=r?r@rGrHrNrOrrrrr9ks	r9c
+sP�dkrtj����fdd�}�j||f|||d�|��EdH\}}	t||	��S)Ncst��d�S)N)rr)rr)rrrr�<lambda>�sz)create_subprocess_shell.<locals>.<lambda>)rrr)r�get_event_loopZsubprocess_shellr9)
�cmdrrrrr�kwds�protocol_factoryr(r"r)rrrr�s)rrrrrc/sT�dkrtj����fdd�}�j||f|�|||d�|��EdH\}	}
t|	|
��S)Ncst��d�S)N)rr)rr)rrrrrQ�sz(create_subprocess_exec.<locals>.<lambda>)rrr)rrRZsubprocess_execr9)Zprogramrrrrr�argsrTrUr(r"r)rrrr�s)�__all__�
subprocess�rrrrZ
coroutinesr	�logr
�PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolrr9Z_DEFAULT_LIMITrrrrrr�<module>s(X]PK=�\�R�ӸA�Aproactor_events.cpython-36.pycnu�[���3


 \�O�@s�dZdgZddlZddlZddlmZddlmZddlmZddlmZdd	lm	Z	dd
lm
Z
ddlmZGdd
�d
e
j
e
j�ZGdd�dee
j�ZGdd�dee
j�ZGdd�de�ZGdd�deee
j�ZGdd�deee
j�ZGdd�dej�ZdS)z�Event loop using a proactor and related classes.

A proactor is a "notify-on-completion" multiplexer.  Currently a
proactor is only implemented on Windows with IOCP.
�BaseProactorEventLoop�N�)�base_events)�compat)�	constants)�futures)�sslproto)�
transports)�loggercs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejrXdd�Z
ddd�Zdd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncs�t�j||�|j|�||_||_||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	rh|jj
�|jj|jj|�|dk	r�|jjtj|d�dS)NrF)�super�__init__�
_set_extra�_sock�	_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_eof_writtenZ_attach�_loop�	call_soonZconnection_maderZ_set_result_unless_cancelled)�self�loop�sock�protocol�waiter�extra�server)�	__class__��//usr/lib64/python3.6/asyncio/proactor_events.pyr
s$



z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jdk	rN|jd|jj��|jdk	rh|jd|j�|jdk	r�|jd|j�|jr�t	|j�}|jd|�|j
r�|jd�dd	j|�S)
N�closed�closingzfd=%szread=%szwrite=%rzwrite_bufsize=%szEOF writtenz<%s>� )r"�__name__r�appendr�filenorrr�lenr�join)r�info�bufsizer#r#r$�__repr__/s"







z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)�_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs
||_dS)N)r)rrr#r#r$�set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$�get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$�
is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr
dSd|_|jd7_|jr@|jdkr@|jj|jd�|jdk	rZ|jj�d|_dS)NTr)	rrrrrr�_call_connection_lostr�cancel)rr#r#r$�closeNs

z _ProactorBasePipeTransport.closecCs*|jdk	r&tjd|t|d�|j�dS)Nzunclosed transport %r)�source)r�warnings�warn�ResourceWarningr7)rr#r#r$�__del__]s
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)�exc_info)�message�	exceptionZ	transportr)
�
isinstancerZ_FATAL_ERROR_IGNOREr�	get_debugr
�debug�call_exception_handlerr�_force_close)r�excr?r#r#r$�_fatal_errorcs
z'_ProactorBasePipeTransport._fatal_errorcCsj|jr
dSd|_|jd7_|jr4|jj�d|_|jrJ|jj�d|_d|_d|_|jj|j	|�dS)NTrr)
rrrr6rrrrrr5)rrFr#r#r$rEps

z'_ProactorBasePipeTransport._force_closecCs^z|jj|�Wdt|jd�r,|jjtj�|jj�d|_|j}|dk	rX|j	�d|_XdS)N�shutdown)
rZconnection_lost�hasattrrrH�socketZ	SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk	r|t|j�7}|S)N)rrr+)r�sizer#r#r$�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r(�
__module__�__qualname__�__doc__r
r/rr2r3r4r7rZPY34r<rGrEr5rL�
__classcell__r#r#)r"r$rs

rcs<eZdZdZd�fdd�	Zdd�Zdd�Zdd	d
�Z�ZS)
�_ProactorReadPipeTransportzTransport for read pipes.Ncs4t�j||||||�d|_d|_|jj|j�dS)NF)rr
�_paused�_reschedule_on_resumerr�
_loop_reading)rrrrrr r!)r"r#r$r
�sz#_ProactorReadPipeTransport.__init__cCs0|js|jrdSd|_|jj�r,tjd|�dS)NTz%r pauses reading)rrRrrBr
rC)rr#r#r$�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsP|js|jrdSd|_|jr6|jj|j|j�d|_|jj�rLtj	d|�dS)NFz%r resumes reading)
rrRrSrrrTrrBr
rC)rr#r#r$�resume_reading�s
z)_ProactorReadPipeTransport.resume_readingcCs�|jrd|_dSd}�z@yf|dk	rN|j|ks@|jdkr<|js@t�d|_|j�}|jr\d}dS|dkrhdS|jjj|j	d�|_Wn�t
k
r�}z2|js�|j|d�n|jj�r�t
jddd�WYdd}~Xn�tk
r�}z|j|�WYdd}~Xn^tk
�r$}z|j|d�WYdd}~Xn0tjk
�rD|j�s@�YnX|jj|j�Wd|�rl|jj|�n:|dk	�r�|jj��r�t
jd|�|jj�}|�s�|j�XdS)NT�iz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rRrSrr�AssertionError�resultr�	_proactor�recvr�ConnectionAbortedErrorrGrBr
rC�ConnectionResetErrorrE�OSErrorr�CancelledError�add_done_callbackrTrZ
data_receivedZeof_receivedr7)r�fut�datarFZ	keep_openr#r#r$rT�sL



z(_ProactorReadPipeTransport._loop_reading)NNN)N)	r(rMrNrOr
rUrVrTrPr#r#)r"r$rQ�s
rQc@s:eZdZdZdd�Zd
dd�Zdd�Zd	d
�Zdd�ZdS)�_ProactorBaseWritePipeTransportzTransport for write pipes.cCs�t|tttf�s&dt|�j}t|��|jr4td��|s<dS|j	rj|j	t
jkrXtj
d�|j	d7_	dS|jdkr�|jdks�t�|jt|�d�n.|js�t|�|_|j�n|jj|�|j�dS)Nz3data argument must be a bytes-like object, not '%s'zwrite_eof() already calledzsocket.send() raised exception.r)rb)rA�bytes�	bytearray�
memoryview�typer(�	TypeErrorr�RuntimeErrorrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningrrrX�
_loop_writing�_maybe_pause_protocol�extend)rrb�msgr#r#r$�write�s*



z%_ProactorBaseWritePipeTransport.writeNcCs4y�||jkst�d|_d|_|r(|j�|dkr<|j}d|_|st|jrV|jj|jd�|j	rj|j
jtj
�|j�n\|jjj|j
|�|_|jj�s�|jdks�t�t|�|_|jj|j�|j�n|jj|j�Wn\tk
�r}z|j|�WYdd}~Xn0tk
�r.}z|j|d�WYdd}~XnXdS)Nrz#Fatal write error on pipe transport)rrXrrYrrrrr5rrrHrJ�SHUT_WRZ_maybe_resume_protocolrZ�send�doner+r`rkrlr]rEr^rG)r�frbrFr#r#r$rk
s4



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS)NTr#)rr#r#r$�
can_write_eof0sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|j�dS)N)r7)rr#r#r$�	write_eof3sz)_ProactorBaseWritePipeTransport.write_eofcCs|jd�dS)N)rE)rr#r#r$�abort6sz%_ProactorBaseWritePipeTransport.abort)NN)	r(rMrNrOrorkrtrurvr#r#r#r$rc�s$
#rccs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs4t�j||�|jjj|jd�|_|jj|j�dS)N�)	rr
rrZr[rrr`�_pipe_closed)r�args�kw)r"r#r$r
;sz$_ProactorWritePipeTransport.__init__cCsv|j�rdS|j�dkst�|jr4|jdks0t�dS||jksLt||jf��d|_|jdk	rj|jt��n|j�dS)NrW)	Z	cancelledrYrXrrrrE�BrokenPipeErrorr7)rrar#r#r$ry@s
z(_ProactorWritePipeTransport._pipe_closed)r(rMrNr
ryrPr#r#)r"r$rw:srwc@s eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFr#)rr#r#r$rtUsz*_ProactorDuplexPipeTransport.can_write_eofcCst�dS)N)�NotImplementedError)rr#r#r$ruXsz&_ProactorDuplexPipeTransport.write_eofN)r(rMrNrOrtrur#r#r#r$r}Psr}cs:eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Z�ZS)�_ProactorSocketTransportz Transport for connected sockets.Ncs$t�j||||||�tj|�dS)N)rr
rZ_set_nodelay)rrrrrr r!)r"r#r$r
asz!_ProactorSocketTransport.__init__cCs�||jd<y|j�|jd<Wn4tjtfk
rP|jj�rLtjd|dd�YnXd|jkr�y|j	�|jd<Wn4tjtfk
r�|jj�r�tjd|dd�YnXdS)NrJZsocknamezgetsockname() failed on %rT)r>�peernamezgetpeername() failed on %r)
r1ZgetsocknamerJ�error�AttributeErrorrrBr
rjZgetpeername)rrr#r#r$rfs



z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rtvsz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdkr.|jjtj�dS)NT)rrrrrHrJrp)rr#r#r$ruys

z"_ProactorSocketTransport.write_eof)NNN)	r(rMrNrOr
rrtrurPr#r#)r"r$r\srcs�eZdZ�fdd�Zd-dd�Zd.ddddd�dd	�Zd/d
d�Zd0dd
�Zd1dd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd2d d!�Zd"d#�Zd3d%d&�Zd'd(�Zd)d*�Zd+d,�Z�ZS)4rcsHt�j�tjd|jj�||_||_d|_i|_	|j
|�|j�dS)NzUsing proactor: %s)rr
r
rCr"r(rZ�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe)rZproactor)r"r#r$r
�s

zBaseProactorEventLoop.__init__NcCst||||||�S)N)r)rrrrr r!r#r#r$�_make_socket_transport�s
z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer r!c
Cs<tj�std��tj||||||�}	t|||	||d�|	jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler~ZSSLProtocolrZ_app_transport)
rZrawsockr�
sslcontextrr�r�r r!Zssl_protocolr#r#r$�_make_ssl_transport�s
z)BaseProactorEventLoop._make_ssl_transportcCst|||||�S)N)r})rrrrr r#r#r$�_make_duplex_pipe_transport�sz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�S)N)rQ)rrrrr r#r#r$�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�S)N)rw)rrrrr r#r#r$�_make_write_pipe_transport�sz0BaseProactorEventLoop._make_write_pipe_transportcsP|j�rtd��|j�rdS|j�|j�|jj�d|_d|_t�j�dS)Nz!Cannot close a running event loop)	Z
is_runningri�	is_closed�_stop_accept_futures�_close_self_piperZr7r�r)r)r"r#r$r7�s
zBaseProactorEventLoop.closecCs|jj||�S)N)rZr[)rr�nr#r#r$�	sock_recv�szBaseProactorEventLoop.sock_recvcCs|jj||�S)N)rZrq)rrrbr#r#r$�sock_sendall�sz"BaseProactorEventLoop.sock_sendallcCs|jj||�S)N)rZZconnect)rrZaddressr#r#r$�sock_connect�sz"BaseProactorEventLoop.sock_connectcCs|jj|�S)N)rZ�accept)rrr#r#r$�sock_accept�sz!BaseProactorEventLoop.sock_acceptcCst�dS)N)r~)rr#r#r$�_socketpair�sz!BaseProactorEventLoop._socketpaircCsL|jdk	r|jj�d|_|jj�d|_|jj�d|_|jd8_dS)Nr)r�r6�_ssockr7�_csock�
_internal_fds)rr#r#r$r��s



z&BaseProactorEventLoop._close_self_pipecCsF|j�\|_|_|jjd�|jjd�|jd7_|j|j�dS)NFr)r�r�r�Zsetblockingr�r�_loop_self_reading)rr#r#r$r��s
z%BaseProactorEventLoop._make_self_pipecCs�y$|dk	r|j�|jj|jd�}WnHtjk
r:dStk
rl}z|jd||d��WYdd}~XnX||_|j	|j
�dS)Niz.Error on reading from the event loop self pipe)r?r@r)rYrZr[r�rr_�	ExceptionrDr�r`r�)rrsrFr#r#r$r��sz(BaseProactorEventLoop._loop_self_readingcCs|jjd�dS)N�)r�rq)rr#r#r$�_write_to_self�sz$BaseProactorEventLoop._write_to_self�dcs&d������fdd�	��j��dS)Ncs"y�|dk	rl|j�\}}�jr,tjd�||���}�dk	rV�j||�dd|i�d�n�j||d|i�d��j�rxdS�jj��}Wn~t	k
r�}zD�j
�dkr��jd|�d���j�n�jr�tjd	�dd
�WYdd}~Xn8t
jk
�r�j�YnX|�j�j
�<|j��dS)Nz#%r got a new connection from %r: %rTr�)r�r r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>���)rYZ_debugr
rCr�r�r�rZr�r^r*rDr7rr_r�r`)rsZconnZaddrrrF)r�protocol_factoryrr!rr�r#r$r�s>


z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r)rr�rr�r!Zbacklogr#)rr�rr!rr�r$�_start_serving�s$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ
event_listr#r#r$�_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jj�D]}|j�qW|jj�dS)N)r��valuesr6�clear)rZfuturer#r#r$r�$sz*BaseProactorEventLoop._stop_accept_futurescCs |j�|jj|�|j�dS)N)r�rZ�
_stop_servingr7)rrr#r#r$r�)sz#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr�)r(rMrNr
r�r�r�r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�rPr#r#)r"r$r�s4







()rO�__all__rJr9�rrrrrr	�logr
Z_FlowControlMixinZ
BaseTransportrZ
ReadTransportrQZWriteTransportrcrwZ	Transportr}rZ
BaseEventLooprr#r#r#r$�<module>s2MT
#PK=�\G��4GGbase_tasks.cpython-36.pycnu�[���3


 \��@sDddlZddlZddlmZddlmZdd�Zdd�Zd	d
�ZdS)�N�)�base_futures)�
coroutinescCsTtj|�}|jrd|d<tj|j�}|jdd|�|jdk	rP|jdd|j�|S)NZ
cancellingrrz	coro=<%s>�zwait_for=%r)rZ_future_repr_infoZ_must_cancelrZ_format_coroutine�_coro�insertZ_fut_waiter)�task�info�coro�r�*/usr/lib64/python3.6/asyncio/base_tasks.py�_task_repr_infos

r
cCs�g}y|jj}Wntk
r,|jj}YnX|dk	rxx6|dk	rl|dk	rZ|dkrRP|d8}|j|�|j}q8W|j�nL|jdk	r�|jj}x8|dk	r�|dk	r�|dkr�P|d8}|j|j	�|j
}q�W|S)Nrr)r�cr_frame�AttributeError�gi_frame�append�f_back�reverse�
_exception�
__traceback__�tb_frame�tb_next)r�limitZframes�f�tbrrr�_task_get_stacks0






rcCs�g}t�}xj|j|d�D]Z}|j}|j}|j}|j}	||krP|j|�tj|�tj	|||j
�}
|j|||	|
f�qW|j}|s�t
d||d�n*|dk	r�t
d||d�nt
d||d�tj||d�|dk	r�x$tj|j|�D]}
t
|
|dd�q�WdS)N)rzNo stack for %r)�filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):�)r�end)�setZ	get_stack�f_lineno�f_code�co_filename�co_name�add�	linecache�
checkcache�getline�	f_globalsrr�print�	traceback�
print_list�format_exception_only�	__class__)rrr�extracted_listZcheckedr�lineno�co�filename�name�line�excrrr�_task_print_stack3s0


r5)r%r*rrrr
rr5rrrr�<module>sPK=�\H�V1  coroutines.cpython-36.opt-2.pycnu�[���3


 \+�@s�dddgZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
l
mZejdZejjo�eejjd��ZyejZejZWnek
r�dZdZYnXy
ejZWnek
r�d
d�ZYnXyddlmZ m!Z"Wne#k
�r*dZ Z"YnXdd�Z$e$�Z%[$dd�Z&Gdd�d�Z'dd�Ze(�Z)dd�Zej*e'fZ+e dk	�r�e+e f7Z+edk	�r�efe+Z+dd�Z,dd�Z-dS)�	coroutine�iscoroutinefunction�iscoroutine�N�)�compat)�	constants)�events)�base_futures)�loggerZ
YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF�)�funcrr�*/usr/lib64/python3.6/asyncio/coroutines.py�<lambda>/sr)�	Coroutine�	AwaitablecCsFGdd�d�}dd�}d}|�}||�}t|�|j|�|j|fkS)	Nc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
z!has_yield_from_bug.<locals>.MyGencSs
d|_dS)N)�	send_args)�selfrrr
�__init__;sz*has_yield_from_bug.<locals>.MyGen.__init__cSs|S)Nr)rrrr
�__iter__=sz*has_yield_from_bug.<locals>.MyGen.__iter__cSsdS)N�*r)rrrr
�__next__?sz*has_yield_from_bug.<locals>.MyGen.__next__cWs
||_dS)N)r)rZwhatrrr
�sendAsz&has_yield_from_bug.<locals>.MyGen.sendN)�__name__�
__module__�__qualname__rrrrrrrr
�MyGen:srcss|EdHdS)Nr)�genrrr
�yield_from_genDsz*has_yield_from_bug.<locals>.yield_from_genr��)rrr)�nextrr)rr�valuer�cororrr
�has_yield_from_bug9s

r#cCs
t|d�S)N)�CoroWrapper)rrrr
�
debug_wrapperPsr%c@s�eZdZd%dd�Zdd�Zdd�Zdd	�Zer8d
d�Zndd�Zd&d
d�Z	dd�Z
edd��Zedd��Z
edd��Zejr�dd�Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zd#d$�ZdS)'r$NcCs>||_||_tjtjd��|_t|dd�|_t|dd�|_	dS)Nrrr)
rrr�
extract_stack�sys�	_getframe�_source_traceback�getattrrr)rrrrrr
r[s
zCoroWrapper.__init__cCs@t|�}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>���)�_format_coroutiner)�	__class__r)r�	coro_repr�framerrr
�__repr__cs

zCoroWrapper.__repr__cCs|S)Nr)rrrr
rjszCoroWrapper.__iter__cCs|jjd�S)N)rr)rrrr
rmszCoroWrapper.__next__cGs4tj�}|j}|jj|jtkr(|d}|jj|�S)Nr)	r'r(�f_back�f_code�co_code�f_lasti�_YIELD_FROMrr)rr!r/Zcallerrrr
rus
zCoroWrapper.sendcCs|jj|�S)N)rr)rr!rrr
r}scCs|jj|||�S)N)r�throw)r�typer!�	tracebackrrr
r6�szCoroWrapper.throwcCs
|jj�S)N)r�close)rrrr
r9�szCoroWrapper.closecCs|jjS)N)r�gi_frame)rrrr
r:�szCoroWrapper.gi_framecCs|jjS)N)r�
gi_running)rrrr
r;�szCoroWrapper.gi_runningcCs|jjS)N)r�gi_code)rrrr
r<�szCoroWrapper.gi_codecCs,t|jdd�}|dk	r(tdj|j|���|S)N�cr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r�RuntimeError�format)rr=rrr
�	__await__�szCoroWrapper.__await__cCs|jjS)N)r�gi_yieldfrom)rrrr
rA�szCoroWrapper.gi_yieldfromcCs|jjS)N)rr=)rrrr
r=�szCoroWrapper.cr_awaitcCs|jjS)N)r�
cr_running)rrrr
rB�szCoroWrapper.cr_runningcCs|jjS)N)r�cr_code)rrrr
rC�szCoroWrapper.cr_codecCs|jjS)N)r�cr_frame)rrrr
rD�szCoroWrapper.cr_framecCs�t|dd�}t|dd�}|dkr,t|dd�}|dk	r�|jd
kr�d|}t|df�}|r�djtj|��}|dtj�d	�7}||j�7}tj	|�dS)Nrr:rDrz%r was never yielded fromr)�zB
Coroutine object created at (most recent call last, truncated to z last lines):
r+)
r*r4�joinr8�format_listrZDEBUG_STACK_DEPTH�rstripr
�error)rrr/�msg�tbrrr
�__del__�szCoroWrapper.__del__)N)NN)rrrrr0rr�_YIELD_FROM_BUGrr6r9�propertyr:r;r<rZPY35r@rAr=rBrCrDrLrrrr
r$Xs(


r$cspt��r�Stj��r��ntj���fdd���tsNtdkrD�}qft��}ntj����fdd��}t|_|S)Nc?sv�||�}tj|�s(tj|�s(t|t�r4|EdH}n>tdk	rry
|j}Wntk
rZYnXt|t�rr|�EdH}|S)N)	r	Zisfuture�inspectZisgenerator�
isinstancer$�
_AwaitableABCr@�AttributeError)�args�kw�resZ
await_meth)rrr
r"�s



zcoroutine.<locals>.corocs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)N)rrrrr+)r$r)r*rr)rS�kwds�w)r"rrr
�wrapper�szcoroutine.<locals>.wrapper)�_inspect_iscoroutinefunctionrO�isgeneratorfunction�	functools�wraps�_DEBUG�_types_coroutine�
_is_coroutine)rrXr)r"rr
r�s


cCst|dd�tkpt|�S)Nr_)r*r_rY)rrrr
r�scCs
t|t�S)N)rP�_COROUTINE_TYPES)�objrrr
rsc
Cst|d�r�t|d�r�t|dt|dt|�j��}dj|�}d}y
|j}Wn4tk
r~y
|j}Wntk
rxYnXYnX|r�dj|�S|Sd}t|t	�r�|j
}|j}|dk	r�dj|�}n|}|dkr�tj
|fi�}d}t|d�r�|jr�|j}nt|d��r|j�r|j}d}t|d��r0|j�r0|j}nt|d	��rJ|j�rJ|j}d
}|�rb|j�rb|j}d}|}t|t	��r�tj|j
��r�|j
dk	�r�tj|j
�}	|	dk	�r�|	\}}|dk�r�d|||f}nd
|||f}n:|dk	�r�|j}d|||f}n|�r|j}d|||f}|S)NrCr<rrz{}()Fz
{} runningrDr:z<empty co_filename>rz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)�hasattrr*r7rr?rBrRr;rPr$rrrZ_format_callbackrCr<rDr:�co_filenamerOrZZ_get_function_source�f_lineno�co_firstlineno)
r"Z	coro_nameZrunningrZ	coro_codeZ
coro_frame�filename�linenor.�sourcerrr
r,sx







r,).�__all__r[rOZopcode�osr'r8�typesrErrrr	�logr
Zopmapr5�flags�ignore_environment�bool�environ�getr]rr^�
CoroutineTypeZ_types_CoroutineTyperRrrY�collections.abcrZ
_CoroutineABCrrQ�ImportErrorr#rMr%r$�objectr_�
GeneratorTyper`rr,rrrr
�<module>sZ




j:




PK=�\�`���protocols.cpython-36.opt-2.pycnu�[���3


 \��@sNddddgZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)	�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocolc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCsdS)N�)�selfZ	transportrr�)/usr/lib64/python3.6/asyncio/protocols.py�connection_madeszBaseProtocol.connection_madecCsdS)Nr)r�excrrr�connection_lostszBaseProtocol.connection_lostcCsdS)Nr)rrrr�
pause_writing!szBaseProtocol.pause_writingcCsdS)Nr)rrrr�resume_writing7szBaseProtocol.resume_writingN)�__name__�
__module__�__qualname__rr
rrrrrrrs
c@seZdZdd�Zdd�ZdS)rcCsdS)Nr)r�datarrr�
data_receivedXszProtocol.data_receivedcCsdS)Nr)rrrr�eof_received^szProtocol.eof_receivedN)r
rrrrrrrrr>sc@seZdZdd�Zdd�ZdS)rcCsdS)Nr)rrZaddrrrr�datagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)Nr)rr	rrr�error_receivedmszDatagramProtocol.error_receivedN)r
rrrrrrrrrgsc@s$eZdZdd�Zdd�Zdd�ZdS)rcCsdS)Nr)r�fdrrrr�pipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)Nr)rrr	rrr�pipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)Nr)rrrr�process_exited�sz!SubprocessProtocol.process_exitedN)r
rrrrrrrrrrtsN)�__all__rrrrrrrr�<module>s
7)
PK=�\�H�O�O#windows_events.cpython-36.opt-2.pycnu�[���3


 \�l�@s�ddlZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlmZd
dddgZdZdZdZdZdZdZGdd�de	j�ZGdd�de	j�ZGdd�de�ZGdd�de�ZGdd�de�Z Gd d!�d!ej!�Z"Gd"d�de
j#�Z$Gd#d�d�Z%Gd$d%�d%ej&�Z'e"Z(Gd&d'�d'ej)�Z*e*Z+dS)(�N�)�events)�base_subprocess)�futures)�proactor_events)�selector_events)�tasks)�
windows_utils)�_overlapped)�	coroutine)�logger�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicyl��i�i�g����MbP?g�������?csZeZdZdd��fdd�
Z�fdd�Zdd�Z�fd	d
�Z�fdd�Z�fd
d�Z�Z	S)�_OverlappedFutureN)�loopcs&t�j|d�|jr|jd=||_dS)N)rr���)�super�__init__�_source_traceback�_ov)�self�ovr)�	__class__��./usr/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@t�j�}|jdk	r<|jjr dnd}|jdd||jjf�|S)N�pendingZ	completedrzoverlapped=<%s, %#x>)r�
_repr_inforr�insert�address)r�info�state)rrrr3s


z_OverlappedFuture._repr_infocCsr|jdkrdSy|jj�WnJtk
rf}z.d||d�}|jrJ|j|d<|jj|�WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)�message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextrrr�_cancel_overlapped:s

z$_OverlappedFuture._cancel_overlappedcs|j�t�j�S)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcst�j|�|j�dS)N)r�
set_exceptionr-)rr$)rrrr.Nsz_OverlappedFuture.set_exceptioncst�j|�d|_dS)N)r�
set_resultr)r�result)rrrr/Rsz_OverlappedFuture.set_result)
�__name__�
__module__�__qualname__rrr-r'r.r/�
__classcell__rr)rrr'srcsjeZdZdd��fdd�
Zdd�Z�fdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	�fdd�Z
�ZS)�_BaseWaitHandleFutureN)rcs8t�j|d�|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jd�tjkS)Nr)�_winapiZWaitForSingleObjectr6Z
WAIT_OBJECT_0)rrrr�_pollhsz_BaseWaitHandleFuture._pollcs\t�j�}|jd|j�|jdk	r>|j�r0dnd}|j|�|jdk	rX|jd|j�|S)Nz
handle=%#xZsignaledZwaitingzwait_handle=%#x)rr�appendr6r<r7)rr!r")rrrrms



z _BaseWaitHandleFuture._repr_infocCs
d|_dS)N)r)r�futrrr�_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs�|js
dSd|_|j}d|_ytj|�WnZtk
r�}z>|jtjkrtd||d�}|jrd|j|d<|jj	|�dSWYdd}~XnX|j
d�dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r8r7r
ZUnregisterWaitr(�winerror�ERROR_IO_PENDINGrr)r*r?)rr:r+r,rrr�_unregister_wait|s"
z&_BaseWaitHandleFuture._unregister_waitcs|j�t�j�S)N)rBrr')r)rrrr'�sz_BaseWaitHandleFuture.cancelcs|j�t�j|�dS)N)rBrr.)rr$)rrrr.�sz#_BaseWaitHandleFuture.set_exceptioncs|j�t�j|�dS)N)rBrr/)rr0)rrrr/�sz _BaseWaitHandleFuture.set_result)r1r2r3rr<rr?rBr'r.r/r4rr)rrr5Ws
r5csBeZdZdd��fdd�
Zdd�Z�fdd�Z�fd	d
�Z�ZS)�_WaitCancelFutureN)rcst�j||||d�d|_dS)N)r)rr�_done_callback)rr�eventr:r)rrrr�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeError)rrrrr'�sz_WaitCancelFuture.cancelcs$t�j|�|jdk	r |j|�dS)N)rr/rD)rr0)rrrr/�s
z_WaitCancelFuture.set_resultcs$t�j|�|jdk	r |j|�dS)N)rr.rD)rr$)rrrr.�s
z_WaitCancelFuture.set_exception)r1r2r3rr'r/r.r4rr)rrrC�srCcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureN)rcs<t�j||||d�||_d|_tjdddd�|_d|_dS)N)rTF)rr�	_proactorZ_unregister_proactorr
ZCreateEvent�_event�
_event_fut)rrr9r:�proactorr)rrrr�s
z_WaitHandleFuture.__init__csF|jdk	r"tj|j�d|_d|_|jj|j�d|_t�j|�dS)N)	rIr;�CloseHandlerJrH�_unregisterrrr?)rr>)rrrr?�s
	z%_WaitHandleFuture._unregister_wait_cbcCs�|js
dSd|_|j}d|_ytj||j�WnZtk
r�}z>|jtjkrxd||d�}|jrh|j|d<|j	j
|�dSWYdd}~XnX|jj|j|j
�|_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r8r7r
ZUnregisterWaitExrIr(r@rArr)r*rH�_wait_cancelr?rJ)rr:r+r,rrrrB�s$

z"_WaitHandleFuture._unregister_wait)r1r2r3rr?rBr4rr)rrrG�srGc@s8eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZeZdS)�
PipeServercCs,||_tj�|_d|_d|_|jd�|_dS)NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr rrrr�s

zPipeServer.__init__cCs|j|jd�}|_|S)NF)rTrV)r�tmprrr�_get_unconnected_pipe�sz PipeServer._get_unconnected_pipec	Csr|j�rdStjtjB}|r&|tjO}tj|j|tjtjBtj	Btj
tjtjtj
tj�}tj|�}|jj|�|S)N)�closedr;ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperPZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr	ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerS�add)r�first�flags�h�piperrrrVs


zPipeServer._server_pipe_handlecCs
|jdkS)N)rP)rrrrrYszPipeServer.closedcCsV|jdk	r|jj�d|_|jdk	rRx|jD]}|j�q,Wd|_d|_|jj�dS)N)rUr'rPrS�closerT�clear)rr`rrrras


zPipeServer.closeN)	r1r2r3rrXrVrYra�__del__rrrrrO�s
rOc@seZdZdd�ZdS)�_WindowsSelectorEventLoopcCstj�S)N)r	�
socketpair)rrrr�_socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3rfrrrrrd(srdcsLeZdZd�fdd�	Zdd�Zedd��Zedd	��Zed
d
d��Z�Z	S)rNcs|dkrt�}t�j|�dS)N)rrr)rrK)rrrr2szProactorEventLoop.__init__cCstj�S)N)r	re)rrrrrf7szProactorEventLoop._socketpairccs8|jj|�}|EdH}|�}|j||d|id�}||fS)N�addr)�extra)rH�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr �fr`�protocol�transrrr�create_pipe_connection:s
z(ProactorEventLoop.create_pipe_connectioncs.t���d�����fdd�	��j���gS)Ncsd}yj|rL|j�}�jj|��j�r2|j�dS��}�j||d�id��j�}|dkr`dS�jj|�}Wn�t	k
r�}zH|r�|j
�d	kr��jd||d��|j�n�jr�t
jd|dd�WYdd}~Xn2tjk
r�|r�|j�YnX|�_|j��dS)
Nrg)rhrzPipe accept failed)r#r$r`zAccept pipe failed on pipe %rT)�exc_infor)r0rS�discardrYrarjrXrH�accept_piper(�filenor*Z_debugrZwarningr�CancelledErrorrU�add_done_callback)rlr`rmr+)r �loop_accept_piperkr�serverrrrvGs<

z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rOZ	call_soon)rrkr r)r rvrkrrwr�start_serving_pipeCs(
z$ProactorEventLoop.start_serving_pipec	ks�|j�}
t||||||||f|
|d�|	��}y|
EdHWn&tk
r`}z
|}
WYdd}~XnXd}
|
dk	r�|j�|j�EdH|
�|S)N)�waiterrh)�
create_future�_WindowsSubprocessTransport�	ExceptionraZ_wait)rrm�args�shell�stdin�stdout�stderr�bufsizerh�kwargsryZtranspr+�errrrr�_make_subprocess_transportrs

z,ProactorEventLoop._make_subprocess_transport)N)N)
r1r2r3rrfrrorxr�r4rr)rrr/s	/c@s�eZdZd0dd�Zdd�Zdd�Zd1d	d
�Zdd�Zd2dd�Zd3dd�Z	dd�Z
dd�Zdd�Ze
dd��Zd4dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd5d(d)�Zd*d+�Zd,d-�Zd.d/�ZdS)6r���cCsDd|_g|_tjtjtd|�|_i|_tj	�|_
g|_tj	�|_dS)Nr)
r)�_resultsr
�CreateIoCompletionPort�INVALID_HANDLE_VALUErZ�_iocp�_cacherQrRr8�
_unregistered�_stopped_serving)rZconcurrencyrrrr�s
zIocpProactor.__init__cCsd|jjt|j�t|j�fS)Nz<%s overlapped#=%s result#=%s>)rr1�lenr�r�)rrrr�__repr__�szIocpProactor.__repr__cCs
||_dS)N)r))rrrrr�set_loop�szIocpProactor.set_loopNcCs |js|j|�|j}g|_|S)N)r�r<)r�timeoutrWrrr�select�s

zIocpProactor.selectcCs|jj�}|j|�|S)N)r)rzr/)r�valuer>rrr�_result�s

zIocpProactor._resultrcCsz|j|�tjt�}y4t|tj�r6|j|j�||�n|j|j�|�Wnt	k
rb|j
d�SXdd�}|j|||�S)N�cSsJy|j�Stk
rD}z |jtjkr2t|j��n�WYdd}~XnXdS)N)�	getresultr(r@r
�ERROR_NETNAME_DELETED�ConnectionResetErrorr})rn�keyrr+rrr�finish_recv�sz&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocpr
�
OverlappedrZ�
isinstance�socketZWSARecvrsZReadFile�BrokenPipeErrorr��	_register)r�conn�nbytesr^rr�rrr�recv�s

	zIocpProactor.recvcCsZ|j|�tjt�}t|tj�r4|j|j�||�n|j|j�|�dd�}|j	|||�S)NcSsJy|j�Stk
rD}z |jtjkr2t|j��n�WYdd}~XnXdS)N)r�r(r@r
r�r�r})rnr�rr+rrr�finish_send�sz&IocpProactor.send.<locals>.finish_send)
r�r
r�rZr�r�ZWSASendrsZ	WriteFiler�)rr��bufr^rr�rrr�send�s

	zIocpProactor.sendcsz|j��|j�j��tjt�}|j�j��j����fdd�}tdd��}|j	|�|�}||��}t
j||jd�|S)NcsD|j�tjd�j��}�jtjtj|��j	�j
����j�fS)Nz@P)r��structZpackrs�
setsockoptr��
SOL_SOCKETr
ZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)rnr�rr�)r��listenerrr�
finish_accept�s
z*IocpProactor.accept.<locals>.finish_acceptcss4y|EdHWn tjk
r.|j��YnXdS)N)rrtra)r%r�rrr�accept_coro�s
z(IocpProactor.accept.<locals>.accept_coro)r)
r��_get_accept_socket�familyr
r�rZZAcceptExrsrr�rZ
ensure_futurer))rr�rr�r�r%�coror)r�r�r�accept�s

		
zIocpProactor.acceptcs�|j��ytj�j��j�WnBtk
rb}z&|jtjkr@��j	�ddkrR�WYdd}~XnXtj
t�}|j�j�|��fdd�}|j
|�|�S)Nrrcs|j��jtjtjd��S)Nr)r�r�r�r�r
ZSO_UPDATE_CONNECT_CONTEXT)rnr�r)r�rr�finish_connects
z,IocpProactor.connect.<locals>.finish_connect)r�r
Z	BindLocalrsr�r(r@�errnoZ	WSAEINVALZgetsocknamer�rZZ	ConnectExr�)rr�r �err�r)r�r�connect�s

zIocpProactor.connectcsJ|j��tjt�}|j�j��}|r0|j��S�fdd�}|j|�|�S)Ncs|j��S)N)r�)rnr�r)r`rr�finish_accept_pipesz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�r
r�rZZConnectNamedPipersr�r�)rr`rZ	connectedr�r)r`rrr
s


zIocpProactor.accept_pipeccszt}xjytj|�}PWn0tk
rF}z|jtjkr6�WYdd}~XnXt|dt�}tj	||j
d�EdHqWtj|�S)N�)r)
�CONNECT_PIPE_INIT_DELAYr
ZConnectPiper(r@ZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYrZsleepr)r	r[)rr Zdelayr9r+rrrris
zIocpProactor.connect_pipecCs|j||d�S)NF)�_wait_for_handle)rr9r�rrr�wait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd�}||_|S)NT)r�rD)rrEZ
done_callbackr>rrrrN7szIocpProactor._wait_cancelcs�|dkrtj}ntj|d�}tjt�}tj||j|j	|�}|rTt
||||jd��nt|||||jd���j
rv�j
d=�fdd�}�|d|f|j|j	<�S)Ng@�@)rrcs�j�S)N)r<)rnr�r)rlrr�finish_wait_for_handleRsz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handlerr)r;�INFINITE�math�ceilr
r�rZZRegisterWaitWithQueuer�r rCr)rGrr�)rr9r�Z
_is_cancel�msrr:r�r)rlrr�>s


	zIocpProactor._wait_for_handlecCs0||jkr,|jj|�tj|j�|jdd�dS)Nr)r8r\r
r�rsr�)r�objrrrr�^s
z IocpProactor._register_with_iocpcCs�t||jd�}|jr|jd=|jsjy|dd|�}Wn,tk
r^}z|j|�WYdd}~XnX|j|�||||f|j|j<|S)N)rrr)	rr)rrr(r.r/r�r )rrr��callbackrlr�r�rrrr�hs

zIocpProactor._registercCs|jj|�dS)N)r�r=)rrrrrrM�szIocpProactor._unregistercCstj|�}|jd�|S)Nr)r�r�)rr��srrrr��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��ntj|d�}|tkr>td���xtj|j|�}|dkrZPd}|\}}}}y|jj|�\}}	}
}WnVt	k
r�|j
j�r�|j
jdd||||fd��|dtj
fkr�tj|�wBYnX|
|jkr�|j�qB|j�sBy||||	�}Wn:tk
�r@}
z|j|
�|jj|�WYdd}
~
XqBX|j|�|jj|�qBWx |jD]}	|jj|	jd��qdW|jj�dS)Nrznegative timeoutg@�@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#�status)r��
ValueErrorr�r�r
ZGetQueuedCompletionStatusr�r��pop�KeyErrorr)Z	get_debugr*r�r;rLr�r'�doner(r.r�r=r/r�r rb)rr�r�r�r�Ztransferredr�r rlrr�r�r�r�rrrr<�sJ






zIocpProactor._pollcCs|jj|�dS)N)r�r\)rr�rrr�
_stop_serving�szIocpProactor._stop_servingcCs�x�t|jj��D]�\}\}}}}|j�r*qt|t�r6qy|j�Wqtk
r�}z8|jdk	r�d||d�}|j	rz|j	|d<|jj
|�WYdd}~XqXqWx|jr�|jd�s�tj
d�q�Wg|_|jdk	r�tj|j�d|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)�listr��itemsZ	cancelledr�rCr'r(r)rr*r<r�debugr�r�r;rL)rr r>rr�r�r+r,rrrra�s, 


"

zIocpProactor.closecCs|j�dS)N)ra)rrrrrc�szIocpProactor.__del__)r�)N)r)r)N)N)r1r2r3rr�r�r�r�r�r�r�r�rrrrir�rNr�r�r�rMr�r<r�rarcrrrrr�s,





 
	
7 c@seZdZdd�ZdS)r{c
sPtj|f|||||d�|���_�fdd�}�jjjt�jj��}	|	j|�dS)N)r~rr�r�r�cs�jj�}�j|�dS)N)�_procZpollZ_process_exited)rl�
returncode)rrrr��s
z4_WindowsSubprocessTransport._start.<locals>.callback)	r	�Popenr�r)rHr��intr6ru)
rr}r~rr�r�r�r�r�rlr)rr�_start�sz"_WindowsSubprocessTransport._startN)r1r2r3r�rrrrr{�sr{c@seZdZeZdS)�_WindowsDefaultEventLoopPolicyN)r1r2r3r
Z
_loop_factoryrrrrr�sr�),r;r�r�r�r�rQ�rrrrrrr	r
Z
coroutinesr�logr�__all__rZr�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerr5rCrG�objectrOZBaseSelectorEventLooprdZBaseProactorEventLooprrZBaseSubprocessTransportr{r
ZBaseDefaultEventLoopPolicyr�rrrrr�<module>sJ0J4;]kPK=�\C�s//transports.cpython-36.opt-1.pycnu�[���3


 \R'�@s�dZddlmZddddddgZGd	d�d�ZGd
d�de�ZGdd�de�ZGdd�dee�ZGd
d�de�ZGdd�de�Z	Gdd�de�Z
dS)zAbstract Transport class.�)�compat�
BaseTransport�
ReadTransport�WriteTransport�	Transport�DatagramTransport�SubprocessTransportc@sDeZdZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rzBase class for transports.NcCs|dkri}||_dS)N)�_extra)�self�extra�r�*/usr/lib64/python3.6/asyncio/transports.py�__init__
szBaseTransport.__init__cCs|jj||�S)z#Get optional transport information.)r	�get)r
�name�defaultrrr
�get_extra_infoszBaseTransport.get_extra_infocCst�dS)z2Return True if the transport is closing or closed.N)�NotImplementedError)r
rrr
�
is_closingszBaseTransport.is_closingcCst�dS)a
Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) called
        with None as its argument.
        N)r)r
rrr
�closeszBaseTransport.closecCst�dS)zSet a new protocol.N)r)r
�protocolrrr
�set_protocol$szBaseTransport.set_protocolcCst�dS)zReturn the current protocol.N)r)r
rrr
�get_protocol(szBaseTransport.get_protocol)N)N)
�__name__�
__module__�__qualname__�__doc__rrrrrrrrrr
r
s


c@s eZdZdZdd�Zdd�ZdS)rz#Interface for read-only transports.cCst�dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        N)r)r
rrr
�
pause_reading0szReadTransport.pause_readingcCst�dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        N)r)r
rrr
�resume_reading8szReadTransport.resume_readingN)rrrrrrrrrr
r-sc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)rz$Interface for write-only transports.NcCst�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        N)r)r
�high�lowrrr
�set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCst�dS)z,Return the current size of the write buffer.N)r)r
rrr
�get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCst�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        N)r)r
�datarrr
�write]szWriteTransport.writecCstj|�}|j|�dS)z�Write a list (or any iterable) of data bytes to the transport.

        The default implementation concatenates the arguments and
        calls write() on the result.
        N)rZflatten_list_bytesr$)r
Zlist_of_datar#rrr
�
writelineses
zWriteTransport.writelinescCst�dS)z�Close the write end after flushing buffered data.

        (This is like typing ^D into a UNIX program reading from stdin.)

        Data may still be received.
        N)r)r
rrr
�	write_eofnszWriteTransport.write_eofcCst�dS)zAReturn True if this transport supports write_eof(), False if not.N)r)r
rrr
�
can_write_eofwszWriteTransport.can_write_eofcCst�dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        N)r)r
rrr
�abort{szWriteTransport.abort)NN)rrrrr!r"r$r%r&r'r(rrrr
rAs
		c@seZdZdZdS)raSInterface representing a bidirectional transport.

    There may be several implementations, but typically, the user does
    not implement new transports; rather, the platform provides some
    useful transports that are implemented using the platform's best
    practices.

    The user never instantiates a transport directly; they call a
    utility function, passing it a protocol factory and other
    information necessary to create the transport and protocol.  (E.g.
    EventLoop.create_connection() or EventLoop.create_server().)

    The utility function will asynchronously create a transport and a
    protocol and hook them up by calling the protocol's
    connection_made() method, passing it the transport.

    The implementation here raises NotImplemented for every method
    except writelines(), which calls write() in a loop.
    N)rrrrrrrr
r�sc@s"eZdZdZddd�Zdd�ZdS)rz(Interface for datagram (UDP) transports.NcCst�dS)aSend data to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        addr is target socket address.
        If addr is None use target address pointed on transport creation.
        N)r)r
r#Zaddrrrr
�sendto�szDatagramTransport.sendtocCst�dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        N)r)r
rrr
r(�szDatagramTransport.abort)N)rrrrr)r(rrrr
r�s

c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rcCst�dS)zGet subprocess id.N)r)r
rrr
�get_pid�szSubprocessTransport.get_pidcCst�dS)z�Get subprocess returncode.

        See also
        http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode
        N)r)r
rrr
�get_returncode�sz"SubprocessTransport.get_returncodecCst�dS)z&Get transport for pipe with number fd.N)r)r
�fdrrr
�get_pipe_transport�sz&SubprocessTransport.get_pipe_transportcCst�dS)z�Send signal to subprocess.

        See also:
        docs.python.org/3/library/subprocess#subprocess.Popen.send_signal
        N)r)r
�signalrrr
�send_signal�szSubprocessTransport.send_signalcCst�dS)aLStop the subprocess.

        Alias for close() method.

        On Posix OSs the method sends SIGTERM to the subprocess.
        On Windows the Win32 API function TerminateProcess()
         is called to stop the subprocess.

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate
        N)r)r
rrr
�	terminate�szSubprocessTransport.terminatecCst�dS)z�Kill the subprocess.

        On Posix OSs the function sends SIGKILL to the subprocess.
        On Windows kill() is an alias for terminate().

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.kill
        N)r)r
rrr
�kill�s	zSubprocessTransport.killN)	rrrr*r+r-r/r0r1rrrr
r�scsVeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	dd�Z
�ZS)�_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class.

    The subclass must implement get_write_buffer_size().  It must call
    _maybe_pause_protocol() whenever the write buffer size increases,
    and _maybe_resume_protocol() whenever it decreases.  It may also
    override set_write_buffer_limits() (e.g. to specify different
    defaults).

    The subclass constructor must call super().__init__(extra).  This
    will call set_write_buffer_limits().

    The user may call set_write_buffer_limits() and
    get_write_buffer_size(), and their protocol's pause_writing() and
    resume_writing() may be called.
    Ncs$t�j|�||_d|_|j�dS)NF)�superr�_loop�_protocol_paused�_set_write_buffer_limits)r
rZloop)�	__class__rr
r�sz_FlowControlMixin.__init__cCsp|j�}||jkrdS|jsld|_y|jj�Wn:tk
rj}z|jjd|||jd��WYdd}~XnXdS)NTzprotocol.pause_writing() failed)�message�	exception�	transportr)r"�_high_waterr5�	_protocolZ
pause_writing�	Exceptionr4�call_exception_handler)r
�size�excrrr
�_maybe_pause_protocol�s
z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j�|jkrdd|_y|jj�Wn:tk
rb}z|jjd|||jd��WYdd}~XnXdS)NFz protocol.resume_writing() failed)r8r9r:r)r5r"�
_low_waterr<Zresume_writingr=r4r>)r
r@rrr
�_maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs|j|jfS)N)rBr;)r
rrr
�get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f��||_||_dS)N�@i�rz*high (%r) must be >= low (%r) must be >= 0i)�
ValueErrorr;rB)r
rr rrr
r6sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d�|j�dS)N)rr )r6rA)r
rr rrr
r!-sz)_FlowControlMixin.set_write_buffer_limitscCst�dS)N)r)r
rrr
r"1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN)rrrrrrArCrDr6r!r"�
__classcell__rr)r7r
r2�s

r2N)rZasyncior�__all__rrrrrrr2rrrr
�<module>s
#D4PK=�\{fU���constants.cpython-36.opt-2.pycnu�[���3


 \s�@sdZdZdZdS)���
N)Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTH�rr�)/usr/lib64/python3.6/asyncio/constants.py�<module>sPK=�\��o�5�5futures.cpython-36.pycnu�[���3


 \>�@s
dZddddddgZddlZddlZddlZddlZd	d
lmZd	dlm	Z	d	dlm
Z
ejZejZej
Z
ejZejZejZejZejd	ZGd
d�d�ZGdd�d�ZeZdd�Zdd�Zdd�Zdd�Zdd�dd�ZyddlZWnek
r�YnXejZZdS)z.A Future class similar to the one in PEP 3148.�CancelledError�TimeoutError�InvalidStateError�Future�wrap_future�isfuture�N�)�base_futures)�compat)�eventsc@s4eZdZdZdZdd�Zdd	�Zd
d�Zdd
�ZdS)�_TracebackLoggera
Helper to log a traceback upon destruction if not cleared.

    This solves a nasty problem with Futures and Tasks that have an
    exception set: if nobody asks for the exception, the exception is
    never logged.  This violates the Zen of Python: 'Errors should
    never pass silently.  Unless explicitly silenced.'

    However, we don't want to log the exception as soon as
    set_exception() is called: if the calling code is written
    properly, it will get the exception and handle it properly.  But
    we *do* want to log it if result() or exception() was never called
    -- otherwise developers waste a lot of time wondering why their
    buggy code fails silently.

    An earlier attempt added a __del__() method to the Future class
    itself, but this backfired because the presence of __del__()
    prevents garbage collection from breaking cycles.  A way out of
    this catch-22 is to avoid having a __del__() method on the Future
    class itself, but instead to have a reference to a helper object
    with a __del__() method that logs the traceback, where we ensure
    that the helper object doesn't participate in cycles, and only the
    Future has a reference to it.

    The helper object is added when set_exception() is called.  When
    the Future is collected, and the helper is present, the helper
    object is also collected, and its __del__() method will log the
    traceback.  When the Future's result() or exception() method is
    called (and a helper object is present), it removes the helper
    object, after calling its clear() method to prevent it from
    logging.

    One downside is that we do a fair amount of work to extract the
    traceback from the exception, even when it is never logged.  It
    would seem cheaper to just store the exception object, but that
    references the traceback, which references stack frames, which may
    reference the Future, which references the _TracebackLogger, and
    then the _TracebackLogger would be included in a cycle, which is
    what we're trying to avoid!  As an optimization, we don't
    immediately format the exception; we only do the work when
    activate() is called, which call is delayed until after all the
    Future's callbacks have run.  Since usually a Future has at least
    one callback (typically set by 'yield from') and usually that
    callback extracts the callback, thereby removing the need to
    format the exception.

    PS. I don't claim credit for this solution.  I first heard of it
    in a discussion about closing files when they are collected.
    �loop�source_traceback�exc�tbcCs |j|_|j|_||_d|_dS)N)�_loopr
�_source_tracebackrrr)�self�futurer�r�'/usr/lib64/python3.6/asyncio/futures.py�__init__Rsz_TracebackLogger.__init__cCs,|j}|dk	r(d|_tj|j||j�|_dS)N)r�	traceback�format_exception�	__class__�
__traceback__r)rrrrr�activateXs

z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrr�clear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j��}|d7}|d|j�7}|dj|j�j�7}|jjd|i�dS)Nz*Future/Task exception was never retrieved
�z0Future/Task created at (most recent call last):
z%s
�message)rr�joinr�format_list�rstripr
�call_exception_handler)r�msg�srcrrr�__del__csz_TracebackLogger.__del__N)r
rrr)	�__name__�
__module__�__qualname__�__doc__�	__slots__rrrr&rrrrrs0rc@s�eZdZdZeZdZdZdZdZ	dZ
dZdd�dd�Ze
jZdd�ZejrRd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zejr�eZ dS)!ra,This class is *almost* compatible with concurrent.futures.Future.

    Differences:

    - This class is not thread-safe.

    - result() and exception() do not take a timeout argument and
      raise an exception when the future isn't done yet.

    - Callbacks registered with add_done_callback() are always called
      via the event loop's call_soon().

    - This class is not compatible with the wait() and as_completed()
      methods in the concurrent.futures package.

    (In Python 3.4 or later we may be able to unify the implementations.)
    NF)r
cCs@|dkrtj�|_n||_g|_|jj�r<tjtjd��|_dS)z�Initialize the future.

        The optional event_loop argument allows explicitly setting the event
        loop object used by the future. If it's not provided, the future uses
        the default event loop.
        Nr)	r�get_event_loopr�
_callbacksZ	get_debug�
extract_stack�sys�	_getframer)rr
rrrr�s
zFuture.__init__cCsd|jjdj|j��fS)Nz<%s %s>� )rr'r �
_repr_info)rrrr�__repr__�szFuture.__repr__cCsD|js
dS|j}d|jj||d�}|jr4|j|d<|jj|�dS)Nz %s exception was never retrieved)r�	exceptionrr)�_log_traceback�
_exceptionrr'rrr#)rr�contextrrrr&�s
zFuture.__del__cCs&d|_|jtkrdSt|_|j�dS)z�Cancel the future and schedule callbacks.

        If the future is already done or cancelled, return False.  Otherwise,
        change the future's state to cancelled, schedule the callbacks and
        return True.
        FT)r5�_state�_PENDING�
_CANCELLED�_schedule_callbacks)rrrr�cancel�s
z
Future.cancelcCsD|jdd�}|sdSg|jdd�<x|D]}|jj||�q*WdS)z�Internal: Ask the event loop to call all callbacks.

        The callbacks are scheduled to be called as soon as possible. Also
        clears the callback list.
        N)r-r�	call_soon)rZ	callbacks�callbackrrrr;�s
zFuture._schedule_callbackscCs
|jtkS)z(Return True if the future was cancelled.)r8r:)rrrr�	cancelled�szFuture.cancelledcCs
|jtkS)z�Return True if the future is done.

        Done means either that a result / exception are available, or that the
        future was cancelled.
        )r8r9)rrrr�done�szFuture.donecCs<|jtkrt�|jtkr td��d|_|jdk	r6|j�|jS)aReturn the result this future represents.

        If the future has been cancelled, raises CancelledError.  If the
        future's result isn't yet available, raises InvalidStateError.  If
        the future is done and has an exception set, this exception is raised.
        zResult is not ready.FN)r8r:r�	_FINISHEDrr5r6�_result)rrrr�result�s


z
Future.resultcCs,|jtkrt�|jtkr td��d|_|jS)a&Return the exception that was set on this future.

        The exception (or None if no exception was set) is returned only if
        the future is done.  If the future has been cancelled, raises
        CancelledError.  If the future isn't done yet, raises
        InvalidStateError.
        zException is not set.F)r8r:rrArr5r6)rrrrr4�s

zFuture.exceptioncCs*|jtkr|jj||�n|jj|�dS)z�Add a callback to be run when the future becomes done.

        The callback is called with a single argument - the future object. If
        the future is already done when this is called, the callback is
        scheduled with call_soon.
        N)r8r9rr=r-�append)r�fnrrr�add_done_callbacks
zFuture.add_done_callbackcs<�fdd�|jD�}t|j�t|�}|r8||jdd�<|S)z}Remove all instances of a callback from the "call when done" list.

        Returns the number of callbacks removed.
        csg|]}|�kr|�qSrr)�.0�f)rErr�
<listcomp>sz/Future.remove_done_callback.<locals>.<listcomp>N)r-�len)rrEZfiltered_callbacksZ
removed_countr)rEr�remove_done_callbacks
zFuture.remove_done_callbackcCs4|jtkrtdj|j|���||_t|_|j�dS)z�Mark the future done and set its result.

        If the future is already done when this method is called, raises
        InvalidStateError.
        z{}: {!r}N)r8r9r�formatrBrAr;)rrCrrr�
set_result s

zFuture.set_resultcCs�|jtkrtdj|j|���t|t�r,|�}t|�tkr@td��||_t	|_|j
�tjrbd|_
nt||�|_|jj|jj�dS)z�Mark the future done and set an exception.

        If the future is already done when this method is called, raises
        InvalidStateError.
        z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r8r9rrL�
isinstance�type�
StopIteration�	TypeErrorr6rAr;r
�PY34r5rZ
_tb_loggerrr=r)rr4rrr�
set_exception,s

zFuture.set_exceptionccs,|j�sd|_|V|j�s$td��|j�S)NTz"yield from wasn't used with future)r@�_asyncio_future_blocking�AssertionErrorrC)rrrr�__iter__Ds
zFuture.__iter__)!r'r(r)r*r9r8rBr6rrrTr5rr	Z_future_repr_infor2r3r
rRr&r<r;r?r@rCr4rFrKrMrSrVZPY35�	__await__rrrrrns4

cCs|j�rdS|j|�dS)z?Helper setting the result only if the future was not cancelled.N)r?rM)ZfutrCrrr�_set_result_unless_cancelledSsrXcCsZ|j�st�|j�r|j�|j�s(dS|j�}|dk	rD|j|�n|j�}|j|�dS)z8Copy state from a future to a concurrent.futures.Future.N)	r@rUr?r<Zset_running_or_notify_cancelr4rSrCrM)�
concurrent�sourcer4rCrrr�_set_concurrent_future_stateZsr[cCsj|j�st�|j�rdS|j�s&t�|j�r8|j�n.|j�}|dk	rT|j|�n|j�}|j|�dS)zqInternal helper to copy state from another Future.

    The other Future may be a concurrent.futures.Future.
    N)r@rUr?r<r4rSrCrM)rZ�destr4rCrrr�_copy_future_stateis
r]cs�t��r"t�tjj�r"td��t��rDt�tjj�rDtd��t��rR�jnd�t��rd�jnd�dd�����fdd�}����fdd	�}�j|��j|�dS)
aChain two futures so that when one completes, so does the other.

    The result (or exception) of source will be copied to destination.
    If destination is cancelled, source gets cancelled too.
    Compatible with both asyncio.Future and concurrent.futures.Future.
    z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|�rt||�n
t||�dS)N)rr]r[)r�otherrrr�
_set_state�sz!_chain_future.<locals>._set_statecs2|j�r.�dks��kr"�j�n�j�j�dS)N)r?r<�call_soon_threadsafe)�destination)�	dest_looprZ�source_looprr�_call_check_cancel�s
z)_chain_future.<locals>._call_check_cancelcsJ�j�r�dk	r�j�rdS�dks,��kr8��|�n�j��|�dS)N)r?Z	is_closedr`)rZ)r_rbrarcrr�_call_set_state�sz&_chain_future.<locals>._call_set_state)rrNrY�futuresrrQrrF)rZrardrer)r_rbrarZrcr�
_chain_future}s	
rg)r
cCsNt|�r|St|tjj�s(tdj|���|dkr8tj�}|j	�}t
||�|S)z&Wrap concurrent.futures.Future object.z/concurrent.futures.Future is expected, got {!r}N)rrNrYrfrrUrLrr,Z
create_futurerg)rr
Z
new_futurerrrr�s
)r*�__all__Zconcurrent.futuresrYZloggingr/rrr	r
rrrrrr9r:rA�DEBUGZSTACK_DEBUGrrZ	_PyFuturerXr[r]rgrZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s>

Pc*
PK=�\���ee"windows_utils.cpython-36.opt-2.pycnu�[���3


 \��@s�ddlZejdkred��ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
dddddgZd	Zej
Z
ejZej�Zeed�r�ejZnejejdfd
d�Zdded
�dd�ZGdd�d�ZGdd�dej�ZdS)�NZwin32z
win32 only�
socketpair�pipe�Popen�PIPE�
PipeHandlei c
Cs|tjkrd}n|tjkr d}ntd��|tjkr:td��|dkrJtd��tj|||�}z�|j|df�|jd�|j�dd�\}}tj|||�}yP|jd	�y|j	||f�Wnt
tfk
r�YnX|jd
�|j�\}}	Wn|j
��YnXWd|j
�X||fS)Nz	127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supported��FT)�socket�AF_INETZAF_INET6�
ValueError�SOCK_STREAMZbindZlistenZgetsocknameZsetblockingZconnect�BlockingIOError�InterruptedErrorZaccept�close)
Zfamily�type�proto�hostZlsockZaddrZportZcsockZssock�_�r�-/usr/lib64/python3.6/asyncio/windows_utils.pyr%s8






FT)�duplex�
overlapped�bufsizecCs"tjdtj�tt�fd�}|r>tj}tjtj	B}||}}ntj
}tj	}d|}}|tjO}|drp|tjO}|dr�tj}nd}d}	}
yZtj
||tjd||tjtj�}	tj||dtjtj|tj�}
tj|	dd�}|jd�|	|
fS|	dk	�rtj|	�|
dk	�rtj|
��YnXdS)Nz\\.\pipe\python-pipe-%d-%d-)�prefixrrT)r)�tempfileZmktemp�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ	PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@








c@sXeZdZdd�Zdd�Zedd��Zdd�Zej	d	�d
d�Z
dd
�Zdd�Zdd�Z
dS)rcCs
||_dS)N)�_handle)�self�handlerrr�__init__�szPipeHandle.__init__cCs*|jdk	rd|j}nd}d|jj|fS)Nz	handle=%r�closedz<%s %s>)r"�	__class__�__name__)r#r$rrr�__repr__�s
zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$�szPipeHandle.handlecCs|jdkrtd��|jS)NzI/O operatioon on closed pipe)r"r)r#rrr�fileno�s
zPipeHandle.fileno)r cCs|jdk	r||j�d|_dS)N)r")r#r rrrr�s

zPipeHandle.closecCs*|jdk	r&tjd|t|d�|j�dS)Nzunclosed %r)�source)r"�warnings�warn�ResourceWarningr)r#rrr�__del__�s
zPipeHandle.__del__cCs|S)Nr)r#rrr�	__enter__�szPipeHandle.__enter__cCs|j�dS)N)r)r#�t�v�tbrrr�__exit__�szPipeHandle.__exit__N)r(�
__module__�__qualname__r%r)�propertyr$r*rr rr/r0r4rrrrr�scseZdZd�fdd�	Z�ZS)rNcs|d}}}d}	}
}|tkr@tddd�\}}	tj|tj�}n|}|tkrhtdd�\}
}
tj|
d�}n|}|tkr�td	d�\}}tj|d�}n|tkr�|}n|}z�y t�j|f|||d�|��Wn4x$|	|
|fD]}|dk	r�t	j
|�q�W�Yn>X|	dk	�rt|	�|_|
dk	�r"t|
�|_
|dk	�r6t|�|_Wd|tk�rNtj|�|tk�rbtj|�|tk�rvtj|�XdS)
NFT)rr)rr)�stdin�stdout�stderr)FT)TF)TF)rr�msvcrtZopen_osfhandler�O_RDONLY�STDOUT�superr%rr rr8r9r:r)r#�argsr8r9r:�kwdsZ	stdin_rfdZ
stdout_wfdZ
stderr_wfdZstdin_whZ	stdout_rhZ	stderr_rhZstdin_rhZ	stdout_whZ	stderr_wh�h)r'rrr%�sH









zPopen.__init__)NNN)r(r5r6r%�
__classcell__rr)r'rr�s)TT)�sys�platform�ImportErrorr�	itertoolsr;rr	�
subprocessrr,�__all__ZBUFSIZErr=�countr�hasattrrr
rrrrrrrr�<module>s*

.0-PK=�\�;�.4.4streams.cpython-36.opt-2.pycnu�[���3


 \�_�@sHdddddddgZddlZeed	�r2ejd
dg�dd
lmZddlmZddlmZddlmZddlm	Z	ddl
mZd!ZGdd�de
�ZGdd�de�Ze	d"ded�dd��Ze	d#ded�dd��Zeed	��re	d$ded�dd
��Ze	d%ded�dd��ZGdd�dej�ZGdd�deej�ZGdd�d�ZGd d�d�ZdS)&�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�IncompleteReadError�LimitOverrunError�NZAF_UNIX�open_unix_connection�start_unix_server�)�
coroutines)�compat)�events)�	protocols)�	coroutine)�logger��cs$eZdZ�fdd�Zdd�Z�ZS)rcs(t�jdt|�|f�||_||_dS)Nz-%d bytes read on a total of %r expected bytes)�super�__init__�len�partial�expected)�selfrr)�	__class__��'/usr/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst|�|j|jffS)N)�typerr)rrrr�
__reduce__&szIncompleteReadError.__reduce__)�__name__�
__module__�__qualname__rr�
__classcell__rr)rrrscs$eZdZ�fdd�Zdd�Z�ZS)rcst�j|�||_dS)N)rr�consumed)r�messager#)rrrr0szLimitOverrunError.__init__cCst|�|jd|jffS)Nr)r�argsr#)rrrrr4szLimitOverrunError.__reduce__)rr r!rrr"rr)rrr*s)�loop�limitc	+sb|dkrtj�}t||d�}t||d��|j�fdd�||f|�EdH\}}t|�||�}||fS)N)r'r&)r&cs�S)Nrr)�protocolrr�<lambda>Qsz!open_connection.<locals>.<lambda>)r�get_event_looprrZcreate_connectionr)	�host�portr&r'�kwds�reader�	transport�_�writerr)r(rr8s c+s8�dkrtj�����fdd�}�j|||f|�EdHS)Ncst��d�}t|��d�}|S)N)r'r&)r&)rr)r.r()�client_connected_cbr'r&rr�factoryqszstart_server.<locals>.factory)rr*Z
create_server)r2r+r,r&r'r-r3r)r2r'r&rrVsc+s`|dkrtj�}t||d�}t||d��|j�fdd�|f|�EdH\}}t|�||�}||fS)N)r'r&)r&cs�S)Nrr)r(rrr)�sz&open_unix_connection.<locals>.<lambda>)rr*rrZcreate_unix_connectionr)�pathr&r'r-r.r/r0r1r)r(rr	}sc+s6�dkrtj�����fdd�}�j||f|�EdHS)Ncst��d�}t|��d�}|S)N)r'r&)r&)rr)r.r()r2r'r&rrr3�sz"start_unix_server.<locals>.factory)rr*Zcreate_unix_server)r2r4r&r'r-r3r)r2r'r&rr
�sc@s:eZdZddd�Zdd�Zdd�Zdd	�Zed
d��ZdS)
�FlowControlMixinNcCs0|dkrtj�|_n||_d|_d|_d|_dS)NF)rr*�_loop�_paused�
_drain_waiter�_connection_lost)rr&rrrr�szFlowControlMixin.__init__cCs d|_|jj�rtjd|�dS)NTz%r pauses writing)r7r6�	get_debugr�debug)rrrr�
pause_writing�s
zFlowControlMixin.pause_writingcCsFd|_|jj�rtjd|�|j}|dk	rBd|_|j�sB|jd�dS)NFz%r resumes writing)r7r6r:rr;r8�done�
set_result)r�waiterrrr�resume_writing�s
zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|j�r4dS|dkrH|jd�n
|j|�dS)NT)r9r7r8r=r>�
set_exception)r�excr?rrr�connection_lost�sz FlowControlMixin.connection_lostccs<|jrtd��|jsdS|j}|jj�}||_|EdHdS)NzConnection lost)r9�ConnectionResetErrorr7r8r6�
create_future)rr?rrr�
_drain_helper�s
zFlowControlMixin._drain_helper)N)	rr r!rr<r@rCrrFrrrrr5�s


	r5csBeZdZd�fdd�	Zdd�Z�fdd�Zdd	�Zd
d�Z�ZS)
rNcs*t�j|d�||_d|_||_d|_dS)N)r&F)rr�_stream_reader�_stream_writer�_client_connected_cb�	_over_ssl)rZ
stream_readerr2r&)rrrr�s
zStreamReaderProtocol.__init__cCsd|jj|�|jd�dk	|_|jdk	r`t|||j|j�|_|j|j|j�}tj	|�r`|jj
|�dS)NZ
sslcontext)rG�
set_transport�get_extra_inforJrIrr6rHrZiscoroutineZcreate_task)rr/�resrrr�connection_made�s


z$StreamReaderProtocol.connection_madecsF|jdk	r*|dkr|jj�n|jj|�t�j|�d|_d|_dS)N)rG�feed_eofrArrCrH)rrB)rrrrC�s
z$StreamReaderProtocol.connection_lostcCs|jj|�dS)N)rG�	feed_data)r�datarrr�
data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj�|jrdSdS)NFT)rGrOrJ)rrrr�eof_receiveds
z!StreamReaderProtocol.eof_received)NN)	rr r!rrNrCrRrSr"rr)rrr�s
	
c@sfeZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zddd�Ze
dd��ZdS)rcCs||_||_||_||_dS)N)�
_transport�	_protocol�_readerr6)rr/r(r.r&rrrrszStreamWriter.__init__cCs:|jjd|jg}|jdk	r,|jd|j�ddj|�S)Nztransport=%rz	reader=%rz<%s>� )rrrTrV�append�join)r�inforrr�__repr__!s
zStreamWriter.__repr__cCs|jS)N)rT)rrrrr/'szStreamWriter.transportcCs|jj|�dS)N)rT�write)rrQrrrr\+szStreamWriter.writecCs|jj|�dS)N)rT�
writelines)rrQrrrr].szStreamWriter.writelinescCs
|jj�S)N)rT�	write_eof)rrrrr^1szStreamWriter.write_eofcCs
|jj�S)N)rT�
can_write_eof)rrrrr_4szStreamWriter.can_write_eofcCs
|jj�S)N)rT�close)rrrrr`7szStreamWriter.closeNcCs|jj||�S)N)rTrL)r�name�defaultrrrrL:szStreamWriter.get_extra_infoccsN|jdk	r |jj�}|dk	r |�|jdk	r:|jj�r:dV|jj�EdHdS)N)rV�	exceptionrTZ
is_closingrUrF)rrBrrr�drain=s	



zStreamWriter.drain)N)rr r!rr[�propertyr/r\r]r^r_r`rLrrdrrrrrs

c@s�eZdZedfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zed'dd��Zed)dd��Zed d!��Zejr�ed"d#��Zed$d%��Zejr�d&d#�ZdS)*rNcCsZ|dkrtd��||_|dkr*tj�|_n||_t�|_d|_d|_d|_	d|_
d|_dS)NrzLimit cannot be <= 0F)�
ValueError�_limitrr*r6�	bytearray�_buffer�_eof�_waiter�
_exceptionrTr7)rr'r&rrrrXszStreamReader.__init__cCs�dg}|jr |jdt|j��|jr0|jd�|jtkrJ|jd|j�|jr`|jd|j�|jrv|jd|j�|jr�|jd|j�|j	r�|jd�d	d
j
|�S)Nrz%d bytes�eofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rW)rirXrrjrg�_DEFAULT_LIMITrkrlrTr7rY)rrZrrrr[ks 


zStreamReader.__repr__cCs|jS)N)rl)rrrrrc}szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|j�s,|j|�dS)N)rlrk�	cancelledrA)rrBr?rrrrA�szStreamReader.set_exceptioncCs*|j}|dk	r&d|_|j�s&|jd�dS)N)rkror>)rr?rrr�_wakeup_waiter�s
zStreamReader._wakeup_waitercCs
||_dS)N)rT)rr/rrrrK�szStreamReader.set_transportcCs*|jr&t|j�|jkr&d|_|jj�dS)NF)r7rrirgrT�resume_reading)rrrr�_maybe_resume_transport�sz$StreamReader._maybe_resume_transportcCsd|_|j�dS)NT)rjrp)rrrrrO�szStreamReader.feed_eofcCs|jo|jS)N)rjri)rrrr�at_eof�szStreamReader.at_eofcCsv|sdS|jj|�|j�|jdk	rr|jrrt|j�d|jkrry|jj�Wntk
rjd|_YnXd|_dS)NrT)	ri�extendrprTr7rrgZ
pause_reading�NotImplementedError)rrQrrrrP�s
zStreamReader.feed_dataccsV|jdk	rtd|��|jr,d|_|jj�|jj�|_z|jEdHWdd|_XdS)NzH%s() called while another coroutine is already waiting for incoming dataF)rk�RuntimeErrorr7rTrqr6rE)rZ	func_namerrr�_wait_for_data�s


zStreamReader._wait_for_dataccs�d}t|�}y|j|�EdH}Wn�tk
rB}z|jSd}~Xnftk
r�}zJ|jj||j�rv|jd|j|�=n
|jj�|j	�t
|jd��WYdd}~XnX|S)N�
r)r�	readuntilrrrri�
startswithr#�clearrrrfr%)r�sep�seplen�line�errr�readline�s
 zStreamReader.readlinerxccs�t|�}|dkrtd��|jdk	r(|j�d}x�t|j�}|||kr||jj||�}|dkr\P|d|}||jkr|td|��|jr�t|j�}|jj	�t
|d��|jd�EdHq.W||jkr�td|��|jd||�}|jd||�=|j�t|�S)Nrz,Separator should be at least one-byte stringrz2Separator is not found, and chunk exceed the limitryz2Separator is found, but chunk is longer than limit���)
rrfrlri�findrgrrj�bytesr{rrwrr)rZ	separatorr}�offsetZbuflenZisep�chunkrrrry�s:






zStreamReader.readuntilrccs�|jdk	r|j�|dkrdS|dkrZg}x&|j|j�EdH}|sBP|j|�q*Wdj|�S|jrz|jrz|jd�EdHt|jd|��}|jd|�=|j	�|S)Nr��read)
rlr�rgrXrYrirjrwr�rr)r�nZblocks�blockrQrrrr�Ps$

zStreamReader.readccs�|dkrtd��|jdk	r |j�|dkr,dSxFt|j�|krr|jr`t|j�}|jj�t||��|jd�EdHq.Wt|j�|kr�t|j�}|jj�nt|jd|��}|jd|�=|j	�|S)Nrz*readexactly size can not be less than zeror��readexactly)
rfrlrrirjr�r{rrwrr)rr�Z
incompleterQrrrr��s&




zStreamReader.readexactlycCs|S)Nr)rrrr�	__aiter__�szStreamReader.__aiter__ccs|j�EdH}|dkrt�|S)Nr�)r��StopAsyncIteration)r�valrrr�	__anext__�szStreamReader.__anext__cCs|S)Nr)rrrrr��s)rxr�)r�)rr r!rnrr[rcrArprKrrrOrsrPrrwr�ryr�r�r
ZPY35r�r�ZPY352rrrrrVs,	 [2*i)NN)NN)N)N)�__all__Zsocket�hasattrrt�rr
rrr�logrrn�EOFErrorr�	Exceptionrrrr	r
ZProtocolr5rrrrrrr�<module>s@
"B3GPK=�\�»��subprocess.cpython-36.opt-1.pycnu�[���3


 \��@s�ddgZddlZddlmZddlmZddlmZddlmZdd	lmZdd
l	m
Z
ejZejZej
Z
Gdd�dejej�ZGd
d�d�Zeddddejfdd��Zeddddejd�dd��ZdS)�create_subprocess_exec�create_subprocess_shell�N�)�events)�	protocols)�streams)�tasks)�	coroutine)�loggercsPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)�SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.cs<t�j|d�||_d|_|_|_d|_d|_g|_dS)N)�loopF)	�super�__init__�_limit�stdin�stdout�stderr�
_transport�_process_exited�	_pipe_fds)�self�limitr)�	__class__��*/usr/lib64/python3.6/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk	r$|jd|j�|jdk	r>|jd|j�|jdk	rX|jd|j�ddj|�S)Nzstdin=%rz	stdout=%rz	stderr=%rz<%s>� )r�__name__r�appendrr�join)r�inforrr�__repr__s



z!SubprocessStreamProtocol.__repr__cCs�||_|jd�}|dk	rDtj|j|jd�|_|jj|�|jj	d�|jd�}|dk	r�tj|j|jd�|_
|j
j|�|jj	d�|jd�}|dk	r�tj||d|jd�|_dS)Nr)rr�r)�protocol�readerr)
r�get_pipe_transportr�StreamReaderr�_looprZ
set_transportrrr�StreamWriterr)r�	transportZstdout_transportZstderr_transportZstdin_transportrrr�connection_made(s&


z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk	r6|j|�dS)Nrr!)rrZ	feed_data)r�fd�datar#rrr�pipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs�|dkr,|j}|dk	r|j�|j|�dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|j�n
|j|�||jkr�|jj|�|j	�dS)Nrrr!)
r�closeZconnection_lostrrZfeed_eofZ
set_exceptionr�remove�_maybe_close_transport)rr*�exc�piper#rrr�pipe_connection_lostJs$



z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|j�dS)NT)rr/)rrrr�process_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|j�dkr$|jr$|jj�d|_dS)Nr)�lenrrrr-)rrrrr/es
z/SubprocessStreamProtocol._maybe_close_transport)r�
__module__�__qualname__�__doc__rr r)r,r2r3r/�
__classcell__rr)rrrs

rc@s~eZdZdd�Zdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zedd��Zedd��Z
edd��Zeddd��ZdS)�ProcesscCs8||_||_||_|j|_|j|_|j|_|j�|_dS)N)rZ	_protocolr&rrrZget_pid�pid)rr(r"rrrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr:)rrrrr uszProcess.__repr__cCs
|jj�S)N)rZget_returncode)rrrr�
returncodexszProcess.returncodeccs|jj�EdHS)zdWait until the process exit and return the process return code.

        This method is a coroutine.N)rZ_wait)rrrr�wait|szProcess.waitcCs|jj|�dS)N)r�send_signal)r�signalrrrr=�szProcess.send_signalcCs|jj�dS)N)r�	terminate)rrrrr?�szProcess.terminatecCs|jj�dS)N)r�kill)rrrrr@�szProcess.killccs�|jj�}|jj|�|r,tjd|t|��y|jj�EdHWn8tt	fk
rx}z|rhtjd||�WYdd}~XnX|r�tjd|�|jj
�dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r&�	get_debugr�writer
�debugr4Zdrain�BrokenPipeError�ConnectionResetErrorr-)r�inputrCr0rrr�_feed_stdin�s
 zProcess._feed_stdincCsdS)Nr)rrrr�_noop�sz
Process._noopccs�|jj|�}|dkr|j}n|j}|jj�rJ|dkr8dnd}tjd||�|j�EdH}|jj�r�|dkrndnd}tjd||�|j	�|S)Nr!rrrz%r communicate: read %sz%r communicate: close %s)
rr$rrr&rAr
rC�readr-)rr*r(�stream�name�outputrrr�_read_stream�s

zProcess._read_streamNccs�|dk	r|j|�}n|j�}|jdk	r2|jd�}n|j�}|jdk	rP|jd�}n|j�}tj||||jd�EdH\}}}|j�EdH||fS)Nrr!)r)	rGrHrrMrrZgatherr&r<)rrFrrrrrr�communicate�s


zProcess.communicate)N)rr5r6rr �propertyr;r	r<r=r?r@rGrHrMrNrrrrr9ks	r9c
+sP�dkrtj����fdd�}�j||f|||d�|��EdH\}}	t||	��S)Ncst��d�S)N)rr)rr)rrrr�<lambda>�sz)create_subprocess_shell.<locals>.<lambda>)rrr)r�get_event_loopZsubprocess_shellr9)
�cmdrrrrr�kwds�protocol_factoryr(r"r)rrrr�s)rrrrrc/sT�dkrtj����fdd�}�j||f|�|||d�|��EdH\}	}
t|	|
��S)Ncst��d�S)N)rr)rr)rrrrrP�sz(create_subprocess_exec.<locals>.<lambda>)rrr)rrQZsubprocess_execr9)Zprogramrrrrr�argsrSrTr(r"r)rrrr�s)�__all__�
subprocess�rrrrZ
coroutinesr	�logr
�PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolrr9Z_DEFAULT_LIMITrrrrrr�<module>s(X]PK=�\��yOyOsslproto.cpython-36.pycnu�[���3


 \�e�
@s�ddlZddlZyddlZWnek
r4dZYnXddlmZddlmZddlmZddlmZddl	m
Z
dd	�Zd
d�ZdZ
d
ZdZdZGdd�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�base_events)�compat)�	protocols)�
transports)�loggercCsj|rtd��ttd�r*tj�}|sfd|_n<tjtj�}|jtjO_|jtj	O_|j
�tj|_|S)Nz(Server side SSL needs a valid SSLContext�create_default_contextF)
�
ValueError�hasattr�sslr�check_hostnameZ
SSLContextZPROTOCOL_SSLv23ZoptionsZOP_NO_SSLv2ZOP_NO_SSLv3Zset_default_verify_pathsZ
CERT_REQUIRED�verify_mode)�server_side�server_hostname�
sslcontext�r�(/usr/lib64/python3.6/asyncio/sslproto.py�_create_transport_contexts
rcCs
ttd�S)N�	MemoryBIO)r
rrrrr�_is_sslproto_available%srZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@s~eZdZdZdZddd�Zedd��Zed	d
��Zedd��Z	ed
d��Z
ddd�Zddd�Zdd�Z
ddd�Zd dd�ZdS)!�_SSLPipeaAn SSL "Pipe".

    An SSL pipe allows you to communicate with an SSL/TLS protocol instance
    through memory buffers. It can be used to implement a security layer for an
    existing connection where you don't have access to the connection's file
    descriptor, or for some reason you don't want to use it.

    An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode,
    data is passed through untransformed. In wrapped mode, application level
    data is encrypted to SSL record level data and vice versa. The SSL record
    level is the lowest level in the SSL protocol suite and is what travels
    as-is over the wire.

    An SslPipe initially is in "unwrapped" mode. To start SSL, call
    do_handshake(). To shutdown SSL again, call unwrap().
    �iNcCsH||_||_||_t|_tj�|_tj�|_d|_	d|_
d|_d|_dS)a�
        The *context* argument specifies the ssl.SSLContext to use.

        The *server_side* argument indicates whether this is a server side or
        client side transport.

        The optional *server_hostname* argument can be used to specify the
        hostname you are connecting to. You may only specify this parameter if
        the _ssl module supports Server Name Indication (SNI).
        NF)
�_context�_server_side�_server_hostname�
_UNWRAPPED�_staterr�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextrrrrr�__init__Ds

z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)r)r#rrrr$Zsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance.

        Return None if the pipe is not wrapped.
        )r)r#rrr�
ssl_object_sz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake
        that is currently in progress.)r )r#rrr�need_ssldatagsz_SSLPipe.need_ssldatacCs
|jtkS)zj
        Whether a security layer is currently in effect.

        Return False during handshake.
        )r�_WRAPPED)r#rrr�wrappedmsz_SSLPipe.wrappedcCsb|jtkrtd��|jj|j|j|j|jd�|_	t
|_||_|jddd�\}}t
|�dks^t�|S)aLStart the SSL handshake.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the handshake is complete. The callback will be
        called with None if successful, else an exception instance.
        z"handshake in progress or completed)rr�T)�only_handshaker)rr�RuntimeErrorrZwrap_biorrrrr�
_DO_HANDSHAKEr!�feed_ssldata�len�AssertionError)r#�callback�ssldata�appdatarrr�do_handshakevs	
z_SSLPipe.do_handshakecCsj|jtkrtd��|jtkr$td��|jttfks6t�t|_||_|jd�\}}|gksf|dgksft�|S)a1Start the SSL shutdown sequence.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the shutdown is complete. The callback will be
        called without arguments.
        zno security layer presentzshutdown in progressr*)	rrr,�	_SHUTDOWNr(r-r0r"r.)r#r1r2r3rrr�shutdown�s	

z_SSLPipe.shutdowncCs2|jj�|jd�\}}|gks.|dgks.t�dS)z�Send a potentially "ragged" EOF.

        This method will raise an SSL_ERROR_EOF exception if the EOF is
        unexpected.
        r*N)rZ	write_eofr.r0)r#r2r3rrr�feed_eof�s
z_SSLPipe.feed_eofFcCs�|jtkr"|r|g}ng}g|fSd|_|r8|jj|�g}g}y�|jtkrx|jj�t|_|j	rl|j	d�|rx||fS|jtkr�xn|jj
|j�}|j|�|s�Pq�WnJ|jt
kr�|jj�d|_t|_|jr�|j�n|jtkr�|j|jj
��Wnxtjtjfk
�rl}zRt|dd�tjtjtjfk�rN|jtk�rL|j	�rL|j	|��|jtjk|_WYdd}~XnX|jj�r�|j|jj
��||fS)a�Feed SSL record level data into the pipe.

        The data must be a bytes instance. It is OK to send an empty bytes
        instance. This can be used to get ssldata for a handshake initiated by
        this endpoint.

        Return a (ssldata, appdata) tuple. The ssldata element is a list of
        buffers containing SSL data that needs to be sent to the remote SSL.

        The appdata element is a list of buffers containing plaintext data that
        needs to be forwarded to the application. The appdata list may contain
        an empty buffer indicating an SSL "close_notify" alert. This alert must
        be acknowledged by calling shutdown().
        FN�errno)rrr r�writer-rr4r(r!�read�max_size�appendr5Zunwrapr"r�SSLError�CertificateError�getattr�SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITE�SSL_ERROR_SYSCALLr8r�pending)r#�datar+r3r2�chunk�excrrrr.�sV











 
z_SSLPipe.feed_ssldatarcCs,d|kot|�kns t�|jtkrV|t|�krF||d�g}ng}|t|�fSg}t|�}x�d|_y(|t|�kr�||jj||d��7}Wn\tj	k
r�}z>|j
dkr�tj|_|jtjtj
tjfkrЂ|jtjk|_WYdd}~XnX|jj�r
|j|jj��|t|�k�s|jrdPqdW||fS)aFeed plaintext data into the pipe.

        Return an (ssldata, offset) tuple. The ssldata element is a list of
        buffers containing record level data that needs to be sent to the
        remote SSL instance. The offset is the number of plaintext bytes that
        were processed, which may be less than the length of data.

        NOTE: In case of short writes, this call MUST be retried with the SAME
        buffer passed into the *data* argument (i.e. the id() must be the
        same). This is an OpenSSL requirement. A further particularity is that
        a short write will always have offset == 0, because the _ssl module
        does not enable partial writes. And even though the offset is zero,
        there will still be encrypted data in ssldata.
        rNFZPROTOCOL_IS_SHUTDOWN)r/r0rr�
memoryviewr rr9rr=�reasonr@r8rArBrrCr<r:)r#rD�offsetr2ZviewrFrrr�feed_appdata�s4 


 
z_SSLPipe.feed_appdatai)N)N)N)F)r)�__name__�
__module__�__qualname__�__doc__r;r%�propertyr$r&r'r)r4r6r7r.rJrrrrr0s
	



Jrc@s�eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Ze	j
rHdd�Zdd�Zdd�Z
ddd�Zdd�Zdd�Zdd�Zdd�ZdS) �_SSLProtocolTransportcCs||_||_d|_dS)NF)�_loop�
_ssl_protocol�_closed)r#�loopZssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||�S)z#Get optional transport information.)rR�_get_extra_info)r#�name�defaultrrr�get_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs||j_dS)N)rR�
_app_protocol)r#�protocolrrr�set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rRrY)r#rrr�get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rS)r#rrr�
is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jj�dS)a
Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) called
        with None as its argument.
        TN)rSrR�_start_shutdown)r#rrr�close<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d�|j�dS)Nzunclosed transport %r)�source)rS�warnings�warn�ResourceWarningr_)r#rrr�__del__Ksz_SSLProtocolTransport.__del__cCs|jjj�dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        N)rR�
_transport�
pause_reading)r#rrrrfQsz#_SSLProtocolTransport.pause_readingcCs|jjj�dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        N)rRre�resume_reading)r#rrrrgYsz$_SSLProtocolTransport.resume_readingcCs|jjj||�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        N)rRre�set_write_buffer_limits)r#ZhighZlowrrrrhasz-_SSLProtocolTransport.set_write_buffer_limitscCs|jjj�S)z,Return the current size of the write buffer.)rRre�get_write_buffer_size)r#rrrrivsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttf�s$tdjt|�j���|s,dS|jj	|�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        z/data: expecting a bytes-like instance, got {!r}N)
�
isinstance�bytes�	bytearrayrG�	TypeError�format�typerKrR�_write_appdata)r#rDrrrr9zsz_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|jj�dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        N)rR�_abort)r#rrr�abort�sz_SSLProtocolTransport.abort)N)NN)rKrLrMr%rXr[r\r]r_rZPY34rdrfrgrhrir9rqrsrrrrrP&s


rPc@s�eZdZdZd(dd�Zd)dd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zd*dd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd+d"d#�Zd$d%�Zd&d'�ZdS),�SSLProtocolz�SSL protocol.

    Implementation of SSL on top of a socket using incoming and outgoing
    buffers which are ssl.MemoryBIO objects.
    FNTcCs�tdkrtd��|st||�}||_|r6|r6||_nd|_||_t|d�|_tj	�|_
d|_||_||_
||_t|j
|�|_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)rr,rrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrQrYrP�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownre�_call_connection_made)r#rTZapp_protocolrZwaiterrrZcall_connection_maderrrr%�s,


zSSLProtocol.__init__cCsD|jdkrdS|jj�s:|dk	r.|jj|�n|jjd�d|_dS)N)r|Z	cancelledZ
set_exceptionZ
set_result)r#rFrrr�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|j�dS)zXCalled when the low-level connection is made.

        Start the SSL handshake.
        N)rerrurrr~�_start_handshake)r#�	transportrrr�connection_made�s

zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|�d|_d|_|j|�dS)z�Called when the low-level connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        FN)rrQ�	call_soonrY�connection_lostrer}r�)r#rFrrrr��szSSLProtocol.connection_lostcCs|jj�dS)z\Called when the low-level transport's buffer goes over
        the high-water mark.
        N)rY�
pause_writing)r#rrrr��szSSLProtocol.pause_writingcCs|jj�dS)z^Called when the low-level transport's buffer drains below
        the low-water mark.
        N)rY�resume_writing)r#rrrr��szSSLProtocol.resume_writingcCs�|jdkrdSy|jj|�\}}WnHtjk
rj}z*|jj�rTtjd||j|j	�|j
�dSd}~XnXx|D]}|jj|�qrWx(|D] }|r�|j
j|�q�|j�Pq�WdS)zXCalled when some SSL data is received.

        The argument is a bytes object.
        Nz%r: SSL error %s (reason %s))r~r.rr=rQ�	get_debugr�warningr8rHrrrer9rY�
data_receivedr^)r#rDr2r3�erErrrr��s"



zSSLProtocol.data_receivedc
CsTzB|jj�rtjd|�|jt�|js@|jj�}|r@tj	d�Wd|j
j�XdS)aCalled when the other end of the low-level stream
        is half-closed.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        z%r received EOFz?returning true from eof_received() has no effect when using sslN)rQr�r�debugr��ConnectionResetErrorr�rY�eof_receivedr�rer_)r#Z	keep_openrrrr�s


zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk	r,|jj||�S|SdS)N)rwrerX)r#rVrWrrrrU!s



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|j�nd|_|jd�dS)NTr*)r�r�rrrp)r#rrrr^)s
zSSLProtocol._start_shutdowncCs.|jj|df�|jt|�7_|j�dS)Nr)rzr<r{r/�_process_write_backlog)r#rDrrrrp2szSSLProtocol._write_appdatacCsH|jj�r$tjd|�|jj�|_nd|_d|_|jjd�|j	�dS)Nz%r starts SSL handshakeTr*r)r*r)
rQr�rr��time�_handshake_start_timer�rzr<r�)r#rrrr�7s
zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk	r|�|j�}t|jd�sR|jrR|jjtj	krRtj
||j�Wn~tk
r�}zb|jj
�r�t|tj�r�tjd|dd�ntjd|dd�|jj�t|t�r�|j|�dS�WYdd}~XnX|jj
��r|jj�|j}tjd||d�|jj||j�|j�|d	�|j�r4|jj|j �|j�d|_!|jj"|j#�dS)
NFrz5%r: SSL handshake failed on verifying the certificateT)�exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compressionr&)$r�r~r&Zgetpeercertr
rurr
rZ	CERT_NONEZmatch_hostname�
BaseExceptionrQr�rjr>rr�rer_�	Exceptionr�r�r�r�rw�updater�r�r�rYr�r}rr�r�)r#Z
handshake_excZsslobjr�rFZdtrrr�_on_handshake_completeCsD




z"SSLProtocol._on_handshake_completecCsJ|jdks|jdkrdSy�x�tt|j��D]�}|jd\}}|rT|jj||�\}}n*|rl|jj|j�}d}n|jj|j	�}d}x|D]}|jj
|�q�W|t|�kr�||f|jd<|jjs�t�|jj
r�|jj�P|jd=|jt|�8_q*WWnRtk
�rD}z4|j�r|j|�n|j|d�t|t��s4�WYdd}~XnXdS)NrrzFatal error on SSL transport)rer~�ranger/rzrJr4r�r6�	_finalizer9r'r0Z_pausedrgr{r�r��_fatal_errorrjr�)r#�irDrIr2rErFrrrr�ws:

z"SSLProtocol._process_write_backlog�Fatal error on transportcCsXt|tj�r*|jj�rBtjd||dd�n|jj|||j|d��|jrT|jj	|�dS)Nz%r: %sT)r�)�messageZ	exceptionr�rZ)
rjrZ_FATAL_ERROR_IGNORErQr�rr�Zcall_exception_handlerreZ_force_close)r#rFr�rrrr��s

zSSLProtocol._fatal_errorcCsd|_|jdk	r|jj�dS)N)r~rer_)r#rrrr��s
zSSLProtocol._finalizec
Cs(z|jdk	r|jj�Wd|j�XdS)N)rersr�)r#rrrrr�s
zSSLProtocol._abort)FNT)N)N)r�)rKrLrMrNr%r�r�r�r�r�r�r�rUr^rpr�r�r�r�r�rrrrrrrt�s&
"


	4,
rt)rxrar�ImportError�rrrr�logrrrrr-r(r5�objectrZ_FlowControlMixinZ	TransportrPZProtocolrtrrrr�<module>s*
wnPK=�\K�[[protocols.cpython-36.opt-1.pycnu�[���3


 \��@sRdZddddgZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�Zd	S)
zAbstract Protocol class.�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocolc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)raCommon base class for protocol interfaces.

    Usually user implements protocols that derived from BaseProtocol
    like Protocol or ProcessProtocol.

    The only case when BaseProtocol should be implemented directly is
    write-only transport like write pipe
    cCsdS)z�Called when a connection is made.

        The argument is the transport representing the pipe connection.
        To receive data, wait for data_received() calls.
        When the connection is closed, connection_lost() is called.
        N�)�selfZ	transportrr�)/usr/lib64/python3.6/asyncio/protocols.py�connection_madeszBaseProtocol.connection_madecCsdS)z�Called when the connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        Nr)r�excrrr�connection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark.

        Pause and resume calls are paired -- pause_writing() is called
        once when the buffer goes strictly over the high-water mark
        (even if subsequent writes increases the buffer size even
        more), and eventually resume_writing() is called once when the
        buffer size reaches the low-water mark.

        Note that if the buffer size equals the high-water mark,
        pause_writing() is not called -- it must go strictly over.
        Conversely, resume_writing() is called when the buffer size is
        equal or lower than the low-water mark.  These end conditions
        are important to ensure that things go as expected when either
        mark is zero.

        NOTE: This is the only Protocol callback that is not called
        through EventLoop.call_soon() -- if it were, it would have no
        effect when it's most needed (when the app keeps writing
        without yielding until pause_writing() is called).
        Nr)rrrr�
pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark.

        See pause_writing() for details.
        Nr)rrrr�resume_writing7szBaseProtocol.resume_writingN)�__name__�
__module__�__qualname__�__doc__rr
rrrrrrrs
c@s eZdZdZdd�Zdd�ZdS)ranInterface for stream protocol.

    The user should implement this interface.  They can inherit from
    this class but don't need to.  The implementations here do
    nothing (they don't raise exceptions).

    When the user wants to requests a transport, they pass a protocol
    factory to a utility function (e.g., EventLoop.create_connection()).

    When the connection is made successfully, connection_made() is
    called with a suitable transport object.  Then data_received()
    will be called 0 or more times with data (bytes) received from the
    transport; finally, connection_lost() will be called exactly once
    with either an exception object or None as an argument.

    State machine of calls:

      start -> CM [-> DR*] [-> ER?] -> CL -> end

    * CM: connection_made()
    * DR: data_received()
    * ER: eof_received()
    * CL: connection_lost()
    cCsdS)zTCalled when some data is received.

        The argument is a bytes object.
        Nr)r�datarrr�
data_receivedXszProtocol.data_receivedcCsdS)z�Called when the other end calls write_eof() or equivalent.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        Nr)rrrr�eof_received^szProtocol.eof_receivedN)r
rrrrrrrrrr>sc@s eZdZdZdd�Zdd�ZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrr�datagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError.

        (Other than BlockingIOError or InterruptedError.)
        Nr)rr	rrr�error_receivedmszDatagramProtocol.error_receivedN)r
rrrrrrrrrrgsc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rz,Interface for protocol for subprocess calls.cCsdS)z�Called when the subprocess writes data into stdout/stderr pipe.

        fd is int file descriptor.
        data is bytes object.
        Nr)r�fdrrrr�pipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)z�Called when a file descriptor associated with the child process is
        closed.

        fd is the int file descriptor that was closed.
        Nr)rrr	rrr�pipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrr�process_exited�sz!SubprocessProtocol.process_exitedN)r
rrrrrrrrrrrtsN)r�__all__rrrrrrrr�<module>s7)
PK=�\�E(�ggcompat.cpython-36.opt-2.pycnu�[���3


 \�@s2ddlZejdkZejd	kZejd
kZdd�ZdS)�N����cCstsdd�|D�}dj|�S)Ncss$|]}t|t�rt|�n|VqdS)N)�
isinstance�
memoryview�bytes)�.0�data�r�&/usr/lib64/python3.6/asyncio/compat.py�	<genexpr>sz%flatten_list_bytes.<locals>.<genexpr>�)�PY34�join)Zlist_of_datarrr�flatten_list_bytes
sr)rr)rr)rrr)�sys�version_inforZPY35ZPY352rrrrr�<module>s


PK=�\"4���queues.cpython-36.opt-2.pycnu�[���3


 \�@s�dddddgZddlZddlZddlmZdd	lmZdd
lmZddlmZGdd�de	�Z
Gd
d�de	�ZGdd�d�ZGdd�de�Z
Gdd�de�Zejs�eZejd�dS)�Queue�
PriorityQueue�	LifoQueue�	QueueFull�
QueueEmpty�N�)�compat)�events)�locks)�	coroutinec@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�&/usr/lib64/python3.6/asyncio/queues.pyrsc@seZdZdS)rN)rr
rrrrrrsc@s�eZdZd(dd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zedd��Z
dd�Zdd�Zedd��Zdd�Zed d!��Zd"d#�Zd$d%�Zed&d'��ZdS))rrN)�loopcCsb|dkrtj�|_n||_||_tj�|_tj�|_d|_t	j
|jd�|_|jj�|j
|�dS)Nr)r)r	Zget_event_loop�_loop�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr
ZEvent�	_finished�set�_init)�self�maxsizerrrr�__init__(s


zQueue.__init__cCstj�|_dS)N)rr�_queue)rrrrrr:szQueue._initcCs
|jj�S)N)r�popleft)rrrr�_get=sz
Queue._getcCs|jj|�dS)N)r�append)r�itemrrr�_put@sz
Queue._putcCs*x$|r$|j�}|j�s|jd�PqWdS)N)r �doneZ
set_result)r�waitersZwaiterrrr�_wakeup_nextEs

zQueue._wakeup_nextcCsdjt|�jt|�|j��S)Nz<{} at {:#x} {}>)�format�typer�id�_format)rrrr�__repr__MszQueue.__repr__cCsdjt|�j|j��S)Nz<{} {}>)r(r)rr+)rrrr�__str__Qsz
Queue.__str__cCszdj|j�}t|dd�r,|djt|j��7}|jrF|djt|j��7}|jr`|djt|j��7}|jrv|dj|j�7}|S)Nzmaxsize={!r}rz _queue={!r}z
 _getters[{}]z
 _putters[{}]z	 tasks={})	r(r�getattr�listrr�lenrr)r�resultrrrr+Tsz
Queue._formatcCs
t|j�S)N)r0r)rrrr�qsize`szQueue.qsizecCs|jS)N)r)rrrrrdsz
Queue.maxsizecCs|jS)N)r)rrrr�emptyiszQueue.emptycCs |jdkrdS|j�|jkSdS)NrF)rr2)rrrr�fullms
z
Queue.fullc	cstxh|j�rh|jj�}|jj|�y|EdHWq|j�|j�r^|j�r^|j|j��YqXqW|j|�S)N)	r4r�
create_futurerr"�cancel�	cancelledr'�
put_nowait)rr#Zputterrrr�putxs	

z	Queue.putcCs>|j�rt�|j|�|jd7_|jj�|j|j�dS)Nr)r4rr$rr�clearr'r)rr#rrrr8�s

zQueue.put_nowaitccs�x�|j�r�|jj�}|jj|�y|EdHWq|j�y|jj|�Wntk
rbYnX|j�r�|j�r�|j	|j��YqXqW|j
�S)N)r3rr5rr"r6�remove�
ValueErrorr7r'�
get_nowait)r�getterrrr�get�s

z	Queue.getcCs$|j�rt�|j�}|j|j�|S)N)r3rr!r'r)rr#rrrr=�s
zQueue.get_nowaitcCs8|jdkrtd��|jd8_|jdkr4|jj�dS)Nrz!task_done() called too many timesr)rr<rr)rrrr�	task_done�s


zQueue.task_doneccs|jdkr|jj�EdHdS)Nr)rr�wait)rrrr�join�s	
z
Queue.join)r)rr
rrrr!r$r'r,r-r+r2�propertyrr3r4rr9r8r?r=r@rBrrrrrs$c@s0eZdZdd�Zejfdd�Zejfdd�ZdS)rcCs
g|_dS)N)r)rrrrrr�szPriorityQueue._initcCs||j|�dS)N)r)rr#�heappushrrrr$�szPriorityQueue._putcCs
||j�S)N)r)r�heappoprrrr!�szPriorityQueue._getN)	rr
rr�heapqrDr$rEr!rrrrr�sc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs
g|_dS)N)r)rrrrrr�szLifoQueue._initcCs|jj|�dS)N)rr")rr#rrrr$�szLifoQueue._putcCs
|jj�S)N)r�pop)rrrrr!�szLifoQueue._getN)rr
rrr$r!rrrrr�s�
JoinableQueue)�__all__rrF�rr	r
Z
coroutinesr�	ExceptionrrrrrZPY35rHr"rrrr�<module>sH
PK=�\1<���J�Jtasks.cpython-36.pycnu�[���3


 \�a�
@s�dZddddddddd	d
ddd
g
ZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
ddlmZGdd�de
j�ZeZyddlZWnek
r�YnXejZZej
jZej
jZej
jZedded�dd��Zdd�Zedd�dd��Zedd��Zddd �d!d�Zed/dd�d"d��Zdd�d#d$�Zee�d	<d	e_ [dd�d%d�Z!ed&d'��Z"Gd(d)�d)e
j�Z#dd*d+�d,d
�Z$dd�d-d�Z%d.d
�Z&dS)0z0Support for tasks, coroutines and the scheduler.�Task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�async�gather�shield�
ensure_future�run_coroutine_threadsafe�N�)�
base_tasks)�compat)�
coroutines)�events)�futures)�	coroutinecs�eZdZdZej�ZiZdZe	ddd��Z
e	ddd��Zdd��fd	d
�
Ze
jrXdd�Zd
d�Zdd�dd�Zddd�dd�Zdd�Zd�fdd�	Zdd�Z�ZS)rz A coroutine wrapped in a Future.TNcCs|dkrtj�}|jj|�S)z�Return the currently running task in an event loop or None.

        By default the current task for the current event loop is returned.

        None is returned when called not in the context of a Task.
        N)r�get_event_loop�_current_tasks�get)�cls�loop�r�%/usr/lib64/python3.6/asyncio/tasks.py�current_task.szTask.current_taskcs$�dkrtj���fdd�|jD�S)z|Return a set of all tasks for an event loop.

        By default all tasks for the current event loop are returned.
        Ncsh|]}|j�kr|�qSr)�_loop)�.0�t)rrr�	<setcomp>Bsz!Task.all_tasks.<locals>.<setcomp>)rr�
_all_tasks)rrr)rr�	all_tasks:szTask.all_tasks)rcsdtj|�stt|���t�j|d�|jr2|jd=||_d|_d|_	|j
j|j�|j
jj|�dS)N)rrF���)r�iscoroutine�AssertionError�repr�super�__init__�_source_traceback�_coro�_fut_waiter�_must_cancelr�	call_soon�_step�	__class__r"�add)�self�coror)r0rrr)Dsz
Task.__init__cCsH|jtjkr8|jr8|dd�}|jr,|j|d<|jj|�tjj|�dS)Nz%Task was destroyed but it is pending!)�task�messageZsource_traceback)	Z_staterZ_PENDING�_log_destroy_pendingr*rZcall_exception_handler�Future�__del__)r2�contextrrrr8Ss
zTask.__del__cCs
tj|�S)N)rZ_task_repr_info)r2rrr�
_repr_info^szTask._repr_info)�limitcCstj||�S)a�Return the list of stack frames for this task's coroutine.

        If the coroutine is not done, this returns the stack where it is
        suspended.  If the coroutine has completed successfully or was
        cancelled, this returns an empty list.  If the coroutine was
        terminated by an exception, this returns the list of traceback
        frames.

        The frames are always ordered from oldest to newest.

        The optional limit gives the maximum number of frames to
        return; by default all available frames are returned.  Its
        meaning differs depending on whether a stack or a traceback is
        returned: the newest frames of a stack are returned, but the
        oldest frames of a traceback are returned.  (This matches the
        behavior of the traceback module.)

        For reasons beyond our control, only one stack frame is
        returned for a suspended coroutine.
        )rZ_task_get_stack)r2r;rrr�	get_stackaszTask.get_stack)r;�filecCstj|||�S)anPrint the stack or traceback for this task's coroutine.

        This produces output similar to that of the traceback module,
        for the frames retrieved by get_stack().  The limit argument
        is passed to get_stack().  The file argument is an I/O stream
        to which the output is written; by default output is written
        to sys.stderr.
        )rZ_task_print_stack)r2r;r=rrr�print_stackxs	zTask.print_stackcCs4d|_|j�rdS|jdk	r*|jj�r*dSd|_dS)a�Request that this task cancel itself.

        This arranges for a CancelledError to be thrown into the
        wrapped coroutine on the next cycle through the event loop.
        The coroutine then has a chance to clean up or even deny
        the request using try/except/finally.

        Unlike Future.cancel, this does not guarantee that the
        task will be cancelled: the exception might be caught and
        acted upon, delaying cancellation of the task or preventing
        cancellation completely.  The task may also return a value or
        raise a different exception.

        Immediately after this method is called, Task.cancelled() will
        not return True (unless the task was already cancelled).  A
        task will be marked as cancelled when the wrapped coroutine
        terminates with a CancelledError exception (even if cancel()
        was not called).
        FNT)Z_log_traceback�doner,�cancelr-)r2rrrr@�s

zTask.cancelcs�|j�stdj||���|jr:t|tj�s4tj�}d|_|j}d|_||j	j
|j<�zy"|dkrn|jd�}n
|j
|�}Wn�tk
r�}z.|jr�d|_|jtj��n|j|j�WYdd}~X�n�tjk
r�t�j�Y�n~tk
�r}z|j|�WYdd}~X�nPtk
�rD}z|j|��WYdd}~X�n Xt|dd�}|dk	�r|j|jk	�r�|jj|jtdj||���n||�r�||k�r�|jj|jtdj|���n2d|_|j|j�||_|j�r|jj��rd|_n|jj|jtdj||���n^|dk�r |jj|j�nDtj|��rJ|jj|jtdj||���n|jj|jtdj|���Wd|j	j
j|j�d}XdS)	Nz!_step(): already done: {!r}, {!r}F�_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r}) r?r&�formatr-�
isinstancer�CancelledErrorr+r,r0rr�send�throw�
StopIteration�
set_exception�
set_result�valuer(r@�	Exception�
BaseException�getattrr.r/�RuntimeErrorrA�add_done_callback�_wakeup�inspectZisgenerator�pop)r2�excr3�resultZblocking)r0rrr/�s�



z
Task._stepcCsJy|j�Wn,tk
r8}z|j|�WYdd}~Xn
X|j�d}dS)N)rTrKr/)r2�futurerSrrrrP�szTask._wakeup)N)N)N)�__name__�
__module__�__qualname__�__doc__�weakref�WeakSetr"rr6�classmethodrr#r)rZPY34r8r:r<r>r@r/rP�
__classcell__rr)r0rrs"	!T)r�timeout�return_whenc#s�tj|�stj|�r&tdt|�j��|s2td��|tt	t
fkrNtdj|����dkr^tj
���fdd�t|�D�}t|||��EdHS)a�Wait for the Futures and coroutines given by fs to complete.

    The sequence futures must not be empty.

    Coroutines will be wrapped in Tasks.

    Returns two sets of Future: (done, pending).

    Usage:

        done, pending = yield from asyncio.wait(fs)

    Note: This does not raise TimeoutError! Futures that aren't done
    when the timeout occurs are returned in the second set.
    z expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}Ncsh|]}t|�d��qS))r)r)r�f)rrrr!7szwait.<locals>.<setcomp>)r�isfuturerr%�	TypeError�typerV�
ValueErrorrrrrBrr�set�_wait)�fsrr^r_r)rrrscGs|j�s|jd�dS)N)r?rI)�waiter�argsrrr�_release_waiter<srj)rccs�|dkrtj�}|dkr"|EdHS|j�}|j|t|�}tjt|�}t||d�}|j|�zhy|EdHWn*t	j
k
r�|j|�|j��YnX|j
�r�|j�S|j|�|j�t	j��Wd|j�XdS)a�Wait for the single Future or coroutine to complete, with timeout.

    Coroutine will be wrapped in Task.

    Returns result of the Future or coroutine.  When a timeout occurs,
    it cancels the task and raises TimeoutError.  To avoid the task
    cancellation, wrap it in shield().

    If the wait is cancelled, the task is also cancelled.

    This function is a coroutine.
    N)r)rr�
create_future�
call_laterrj�	functools�partialrrOrrD�remove_done_callbackr@r?rT�TimeoutError)�futr^rrh�timeout_handle�cbrrrrAs,



c#s�|std��|j��d�|dk	r.|j|t���t|������fdd�}x|D]}|j|�qNWz�EdHWd�dk	r��j�Xt�t�}}x4|D],}|j|�|j	�r�|j
|�q�|j
|�q�W||fS)zeInternal helper for wait() and wait_for().

    The fs argument must be a collection of Futures.
    zSet of Futures is empty.Ncs\�d8��dks6�tks6�tkrX|j�rX|j�dk	rX�dk	rF�j��j�sX�jd�dS)Nrr)rr�	cancelled�	exceptionr@r?rI)r`)�counterr_rrrhrr�_on_completion|sz_wait.<locals>._on_completion)r&rkrlrj�lenrOr@reror?r1)rgr^r_rrwr`r?�pendingr)rvr_rrrhrrfos(



rf)rr^c#s�tj|�stj|�r&tdt|�j���dk	r2�ntj���fdd�t	|�D��ddl
m}|�d��d����fdd	�}���fd
d��t�fdd
��}x�D]}|j
��q�W�r�|dk	rʈj||��xtt���D]}|�Vq�WdS)amReturn an iterator whose values are coroutines.

    When waiting for the yielded coroutines you'll get the results (or
    exceptions!) of the original Futures (or coroutines), in the order
    in which and as soon as they complete.

    This differs from PEP 3148; the proper way to use this is:

        for f in as_completed(fs):
            result = yield from f  # The 'yield from' may raise.
            # Use result.

    If a timeout is specified, the 'yield from' will raise
    TimeoutError when the timeout occurs before all Futures are done.

    Note: The futures 'f' are not necessarily members of fs.
    z expect a list of futures, not %sNcsh|]}t|�d��qS))r)r)rr`)rrrr!�szas_completed.<locals>.<setcomp>r)�Queue)rcs.x �D]}|j���jd�qW�j�dS)N)ro�
put_nowait�clear)r`)rwr?�todorr�_on_timeout�s

z!as_completed.<locals>._on_timeoutcs6�sdS�j|��j|��r2�dk	r2�j�dS)N)�remover{r@)r`)r?rrr}rrrw�s

z$as_completed.<locals>._on_completionc3s$�j�EdH}|dkrtj�|j�S)N)rrrprT)r`)r?rr�
_wait_for_one�sz#as_completed.<locals>._wait_for_one)rrarr%rbrcrVrrreZqueuesrzrrOrl�rangerx)rgrr^rzr~r�r`�_r)rwr?rrrr}rr�s 

c
csX|dkrdV|S|dkr"tj�}|j�}|jj|tj||�}z
|EdHS|j�XdS)z9Coroutine that completes after a given time (in seconds).rN)rrrkrrlrZ_set_result_unless_cancelledr@)ZdelayrTrrU�hrrrr�s
cCstjdtdd�t||d�S)z�Wrap a coroutine in a future.

    If the argument is a Future, it is returned directly.

    This function is deprecated in 3.5. Use asyncio.ensure_future() instead.
    z;asyncio.async() function is deprecated, use ensure_future()�)�
stacklevel)r)�warnings�warn�DeprecationWarningr)�coro_or_futurerrrr�async_�sr�cCs�tj|�r(|dk	r$||jk	r$td��|Stj|�r^|dkrBtj�}|j|�}|j	rZ|j	d=|St
jr~tj
|�r~tt|�|d�Std��dS)zmWrap a coroutine or an awaitable in a future.

    If the argument is a Future, it is returned directly.
    Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rrarrdrr%rrZcreate_taskr*rZPY35rQZisawaitabler�_wrap_awaitablerb)r�rr4rrrr�s


ccs|j�EdHS)z�Helper for asyncio.ensure_future().

    Wraps awaitable (an object with __await__) into a coroutine
    that will later be wrapped in a Task by ensure_future().
    N)�	__await__)Z	awaitablerrrr�sr�cs.eZdZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFuturez�Helper for gather().

    This overrides cancel() to cancel all the children and act more
    like Task.cancel(), which doesn't immediately mark itself as
    cancelled.
    N)rcst�j|d�||_d|_dS)N)rF)r(r)�	_children�_cancel_requested)r2�childrenr)r0rrr)$sz_GatheringFuture.__init__cCs:|j�rdSd}x|jD]}|j�rd}qW|r6d|_|S)NFT)r?r�r@r�)r2ZretZchildrrrr@)sz_GatheringFuture.cancel)rVrWrXrYr)r@r]rr)r0rr�sr�F)r�return_exceptionscs|s*|dkrtj�}|j���jg��Si�xjt|�D]^}tj|�sht||d�}|dkr`|j}d|_	n&|}|dkr||j}n|j|k	r�t
d��|�|<q8W�fdd�|D�}t|��t||d��d�dg�������fdd	�}x&t
|�D]\}}|jtj||��q�W�S)
a7Return a future aggregating results from the given coroutines
    or futures.

    Coroutines will be wrapped in a future and scheduled in the event
    loop. They will not necessarily be scheduled in the same order as
    passed in.

    All futures must share the same event loop.  If all the tasks are
    done successfully, the returned future's result is the list of
    results (in the order of the original sequence, not necessarily
    the order of results arrival).  If *return_exceptions* is True,
    exceptions in the tasks are treated the same as successful
    results, and gathered in the result list; otherwise, the first
    raised exception will be immediately propagated to the returned
    future.

    Cancellation: if the outer Future is cancelled, all children (that
    have not completed yet) are also cancelled.  If any child is
    cancelled, this is treated as if it raised CancelledError --
    the outer Future is *not* cancelled in this case.  (This is to
    prevent the cancellation of one child to cause other children to
    be cancelled.)
    N)rFz)futures are tied to different event loopscsg|]}�|�qSrr)r�arg)�
arg_to_futrr�
<listcomp>hszgather.<locals>.<listcomp>rcs��j�r|j�s|j�dS|j�r@tj�}�sl�j|�dSn,|jdk	rf|j�}�sl�j|�dSn|j}|�|<�d7���kr��jr��jtj��n
�j	��dS)Nr)
r?rtrurrDrHZ
_exceptionZ_resultr�rI)�irq�res)�	nchildren�	nfinished�outer�resultsr�rr�_done_callbackns*


zgather.<locals>._done_callback)rrrkrIrerrarrr6rdrxr��	enumeraterOrmrn)rr�Zcoros_or_futuresr�rqr�r�r�r)r�r�r�r�r�r�rr
8s8



cs@t||d�}|j�r|S|j}|j���fdd�}|j|��S)a=Wait for a future, shielding it from cancellation.

    The statement

        res = yield from shield(something())

    is exactly equivalent to the statement

        res = yield from something()

    *except* that if the coroutine containing it is cancelled, the
    task running in something() is not cancelled.  From the POV of
    something(), the cancellation did not happen.  But its caller is
    still cancelled, so the yield-from expression still raises
    CancelledError.  Note: If something() is cancelled by other means
    this will still cancel shield().

    If you want to completely ignore cancellation (not recommended)
    you can combine shield() with a try/except clause, as follows:

        try:
            res = yield from shield(something())
        except CancelledError:
            res = None
    )rcs\�j�r|j�s|j�dS|j�r.�j�n*|j�}|dk	rJ�j|�n�j|j��dS)N)rtrur@rHrIrT)�innerrS)r�rrr��s
zshield.<locals>._done_callback)rr?rrkrO)r�rr�r�r)r�rr�s
cs:tj��std��tjj�����fdd�}�j|��S)zsSubmit a coroutine object to a given event loop.

    Return a concurrent.futures.Future to access the result.
    zA coroutine object is requiredcsTytjt��d���Wn6tk
rN}z�j�r<�j|��WYdd}~XnXdS)N)r)rZ
_chain_futurerrKZset_running_or_notify_cancelrH)rS)r3rUrrr�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rr%rb�
concurrentrr7Zcall_soon_threadsafe)r3rr�r)r3rUrrr
�s


)N)'rY�__all__Zconcurrent.futuresr�rmrQr�rZ�rrrrrrr7rZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrjrrfrrr��globalsrVrr�r�r
rr
rrrr�<module>sZ
s
--8

W5PK=�\��� � coroutines.cpython-36.opt-1.pycnu�[���3


 \+�@s�dddgZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
l
mZejdZejjo�eejjd��ZyejZejZWnek
r�dZdZYnXy
ejZWnek
r�d
d�ZYnXyddlmZ m!Z"Wne#k
�r*dZ Z"YnXdd�Z$e$�Z%[$dd�Z&Gdd�d�Z'dd�Ze(�Z)dd�Zej*e'fZ+e dk	�r�e+e f7Z+edk	�r�efe+Z+dd�Z,dd�Z-dS)�	coroutine�iscoroutinefunction�iscoroutine�N�)�compat)�	constants)�events)�base_futures)�loggerZ
YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF�)�funcrr�*/usr/lib64/python3.6/asyncio/coroutines.py�<lambda>/sr)�	Coroutine�	AwaitablecCsFGdd�d�}dd�}d}|�}||�}t|�|j|�|j|fkS)	Nc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
z!has_yield_from_bug.<locals>.MyGencSs
d|_dS)N)�	send_args)�selfrrr
�__init__;sz*has_yield_from_bug.<locals>.MyGen.__init__cSs|S)Nr)rrrr
�__iter__=sz*has_yield_from_bug.<locals>.MyGen.__iter__cSsdS)N�*r)rrrr
�__next__?sz*has_yield_from_bug.<locals>.MyGen.__next__cWs
||_dS)N)r)rZwhatrrr
�sendAsz&has_yield_from_bug.<locals>.MyGen.sendN)�__name__�
__module__�__qualname__rrrrrrrr
�MyGen:srcss|EdHdS)Nr)�genrrr
�yield_from_genDsz*has_yield_from_bug.<locals>.yield_from_genr��)rrr)�nextrr)rr�valuer�cororrr
�has_yield_from_bug9s

r#cCs
t|d�S)N)�CoroWrapper)rrrr
�
debug_wrapperPsr%c@s�eZdZd%dd�Zdd�Zdd�Zdd	�Zer8d
d�Zndd�Zd&d
d�Z	dd�Z
edd��Zedd��Z
edd��Zejr�dd�Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zd#d$�ZdS)'r$NcCs>||_||_tjtjd��|_t|dd�|_t|dd�|_	dS)Nrrr)
rrr�
extract_stack�sys�	_getframe�_source_traceback�getattrrr)rrrrrr
r[s
zCoroWrapper.__init__cCs@t|�}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>���)�_format_coroutiner)�	__class__r)r�	coro_repr�framerrr
�__repr__cs

zCoroWrapper.__repr__cCs|S)Nr)rrrr
rjszCoroWrapper.__iter__cCs|jjd�S)N)rr)rrrr
rmszCoroWrapper.__next__cGs4tj�}|j}|jj|jtkr(|d}|jj|�S)Nr)	r'r(�f_back�f_code�co_code�f_lasti�_YIELD_FROMrr)rr!r/Zcallerrrr
rus
zCoroWrapper.sendcCs|jj|�S)N)rr)rr!rrr
r}scCs|jj|||�S)N)r�throw)r�typer!�	tracebackrrr
r6�szCoroWrapper.throwcCs
|jj�S)N)r�close)rrrr
r9�szCoroWrapper.closecCs|jjS)N)r�gi_frame)rrrr
r:�szCoroWrapper.gi_framecCs|jjS)N)r�
gi_running)rrrr
r;�szCoroWrapper.gi_runningcCs|jjS)N)r�gi_code)rrrr
r<�szCoroWrapper.gi_codecCs,t|jdd�}|dk	r(tdj|j|���|S)N�cr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r�RuntimeError�format)rr=rrr
�	__await__�szCoroWrapper.__await__cCs|jjS)N)r�gi_yieldfrom)rrrr
rA�szCoroWrapper.gi_yieldfromcCs|jjS)N)rr=)rrrr
r=�szCoroWrapper.cr_awaitcCs|jjS)N)r�
cr_running)rrrr
rB�szCoroWrapper.cr_runningcCs|jjS)N)r�cr_code)rrrr
rC�szCoroWrapper.cr_codecCs|jjS)N)r�cr_frame)rrrr
rD�szCoroWrapper.cr_framecCs�t|dd�}t|dd�}|dkr,t|dd�}|dk	r�|jd
kr�d|}t|df�}|r�djtj|��}|dtj�d	�7}||j�7}tj	|�dS)Nrr:rDrz%r was never yielded fromr)�zB
Coroutine object created at (most recent call last, truncated to z last lines):
r+)
r*r4�joinr8�format_listrZDEBUG_STACK_DEPTH�rstripr
�error)rrr/�msg�tbrrr
�__del__�szCoroWrapper.__del__)N)NN)rrrrr0rr�_YIELD_FROM_BUGrr6r9�propertyr:r;r<rZPY35r@rAr=rBrCrDrLrrrr
r$Xs(


r$cspt��r�Stj��r��ntj���fdd���tsNtdkrD�}qft��}ntj����fdd��}t|_|S)z�Decorator to mark coroutines.

    If the coroutine is not yielded from before it is destroyed,
    an error message is logged.
    c?sv�||�}tj|�s(tj|�s(t|t�r4|EdH}n>tdk	rry
|j}Wntk
rZYnXt|t�rr|�EdH}|S)N)	r	Zisfuture�inspectZisgenerator�
isinstancer$�
_AwaitableABCr@�AttributeError)�args�kw�resZ
await_meth)rrr
r"�s



zcoroutine.<locals>.coroNcs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)N)rrrrr+)r$r)r*rr)rS�kwds�w)r"rrr
�wrapper�szcoroutine.<locals>.wrapper)�_inspect_iscoroutinefunctionrO�isgeneratorfunction�	functools�wraps�_DEBUG�_types_coroutine�
_is_coroutine)rrXr)r"rr
r�s


cCst|dd�tkpt|�S)z6Return True if func is a decorated coroutine function.r_N)r*r_rY)rrrr
r�scCs
t|t�S)z)Return True if obj is a coroutine object.)rP�_COROUTINE_TYPES)�objrrr
rsc
Cst|d�r�t|d�r�t|dt|dt|�j��}dj|�}d}y
|j}Wn4tk
r~y
|j}Wntk
rxYnXYnX|r�dj|�S|Sd}t|t	�r�|j
}|j}|dk	r�dj|�}n|}|dkr�tj
|fi�}d}t|d�r�|jr�|j}nt|d��r|j�r|j}d}t|d��r0|j�r0|j}nt|d	��rJ|j�rJ|j}d
}|�rb|j�rb|j}d}|}t|t	��r�tj|j
��r�|j
dk	�r�tj|j
�}	|	dk	�r�|	\}}|dk�r�d|||f}nd
|||f}n:|dk	�r�|j}d|||f}n|�r|j}d|||f}|S)NrCr<rrz{}()Fz
{} runningrDr:z<empty co_filename>rz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)�hasattrr*r7rr?rBrRr;rPr$rrrZ_format_callbackrCr<rDr:�co_filenamerOrZZ_get_function_source�f_lineno�co_firstlineno)
r"Z	coro_nameZrunningrZ	coro_codeZ
coro_frame�filename�linenor.�sourcerrr
r,sx







r,).�__all__r[rOZopcode�osr'r8�typesrErrrr	�logr
Zopmapr5�flags�ignore_environment�bool�environ�getr]rr^�
CoroutineTypeZ_types_CoroutineTyperRrrY�collections.abcrZ
_CoroutineABCrrQ�ImportErrorr#rMr%r$�objectr_�
GeneratorTyper`rr,rrrr
�<module>sZ




j:




PK=�\����j#j#$base_subprocess.cpython-36.opt-2.pycnu�[���3


 \�#�@s�ddlZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
Gdd	�d	ej�ZGd
d�dej
�ZGdd
�d
eej�ZdS)�N�)�compat)�	protocols)�
transports)�	coroutine)�loggercs�eZdZd0�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jrTdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zed*d+��Zd,d-�Zd.d/�Z�ZS)1�BaseSubprocessTransportNc
s&t�j|
�d|_||_||_d|_d|_d|_g|_t	j
�|_i|_d|_
|tjkr`d|jd<|tjkrtd|jd<|tjkr�d|jd<y"|jf||||||d�|��Wn|j��YnX|jj|_|j|jd<|jj��rt|ttf�r�|}n|d}tjd||j�|jj|j|	��dS)NFrr�)�args�shell�stdin�stdout�stderr�bufsize�
subprocesszprocess %r created: pid %s)�super�__init__�_closed�	_protocol�_loop�_proc�_pid�_returncode�
_exit_waiters�collections�deque�_pending_calls�_pipes�	_finishedr�PIPE�_start�close�pidZ_extra�	get_debug�
isinstance�bytes�strr�debugZcreate_task�_connect_pipes)
�self�loop�protocolr
rrr
rr�waiterZextra�kwargsZprogram)�	__class__��//usr/lib64/python3.6/asyncio/base_subprocess.pyrs@








z BaseSubprocessTransport.__init__cCs|jjg}|jr|jd�|jdk	r4|jd|j�|jdk	rP|jd|j�n |jdk	rf|jd�n
|jd�|jjd�}|dk	r�|jd|j�|jjd�}|jjd	�}|dk	r�||kr�|jd
|j�n0|dk	r�|jd|j�|dk	r�|jd|j�d
dj	|�S)N�closedzpid=%sz
returncode=%sZrunningznot startedrzstdin=%srr	zstdout=stderr=%sz	stdout=%sz	stderr=%sz<%s>� )
r.�__name__r�appendrrr�get�pipe�join)r)�inforr
rr/r/r0�__repr__9s,





z BaseSubprocessTransport.__repr__cKst�dS)N)�NotImplementedError)r)r
rrr
rrr-r/r/r0r VszBaseSubprocessTransport._startcCs
||_dS)N)r)r)r+r/r/r0�set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0�get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0�
is_closing_sz"BaseSubprocessTransport.is_closingcCs�|jr
dSd|_x&|jj�D]}|dkr*q|jj�qW|jdk	r�|jdkr�|jj�dkr�|jj	�rpt
jd|�y|jj�Wnt
k
r�YnXdS)NTz$Close running child process: kill %r)rr�valuesr6r!rrZpollrr#rZwarning�kill�ProcessLookupError)r)�protor/r/r0r!bs 


zBaseSubprocessTransport.closecCs&|js"tjd|t|d�|j�dS)Nzunclosed transport %r)�source)r�warnings�warn�ResourceWarningr!)r)r/r/r0�__del__�szBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0�get_pid�szBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0�get_returncode�sz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)�fdr/r/r0�get_pipe_transport�s
z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrt��dS)N)rr@)r)r/r/r0�_check_proc�s
z#BaseSubprocessTransport._check_proccCs|j�|jj|�dS)N)rKr�send_signal)r)�signalr/r/r0rL�sz#BaseSubprocessTransport.send_signalcCs|j�|jj�dS)N)rKr�	terminate)r)r/r/r0rN�sz!BaseSubprocessTransport.terminatecCs|j�|jj�dS)N)rKrr?)r)r/r/r0r?�szBaseSubprocessTransport.killc	#sPy�j}�j}|jdk	rB|j�fdd�|j�EdH\}}|�jd<|jdk	rv|j�fdd�|j�EdH\}}|�jd<|jdk	r�|j�fdd�|j�EdH\}}|�jd<|j�j	j
��x"�jD]\}}|j|f|��q�Wd�_WnDtk
�r*}z&|dk	�r|j
��r|j|�WYdd}~Xn"X|dk	�rL|j
��rL|jd�dS)Ncs
t�d�S)Nr)�WriteSubprocessPipeProtor/)r)r/r0�<lambda>�sz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>rcs
t�d�S)Nr)�ReadSubprocessPipeProtor/)r)r/r0rP�srcs
t�d�S)Nr	)rQr/)r)r/r0rP�sr	)rrrZconnect_write_piperr
Zconnect_read_piper�	call_soonr�connection_mader�	Exception�	cancelledZ
set_exception�
set_result)	r)r,�procr*�_r6�callback�data�excr/)r)r0r(�s6









z&BaseSubprocessTransport._connect_pipescGs2|jdk	r|jj||f�n|jj|f|��dS)N)rr4rrR)r)�cbrZr/r/r0�_call�s
zBaseSubprocessTransport._callcCs|j|jj||�|j�dS)N)r]rZpipe_connection_lost�_try_finish)r)rIr[r/r/r0�_pipe_connection_lost�sz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||�dS)N)r]rZpipe_data_received)r)rIrZr/r/r0�_pipe_data_received�sz+BaseSubprocessTransport._pipe_data_receivedcCst|jj�rtjd||�||_|jjdkr2||j_|j|jj	�|j
�x |jD]}|j�sP|j
|�qPWd|_dS)Nz%r exited with return code %r)rr#rr8rr�
returncoder]rZprocess_exitedr^rrUrV)r)rar,r/r/r0�_process_exited�s
z'BaseSubprocessTransport._process_exitedccs0|jdk	r|jS|jj�}|jj|�|EdHS)N)rrZ
create_futurerr4)r)r,r/r/r0�_wait�s


zBaseSubprocessTransport._waitcCs>|jdkrdStdd�|jj�D��r:d|_|j|jd�dS)Ncss|]}|dk	o|jVqdS)N)�disconnected)�.0�pr/r/r0�	<genexpr>�sz6BaseSubprocessTransport._try_finish.<locals>.<genexpr>T)r�allrr>rr]�_call_connection_lost)r)r/r/r0r^�s
z#BaseSubprocessTransport._try_finishcCs*z|jj|�Wdd|_d|_d|_XdS)N)r�connection_lostrr)r)r[r/r/r0ri�s
z-BaseSubprocessTransport._call_connection_lost)NN)r3�
__module__�__qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r]r_r`rbrcr^ri�
__classcell__r/r/)r.r0rs0)%	rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rOcCs||_||_d|_d|_dS)NF)rWrIr6rd)r)rWrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs
||_dS)N)r6)r)Z	transportr/r/r0rSsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|�d|_dS)NT)rdrWr_rI)r)r[r/r/r0rjsz(WriteSubprocessPipeProto.connection_lostcCs|jjj�dS)N)rWr�
pause_writing)r)r/r/r0rnsz&WriteSubprocessPipeProto.pause_writingcCs|jjj�dS)N)rWr�resume_writing)r)r/r/r0rosz'WriteSubprocessPipeProto.resume_writingN)	r3rkrlrrSr9rjrnror/r/r/r0rOsrOc@seZdZdd�ZdS)rQcCs|jj|j|�dS)N)rWr`rI)r)rZr/r/r0�
data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rkrlrpr/r/r/r0rQ!srQ)rrrC�rrrZ
coroutinesr�logrZSubprocessTransportrZBaseProtocolrOZProtocolrQr/r/r/r0�<module>s{PK=�\5�h�@�@$proactor_events.cpython-36.opt-1.pycnu�[���3


 \�O�@s�dZdgZddlZddlZddlmZddlmZddlmZddlmZdd	lm	Z	dd
lm
Z
ddlmZGdd
�d
e
j
e
j�ZGdd�dee
j�ZGdd�dee
j�ZGdd�de�ZGdd�deee
j�ZGdd�deee
j�ZGdd�dej�ZdS)z�Event loop using a proactor and related classes.

A proactor is a "notify-on-completion" multiplexer.  Currently a
proactor is only implemented on Windows with IOCP.
�BaseProactorEventLoop�N�)�base_events)�compat)�	constants)�futures)�sslproto)�
transports)�loggercs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejrXdd�Z
ddd�Zdd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncs�t�j||�|j|�||_||_||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	rh|jj
�|jj|jj|�|dk	r�|jjtj|d�dS)NrF)�super�__init__�
_set_extra�_sock�	_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_eof_writtenZ_attach�_loop�	call_soonZconnection_maderZ_set_result_unless_cancelled)�self�loop�sock�protocol�waiter�extra�server)�	__class__��//usr/lib64/python3.6/asyncio/proactor_events.pyr
s$



z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jdk	rN|jd|jj��|jdk	rh|jd|j�|jdk	r�|jd|j�|jr�t	|j�}|jd|�|j
r�|jd�dd	j|�S)
N�closed�closingzfd=%szread=%szwrite=%rzwrite_bufsize=%szEOF writtenz<%s>� )r"�__name__r�appendr�filenorrr�lenr�join)r�info�bufsizer#r#r$�__repr__/s"







z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)�_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs
||_dS)N)r)rrr#r#r$�set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$�get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$�
is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr
dSd|_|jd7_|jr@|jdkr@|jj|jd�|jdk	rZ|jj�d|_dS)NTr)	rrrrrr�_call_connection_lostr�cancel)rr#r#r$�closeNs

z _ProactorBasePipeTransport.closecCs*|jdk	r&tjd|t|d�|j�dS)Nzunclosed transport %r)�source)r�warnings�warn�ResourceWarningr7)rr#r#r$�__del__]s
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)�exc_info)�message�	exceptionZ	transportr)
�
isinstancerZ_FATAL_ERROR_IGNOREr�	get_debugr
�debug�call_exception_handlerr�_force_close)r�excr?r#r#r$�_fatal_errorcs
z'_ProactorBasePipeTransport._fatal_errorcCsj|jr
dSd|_|jd7_|jr4|jj�d|_|jrJ|jj�d|_d|_d|_|jj|j	|�dS)NTrr)
rrrr6rrrrrr5)rrFr#r#r$rEps

z'_ProactorBasePipeTransport._force_closecCs^z|jj|�Wdt|jd�r,|jjtj�|jj�d|_|j}|dk	rX|j	�d|_XdS)N�shutdown)
rZconnection_lost�hasattrrrH�socketZ	SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk	r|t|j�7}|S)N)rrr+)r�sizer#r#r$�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r(�
__module__�__qualname__�__doc__r
r/rr2r3r4r7rZPY34r<rGrEr5rL�
__classcell__r#r#)r"r$rs

rcs<eZdZdZd�fdd�	Zdd�Zdd�Zdd	d
�Z�ZS)
�_ProactorReadPipeTransportzTransport for read pipes.Ncs4t�j||||||�d|_d|_|jj|j�dS)NF)rr
�_paused�_reschedule_on_resumerr�
_loop_reading)rrrrrr r!)r"r#r$r
�sz#_ProactorReadPipeTransport.__init__cCs0|js|jrdSd|_|jj�r,tjd|�dS)NTz%r pauses reading)rrRrrBr
rC)rr#r#r$�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsP|js|jrdSd|_|jr6|jj|j|j�d|_|jj�rLtj	d|�dS)NFz%r resumes reading)
rrRrSrrrTrrBr
rC)rr#r#r$�resume_reading�s
z)_ProactorReadPipeTransport.resume_readingcCs�|jrd|_dSd}�z"yH|dk	r0d|_|j�}|jr>d}dS|dkrJdS|jjj|jd�|_Wn�t	k
r�}z2|js�|j
|d�n|jj�r�tj
ddd�WYdd}~Xn�tk
r�}z|j|�WYdd}~Xn^tk
�r}z|j
|d�WYdd}~Xn0tjk
�r&|j�s"�YnX|jj|j�Wd|�rN|jj|�n:|dk	�r�|jj��rptj
d|�|jj�}|�s�|j�XdS)NT�iz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rRrSr�resultrr�	_proactor�recvr�ConnectionAbortedErrorrGrBr
rC�ConnectionResetErrorrE�OSErrorr�CancelledError�add_done_callbackrTrZ
data_receivedZeof_receivedr7)r�fut�datarFZ	keep_openr#r#r$rT�sH


z(_ProactorReadPipeTransport._loop_reading)NNN)N)	r(rMrNrOr
rUrVrTrPr#r#)r"r$rQ�s
rQc@s:eZdZdZdd�Zd
dd�Zdd�Zd	d
�Zdd�ZdS)�_ProactorBaseWritePipeTransportzTransport for write pipes.cCs�t|tttf�s&dt|�j}t|��|jr4td��|s<dS|j	rj|j	t
jkrXtj
d�|j	d7_	dS|jdkr�|jt|�d�n.|js�t|�|_|j�n|jj|�|j�dS)Nz3data argument must be a bytes-like object, not '%s'zwrite_eof() already calledzsocket.send() raised exception.r)ra)rA�bytes�	bytearray�
memoryview�typer(�	TypeErrorr�RuntimeErrorrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�
_loop_writingr�_maybe_pause_protocol�extend)rra�msgr#r#r$�write�s(



z%_ProactorBaseWritePipeTransport.writeNcCsy�d|_d|_|r|j�|dkr.|j}d|_|sf|jrH|jj|jd�|jr\|j	j
tj�|j
�nN|jjj|j	|�|_|jj�s�t|�|_|jj|j�|j�n|jj|j�WnZtk
r�}z|j|�WYdd}~Xn0tk
�r}z|j|d�WYdd}~XnXdS)Nrz#Fatal write error on pipe transport)rrrXrrrrr5rrrHrJ�SHUT_WRZ_maybe_resume_protocolrY�send�doner+r_rjrkr\rEr]rG)r�frarFr#r#r$rj
s0



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS)NTr#)rr#r#r$�
can_write_eof0sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|j�dS)N)r7)rr#r#r$�	write_eof3sz)_ProactorBaseWritePipeTransport.write_eofcCs|jd�dS)N)rE)rr#r#r$�abort6sz%_ProactorBaseWritePipeTransport.abort)NN)	r(rMrNrOrnrjrsrtrur#r#r#r$rb�s$
#rbcs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs4t�j||�|jjj|jd�|_|jj|j�dS)N�)	rr
rrYrZrrr_�_pipe_closed)r�args�kw)r"r#r$r
;sz$_ProactorWritePipeTransport.__init__cCs@|j�rdS|jrdSd|_|jdk	r4|jt��n|j�dS)N)Z	cancelledrrrrE�BrokenPipeErrorr7)rr`r#r#r$rx@s
z(_ProactorWritePipeTransport._pipe_closed)r(rMrNr
rxrPr#r#)r"r$rv:srvc@s eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFr#)rr#r#r$rsUsz*_ProactorDuplexPipeTransport.can_write_eofcCst�dS)N)�NotImplementedError)rr#r#r$rtXsz&_ProactorDuplexPipeTransport.write_eofN)r(rMrNrOrsrtr#r#r#r$r|Psr|cs:eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Z�ZS)�_ProactorSocketTransportz Transport for connected sockets.Ncs$t�j||||||�tj|�dS)N)rr
rZ_set_nodelay)rrrrrr r!)r"r#r$r
asz!_ProactorSocketTransport.__init__cCs�||jd<y|j�|jd<Wn4tjtfk
rP|jj�rLtjd|dd�YnXd|jkr�y|j	�|jd<Wn4tjtfk
r�|jj�r�tjd|dd�YnXdS)NrJZsocknamezgetsockname() failed on %rT)r>�peernamezgetpeername() failed on %r)
r1ZgetsocknamerJ�error�AttributeErrorrrBr
riZgetpeername)rrr#r#r$rfs



z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rsvsz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdkr.|jjtj�dS)NT)rrrrrHrJro)rr#r#r$rtys

z"_ProactorSocketTransport.write_eof)NNN)	r(rMrNrOr
rrsrtrPr#r#)r"r$r~\sr~cs�eZdZ�fdd�Zd-dd�Zd.ddddd�dd	�Zd/d
d�Zd0dd
�Zd1dd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd2d d!�Zd"d#�Zd3d%d&�Zd'd(�Zd)d*�Zd+d,�Z�ZS)4rcsHt�j�tjd|jj�||_||_d|_i|_	|j
|�|j�dS)NzUsing proactor: %s)rr
r
rCr"r(rY�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe)rZproactor)r"r#r$r
�s

zBaseProactorEventLoop.__init__NcCst||||||�S)N)r~)rrrrr r!r#r#r$�_make_socket_transport�s
z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer r!c
Cs<tj�std��tj||||||�}	t|||	||d�|	jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler}ZSSLProtocolr~Z_app_transport)
rZrawsockr�
sslcontextrr�r�r r!Zssl_protocolr#r#r$�_make_ssl_transport�s
z)BaseProactorEventLoop._make_ssl_transportcCst|||||�S)N)r|)rrrrr r#r#r$�_make_duplex_pipe_transport�sz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�S)N)rQ)rrrrr r#r#r$�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�S)N)rv)rrrrr r#r#r$�_make_write_pipe_transport�sz0BaseProactorEventLoop._make_write_pipe_transportcsP|j�rtd��|j�rdS|j�|j�|jj�d|_d|_t�j�dS)Nz!Cannot close a running event loop)	Z
is_runningrh�	is_closed�_stop_accept_futures�_close_self_piperYr7r�r)r)r"r#r$r7�s
zBaseProactorEventLoop.closecCs|jj||�S)N)rYrZ)rr�nr#r#r$�	sock_recv�szBaseProactorEventLoop.sock_recvcCs|jj||�S)N)rYrp)rrrar#r#r$�sock_sendall�sz"BaseProactorEventLoop.sock_sendallcCs|jj||�S)N)rYZconnect)rrZaddressr#r#r$�sock_connect�sz"BaseProactorEventLoop.sock_connectcCs|jj|�S)N)rY�accept)rrr#r#r$�sock_accept�sz!BaseProactorEventLoop.sock_acceptcCst�dS)N)r})rr#r#r$�_socketpair�sz!BaseProactorEventLoop._socketpaircCsL|jdk	r|jj�d|_|jj�d|_|jj�d|_|jd8_dS)Nr)r�r6�_ssockr7�_csock�
_internal_fds)rr#r#r$r��s



z&BaseProactorEventLoop._close_self_pipecCsF|j�\|_|_|jjd�|jjd�|jd7_|j|j�dS)NFr)r�r�r�Zsetblockingr�r�_loop_self_reading)rr#r#r$r��s
z%BaseProactorEventLoop._make_self_pipecCs�y$|dk	r|j�|jj|jd�}WnHtjk
r:dStk
rl}z|jd||d��WYdd}~XnX||_|j	|j
�dS)Niz.Error on reading from the event loop self pipe)r?r@r)rXrYrZr�rr^�	ExceptionrDr�r_r�)rrrrFr#r#r$r��sz(BaseProactorEventLoop._loop_self_readingcCs|jjd�dS)N�)r�rp)rr#r#r$�_write_to_self�sz$BaseProactorEventLoop._write_to_self�dcs&d������fdd�	��j��dS)Ncs"y�|dk	rl|j�\}}�jr,tjd�||���}�dk	rV�j||�dd|i�d�n�j||d|i�d��j�rxdS�jj��}Wn~t	k
r�}zD�j
�dkr��jd|�d���j�n�jr�tjd	�dd
�WYdd}~Xn8t
jk
�r�j�YnX|�j�j
�<|j��dS)Nz#%r got a new connection from %r: %rTr)r�r r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>���)rXZ_debugr
rCr�r�r�rYr�r]r*rDr7rr^r�r_)rrZconnZaddrrrF)r�protocol_factoryrr!rr�r#r$r�s>


z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r)rr�rr�r!Zbacklogr#)rr�rr!rr�r$�_start_serving�s$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ
event_listr#r#r$�_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jj�D]}|j�qW|jj�dS)N)r��valuesr6�clear)rZfuturer#r#r$r�$sz*BaseProactorEventLoop._stop_accept_futurescCs |j�|jj|�|j�dS)N)r�rY�
_stop_servingr7)rrr#r#r$r�)sz#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr�)r(rMrNr
r�r�r�r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�rPr#r#)r"r$r�s4







()rO�__all__rJr9�rrrrrr	�logr
Z_FlowControlMixinZ
BaseTransportrZ
ReadTransportrQZWriteTransportrbrvZ	Transportr|r~Z
BaseEventLooprr#r#r#r$�<module>s2MT
#PK=�\Y����futures.cpython-36.opt-2.pycnu�[���3


 \>�@sddddddgZddlZddlZddlZddlZdd	lmZdd
lmZddlm	Z	ej
Z
ejZejZej
Z
ejZejZejZejdZGdd
�d
�ZGdd�d�ZeZdd�Zdd�Zdd�Zdd�Zdd�dd�ZyddlZWnek
r�YnXejZZdS)�CancelledError�TimeoutError�InvalidStateError�Future�wrap_future�isfuture�N�)�base_futures)�compat)�eventsc@s0eZdZdZdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracebackLogger�loop�source_traceback�exc�tbcCs |j|_|j|_||_d|_dS)N)�_loopr
�_source_tracebackrrr)�self�futurer�r�'/usr/lib64/python3.6/asyncio/futures.py�__init__Rsz_TracebackLogger.__init__cCs,|j}|dk	r(d|_tj|j||j�|_dS)N)r�	traceback�format_exception�	__class__�
__traceback__r)rrrrr�activateXs

z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrr�clear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j��}|d7}|d|j�7}|dj|j�j�7}|jjd|i�dS)Nz*Future/Task exception was never retrieved
�z0Future/Task created at (most recent call last):
z%s
�message)rr�joinr�format_list�rstripr
�call_exception_handler)r�msg�srcrrr�__del__csz_TracebackLogger.__del__N)r
rrr)�__name__�
__module__�__qualname__�	__slots__rrrr&rrrrrs
2rc@s�eZdZeZdZdZdZdZdZ	dZ
dd�dd�Zej
Zdd�ZejrNdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zejr�eZdS) rNF)r
cCs@|dkrtj�|_n||_g|_|jj�r<tjtjd��|_dS)Nr)	r�get_event_loopr�
_callbacksZ	get_debug�
extract_stack�sys�	_getframer)rr
rrrr�s
zFuture.__init__cCsd|jjdj|j��fS)Nz<%s %s>� )rr'r �
_repr_info)rrrr�__repr__�szFuture.__repr__cCsD|js
dS|j}d|jj||d�}|jr4|j|d<|jj|�dS)Nz %s exception was never retrieved)r�	exceptionrr)�_log_traceback�
_exceptionrr'rrr#)rr�contextrrrr&�s
zFuture.__del__cCs&d|_|jtkrdSt|_|j�dS)NFT)r4�_state�_PENDING�
_CANCELLED�_schedule_callbacks)rrrr�cancel�s
z
Future.cancelcCsD|jdd�}|sdSg|jdd�<x|D]}|jj||�q*WdS)N)r,r�	call_soon)rZ	callbacks�callbackrrrr:�s
zFuture._schedule_callbackscCs
|jtkS)N)r7r9)rrrr�	cancelled�szFuture.cancelledcCs
|jtkS)N)r7r8)rrrr�done�szFuture.donecCs<|jtkrt�|jtkr td��d|_|jdk	r6|j�|jS)NzResult is not ready.F)r7r9r�	_FINISHEDrr4r5�_result)rrrr�result�s


z
Future.resultcCs,|jtkrt�|jtkr td��d|_|jS)NzException is not set.F)r7r9rr@rr4r5)rrrrr3�s

zFuture.exceptioncCs*|jtkr|jj||�n|jj|�dS)N)r7r8rr<r,�append)r�fnrrr�add_done_callbacks
zFuture.add_done_callbackcs<�fdd�|jD�}t|j�t|�}|r8||jdd�<|S)Ncsg|]}|�kr|�qSrr)�.0�f)rDrr�
<listcomp>sz/Future.remove_done_callback.<locals>.<listcomp>)r,�len)rrDZfiltered_callbacksZ
removed_countr)rDr�remove_done_callbacks
zFuture.remove_done_callbackcCs4|jtkrtdj|j|���||_t|_|j�dS)Nz{}: {!r})r7r8r�formatrAr@r:)rrBrrr�
set_result s

zFuture.set_resultcCs�|jtkrtdj|j|���t|t�r,|�}t|�tkr@td��||_t	|_|j
�tjrbd|_
nt||�|_|jj|jj�dS)Nz{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureT)r7r8rrK�
isinstance�type�
StopIteration�	TypeErrorr5r@r:r
�PY34r4rZ
_tb_loggerrr<r)rr3rrr�
set_exception,s

zFuture.set_exceptionccs|j�sd|_|V|j�S)NT)r?�_asyncio_future_blockingrB)rrrr�__iter__DszFuture.__iter__) r'r(r)r8r7rAr5rrrSr4rr	Z_future_repr_infor1r2r
rQr&r;r:r>r?rBr3rErJrLrRrTZPY35�	__await__rrrrrns2

cCs|j�rdS|j|�dS)N)r>rL)ZfutrBrrr�_set_result_unless_cancelledSsrVcCsN|j�r|j�|j�sdS|j�}|dk	r8|j|�n|j�}|j|�dS)N)r>r;Zset_running_or_notify_cancelr3rRrBrL)�
concurrent�sourcer3rBrrr�_set_concurrent_future_stateZsrYcCsP|j�rdS|j�r|j�n.|j�}|dk	r:|j|�n|j�}|j|�dS)N)r>r;r3rRrBrL)rX�destr3rBrrr�_copy_future_stateis
r[cs�t��r"t�tjj�r"td��t��rDt�tjj�rDtd��t��rR�jnd�t��rd�jnd�dd�����fdd�}����fdd�}�j|��j|�dS)	Nz(A future is required for source argumentz-A future is required for destination argumentcSs"t|�rt||�n
t||�dS)N)rr[rY)r�otherrrr�
_set_state�sz!_chain_future.<locals>._set_statecs2|j�r.�dks��kr"�j�n�j�j�dS)N)r>r;�call_soon_threadsafe)�destination)�	dest_looprX�source_looprr�_call_check_cancel�s
z)_chain_future.<locals>._call_check_cancelcsJ�j�r�dk	r�j�rdS�dks,��kr8��|�n�j��|�dS)N)r>Z	is_closedr^)rX)r]r`r_rarr�_call_set_state�sz&_chain_future.<locals>._call_set_state)rrMrWZfuturesrrPrrE)rXr_rbrcr)r]r`r_rXrar�
_chain_future}s	
rd)r
cCs2t|�r|S|dkrtj�}|j�}t||�|S)N)rrr+Z
create_futurerd)rr
Z
new_futurerrrr�s
)�__all__Zconcurrent.futuresrWZloggingr.rrr	r
rrrrrr8r9r@�DEBUGZSTACK_DEBUGrrZ	_PyFuturerVrYr[rdrZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s<

Pc*
PK=�\6����D�Devents.cpython-36.opt-2.pycnu�[���3


 \�[�@s|dddddddddd	d
ddd
gZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZdd�Z
dd�Zd2dd�Zdd�Zd3dd�ZGdd�d�ZGdd�de�ZGd d�d�ZGd!d�d�ZGd"d�d�ZGd#d$�d$e�Zdaej�ZGd%d&�d&ej�Ze�Zd'd
�Zd(d�Zd)d*�Z d+d�Z!d,d�Z"d-d�Z#d.d�Z$d/d	�Z%d0d
�Z&d1d�Z'dS)4�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�_get_running_loop�N�)�compat)�	constantscCsttjrtj|�}nt|d�r"|j}tj|�r>|j}|j|j	fSt
|tj�rTt
|j�Stjrpt
|tj�rpt
|j�SdS)N�__wrapped__)rZPY34�inspectZunwrap�hasattrrZ
isfunction�__code__�co_filename�co_firstlineno�
isinstance�	functools�partial�_get_function_source�func�
partialmethod)r�code�r �&/usr/lib64/python3.6/asyncio/events.pyrs



rcCsJg}|r|jdd�|D��|r8|jdd�|j�D��ddj|�dS)Ncss|]}tj|�VqdS)N)�reprlib�repr)�.0�argr r r!�	<genexpr>1sz*_format_args_and_kwargs.<locals>.<genexpr>css$|]\}}dj|tj|��VqdS)z{}={}N)�formatr"r#)r$�k�vr r r!r&3s�(z, �))�extend�items�join)�args�kwargsr-r r r!�_format_args_and_kwargs)s
r1�cCs�t|tj�r.t||�|}t|j|j|j|�St|d�rF|j	rF|j	}n t|d�r^|j
r^|j
}nt|�}|t||�7}|r�||7}|S)N�__qualname__�__name__)rrrr1�_format_callbackrr/�keywordsrr3r4r#)rr/r0�suffix�	func_reprr r r!r58sr5cCs(t||d�}t|�}|r$|d|7}|S)Nz	 at %s:%s)r5r)rr/r8�sourcer r r!�_format_callback_sourceIs
r:cCsD|dkrtj�j}|dkr tj}tjjtj|�|dd�}|j	�|S)NF)�limit�lookup_lines)
�sys�	_getframe�f_backrZDEBUG_STACK_DEPTH�	traceback�StackSummary�extract�
walk_stack�reverse)�fr;�stackr r r!�
extract_stackQs
rGc@s8eZdZdZdd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)r�	_callback�_args�
_cancelled�_loop�_source_traceback�_repr�__weakref__cCsD||_||_||_d|_d|_|jj�r:ttjd��|_	nd|_	dS)NFr)
rKrHrIrJrM�	get_debugrGr=r>rL)�self�callbackr/�loopr r r!�__init__hs
zHandle.__init__cCsf|jjg}|jr|jd�|jdk	r8|jt|j|j��|jrb|jd}|jd|d|df�|S)NZ	cancelledrzcreated at %s:%sr���)�	__class__r4rJ�appendrHr:rIrL)rP�info�framer r r!�
_repr_infoss



zHandle._repr_infocCs&|jdk	r|jS|j�}ddj|�S)Nz<%s>� )rMrYr.)rPrWr r r!�__repr__~s
zHandle.__repr__cCs0|js,d|_|jj�r t|�|_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!�cancel�s

z
Handle.cancelcCs|y|j|j�Wnbtk
rr}zFt|j|j�}dj|�}|||d�}|jrV|j|d<|jj|�WYdd}~XnXd}dS)NzException in callback {})�messageZ	exception�handleZsource_traceback)rHrI�	Exceptionr:r'rLrK�call_exception_handler)rP�exc�cb�msg�contextr r r!�_run�s

zHandle._runN)rHrIrJrKrLrMrN)	r4�
__module__r3�	__slots__rSrYr[r\rer r r r!rbscsteZdZddgZ�fdd�Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Z�fdd�Z
�ZS)r�
_scheduled�_whencs.t�j|||�|jr|jd=||_d|_dS)NrFrT)�superrSrLrirh)rP�whenrQr/rR)rUr r!rS�s
zTimerHandle.__init__cs.t�j�}|jrdnd}|j|d|j�|S)N�rzwhen=%s)rjrYrJ�insertri)rPrW�pos)rUr r!rY�s
zTimerHandle._repr_infocCs
t|j�S)N)�hashri)rPr r r!�__hash__�szTimerHandle.__hash__cCs|j|jkS)N)ri)rP�otherr r r!�__lt__�szTimerHandle.__lt__cCs|j|jkrdS|j|�S)NT)ri�__eq__)rPrqr r r!�__le__�szTimerHandle.__le__cCs|j|jkS)N)ri)rPrqr r r!�__gt__�szTimerHandle.__gt__cCs|j|jkrdS|j|�S)NT)rirs)rPrqr r r!�__ge__�szTimerHandle.__ge__cCs>t|t�r:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrirHrIrJ�NotImplemented)rPrqr r r!rs�s
zTimerHandle.__eq__cCs|j|�}|tkrtS|S)N)rsrw)rPrqZequalr r r!�__ne__�s
zTimerHandle.__ne__cs |js|jj|�t�j�dS)N)rJrK�_timer_handle_cancelledrjr\)rP)rUr r!r\�szTimerHandle.cancel)r4rfr3rgrSrYrprrrtrurvrsrxr\�
__classcell__r r )rUr!r�sc@seZdZdd�Zdd�ZdS)rcCstS)N)rw)rPr r r!�close�szAbstractServer.closecCstS)N)rw)rPr r r!�wait_closed�szAbstractServer.wait_closedN)r4rfr3r{r|r r r r!r�sc	@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d#d#d#d$�d%d&�Zdgd'd(�Zdhd)d#d#d#d)d)d)d*�d+d,�Zdiejejd)d-d)d)d)d.�d/d0�Zd)d)d)d1�d2d3�Zd)d-d)d4�d5d6�Zdjd#d#d#d)d)d)d)d7�d8d9�Zd:d;�Zd<d=�Ze j!e j!e j!d>�d?d@�Z"e j!e j!e j!d>�dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5d)S)krcCst�dS)N)�NotImplementedError)rPr r r!�run_forever�szAbstractEventLoop.run_forevercCst�dS)N)r})rPZfuturer r r!�run_until_complete�sz$AbstractEventLoop.run_until_completecCst�dS)N)r})rPr r r!�stop�szAbstractEventLoop.stopcCst�dS)N)r})rPr r r!�
is_running�szAbstractEventLoop.is_runningcCst�dS)N)r})rPr r r!�	is_closedszAbstractEventLoop.is_closedcCst�dS)N)r})rPr r r!r{s	zAbstractEventLoop.closecCst�dS)N)r})rPr r r!�shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCst�dS)N)r})rPr^r r r!rysz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|��S)Nr)�
call_later)rPrQr/r r r!�	call_soonszAbstractEventLoop.call_sooncGst�dS)N)r})rPZdelayrQr/r r r!r�szAbstractEventLoop.call_latercGst�dS)N)r})rPrkrQr/r r r!�call_atszAbstractEventLoop.call_atcCst�dS)N)r})rPr r r!�time"szAbstractEventLoop.timecCst�dS)N)r})rPr r r!�
create_future%szAbstractEventLoop.create_futurecCst�dS)N)r})rP�coror r r!�create_task*szAbstractEventLoop.create_taskcGst�dS)N)r})rPrQr/r r r!�call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGst�dS)N)r})rP�executorrr/r r r!�run_in_executor2sz!AbstractEventLoop.run_in_executorcCst�dS)N)r})rPr�r r r!�set_default_executor5sz&AbstractEventLoop.set_default_executorr)�family�type�proto�flagscCst�dS)N)r})rP�host�portr�r�r�r�r r r!�getaddrinfo:szAbstractEventLoop.getaddrinfocCst�dS)N)r})rPZsockaddrr�r r r!�getnameinfo=szAbstractEventLoop.getnameinfoN)�sslr�r�r��sock�
local_addr�server_hostnamecCst�dS)N)r})rP�protocol_factoryr�r�r�r�r�r�r�r�r�r r r!�create_connection@sz#AbstractEventLoop.create_connection�d)r�r�r��backlogr��
reuse_address�
reuse_portcCst�dS)N)r})rPr�r�r�r�r�r�r�r�r�r�r r r!�
create_serverEs'zAbstractEventLoop.create_server)r�r�r�cCst�dS)N)r})rPr��pathr�r�r�r r r!�create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)r�r�r�cCst�dS)N)r})rPr�r�r�r�r�r r r!�create_unix_serverssz$AbstractEventLoop.create_unix_server)r�r�r�r�r��allow_broadcastr�cCst�dS)N)r})rPr�r�Zremote_addrr�r�r�r�r�r�r�r r r!�create_datagram_endpoint�s!z*AbstractEventLoop.create_datagram_endpointcCst�dS)N)r})rPr��piper r r!�connect_read_pipe�sz#AbstractEventLoop.connect_read_pipecCst�dS)N)r})rPr�r�r r r!�connect_write_pipe�sz$AbstractEventLoop.connect_write_pipe)�stdin�stdout�stderrcKst�dS)N)r})rPr��cmdr�r�r�r0r r r!�subprocess_shell�sz"AbstractEventLoop.subprocess_shellcOst�dS)N)r})rPr�r�r�r�r/r0r r r!�subprocess_exec�sz!AbstractEventLoop.subprocess_execcGst�dS)N)r})rP�fdrQr/r r r!�
add_reader�szAbstractEventLoop.add_readercCst�dS)N)r})rPr�r r r!�
remove_reader�szAbstractEventLoop.remove_readercGst�dS)N)r})rPr�rQr/r r r!�
add_writer�szAbstractEventLoop.add_writercCst�dS)N)r})rPr�r r r!�
remove_writer�szAbstractEventLoop.remove_writercCst�dS)N)r})rPr��nbytesr r r!�	sock_recv�szAbstractEventLoop.sock_recvcCst�dS)N)r})rPr��datar r r!�sock_sendall�szAbstractEventLoop.sock_sendallcCst�dS)N)r})rPr�Zaddressr r r!�sock_connect�szAbstractEventLoop.sock_connectcCst�dS)N)r})rPr�r r r!�sock_accept�szAbstractEventLoop.sock_acceptcGst�dS)N)r})rP�sigrQr/r r r!�add_signal_handler�sz$AbstractEventLoop.add_signal_handlercCst�dS)N)r})rPr�r r r!�remove_signal_handler�sz'AbstractEventLoop.remove_signal_handlercCst�dS)N)r})rP�factoryr r r!�set_task_factory�sz"AbstractEventLoop.set_task_factorycCst�dS)N)r})rPr r r!�get_task_factory�sz"AbstractEventLoop.get_task_factorycCst�dS)N)r})rPr r r!�get_exception_handlersz'AbstractEventLoop.get_exception_handlercCst�dS)N)r})rPZhandlerr r r!�set_exception_handlersz'AbstractEventLoop.set_exception_handlercCst�dS)N)r})rPrdr r r!�default_exception_handlersz+AbstractEventLoop.default_exception_handlercCst�dS)N)r})rPrdr r r!r`sz(AbstractEventLoop.call_exception_handlercCst�dS)N)r})rPr r r!rOszAbstractEventLoop.get_debugcCst�dS)N)r})rPZenabledr r r!�	set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)6r4rfr3r~rr�r�r�r{r�ryr�r�r�r�r�r�r�r�r�r�r�r��socketZ	AF_UNSPECZ
AI_PASSIVEr�r�r�r�r�r��
subprocess�PIPEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r`rOr�r r r r!r�sr

'!

	c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rcCst�dS)N)r})rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCst�dS)N)r})rPrRr r r!r	$sz&AbstractEventLoopPolicy.set_event_loopcCst�dS)N)r})rPr r r!r
(sz&AbstractEventLoopPolicy.new_event_loopcCst�dS)N)r})rPr r r!r0sz)AbstractEventLoopPolicy.get_child_watchercCst�dS)N)r})rP�watcherr r r!r4sz)AbstractEventLoopPolicy.set_child_watcherN)r4rfr3rr	r
rrr r r r!rs

c@sBeZdZdZGdd�dej�Zdd�Zdd�Zdd	�Z	d
d�Z
dS)�BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK�_set_calledr r r r!�_LocalHsr�cCs|j�|_dS)N)r��_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jjr4ttj�tj�r4|j|j��|jjdkrRt	dtj�j
��|jjS)Nz,There is no current event loop in thread %r.)r�rKr�r�	threadingZcurrent_threadZ_MainThreadr	r
�RuntimeError�name)rPr r r!rOs
z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)NT)r�r�rK)rPrRr r r!r	]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|j�S)N)�
_loop_factory)rPr r r!r
csz)BaseDefaultEventLoopPolicy.new_event_loop)r4rfr3r�r��localr�rSrr	r
r r r r!r�9s
r�c@seZdZdZdS)�_RunningLoopN)NN)r4rfr3�loop_pidr r r r!r�wsr�cCs&tj\}}|dk	r"|tj�kr"|SdS)N)�
_running_loopr��os�getpid)Zrunning_loop�pidr r r!r~s
cCs|tj�ft_dS)N)r�r�r�r�)rRr r r!r
�sc	Cs.t� tdkr ddlm}|�aWdQRXdS)Nr)�DefaultEventLoopPolicy)�_lock�_event_loop_policyr2r�)r�r r r!�_init_event_loop_policy�sr�cCstdkrt�tS)N)r�r�r r r r!r�scCs|adS)N)r�)Zpolicyr r r!r�scCst�}|dk	r|St�j�S)N)rrr)Zcurrent_loopr r r!r�s	cCst�j|�dS)N)rr	)rRr r r!r	�scCs
t�j�S)N)rr
r r r r!r
�scCs
t�j�S)N)rrr r r r!r�scCst�j|�S)N)rr)r�r r r!r�s)r2)NN)(�__all__rrr�r"r�r�r=r�r@r2rrrr1r5r:rGrrrrrr�r�ZLockr�r�r�r�rr
r�rrrr	r
rrr r r r!�<module>sX

>85"7		PK=�\3'~��!base_futures.cpython-36.opt-2.pycnu�[���3


 \�@srgZddlZddlZddlmZejjjZejj	Z	ejj
Z
Gdd�de�ZdZdZ
dZd	d
�Zdd�Zd
d�ZdS)�N�)�eventsc@seZdZdS)�InvalidStateErrorN)�__name__�
__module__�__qualname__�rr�,/usr/lib64/python3.6/asyncio/base_futures.pyr
srZPENDINGZ	CANCELLEDZFINISHEDcCst|jd�o|jdk	S)N�_asyncio_future_blocking)�hasattr�	__class__r
)�objrrr	�isfuturesrcCs�t|�}|sd}dd�}|dkr.||d�}nP|dkrTdj||d�||d��}n*|dkr~dj||d�|d||d
��}d	|S)N�cSstj|f�S)N)rZ_format_callback_source)�callbackrrr	�	format_cb(sz$_format_callbacks.<locals>.format_cbrr�z{}, {}z{}, <{} more>, {}zcb=[%s]���)�len�format)�cb�sizerrrr	�_format_callbacks"srcCs�|jj�g}|jtkrP|jdk	r4|jdj|j��ntj|j�}|jdj|��|j	rf|jt
|j	��|jr�|jd}|jd|d|df�|S)Nzexception={!r}z	result={}rzcreated at %s:%srr)Z_state�lower�	_FINISHEDZ
_exception�appendr�reprlib�reprZ_resultZ
_callbacksrZ_source_traceback)Zfuture�info�result�framerrr	�_future_repr_info6s


r!)�__all__Zconcurrent.futures._baseZ
concurrentrrrZfuturesZ_base�ErrorZCancelledError�TimeoutErrorrZ_PENDINGZ
_CANCELLEDrrrr!rrrr	�<module>s
PK=�\��z�4�4futures.cpython-36.opt-1.pycnu�[���3


 \>�@s
dZddddddgZddlZddlZddlZddlZd	d
lmZd	dlm	Z	d	dlm
Z
ejZejZej
Z
ejZejZejZejZejd	ZGd
d�d�ZGdd�d�ZeZdd�Zdd�Zdd�Zdd�Zdd�dd�ZyddlZWnek
r�YnXejZZdS)z.A Future class similar to the one in PEP 3148.�CancelledError�TimeoutError�InvalidStateError�Future�wrap_future�isfuture�N�)�base_futures)�compat)�eventsc@s4eZdZdZdZdd�Zdd	�Zd
d�Zdd
�ZdS)�_TracebackLoggera
Helper to log a traceback upon destruction if not cleared.

    This solves a nasty problem with Futures and Tasks that have an
    exception set: if nobody asks for the exception, the exception is
    never logged.  This violates the Zen of Python: 'Errors should
    never pass silently.  Unless explicitly silenced.'

    However, we don't want to log the exception as soon as
    set_exception() is called: if the calling code is written
    properly, it will get the exception and handle it properly.  But
    we *do* want to log it if result() or exception() was never called
    -- otherwise developers waste a lot of time wondering why their
    buggy code fails silently.

    An earlier attempt added a __del__() method to the Future class
    itself, but this backfired because the presence of __del__()
    prevents garbage collection from breaking cycles.  A way out of
    this catch-22 is to avoid having a __del__() method on the Future
    class itself, but instead to have a reference to a helper object
    with a __del__() method that logs the traceback, where we ensure
    that the helper object doesn't participate in cycles, and only the
    Future has a reference to it.

    The helper object is added when set_exception() is called.  When
    the Future is collected, and the helper is present, the helper
    object is also collected, and its __del__() method will log the
    traceback.  When the Future's result() or exception() method is
    called (and a helper object is present), it removes the helper
    object, after calling its clear() method to prevent it from
    logging.

    One downside is that we do a fair amount of work to extract the
    traceback from the exception, even when it is never logged.  It
    would seem cheaper to just store the exception object, but that
    references the traceback, which references stack frames, which may
    reference the Future, which references the _TracebackLogger, and
    then the _TracebackLogger would be included in a cycle, which is
    what we're trying to avoid!  As an optimization, we don't
    immediately format the exception; we only do the work when
    activate() is called, which call is delayed until after all the
    Future's callbacks have run.  Since usually a Future has at least
    one callback (typically set by 'yield from') and usually that
    callback extracts the callback, thereby removing the need to
    format the exception.

    PS. I don't claim credit for this solution.  I first heard of it
    in a discussion about closing files when they are collected.
    �loop�source_traceback�exc�tbcCs |j|_|j|_||_d|_dS)N)�_loopr
�_source_tracebackrrr)�self�futurer�r�'/usr/lib64/python3.6/asyncio/futures.py�__init__Rsz_TracebackLogger.__init__cCs,|j}|dk	r(d|_tj|j||j�|_dS)N)r�	traceback�format_exception�	__class__�
__traceback__r)rrrrr�activateXs

z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrr�clear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j��}|d7}|d|j�7}|dj|j�j�7}|jjd|i�dS)Nz*Future/Task exception was never retrieved
�z0Future/Task created at (most recent call last):
z%s
�message)rr�joinr�format_list�rstripr
�call_exception_handler)r�msg�srcrrr�__del__csz_TracebackLogger.__del__N)r
rrr)	�__name__�
__module__�__qualname__�__doc__�	__slots__rrrr&rrrrrs0rc@s�eZdZdZeZdZdZdZdZ	dZ
dZdd�dd�Ze
jZdd�ZejrRd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zejr�eZ dS)!ra,This class is *almost* compatible with concurrent.futures.Future.

    Differences:

    - This class is not thread-safe.

    - result() and exception() do not take a timeout argument and
      raise an exception when the future isn't done yet.

    - Callbacks registered with add_done_callback() are always called
      via the event loop's call_soon().

    - This class is not compatible with the wait() and as_completed()
      methods in the concurrent.futures package.

    (In Python 3.4 or later we may be able to unify the implementations.)
    NF)r
cCs@|dkrtj�|_n||_g|_|jj�r<tjtjd��|_dS)z�Initialize the future.

        The optional event_loop argument allows explicitly setting the event
        loop object used by the future. If it's not provided, the future uses
        the default event loop.
        Nr)	r�get_event_loopr�
_callbacksZ	get_debug�
extract_stack�sys�	_getframer)rr
rrrr�s
zFuture.__init__cCsd|jjdj|j��fS)Nz<%s %s>� )rr'r �
_repr_info)rrrr�__repr__�szFuture.__repr__cCsD|js
dS|j}d|jj||d�}|jr4|j|d<|jj|�dS)Nz %s exception was never retrieved)r�	exceptionrr)�_log_traceback�
_exceptionrr'rrr#)rr�contextrrrr&�s
zFuture.__del__cCs&d|_|jtkrdSt|_|j�dS)z�Cancel the future and schedule callbacks.

        If the future is already done or cancelled, return False.  Otherwise,
        change the future's state to cancelled, schedule the callbacks and
        return True.
        FT)r5�_state�_PENDING�
_CANCELLED�_schedule_callbacks)rrrr�cancel�s
z
Future.cancelcCsD|jdd�}|sdSg|jdd�<x|D]}|jj||�q*WdS)z�Internal: Ask the event loop to call all callbacks.

        The callbacks are scheduled to be called as soon as possible. Also
        clears the callback list.
        N)r-r�	call_soon)rZ	callbacks�callbackrrrr;�s
zFuture._schedule_callbackscCs
|jtkS)z(Return True if the future was cancelled.)r8r:)rrrr�	cancelled�szFuture.cancelledcCs
|jtkS)z�Return True if the future is done.

        Done means either that a result / exception are available, or that the
        future was cancelled.
        )r8r9)rrrr�done�szFuture.donecCs<|jtkrt�|jtkr td��d|_|jdk	r6|j�|jS)aReturn the result this future represents.

        If the future has been cancelled, raises CancelledError.  If the
        future's result isn't yet available, raises InvalidStateError.  If
        the future is done and has an exception set, this exception is raised.
        zResult is not ready.FN)r8r:r�	_FINISHEDrr5r6�_result)rrrr�result�s


z
Future.resultcCs,|jtkrt�|jtkr td��d|_|jS)a&Return the exception that was set on this future.

        The exception (or None if no exception was set) is returned only if
        the future is done.  If the future has been cancelled, raises
        CancelledError.  If the future isn't done yet, raises
        InvalidStateError.
        zException is not set.F)r8r:rrArr5r6)rrrrr4�s

zFuture.exceptioncCs*|jtkr|jj||�n|jj|�dS)z�Add a callback to be run when the future becomes done.

        The callback is called with a single argument - the future object. If
        the future is already done when this is called, the callback is
        scheduled with call_soon.
        N)r8r9rr=r-�append)r�fnrrr�add_done_callbacks
zFuture.add_done_callbackcs<�fdd�|jD�}t|j�t|�}|r8||jdd�<|S)z}Remove all instances of a callback from the "call when done" list.

        Returns the number of callbacks removed.
        csg|]}|�kr|�qSrr)�.0�f)rErr�
<listcomp>sz/Future.remove_done_callback.<locals>.<listcomp>N)r-�len)rrEZfiltered_callbacksZ
removed_countr)rEr�remove_done_callbacks
zFuture.remove_done_callbackcCs4|jtkrtdj|j|���||_t|_|j�dS)z�Mark the future done and set its result.

        If the future is already done when this method is called, raises
        InvalidStateError.
        z{}: {!r}N)r8r9r�formatrBrAr;)rrCrrr�
set_result s

zFuture.set_resultcCs�|jtkrtdj|j|���t|t�r,|�}t|�tkr@td��||_t	|_|j
�tjrbd|_
nt||�|_|jj|jj�dS)z�Mark the future done and set an exception.

        If the future is already done when this method is called, raises
        InvalidStateError.
        z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r8r9rrL�
isinstance�type�
StopIteration�	TypeErrorr6rAr;r
�PY34r5rZ
_tb_loggerrr=r)rr4rrr�
set_exception,s

zFuture.set_exceptionccs|j�sd|_|V|j�S)NT)r@�_asyncio_future_blockingrC)rrrr�__iter__DszFuture.__iter__)!r'r(r)r*r9r8rBr6rrrTr5rr	Z_future_repr_infor2r3r
rRr&r<r;r?r@rCr4rFrKrMrSrUZPY35�	__await__rrrrrns4

cCs|j�rdS|j|�dS)z?Helper setting the result only if the future was not cancelled.N)r?rM)ZfutrCrrr�_set_result_unless_cancelledSsrWcCsN|j�r|j�|j�sdS|j�}|dk	r8|j|�n|j�}|j|�dS)z8Copy state from a future to a concurrent.futures.Future.N)r?r<Zset_running_or_notify_cancelr4rSrCrM)�
concurrent�sourcer4rCrrr�_set_concurrent_future_stateZsrZcCsP|j�rdS|j�r|j�n.|j�}|dk	r:|j|�n|j�}|j|�dS)zqInternal helper to copy state from another Future.

    The other Future may be a concurrent.futures.Future.
    N)r?r<r4rSrCrM)rY�destr4rCrrr�_copy_future_stateis
r\cs�t��r"t�tjj�r"td��t��rDt�tjj�rDtd��t��rR�jnd�t��rd�jnd�dd�����fdd�}����fdd	�}�j|��j|�dS)
aChain two futures so that when one completes, so does the other.

    The result (or exception) of source will be copied to destination.
    If destination is cancelled, source gets cancelled too.
    Compatible with both asyncio.Future and concurrent.futures.Future.
    z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|�rt||�n
t||�dS)N)rr\rZ)r�otherrrr�
_set_state�sz!_chain_future.<locals>._set_statecs2|j�r.�dks��kr"�j�n�j�j�dS)N)r?r<�call_soon_threadsafe)�destination)�	dest_looprY�source_looprr�_call_check_cancel�s
z)_chain_future.<locals>._call_check_cancelcsJ�j�r�dk	r�j�rdS�dks,��kr8��|�n�j��|�dS)N)r?Z	is_closedr_)rY)r^rar`rbrr�_call_set_state�sz&_chain_future.<locals>._call_set_state)rrNrXZfuturesrrQrrF)rYr`rcrdr)r^rar`rYrbr�
_chain_future}s	
re)r
cCs2t|�r|S|dkrtj�}|j�}t||�|S)z&Wrap concurrent.futures.Future object.N)rrr,Z
create_futurere)rr
Z
new_futurerrrr�s
)r*�__all__Zconcurrent.futuresrXZloggingr/rrr	r
rrrrrr9r:rA�DEBUGZSTACK_DEBUGrrZ	_PyFuturerWrZr\rerZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s>

Pc*
PK=�\�>B�transports.cpython-36.opt-2.pycnu�[���3


 \R'�@s�ddlmZddddddgZGdd�d�ZGd	d�de�ZGd
d�de�ZGdd�dee�ZGdd�de�ZGd
d�de�ZGdd�de�Z	dS)�)�compat�
BaseTransport�
ReadTransport�WriteTransport�	Transport�DatagramTransport�SubprocessTransportc@s@eZdZddd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rNcCs|dkri}||_dS)N)�_extra)�self�extra�r�*/usr/lib64/python3.6/asyncio/transports.py�__init__
szBaseTransport.__init__cCs|jj||�S)N)r	�get)r
�name�defaultrrr
�get_extra_infoszBaseTransport.get_extra_infocCst�dS)N)�NotImplementedError)r
rrr
�
is_closingszBaseTransport.is_closingcCst�dS)N)r)r
rrr
�closeszBaseTransport.closecCst�dS)N)r)r
�protocolrrr
�set_protocol$szBaseTransport.set_protocolcCst�dS)N)r)r
rrr
�get_protocol(szBaseTransport.get_protocol)N)N)	�__name__�
__module__�__qualname__rrrrrrrrrr
r
s


c@seZdZdd�Zdd�ZdS)rcCst�dS)N)r)r
rrr
�
pause_reading0szReadTransport.pause_readingcCst�dS)N)r)r
rrr
�resume_reading8szReadTransport.resume_readingN)rrrrrrrrr
r-sc@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)rNcCst�dS)N)r)r
�high�lowrrr
�set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCst�dS)N)r)r
rrr
�get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCst�dS)N)r)r
�datarrr
�write]szWriteTransport.writecCstj|�}|j|�dS)N)rZflatten_list_bytesr#)r
Zlist_of_datar"rrr
�
writelineses
zWriteTransport.writelinescCst�dS)N)r)r
rrr
�	write_eofnszWriteTransport.write_eofcCst�dS)N)r)r
rrr
�
can_write_eofwszWriteTransport.can_write_eofcCst�dS)N)r)r
rrr
�abort{szWriteTransport.abort)NN)
rrrr r!r#r$r%r&r'rrrr
rAs
		c@seZdZdS)rN)rrrrrrr
r�sc@seZdZddd�Zdd�ZdS)rNcCst�dS)N)r)r
r"Zaddrrrr
�sendto�szDatagramTransport.sendtocCst�dS)N)r)r
rrr
r'�szDatagramTransport.abort)N)rrrr(r'rrrr
r�s

c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rcCst�dS)N)r)r
rrr
�get_pid�szSubprocessTransport.get_pidcCst�dS)N)r)r
rrr
�get_returncode�sz"SubprocessTransport.get_returncodecCst�dS)N)r)r
�fdrrr
�get_pipe_transport�sz&SubprocessTransport.get_pipe_transportcCst�dS)N)r)r
�signalrrr
�send_signal�szSubprocessTransport.send_signalcCst�dS)N)r)r
rrr
�	terminate�szSubprocessTransport.terminatecCst�dS)N)r)r
rrr
�kill�s	zSubprocessTransport.killN)	rrrr)r*r,r.r/r0rrrr
r�scsReZdZd�fdd�	Zdd�Zdd�Zdd	�Zdd
d�Zddd
�Zdd�Z	�Z
S)�_FlowControlMixinNcs$t�j|�||_d|_|j�dS)NF)�superr�_loop�_protocol_paused�_set_write_buffer_limits)r
rZloop)�	__class__rr
r�sz_FlowControlMixin.__init__cCsp|j�}||jkrdS|jsld|_y|jj�Wn:tk
rj}z|jjd|||jd��WYdd}~XnXdS)NTzprotocol.pause_writing() failed)�message�	exception�	transportr)r!�_high_waterr4�	_protocolZ
pause_writing�	Exceptionr3�call_exception_handler)r
�size�excrrr
�_maybe_pause_protocol�s
z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j�|jkrdd|_y|jj�Wn:tk
rb}z|jjd|||jd��WYdd}~XnXdS)NFz protocol.resume_writing() failed)r7r8r9r)r4r!�
_low_waterr;Zresume_writingr<r3r=)r
r?rrr
�_maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs|j|jfS)N)rAr:)r
rrr
�get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f��||_||_dS)N�@i�rz*high (%r) must be >= low (%r) must be >= 0i)�
ValueErrorr:rA)r
rrrrr
r5sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d�|j�dS)N)rr)r5r@)r
rrrrr
r -sz)_FlowControlMixin.set_write_buffer_limitscCst�dS)N)r)r
rrr
r!1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN)rrrrr@rBrCr5r r!�
__classcell__rr)r6r
r1�s

r1N)
Zasyncior�__all__rrrrrrr1rrrr
�<module>s
#D4PK=�\Ea�#mm$selector_events.cpython-36.opt-2.pycnu�[���3


 \���
@s8dgZddlZddlZddlZddlZddlZddlZyddlZWnek
rZdZYnXddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZdd	l	mZdd
l	mZddl	mZddlmZdd
lmZdd�ZGdd�de
j�ZGdd�dejej�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�BaseSelectorEventLoop�N�)�base_events)�compat)�	constants)�events)�futures)�	selectors)�
transports)�sslproto)�	coroutine)�loggercCs6y|j|�}Wntk
r"dSXt|j|@�SdS)NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�//usr/lib64/python3.6/asyncio/selector_events.py�_test_selector_event s
rcsneZdZdN�fdd�	ZdOddd�dd�ZdPddddd�d	d
�Zddddd�dd�ZdQd
d�Z�fdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdRdd�ZdSd d!�ZedTd"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zed>d?��Z d@dA�Z!dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dJdK�Z&dLdM�Z'�Z(S)UrNcsFt�j�|dkrtj�}tjd|jj�||_|j	�t
j�|_dS)NzUsing selector: %s)
�super�__init__r	ZDefaultSelectorr
�debug�	__class__�__name__�	_selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfr)rrrr1s
zBaseSelectorEventLoop.__init__)�extra�servercCst||||||�S)N)�_SelectorSocketTransport)r!�sock�protocol�waiterr"r#rrr�_make_socket_transport;s
z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer"r#c

CsNtj�s"|j||||||||d�Stj||||||�}	t|||	||d�|	jS)N)r)r*r"r#)r"r#)rZ_is_sslproto_available�_make_legacy_ssl_transportZSSLProtocolr$Z_app_transport)
r!�rawsockr&�
sslcontextr'r)r*r"r#Zssl_protocolrrr�_make_ssl_transport@s

z)BaseSelectorEventLoop._make_ssl_transportc	
Cst|||||||||�	S)N)�_SelectorSslTransport)	r!r,r&r-r'r)r*r"r#rrrr+Os
z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||�S)N)�_SelectorDatagramTransport)r!r%r&�addressr'r"rrr�_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|j�rtd��|j�rdS|j�t�j�|jdk	rH|jj�d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer)r!)rrrr6^s


zBaseSelectorEventLoop.closecCst�dS)N)�NotImplementedError)r!rrr�_socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj��|jj�d|_|jj�d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor6�_csock�
_internal_fds)r!rrrr5ls

z&BaseSelectorEventLoop._close_self_pipecCsN|j�\|_|_|jjd�|jjd�|jd7_|j|jj�|j�dS)NFr)r8r:r<�setblockingr=�_add_readerr;�_read_from_self)r!rrrrts
z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!�datarrr�_process_self_data|sz(BaseSelectorEventLoop._process_self_datacCsVxPy |jjd�}|sP|j|�Wqtk
r8wYqtk
rLPYqXqWdS)Ni)r:�recvrB�InterruptedError�BlockingIOError)r!rArrrr@sz%BaseSelectorEventLoop._read_from_selfcCsJ|j}|dk	rFy|jd�Wn(tk
rD|jr@tjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketT)�exc_info)r<�send�OSError�_debugr
r)r!Zcsockrrr�_write_to_self�sz$BaseSelectorEventLoop._write_to_self�dcCs |j|j�|j|||||�dS)N)r?r;�_accept_connection)r!�protocol_factoryr%r-r#�backlogrrr�_start_serving�sz$BaseSelectorEventLoop._start_servingcCs�x�t|�D]�}y0|j�\}}|jr2tjd|||�|jd�Wn�tttfk
rXdSt	k
r�}	z^|	j
t
jt
jt
j
t
jfkr�|jd|	|d��|j|j��|jtj|j|||||�n�WYdd}	~	Xq
Xd|i}
|j|||
||�}|j|�q
WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exception�socket�peername)�range�acceptrJr
rr>rErD�ConnectionAbortedErrorrI�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr9r;Z
call_laterrZACCEPT_RETRY_DELAYrP�_accept_connection2Zcreate_task)r!rNr%r-r#rO�_�conn�addr�excr"rVrrrrM�s4


z(BaseSelectorEventLoop._accept_connectionccs�d}d}yj|�}|j�}|r6|j||||d||d�}n|j|||||d�}y|EdHWn|j��YnXWn\tk
r�}	z@|jr�d|	d�}
|dk	r�||
d<|dk	r�||
d<|j|
�WYdd}	~	XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr&�	transport)�
create_futurer.r(r6�	ExceptionrJrY)r!rNr\r"r-r#r&r_r'r^�contextrrrrZ�s4z)BaseSelectorEventLoop._accept_connection2cCs@y|j|}Wntk
r"YnX|j�s<tdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r r�
is_closingr3�format)r!rr_rrr�_ensure_fd_no_transport�sz-BaseSelectorEventLoop._ensure_fd_no_transportc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tj|df�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)�
_check_closedr�Handlerrr�registerr	�
EVENT_READrA�modify�cancel)	r!r�callback�args�handler�mask�reader�writerrrrr?�s
z!BaseSelectorEventLoop._add_readerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	||d|f�|dk	r�|j
�dSdSdS)NFT)r4rrrrrAr	ri�
unregisterrjrk)r!rrrorprqrrrr9sz$BaseSelectorEventLoop._remove_readerc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tjd|f�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)rfrrgrrrrhr	�EVENT_WRITErArjrk)	r!rrlrmrnrrorprqrrr�_add_writers
z!BaseSelectorEventLoop._add_writerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	|||df�|dk	r�|j
�dSdSdS)NFT)r4rrrrrAr	rsrrrjrk)r!rrrorprqrrr�_remove_writer,sz$BaseSelectorEventLoop._remove_writercGs|j|�|j||f|��S)N)rer?)r!rrlrmrrr�
add_readerCs
z BaseSelectorEventLoop.add_readercCs|j|�|j|�S)N)rer9)r!rrrr�
remove_readerHs
z#BaseSelectorEventLoop.remove_readercGs|j|�|j||f|��S)N)rert)r!rrlrmrrr�
add_writerMs
z BaseSelectorEventLoop.add_writercCs|j|�|j|�S)N)reru)r!rrrr�
remove_writerRs
z#BaseSelectorEventLoop.remove_writercCs6|jr|j�dkrtd��|j�}|j|d||�|S)Nrzthe socket must be non-blocking)rJ�
gettimeout�
ValueErrorr`�
_sock_recv)r!r%�n�futrrr�	sock_recvWs
	zBaseSelectorEventLoop.sock_recvcCs�|dk	r|j|�|j�rdSy|j|�}Wn`ttfk
rb|j�}|j||j||||�Yn6tk
r�}z|j	|�WYdd}~XnX|j
|�dS)N)rw�	cancelledrCrErDr;rvr|ra�
set_exception�
set_result)r!r~�
registered_fdr%r}rArr^rrrr|fs
z BaseSelectorEventLoop._sock_recvcCsF|jr|j�dkrtd��|j�}|r8|j|d||�n
|jd�|S)Nrzthe socket must be non-blocking)rJrzr{r`�
_sock_sendallr�)r!r%rAr~rrr�sock_sendall{s
z"BaseSelectorEventLoop.sock_sendallcCs�|dk	r|j|�|j�rdSy|j|�}WnDttfk
rHd}Yn*tk
rp}z|j|�dSd}~XnX|t|�kr�|jd�n.|r�||d�}|j	�}|j
||j||||�dS)Nr)ryr�rHrErDrar��lenr�r;rxr�)r!r~r�r%rAr}r^rrrrr��s"

z#BaseSelectorEventLoop._sock_sendallccs�|jr|j�dkrtd��ttd�s2|jtjkrptj||j|j	|d�}|j
�sZ|EdH|j�d\}}}}}|j�}|j
|||�|EdHS)Nrzthe socket must be non-blocking�AF_UNIX)�family�proto�loop)rJrzr{�hasattrrSr�r�rZ_ensure_resolvedr��done�resultr`�
_sock_connect)r!r%r1Zresolvedr[r~rrr�sock_connect�s
z"BaseSelectorEventLoop.sock_connectcCs�|j�}y|j|�Wnjttfk
rV|jtj|j|��|j||j	|||�Yn6t
k
r�}z|j|�WYdd}~XnX|jd�dS)N)
r;ZconnectrErDZadd_done_callback�	functools�partial�_sock_connect_donerx�_sock_connect_cbrar�r�)r!r~r%r1rr^rrrr��sz#BaseSelectorEventLoop._sock_connectcCs|j|�dS)N)ry)r!rr~rrrr��sz(BaseSelectorEventLoop._sock_connect_donecCs�|j�rdSy,|jtjtj�}|dkr6t|d|f��WnBttfk
rPYn6tk
rz}z|j	|�WYdd}~XnX|j
d�dS)NrzConnect call failed %s)r�Z
getsockoptrSZ
SOL_SOCKETZSO_ERRORrIrErDrar�r�)r!r~r%r1�errr^rrrr��sz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|j�dkrtd��|j�}|j|d|�|S)Nrzthe socket must be non-blockingF)rJrzr{r`�_sock_accept)r!r%r~rrr�sock_accept�s

z!BaseSelectorEventLoop.sock_acceptcCs�|j�}|r|j|�|j�r"dSy|j�\}}|jd�WnVttfk
rh|j||j|d|�Yn:t	k
r�}z|j
|�WYdd}~XnX|j||f�dS)NFT)r;rwr�rVr>rErDrvr�rar�r�)r!r~Z
registeredr%rr\r1r^rrrr��s
z"BaseSelectorEventLoop._sock_acceptcCs�x~|D]v\}}|j|j}\}}|tj@rN|dk	rN|jrD|j|�n
|j|�|tj@r|dk	r|jrr|j|�q|j|�qWdS)N)	�fileobjrAr	riZ
_cancelledr9Z
_add_callbackrsru)r!Z
event_listrror�rprqrrr�_process_events�s
z%BaseSelectorEventLoop._process_eventscCs|j|j��|j�dS)N)r9r;r6)r!r%rrr�
_stop_servingsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN))r�
__module__�__qualname__rr(r.r+r2r6r8r5rrBr@rKrPrMrrZrer?r9rtrurvrwrxryrr|r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rrr+sR



(#cs�eZdZdZeZdZd �fdd�	Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ejr`dd�Zd!dd�Zdd�Zdd�Zdd�Zdd�Z�ZS)"�_SelectorTransport�iNcs�t�j||�||jd<|j�|jd<d|jkrdy|j�|jd<Wn tjk
rbd|jd<YnX||_|j�|_	||_
d|_||_|j
�|_d|_d|_|jdk	r�|jj�||j|j	<dS)NrSZsocknamerTTrF)rr�_extraZgetsocknameZgetpeernamerS�error�_sockr;�_sock_fd�	_protocol�_protocol_connected�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr )r!r�r%r&r"r#)rrrrs&





z_SelectorTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�|jdk	r�|jj�r�t|jj	|jt
j�}|rz|jd�n
|jd�t|jj	|jt
j�}|r�d}nd}|j
�}|jd||f�d	d
j|�S)N�closed�closingzfd=%szread=pollingz	read=idle�pollingZidlezwrite=<%s, bufsize=%s>z<%s>� )rrr��appendr�r��_loopr4rrr	rirs�get_write_buffer_size�join)r!�infor��state�bufsizerrr�__repr__2s*



z_SelectorTransport.__repr__cCs|jd�dS)N)�_force_close)r!rrr�abortNsz_SelectorTransport.abortcCs
||_dS)N)r�)r!r&rrr�set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r�)r!rrr�get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r�)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr
dSd|_|jj|j�|jsP|jd7_|jj|j�|jj|jd�dS)NTr)	r�r�r9r�r�r�ru�	call_soon�_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)�source)r��warnings�warn�ResourceWarningr6)r!rrr�__del__hs
z_SelectorTransport.__del__�Fatal error on transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)rG)rQrRr_r&)
�
isinstancerZ_FATAL_ERROR_IGNOREr��	get_debugr
rrYr�r�)r!r^rQrrr�_fatal_errorns
z_SelectorTransport._fatal_errorcCsd|jr
dS|jr(|jj�|jj|j�|jsBd|_|jj|j�|jd7_|jj|j	|�dS)NTr)
r�r��clearr�rur�r�r9r�r�)r!r^rrrr�|s
z_SelectorTransport._force_closecCsVz|jr|jj|�Wd|jj�d|_d|_d|_|j}|dk	rP|j�d|_XdS)N)r�r�Zconnection_lostr�r6r�r�Z_detach)r!r^r#rrrr��s
z(_SelectorTransport._call_connection_lostcCs
t|j�S)N)r�r�)r!rrrr��sz(_SelectorTransport.get_write_buffer_sizecGs"|jr
dS|jj||f|��dS)N)r�r�r?)r!rrlrmrrrr?�sz_SelectorTransport._add_readeri)NN)r�)rr�r��max_size�	bytearrayr�r�rr�r�r�r�rcr6rZPY34r�r�r�r�r�r?r�rr)rrr�s"

r�csVeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
�ZS)r$Ncsrt�j|||||�d|_d|_tj|j�|jj|j	j
|�|jj|j|j|j
�|dk	rn|jjtj|d�dS)NF)rr�_eof�_pausedrZ_set_nodelayr�r�r�r��connection_mader?r��_read_readyr�_set_result_unless_cancelled)r!r�r%r&r'r"r#)rrrr�s

z!_SelectorSocketTransport.__init__cCs>|js|jrdSd|_|jj|j�|jj�r:tjd|�dS)NTz%r pauses reading)r�r�r�r9r�r�r
r)r!rrr�
pause_reading�s
z&_SelectorSocketTransport.pause_readingcCsB|js|jrdSd|_|j|j|j�|jj�r>tjd|�dS)NFz%r resumes reading)	r�r�r?r�r�r�r�r
r)r!rrr�resume_reading�s
z'_SelectorSocketTransport.resume_readingcCs�|jr
dSy|jj|j�}WnDttfk
r4Yn|tk
r`}z|j|d�WYdd}~XnPX|rt|jj	|�n<|j
j�r�tj
d|�|jj�}|r�|j
j|j�n|j�dS)Nz$Fatal read error on socket transportz%r received EOF)r�r�rCr�rErDrar�r��
data_receivedr�r�r
r�eof_receivedr9r�r6)r!rAr^�	keep_openrrrr��s 

z$_SelectorSocketTransport._read_readycCs�t|tttf�s"tdt|�j��|jr0td��|s8dS|j	rf|j	t
jkrTtj
d�|j	d7_	dS|js�y|jj|�}WnBttfk
r�Yn@tk
r�}z|j|d�dSd}~XnX||d�}|s�dS|jj|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)r��bytesr��
memoryview�	TypeError�typerr�r3r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�r�rHrErDrar�r�rtr��_write_ready�extend�_maybe_pause_protocol)r!rAr}r^rrr�write�s4
z_SelectorSocketTransport.writecCs�|jr
dSy|jj|j�}Wn\ttfk
r4Yn�tk
rx}z*|jj|j	�|jj
�|j|d�WYdd}~XnTX|r�|jd|�=|j�|js�|jj|j	�|j
r�|jd�n|jr�|jjtj�dS)Nz%Fatal write error on socket transport)r�r�rHr�rErDrar�rur�r�r��_maybe_resume_protocolr�r�r��shutdownrS�SHUT_WR)r!r}r^rrrr�s&
z%_SelectorSocketTransport._write_readycCs.|js|jrdSd|_|js*|jjtj�dS)NT)r�r�r�r�r�rSr�)r!rrr�	write_eofs
z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr�
can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN)rr�r�rr�r�r�r�r�r�r�r�rr)rrr$�s#r$csdeZdZeZd�fdd�	Zddd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�ZS)r/NFc

s�tdkrtd��|s tj||�}|dd�}
|r<|r<||
d<|j|f|
�}t�j|||||	�d|_||_||_	||_
d|_|jj
|d�|jj�r�tjd|�|jj�}nd}|j|�dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)�sslr3rZ_create_transport_contextZwrap_socketrrr��_server_hostname�_waiter�_sslcontextr�r��updater�r�r
r�time�
_on_handshake)
r!r�r,r&r-r'r)r*r"r#Zwrap_kwargsZsslsock�
start_time)rrrr(s*

z_SelectorSslTransport.__init__cCsD|jdkrdS|jj�s:|dk	r.|jj|�n|jjd�d|_dS)N)r�r�r�r�)r!r^rrr�_wakeup_waiterLs

z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jj�Wn�tjk
r8|jj|j|j|�dStjk
r`|jj	|j|j|�dSt
k
r�}z`|jj�r�tj
d|dd�|jj|j�|jj|j�|jj�|j|�t|t�r�dS�WYdd}~XnX|jj|j�|jj|j�|jj�}t|jd��s�|j�r�|jjtjk�r�ytj||j�WnRtk
�r�}z4|jj��rjtj
d|dd�|jj�|j|�dSd}~XnX|jj||jj�|jj�|jd�d|_d|_ |jj|j|j!�d|_"|jj#|j$j%|�|jj#|j�|jj��r |jj&�|}tj'd||d	�dS)
Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)�peercert�cipher�compressionZ
ssl_objectFz%r: SSL handshake took %.1f msg@�@)(r�Zdo_handshaker��SSLWantReadErrorr�r?r�r��SSLWantWriteErrorrt�
BaseExceptionr�r
r�r9rur6r�r�raZgetpeercertr�r�r�Zverify_modeZ	CERT_NONEZmatch_hostnamer�r�r�r��_read_wants_write�_write_wants_readr�r�r�r�r�r�r)r!r�r^r�Zdtrrrr�Vsb













z#_SelectorSslTransport._on_handshakecCsJ|jrtd��|jrtd��d|_|jj|j�|jj�rFtjd|�dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r3r�r�r9r�r�r
r)r!rrrr��s
z#_SelectorSslTransport.pause_readingcCsJ|jstd��d|_|jrdS|jj|j|j�|jj�rFtj	d|�dS)Nz
Not pausedFz%r resumes reading)
r�r3r�r�r?r�r�r�r
r)r!rrrr��s
z$_SelectorSslTransport.resume_readingcCs"|jr
dS|jr6d|_|j�|jr6|jj|j|j�y|jj|j	�}Wn�t
ttj
fk
rdYn�tjk
r�d|_|jj|j�|jj|j|j�Yn�tk
r�}z|j|d�WYdd}~XnTX|r�|jj|�n@z4|jj�r�tjd|�|jj�}|�rtjd�Wd|j�XdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)r�r�r�r�r�rtr�r�rCr�rErDr�r�r�r�r9rar�r�r�r�r
rr�r�r6)r!rAr^r�rrrr��s4

z!_SelectorSslTransport._read_readycCs(|jr
dS|jr<d|_|j�|jp(|js<|jj|j|j�|jr�y|j	j
|j�}Wn�ttt
jfk
rtd}Ynpt
jk
r�d}|jj|j�d|_YnDtk
r�}z(|jj|j�|jj�|j|d�dSd}~XnX|r�|jd|�=|j�|j�s$|jj|j�|j�r$|jd�dS)NFrTz"Fatal write error on SSL transport)r�r�r�r�r�r�r?r�r�r�rHrErDr�r�r�rur�rar�r�r�r�)r!r}r^rrrr��s8

z"_SelectorSslTransport._write_readycCs�t|tttf�s"tdt|�j��|s*dS|jrX|jtj	krFt
jd�|jd7_dS|jsp|j
j|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rzsocket.send() raised exception.r)r�r�r�r�r�r�rr�rr�r
r�r�r�rtr�r�r�r�)r!rArrrr��s
z_SelectorSslTransport.writecCsdS)NFr)r!rrrr�sz#_SelectorSslTransport.can_write_eof)NFNNN)N)rr�r�r�r�rr�r�r�r�r�r�r�r�r�rr)rrr/$s"

?
"#r/csFeZdZejZd�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r0Ncs^t�j||||�||_|jj|jj|�|jj|j|j|j	�|dk	rZ|jjt
j|d�dS)N)rr�_addressr�r�r�r�r?r�r�rr�)r!r�r%r&r1r'r")rrrrs

z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss|]\}}t|�VqdS)N)r�)�.0rAr[rrr�	<genexpr>szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�)r!rrrr�sz0_SelectorDatagramTransport.get_write_buffer_sizecCs�|jr
dSy|jj|j�\}}Wnpttfk
r8Ynhtk
rd}z|jj|�WYdd}~Xn<t	k
r�}z|j
|d�WYdd}~XnX|jj||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rErDrIr��error_receivedrar�Zdatagram_received)r!rAr]r^rrrr� sz&_SelectorDatagramTransport._read_readycCsTt|tttf�s"tdt|�j��|s*dS|jrN|d|jfkrNtd|jf��|j	r�|jr�|j	t
jkrptj
d�|j	d7_	dS|j�s4y&|jr�|jj|�n|jj||�dSttfk
r�|jj|j|j�YnZtk
�r}z|jj|�dSd}~Xn.tk
�r2}z|j|d�dSd}~XnX|jjt|�|f�|j�dS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)r�r�r�r�r�r�rr�r{r�rr�r
r�r�r�rH�sendtorErDr�rtr��
_sendto_readyrIr�r�rar�r�r�)r!rAr]r^rrrr�.s<
z!_SelectorDatagramTransport.sendtocCs�x�|jr�|jj�\}}y&|jr,|jj|�n|jj||�Wqttfk
rf|jj||f�PYqt	k
r�}z|j
j|�dSd}~Xqtk
r�}z|j
|d�dSd}~XqXqW|j�|js�|jj|j�|jr�|jd�dS)Nz'Fatal write error on datagram transport)r��popleftr�r�rHr�rErD�
appendleftrIr�r�rar�r�r�rur�r�r�)r!rAr]r^rrrr�Us*z(_SelectorDatagramTransport._sendto_ready)NNN)N)rr�r��collections�dequer�rr�r�r�r�r�rr)rrr0s
'r0)�__all__r�rXr�rSr�rr��ImportError�rrrrrr	r
rZ
coroutinesr�logr
rZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r$r/r0rrrr�<module>sB
iiPK=�\��ь��constants.cpython-36.opt-1.pycnu�[���3


 \s�@sdZdZdZdZdS)z
Constants.���
N)�__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTH�rr�)/usr/lib64/python3.6/asyncio/constants.py�<module>sPK=�\�pä�b�bevents.cpython-36.pycnu�[���3


 \�[�@s�dZddddddddd	d
ddd
dgZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
dd�Zdd�Zd3dd�Zdd�Zd4dd�ZGdd�d�ZGd d�de�ZGd!d�d�ZGd"d�d�ZGd#d�d�ZGd$d%�d%e�Zdae	j�ZGd&d'�d'e	j�Ze�Zd(d�Zd)d
�Z d*d+�Z!d,d�Z"d-d�Z#d.d�Z$d/d	�Z%d0d
�Z&d1d�Z'd2d�Z(dS)5z!Event loop and event loop policy.�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�_get_running_loop�N�)�compat)�	constantscCsttjrtj|�}nt|d�r"|j}tj|�r>|j}|j|j	fSt
|tj�rTt
|j�Stjrpt
|tj�rpt
|j�SdS)N�__wrapped__)rZPY34�inspectZunwrap�hasattrrZ
isfunction�__code__�co_filename�co_firstlineno�
isinstance�	functools�partial�_get_function_source�func�
partialmethod)r�code�r �&/usr/lib64/python3.6/asyncio/events.pyrs



rcCsJg}|r|jdd�|D��|r8|jdd�|j�D��ddj|�dS)z�Format function arguments and keyword arguments.

    Special case for a single parameter: ('hello',) is formatted as ('hello').
    css|]}tj|�VqdS)N)�reprlib�repr)�.0�argr r r!�	<genexpr>1sz*_format_args_and_kwargs.<locals>.<genexpr>css$|]\}}dj|tj|��VqdS)z{}={}N)�formatr"r#)r$�k�vr r r!r&3s�(z, �))�extend�items�join)�args�kwargsr-r r r!�_format_args_and_kwargs)s
r1�cCs�t|tj�r.t||�|}t|j|j|j|�St|d�rF|j	rF|j	}n t|d�r^|j
r^|j
}nt|�}|t||�7}|r�||7}|S)N�__qualname__�__name__)rrrr1�_format_callbackrr/�keywordsrr3r4r#)rr/r0�suffix�	func_reprr r r!r58sr5cCs(t||d�}t|�}|r$|d|7}|S)Nz	 at %s:%s)r5r)rr/r8�sourcer r r!�_format_callback_sourceIs
r:cCsD|dkrtj�j}|dkr tj}tjjtj|�|dd�}|j	�|S)zlReplacement for traceback.extract_stack() that only does the
    necessary work for asyncio debug mode.
    NF)�limit�lookup_lines)
�sys�	_getframe�f_backrZDEBUG_STACK_DEPTH�	traceback�StackSummary�extract�
walk_stack�reverse)�fr;�stackr r r!�
extract_stackQs
rGc@s<eZdZdZdZd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dS)rz1Object returned by callback registration methods.�	_callback�_args�
_cancelled�_loop�_source_traceback�_repr�__weakref__cCsD||_||_||_d|_d|_|jj�r:ttjd��|_	nd|_	dS)NFr)
rKrHrIrJrM�	get_debugrGr=r>rL)�self�callbackr/�loopr r r!�__init__hs
zHandle.__init__cCsf|jjg}|jr|jd�|jdk	r8|jt|j|j��|jrb|jd}|jd|d|df�|S)NZ	cancelledrzcreated at %s:%sr���)�	__class__r4rJ�appendrHr:rIrL)rP�info�framer r r!�
_repr_infoss



zHandle._repr_infocCs&|jdk	r|jS|j�}ddj|�S)Nz<%s>� )rMrYr.)rPrWr r r!�__repr__~s
zHandle.__repr__cCs0|js,d|_|jj�r t|�|_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!�cancel�s

z
Handle.cancelcCs|y|j|j�Wnbtk
rr}zFt|j|j�}dj|�}|||d�}|jrV|j|d<|jj|�WYdd}~XnXd}dS)NzException in callback {})�messageZ	exception�handleZsource_traceback)rHrI�	Exceptionr:r'rLrK�call_exception_handler)rP�exc�cb�msg�contextr r r!�_run�s

zHandle._runN)rHrIrJrKrLrMrN)
r4�
__module__r3�__doc__�	__slots__rSrYr[r\rer r r r!rbscsxeZdZdZddgZ�fdd�Z�fdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
�fdd�Z�ZS)rz7Object returned by timed callback registration methods.�
_scheduled�_whencs:|dk	st�t�j|||�|jr*|jd=||_d|_dS)NrFrT)�AssertionError�superrSrLrjri)rP�whenrQr/rR)rUr r!rS�szTimerHandle.__init__cs.t�j�}|jrdnd}|j|d|j�|S)N�rzwhen=%s)rlrYrJ�insertrj)rPrW�pos)rUr r!rY�s
zTimerHandle._repr_infocCs
t|j�S)N)�hashrj)rPr r r!�__hash__�szTimerHandle.__hash__cCs|j|jkS)N)rj)rP�otherr r r!�__lt__�szTimerHandle.__lt__cCs|j|jkrdS|j|�S)NT)rj�__eq__)rPrsr r r!�__le__�szTimerHandle.__le__cCs|j|jkS)N)rj)rPrsr r r!�__gt__�szTimerHandle.__gt__cCs|j|jkrdS|j|�S)NT)rjru)rPrsr r r!�__ge__�szTimerHandle.__ge__cCs>t|t�r:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrjrHrIrJ�NotImplemented)rPrsr r r!ru�s
zTimerHandle.__eq__cCs|j|�}|tkrtS|S)N)rury)rPrsZequalr r r!�__ne__�s
zTimerHandle.__ne__cs |js|jj|�t�j�dS)N)rJrK�_timer_handle_cancelledrlr\)rP)rUr r!r\�szTimerHandle.cancel)r4rfr3rgrhrSrYrrrtrvrwrxrurzr\�
__classcell__r r )rUr!r�sc@s eZdZdZdd�Zdd�ZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving.  This leaves existing connections open.)ry)rPr r r!�close�szAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)ry)rPr r r!�wait_closed�szAbstractServer.wait_closedN)r4rfr3rgr}r~r r r r!r�sc	@seZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d$d$d$d%�d&d'�Zdhd(d)�Zdid*d$d$d$d*d*d*d+�d,d-�Zdjejejd*d.d*d*d*d/�d0d1�Zd*d*d*d2�d3d4�Zd*d.d*d5�d6d7�Zdkd$d$d$d*d*d*d*d8�d9d:�Zd;d<�Zd=d>�Z e!j"e!j"e!j"d?�d@dA�Z#e!j"e!j"e!j"d?�dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1d^d_�Z2d`da�Z3dbdc�Z4ddde�Z5dfdg�Z6d*S)lrzAbstract event loop.cCst�dS)z*Run the event loop until stop() is called.N)�NotImplementedError)rPr r r!�run_forever�szAbstractEventLoop.run_forevercCst�dS)zpRun the event loop until a Future is done.

        Return the Future's result, or raise its exception.
        N)r)rPZfuturer r r!�run_until_complete�sz$AbstractEventLoop.run_until_completecCst�dS)z�Stop the event loop as soon as reasonable.

        Exactly how soon that is may depend on the implementation, but
        no more I/O callbacks should be scheduled.
        N)r)rPr r r!�stop�szAbstractEventLoop.stopcCst�dS)z3Return whether the event loop is currently running.N)r)rPr r r!�
is_running�szAbstractEventLoop.is_runningcCst�dS)z*Returns True if the event loop was closed.N)r)rPr r r!�	is_closedszAbstractEventLoop.is_closedcCst�dS)z�Close the loop.

        The loop should not be running.

        This is idempotent and irreversible.

        No other methods should be called after this one.
        N)r)rPr r r!r}s	zAbstractEventLoop.closecCst�dS)z,Shutdown all active asynchronous generators.N)r)rPr r r!�shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCst�dS)z3Notification that a TimerHandle has been cancelled.N)r)rPr^r r r!r{sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|��S)Nr)�
call_later)rPrQr/r r r!�	call_soonszAbstractEventLoop.call_sooncGst�dS)N)r)rPZdelayrQr/r r r!r�szAbstractEventLoop.call_latercGst�dS)N)r)rPrmrQr/r r r!�call_atszAbstractEventLoop.call_atcCst�dS)N)r)rPr r r!�time"szAbstractEventLoop.timecCst�dS)N)r)rPr r r!�
create_future%szAbstractEventLoop.create_futurecCst�dS)N)r)rP�coror r r!�create_task*szAbstractEventLoop.create_taskcGst�dS)N)r)rPrQr/r r r!�call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGst�dS)N)r)rP�executorrr/r r r!�run_in_executor2sz!AbstractEventLoop.run_in_executorcCst�dS)N)r)rPr�r r r!�set_default_executor5sz&AbstractEventLoop.set_default_executorr)�family�type�proto�flagscCst�dS)N)r)rP�host�portr�r�r�r�r r r!�getaddrinfo:szAbstractEventLoop.getaddrinfocCst�dS)N)r)rPZsockaddrr�r r r!�getnameinfo=szAbstractEventLoop.getnameinfoN)�sslr�r�r��sock�
local_addr�server_hostnamecCst�dS)N)r)rP�protocol_factoryr�r�r�r�r�r�r�r�r�r r r!�create_connection@sz#AbstractEventLoop.create_connection�d)r�r�r��backlogr��
reuse_address�
reuse_portcCst�dS)a�A coroutine which creates a TCP server bound to host and port.

        The return value is a Server object which can be used to stop
        the service.

        If host is an empty string or None all interfaces are assumed
        and a list of multiple sockets will be returned (most likely
        one for IPv4 and another one for IPv6). The host parameter can also be a
        sequence (e.g. list) of hosts to bind to.

        family can be set to either AF_INET or AF_INET6 to force the
        socket to use IPv4 or IPv6. If not set it will be determined
        from host (defaults to AF_UNSPEC).

        flags is a bitmask for getaddrinfo().

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows.
        N)r)rPr�r�r�r�r�r�r�r�r�r�r r r!�
create_serverEs'zAbstractEventLoop.create_server)r�r�r�cCst�dS)N)r)rPr��pathr�r�r�r r r!�create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)r�r�r�cCst�dS)a#A coroutine which creates a UNIX Domain Socket server.

        The return value is a Server object, which can be used to stop
        the service.

        path is a str, representing a file systsem path to bind the
        server socket to.

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.
        N)r)rPr�r�r�r�r�r r r!�create_unix_serverssz$AbstractEventLoop.create_unix_server)r�r�r�r�r��allow_broadcastr�cCst�dS)a�A coroutine which creates a datagram endpoint.

        This method will try to establish the endpoint in the background.
        When successful, the coroutine returns a (transport, protocol) pair.

        protocol_factory must be a callable returning a protocol instance.

        socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_DGRAM.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified it will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows and some UNIX's. If the
        :py:data:`~socket.SO_REUSEPORT` constant is not defined then this
        capability is unsupported.

        allow_broadcast tells the kernel to allow this endpoint to send
        messages to the broadcast address.

        sock can optionally be specified in order to use a preexisting
        socket object.
        N)r)rPr�r�Zremote_addrr�r�r�r�r�r�r�r r r!�create_datagram_endpoint�s!z*AbstractEventLoop.create_datagram_endpointcCst�dS)aRegister read pipe in event loop. Set the pipe to non-blocking mode.

        protocol_factory should instantiate object with Protocol interface.
        pipe is a file-like object.
        Return pair (transport, protocol), where transport supports the
        ReadTransport interface.N)r)rPr��piper r r!�connect_read_pipe�sz#AbstractEventLoop.connect_read_pipecCst�dS)aRegister write pipe in event loop.

        protocol_factory should instantiate object with BaseProtocol interface.
        Pipe is file-like object already switched to nonblocking.
        Return pair (transport, protocol), where transport support
        WriteTransport interface.N)r)rPr�r�r r r!�connect_write_pipe�sz$AbstractEventLoop.connect_write_pipe)�stdin�stdout�stderrcKst�dS)N)r)rPr��cmdr�r�r�r0r r r!�subprocess_shell�sz"AbstractEventLoop.subprocess_shellcOst�dS)N)r)rPr�r�r�r�r/r0r r r!�subprocess_exec�sz!AbstractEventLoop.subprocess_execcGst�dS)N)r)rP�fdrQr/r r r!�
add_reader�szAbstractEventLoop.add_readercCst�dS)N)r)rPr�r r r!�
remove_reader�szAbstractEventLoop.remove_readercGst�dS)N)r)rPr�rQr/r r r!�
add_writer�szAbstractEventLoop.add_writercCst�dS)N)r)rPr�r r r!�
remove_writer�szAbstractEventLoop.remove_writercCst�dS)N)r)rPr��nbytesr r r!�	sock_recv�szAbstractEventLoop.sock_recvcCst�dS)N)r)rPr��datar r r!�sock_sendall�szAbstractEventLoop.sock_sendallcCst�dS)N)r)rPr�Zaddressr r r!�sock_connect�szAbstractEventLoop.sock_connectcCst�dS)N)r)rPr�r r r!�sock_accept�szAbstractEventLoop.sock_acceptcGst�dS)N)r)rP�sigrQr/r r r!�add_signal_handler�sz$AbstractEventLoop.add_signal_handlercCst�dS)N)r)rPr�r r r!�remove_signal_handler�sz'AbstractEventLoop.remove_signal_handlercCst�dS)N)r)rP�factoryr r r!�set_task_factory�sz"AbstractEventLoop.set_task_factorycCst�dS)N)r)rPr r r!�get_task_factory�sz"AbstractEventLoop.get_task_factorycCst�dS)N)r)rPr r r!�get_exception_handlersz'AbstractEventLoop.get_exception_handlercCst�dS)N)r)rPZhandlerr r r!�set_exception_handlersz'AbstractEventLoop.set_exception_handlercCst�dS)N)r)rPrdr r r!�default_exception_handlersz+AbstractEventLoop.default_exception_handlercCst�dS)N)r)rPrdr r r!r`sz(AbstractEventLoop.call_exception_handlercCst�dS)N)r)rPr r r!rOszAbstractEventLoop.get_debugcCst�dS)N)r)rPZenabledr r r!�	set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)7r4rfr3rgr�r�r�r�r�r}r�r{r�r�r�r�r�r�r�r�r�r�r�r��socketZ	AF_UNSPECZ
AI_PASSIVEr�r�r�r�r�r��
subprocess�PIPEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r`rOr�r r r r!r�st

'!

	c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rz-Abstract policy for accessing the event loop.cCst�dS)a:Get the event loop for the current context.

        Returns an event loop object implementing the BaseEventLoop interface,
        or raises an exception in case no event loop has been set for the
        current context and the current policy does not specify to create one.

        It should never return None.N)r)rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCst�dS)z3Set the event loop for the current context to loop.N)r)rPrRr r r!r	$sz&AbstractEventLoopPolicy.set_event_loopcCst�dS)z�Create and return a new event loop object according to this
        policy's rules. If there's need to set this loop as the event loop for
        the current context, set_event_loop must be called explicitly.N)r)rPr r r!r
(sz&AbstractEventLoopPolicy.new_event_loopcCst�dS)z$Get the watcher for child processes.N)r)rPr r r!r0sz)AbstractEventLoopPolicy.get_child_watchercCst�dS)z$Set the watcher for child processes.N)r)rP�watcherr r r!r4sz)AbstractEventLoopPolicy.set_child_watcherN)	r4rfr3rgrr	r
rrr r r r!rs
c@sFeZdZdZdZGdd�dej�Zdd�Zdd�Z	d	d
�Z
dd�ZdS)
�BaseDefaultEventLoopPolicya�Default policy implementation for accessing the event loop.

    In this policy, each thread has its own event loop.  However, we
    only automatically create an event loop by default for the main
    thread; other threads by default have no event loop.

    Other policies may have different rules (e.g. a single global
    event loop, or automatically creating an event loop per thread, or
    using some other notion of context to which an event loop is
    associated).
    Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK�_set_calledr r r r!�_LocalHsr�cCs|j�|_dS)N)r��_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jjr4ttj�tj�r4|j|j��|jjdkrRt	dtj�j
��|jjS)zSGet the event loop.

        This may be None or an instance of EventLoop.
        Nz,There is no current event loop in thread %r.)r�rKr�r�	threadingZcurrent_threadZ_MainThreadr	r
�RuntimeError�name)rPr r r!rOs
z)BaseDefaultEventLoopPolicy.get_event_loopcCs*d|j_|dkst|t�st�||j_dS)zSet the event loop.TN)r�r�rrrkrK)rPrRr r r!r	]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|j�S)zvCreate a new event loop.

        You must call set_event_loop() to make this the current event
        loop.
        )�
_loop_factory)rPr r r!r
csz)BaseDefaultEventLoopPolicy.new_event_loop)r4rfr3rgr�r��localr�rSrr	r
r r r r!r�9sr�c@seZdZdZdS)�_RunningLoopN)NN)r4rfr3�loop_pidr r r r!r�wsr�cCs&tj\}}|dk	r"|tj�kr"|SdS)z�Return the running event loop or None.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)�
_running_loopr��os�getpid)Zrunning_loop�pidr r r!r~s
cCs|tj�ft_dS)z�Set the running event loop.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)r�r�r�r�)rRr r r!r
�sc	Cs.t� tdkr ddlm}|�aWdQRXdS)Nr)�DefaultEventLoopPolicy)�_lock�_event_loop_policyr2r�)r�r r r!�_init_event_loop_policy�sr�cCstdkrt�tS)z"Get the current event loop policy.N)r�r�r r r r!r�scCs|dkst|t�st�|adS)zZSet the current event loop policy.

    If policy is None, the default policy is restored.N)rrrkr�)Zpolicyr r r!r�scCst�}|dk	r|St�j�S)aGReturn an asyncio event loop.

    When called from a coroutine or a callback (e.g. scheduled with call_soon
    or similar API), this function will always return the running event loop.

    If there is no running event loop set, the function will return
    the result of `get_event_loop_policy().get_event_loop()` call.
    N)rrr)Zcurrent_loopr r r!r�s	cCst�j|�dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr	)rRr r r!r	�scCs
t�j�S)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr
r r r r!r
�scCs
t�j�S)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rrr r r r!r�scCst�j|�S)zMEquivalent to calling
    get_event_loop_policy().set_child_watcher(watcher).)rr)r�r r r!r�s)r2)NN))rg�__all__rrr�r"r�r�r=r�r@r2rrrr1r5r:rGrrrrrr�r�ZLockr�r�r�r�rr
r�rrrr	r
rrr r r r!�<module>sZ

>85"7		PK=�\�x�mDmDtest_utils.cpython-36.opt-1.pycnu�[���3


 \�:�
@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddl
mZddlmZddlmZmZyddlZWnek
r�dZYnXddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddl m!Z!ddl"m#Z#e	j$dk�rHddl%m&Z&nddlm&Z&dd�Z'e'd�Z(e'd�Z)dd�Z*dd�Z+dRdd�Z,dd�Z-Gdd �d e�Z.Gd!d"�d"e�Z/Gd#d$�d$�Z0Gd%d&�d&e0e/�Z1d'd(�d)d*�Z2e3ed+��rZGd,d-�d-ej4e�Z5Gd.d/�d/e5e�Z6Gd0d1�d1e6�Z7Gd2d3�d3e0e7�Z8d4d5�Z9ej:d6d7��Z;ej:d'd(�d8d9��Z<ej:d:dd'd;�d<d=��Z=d>d?�Z>Gd@dA�dAej?�Z@GdBdC�dCejA�ZBdDdE�ZCGdFdG�dGeD�ZEdHdI�ZFGdJdK�dKe
jG�ZGej:dLdM��ZHejIejJejKfdNdO�ZLdPdQ�ZMdS)SzUtilities shared by tests.�N)�mock)�
HTTPServer)�WSGIRequestHandler�
WSGIServer�)�base_events)�compat)�events)�futures)�	selectors)�tasks)�	coroutine)�logger)�supportZwin32)�
socketpaircCs`ttd�r*tjjtj|�}tjj|�r*|Stjjtjjtj�d|�}tjj|�rT|St	|��dS)N�
TEST_HOME_DIR�test)
�hasattrr�os�path�joinr�isfile�dirname�__file__�FileNotFoundError)�filename�fullname�r�*/usr/lib64/python3.6/asyncio/test_utils.py�	data_file-s
rzssl_cert.pemzssl_key.pemcCstdkrdStjtj�SdS)N)�ssl�
SSLContextZPROTOCOL_SSLv23rrrr�dummy_ssl_context<sr"c
Cs@tdd��}|�}|j|�}d|_z|j|�Wd|j�XdS)NcSsdS)Nrrrrr�onceDszrun_briefly.<locals>.onceF)r
Zcreate_taskZ_log_destroy_pending�run_until_complete�close)�loopr#�gen�trrr�run_brieflyCs
r)�cCsTtj�|}xB|�sN|dk	r8|tj�}|dkr8tj��|jtjd|d��qWdS)Nrg����MbP?)r&)�timer
�TimeoutErrorr$rZsleep)r&Zpred�timeoutZdeadlinerrr�	run_untilRsr.cCs|j|j�|j�dS)z�Legacy API to run once through the event loop.

    This is the recommended pattern for test code.  It will poll the
    selector once and run all callbacks scheduled in response to I/O
    events.
    N)Z	call_soon�stopZrun_forever)r&rrr�run_once\sr0c@seZdZdd�Zdd�ZdS)�SilentWSGIRequestHandlercCstj�S)N)�io�StringIO)�selfrrr�
get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4�format�argsrrr�log_messagelsz$SilentWSGIRequestHandler.log_messageN)�__name__�
__module__�__qualname__r5r8rrrrr1gsr1cs(eZdZdZ�fdd�Zdd�Z�ZS)�SilentWSGIServer�cs"t�j�\}}|j|j�||fS)N)�super�get_request�
settimeout�request_timeout)r4�request�client_addr)�	__class__rrr?tszSilentWSGIServer.get_requestcCsdS)Nr)r4rB�client_addressrrr�handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF�
__classcell__rr)rDrr<psr<c@seZdZdd�ZdS)�SSLWSGIServerMixincCs^t}t}tj�}|j||�|j|dd�}y|j|||�|j�Wntk
rXYnXdS)NT)Zserver_side)	�ONLYKEY�ONLYCERTr r!Zload_cert_chainZwrap_socketZRequestHandlerClassr%�OSError)r4rBrEZkeyfileZcertfile�contextZssockrrr�finish_requestsz!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@seZdZdS)�
SSLWSGIServerN)r9r:r;rrrrrN�srNF)�use_sslc
#svdd�}|r|n|}||t���j|��j�_tj�fdd�d�}|j�z
�VWd�j��j�|j	�XdS)NcSsd}dg}|||�dgS)Nz200 OK�Content-type�
text/plainsTest message)rPrQr)�environZstart_responseZstatusZheadersrrr�app�s
z_run_test_server.<locals>.appcs�jdd�S)Ng�������?)Z
poll_interval)Z
serve_foreverr)�httpdrr�<lambda>�sz"_run_test_server.<locals>.<lambda>)�target)
r1Zset_appZserver_address�address�	threadingZThread�start�shutdownZserver_closer)rWrO�
server_cls�server_ssl_clsrSZserver_classZ
server_threadr)rTr�_run_test_server�s


r]ZAF_UNIXc@seZdZdd�ZdS)�UnixHTTPServercCstjj|�d|_d|_dS)Nz	127.0.0.1�P)�socketserver�UnixStreamServer�server_bindZserver_nameZserver_port)r4rrrrb�szUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^�sr^cs(eZdZdZdd�Z�fdd�Z�ZS)�UnixWSGIServerr=cCstj|�|j�dS)N)r^rbZ
setup_environ)r4rrrrb�s
zUnixWSGIServer.server_bindcs"t�j�\}}|j|j�|dfS)N�	127.0.0.1�)rdre)r>r?r@rA)r4rBrC)rDrrr?�szUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrc�srcc@seZdZdd�ZdS)�SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrF�sz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrf�srfc@seZdZdS)�UnixSSLWSGIServerN)r9r:r;rrrrrg�srgc	Cstj��}|jSQRXdS)N)�tempfileZNamedTemporaryFile�name)�filerrr�gen_unix_socket_path�s
rkccs<t�}z
|VWdytj|�Wntk
r4YnXXdS)N)rkr�unlinkrK)rrrr�unix_socket_path�s
rmc
cs,t��}t||ttd�EdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrr�run_test_unix_server�srnz	127.0.0.1)�host�portrOccst||f|ttd�EdHdS)N)rWrOr[r\)r]r<rN)rorprOrrr�run_test_server�s
rqcCsPi}x4t|�D](}|jd�r(|jd�r(qtdd�||<qWtd|f|j|��S)N�__)�return_valueZTestProtocol)�dir�
startswith�endswith�MockCallback�type�	__bases__)�baseZdctrirrr�make_test_protocol�sr{c@s6eZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)
�TestSelectorcCs
i|_dS)N)�keys)r4rrr�__init__szTestSelector.__init__NcCstj|d||�}||j|<|S)Nr)rZSelectorKeyr})r4�fileobjr	�data�keyrrr�registers
zTestSelector.registercCs|jj|�S)N)r}�pop)r4rrrr�
unregisterszTestSelector.unregistercCsgS)Nr)r4r-rrr�selectszTestSelector.selectcCs|jS)N)r})r4rrr�get_mapszTestSelector.get_map)N)r9r:r;r~r�r�r�r�rrrrr|s

r|cs�eZdZdZd-�fdd�	Zdd�Zdd�Z�fd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Z�fd%d&�Z�fd'd(�Zd)d*�Zd+d,�Z�ZS).�TestLoopa�Loop for unittests.

    It manages self time directly.
    If something scheduled to be executed later then
    on next loop iteration after all ready handlers done
    generator passed to __init__ is calling.

    Generator should be like this:

        def gen():
            ...
            when = yield ...
            ... = yield time_advance

    Value returned by yield is absolute time of next scheduled handler.
    Value passed to yield is time advance to move loop's time forward.
    Ncsvt�j�|dkr"dd�}d|_nd|_|�|_t|j�d|_d|_g|_t�|_	i|_
i|_|j�t
j�|_dS)Ncss
dVdS)Nrrrrrr',szTestLoop.__init__.<locals>.genFTrg��&�.>)r>r~�_check_on_close�_gen�next�_timeZ_clock_resolution�_timersr|Z	_selector�readers�writers�reset_counters�weakref�WeakValueDictionary�_transports)r4r')rDrrr~(s

zTestLoop.__init__cCs|jS)N)r�)r4rrrr+?sz
TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r�)r4�advancerrr�advance_timeBszTestLoop.advance_timecsBt�j�|jr>y|jjd�Wntk
r4Yn
Xtd��dS)NrzTime generator is not finished)r>r%r�r��send�
StopIteration�AssertionError)r4)rDrrr%Gs
zTestLoop.closecGstj|||�|j|<dS)N)r	�Handler�)r4�fd�callbackr7rrr�_add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)�remove_reader_countr�)r4r�rrr�_remove_readerTs

zTestLoop._remove_readercGsh||jkrtd|�d���|j|}|j|krDtd|j�d|����|j|krdtd|j�d|����dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )r�r�Z	_callbackZ_args)r4r�r�r7�handlerrr�
assert_reader\s



zTestLoop.assert_readercCs||jkrtd|�d���dS)Nzfd z is registered)r�r�)r4r�rrr�assert_no_readergs
zTestLoop.assert_no_readercGstj|||�|j|<dS)N)r	r�r�)r4r�r�r7rrr�_add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)�remove_writer_countr�)r4r�rrr�_remove_writerns

zTestLoop._remove_writercGs|j|}dS)N)r�)r4r�r�r7r�rrr�
assert_writervs
zTestLoop.assert_writercCs8y|j|}Wntk
r"YnXtdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r��KeyError�RuntimeErrorr6)r4r�Z	transportrrr�_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j|�|j||f|��S)zAdd a reader callback.)r�r�)r4r�r�r7rrr�
add_reader�s
zTestLoop.add_readercCs|j|�|j|�S)zRemove a reader callback.)r�r�)r4r�rrr�
remove_reader�s
zTestLoop.remove_readercGs|j|�|j||f|��S)zAdd a writer callback..)r�r�)r4r�r�r7rrr�
add_writer�s
zTestLoop.add_writercCs|j|�|j|�S)zRemove a writer callback.)r�r�)r4r�rrr�
remove_writer�s
zTestLoop.remove_writercCstjt�|_tjt�|_dS)N)�collections�defaultdict�intr�r�)r4rrrr��szTestLoop.reset_counterscs:t�j�x$|jD]}|jj|�}|j|�qWg|_dS)N)r>�	_run_oncer�r�r�r�)r4�whenr�)rDrrr��s

zTestLoop._run_oncecs |jj|�t�j||f|��S)N)r��appendr>�call_at)r4r�r�r7)rDrrr��szTestLoop.call_atcCsdS)Nr)r4Z
event_listrrr�_process_events�szTestLoop._process_eventscCsdS)Nr)r4rrr�_write_to_self�szTestLoop._write_to_self)N)r9r:r;�__doc__r~r+r�r%r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rGrr)rDrr�s,

r�cKstjfddgi|��S)N�spec�__call__)rZMock)�kwargsrrrrw�srwc@seZdZdZdd�ZdS)�MockPatternz�A regex based str with a fuzzy __eq__.

    Use this helper with 'mock.assert_called_with', or anywhere
    where a regex comparison between strings is needed.

    For instance:
       mock_call.assert_called_with(MockPattern('spam.*ham'))
    cCsttjt|�|tj��S)N)�bool�re�search�str�S)r4�otherrrr�__eq__�szMockPattern.__eq__N)r9r:r;r�r�rrrrr��sr�cCs$tj|�}|dkr td|f��|S)Nzunable to get the source of %r)r	Z_get_function_source�
ValueError)�func�sourcerrr�get_function_source�s
r�c@sVeZdZedd��Zdd�dd�Zddd	�Zd
d�Zdd
�Zdd�Z	e
jsRdd�ZdS)�TestCasecCs&|j}|dk	r|jdd�|j�dS)NT)�wait)Z_default_executorrZr%)r&Zexecutorrrr�
close_loop�szTestCase.close_loopT)�cleanupcCs tjd�|r|j|j|�dS)N)r	�set_event_loopZ
addCleanupr�)r4r&r�rrrr��s
zTestCase.set_event_loopNcCst|�}|j|�|S)N)r�r�)r4r'r&rrr�
new_test_loop�s
zTestCase.new_test_loopcCs|jt_dS)N)�_get_running_loopr	)r4rrr�unpatch_get_running_loop�sz!TestCase.unpatch_get_running_loopcCs tj|_dd�t_tj�|_dS)NcSsdS)NrrrrrrU�sz TestCase.setUp.<locals>.<lambda>)r	r�rZthreading_setup�_thread_cleanup)r4rrr�setUp�s
zTestCase.setUpcCsB|j�tjd�|jtj�d�|j�tj|j	�tj
�dS)N)NNN)r�r	r�ZassertEqual�sys�exc_infoZ
doCleanupsrZthreading_cleanupr�Z
reap_children)r4rrr�tearDown�s
zTestCase.tearDowncOsGdd�d�}|�S)Nc@seZdZdd�Zdd�ZdS)z!TestCase.subTest.<locals>.EmptyCMcSsdS)Nr)r4rrr�	__enter__�sz+TestCase.subTest.<locals>.EmptyCM.__enter__cWsdS)Nr)r4�excrrr�__exit__�sz*TestCase.subTest.<locals>.EmptyCM.__exit__N)r9r:r;r�r�rrrr�EmptyCM�sr�r)r4r7r�r�rrr�subTest�szTestCase.subTest)N)
r9r:r;�staticmethodr�r�r�r�r�r�rZPY34r�rrrrr��s

r�ccs2tj}ztjtjd�dVWdtj|�XdS)zrContext manager to disable asyncio logger.

    For example, it can be used to ignore warnings in debug mode.
    rN)r�levelZsetLevel�loggingZCRITICAL)Z	old_levelrrr�disable_logger�s

r�cCs*tjtj�}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ	MagicMock�socket�protorx�familyZ
gettimeoutrs)r�rxr�Zsockrrr�mock_nonblocking_socketsr�cCstjddd�S)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrr�force_legacy_ssl_supportsr�)r*)Nr�r��
contextlibr2r�rr�r�r`r�rhrXr+Zunittestr�rZhttp.serverrZwsgiref.simple_serverrrr �ImportErrorrerrr	r
rrZ
coroutinesr
�logrrr�platformZ
windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrk�contextmanagerrmrnrqr{ZBaseSelectorr|Z
BaseEventLoopr�rwr�r�r�r�r�ZIPPROTO_TCPZSOCK_STREAMZAF_INETr�r�rrrr�<module>s�


	


4
PK=�\��t�GsGs$selector_events.cpython-36.opt-1.pycnu�[���3


 \���
@s<dZdgZddlZddlZddlZddlZddlZddlZyddlZWne	k
r^dZYnXddl
mZddl
mZddl
m
Z
ddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
lmZddlmZdd�ZGdd�dej�ZGdd�dejej�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z�Event loop using a selector and related classes.

A selector is a "notify-when-ready" multiplexer.  For a subclass which
also includes support for signal handling, see the unix_events sub-module.
�BaseSelectorEventLoop�N�)�base_events)�compat)�	constants)�events)�futures)�	selectors)�
transports)�sslproto)�	coroutine)�loggercCs6y|j|�}Wntk
r"dSXt|j|@�SdS)NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�//usr/lib64/python3.6/asyncio/selector_events.py�_test_selector_event s
rcsreZdZdZdO�fdd�	ZdPddd�dd�ZdQddddd	�d
d�Zddddd	�dd
�ZdRdd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdSdd �ZdTd!d"�ZedUd#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z ed?d@��Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(�Z)S)VrzJSelector event loop.

    See events.EventLoop for API specification.
    NcsFt�j�|dkrtj�}tjd|jj�||_|j	�t
j�|_dS)NzUsing selector: %s)
�super�__init__r	ZDefaultSelectorr
�debug�	__class__�__name__�	_selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfr)rrrr1s
zBaseSelectorEventLoop.__init__)�extra�servercCst||||||�S)N)�_SelectorSocketTransport)r!�sock�protocol�waiterr"r#rrr�_make_socket_transport;s
z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer"r#c

CsNtj�s"|j||||||||d�Stj||||||�}	t|||	||d�|	jS)N)r)r*r"r#)r"r#)rZ_is_sslproto_available�_make_legacy_ssl_transportZSSLProtocolr$Z_app_transport)
r!�rawsockr&�
sslcontextr'r)r*r"r#Zssl_protocolrrr�_make_ssl_transport@s

z)BaseSelectorEventLoop._make_ssl_transportc	
Cst|||||||||�	S)N)�_SelectorSslTransport)	r!r,r&r-r'r)r*r"r#rrrr+Os
z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||�S)N)�_SelectorDatagramTransport)r!r%r&�addressr'r"rrr�_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|j�rtd��|j�rdS|j�t�j�|jdk	rH|jj�d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer)r!)rrrr6^s


zBaseSelectorEventLoop.closecCst�dS)N)�NotImplementedError)r!rrr�_socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj��|jj�d|_|jj�d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor6�_csock�
_internal_fds)r!rrrr5ls

z&BaseSelectorEventLoop._close_self_pipecCsN|j�\|_|_|jjd�|jjd�|jd7_|j|jj�|j�dS)NFr)r8r:r<�setblockingr=�_add_readerr;�_read_from_self)r!rrrrts
z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!�datarrr�_process_self_data|sz(BaseSelectorEventLoop._process_self_datacCsVxPy |jjd�}|sP|j|�Wqtk
r8wYqtk
rLPYqXqWdS)Ni)r:�recvrB�InterruptedError�BlockingIOError)r!rArrrr@sz%BaseSelectorEventLoop._read_from_selfcCsJ|j}|dk	rFy|jd�Wn(tk
rD|jr@tjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketT)�exc_info)r<�send�OSError�_debugr
r)r!Zcsockrrr�_write_to_self�sz$BaseSelectorEventLoop._write_to_self�dcCs |j|j�|j|||||�dS)N)r?r;�_accept_connection)r!�protocol_factoryr%r-r#�backlogrrr�_start_serving�sz$BaseSelectorEventLoop._start_servingcCs�x�t|�D]�}y0|j�\}}|jr2tjd|||�|jd�Wn�tttfk
rXdSt	k
r�}	z^|	j
t
jt
jt
j
t
jfkr�|jd|	|d��|j|j��|jtj|j|||||�n�WYdd}	~	Xq
Xd|i}
|j|||
||�}|j|�q
WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exception�socket�peername)�range�acceptrJr
rr>rErD�ConnectionAbortedErrorrI�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr9r;Z
call_laterrZACCEPT_RETRY_DELAYrP�_accept_connection2Zcreate_task)r!rNr%r-r#rO�_�conn�addr�excr"rVrrrrM�s4


z(BaseSelectorEventLoop._accept_connectionccs�d}d}yj|�}|j�}|r6|j||||d||d�}n|j|||||d�}y|EdHWn|j��YnXWn\tk
r�}	z@|jr�d|	d�}
|dk	r�||
d<|dk	r�||
d<|j|
�WYdd}	~	XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr&�	transport)�
create_futurer.r(r6�	ExceptionrJrY)r!rNr\r"r-r#r&r_r'r^�contextrrrrZ�s4z)BaseSelectorEventLoop._accept_connection2cCs@y|j|}Wntk
r"YnX|j�s<tdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r r�
is_closingr3�format)r!rr_rrr�_ensure_fd_no_transport�sz-BaseSelectorEventLoop._ensure_fd_no_transportc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tj|df�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)�
_check_closedr�Handlerrr�registerr	�
EVENT_READrA�modify�cancel)	r!r�callback�args�handler�mask�reader�writerrrrr?�s
z!BaseSelectorEventLoop._add_readerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	||d|f�|dk	r�|j
�dSdSdS)NFT)r4rrrrrAr	ri�
unregisterrjrk)r!rrrorprqrrrr9sz$BaseSelectorEventLoop._remove_readerc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tjd|f�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)rfrrgrrrrhr	�EVENT_WRITErArjrk)	r!rrlrmrnrrorprqrrr�_add_writers
z!BaseSelectorEventLoop._add_writerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	|||df�|dk	r�|j
�dSdSdS)zRemove a writer callback.FNT)r4rrrrrAr	rsrrrjrk)r!rrrorprqrrr�_remove_writer,sz$BaseSelectorEventLoop._remove_writercGs|j|�|j||f|��S)zAdd a reader callback.)rer?)r!rrlrmrrr�
add_readerCs
z BaseSelectorEventLoop.add_readercCs|j|�|j|�S)zRemove a reader callback.)rer9)r!rrrr�
remove_readerHs
z#BaseSelectorEventLoop.remove_readercGs|j|�|j||f|��S)zAdd a writer callback..)rert)r!rrlrmrrr�
add_writerMs
z BaseSelectorEventLoop.add_writercCs|j|�|j|�S)zRemove a writer callback.)reru)r!rrrr�
remove_writerRs
z#BaseSelectorEventLoop.remove_writercCs6|jr|j�dkrtd��|j�}|j|d||�|S)z�Receive data from the socket.

        The return value is a bytes object representing the data received.
        The maximum amount of data to be received at once is specified by
        nbytes.

        This method is a coroutine.
        rzthe socket must be non-blockingN)rJ�
gettimeout�
ValueErrorr`�
_sock_recv)r!r%�n�futrrr�	sock_recvWs
	zBaseSelectorEventLoop.sock_recvcCs�|dk	r|j|�|j�rdSy|j|�}Wn`ttfk
rb|j�}|j||j||||�Yn6tk
r�}z|j	|�WYdd}~XnX|j
|�dS)N)rw�	cancelledrCrErDr;rvr|ra�
set_exception�
set_result)r!r~�
registered_fdr%r}rArr^rrrr|fs
z BaseSelectorEventLoop._sock_recvcCsF|jr|j�dkrtd��|j�}|r8|j|d||�n
|jd�|S)a�Send data to the socket.

        The socket must be connected to a remote socket. This method continues
        to send data from data until either all data has been sent or an
        error occurs. None is returned on success. On error, an exception is
        raised, and there is no way to determine how much data, if any, was
        successfully processed by the receiving end of the connection.

        This method is a coroutine.
        rzthe socket must be non-blockingN)rJrzr{r`�
_sock_sendallr�)r!r%rAr~rrr�sock_sendall{s
z"BaseSelectorEventLoop.sock_sendallcCs�|dk	r|j|�|j�rdSy|j|�}WnDttfk
rHd}Yn*tk
rp}z|j|�dSd}~XnX|t|�kr�|jd�n.|r�||d�}|j	�}|j
||j||||�dS)Nr)ryr�rHrErDrar��lenr�r;rxr�)r!r~r�r%rAr}r^rrrrr��s"

z#BaseSelectorEventLoop._sock_sendallccs�|jr|j�dkrtd��ttd�s2|jtjkrptj||j|j	|d�}|j
�sZ|EdH|j�d\}}}}}|j�}|j
|||�|EdHS)zTConnect to a remote socket at address.

        This method is a coroutine.
        rzthe socket must be non-blocking�AF_UNIX)�family�proto�loopN)rJrzr{�hasattrrSr�r�rZ_ensure_resolvedr��done�resultr`�
_sock_connect)r!r%r1Zresolvedr[r~rrr�sock_connect�s
z"BaseSelectorEventLoop.sock_connectcCs�|j�}y|j|�Wnjttfk
rV|jtj|j|��|j||j	|||�Yn6t
k
r�}z|j|�WYdd}~XnX|jd�dS)N)
r;ZconnectrErDZadd_done_callback�	functools�partial�_sock_connect_donerx�_sock_connect_cbrar�r�)r!r~r%r1rr^rrrr��sz#BaseSelectorEventLoop._sock_connectcCs|j|�dS)N)ry)r!rr~rrrr��sz(BaseSelectorEventLoop._sock_connect_donecCs�|j�rdSy,|jtjtj�}|dkr6t|d|f��WnBttfk
rPYn6tk
rz}z|j	|�WYdd}~XnX|j
d�dS)NrzConnect call failed %s)r�Z
getsockoptrSZ
SOL_SOCKETZSO_ERRORrIrErDrar�r�)r!r~r%r1�errr^rrrr��sz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|j�dkrtd��|j�}|j|d|�|S)a|Accept a connection.

        The socket must be bound to an address and listening for connections.
        The return value is a pair (conn, address) where conn is a new socket
        object usable to send and receive data on the connection, and address
        is the address bound to the socket on the other end of the connection.

        This method is a coroutine.
        rzthe socket must be non-blockingF)rJrzr{r`�_sock_accept)r!r%r~rrr�sock_accept�s

z!BaseSelectorEventLoop.sock_acceptcCs�|j�}|r|j|�|j�r"dSy|j�\}}|jd�WnVttfk
rh|j||j|d|�Yn:t	k
r�}z|j
|�WYdd}~XnX|j||f�dS)NFT)r;rwr�rVr>rErDrvr�rar�r�)r!r~Z
registeredr%rr\r1r^rrrr��s
z"BaseSelectorEventLoop._sock_acceptcCs�x~|D]v\}}|j|j}\}}|tj@rN|dk	rN|jrD|j|�n
|j|�|tj@r|dk	r|jrr|j|�q|j|�qWdS)N)	�fileobjrAr	riZ
_cancelledr9Z
_add_callbackrsru)r!Z
event_listrror�rprqrrr�_process_events�s
z%BaseSelectorEventLoop._process_eventscCs|j|j��|j�dS)N)r9r;r6)r!r%rrr�
_stop_servingsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN)*r�
__module__�__qualname__�__doc__rr(r.r+r2r6r8r5rrBr@rKrPrMrrZrer?r9rtrurvrwrxryrr|r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rrr+sT



(#cs�eZdZdZeZdZd �fdd�	Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ejr`dd�Zd!dd�Zdd�Zdd�Zdd�Zdd�Z�ZS)"�_SelectorTransport�iNcs�t�j||�||jd<|j�|jd<d|jkrdy|j�|jd<Wn tjk
rbd|jd<YnX||_|j�|_	||_
d|_||_|j
�|_d|_d|_|jdk	r�|jj�||j|j	<dS)NrSZsocknamerTTrF)rr�_extraZgetsocknameZgetpeernamerS�error�_sockr;�_sock_fd�	_protocol�_protocol_connected�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr )r!r�r%r&r"r#)rrrrs&





z_SelectorTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�|jdk	r�|jj�r�t|jj	|jt
j�}|rz|jd�n
|jd�t|jj	|jt
j�}|r�d}nd}|j
�}|jd||f�d	d
j|�S)N�closed�closingzfd=%szread=pollingz	read=idle�pollingZidlezwrite=<%s, bufsize=%s>z<%s>� )rrr��appendr�r��_loopr4rrr	rirs�get_write_buffer_size�join)r!�infor��state�bufsizerrr�__repr__2s*



z_SelectorTransport.__repr__cCs|jd�dS)N)�_force_close)r!rrr�abortNsz_SelectorTransport.abortcCs
||_dS)N)r�)r!r&rrr�set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r�)r!rrr�get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r�)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr
dSd|_|jj|j�|jsP|jd7_|jj|j�|jj|jd�dS)NTr)	r�r�r9r�r�r�ru�	call_soon�_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)�source)r��warnings�warn�ResourceWarningr6)r!rrr�__del__hs
z_SelectorTransport.__del__�Fatal error on transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)rG)rQrRr_r&)
�
isinstancerZ_FATAL_ERROR_IGNOREr��	get_debugr
rrYr�r�)r!r^rQrrr�_fatal_errorns
z_SelectorTransport._fatal_errorcCsd|jr
dS|jr(|jj�|jj|j�|jsBd|_|jj|j�|jd7_|jj|j	|�dS)NTr)
r�r��clearr�rur�r�r9r�r�)r!r^rrrr�|s
z_SelectorTransport._force_closecCsVz|jr|jj|�Wd|jj�d|_d|_d|_|j}|dk	rP|j�d|_XdS)N)r�r�Zconnection_lostr�r6r�r�Z_detach)r!r^r#rrrr��s
z(_SelectorTransport._call_connection_lostcCs
t|j�S)N)r�r�)r!rrrr��sz(_SelectorTransport.get_write_buffer_sizecGs"|jr
dS|jj||f|��dS)N)r�r�r?)r!rrlrmrrrr?�sz_SelectorTransport._add_readeri)NN)r�)rr�r��max_size�	bytearrayr�r�rr�r�r�r�rcr6rZPY34r�r�r�r�r�r?r�rr)rrr�s"

r�csVeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
�ZS)r$Ncsrt�j|||||�d|_d|_tj|j�|jj|j	j
|�|jj|j|j|j
�|dk	rn|jjtj|d�dS)NF)rr�_eof�_pausedrZ_set_nodelayr�r�r�r��connection_mader?r��_read_readyr�_set_result_unless_cancelled)r!r�r%r&r'r"r#)rrrr�s

z!_SelectorSocketTransport.__init__cCs>|js|jrdSd|_|jj|j�|jj�r:tjd|�dS)NTz%r pauses reading)r�r�r�r9r�r�r
r)r!rrr�
pause_reading�s
z&_SelectorSocketTransport.pause_readingcCsB|js|jrdSd|_|j|j|j�|jj�r>tjd|�dS)NFz%r resumes reading)	r�r�r?r�r�r�r�r
r)r!rrr�resume_reading�s
z'_SelectorSocketTransport.resume_readingcCs�|jr
dSy|jj|j�}WnDttfk
r4Yn|tk
r`}z|j|d�WYdd}~XnPX|rt|jj	|�n<|j
j�r�tj
d|�|jj�}|r�|j
j|j�n|j�dS)Nz$Fatal read error on socket transportz%r received EOF)r�r�rCr�rErDrar�r��
data_receivedr�r�r
r�eof_receivedr9r�r6)r!rAr^�	keep_openrrrr��s 

z$_SelectorSocketTransport._read_readycCs�t|tttf�s"tdt|�j��|jr0td��|s8dS|j	rf|j	t
jkrTtj
d�|j	d7_	dS|js�y|jj|�}WnBttfk
r�Yn@tk
r�}z|j|d�dSd}~XnX||d�}|s�dS|jj|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)r��bytesr��
memoryview�	TypeError�typerr�r3r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�r�rHrErDrar�r�rtr��_write_ready�extend�_maybe_pause_protocol)r!rAr}r^rrr�write�s4
z_SelectorSocketTransport.writecCs�|jr
dSy|jj|j�}Wn\ttfk
r4Yn�tk
rx}z*|jj|j	�|jj
�|j|d�WYdd}~XnTX|r�|jd|�=|j�|js�|jj|j	�|j
r�|jd�n|jr�|jjtj�dS)Nz%Fatal write error on socket transport)r�r�rHr�rErDrar�rur�r�r��_maybe_resume_protocolr�r�r��shutdownrS�SHUT_WR)r!r}r^rrrr�s&
z%_SelectorSocketTransport._write_readycCs.|js|jrdSd|_|js*|jjtj�dS)NT)r�r�r�r�r�rSr�)r!rrr�	write_eofs
z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr�
can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN)rr�r�rr�r�r�r�r�r�r�r�rr)rrr$�s#r$csdeZdZeZd�fdd�	Zddd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�ZS)r/NFc

s�tdkrtd��|s tj||�}|dd�}
|r<|r<||
d<|j|f|
�}t�j|||||	�d|_||_||_	||_
d|_|jj
|d�|jj�r�tjd|�|jj�}nd}|j|�dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)�sslr3rZ_create_transport_contextZwrap_socketrrr��_server_hostname�_waiter�_sslcontextr�r��updater�r�r
r�time�
_on_handshake)
r!r�r,r&r-r'r)r*r"r#Zwrap_kwargsZsslsock�
start_time)rrrr(s*

z_SelectorSslTransport.__init__cCsD|jdkrdS|jj�s:|dk	r.|jj|�n|jjd�d|_dS)N)r�r�r�r�)r!r^rrr�_wakeup_waiterLs

z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jj�Wn�tjk
r8|jj|j|j|�dStjk
r`|jj	|j|j|�dSt
k
r�}z`|jj�r�tj
d|dd�|jj|j�|jj|j�|jj�|j|�t|t�r�dS�WYdd}~XnX|jj|j�|jj|j�|jj�}t|jd��s�|j�r�|jjtjk�r�ytj||j�WnRtk
�r�}z4|jj��rjtj
d|dd�|jj�|j|�dSd}~XnX|jj||jj�|jj�|jd�d|_d|_ |jj|j|j!�d|_"|jj#|j$j%|�|jj#|j�|jj��r |jj&�|}tj'd||d	�dS)
Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)�peercert�cipher�compressionZ
ssl_objectFz%r: SSL handshake took %.1f msg@�@)(r�Zdo_handshaker��SSLWantReadErrorr�r?r�r��SSLWantWriteErrorrt�
BaseExceptionr�r
r�r9rur6r�r�raZgetpeercertr�r�r�Zverify_modeZ	CERT_NONEZmatch_hostnamer�r�r�r��_read_wants_write�_write_wants_readr�r�r�r�r�r�r)r!r�r^r�Zdtrrrr�Vsb













z#_SelectorSslTransport._on_handshakecCsJ|jrtd��|jrtd��d|_|jj|j�|jj�rFtjd|�dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r3r�r�r9r�r�r
r)r!rrrr��s
z#_SelectorSslTransport.pause_readingcCsJ|jstd��d|_|jrdS|jj|j|j�|jj�rFtj	d|�dS)Nz
Not pausedFz%r resumes reading)
r�r3r�r�r?r�r�r�r
r)r!rrrr��s
z$_SelectorSslTransport.resume_readingcCs"|jr
dS|jr6d|_|j�|jr6|jj|j|j�y|jj|j	�}Wn�t
ttj
fk
rdYn�tjk
r�d|_|jj|j�|jj|j|j�Yn�tk
r�}z|j|d�WYdd}~XnTX|r�|jj|�n@z4|jj�r�tjd|�|jj�}|�rtjd�Wd|j�XdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)r�r�r�r�r�rtr�r�rCr�rErDr�r�r�r�r9rar�r�r�r�r
rr�r�r6)r!rAr^r�rrrr��s4

z!_SelectorSslTransport._read_readycCs(|jr
dS|jr<d|_|j�|jp(|js<|jj|j|j�|jr�y|j	j
|j�}Wn�ttt
jfk
rtd}Ynpt
jk
r�d}|jj|j�d|_YnDtk
r�}z(|jj|j�|jj�|j|d�dSd}~XnX|r�|jd|�=|j�|j�s$|jj|j�|j�r$|jd�dS)NFrTz"Fatal write error on SSL transport)r�r�r�r�r�r�r?r�r�r�rHrErDr�r�r�rur�rar�r�r�r�)r!r}r^rrrr��s8

z"_SelectorSslTransport._write_readycCs�t|tttf�s"tdt|�j��|s*dS|jrX|jtj	krFt
jd�|jd7_dS|jsp|j
j|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rzsocket.send() raised exception.r)r�r�r�r�r�r�rr�rr�r
r�r�r�rtr�r�r�r�)r!rArrrr��s
z_SelectorSslTransport.writecCsdS)NFr)r!rrrr�sz#_SelectorSslTransport.can_write_eof)NFNNN)N)rr�r�r�r�rr�r�r�r�r�r�r�r�r�rr)rrr/$s"

?
"#r/csFeZdZejZd�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r0Ncs^t�j||||�||_|jj|jj|�|jj|j|j|j	�|dk	rZ|jjt
j|d�dS)N)rr�_addressr�r�r�r�r?r�r�rr�)r!r�r%r&r1r'r")rrrrs

z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss|]\}}t|�VqdS)N)r�)�.0rAr[rrr�	<genexpr>szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�)r!rrrr�sz0_SelectorDatagramTransport.get_write_buffer_sizecCs�|jr
dSy|jj|j�\}}Wnpttfk
r8Ynhtk
rd}z|jj|�WYdd}~Xn<t	k
r�}z|j
|d�WYdd}~XnX|jj||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rErDrIr��error_receivedrar�Zdatagram_received)r!rAr]r^rrrr� sz&_SelectorDatagramTransport._read_readycCsTt|tttf�s"tdt|�j��|s*dS|jrN|d|jfkrNtd|jf��|j	r�|jr�|j	t
jkrptj
d�|j	d7_	dS|j�s4y&|jr�|jj|�n|jj||�dSttfk
r�|jj|j|j�YnZtk
�r}z|jj|�dSd}~Xn.tk
�r2}z|j|d�dSd}~XnX|jjt|�|f�|j�dS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)r�r�r�r�r�r�rr�r{r�rr�r
r�r�r�rH�sendtorErDr�rtr��
_sendto_readyrIr�r�rar�r�r�)r!rAr]r^rrrr�.s<
z!_SelectorDatagramTransport.sendtocCs�x�|jr�|jj�\}}y&|jr,|jj|�n|jj||�Wqttfk
rf|jj||f�PYqt	k
r�}z|j
j|�dSd}~Xqtk
r�}z|j
|d�dSd}~XqXqW|j�|js�|jj|j�|jr�|jd�dS)Nz'Fatal write error on datagram transport)r��popleftr�r�rHr�rErD�
appendleftrIr�r�rar�r�r�rur�r�r�)r!rAr]r^rrrr�Us*z(_SelectorDatagramTransport._sendto_ready)NNN)N)rr�r��collections�dequer�rr�r�r�r�r�rr)rrr0s
'r0) r��__all__r�rXr�rSr�rr��ImportError�rrrrrr	r
rZ
coroutinesr�logr
rZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r$r/r0rrrr�<module>sD
iiPK=�\�a��Z<Z<locks.cpython-36.pycnu�[���3


 \�<�@s�dZdddddgZddlZdd	lmZdd
lmZddlmZddlmZGd
d�d�Z	Gdd�d�Z
Gdd�de
�ZGdd�d�ZGdd�de
�Z
Gdd�de
�ZGdd�de�ZdS)zSynchronization primitives.�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�compat)�events)�futures)�	coroutinec@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ContextManageraContext manager.

    This enables the following idiom for acquiring and releasing a
    lock around a block:

        with (yield from lock):
            <block>

    while failing loudly when accidentally using:

        with lock:
            <block>
    cCs
||_dS)N)�_lock)�self�lock�r�%/usr/lib64/python3.6/asyncio/locks.py�__init__sz_ContextManager.__init__cCsdS)Nr)rrrr�	__enter__sz_ContextManager.__enter__cGsz|jj�Wdd|_XdS)N)r
�release)r�argsrrr�__exit__$sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__�__doc__rrrrrrrr
s
rc@sNeZdZdd�Zdd�Zedd��ZejrJdd�Z	ed	d
��Z
edd��Zd
S)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|j�EdHt|�S)N)�acquirer)rrrr�__iter__5sz_ContextManagerMixin.__iter__ccs|j�EdHt|�S)N)rr)rrrr�	__await__Hsz_ContextManagerMixin.__await__ccs|j�EdHdS)N)r)rrrr�
__aenter__Msz_ContextManagerMixin.__aenter__cCs|j�dS)N)r)r�exc_type�exc�tbrrr�	__aexit__Tsz_ContextManagerMixin.__aexit__N)rrrrrrrrZPY35rr r$rrrrr+srcsReZdZdZdd�dd�Z�fdd�Zdd	�Zed
d��Zdd
�Z	dd�Z
�ZS)ra�Primitive lock objects.

    A primitive lock is a synchronization primitive that is not owned
    by a particular coroutine when locked.  A primitive lock is in one
    of two states, 'locked' or 'unlocked'.

    It is created in the unlocked state.  It has two basic methods,
    acquire() and release().  When the state is unlocked, acquire()
    changes the state to locked and returns immediately.  When the
    state is locked, acquire() blocks until a call to release() in
    another coroutine changes it to unlocked, then the acquire() call
    resets it to locked and returns.  The release() method should only
    be called in the locked state; it changes the state to unlocked
    and returns immediately.  If an attempt is made to release an
    unlocked lock, a RuntimeError will be raised.

    When more than one coroutine is blocked in acquire() waiting for
    the state to turn to unlocked, only one coroutine proceeds when a
    release() call resets the state to unlocked; first coroutine which
    is blocked in acquire() is being processed.

    acquire() is a coroutine and should be called with 'yield from'.

    Locks also support the context management protocol.  '(yield from lock)'
    should be used as the context manager expression.

    Usage:

        lock = Lock()
        ...
        yield from lock
        try:
            ...
        finally:
            lock.release()

    Context manager usage:

        lock = Lock()
        ...
        with (yield from lock):
             ...

    Lock objects can be tested for locking state:

        if not lock.locked():
           yield from lock
        else:
           # lock is acquired
           ...

    N)�loopcCs.tj�|_d|_|dk	r ||_n
tj�|_dS)NF)�collections�deque�_waiters�_locked�_loopr	�get_event_loop)rr%rrrr�s

z
Lock.__init__csDt�j�}|jrdnd}|jr0dj|t|j��}dj|dd�|�S)N�locked�unlockedz
{},waiters:{}z	<{} [{}]>r���)�super�__repr__r)r(�format�len)r�res�extra)�	__class__rrr0�s

z
Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,�szLock.lockedccs�|jr&tdd�|jD��r&d|_dS|jj�}|jj|�y"z|EdHWd|jj|�XWn&tjk
r�|js~|j	��YnXd|_dS)z�Acquire a lock.

        This method blocks until the lock is unlocked, then sets it to
        locked and returns True.
        css|]}|j�VqdS)N)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>TN)
r)�allr(r*�
create_future�append�remover
�CancelledError�_wake_up_first)r�futrrrr�s
zLock.acquirecCs"|jrd|_|j�ntd��dS)aGRelease a lock.

        When the lock is locked, reset it to unlocked, and return.
        If any other coroutines are blocked waiting for the lock to become
        unlocked, allow exactly one of them to proceed.

        When invoked on an unlocked lock, a RuntimeError is raised.

        There is no return value.
        FzLock is not acquired.N)r)r?r)rrrrr�s
zLock.releasecCs>ytt|j��}Wntk
r&dSX|j�s:|jd�dS)z*Wake up the first waiter if it isn't done.NT)�next�iterr(�
StopIteration�done�
set_result)rr@rrrr?�szLock._wake_up_first)rrrrrr0r,rrrr?�
__classcell__rr)r5rrYs4csReZdZdZdd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Ze	dd��Z
�ZS)ra#Asynchronous equivalent to threading.Event.

    Class implementing event objects. An event manages a flag that can be set
    to true with the set() method and reset to false with the clear() method.
    The wait() method blocks until the flag is true. The flag is initially
    false.
    N)r%cCs.tj�|_d|_|dk	r ||_n
tj�|_dS)NF)r&r'r(�_valuer*r	r+)rr%rrrr�s

zEvent.__init__csDt�j�}|jrdnd}|jr0dj|t|j��}dj|dd�|�S)N�setZunsetz
{},waiters:{}z	<{} [{}]>rr.)r/r0rGr(r1r2)rr3r4)r5rrr0�s

zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rG)rrrr�is_set�szEvent.is_setcCs2|js.d|_x |jD]}|j�s|jd�qWdS)z�Set the internal flag to true. All coroutines waiting for it to
        become true are awakened. Coroutine that call wait() once the flag is
        true will not block at all.
        TN)rGr(rDrE)rr@rrrrH�s
z	Event.setcCs
d|_dS)z�Reset the internal flag to false. Subsequently, coroutines calling
        wait() will block until set() is called to set the internal flag
        to true again.FN)rG)rrrr�clearszEvent.clearccsB|jr
dS|jj�}|jj|�z|EdHdS|jj|�XdS)z�Block until the internal flag is true.

        If the internal flag is true on entry, return True
        immediately.  Otherwise, block until another coroutine calls
        set() to set the flag to true, then return True.
        TN)rGr*r;r(r<r=)rr@rrr�wait
s

z
Event.wait)rrrrrr0rIrHrJrrKrFrr)r5rr�scsZeZdZdZddd�dd�Z�fdd�Zedd	��Zed
d��Zdd
d�Z	dd�Z
�ZS)raAsynchronous equivalent to threading.Condition.

    This class implements condition variable objects. A condition variable
    allows one or more coroutines to wait until they are notified by another
    coroutine.

    A new Lock object is created and used as the underlying lock.
    N)r%cCsp|dk	r||_n
tj�|_|dkr0t|jd�}n|j|jk	rDtd��||_|j|_|j|_|j|_t	j
�|_dS)N)r%z"loop argument must agree with lock)r*r	r+r�
ValueErrorr
r,rrr&r'r()rrr%rrrr+s
zCondition.__init__csFt�j�}|j�rdnd}|jr2dj|t|j��}dj|dd�|�S)Nr,r-z
{},waiters:{}z	<{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr0>s

zCondition.__repr__ccs�|j�std��|j�z8|jj�}|jj|�z|EdHdS|jj|�XWdd}x4y|j�EdHPWqXt	j
k
r�d}YqXXqXW|r�t	j
�XdS)a�Wait until notified.

        If the calling coroutine has not acquired the lock when this
        method is called, a RuntimeError is raised.

        This method releases the underlying lock, and then blocks
        until it is awakened by a notify() or notify_all() call for
        the same condition variable in another coroutine.  Once
        awakened, it re-acquires the lock and returns True.
        zcannot wait on un-acquired lockNTF)r,rrr*r;r(r<r=rr
r>)rr@r6rrrrKEs&

zCondition.waitccs(|�}x|s"|j�EdH|�}qW|S)z�Wait until a predicate becomes true.

        The predicate should be a callable which result will be
        interpreted as a boolean value.  The final predicate value is
        the return value.
        N)rK)rZ	predicate�resultrrr�wait_forks

zCondition.wait_forrcCsL|j�std��d}x2|jD](}||kr*P|j�s|d7}|jd�qWdS)aBy default, wake up one coroutine waiting on this condition, if any.
        If the calling coroutine has not acquired the lock when this method
        is called, a RuntimeError is raised.

        This method wakes up at most n of the coroutines waiting for the
        condition variable; it is a no-op if no coroutines are waiting.

        Note: an awakened coroutine does not actually return from its
        wait() call until it can reacquire the lock. Since notify() does
        not release the lock, its caller should.
        z!cannot notify on un-acquired lockrrFN)r,rr(rDrE)r�n�idxr@rrr�notifyyszCondition.notifycCs|jt|j��dS)aWake up all threads waiting on this condition. This method acts
        like notify(), but wakes up all waiting threads instead of one. If the
        calling thread has not acquired the lock when this method is called,
        a RuntimeError is raised.
        N)rQr2r()rrrr�
notify_all�szCondition.notify_all)N)r)rrrrrr0rrKrNrQrRrFrr)r5rr!s&
csTeZdZdZddd�dd�Z�fdd�Zd	d
�Zdd�Zed
d��Z	dd�Z
�ZS)raA Semaphore implementation.

    A semaphore manages an internal counter which is decremented by each
    acquire() call and incremented by each release() call. The counter
    can never go below zero; when acquire() finds that it is zero, it blocks,
    waiting until some other thread calls release().

    Semaphores also support the context management protocol.

    The optional argument gives the initial value for the internal
    counter; it defaults to 1. If the value given is less than 0,
    ValueError is raised.
    rN)r%cCs>|dkrtd��||_tj�|_|dk	r0||_n
tj�|_dS)Nrz$Semaphore initial value must be >= 0)rLrGr&r'r(r*r	r+)r�valuer%rrrr�s
zSemaphore.__init__csNt�j�}|j�rdn
dj|j�}|jr:dj|t|j��}dj|dd�|�S)Nr,zunlocked,value:{}z
{},waiters:{}z	<{} [{}]>rr.)r/r0r,r1rGr(r2)rr3r4)r5rrr0�s
zSemaphore.__repr__cCs0x*|jr*|jj�}|j�s|jd�dSqWdS)N)r(�popleftrDrE)rZwaiterrrr�
_wake_up_next�s


zSemaphore._wake_up_nextcCs
|jdkS)z:Returns True if semaphore can not be acquired immediately.r)rG)rrrrr,�szSemaphore.lockedc	cszxf|jdkrf|jj�}|jj|�y|EdHWq|j�|jdkr\|j�r\|j��YqXqW|jd8_dS)a5Acquire a semaphore.

        If the internal counter is larger than zero on entry,
        decrement it by one and return True immediately.  If it is
        zero on entry, block, waiting until some other coroutine has
        called release() to make it larger than 0, and then return
        True.
        rNrT)rGr*r;r(r<Zcancelr6rU)rr@rrrr�s

zSemaphore.acquirecCs|jd7_|j�dS)z�Release a semaphore, incrementing the internal counter by one.
        When it was zero on entry and another coroutine is waiting for it to
        become larger than zero again, wake up that coroutine.
        rN)rGrU)rrrrr�szSemaphore.release)r)rrrrrr0rUr,rrrrFrr)r5rr�s

cs4eZdZdZd	dd��fdd�Z�fdd�Z�ZS)
rz�A bounded semaphore implementation.

    This raises ValueError in release() if it would increase the value
    above the initial value.
    rN)r%cs||_t�j||d�dS)N)r%)�_bound_valuer/r)rrSr%)r5rrr�szBoundedSemaphore.__init__cs"|j|jkrtd��t�j�dS)Nz(BoundedSemaphore released too many times)rGrVrLr/r)r)r5rrr�szBoundedSemaphore.release)r)rrrrrrrFrr)r5rr�s)r�__all__r&�rr	r
Z
coroutinesrrrrrrrrrrrr�<module>s.ByMPK=�\��ېb�bevents.cpython-36.opt-1.pycnu�[���3


 \�[�@s�dZddddddddd	d
ddd
dgZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
dd�Zdd�Zd3dd�Zdd�Zd4dd�ZGdd�d�ZGd d�de�ZGd!d�d�ZGd"d�d�ZGd#d�d�ZGd$d%�d%e�Zdae	j�ZGd&d'�d'e	j�Ze�Zd(d�Zd)d
�Z d*d+�Z!d,d�Z"d-d�Z#d.d�Z$d/d	�Z%d0d
�Z&d1d�Z'd2d�Z(dS)5z!Event loop and event loop policy.�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�_get_running_loop�N�)�compat)�	constantscCsttjrtj|�}nt|d�r"|j}tj|�r>|j}|j|j	fSt
|tj�rTt
|j�Stjrpt
|tj�rpt
|j�SdS)N�__wrapped__)rZPY34�inspectZunwrap�hasattrrZ
isfunction�__code__�co_filename�co_firstlineno�
isinstance�	functools�partial�_get_function_source�func�
partialmethod)r�code�r �&/usr/lib64/python3.6/asyncio/events.pyrs



rcCsJg}|r|jdd�|D��|r8|jdd�|j�D��ddj|�dS)z�Format function arguments and keyword arguments.

    Special case for a single parameter: ('hello',) is formatted as ('hello').
    css|]}tj|�VqdS)N)�reprlib�repr)�.0�argr r r!�	<genexpr>1sz*_format_args_and_kwargs.<locals>.<genexpr>css$|]\}}dj|tj|��VqdS)z{}={}N)�formatr"r#)r$�k�vr r r!r&3s�(z, �))�extend�items�join)�args�kwargsr-r r r!�_format_args_and_kwargs)s
r1�cCs�t|tj�r.t||�|}t|j|j|j|�St|d�rF|j	rF|j	}n t|d�r^|j
r^|j
}nt|�}|t||�7}|r�||7}|S)N�__qualname__�__name__)rrrr1�_format_callbackrr/�keywordsrr3r4r#)rr/r0�suffix�	func_reprr r r!r58sr5cCs(t||d�}t|�}|r$|d|7}|S)Nz	 at %s:%s)r5r)rr/r8�sourcer r r!�_format_callback_sourceIs
r:cCsD|dkrtj�j}|dkr tj}tjjtj|�|dd�}|j	�|S)zlReplacement for traceback.extract_stack() that only does the
    necessary work for asyncio debug mode.
    NF)�limit�lookup_lines)
�sys�	_getframe�f_backrZDEBUG_STACK_DEPTH�	traceback�StackSummary�extract�
walk_stack�reverse)�fr;�stackr r r!�
extract_stackQs
rGc@s<eZdZdZdZd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dS)rz1Object returned by callback registration methods.�	_callback�_args�
_cancelled�_loop�_source_traceback�_repr�__weakref__cCsD||_||_||_d|_d|_|jj�r:ttjd��|_	nd|_	dS)NFr)
rKrHrIrJrM�	get_debugrGr=r>rL)�self�callbackr/�loopr r r!�__init__hs
zHandle.__init__cCsf|jjg}|jr|jd�|jdk	r8|jt|j|j��|jrb|jd}|jd|d|df�|S)NZ	cancelledrzcreated at %s:%sr���)�	__class__r4rJ�appendrHr:rIrL)rP�info�framer r r!�
_repr_infoss



zHandle._repr_infocCs&|jdk	r|jS|j�}ddj|�S)Nz<%s>� )rMrYr.)rPrWr r r!�__repr__~s
zHandle.__repr__cCs0|js,d|_|jj�r t|�|_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!�cancel�s

z
Handle.cancelcCs|y|j|j�Wnbtk
rr}zFt|j|j�}dj|�}|||d�}|jrV|j|d<|jj|�WYdd}~XnXd}dS)NzException in callback {})�messageZ	exception�handleZsource_traceback)rHrI�	Exceptionr:r'rLrK�call_exception_handler)rP�exc�cb�msg�contextr r r!�_run�s

zHandle._runN)rHrIrJrKrLrMrN)
r4�
__module__r3�__doc__�	__slots__rSrYr[r\rer r r r!rbscsxeZdZdZddgZ�fdd�Z�fdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
�fdd�Z�ZS)rz7Object returned by timed callback registration methods.�
_scheduled�_whencs.t�j|||�|jr|jd=||_d|_dS)NrFrT)�superrSrLrjri)rP�whenrQr/rR)rUr r!rS�s
zTimerHandle.__init__cs.t�j�}|jrdnd}|j|d|j�|S)N�rzwhen=%s)rkrYrJ�insertrj)rPrW�pos)rUr r!rY�s
zTimerHandle._repr_infocCs
t|j�S)N)�hashrj)rPr r r!�__hash__�szTimerHandle.__hash__cCs|j|jkS)N)rj)rP�otherr r r!�__lt__�szTimerHandle.__lt__cCs|j|jkrdS|j|�S)NT)rj�__eq__)rPrrr r r!�__le__�szTimerHandle.__le__cCs|j|jkS)N)rj)rPrrr r r!�__gt__�szTimerHandle.__gt__cCs|j|jkrdS|j|�S)NT)rjrt)rPrrr r r!�__ge__�szTimerHandle.__ge__cCs>t|t�r:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrjrHrIrJ�NotImplemented)rPrrr r r!rt�s
zTimerHandle.__eq__cCs|j|�}|tkrtS|S)N)rtrx)rPrrZequalr r r!�__ne__�s
zTimerHandle.__ne__cs |js|jj|�t�j�dS)N)rJrK�_timer_handle_cancelledrkr\)rP)rUr r!r\�szTimerHandle.cancel)r4rfr3rgrhrSrYrqrsrurvrwrtryr\�
__classcell__r r )rUr!r�sc@s eZdZdZdd�Zdd�ZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving.  This leaves existing connections open.)rx)rPr r r!�close�szAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)rx)rPr r r!�wait_closed�szAbstractServer.wait_closedN)r4rfr3rgr|r}r r r r!r�sc	@seZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d$d$d$d%�d&d'�Zdhd(d)�Zdid*d$d$d$d*d*d*d+�d,d-�Zdjejejd*d.d*d*d*d/�d0d1�Zd*d*d*d2�d3d4�Zd*d.d*d5�d6d7�Zdkd$d$d$d*d*d*d*d8�d9d:�Zd;d<�Zd=d>�Z e!j"e!j"e!j"d?�d@dA�Z#e!j"e!j"e!j"d?�dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1d^d_�Z2d`da�Z3dbdc�Z4ddde�Z5dfdg�Z6d*S)lrzAbstract event loop.cCst�dS)z*Run the event loop until stop() is called.N)�NotImplementedError)rPr r r!�run_forever�szAbstractEventLoop.run_forevercCst�dS)zpRun the event loop until a Future is done.

        Return the Future's result, or raise its exception.
        N)r~)rPZfuturer r r!�run_until_complete�sz$AbstractEventLoop.run_until_completecCst�dS)z�Stop the event loop as soon as reasonable.

        Exactly how soon that is may depend on the implementation, but
        no more I/O callbacks should be scheduled.
        N)r~)rPr r r!�stop�szAbstractEventLoop.stopcCst�dS)z3Return whether the event loop is currently running.N)r~)rPr r r!�
is_running�szAbstractEventLoop.is_runningcCst�dS)z*Returns True if the event loop was closed.N)r~)rPr r r!�	is_closedszAbstractEventLoop.is_closedcCst�dS)z�Close the loop.

        The loop should not be running.

        This is idempotent and irreversible.

        No other methods should be called after this one.
        N)r~)rPr r r!r|s	zAbstractEventLoop.closecCst�dS)z,Shutdown all active asynchronous generators.N)r~)rPr r r!�shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCst�dS)z3Notification that a TimerHandle has been cancelled.N)r~)rPr^r r r!rzsz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|��S)Nr)�
call_later)rPrQr/r r r!�	call_soonszAbstractEventLoop.call_sooncGst�dS)N)r~)rPZdelayrQr/r r r!r�szAbstractEventLoop.call_latercGst�dS)N)r~)rPrlrQr/r r r!�call_atszAbstractEventLoop.call_atcCst�dS)N)r~)rPr r r!�time"szAbstractEventLoop.timecCst�dS)N)r~)rPr r r!�
create_future%szAbstractEventLoop.create_futurecCst�dS)N)r~)rP�coror r r!�create_task*szAbstractEventLoop.create_taskcGst�dS)N)r~)rPrQr/r r r!�call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGst�dS)N)r~)rP�executorrr/r r r!�run_in_executor2sz!AbstractEventLoop.run_in_executorcCst�dS)N)r~)rPr�r r r!�set_default_executor5sz&AbstractEventLoop.set_default_executorr)�family�type�proto�flagscCst�dS)N)r~)rP�host�portr�r�r�r�r r r!�getaddrinfo:szAbstractEventLoop.getaddrinfocCst�dS)N)r~)rPZsockaddrr�r r r!�getnameinfo=szAbstractEventLoop.getnameinfoN)�sslr�r�r��sock�
local_addr�server_hostnamecCst�dS)N)r~)rP�protocol_factoryr�r�r�r�r�r�r�r�r�r r r!�create_connection@sz#AbstractEventLoop.create_connection�d)r�r�r��backlogr��
reuse_address�
reuse_portcCst�dS)a�A coroutine which creates a TCP server bound to host and port.

        The return value is a Server object which can be used to stop
        the service.

        If host is an empty string or None all interfaces are assumed
        and a list of multiple sockets will be returned (most likely
        one for IPv4 and another one for IPv6). The host parameter can also be a
        sequence (e.g. list) of hosts to bind to.

        family can be set to either AF_INET or AF_INET6 to force the
        socket to use IPv4 or IPv6. If not set it will be determined
        from host (defaults to AF_UNSPEC).

        flags is a bitmask for getaddrinfo().

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows.
        N)r~)rPr�r�r�r�r�r�r�r�r�r�r r r!�
create_serverEs'zAbstractEventLoop.create_server)r�r�r�cCst�dS)N)r~)rPr��pathr�r�r�r r r!�create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)r�r�r�cCst�dS)a#A coroutine which creates a UNIX Domain Socket server.

        The return value is a Server object, which can be used to stop
        the service.

        path is a str, representing a file systsem path to bind the
        server socket to.

        sock can optionally be specified in order to use a preexisting
        socket object.

        backlog is the maximum number of queued connections passed to
        listen() (defaults to 100).

        ssl can be set to an SSLContext to enable SSL over the
        accepted connections.
        N)r~)rPr�r�r�r�r�r r r!�create_unix_serverssz$AbstractEventLoop.create_unix_server)r�r�r�r�r��allow_broadcastr�cCst�dS)a�A coroutine which creates a datagram endpoint.

        This method will try to establish the endpoint in the background.
        When successful, the coroutine returns a (transport, protocol) pair.

        protocol_factory must be a callable returning a protocol instance.

        socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_DGRAM.

        reuse_address tells the kernel to reuse a local socket in
        TIME_WAIT state, without waiting for its natural timeout to
        expire. If not specified it will automatically be set to True on
        UNIX.

        reuse_port tells the kernel to allow this endpoint to be bound to
        the same port as other existing endpoints are bound to, so long as
        they all set this flag when being created. This option is not
        supported on Windows and some UNIX's. If the
        :py:data:`~socket.SO_REUSEPORT` constant is not defined then this
        capability is unsupported.

        allow_broadcast tells the kernel to allow this endpoint to send
        messages to the broadcast address.

        sock can optionally be specified in order to use a preexisting
        socket object.
        N)r~)rPr�r�Zremote_addrr�r�r�r�r�r�r�r r r!�create_datagram_endpoint�s!z*AbstractEventLoop.create_datagram_endpointcCst�dS)aRegister read pipe in event loop. Set the pipe to non-blocking mode.

        protocol_factory should instantiate object with Protocol interface.
        pipe is a file-like object.
        Return pair (transport, protocol), where transport supports the
        ReadTransport interface.N)r~)rPr��piper r r!�connect_read_pipe�sz#AbstractEventLoop.connect_read_pipecCst�dS)aRegister write pipe in event loop.

        protocol_factory should instantiate object with BaseProtocol interface.
        Pipe is file-like object already switched to nonblocking.
        Return pair (transport, protocol), where transport support
        WriteTransport interface.N)r~)rPr�r�r r r!�connect_write_pipe�sz$AbstractEventLoop.connect_write_pipe)�stdin�stdout�stderrcKst�dS)N)r~)rPr��cmdr�r�r�r0r r r!�subprocess_shell�sz"AbstractEventLoop.subprocess_shellcOst�dS)N)r~)rPr�r�r�r�r/r0r r r!�subprocess_exec�sz!AbstractEventLoop.subprocess_execcGst�dS)N)r~)rP�fdrQr/r r r!�
add_reader�szAbstractEventLoop.add_readercCst�dS)N)r~)rPr�r r r!�
remove_reader�szAbstractEventLoop.remove_readercGst�dS)N)r~)rPr�rQr/r r r!�
add_writer�szAbstractEventLoop.add_writercCst�dS)N)r~)rPr�r r r!�
remove_writer�szAbstractEventLoop.remove_writercCst�dS)N)r~)rPr��nbytesr r r!�	sock_recv�szAbstractEventLoop.sock_recvcCst�dS)N)r~)rPr��datar r r!�sock_sendall�szAbstractEventLoop.sock_sendallcCst�dS)N)r~)rPr�Zaddressr r r!�sock_connect�szAbstractEventLoop.sock_connectcCst�dS)N)r~)rPr�r r r!�sock_accept�szAbstractEventLoop.sock_acceptcGst�dS)N)r~)rP�sigrQr/r r r!�add_signal_handler�sz$AbstractEventLoop.add_signal_handlercCst�dS)N)r~)rPr�r r r!�remove_signal_handler�sz'AbstractEventLoop.remove_signal_handlercCst�dS)N)r~)rP�factoryr r r!�set_task_factory�sz"AbstractEventLoop.set_task_factorycCst�dS)N)r~)rPr r r!�get_task_factory�sz"AbstractEventLoop.get_task_factorycCst�dS)N)r~)rPr r r!�get_exception_handlersz'AbstractEventLoop.get_exception_handlercCst�dS)N)r~)rPZhandlerr r r!�set_exception_handlersz'AbstractEventLoop.set_exception_handlercCst�dS)N)r~)rPrdr r r!�default_exception_handlersz+AbstractEventLoop.default_exception_handlercCst�dS)N)r~)rPrdr r r!r`sz(AbstractEventLoop.call_exception_handlercCst�dS)N)r~)rPr r r!rOszAbstractEventLoop.get_debugcCst�dS)N)r~)rPZenabledr r r!�	set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)7r4rfr3rgrr�r�r�r�r|r�rzr�r�r�r�r�r�r�r�r�r�r�r��socketZ	AF_UNSPECZ
AI_PASSIVEr�r�r�r�r�r��
subprocess�PIPEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r`rOr�r r r r!r�st

'!

	c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rz-Abstract policy for accessing the event loop.cCst�dS)a:Get the event loop for the current context.

        Returns an event loop object implementing the BaseEventLoop interface,
        or raises an exception in case no event loop has been set for the
        current context and the current policy does not specify to create one.

        It should never return None.N)r~)rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCst�dS)z3Set the event loop for the current context to loop.N)r~)rPrRr r r!r	$sz&AbstractEventLoopPolicy.set_event_loopcCst�dS)z�Create and return a new event loop object according to this
        policy's rules. If there's need to set this loop as the event loop for
        the current context, set_event_loop must be called explicitly.N)r~)rPr r r!r
(sz&AbstractEventLoopPolicy.new_event_loopcCst�dS)z$Get the watcher for child processes.N)r~)rPr r r!r0sz)AbstractEventLoopPolicy.get_child_watchercCst�dS)z$Set the watcher for child processes.N)r~)rP�watcherr r r!r4sz)AbstractEventLoopPolicy.set_child_watcherN)	r4rfr3rgrr	r
rrr r r r!rs
c@sFeZdZdZdZGdd�dej�Zdd�Zdd�Z	d	d
�Z
dd�ZdS)
�BaseDefaultEventLoopPolicya�Default policy implementation for accessing the event loop.

    In this policy, each thread has its own event loop.  However, we
    only automatically create an event loop by default for the main
    thread; other threads by default have no event loop.

    Other policies may have different rules (e.g. a single global
    event loop, or automatically creating an event loop per thread, or
    using some other notion of context to which an event loop is
    associated).
    Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK�_set_calledr r r r!�_LocalHsr�cCs|j�|_dS)N)r��_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jjr4ttj�tj�r4|j|j��|jjdkrRt	dtj�j
��|jjS)zSGet the event loop.

        This may be None or an instance of EventLoop.
        Nz,There is no current event loop in thread %r.)r�rKr�r�	threadingZcurrent_threadZ_MainThreadr	r
�RuntimeError�name)rPr r r!rOs
z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)zSet the event loop.TN)r�r�rK)rPrRr r r!r	]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|j�S)zvCreate a new event loop.

        You must call set_event_loop() to make this the current event
        loop.
        )�
_loop_factory)rPr r r!r
csz)BaseDefaultEventLoopPolicy.new_event_loop)r4rfr3rgr�r��localr�rSrr	r
r r r r!r�9sr�c@seZdZdZdS)�_RunningLoopN)NN)r4rfr3�loop_pidr r r r!r�wsr�cCs&tj\}}|dk	r"|tj�kr"|SdS)z�Return the running event loop or None.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)�
_running_loopr��os�getpid)Zrunning_loop�pidr r r!r~s
cCs|tj�ft_dS)z�Set the running event loop.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)r�r�r�r�)rRr r r!r
�sc	Cs.t� tdkr ddlm}|�aWdQRXdS)Nr)�DefaultEventLoopPolicy)�_lock�_event_loop_policyr2r�)r�r r r!�_init_event_loop_policy�sr�cCstdkrt�tS)z"Get the current event loop policy.N)r�r�r r r r!r�scCs|adS)zZSet the current event loop policy.

    If policy is None, the default policy is restored.N)r�)Zpolicyr r r!r�scCst�}|dk	r|St�j�S)aGReturn an asyncio event loop.

    When called from a coroutine or a callback (e.g. scheduled with call_soon
    or similar API), this function will always return the running event loop.

    If there is no running event loop set, the function will return
    the result of `get_event_loop_policy().get_event_loop()` call.
    N)rrr)Zcurrent_loopr r r!r�s	cCst�j|�dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr	)rRr r r!r	�scCs
t�j�S)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr
r r r r!r
�scCs
t�j�S)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rrr r r r!r�scCst�j|�S)zMEquivalent to calling
    get_event_loop_policy().set_child_watcher(watcher).)rr)r�r r r!r�s)r2)NN))rg�__all__rrr�r"r�r�r=r�r@r2rrrr1r5r:rGrrrrrr�r�ZLockr�r�r�r�rr
r�rrrr	r
rrr r r r!�<module>sZ

>85"7		PK=�\ϤУ!base_futures.cpython-36.opt-1.pycnu�[���3


 \�@srgZddlZddlZddlmZejjjZejj	Z	ejj
Z
Gdd�de�ZdZdZ
dZd	d
�Zdd�Zd
d�ZdS)�N�)�eventsc@seZdZdZdS)�InvalidStateErrorz+The operation is not allowed in this state.N)�__name__�
__module__�__qualname__�__doc__�r	r	�,/usr/lib64/python3.6/asyncio/base_futures.pyr
srZPENDINGZ	CANCELLEDZFINISHEDcCst|jd�o|jdk	S)z�Check for a Future.

    This returns True when obj is a Future instance or is advertising
    itself as duck-type compatible by setting _asyncio_future_blocking.
    See comment in Future for more details.
    �_asyncio_future_blockingN)�hasattr�	__class__r)�objr	r	r
�isfuturesrcCs�t|�}|sd}dd�}|dkr.||d�}nP|dkrTdj||d�||d��}n*|dkr~dj||d�|d||d
��}d	|S)z#helper function for Future.__repr__�cSstj|f�S)N)rZ_format_callback_source)�callbackr	r	r
�	format_cb(sz$_format_callbacks.<locals>.format_cbrr�z{}, {}z{}, <{} more>, {}zcb=[%s]���)�len�format)�cb�sizerr	r	r
�_format_callbacks"srcCs�|jj�g}|jtkrP|jdk	r4|jdj|j��ntj|j�}|jdj|��|j	rf|jt
|j	��|jr�|jd}|jd|d|df�|S)z#helper function for Future.__repr__Nzexception={!r}z	result={}rzcreated at %s:%srr)Z_state�lower�	_FINISHEDZ
_exception�appendr�reprlib�reprZ_resultZ
_callbacksrZ_source_traceback)Zfuture�info�result�framer	r	r
�_future_repr_info6s


r")�__all__Zconcurrent.futures._baseZ
concurrentrrrZfuturesZ_base�ErrorZCancelledError�TimeoutErrorrZ_PENDINGZ
_CANCELLEDrrrr"r	r	r	r
�<module>s
PK=�\�����compat.cpython-36.opt-1.pycnu�[���3


 \�@s6dZddlZejd	kZejd
kZejdkZdd�ZdS)z8Compatibility helpers for the different Python versions.�N����cCstsdd�|D�}dj|�S)z-Concatenate a sequence of bytes-like objects.css$|]}t|t�rt|�n|VqdS)N)�
isinstance�
memoryview�bytes)�.0�data�r�&/usr/lib64/python3.6/asyncio/compat.py�	<genexpr>sz%flatten_list_bytes.<locals>.<genexpr>�)�PY34�join)Zlist_of_datarrr�flatten_list_bytes
sr)rr)rr)rrr)�__doc__�sys�version_inforZPY35ZPY352rrrrr�<module>s



PK=�\P���ŘŘ base_events.cpython-36.opt-1.pycnu�[���3


 \��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZdgZdZd
ZeeefZ e!e	d�Z"d)Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)de	j*ddd�dd�Z+e!e	d ��rRd!d"�Z,nd#d"�Z,d$d%�Z-Gd&d'�d'ej.�Z/Gd(d�dej0�Z1dS)*a�Base implementation of event loop.

The event loop can be broken up into a multiplexer (the part
responsible for notifying us of I/O events) and the event loop proper,
which wraps a multiplexer with functionality for scheduling callbacks,
immediately or at a given time in the future.

Whenever a public API takes a callback, subsequent positional
arguments will be passed to the callback if/when it is called.  This
avoids the proliferation of trivial lambdas implementing closures.
Keyword arguments for the callback are not supported; this is a
conscious design decision, leaving the door open for keyword arguments
to modify the meaning of the API call itself.
�N�)�compat)�
coroutines)�events)�futures)�tasks)�	coroutine)�logger�
BaseEventLoop�dg�?�AF_INET6�icCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�+/usr/lib64/python3.6/asyncio/base_events.py�_format_handle?s
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeHs


rcCsLttd�std��n4y|jtjtjd�Wntk
rFtd��YnXdS)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr�OSError)�sockrrr�_set_reuseportQs

r&cCs&ttd�r|d@tjkS|tjkSdS)N�
SOCK_NONBLOCK�)rr �SOCK_STREAM)�	sock_typerrr�_is_stream_socket\s
r+cCs&ttd�r|d@tjkS|tjkSdS)Nr'r()rr �
SOCK_DGRAM)r*rrr�_is_dgram_sockeths
r-cCsvttd�sdS|dtjtjhks(|dkr,dSt|�r<tj}nt|�rLtj}ndS|dkr^d}nVt|t�rv|dkrvd}n>t|t�r�|dkr�d}n&yt	|�}Wnt
tfk
r�dSX|tjkr�tj
g}tr�|jtj�n|g}t|t�r�|jd�}d|k�rdSxp|D]h}yJtj||�t�r@|tjk�r@|||d||ddffS|||d||ffSWntk
�rjYnX�qWdS)N�	inet_ptonr��Zidna�%)rr �IPPROTO_TCPZIPPROTO_UDPr+r-r�bytesr�int�	TypeErrorr!�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder.r$)�host�port�family�type�protoZafs�afrrr�_ipaddr_infopsL





rA)r=r>r?�flagsc
CsZ|dd�\}}t|||||�}|dk	r@|j�}	|	j|g�|	S|j||||||d�SdS)N�)r=r>r?rB)rA�
create_future�
set_result�getaddrinfo)
�addressr=r>r?rB�loopr;r<�info�futrrr�_ensure_resolved�srK�TCP_NODELAYcCs>|jtjtjhkr:t|j�r:|jtjkr:|jtjtj	d�dS)Nr)
r=r r7rr+r>r?r2r"rL)r%rrr�_set_nodelay�s
rMcCsdS)Nr)r%rrrrM�scCs.|j}t|t�r t|t�r dS|jj�dS)N)Z
_exceptionr�
BaseException�	Exception�_loop�stop)rJ�excrrr�_run_until_complete_cb�s

rSc@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
dS)�ServercCs||_||_d|_g|_dS)Nr)rP�sockets�
_active_count�_waiters)�selfrHrUrrr�__init__�szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>)�	__class__�__name__rU)rXrrr�__repr__�szServer.__repr__cCs|jd7_dS)Nr)rV)rXrrr�_attach�szServer._attachcCs.|jd8_|jdkr*|jdkr*|j�dS)Nrr)rVrU�_wakeup)rXrrr�_detach�szServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|�qW|jdkrD|j�dS)Nr)rUrPZ
_stop_servingrVr^)rXrUr%rrr�close�s

zServer.closecCs0|j}d|_x|D]}|j�s|j|�qWdS)N)rW�donerE)rX�waiters�waiterrrrr^�s

zServer._wakeupccs<|jdks|jdkrdS|jj�}|jj|�|EdHdS)N)rUrWrPrDr9)rXrcrrr�wait_closed�s

zServer.wait_closedN)r[�
__module__�__qualname__rYr\r]r_r`r^rrdrrrrrT�s
rTc
@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd�d
d
d�dd�Z	d�dd
d
d
d�dd�Z
d�dd�Zd�dd�Zd�dd�Z
ed�dd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zed'd(��Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zej�r�d3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdMdMdMdN�dOdP�Z*d�dQdR�Z+ed�d
dMdMdMd
d
d
dS�dTdU��Z,ed�dVdW��Z-ed�dMdMdMd
d
d
d
dX�dYdZ��Z.ed[d\��Z/ed�e0j1e0j2d
d]d
d
d
d^�d_d`��Z3ed
da�dbdc��Z4eddde��Z5edfdg��Z6dhdi�Z7ee8j9e8j9e8j9ddjdMdk�dldm��Z:ee8j9e8j9e8j9dddMdk�dndo��Z;dpdq�Z<drds�Z=dtdu�Z>dvdw�Z?dxdy�Z@dzd{�ZAd|d}�ZBd~d�ZCd�d��ZDd�d��ZEd�d��ZFd
S)�r
cCs�d|_d|_d|_tj�|_g|_d|_d|_d|_	t
jd�j|_
d|_|jtjjodttjjd���d|_d|_d|_d|_ttd�r�tj�|_nd|_d|_dS)NrF�	monotonicZPYTHONASYNCIODEBUGg�������?�get_asyncgen_hooks) �_timer_cancelled_count�_closed�	_stopping�collections�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�timeZget_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debug�sysrB�ignore_environment�bool�os�environ�get�slow_callback_duration�_current_handle�
_task_factory�_coroutine_wrapper_setr�weakref�WeakSet�
_asyncgens�_asyncgens_shutdown_called)rXrrrrY�s(

zBaseEventLoop.__init__cCs d|jj|j�|j�|j�fS)Nz"<%s running=%s closed=%s debug=%s>)rZr[�
is_running�	is_closed�	get_debug)rXrrrr\ szBaseEventLoop.__repr__cCstj|d�S)z,Create a Future object attached to the loop.)rH)rZFuture)rXrrrrD%szBaseEventLoop.create_futurecCs@|j�|jdkr0tj||d�}|jr<|jd=n|j||�}|S)zDSchedule a coroutine object.

        Return a task object.
        N)rHr���)�
_check_closedr~rr�_source_traceback)rX�coroZtaskrrr�create_task)s

zBaseEventLoop.create_taskcCs$|dk	rt|�rtd��||_dS)awSet a task factory that will be used by loop.create_task().

        If factory is None the default task factory will be set.

        If factory is a callable, it should have a signature matching
        '(loop, coro)', where 'loop' will be a reference to the active
        event loop, 'coro' will be a coroutine object.  The callable
        must return a Future.
        Nz'task factory must be a callable or None)�callabler5r~)rX�factoryrrr�set_task_factory7s
zBaseEventLoop.set_task_factorycCs|jS)z<Return a task factory, or None if the default one is in use.)r~)rXrrr�get_task_factoryEszBaseEventLoop.get_task_factoryN)�extra�servercCst�dS)zCreate socket transport.N)�NotImplementedError)rXr%�protocolrcr�r�rrr�_make_socket_transportIsz$BaseEventLoop._make_socket_transportF)�server_side�server_hostnamer�r�c	Cst�dS)zCreate SSL transport.N)r�)	rXZrawsockr��
sslcontextrcr�r�r�r�rrr�_make_ssl_transportNsz!BaseEventLoop._make_ssl_transportcCst�dS)zCreate datagram transport.N)r�)rXr%r�rGrcr�rrr�_make_datagram_transportTsz&BaseEventLoop._make_datagram_transportcCst�dS)zCreate read pipe transport.N)r�)rX�piper�rcr�rrr�_make_read_pipe_transportYsz'BaseEventLoop._make_read_pipe_transportcCst�dS)zCreate write pipe transport.N)r�)rXr�r�rcr�rrr�_make_write_pipe_transport^sz(BaseEventLoop._make_write_pipe_transportc	
Kst�dS)zCreate subprocess transport.N)r�)
rXr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transportcsz(BaseEventLoop._make_subprocess_transportcCst�dS)z�Write a byte to self-pipe, to wake up the event loop.

        This may be called from a different thread.

        The subclass is responsible for implementing the self-pipe.
        N)r�)rXrrr�_write_to_selfjszBaseEventLoop._write_to_selfcCst�dS)zProcess selector events.N)r�)rX�
event_listrrr�_process_eventssszBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)rj�RuntimeError)rXrrrr�wszBaseEventLoop._check_closedcCs*|jj|�|j�s&|j|j|j��dS)N)r��discardr��call_soon_threadsafer��aclose)rX�agenrrr�_asyncgen_finalizer_hook{sz&BaseEventLoop._asyncgen_finalizer_hookcCs,|jrtjdj|�t|d�|jj|�dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call)�source)r��warnings�warn�format�ResourceWarningr��add)rXr�rrr�_asyncgen_firstiter_hook�s
z&BaseEventLoop._asyncgen_firstiter_hookccs�d|_|jdkst|j�r dSt|j�}|jj�tjdd�|D�d|d��}|EdH}x8t||�D]*\}}t|t	�rf|j
dj|�||d��qfWdS)z,Shutdown all active asynchronous generators.TNcSsg|]}|j��qSr)r�)�.0Zagrrr�
<listcomp>�sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})�message�	exceptionZasyncgen)r�r��len�list�clearr�gather�ziprrO�call_exception_handlerr�)rXZ
closing_agensZ
shutdown_coroZresults�resultr�rrr�shutdown_asyncgens�s"




z BaseEventLoop.shutdown_asyncgenscCs�|j�|j�rtd��tj�dk	r,td��|j|j�tj�|_	|j
dk	rftj�}tj
|j|jd�z$tj|�x|j�|jrtPqtWWdd|_d|_	tjd�|jd�|j
dk	r�tj
|�XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is running)�	firstiter�	finalizerF)r�r�r�rZ_get_running_loop�_set_coroutine_wrapper�_debug�	threading�	get_identrqr�rvrh�set_asyncgen_hooksr�r�Z_set_running_loop�	_run_oncerk)rXZold_agen_hooksrrr�run_forever�s0







zBaseEventLoop.run_forevercCs�|j�tj|�}tj||d�}|r,d|_|jt�z>y|j�Wn,|rj|j	�rj|j
�rj|j��YnXWd|jt�X|j	�s�t
d��|j�S)a\Run until the Future is done.

        If the argument is a coroutine, it is wrapped in a Task.

        WARNING: It would be disastrous to call run_until_complete()
        with the same coroutine twice -- it would wrap it in two
        different Tasks and that can't be good.

        Return the Future's result, or raise its exception.
        )rHFNz+Event loop stopped before Future completed.)r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrSr�raZ	cancelledr�Zremove_done_callbackr�r�)rXZfutureZnew_taskrrr�run_until_complete�s 
z BaseEventLoop.run_until_completecCs
d|_dS)z�Stop running the event loop.

        Every callback already scheduled will still run.  This simply informs
        run_forever to stop looping after a complete iteration.
        TN)rk)rXrrrrQ�szBaseEventLoop.stopcCsj|j�rtd��|jrdS|jr,tjd|�d|_|jj�|jj�|j	}|dk	rfd|_	|j
dd�dS)z�Close the event loop.

        This clears the queues and shuts down the executor,
        but does not wait for the executor to finish.

        The event loop must not be running.
        z!Cannot close a running event loopNzClose %rTF)�wait)r�r�rjr�r	�debugrnr�rorpZshutdown)rX�executorrrrr`�s

zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rj)rXrrrr�szBaseEventLoop.is_closedcCs0|j�s,tjd|t|d�|j�s,|j�dS)Nzunclosed event loop %r)r�)r�r�r�r�r�r`)rXrrr�__del__s
zBaseEventLoop.__del__cCs
|jdk	S)z*Returns True if the event loop is running.N)rq)rXrrrr�szBaseEventLoop.is_runningcCstj�S)z�Return the time according to the event loop's clock.

        This is a float expressed in seconds since an epoch, but the
        epoch, precision, accuracy and drift are unspecified and may
        differ per event loop.
        )rrrg)rXrrrrrszBaseEventLoop.timecGs,|j|j�||f|��}|jr(|jd=|S)a8Arrange for a callback to be called at a given time.

        Return a Handle: an opaque object with a cancel() method that
        can be used to cancel the call.

        The delay can be an int or float, expressed in seconds.  It is
        always relative to the current time.

        Each callback will be called exactly once.  If two callbacks
        are scheduled for exactly the same time, it undefined which
        will be called first.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        rr�)�call_atrrr�)rXZdelay�callbackr��timerrrr�
call_later szBaseEventLoop.call_latercGsX|j�|jr"|j�|j|d�tj||||�}|jr@|jd=tj|j	|�d|_	|S)z|Like call_later(), but uses an absolute time.

        Absolute time corresponds to the event loop's time() method.
        r�rTr�)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushro)rX�whenr�r�r�rrrr�5szBaseEventLoop.call_atcGs@|j�|jr"|j�|j|d�|j||�}|jr<|jd=|S)aTArrange for a callback to be called as soon as possible.

        This operates as a FIFO queue: callbacks are called in the
        order in which they are registered.  Each callback will be
        called exactly once.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        �	call_soonrr�)r�r�r�r��
_call_soonr�)rXr�r�rrrrr�Es
zBaseEventLoop.call_sooncCs>tj|�stj|�r"tdj|���t|�s:tdj||���dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZiscoroutineZiscoroutinefunctionr5r�r�)rXr��methodrrrr�Xs

zBaseEventLoop._check_callbackcCs,tj|||�}|jr|jd=|jj|�|S)Nrr�)rZHandler�rnr9)rXr�r�rrrrr�cs
zBaseEventLoop._call_sooncCs,|jdkrdStj�}||jkr(td��dS)aoCheck that the current thread is the thread running the event loop.

        Non-thread-safe methods of this class make this assumption and will
        likely behave incorrectly when the assumption is violated.

        Should only be called when (self._debug == True).  The caller is
        responsible for checking this condition for performance reasons.
        NzMNon-thread-safe operation invoked on an event loop other than the current one)rqr�r�r�)rXZ	thread_idrrrr�js	

zBaseEventLoop._check_threadcGs@|j�|jr|j|d�|j||�}|jr4|jd=|j�|S)z"Like call_soon(), but thread-safe.r�rr�)r�r�r�r�r�r�)rXr�r�rrrrr�{sz"BaseEventLoop.call_soon_threadsafecGsZ|j�|jr|j|d�|dkr@|j}|dkr@tjj�}||_tj|j|f|��|d�S)N�run_in_executor)rH)	r�r�r�rp�
concurrentrZThreadPoolExecutorZwrap_futureZsubmit)rXr��funcr�rrrr��s
zBaseEventLoop.run_in_executorcCs
||_dS)N)rp)rXr�rrr�set_default_executor�sz"BaseEventLoop.set_default_executorcCs�d||fg}|r |jd|�|r2|jd|�|rD|jd|�|rV|jd|�dj|�}tjd|�|j�}tj||||||�}	|j�|}
d||
d	|	f}|
|jkr�tj|�n
tj|�|	S)
Nz%s:%rz	family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@�@)	r9�joinr	r�rrr rFr|rI)rXr;r<r=r>r?rB�msg�t0Zaddrinfo�dtrrr�_getaddrinfo_debug�s(


z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc	Cs>|jr |jd|j||||||�S|jdtj||||||�SdS)N)r�r�r�r rF)rXr;r<r=r>r?rBrrrrF�s


zBaseEventLoop.getaddrinfocCs|jdtj||�S)N)r�r �getnameinfo)rXZsockaddrrBrrrr��szBaseEventLoop.getnameinfo)�sslr=r?rBr%�
local_addrr�c#s|
dk	r|rtd��|
dkr2|r2|s.td��|}
|dk	sD|dk	�r�|dk	rTtd��t||f|tj|||d�}|g}|	dk	r�t|	|tj|||d�}
|j|
�nd}
tj||d�EdH|j�}|s�td��|
dk	r�|
j�}|s�td��g}�x�|D�]B\}}}}}y�tj|||d�}|j	d	�|
dk	�r�x�|D]j\}}}}}y|j
|�PWnHtk
�r�}z*t|jd
j||j
j���}|j|�WYdd}~XnX�q.W|j�d}w�|j�r�tjd||�|j||�EdHWn^tk
�r}z"|dk	�r�|j�|j|�WYdd}~Xq�|dk	�r,|j��Yq�XPq�Wt|�dk�rR|d
�nJt|d
��t�fdd�|D���r~|d
�tdjdjdd�|D�����n,|dk�r�td��t|j��s�tdj|���|j||||
�EdH\}}|j�r
|jd�}tjd|||||�||fS)a�Connect to a TCP server.

        Create a streaming transport connection to a given Internet host and
        port: socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_STREAM. protocol_factory must be
        a callable returning a protocol instance.

        This method is a coroutine which will try to establish the connection
        in the background.  When successful, the coroutine returns a
        (transport, protocol) pair.
        Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|��kVqdS)N)r)r�rR)�modelrr�	<genexpr>sz2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, css|]}t|�VqdS)N)r)r�rRrrrr�#sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rr�r�r$�setblocking�bind�errnor��strerror�lowerr`r�r	r��sock_connectr�r�allr�r+r>�_create_connection_transport�get_extra_info)rX�protocol_factoryr;r<r�r=r?rBr%r�r��f1�fs�f2�infosZladdr_infos�
exceptionsr>ZcnamerG�_ZladdrrR�	transportr�r)r�r�create_connection�s�





"




zBaseEventLoop.create_connectionc
	cs�|jd�|�}|j�}|rFt|t�r*dn|}|j||||||d�}	n|j|||�}	y|EdHWn|	j��YnX|	|fS)NF)r�r�)r�rDrrxr�r�r`)
rXr%r�r�r�r�r�rcr�r�rrrr�=s
z*BaseEventLoop._create_connection_transport)r=r?rB�
reuse_address�
reuse_port�allow_broadcastr%c#s8|
dk	r�t|
j�s tdj|
����s@�s@|s@|s@|s@|s@|s@|	r~t��||||||	d�}djdd�|j�D��}tdj|���|
jd�d}
�n*�p��s�|d	kr�td
��||fdff}n�tj	�}x�d	�fd�ffD]~\}}|dk	r�t
||tj|||d�EdH}|�st
d
��xB|D]:\}}}}}||f}||k�r>ddg||<||||<�qWq�W��fdd�|j�D�}|�sztd��g}|dk�r�tjdk�o�tjdk}�x|D�]\\}}\}}d}
d}
y�tj|tj|d�}
|�r�|
jtjtjd�|�r�t|
�|	�r|
jtjtjd�|
jd���r,|
j|���rH|j|
|�EdH|}
Wn^t
k
�r�}z"|
dk	�rp|
j�|j|�WYdd}~Xn"|
dk	�r�|
j��YnXP�q�W|d	�|�}|j�}|j|
||
|�}|j�r
��r�tjd��||�ntj d�||�y|EdHWn|j��YnX||fS)zCreate datagram connection.Nz#A UDP Socket was expected, got {!r})r��remote_addrr=r?rBr�r�r�z, css"|]\}}|rdj||�VqdS)z{}={}N)r�)r��k�vrrrr�isz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyr)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}�r|ddkp*�o*|ddks||f�qS)rNrr)r��keyZ	addr_pair)r�r�rrr��sz:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address information�posix�cygwin)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)!r-r>r!r��dictr��itemsr�rl�OrderedDictrKr r,r$ry�namerv�platformr"r#�SO_REUSEADDRr&ZSO_BROADCASTr�r�r`r9rDr�r�r	rIr�)rXr�r�r�r=r?rBr�r�r�r%ZoptsZproblemsZr_addrZaddr_pairs_infoZ
addr_infos�idxZaddrr�Zfamr�ZprorGrr�Z
local_addressZremote_addressrRr�rcr�r)r�r�r�create_datagram_endpointUs�








z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||d�EdH}|s0tdj|���|S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r�)rXr;r<r=rBr�rrr�_create_server_getaddrinfo�s
z(BaseEventLoop._create_server_getaddrinfor)r=rBr%�backlogr�r�r�c #s�t|t�rtd��|dk	s$�dk	�r|dk	r4td��|	dkrPtjdkoNtjdk}	g}|dkrddg}n$t|t�s|t|t	j
�r�|g}n|}����fdd�|D�}
tj|
d	�i�EdH}t
tjj|��}d
}�z �x|D�]
}|\}}}}}ytj|||�}Wn6tjk
�r2�j�r,tjd|||dd
�w�YnX|j|�|	�rV|jtjtjd�|
�rdt|�t�r�|tjk�r�ttd��r�|jtjtjd�y|j |�Wq�t!k
�r�}z t!|j"d||j#j$�f��WYdd}~Xq�Xq�Wd}Wd|�sx|D]}|j%��q�WXn2|dk�r"td��t&|j'��s<tdj(|���|g}t)�|�}x4|D],}|j*|�|j+d
��j,|||||��qRW�j�r�tj-d|�|S)a1Create a TCP server.

        The host parameter can be a string, in that case the TCP server is bound
        to host and port.

        The host parameter can also be a sequence of strings and in that case
        the TCP server is bound to all hosts of the sequence. If a host
        appears multiple times (possibly indirectly e.g. when hostnames
        resolve to the same IP address), the server is only bound once to that
        host.

        Return a Server object which can be used to stop the service.

        This method is a coroutine.
        z*ssl argument must be an SSLContext or NoneNz8host/port and sock can not be specified at the same timerrr0csg|]}�j|���d��qS))r=rB)r)r�r;)r=rBr<rXrrr�sz/BaseEventLoop.create_server.<locals>.<listcomp>rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)�exc_info�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z
%r is serving).rrxr5r!ryrrvrrrl�Iterablerr��set�	itertools�chain�
from_iterabler �errorr�r	�warningr9r"r#r	r&r8rrrZIPV6_V6ONLYr�r$r�r�r�r`r+r>r�rTZlistenr�Z_start_servingrI)rXr�r;r<r=rBr%r
r�r�r�rUZhostsr�r�Z	completed�resr@Zsocktyper?Z	canonnameZsa�errr�r)r=rBr<rXr�
create_server�s�


(





zBaseEventLoop.create_server)r�ccs^t|j�stdj|���|j|||ddd�EdH\}}|jrV|jd�}tjd|||�||fS)aHandle an accepted connection.

        This is used by servers that accept connections outside of
        asyncio but that use asyncio to handle connections.

        This method is a coroutine.  When completed, the coroutine
        returns a (transport, protocol) pair.
        z&A Stream Socket was expected, got {!r}r0T)r�Nr z%r handled: (%r, %r))	r+r>r!r�r�r�r�r	r�)rXr�r%r�r�r�rrr�connect_accepted_socketAs


z%BaseEventLoop.connect_accepted_socketccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz Read pipe %r connected: (%r, %r))rDr�r`r�r	r��fileno)rXr�r�r�rcr�rrr�connect_read_pipeXszBaseEventLoop.connect_read_pipeccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz!Write pipe %r connected: (%r, %r))rDr�r`r�r	r�r)rXr�r�r�rcr�rrr�connect_write_pipeisz BaseEventLoop.connect_write_pipecCs�|g}|dk	r |jdt|��|dk	rF|tjkrF|jdt|��n4|dk	r`|jdt|��|dk	rz|jdt|��tjdj|��dS)Nzstdin=%szstdout=stderr=%sz	stdout=%sz	stderr=%s� )r9rrrr	r�r�)rXr�r�r�r�rIrrr�_log_subprocesszszBaseEventLoop._log_subprocessT)r�r�r��universal_newlinesr�r�c
ks�t|ttf�std��|r"td��|s.td��|dkr>td��|�}
d}|jrfd|}|j||||�|j|
|d||||f|	�EdH}|jr�|dk	r�tjd||�||
fS)	Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r)	rr3rr!r�rr�r	rI)
rXr��cmdr�r�r�r r�r�r�r��	debug_logr�rrr�subprocess_shell�s$zBaseEventLoop.subprocess_shellcos�|rtd��|rtd��|dkr(td��|f|	}x,|D]$}t|ttf�s8tdt|�j��q8W|�}
d}|jr�d|}|j||||�|j	|
|d||||f|
�EdH}|jr�|dk	r�t
jd||�||
fS)	Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r)r!rrr3r5r>r[r�rr�r	rI)rXr�Zprogramr�r�r�r r�r�r�r�Z
popen_args�argr�r"r�rrr�subprocess_exec�s,

zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use.
        )rt)rXrrr�get_exception_handler�sz#BaseEventLoop.get_exception_handlercCs*|dk	r t|�r tdj|���||_dS)a�Set handler as the new event loop exception handler.

        If handler is None, the default exception handler will
        be set.

        If handler is a callable object, it should have a
        signature matching '(loop, context)', where 'loop'
        will be a reference to the active event loop, 'context'
        will be a dict object (see `call_exception_handler()`
        documentation for details about context).
        Nz/A callable object or None is expected, got {!r})r�r5r�rt)rXZhandlerrrr�set_exception_handler�sz#BaseEventLoop.set_exception_handlerc	Cs|jd�}|sd}|jd�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}x�t|�D]�}|dkr~qp||}|dkr�djtj|��}d	}||j	�7}n2|dkr�djtj|��}d
}||j	�7}nt
|�}|jdj||��qpWt
jdj|�|d
�dS)aEDefault exception handler.

        This is called when an exception occurs and no exception
        handler is set, and can be called by a custom exception
        handler that wants to defer to the default behavior.

        This default handler logs the error message and other
        context-dependent information.  In debug mode, a truncated
        stack trace is also appended showing where the given object
        (e.g. a handle or future or task) was created, if any.

        The context parameter has the same meaning as in
        `call_exception_handler()`.
        r�z!Unhandled exception in event loopr�NFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last):
z+Handle created at (most recent call last):
z{}: {}�
)r>r�r�)r{r>�
__traceback__r}r��sortedr��	traceback�format_list�rstriprr9r�r	r)	rX�contextr�r�rZ	log_linesr�value�tbrrr�default_exception_handler�s6


z'BaseEventLoop.default_exception_handlercCs�|jdkr>y|j|�Wq�tk
r:tjddd�Yq�Xnny|j||�Wn\tk
r�}z@y|jd||d��Wn"tk
r�tjddd�YnXWYdd}~XnXdS)aCall the current event loop's exception handler.

        The context argument is a dict containing the following keys:

        - 'message': Error message;
        - 'exception' (optional): Exception object;
        - 'future' (optional): Future instance;
        - 'handle' (optional): Handle instance;
        - 'protocol' (optional): Protocol instance;
        - 'transport' (optional): Transport instance;
        - 'socket' (optional): Socket instance;
        - 'asyncgen' (optional): Asynchronous generator that caused
                                 the exception.

        New keys maybe introduced in the future.

        Note: do not overload this method in an event loop subclass.
        For custom exception handling, use the
        `set_exception_handler()` method.
        Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)r�r�r.zeException in default exception handler while handling an unexpected error in custom exception handler)rtr1rOr	r)rXr.rRrrrr�s"
z$BaseEventLoop.call_exception_handlercCs|jr
dS|jj|�dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N)�
_cancelledrnr9)rXrrrr�
_add_callback9szBaseEventLoop._add_callbackcCs|j|�|j�dS)z6Like _add_callback() but called from a signal handler.N)r3r�)rXrrrr�_add_callback_signalsafeAs
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rori)rXrrrr�_timer_handle_cancelledFsz%BaseEventLoop._timer_handle_cancelledcCs�t|j�}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|�q,Wtj|�||_d|_n8x6|jr�|jdjr�|jd8_tj	|j�}d|_qfWd}|j
s�|jr�d}n*|jr�|jdj}t
td||j��t�}|jo�|dk�r�|j�}|jj|�}|j�|}|dk�rtj}	ntj}	t|�}
|dk�rLtj|	d|d|
�nD|
�rntj|	d|d|d|
�n"|dk�r�tj|	d	|d|d�n|jj|�}|j|�|j�|j}xD|j�r�|jd}|j|k�r�Ptj	|j�}d|_|j
j|��q�Wt|j
�}x�t|�D]|}
|j
j�}|j�r*�q|j�r�zD||_|j�}|j�|j�|}||jk�rttj d
t!|�|�Wdd|_Xn|j��qWd}dS)z�Run one full iteration of the event loop.

        This calls all currently ready callbacks, polls for I/O,
        schedules the resulting callbacks, and finally schedules
        'call_later' callbacks.
        FrrNg�?zpoll took %.3f ms: %s eventsg@�@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"r�ro�_MIN_SCHEDULED_TIMER_HANDLESri�%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr2r9r��heapify�heappoprnrkZ_when�min�maxrr�MAXIMUM_SELECT_TIMEOUTr�Z	_selectorZselect�logging�INFO�DEBUGr	�logr�rs�range�popleftr}Z_runr|rr)rXZsched_countZ
new_scheduledrZtimeoutr�r�r�r��levelZneventZend_timeZntodo�irrrr�Ks�











zBaseEventLoop._run_oncecCs�ytj}tj}Wntk
r$dSXt|�}|j|kr<dStj}|�}|rz|d|fkrjtj	d|t
�q�||�d|_n,|d|fkr�tj	d|t
�n|d�d|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF)rv�set_coroutine_wrapper�get_coroutine_wrapper�AttributeErrorrxrrZ
debug_wrapperr�r��RuntimeWarning)rX�enabledZset_wrapperZget_wrapper�wrapperZcurrent_wrapperrrrr��s.

z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r�)rXrrrr��szBaseEventLoop.get_debugcCs||_|j�r|j|�dS)N)r�r�r�)rXrIrrrru�szBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)NN)F)NN)NN)Gr[rerfrYr\rDr�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�rQr`r�rZPY34r�r�rrr�r�r�r�r�r�r�r�r�r�rFr�r�r�rrr r6Z
AI_PASSIVErrrrrrrr#r%r&r'r1r�r3r4r5r�r�r�rurrrrr
�s�!


		%	

u	`
12c!i�Q)2�__doc__rlZconcurrent.futuresr�r��inspectrr=ryr rr�rrr+rvr�r�r0rrrrrrr@r	�__all__r6r7�BrokenPipeError�ConnectionResetError�ConnectionAbortedErrorZ_FATAL_ERROR_IGNORErr8r<rrr&r+r-rAr)rKrMrSZAbstractServerrTZAbstractEventLoopr
rrrr�<module>sV
		;


/PK=�\�a��Z<Z<locks.cpython-36.opt-1.pycnu�[���3


 \�<�@s�dZdddddgZddlZdd	lmZdd
lmZddlmZddlmZGd
d�d�Z	Gdd�d�Z
Gdd�de
�ZGdd�d�ZGdd�de
�Z
Gdd�de
�ZGdd�de�ZdS)zSynchronization primitives.�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�compat)�events)�futures)�	coroutinec@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ContextManageraContext manager.

    This enables the following idiom for acquiring and releasing a
    lock around a block:

        with (yield from lock):
            <block>

    while failing loudly when accidentally using:

        with lock:
            <block>
    cCs
||_dS)N)�_lock)�self�lock�r�%/usr/lib64/python3.6/asyncio/locks.py�__init__sz_ContextManager.__init__cCsdS)Nr)rrrr�	__enter__sz_ContextManager.__enter__cGsz|jj�Wdd|_XdS)N)r
�release)r�argsrrr�__exit__$sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__�__doc__rrrrrrrr
s
rc@sNeZdZdd�Zdd�Zedd��ZejrJdd�Z	ed	d
��Z
edd��Zd
S)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|j�EdHt|�S)N)�acquirer)rrrr�__iter__5sz_ContextManagerMixin.__iter__ccs|j�EdHt|�S)N)rr)rrrr�	__await__Hsz_ContextManagerMixin.__await__ccs|j�EdHdS)N)r)rrrr�
__aenter__Msz_ContextManagerMixin.__aenter__cCs|j�dS)N)r)r�exc_type�exc�tbrrr�	__aexit__Tsz_ContextManagerMixin.__aexit__N)rrrrrrrrZPY35rr r$rrrrr+srcsReZdZdZdd�dd�Z�fdd�Zdd	�Zed
d��Zdd
�Z	dd�Z
�ZS)ra�Primitive lock objects.

    A primitive lock is a synchronization primitive that is not owned
    by a particular coroutine when locked.  A primitive lock is in one
    of two states, 'locked' or 'unlocked'.

    It is created in the unlocked state.  It has two basic methods,
    acquire() and release().  When the state is unlocked, acquire()
    changes the state to locked and returns immediately.  When the
    state is locked, acquire() blocks until a call to release() in
    another coroutine changes it to unlocked, then the acquire() call
    resets it to locked and returns.  The release() method should only
    be called in the locked state; it changes the state to unlocked
    and returns immediately.  If an attempt is made to release an
    unlocked lock, a RuntimeError will be raised.

    When more than one coroutine is blocked in acquire() waiting for
    the state to turn to unlocked, only one coroutine proceeds when a
    release() call resets the state to unlocked; first coroutine which
    is blocked in acquire() is being processed.

    acquire() is a coroutine and should be called with 'yield from'.

    Locks also support the context management protocol.  '(yield from lock)'
    should be used as the context manager expression.

    Usage:

        lock = Lock()
        ...
        yield from lock
        try:
            ...
        finally:
            lock.release()

    Context manager usage:

        lock = Lock()
        ...
        with (yield from lock):
             ...

    Lock objects can be tested for locking state:

        if not lock.locked():
           yield from lock
        else:
           # lock is acquired
           ...

    N)�loopcCs.tj�|_d|_|dk	r ||_n
tj�|_dS)NF)�collections�deque�_waiters�_locked�_loopr	�get_event_loop)rr%rrrr�s

z
Lock.__init__csDt�j�}|jrdnd}|jr0dj|t|j��}dj|dd�|�S)N�locked�unlockedz
{},waiters:{}z	<{} [{}]>r���)�super�__repr__r)r(�format�len)r�res�extra)�	__class__rrr0�s

z
Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,�szLock.lockedccs�|jr&tdd�|jD��r&d|_dS|jj�}|jj|�y"z|EdHWd|jj|�XWn&tjk
r�|js~|j	��YnXd|_dS)z�Acquire a lock.

        This method blocks until the lock is unlocked, then sets it to
        locked and returns True.
        css|]}|j�VqdS)N)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>TN)
r)�allr(r*�
create_future�append�remover
�CancelledError�_wake_up_first)r�futrrrr�s
zLock.acquirecCs"|jrd|_|j�ntd��dS)aGRelease a lock.

        When the lock is locked, reset it to unlocked, and return.
        If any other coroutines are blocked waiting for the lock to become
        unlocked, allow exactly one of them to proceed.

        When invoked on an unlocked lock, a RuntimeError is raised.

        There is no return value.
        FzLock is not acquired.N)r)r?r)rrrrr�s
zLock.releasecCs>ytt|j��}Wntk
r&dSX|j�s:|jd�dS)z*Wake up the first waiter if it isn't done.NT)�next�iterr(�
StopIteration�done�
set_result)rr@rrrr?�szLock._wake_up_first)rrrrrr0r,rrrr?�
__classcell__rr)r5rrYs4csReZdZdZdd�dd�Z�fdd�Zdd	�Zd
d�Zdd
�Ze	dd��Z
�ZS)ra#Asynchronous equivalent to threading.Event.

    Class implementing event objects. An event manages a flag that can be set
    to true with the set() method and reset to false with the clear() method.
    The wait() method blocks until the flag is true. The flag is initially
    false.
    N)r%cCs.tj�|_d|_|dk	r ||_n
tj�|_dS)NF)r&r'r(�_valuer*r	r+)rr%rrrr�s

zEvent.__init__csDt�j�}|jrdnd}|jr0dj|t|j��}dj|dd�|�S)N�setZunsetz
{},waiters:{}z	<{} [{}]>rr.)r/r0rGr(r1r2)rr3r4)r5rrr0�s

zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rG)rrrr�is_set�szEvent.is_setcCs2|js.d|_x |jD]}|j�s|jd�qWdS)z�Set the internal flag to true. All coroutines waiting for it to
        become true are awakened. Coroutine that call wait() once the flag is
        true will not block at all.
        TN)rGr(rDrE)rr@rrrrH�s
z	Event.setcCs
d|_dS)z�Reset the internal flag to false. Subsequently, coroutines calling
        wait() will block until set() is called to set the internal flag
        to true again.FN)rG)rrrr�clearszEvent.clearccsB|jr
dS|jj�}|jj|�z|EdHdS|jj|�XdS)z�Block until the internal flag is true.

        If the internal flag is true on entry, return True
        immediately.  Otherwise, block until another coroutine calls
        set() to set the flag to true, then return True.
        TN)rGr*r;r(r<r=)rr@rrr�wait
s

z
Event.wait)rrrrrr0rIrHrJrrKrFrr)r5rr�scsZeZdZdZddd�dd�Z�fdd�Zedd	��Zed
d��Zdd
d�Z	dd�Z
�ZS)raAsynchronous equivalent to threading.Condition.

    This class implements condition variable objects. A condition variable
    allows one or more coroutines to wait until they are notified by another
    coroutine.

    A new Lock object is created and used as the underlying lock.
    N)r%cCsp|dk	r||_n
tj�|_|dkr0t|jd�}n|j|jk	rDtd��||_|j|_|j|_|j|_t	j
�|_dS)N)r%z"loop argument must agree with lock)r*r	r+r�
ValueErrorr
r,rrr&r'r()rrr%rrrr+s
zCondition.__init__csFt�j�}|j�rdnd}|jr2dj|t|j��}dj|dd�|�S)Nr,r-z
{},waiters:{}z	<{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr0>s

zCondition.__repr__ccs�|j�std��|j�z8|jj�}|jj|�z|EdHdS|jj|�XWdd}x4y|j�EdHPWqXt	j
k
r�d}YqXXqXW|r�t	j
�XdS)a�Wait until notified.

        If the calling coroutine has not acquired the lock when this
        method is called, a RuntimeError is raised.

        This method releases the underlying lock, and then blocks
        until it is awakened by a notify() or notify_all() call for
        the same condition variable in another coroutine.  Once
        awakened, it re-acquires the lock and returns True.
        zcannot wait on un-acquired lockNTF)r,rrr*r;r(r<r=rr
r>)rr@r6rrrrKEs&

zCondition.waitccs(|�}x|s"|j�EdH|�}qW|S)z�Wait until a predicate becomes true.

        The predicate should be a callable which result will be
        interpreted as a boolean value.  The final predicate value is
        the return value.
        N)rK)rZ	predicate�resultrrr�wait_forks

zCondition.wait_forrcCsL|j�std��d}x2|jD](}||kr*P|j�s|d7}|jd�qWdS)aBy default, wake up one coroutine waiting on this condition, if any.
        If the calling coroutine has not acquired the lock when this method
        is called, a RuntimeError is raised.

        This method wakes up at most n of the coroutines waiting for the
        condition variable; it is a no-op if no coroutines are waiting.

        Note: an awakened coroutine does not actually return from its
        wait() call until it can reacquire the lock. Since notify() does
        not release the lock, its caller should.
        z!cannot notify on un-acquired lockrrFN)r,rr(rDrE)r�n�idxr@rrr�notifyyszCondition.notifycCs|jt|j��dS)aWake up all threads waiting on this condition. This method acts
        like notify(), but wakes up all waiting threads instead of one. If the
        calling thread has not acquired the lock when this method is called,
        a RuntimeError is raised.
        N)rQr2r()rrrr�
notify_all�szCondition.notify_all)N)r)rrrrrr0rrKrNrQrRrFrr)r5rr!s&
csTeZdZdZddd�dd�Z�fdd�Zd	d
�Zdd�Zed
d��Z	dd�Z
�ZS)raA Semaphore implementation.

    A semaphore manages an internal counter which is decremented by each
    acquire() call and incremented by each release() call. The counter
    can never go below zero; when acquire() finds that it is zero, it blocks,
    waiting until some other thread calls release().

    Semaphores also support the context management protocol.

    The optional argument gives the initial value for the internal
    counter; it defaults to 1. If the value given is less than 0,
    ValueError is raised.
    rN)r%cCs>|dkrtd��||_tj�|_|dk	r0||_n
tj�|_dS)Nrz$Semaphore initial value must be >= 0)rLrGr&r'r(r*r	r+)r�valuer%rrrr�s
zSemaphore.__init__csNt�j�}|j�rdn
dj|j�}|jr:dj|t|j��}dj|dd�|�S)Nr,zunlocked,value:{}z
{},waiters:{}z	<{} [{}]>rr.)r/r0r,r1rGr(r2)rr3r4)r5rrr0�s
zSemaphore.__repr__cCs0x*|jr*|jj�}|j�s|jd�dSqWdS)N)r(�popleftrDrE)rZwaiterrrr�
_wake_up_next�s


zSemaphore._wake_up_nextcCs
|jdkS)z:Returns True if semaphore can not be acquired immediately.r)rG)rrrrr,�szSemaphore.lockedc	cszxf|jdkrf|jj�}|jj|�y|EdHWq|j�|jdkr\|j�r\|j��YqXqW|jd8_dS)a5Acquire a semaphore.

        If the internal counter is larger than zero on entry,
        decrement it by one and return True immediately.  If it is
        zero on entry, block, waiting until some other coroutine has
        called release() to make it larger than 0, and then return
        True.
        rNrT)rGr*r;r(r<Zcancelr6rU)rr@rrrr�s

zSemaphore.acquirecCs|jd7_|j�dS)z�Release a semaphore, incrementing the internal counter by one.
        When it was zero on entry and another coroutine is waiting for it to
        become larger than zero again, wake up that coroutine.
        rN)rGrU)rrrrr�szSemaphore.release)r)rrrrrr0rUr,rrrrFrr)r5rr�s

cs4eZdZdZd	dd��fdd�Z�fdd�Z�ZS)
rz�A bounded semaphore implementation.

    This raises ValueError in release() if it would increase the value
    above the initial value.
    rN)r%cs||_t�j||d�dS)N)r%)�_bound_valuer/r)rrSr%)r5rrr�szBoundedSemaphore.__init__cs"|j|jkrtd��t�j�dS)Nz(BoundedSemaphore released too many times)rGrVrLr/r)r)r5rrr�szBoundedSemaphore.release)r)rrrrrrrFrr)r5rr�s)r�__all__r&�rr	r
Z
coroutinesrrrrrrrrrrrr�<module>s.ByMPK=�\D��o?o?$proactor_events.cpython-36.opt-2.pycnu�[���3


 \�O�@s�dgZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
l
mZGdd�de	je	j
�ZGd
d�dee	j�ZGdd�dee	j�ZGdd�de�ZGdd�deee	j�ZGdd�deee	j�ZGdd�dej�ZdS)�BaseProactorEventLoop�N�)�base_events)�compat)�	constants)�futures)�sslproto)�
transports)�loggercs~eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jrTdd�Zddd�Z
dd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportNcs�t�j||�|j|�||_||_||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	rh|jj
�|jj|jj|�|dk	r�|jjtj|d�dS)NrF)�super�__init__�
_set_extra�_sock�	_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_eof_writtenZ_attach�_loop�	call_soonZconnection_maderZ_set_result_unless_cancelled)�self�loop�sock�protocol�waiter�extra�server)�	__class__��//usr/lib64/python3.6/asyncio/proactor_events.pyr
s$



z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jdk	rN|jd|jj��|jdk	rh|jd|j�|jdk	r�|jd|j�|jr�t	|j�}|jd|�|j
r�|jd�dd	j|�S)
N�closed�closingzfd=%szread=%szwrite=%rzwrite_bufsize=%szEOF writtenz<%s>� )r"�__name__r�appendr�filenorrr�lenr�join)r�info�bufsizer#r#r$�__repr__/s"







z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)�_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs
||_dS)N)r)rrr#r#r$�set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$�get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$�
is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr
dSd|_|jd7_|jr@|jdkr@|jj|jd�|jdk	rZ|jj�d|_dS)NTr)	rrrrrr�_call_connection_lostr�cancel)rr#r#r$�closeNs

z _ProactorBasePipeTransport.closecCs*|jdk	r&tjd|t|d�|j�dS)Nzunclosed transport %r)�source)r�warnings�warn�ResourceWarningr7)rr#r#r$�__del__]s
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)�exc_info)�message�	exceptionZ	transportr)
�
isinstancerZ_FATAL_ERROR_IGNOREr�	get_debugr
�debug�call_exception_handlerr�_force_close)r�excr?r#r#r$�_fatal_errorcs
z'_ProactorBasePipeTransport._fatal_errorcCsj|jr
dSd|_|jd7_|jr4|jj�d|_|jrJ|jj�d|_d|_d|_|jj|j	|�dS)NTrr)
rrrr6rrrrrr5)rrFr#r#r$rEps

z'_ProactorBasePipeTransport._force_closecCs^z|jj|�Wdt|jd�r,|jjtj�|jj�d|_|j}|dk	rX|j	�d|_XdS)N�shutdown)
rZconnection_lost�hasattrrrH�socketZ	SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk	r|t|j�7}|S)N)rrr+)r�sizer#r#r$�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r(�
__module__�__qualname__r
r/rr2r3r4r7rZPY34r<rGrEr5rL�
__classcell__r#r#)r"r$rs

rcs8eZdZd
�fdd�	Zdd�Zdd�Zddd	�Z�ZS)�_ProactorReadPipeTransportNcs4t�j||||||�d|_d|_|jj|j�dS)NF)rr
�_paused�_reschedule_on_resumerr�
_loop_reading)rrrrrr r!)r"r#r$r
�sz#_ProactorReadPipeTransport.__init__cCs0|js|jrdSd|_|jj�r,tjd|�dS)NTz%r pauses reading)rrQrrBr
rC)rr#r#r$�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsP|js|jrdSd|_|jr6|jj|j|j�d|_|jj�rLtj	d|�dS)NFz%r resumes reading)
rrQrRrrrSrrBr
rC)rr#r#r$�resume_reading�s
z)_ProactorReadPipeTransport.resume_readingcCs�|jrd|_dSd}�z"yH|dk	r0d|_|j�}|jr>d}dS|dkrJdS|jjj|jd�|_Wn�t	k
r�}z2|js�|j
|d�n|jj�r�tj
ddd�WYdd}~Xn�tk
r�}z|j|�WYdd}~Xn^tk
�r}z|j
|d�WYdd}~Xn0tjk
�r&|j�s"�YnX|jj|j�Wd|�rN|jj|�n:|dk	�r�|jj��rptj
d|�|jj�}|�s�|j�XdS)NT�iz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rQrRr�resultrr�	_proactor�recvr�ConnectionAbortedErrorrGrBr
rC�ConnectionResetErrorrE�OSErrorr�CancelledError�add_done_callbackrSrZ
data_receivedZeof_receivedr7)r�fut�datarFZ	keep_openr#r#r$rS�sH


z(_ProactorReadPipeTransport._loop_reading)NNN)N)r(rMrNr
rTrUrSrOr#r#)r"r$rP�s

rPc@s6eZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)
�_ProactorBaseWritePipeTransportcCs�t|tttf�s&dt|�j}t|��|jr4td��|s<dS|j	rj|j	t
jkrXtj
d�|j	d7_	dS|jdkr�|jt|�d�n.|js�t|�|_|j�n|jj|�|j�dS)Nz3data argument must be a bytes-like object, not '%s'zwrite_eof() already calledzsocket.send() raised exception.r)r`)rA�bytes�	bytearray�
memoryview�typer(�	TypeErrorr�RuntimeErrorrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�
_loop_writingr�_maybe_pause_protocol�extend)rr`�msgr#r#r$�write�s(



z%_ProactorBaseWritePipeTransport.writeNcCsy�d|_d|_|r|j�|dkr.|j}d|_|sf|jrH|jj|jd�|jr\|j	j
tj�|j
�nN|jjj|j	|�|_|jj�s�t|�|_|jj|j�|j�n|jj|j�WnZtk
r�}z|j|�WYdd}~Xn0tk
�r}z|j|d�WYdd}~XnXdS)Nrz#Fatal write error on pipe transport)rrrWrrrrr5rrrHrJ�SHUT_WRZ_maybe_resume_protocolrX�send�doner+r^rirjr[rEr\rG)r�fr`rFr#r#r$ri
s0



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS)NTr#)rr#r#r$�
can_write_eof0sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|j�dS)N)r7)rr#r#r$�	write_eof3sz)_ProactorBaseWritePipeTransport.write_eofcCs|jd�dS)N)rE)rr#r#r$�abort6sz%_ProactorBaseWritePipeTransport.abort)NN)r(rMrNrmrirrrsrtr#r#r#r$ra�s
$
#racs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs4t�j||�|jjj|jd�|_|jj|j�dS)N�)	rr
rrXrYrrr^�_pipe_closed)r�args�kw)r"r#r$r
;sz$_ProactorWritePipeTransport.__init__cCs@|j�rdS|jrdSd|_|jdk	r4|jt��n|j�dS)N)Z	cancelledrrrrE�BrokenPipeErrorr7)rr_r#r#r$rw@s
z(_ProactorWritePipeTransport._pipe_closed)r(rMrNr
rwrOr#r#)r"r$ru:sruc@seZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportcCsdS)NFr#)rr#r#r$rrUsz*_ProactorDuplexPipeTransport.can_write_eofcCst�dS)N)�NotImplementedError)rr#r#r$rsXsz&_ProactorDuplexPipeTransport.write_eofN)r(rMrNrrrsr#r#r#r$r{Psr{cs6eZdZd
�fdd�	Zdd�Zdd�Zdd	�Z�ZS)�_ProactorSocketTransportNcs$t�j||||||�tj|�dS)N)rr
rZ_set_nodelay)rrrrrr r!)r"r#r$r
asz!_ProactorSocketTransport.__init__cCs�||jd<y|j�|jd<Wn4tjtfk
rP|jj�rLtjd|dd�YnXd|jkr�y|j	�|jd<Wn4tjtfk
r�|jj�r�tjd|dd�YnXdS)NrJZsocknamezgetsockname() failed on %rT)r>�peernamezgetpeername() failed on %r)
r1ZgetsocknamerJ�error�AttributeErrorrrBr
rhZgetpeername)rrr#r#r$rfs



z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rrvsz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdkr.|jjtj�dS)NT)rrrrrHrJrn)rr#r#r$rsys

z"_ProactorSocketTransport.write_eof)NNN)r(rMrNr
rrrrsrOr#r#)r"r$r}\s
r}cs�eZdZ�fdd�Zd-dd�Zd.ddddd�dd	�Zd/d
d�Zd0dd
�Zd1dd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd2d d!�Zd"d#�Zd3d%d&�Zd'd(�Zd)d*�Zd+d,�Z�ZS)4rcsHt�j�tjd|jj�||_||_d|_i|_	|j
|�|j�dS)NzUsing proactor: %s)rr
r
rCr"r(rX�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe)rZproactor)r"r#r$r
�s

zBaseProactorEventLoop.__init__NcCst||||||�S)N)r})rrrrr r!r#r#r$�_make_socket_transport�s
z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer r!c
Cs<tj�std��tj||||||�}	t|||	||d�|	jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler|ZSSLProtocolr}Z_app_transport)
rZrawsockr�
sslcontextrr�r�r r!Zssl_protocolr#r#r$�_make_ssl_transport�s
z)BaseProactorEventLoop._make_ssl_transportcCst|||||�S)N)r{)rrrrr r#r#r$�_make_duplex_pipe_transport�sz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�S)N)rP)rrrrr r#r#r$�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�S)N)ru)rrrrr r#r#r$�_make_write_pipe_transport�sz0BaseProactorEventLoop._make_write_pipe_transportcsP|j�rtd��|j�rdS|j�|j�|jj�d|_d|_t�j�dS)Nz!Cannot close a running event loop)	Z
is_runningrg�	is_closed�_stop_accept_futures�_close_self_piperXr7r�r)r)r"r#r$r7�s
zBaseProactorEventLoop.closecCs|jj||�S)N)rXrY)rr�nr#r#r$�	sock_recv�szBaseProactorEventLoop.sock_recvcCs|jj||�S)N)rXro)rrr`r#r#r$�sock_sendall�sz"BaseProactorEventLoop.sock_sendallcCs|jj||�S)N)rXZconnect)rrZaddressr#r#r$�sock_connect�sz"BaseProactorEventLoop.sock_connectcCs|jj|�S)N)rX�accept)rrr#r#r$�sock_accept�sz!BaseProactorEventLoop.sock_acceptcCst�dS)N)r|)rr#r#r$�_socketpair�sz!BaseProactorEventLoop._socketpaircCsL|jdk	r|jj�d|_|jj�d|_|jj�d|_|jd8_dS)Nr)r�r6�_ssockr7�_csock�
_internal_fds)rr#r#r$r��s



z&BaseProactorEventLoop._close_self_pipecCsF|j�\|_|_|jjd�|jjd�|jd7_|j|j�dS)NFr)r�r�r�Zsetblockingr�r�_loop_self_reading)rr#r#r$r��s
z%BaseProactorEventLoop._make_self_pipecCs�y$|dk	r|j�|jj|jd�}WnHtjk
r:dStk
rl}z|jd||d��WYdd}~XnX||_|j	|j
�dS)Niz.Error on reading from the event loop self pipe)r?r@r)rWrXrYr�rr]�	ExceptionrDr�r^r�)rrqrFr#r#r$r��sz(BaseProactorEventLoop._loop_self_readingcCs|jjd�dS)N�)r�ro)rr#r#r$�_write_to_self�sz$BaseProactorEventLoop._write_to_self�dcs&d������fdd�	��j��dS)Ncs"y�|dk	rl|j�\}}�jr,tjd�||���}�dk	rV�j||�dd|i�d�n�j||d|i�d��j�rxdS�jj��}Wn~t	k
r�}zD�j
�dkr��jd|�d���j�n�jr�tjd	�dd
�WYdd}~Xn8t
jk
�r�j�YnX|�j�j
�<|j��dS)Nz#%r got a new connection from %r: %rTr~)r�r r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>���)rWZ_debugr
rCr�r�r�rXr�r\r*rDr7rr]r�r^)rqZconnZaddrrrF)r�protocol_factoryrr!rr�r#r$r�s>


z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r)rr�rr�r!Zbacklogr#)rr�rr!rr�r$�_start_serving�s$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ
event_listr#r#r$�_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jj�D]}|j�qW|jj�dS)N)r��valuesr6�clear)rZfuturer#r#r$r�$sz*BaseProactorEventLoop._stop_accept_futurescCs |j�|jj|�|j�dS)N)r�rX�
_stop_servingr7)rrr#r#r$r�)sz#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr�)r(rMrNr
r�r�r�r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�rOr#r#)r"r$r�s4







()�__all__rJr9�rrrrrr	�logr
Z_FlowControlMixinZ
BaseTransportrZ
ReadTransportrPZWriteTransportraruZ	Transportr{r}Z
BaseEventLooprr#r#r#r$�<module>s0MT
#PK=�\G��4GGbase_tasks.cpython-36.opt-1.pycnu�[���3


 \��@sDddlZddlZddlmZddlmZdd�Zdd�Zd	d
�ZdS)�N�)�base_futures)�
coroutinescCsTtj|�}|jrd|d<tj|j�}|jdd|�|jdk	rP|jdd|j�|S)NZ
cancellingrrz	coro=<%s>�zwait_for=%r)rZ_future_repr_infoZ_must_cancelrZ_format_coroutine�_coro�insertZ_fut_waiter)�task�info�coro�r�*/usr/lib64/python3.6/asyncio/base_tasks.py�_task_repr_infos

r
cCs�g}y|jj}Wntk
r,|jj}YnX|dk	rxx6|dk	rl|dk	rZ|dkrRP|d8}|j|�|j}q8W|j�nL|jdk	r�|jj}x8|dk	r�|dk	r�|dkr�P|d8}|j|j	�|j
}q�W|S)Nrr)r�cr_frame�AttributeError�gi_frame�append�f_back�reverse�
_exception�
__traceback__�tb_frame�tb_next)r�limitZframes�f�tbrrr�_task_get_stacks0






rcCs�g}t�}xj|j|d�D]Z}|j}|j}|j}|j}	||krP|j|�tj|�tj	|||j
�}
|j|||	|
f�qW|j}|s�t
d||d�n*|dk	r�t
d||d�nt
d||d�tj||d�|dk	r�x$tj|j|�D]}
t
|
|dd�q�WdS)N)rzNo stack for %r)�filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):�)r�end)�setZ	get_stack�f_lineno�f_code�co_filename�co_name�add�	linecache�
checkcache�getline�	f_globalsrr�print�	traceback�
print_list�format_exception_only�	__class__)rrr�extracted_listZcheckedr�lineno�co�filename�name�line�excrrr�_task_print_stack3s0


r5)r%r*rrrr
rr5rrrr�<module>sPK=�\s�58�s�sselector_events.cpython-36.pycnu�[���3


 \���
@s<dZdgZddlZddlZddlZddlZddlZddlZyddlZWne	k
r^dZYnXddl
mZddl
mZddl
m
Z
ddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
lmZddlmZdd�ZGdd�dej�ZGdd�dejej�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z�Event loop using a selector and related classes.

A selector is a "notify-when-ready" multiplexer.  For a subclass which
also includes support for signal handling, see the unix_events sub-module.
�BaseSelectorEventLoop�N�)�base_events)�compat)�	constants)�events)�futures)�	selectors)�
transports)�sslproto)�	coroutine)�loggercCs6y|j|�}Wntk
r"dSXt|j|@�SdS)NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�//usr/lib64/python3.6/asyncio/selector_events.py�_test_selector_event s
rcsreZdZdZdO�fdd�	ZdPddd�dd�ZdQddddd	�d
d�Zddddd	�dd
�ZdRdd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdSdd �ZdTd!d"�ZedUd#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z ed?d@��Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(�Z)S)VrzJSelector event loop.

    See events.EventLoop for API specification.
    NcsFt�j�|dkrtj�}tjd|jj�||_|j	�t
j�|_dS)NzUsing selector: %s)
�super�__init__r	ZDefaultSelectorr
�debug�	__class__�__name__�	_selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfr)rrrr1s
zBaseSelectorEventLoop.__init__)�extra�servercCst||||||�S)N)�_SelectorSocketTransport)r!�sock�protocol�waiterr"r#rrr�_make_socket_transport;s
z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer"r#c

CsNtj�s"|j||||||||d�Stj||||||�}	t|||	||d�|	jS)N)r)r*r"r#)r"r#)rZ_is_sslproto_available�_make_legacy_ssl_transportZSSLProtocolr$Z_app_transport)
r!�rawsockr&�
sslcontextr'r)r*r"r#Zssl_protocolrrr�_make_ssl_transport@s

z)BaseSelectorEventLoop._make_ssl_transportc	
Cst|||||||||�	S)N)�_SelectorSslTransport)	r!r,r&r-r'r)r*r"r#rrrr+Os
z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||�S)N)�_SelectorDatagramTransport)r!r%r&�addressr'r"rrr�_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|j�rtd��|j�rdS|j�t�j�|jdk	rH|jj�d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer)r!)rrrr6^s


zBaseSelectorEventLoop.closecCst�dS)N)�NotImplementedError)r!rrr�_socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj��|jj�d|_|jj�d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor6�_csock�
_internal_fds)r!rrrr5ls

z&BaseSelectorEventLoop._close_self_pipecCsN|j�\|_|_|jjd�|jjd�|jd7_|j|jj�|j�dS)NFr)r8r:r<�setblockingr=�_add_readerr;�_read_from_self)r!rrrrts
z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!�datarrr�_process_self_data|sz(BaseSelectorEventLoop._process_self_datacCsVxPy |jjd�}|sP|j|�Wqtk
r8wYqtk
rLPYqXqWdS)Ni)r:�recvrB�InterruptedError�BlockingIOError)r!rArrrr@sz%BaseSelectorEventLoop._read_from_selfcCsJ|j}|dk	rFy|jd�Wn(tk
rD|jr@tjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketT)�exc_info)r<�send�OSError�_debugr
r)r!Zcsockrrr�_write_to_self�sz$BaseSelectorEventLoop._write_to_self�dcCs |j|j�|j|||||�dS)N)r?r;�_accept_connection)r!�protocol_factoryr%r-r#�backlogrrr�_start_serving�sz$BaseSelectorEventLoop._start_servingcCs�x�t|�D]�}y0|j�\}}|jr2tjd|||�|jd�Wn�tttfk
rXdSt	k
r�}	z^|	j
t
jt
jt
j
t
jfkr�|jd|	|d��|j|j��|jtj|j|||||�n�WYdd}	~	Xq
Xd|i}
|j|||
||�}|j|�q
WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exception�socket�peername)�range�acceptrJr
rr>rErD�ConnectionAbortedErrorrI�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr9r;Z
call_laterrZACCEPT_RETRY_DELAYrP�_accept_connection2Zcreate_task)r!rNr%r-r#rO�_�conn�addr�excr"rVrrrrM�s4


z(BaseSelectorEventLoop._accept_connectionccs�d}d}yj|�}|j�}|r6|j||||d||d�}n|j|||||d�}y|EdHWn|j��YnXWn\tk
r�}	z@|jr�d|	d�}
|dk	r�||
d<|dk	r�||
d<|j|
�WYdd}	~	XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr&�	transport)�
create_futurer.r(r6�	ExceptionrJrY)r!rNr\r"r-r#r&r_r'r^�contextrrrrZ�s4z)BaseSelectorEventLoop._accept_connection2cCs@y|j|}Wntk
r"YnX|j�s<tdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r r�
is_closingr3�format)r!rr_rrr�_ensure_fd_no_transport�sz-BaseSelectorEventLoop._ensure_fd_no_transportc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tj|df�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)�
_check_closedr�Handlerrr�registerr	�
EVENT_READrA�modify�cancel)	r!r�callback�args�handler�mask�reader�writerrrrr?�s
z!BaseSelectorEventLoop._add_readerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	||d|f�|dk	r�|j
�dSdSdS)NFT)r4rrrrrAr	ri�
unregisterrjrk)r!rrrorprqrrrr9sz$BaseSelectorEventLoop._remove_readerc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tjd|f�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)rfrrgrrrrhr	�EVENT_WRITErArjrk)	r!rrlrmrnrrorprqrrr�_add_writers
z!BaseSelectorEventLoop._add_writerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	|||df�|dk	r�|j
�dSdSdS)zRemove a writer callback.FNT)r4rrrrrAr	rsrrrjrk)r!rrrorprqrrr�_remove_writer,sz$BaseSelectorEventLoop._remove_writercGs|j|�|j||f|��S)zAdd a reader callback.)rer?)r!rrlrmrrr�
add_readerCs
z BaseSelectorEventLoop.add_readercCs|j|�|j|�S)zRemove a reader callback.)rer9)r!rrrr�
remove_readerHs
z#BaseSelectorEventLoop.remove_readercGs|j|�|j||f|��S)zAdd a writer callback..)rert)r!rrlrmrrr�
add_writerMs
z BaseSelectorEventLoop.add_writercCs|j|�|j|�S)zRemove a writer callback.)reru)r!rrrr�
remove_writerRs
z#BaseSelectorEventLoop.remove_writercCs6|jr|j�dkrtd��|j�}|j|d||�|S)z�Receive data from the socket.

        The return value is a bytes object representing the data received.
        The maximum amount of data to be received at once is specified by
        nbytes.

        This method is a coroutine.
        rzthe socket must be non-blockingN)rJ�
gettimeout�
ValueErrorr`�
_sock_recv)r!r%�n�futrrr�	sock_recvWs
	zBaseSelectorEventLoop.sock_recvcCs�|dk	r|j|�|j�rdSy|j|�}Wn`ttfk
rb|j�}|j||j||||�Yn6tk
r�}z|j	|�WYdd}~XnX|j
|�dS)N)rw�	cancelledrCrErDr;rvr|ra�
set_exception�
set_result)r!r~�
registered_fdr%r}rArr^rrrr|fs
z BaseSelectorEventLoop._sock_recvcCsF|jr|j�dkrtd��|j�}|r8|j|d||�n
|jd�|S)a�Send data to the socket.

        The socket must be connected to a remote socket. This method continues
        to send data from data until either all data has been sent or an
        error occurs. None is returned on success. On error, an exception is
        raised, and there is no way to determine how much data, if any, was
        successfully processed by the receiving end of the connection.

        This method is a coroutine.
        rzthe socket must be non-blockingN)rJrzr{r`�
_sock_sendallr�)r!r%rAr~rrr�sock_sendall{s
z"BaseSelectorEventLoop.sock_sendallcCs�|dk	r|j|�|j�rdSy|j|�}WnDttfk
rHd}Yn*tk
rp}z|j|�dSd}~XnX|t|�kr�|jd�n.|r�||d�}|j	�}|j
||j||||�dS)Nr)ryr�rHrErDrar��lenr�r;rxr�)r!r~r�r%rAr}r^rrrrr��s"

z#BaseSelectorEventLoop._sock_sendallccs�|jr|j�dkrtd��ttd�s2|jtjkrptj||j|j	|d�}|j
�sZ|EdH|j�d\}}}}}|j�}|j
|||�|EdHS)zTConnect to a remote socket at address.

        This method is a coroutine.
        rzthe socket must be non-blocking�AF_UNIX)�family�proto�loopN)rJrzr{�hasattrrSr�r�rZ_ensure_resolvedr��done�resultr`�
_sock_connect)r!r%r1Zresolvedr[r~rrr�sock_connect�s
z"BaseSelectorEventLoop.sock_connectcCs�|j�}y|j|�Wnjttfk
rV|jtj|j|��|j||j	|||�Yn6t
k
r�}z|j|�WYdd}~XnX|jd�dS)N)
r;ZconnectrErDZadd_done_callback�	functools�partial�_sock_connect_donerx�_sock_connect_cbrar�r�)r!r~r%r1rr^rrrr��sz#BaseSelectorEventLoop._sock_connectcCs|j|�dS)N)ry)r!rr~rrrr��sz(BaseSelectorEventLoop._sock_connect_donecCs�|j�rdSy,|jtjtj�}|dkr6t|d|f��WnBttfk
rPYn6tk
rz}z|j	|�WYdd}~XnX|j
d�dS)NrzConnect call failed %s)r�Z
getsockoptrSZ
SOL_SOCKETZSO_ERRORrIrErDrar�r�)r!r~r%r1�errr^rrrr��sz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|j�dkrtd��|j�}|j|d|�|S)a|Accept a connection.

        The socket must be bound to an address and listening for connections.
        The return value is a pair (conn, address) where conn is a new socket
        object usable to send and receive data on the connection, and address
        is the address bound to the socket on the other end of the connection.

        This method is a coroutine.
        rzthe socket must be non-blockingF)rJrzr{r`�_sock_accept)r!r%r~rrr�sock_accept�s

z!BaseSelectorEventLoop.sock_acceptcCs�|j�}|r|j|�|j�r"dSy|j�\}}|jd�WnVttfk
rh|j||j|d|�Yn:t	k
r�}z|j
|�WYdd}~XnX|j||f�dS)NFT)r;rwr�rVr>rErDrvr�rar�r�)r!r~Z
registeredr%rr\r1r^rrrr��s
z"BaseSelectorEventLoop._sock_acceptcCs�x~|D]v\}}|j|j}\}}|tj@rN|dk	rN|jrD|j|�n
|j|�|tj@r|dk	r|jrr|j|�q|j|�qWdS)N)	�fileobjrAr	riZ
_cancelledr9Z
_add_callbackrsru)r!Z
event_listrror�rprqrrr�_process_events�s
z%BaseSelectorEventLoop._process_eventscCs|j|j��|j�dS)N)r9r;r6)r!r%rrr�
_stop_servingsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN)*r�
__module__�__qualname__�__doc__rr(r.r+r2r6r8r5rrBr@rKrPrMrrZrer?r9rtrurvrwrxryrr|r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rrr+sT



(#cs�eZdZdZeZdZd �fdd�	Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ejr`dd�Zd!dd�Zdd�Zdd�Zdd�Zdd�Z�ZS)"�_SelectorTransport�iNcs�t�j||�||jd<|j�|jd<d|jkrdy|j�|jd<Wn tjk
rbd|jd<YnX||_|j�|_	||_
d|_||_|j
�|_d|_d|_|jdk	r�|jj�||j|j	<dS)NrSZsocknamerTTrF)rr�_extraZgetsocknameZgetpeernamerS�error�_sockr;�_sock_fd�	_protocol�_protocol_connected�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr )r!r�r%r&r"r#)rrrrs&





z_SelectorTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�|jdk	r�|jj�r�t|jj	|jt
j�}|rz|jd�n
|jd�t|jj	|jt
j�}|r�d}nd}|j
�}|jd||f�d	d
j|�S)N�closed�closingzfd=%szread=pollingz	read=idle�pollingZidlezwrite=<%s, bufsize=%s>z<%s>� )rrr��appendr�r��_loopr4rrr	rirs�get_write_buffer_size�join)r!�infor��state�bufsizerrr�__repr__2s*



z_SelectorTransport.__repr__cCs|jd�dS)N)�_force_close)r!rrr�abortNsz_SelectorTransport.abortcCs
||_dS)N)r�)r!r&rrr�set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r�)r!rrr�get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r�)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr
dSd|_|jj|j�|jsP|jd7_|jj|j�|jj|jd�dS)NTr)	r�r�r9r�r�r�ru�	call_soon�_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)�source)r��warnings�warn�ResourceWarningr6)r!rrr�__del__hs
z_SelectorTransport.__del__�Fatal error on transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)rG)rQrRr_r&)
�
isinstancerZ_FATAL_ERROR_IGNOREr��	get_debugr
rrYr�r�)r!r^rQrrr�_fatal_errorns
z_SelectorTransport._fatal_errorcCsd|jr
dS|jr(|jj�|jj|j�|jsBd|_|jj|j�|jd7_|jj|j	|�dS)NTr)
r�r��clearr�rur�r�r9r�r�)r!r^rrrr�|s
z_SelectorTransport._force_closecCsVz|jr|jj|�Wd|jj�d|_d|_d|_|j}|dk	rP|j�d|_XdS)N)r�r�Zconnection_lostr�r6r�r�Z_detach)r!r^r#rrrr��s
z(_SelectorTransport._call_connection_lostcCs
t|j�S)N)r�r�)r!rrrr��sz(_SelectorTransport.get_write_buffer_sizecGs"|jr
dS|jj||f|��dS)N)r�r�r?)r!rrlrmrrrr?�sz_SelectorTransport._add_readeri)NN)r�)rr�r��max_size�	bytearrayr�r�rr�r�r�r�rcr6rZPY34r�r�r�r�r�r?r�rr)rrr�s"

r�csVeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
�ZS)r$Ncsrt�j|||||�d|_d|_tj|j�|jj|j	j
|�|jj|j|j|j
�|dk	rn|jjtj|d�dS)NF)rr�_eof�_pausedrZ_set_nodelayr�r�r�r��connection_mader?r��_read_readyr�_set_result_unless_cancelled)r!r�r%r&r'r"r#)rrrr�s

z!_SelectorSocketTransport.__init__cCs>|js|jrdSd|_|jj|j�|jj�r:tjd|�dS)NTz%r pauses reading)r�r�r�r9r�r�r
r)r!rrr�
pause_reading�s
z&_SelectorSocketTransport.pause_readingcCsB|js|jrdSd|_|j|j|j�|jj�r>tjd|�dS)NFz%r resumes reading)	r�r�r?r�r�r�r�r
r)r!rrr�resume_reading�s
z'_SelectorSocketTransport.resume_readingcCs�|jr
dSy|jj|j�}WnDttfk
r4Yn|tk
r`}z|j|d�WYdd}~XnPX|rt|jj	|�n<|j
j�r�tj
d|�|jj�}|r�|j
j|j�n|j�dS)Nz$Fatal read error on socket transportz%r received EOF)r�r�rCr�rErDrar�r��
data_receivedr�r�r
r�eof_receivedr9r�r6)r!rAr^�	keep_openrrrr��s 

z$_SelectorSocketTransport._read_readycCs�t|tttf�s"tdt|�j��|jr0td��|s8dS|j	rf|j	t
jkrTtj
d�|j	d7_	dS|js�y|jj|�}WnBttfk
r�Yn@tk
r�}z|j|d�dSd}~XnX||d�}|s�dS|jj|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)r��bytesr��
memoryview�	TypeError�typerr�r3r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�r�rHrErDrar�r�rtr��_write_ready�extend�_maybe_pause_protocol)r!rAr}r^rrr�write�s4
z_SelectorSocketTransport.writecCs�|jstd��|jrdSy|jj|j�}Wn\ttfk
rBYn�tk
r�}z*|jj	|j
�|jj�|j|d�WYdd}~XnTX|r�|jd|�=|j
�|js�|jj	|j
�|jr�|jd�n|jr�|jjtj�dS)NzData should not be emptyz%Fatal write error on socket transport)r��AssertionErrorr�r�rHrErDrar�rur�r�r��_maybe_resume_protocolr�r�r��shutdownrS�SHUT_WR)r!r}r^rrrr�s(
z%_SelectorSocketTransport._write_readycCs.|js|jrdSd|_|js*|jjtj�dS)NT)r�r�r�r�r�rSr�)r!rrr�	write_eofs
z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr�
can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN)rr�r�rr�r�r�r�r�r�r�r�rr)rrr$�s#r$csdeZdZeZd�fdd�	Zddd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�ZS)r/NFc

s�tdkrtd��|s tj||�}|dd�}
|r<|r<||
d<|j|f|
�}t�j|||||	�d|_||_||_	||_
d|_|jj
|d�|jj�r�tjd|�|jj�}nd}|j|�dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)�sslr3rZ_create_transport_contextZwrap_socketrrr��_server_hostname�_waiter�_sslcontextr�r��updater�r�r
r�time�
_on_handshake)
r!r�r,r&r-r'r)r*r"r#Zwrap_kwargsZsslsock�
start_time)rrrr(s*

z_SelectorSslTransport.__init__cCsD|jdkrdS|jj�s:|dk	r.|jj|�n|jjd�d|_dS)N)r�r�r�r�)r!r^rrr�_wakeup_waiterLs

z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jj�Wn�tjk
r8|jj|j|j|�dStjk
r`|jj	|j|j|�dSt
k
r�}z`|jj�r�tj
d|dd�|jj|j�|jj|j�|jj�|j|�t|t�r�dS�WYdd}~XnX|jj|j�|jj|j�|jj�}t|jd��s�|j�r�|jjtjk�r�ytj||j�WnRtk
�r�}z4|jj��rjtj
d|dd�|jj�|j|�dSd}~XnX|jj||jj�|jj�|jd�d|_d|_ |jj|j|j!�d|_"|jj#|j$j%|�|jj#|j�|jj��r |jj&�|}tj'd||d	�dS)
Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)�peercert�cipher�compressionZ
ssl_objectFz%r: SSL handshake took %.1f msg@�@)(r�Zdo_handshaker��SSLWantReadErrorr�r?r�r��SSLWantWriteErrorrt�
BaseExceptionr�r
r�r9rur6r�r�raZgetpeercertr�r�r�Zverify_modeZ	CERT_NONEZmatch_hostnamer�r�r�r��_read_wants_write�_write_wants_readr�r�r�r�r�r�r)r!r�r^r�Zdtrrrr�Vsb













z#_SelectorSslTransport._on_handshakecCsJ|jrtd��|jrtd��d|_|jj|j�|jj�rFtjd|�dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r3r�r�r9r�r�r
r)r!rrrr��s
z#_SelectorSslTransport.pause_readingcCsJ|jstd��d|_|jrdS|jj|j|j�|jj�rFtj	d|�dS)Nz
Not pausedFz%r resumes reading)
r�r3r�r�r?r�r�r�r
r)r!rrrr��s
z$_SelectorSslTransport.resume_readingcCs"|jr
dS|jr6d|_|j�|jr6|jj|j|j�y|jj|j	�}Wn�t
ttj
fk
rdYn�tjk
r�d|_|jj|j�|jj|j|j�Yn�tk
r�}z|j|d�WYdd}~XnTX|r�|jj|�n@z4|jj�r�tjd|�|jj�}|�rtjd�Wd|j�XdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)r�r�r�r�r�rtr�r�rCr�rErDr�r�r�r�r9rar�r�r�r�r
rr�r�r6)r!rAr^r�rrrr��s4

z!_SelectorSslTransport._read_readycCs(|jr
dS|jr<d|_|j�|jp(|js<|jj|j|j�|jr�y|j	j
|j�}Wn�ttt
jfk
rtd}Ynpt
jk
r�d}|jj|j�d|_YnDtk
r�}z(|jj|j�|jj�|j|d�dSd}~XnX|r�|jd|�=|j�|j�s$|jj|j�|j�r$|jd�dS)NFrTz"Fatal write error on SSL transport)r�r�r�r�r�r�r?r�r�r�rHrErDr�r�r�rur�rar�r�r�r�)r!r}r^rrrr��s8

z"_SelectorSslTransport._write_readycCs�t|tttf�s"tdt|�j��|s*dS|jrX|jtj	krFt
jd�|jd7_dS|jsp|j
j|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rzsocket.send() raised exception.r)r�r�r�r�r�r�rr�rr�r
r�r�r�rtr�r�r�r�)r!rArrrr��s
z_SelectorSslTransport.writecCsdS)NFr)r!rrrr�sz#_SelectorSslTransport.can_write_eof)NFNNN)N)rr�r�r�r�rr�r�r�r�r�r�r�r�r�rr)rrr/$s"

?
"#r/csFeZdZejZd�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r0Ncs^t�j||||�||_|jj|jj|�|jj|j|j|j	�|dk	rZ|jjt
j|d�dS)N)rr�_addressr�r�r�r�r?r�r�rr�)r!r�r%r&r1r'r")rrrrs

z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss|]\}}t|�VqdS)N)r�)�.0rAr[rrr�	<genexpr>szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�)r!rrrr�sz0_SelectorDatagramTransport.get_write_buffer_sizecCs�|jr
dSy|jj|j�\}}Wnpttfk
r8Ynhtk
rd}z|jj|�WYdd}~Xn<t	k
r�}z|j
|d�WYdd}~XnX|jj||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rErDrIr��error_receivedrar�Zdatagram_received)r!rAr]r^rrrr� sz&_SelectorDatagramTransport._read_readycCsTt|tttf�s"tdt|�j��|s*dS|jrN|d|jfkrNtd|jf��|j	r�|jr�|j	t
jkrptj
d�|j	d7_	dS|j�s4y&|jr�|jj|�n|jj||�dSttfk
r�|jj|j|j�YnZtk
�r}z|jj|�dSd}~Xn.tk
�r2}z|j|d�dSd}~XnX|jjt|�|f�|j�dS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)r�r�r�r�r�r�rr�r{r�rr�r
r�r�r�rH�sendtorErDr�rtr��
_sendto_readyrIr�r�rar�r�r�)r!rAr]r^rrrr�.s<
z!_SelectorDatagramTransport.sendtocCs�x�|jr�|jj�\}}y&|jr,|jj|�n|jj||�Wqttfk
rf|jj||f�PYqt	k
r�}z|j
j|�dSd}~Xqtk
r�}z|j
|d�dSd}~XqXqW|j�|js�|jj|j�|jr�|jd�dS)Nz'Fatal write error on datagram transport)r��popleftr�r�rHr�rErD�
appendleftrIr�r�rar�r�r�rur�r�r�)r!rAr]r^rrrr�Us*z(_SelectorDatagramTransport._sendto_ready)NNN)N)rr�r��collections�dequer�rr�r�r�r�r�rr)rrr0s
'r0) r��__all__r�rXr�rSr�rr��ImportError�rrrrrr	r
rZ
coroutinesr�logr
rZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r$r/r0rrrr�<module>sD
iiPK=�\K�[[protocols.cpython-36.pycnu�[���3


 \��@sRdZddddgZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�Zd	S)
zAbstract Protocol class.�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocolc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)raCommon base class for protocol interfaces.

    Usually user implements protocols that derived from BaseProtocol
    like Protocol or ProcessProtocol.

    The only case when BaseProtocol should be implemented directly is
    write-only transport like write pipe
    cCsdS)z�Called when a connection is made.

        The argument is the transport representing the pipe connection.
        To receive data, wait for data_received() calls.
        When the connection is closed, connection_lost() is called.
        N�)�selfZ	transportrr�)/usr/lib64/python3.6/asyncio/protocols.py�connection_madeszBaseProtocol.connection_madecCsdS)z�Called when the connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        Nr)r�excrrr�connection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark.

        Pause and resume calls are paired -- pause_writing() is called
        once when the buffer goes strictly over the high-water mark
        (even if subsequent writes increases the buffer size even
        more), and eventually resume_writing() is called once when the
        buffer size reaches the low-water mark.

        Note that if the buffer size equals the high-water mark,
        pause_writing() is not called -- it must go strictly over.
        Conversely, resume_writing() is called when the buffer size is
        equal or lower than the low-water mark.  These end conditions
        are important to ensure that things go as expected when either
        mark is zero.

        NOTE: This is the only Protocol callback that is not called
        through EventLoop.call_soon() -- if it were, it would have no
        effect when it's most needed (when the app keeps writing
        without yielding until pause_writing() is called).
        Nr)rrrr�
pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark.

        See pause_writing() for details.
        Nr)rrrr�resume_writing7szBaseProtocol.resume_writingN)�__name__�
__module__�__qualname__�__doc__rr
rrrrrrrs
c@s eZdZdZdd�Zdd�ZdS)ranInterface for stream protocol.

    The user should implement this interface.  They can inherit from
    this class but don't need to.  The implementations here do
    nothing (they don't raise exceptions).

    When the user wants to requests a transport, they pass a protocol
    factory to a utility function (e.g., EventLoop.create_connection()).

    When the connection is made successfully, connection_made() is
    called with a suitable transport object.  Then data_received()
    will be called 0 or more times with data (bytes) received from the
    transport; finally, connection_lost() will be called exactly once
    with either an exception object or None as an argument.

    State machine of calls:

      start -> CM [-> DR*] [-> ER?] -> CL -> end

    * CM: connection_made()
    * DR: data_received()
    * ER: eof_received()
    * CL: connection_lost()
    cCsdS)zTCalled when some data is received.

        The argument is a bytes object.
        Nr)r�datarrr�
data_receivedXszProtocol.data_receivedcCsdS)z�Called when the other end calls write_eof() or equivalent.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        Nr)rrrr�eof_received^szProtocol.eof_receivedN)r
rrrrrrrrrr>sc@s eZdZdZdd�Zdd�ZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrr�datagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError.

        (Other than BlockingIOError or InterruptedError.)
        Nr)rr	rrr�error_receivedmszDatagramProtocol.error_receivedN)r
rrrrrrrrrrgsc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rz,Interface for protocol for subprocess calls.cCsdS)z�Called when the subprocess writes data into stdout/stderr pipe.

        fd is int file descriptor.
        data is bytes object.
        Nr)r�fdrrrr�pipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)z�Called when a file descriptor associated with the child process is
        closed.

        fd is the int file descriptor that was closed.
        Nr)rrr	rrr�pipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrr�process_exited�sz!SubprocessProtocol.process_exitedN)r
rrrrrrrrrrrtsN)r�__all__rrrrrrrr�<module>s7)
PK=�\�#�~� � queues.cpython-36.pycnu�[���3


 \�@s�dZdddddgZddlZddlZdd	lmZdd
lmZddlmZddlm	Z	Gd
d�de
�ZGdd�de
�ZGdd�d�Z
Gdd�de
�ZGdd�de
�Zejs�e
Zejd�dS)ZQueues�Queue�
PriorityQueue�	LifoQueue�	QueueFull�
QueueEmpty�N�)�compat)�events)�locks)�	coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object
    which is empty.
    N)�__name__�
__module__�__qualname__�__doc__�rr�&/usr/lib64/python3.6/asyncio/queues.pyrsc@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue
    object which is full.
    N)rr
rrrrrrrsc@s�eZdZdZd)dd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�Zdd�Zedd��Zdd �Zed!d"��Zd#d$�Zd%d&�Zed'd(��ZdS)*raA queue, useful for coordinating producer and consumer coroutines.

    If maxsize is less than or equal to zero, the queue size is infinite. If it
    is an integer greater than 0, then "yield from put()" will block when the
    queue reaches maxsize, until an item is removed by get().

    Unlike the standard library Queue, you can reliably know this Queue's size
    with qsize(), since your single-threaded asyncio application won't be
    interrupted between calling qsize() and doing an operation on the Queue.
    rN)�loopcCsb|dkrtj�|_n||_||_tj�|_tj�|_d|_t	j
|jd�|_|jj�|j
|�dS)Nr)r)r	Zget_event_loop�_loop�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr
ZEvent�	_finished�set�_init)�self�maxsizerrrr�__init__(s


zQueue.__init__cCstj�|_dS)N)rr�_queue)rrrrrr:szQueue._initcCs
|jj�S)N)r �popleft)rrrr�_get=sz
Queue._getcCs|jj|�dS)N)r �append)r�itemrrr�_put@sz
Queue._putcCs*x$|r$|j�}|j�s|jd�PqWdS)N)r!�doneZ
set_result)r�waitersZwaiterrrr�_wakeup_nextEs

zQueue._wakeup_nextcCsdjt|�jt|�|j��S)Nz<{} at {:#x} {}>)�format�typer�id�_format)rrrr�__repr__MszQueue.__repr__cCsdjt|�j|j��S)Nz<{} {}>)r)r*rr,)rrrr�__str__Qsz
Queue.__str__cCszdj|j�}t|dd�r,|djt|j��7}|jrF|djt|j��7}|jr`|djt|j��7}|jrv|dj|j�7}|S)Nzmaxsize={!r}r z _queue={!r}z
 _getters[{}]z
 _putters[{}]z	 tasks={})	r)r�getattr�listr r�lenrr)r�resultrrrr,Tsz
Queue._formatcCs
t|j�S)zNumber of items in the queue.)r1r )rrrr�qsize`szQueue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz
Queue.maxsizecCs|jS)z3Return True if the queue is empty, False otherwise.)r )rrrr�emptyiszQueue.emptycCs |jdkrdS|j�|jkSdS)z�Return True if there are maxsize items in the queue.

        Note: if the Queue was initialized with maxsize=0 (the default),
        then full() is never True.
        rFN)rr3)rrrr�fullms
z
Queue.fullc	cstxh|j�rh|jj�}|jj|�y|EdHWq|j�|j�r^|j�r^|j|j��YqXqW|j|�S)z�Put an item into the queue.

        Put an item into the queue. If the queue is full, wait until a free
        slot is available before adding item.

        This method is a coroutine.
        N)	r5r�
create_futurerr#�cancel�	cancelledr(�
put_nowait)rr$Zputterrrr�putxs	

z	Queue.putcCs>|j�rt�|j|�|jd7_|jj�|j|j�dS)zyPut an item into the queue without blocking.

        If no free slot is immediately available, raise QueueFull.
        rN)r5rr%rr�clearr(r)rr$rrrr9�s

zQueue.put_nowaitccs�x�|j�r�|jj�}|jj|�y|EdHWq|j�y|jj|�Wntk
rbYnX|j�r�|j�r�|j	|j��YqXqW|j
�S)z�Remove and return an item from the queue.

        If queue is empty, wait until an item is available.

        This method is a coroutine.
        N)r4rr6rr#r7�remove�
ValueErrorr8r(�
get_nowait)r�getterrrr�get�s

z	Queue.getcCs$|j�rt�|j�}|j|j�|S)z�Remove and return an item from the queue.

        Return an item if one is immediately available, else raise QueueEmpty.
        )r4rr"r(r)rr$rrrr>�s
zQueue.get_nowaitcCs8|jdkrtd��|jd8_|jdkr4|jj�dS)a$Indicate that a formerly enqueued task is complete.

        Used by queue consumers. For each get() used to fetch a task,
        a subsequent call to task_done() tells the queue that the processing
        on the task is complete.

        If a join() is currently blocking, it will resume when all items have
        been processed (meaning that a task_done() call was received for every
        item that had been put() into the queue).

        Raises ValueError if called more times than there were items placed in
        the queue.
        rz!task_done() called too many timesrN)rr=rr)rrrr�	task_done�s


zQueue.task_doneccs|jdkr|jj�EdHdS)aBlock until all items in the queue have been gotten and processed.

        The count of unfinished tasks goes up whenever an item is added to the
        queue. The count goes down whenever a consumer calls task_done() to
        indicate that the item was retrieved and all work on it is complete.
        When the count of unfinished tasks drops to zero, join() unblocks.
        rN)rr�wait)rrrr�join�s	
z
Queue.join)r)rr
rrrrr"r%r(r-r.r,r3�propertyrr4r5rr:r9r@r>rArCrrrrrs&
c@s4eZdZdZdd�Zejfdd�Zejfdd�Z	dS)	rz�A subclass of Queue; retrieves entries in priority order (lowest first).

    Entries are typically tuples of the form: (priority number, data).
    cCs
g|_dS)N)r )rrrrrr�szPriorityQueue._initcCs||j|�dS)N)r )rr$�heappushrrrr%�szPriorityQueue._putcCs
||j�S)N)r )r�heappoprrrr"�szPriorityQueue._getN)
rr
rrr�heapqrEr%rFr"rrrrr�sc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rzEA subclass of Queue that retrieves most recently added entries first.cCs
g|_dS)N)r )rrrrrr�szLifoQueue._initcCs|jj|�dS)N)r r#)rr$rrrr%�szLifoQueue._putcCs
|jj�S)N)r �pop)rrrrr"�szLifoQueue._getN)rr
rrrr%r"rrrrr�s�
JoinableQueue)r�__all__rrG�rr	r
Z
coroutinesr�	ExceptionrrrrrZPY35rIr#rrrr�<module>s H
PK=�\P�f�#�#$base_subprocess.cpython-36.opt-1.pycnu�[���3


 \�#�@s�ddlZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
Gdd	�d	ej�ZGd
d�dej
�ZGdd
�d
eej�ZdS)�N�)�compat)�	protocols)�
transports)�	coroutine)�loggercs�eZdZd0�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jrTdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zed*d+��Zd,d-�Zd.d/�Z�ZS)1�BaseSubprocessTransportNc
s&t�j|
�d|_||_||_d|_d|_d|_g|_t	j
�|_i|_d|_
|tjkr`d|jd<|tjkrtd|jd<|tjkr�d|jd<y"|jf||||||d�|��Wn|j��YnX|jj|_|j|jd<|jj��rt|ttf�r�|}n|d}tjd||j�|jj|j|	��dS)NFrr�)�args�shell�stdin�stdout�stderr�bufsize�
subprocesszprocess %r created: pid %s)�super�__init__�_closed�	_protocol�_loop�_proc�_pid�_returncode�
_exit_waiters�collections�deque�_pending_calls�_pipes�	_finishedr�PIPE�_start�close�pidZ_extra�	get_debug�
isinstance�bytes�strr�debugZcreate_task�_connect_pipes)
�self�loop�protocolr
rrr
rr�waiterZextra�kwargsZprogram)�	__class__��//usr/lib64/python3.6/asyncio/base_subprocess.pyrs@








z BaseSubprocessTransport.__init__cCs|jjg}|jr|jd�|jdk	r4|jd|j�|jdk	rP|jd|j�n |jdk	rf|jd�n
|jd�|jjd�}|dk	r�|jd|j�|jjd�}|jjd	�}|dk	r�||kr�|jd
|j�n0|dk	r�|jd|j�|dk	r�|jd|j�d
dj	|�S)N�closedzpid=%sz
returncode=%sZrunningznot startedrzstdin=%srr	zstdout=stderr=%sz	stdout=%sz	stderr=%sz<%s>� )
r.�__name__r�appendrrr�get�pipe�join)r)�inforr
rr/r/r0�__repr__9s,





z BaseSubprocessTransport.__repr__cKst�dS)N)�NotImplementedError)r)r
rrr
rrr-r/r/r0r VszBaseSubprocessTransport._startcCs
||_dS)N)r)r)r+r/r/r0�set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0�get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0�
is_closing_sz"BaseSubprocessTransport.is_closingcCs�|jr
dSd|_x&|jj�D]}|dkr*q|jj�qW|jdk	r�|jdkr�|jj�dkr�|jj	�rpt
jd|�y|jj�Wnt
k
r�YnXdS)NTz$Close running child process: kill %r)rr�valuesr6r!rrZpollrr#rZwarning�kill�ProcessLookupError)r)�protor/r/r0r!bs 


zBaseSubprocessTransport.closecCs&|js"tjd|t|d�|j�dS)Nzunclosed transport %r)�source)r�warnings�warn�ResourceWarningr!)r)r/r/r0�__del__�szBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0�get_pid�szBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0�get_returncode�sz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)�fdr/r/r0�get_pipe_transport�s
z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrt��dS)N)rr@)r)r/r/r0�_check_proc�s
z#BaseSubprocessTransport._check_proccCs|j�|jj|�dS)N)rKr�send_signal)r)�signalr/r/r0rL�sz#BaseSubprocessTransport.send_signalcCs|j�|jj�dS)N)rKr�	terminate)r)r/r/r0rN�sz!BaseSubprocessTransport.terminatecCs|j�|jj�dS)N)rKrr?)r)r/r/r0r?�szBaseSubprocessTransport.killc	#sPy�j}�j}|jdk	rB|j�fdd�|j�EdH\}}|�jd<|jdk	rv|j�fdd�|j�EdH\}}|�jd<|jdk	r�|j�fdd�|j�EdH\}}|�jd<|j�j	j
��x"�jD]\}}|j|f|��q�Wd�_WnDtk
�r*}z&|dk	�r|j
��r|j|�WYdd}~Xn"X|dk	�rL|j
��rL|jd�dS)Ncs
t�d�S)Nr)�WriteSubprocessPipeProtor/)r)r/r0�<lambda>�sz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>rcs
t�d�S)Nr)�ReadSubprocessPipeProtor/)r)r/r0rP�srcs
t�d�S)Nr	)rQr/)r)r/r0rP�sr	)rrrZconnect_write_piperr
Zconnect_read_piper�	call_soonr�connection_mader�	Exception�	cancelledZ
set_exception�
set_result)	r)r,�procr*�_r6�callback�data�excr/)r)r0r(�s6









z&BaseSubprocessTransport._connect_pipescGs2|jdk	r|jj||f�n|jj|f|��dS)N)rr4rrR)r)�cbrZr/r/r0�_call�s
zBaseSubprocessTransport._callcCs|j|jj||�|j�dS)N)r]rZpipe_connection_lost�_try_finish)r)rIr[r/r/r0�_pipe_connection_lost�sz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||�dS)N)r]rZpipe_data_received)r)rIrZr/r/r0�_pipe_data_received�sz+BaseSubprocessTransport._pipe_data_receivedcCst|jj�rtjd||�||_|jjdkr2||j_|j|jj	�|j
�x |jD]}|j�sP|j
|�qPWd|_dS)Nz%r exited with return code %r)rr#rr8rr�
returncoder]rZprocess_exitedr^rrUrV)r)rar,r/r/r0�_process_exited�s
z'BaseSubprocessTransport._process_exitedccs0|jdk	r|jS|jj�}|jj|�|EdHS)zdWait until the process exit and return the process return code.

        This method is a coroutine.N)rrZ
create_futurerr4)r)r,r/r/r0�_wait�s


zBaseSubprocessTransport._waitcCs>|jdkrdStdd�|jj�D��r:d|_|j|jd�dS)Ncss|]}|dk	o|jVqdS)N)�disconnected)�.0�pr/r/r0�	<genexpr>�sz6BaseSubprocessTransport._try_finish.<locals>.<genexpr>T)r�allrr>rr]�_call_connection_lost)r)r/r/r0r^�s
z#BaseSubprocessTransport._try_finishcCs*z|jj|�Wdd|_d|_d|_XdS)N)r�connection_lostrr)r)r[r/r/r0ri�s
z-BaseSubprocessTransport._call_connection_lost)NN)r3�
__module__�__qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r]r_r`rbrcr^ri�
__classcell__r/r/)r.r0rs0)%	rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rOcCs||_||_d|_d|_dS)NF)rWrIr6rd)r)rWrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs
||_dS)N)r6)r)Z	transportr/r/r0rSsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|�d|_dS)NT)rdrWr_rI)r)r[r/r/r0rjsz(WriteSubprocessPipeProto.connection_lostcCs|jjj�dS)N)rWr�
pause_writing)r)r/r/r0rnsz&WriteSubprocessPipeProto.pause_writingcCs|jjj�dS)N)rWr�resume_writing)r)r/r/r0rosz'WriteSubprocessPipeProto.resume_writingN)	r3rkrlrrSr9rjrnror/r/r/r0rOsrOc@seZdZdd�ZdS)rQcCs|jj|j|�dS)N)rWr`rI)r)rZr/r/r0�
data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rkrlrpr/r/r/r0rQ!srQ)rrrC�rrrZ
coroutinesr�logrZSubprocessTransportrZBaseProtocolrOZProtocolrQr/r/r/r0�<module>s{PK=�\Q*_//transports.cpython-36.pycnu�[���3


 \R'�@s�dZddlmZddddddgZGd	d�d�ZGd
d�de�ZGdd�de�ZGdd�dee�ZGd
d�de�ZGdd�de�Z	Gdd�de�Z
dS)zAbstract Transport class.�)�compat�
BaseTransport�
ReadTransport�WriteTransport�	Transport�DatagramTransport�SubprocessTransportc@sDeZdZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rzBase class for transports.NcCs|dkri}||_dS)N)�_extra)�self�extra�r�*/usr/lib64/python3.6/asyncio/transports.py�__init__
szBaseTransport.__init__cCs|jj||�S)z#Get optional transport information.)r	�get)r
�name�defaultrrr
�get_extra_infoszBaseTransport.get_extra_infocCst�dS)z2Return True if the transport is closing or closed.N)�NotImplementedError)r
rrr
�
is_closingszBaseTransport.is_closingcCst�dS)a
Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) called
        with None as its argument.
        N)r)r
rrr
�closeszBaseTransport.closecCst�dS)zSet a new protocol.N)r)r
�protocolrrr
�set_protocol$szBaseTransport.set_protocolcCst�dS)zReturn the current protocol.N)r)r
rrr
�get_protocol(szBaseTransport.get_protocol)N)N)
�__name__�
__module__�__qualname__�__doc__rrrrrrrrrr
r
s


c@s eZdZdZdd�Zdd�ZdS)rz#Interface for read-only transports.cCst�dS)z�Pause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        N)r)r
rrr
�
pause_reading0szReadTransport.pause_readingcCst�dS)z�Resume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        N)r)r
rrr
�resume_reading8szReadTransport.resume_readingN)rrrrrrrrrr
r-sc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)rz$Interface for write-only transports.NcCst�dS)a�Set the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        N)r)r
�high�lowrrr
�set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCst�dS)z,Return the current size of the write buffer.N)r)r
rrr
�get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCst�dS)z�Write some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        N)r)r
�datarrr
�write]szWriteTransport.writecCstj|�}|j|�dS)z�Write a list (or any iterable) of data bytes to the transport.

        The default implementation concatenates the arguments and
        calls write() on the result.
        N)rZflatten_list_bytesr$)r
Zlist_of_datar#rrr
�
writelineses
zWriteTransport.writelinescCst�dS)z�Close the write end after flushing buffered data.

        (This is like typing ^D into a UNIX program reading from stdin.)

        Data may still be received.
        N)r)r
rrr
�	write_eofnszWriteTransport.write_eofcCst�dS)zAReturn True if this transport supports write_eof(), False if not.N)r)r
rrr
�
can_write_eofwszWriteTransport.can_write_eofcCst�dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        N)r)r
rrr
�abort{szWriteTransport.abort)NN)rrrrr!r"r$r%r&r'r(rrrr
rAs
		c@seZdZdZdS)raSInterface representing a bidirectional transport.

    There may be several implementations, but typically, the user does
    not implement new transports; rather, the platform provides some
    useful transports that are implemented using the platform's best
    practices.

    The user never instantiates a transport directly; they call a
    utility function, passing it a protocol factory and other
    information necessary to create the transport and protocol.  (E.g.
    EventLoop.create_connection() or EventLoop.create_server().)

    The utility function will asynchronously create a transport and a
    protocol and hook them up by calling the protocol's
    connection_made() method, passing it the transport.

    The implementation here raises NotImplemented for every method
    except writelines(), which calls write() in a loop.
    N)rrrrrrrr
r�sc@s"eZdZdZddd�Zdd�ZdS)rz(Interface for datagram (UDP) transports.NcCst�dS)aSend data to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        addr is target socket address.
        If addr is None use target address pointed on transport creation.
        N)r)r
r#Zaddrrrr
�sendto�szDatagramTransport.sendtocCst�dS)z�Close the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        N)r)r
rrr
r(�szDatagramTransport.abort)N)rrrrr)r(rrrr
r�s

c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rcCst�dS)zGet subprocess id.N)r)r
rrr
�get_pid�szSubprocessTransport.get_pidcCst�dS)z�Get subprocess returncode.

        See also
        http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode
        N)r)r
rrr
�get_returncode�sz"SubprocessTransport.get_returncodecCst�dS)z&Get transport for pipe with number fd.N)r)r
�fdrrr
�get_pipe_transport�sz&SubprocessTransport.get_pipe_transportcCst�dS)z�Send signal to subprocess.

        See also:
        docs.python.org/3/library/subprocess#subprocess.Popen.send_signal
        N)r)r
�signalrrr
�send_signal�szSubprocessTransport.send_signalcCst�dS)aLStop the subprocess.

        Alias for close() method.

        On Posix OSs the method sends SIGTERM to the subprocess.
        On Windows the Win32 API function TerminateProcess()
         is called to stop the subprocess.

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate
        N)r)r
rrr
�	terminate�szSubprocessTransport.terminatecCst�dS)z�Kill the subprocess.

        On Posix OSs the function sends SIGKILL to the subprocess.
        On Windows kill() is an alias for terminate().

        See also:
        http://docs.python.org/3/library/subprocess#subprocess.Popen.kill
        N)r)r
rrr
�kill�s	zSubprocessTransport.killN)	rrrr*r+r-r/r0r1rrrr
r�scsVeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	dd�Z
�ZS)�_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class.

    The subclass must implement get_write_buffer_size().  It must call
    _maybe_pause_protocol() whenever the write buffer size increases,
    and _maybe_resume_protocol() whenever it decreases.  It may also
    override set_write_buffer_limits() (e.g. to specify different
    defaults).

    The subclass constructor must call super().__init__(extra).  This
    will call set_write_buffer_limits().

    The user may call set_write_buffer_limits() and
    get_write_buffer_size(), and their protocol's pause_writing() and
    resume_writing() may be called.
    Ncs0t�j|�|dk	st�||_d|_|j�dS)NF)�superr�AssertionError�_loop�_protocol_paused�_set_write_buffer_limits)r
rZloop)�	__class__rr
r�s
z_FlowControlMixin.__init__cCsp|j�}||jkrdS|jsld|_y|jj�Wn:tk
rj}z|jjd|||jd��WYdd}~XnXdS)NTzprotocol.pause_writing() failed)�message�	exception�	transportr)r"�_high_waterr6�	_protocolZ
pause_writing�	Exceptionr5�call_exception_handler)r
�size�excrrr
�_maybe_pause_protocol�s
z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j�|jkrdd|_y|jj�Wn:tk
rb}z|jjd|||jd��WYdd}~XnXdS)NFz protocol.resume_writing() failed)r9r:r;r)r6r"�
_low_waterr=Zresume_writingr>r5r?)r
rArrr
�_maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs|j|jfS)N)rCr<)r
rrr
�get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f��||_||_dS)N�@i�rz*high (%r) must be >= low (%r) must be >= 0i)�
ValueErrorr<rC)r
rr rrr
r7sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d�|j�dS)N)rr )r7rB)r
rr rrr
r!-sz)_FlowControlMixin.set_write_buffer_limitscCst�dS)N)r)r
rrr
r"1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN)rrrrrrBrDrEr7r!r"�
__classcell__rr)r8r
r2�s

r2N)rZasyncior�__all__rrrrrrr2rrrr
�<module>s
#D4PK=�\�����log.cpython-36.opt-1.pycnu�[���3


 \|�@sdZddlZeje�ZdS)zLogging configuration.�N)�__doc__ZloggingZ	getLogger�__package__Zlogger�rr�#/usr/lib64/python3.6/asyncio/log.py�<module>sPK=�\�����log.cpython-36.pycnu�[���3


 \|�@sdZddlZeje�ZdS)zLogging configuration.�N)�__doc__ZloggingZ	getLogger�__package__Zlogger�rr�#/usr/lib64/python3.6/asyncio/log.py�<module>sPK=�\�����compat.cpython-36.pycnu�[���3


 \�@s6dZddlZejd	kZejd
kZejdkZdd�ZdS)z8Compatibility helpers for the different Python versions.�N����cCstsdd�|D�}dj|�S)z-Concatenate a sequence of bytes-like objects.css$|]}t|t�rt|�n|VqdS)N)�
isinstance�
memoryview�bytes)�.0�data�r�&/usr/lib64/python3.6/asyncio/compat.py�	<genexpr>sz%flatten_list_bytes.<locals>.<genexpr>�)�PY34�join)Zlist_of_datarrr�flatten_list_bytes
sr)rr)rr)rrr)�__doc__�sys�version_inforZPY35ZPY352rrrrr�<module>s



PK=�\�%�O�S�Swindows_events.cpython-36.pycnu�[���3


 \�l�@s�dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddddgZdZdZdZdZdZdZGdd�de
j�ZGdd�de
j�ZGdd�de�ZGdd�de�ZGdd �d e �Z!Gd!d"�d"ej"�Z#Gd#d�dej$�Z%Gd$d�d�Z&Gd%d&�d&e	j'�Z(e#Z)Gd'd(�d(ej*�Z+e+Z,dS))z.Selector and proactor event loops for Windows.�N�)�events)�base_subprocess)�futures)�proactor_events)�selector_events)�tasks)�
windows_utils)�_overlapped)�	coroutine)�logger�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicyl��i�i�g����MbP?g�������?cs^eZdZdZdd��fdd�
Z�fdd�Zdd	�Z�fd
d�Z�fdd
�Z�fdd�Z	�Z
S)�_OverlappedFuturez�Subclass of Future which represents an overlapped operation.

    Cancelling it will immediately cancel the overlapped operation.
    N)�loopcs&t�j|d�|jr|jd=||_dS)N)rr���)�super�__init__�_source_traceback�_ov)�self�ovr)�	__class__��./usr/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@t�j�}|jdk	r<|jjr dnd}|jdd||jjf�|S)N�pendingZ	completedrzoverlapped=<%s, %#x>)r�
_repr_inforr�insert�address)r�info�state)rrrr3s


z_OverlappedFuture._repr_infocCsr|jdkrdSy|jj�WnJtk
rf}z.d||d�}|jrJ|j|d<|jj|�WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)�message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextrrr�_cancel_overlapped:s

z$_OverlappedFuture._cancel_overlappedcs|j�t�j�S)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcst�j|�|j�dS)N)r�
set_exceptionr-)rr$)rrrr.Nsz_OverlappedFuture.set_exceptioncst�j|�d|_dS)N)r�
set_resultr)r�result)rrrr/Rsz_OverlappedFuture.set_result)�__name__�
__module__�__qualname__�__doc__rrr-r'r.r/�
__classcell__rr)rrr'srcsneZdZdZdd��fdd�
Zdd�Z�fdd	�Zd
d�Zdd
�Z�fdd�Z	�fdd�Z
�fdd�Z�ZS)�_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.N)rcs8t�j|d�|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jd�tjkS)Nr)�_winapiZWaitForSingleObjectr7Z
WAIT_OBJECT_0)rrrr�_pollhsz_BaseWaitHandleFuture._pollcs\t�j�}|jd|j�|jdk	r>|j�r0dnd}|j|�|jdk	rX|jd|j�|S)Nz
handle=%#xZsignaledZwaitingzwait_handle=%#x)rr�appendr7r=r8)rr!r")rrrrms



z _BaseWaitHandleFuture._repr_infocCs
d|_dS)N)r)r�futrrr�_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs�|js
dSd|_|j}d|_ytj|�WnZtk
r�}z>|jtjkrtd||d�}|jrd|j|d<|jj	|�dSWYdd}~XnX|j
d�dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r
ZUnregisterWaitr(�winerror�ERROR_IO_PENDINGrr)r*r@)rr;r+r,rrr�_unregister_wait|s"
z&_BaseWaitHandleFuture._unregister_waitcs|j�t�j�S)N)rCrr')r)rrrr'�sz_BaseWaitHandleFuture.cancelcs|j�t�j|�dS)N)rCrr.)rr$)rrrr.�sz#_BaseWaitHandleFuture.set_exceptioncs|j�t�j|�dS)N)rCrr/)rr0)rrrr/�sz _BaseWaitHandleFuture.set_result)
r1r2r3r4rr=rr@rCr'r.r/r5rr)rrr6Ws
r6csFeZdZdZdd��fdd�
Zdd�Z�fdd	�Z�fd
d�Z�ZS)�_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a
    _WaitHandleFuture using an event.
    N)rcst�j||||d�d|_dS)N)r)rr�_done_callback)rr�eventr;r)rrrr�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeError)rrrrr'�sz_WaitCancelFuture.cancelcs$t�j|�|jdk	r |j|�dS)N)rr/rE)rr0)rrrr/�s
z_WaitCancelFuture.set_resultcs$t�j|�|jdk	r |j|�dS)N)rr.rE)rr$)rrrr.�s
z_WaitCancelFuture.set_exception)	r1r2r3r4rr'r/r.r5rr)rrrD�s
rDcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureN)rcs<t�j||||d�||_d|_tjdddd�|_d|_dS)N)rTF)rr�	_proactorZ_unregister_proactorr
ZCreateEvent�_event�
_event_fut)rrr:r;�proactorr)rrrr�s
z_WaitHandleFuture.__init__csF|jdk	r"tj|j�d|_d|_|jj|j�d|_t�j|�dS)N)	rJr<�CloseHandlerKrI�_unregisterrrr@)rr?)rrrr@�s
	z%_WaitHandleFuture._unregister_wait_cbcCs�|js
dSd|_|j}d|_ytj||j�WnZtk
r�}z>|jtjkrxd||d�}|jrh|j|d<|j	j
|�dSWYdd}~XnX|jj|j|j
�|_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r
ZUnregisterWaitExrJr(rArBrr)r*rI�_wait_cancelr@rK)rr;r+r,rrrrC�s$

z"_WaitHandleFuture._unregister_wait)r1r2r3rr@rCr5rr)rrrH�srHc@s<eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZeZ	dS)
�
PipeServerzXClass representing a pipe server.

    This is much like a bound, listening socket.
    cCs,||_tj�|_d|_d|_|jd�|_dS)NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr rrrr�s

zPipeServer.__init__cCs|j|jd�}|_|S)NF)rUrW)r�tmprrr�_get_unconnected_pipe�sz PipeServer._get_unconnected_pipec	Csr|j�rdStjtjB}|r&|tjO}tj|j|tjtjBtj	Btj
tjtjtj
tj�}tj|�}|jj|�|S)N)�closedr<ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr	ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerT�add)r�first�flags�h�piperrrrWs


zPipeServer._server_pipe_handlecCs
|jdkS)N)rQ)rrrrrZszPipeServer.closedcCsV|jdk	r|jj�d|_|jdk	rRx|jD]}|j�q,Wd|_d|_|jj�dS)N)rVr'rQrT�closerU�clear)rrarrrrbs


zPipeServer.closeN)
r1r2r3r4rrYrWrZrb�__del__rrrrrP�s
rPc@seZdZdZdd�ZdS)�_WindowsSelectorEventLoopz'Windows version of selector event loop.cCstj�S)N)r	�
socketpair)rrrr�_socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre(srecsPeZdZdZd
�fdd�	Zdd�Zedd��Zed	d
��Zeddd��Z	�Z
S)rz2Windows version of proactor event loop using IOCP.Ncs|dkrt�}t�j|�dS)N)rrr)rrL)rrrr2szProactorEventLoop.__init__cCstj�S)N)r	rf)rrrrrg7szProactorEventLoop._socketpairccs8|jj|�}|EdH}|�}|j||d|id�}||fS)N�addr)�extra)rI�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr �fra�protocol�transrrr�create_pipe_connection:s
z(ProactorEventLoop.create_pipe_connectioncs.t���d�����fdd�	��j���gS)Ncsd}yj|rL|j�}�jj|��j�r2|j�dS��}�j||d�id��j�}|dkr`dS�jj|�}Wn�t	k
r�}zH|r�|j
�d	kr��jd||d��|j�n�jr�t
jd|dd�WYdd}~Xn2tjk
r�|r�|j�YnX|�_|j��dS)
Nrh)rirzPipe accept failed)r#r$razAccept pipe failed on pipe %rT)�exc_infor)r0rT�discardrZrbrkrYrI�accept_piper(�filenor*Z_debugrZwarningr�CancelledErrorrV�add_done_callback)rmrarnr+)r �loop_accept_piperlr�serverrrrwGs<

z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rPZ	call_soon)rrlr r)r rwrlrrxr�start_serving_pipeCs(
z$ProactorEventLoop.start_serving_pipec	ks�|j�}
t||||||||f|
|d�|	��}y|
EdHWn&tk
r`}z
|}
WYdd}~XnXd}
|
dk	r�|j�|j�EdH|
�|S)N)�waiterri)�
create_future�_WindowsSubprocessTransport�	ExceptionrbZ_wait)rrn�args�shell�stdin�stdout�stderr�bufsizeri�kwargsrzZtranspr+�errrrr�_make_subprocess_transportrs

z,ProactorEventLoop._make_subprocess_transport)N)N)r1r2r3r4rrgrrpryr�r5rr)rrr/s	/c@s�eZdZdZd1dd�Zdd�Zdd�Zd2d
d�Zdd
�Zd3dd�Z	d4dd�Z
dd�Zdd�Zdd�Z
edd��Zd5dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd6d)d*�Zd+d,�Zd-d.�Zd/d0�Zd	S)7rz#Proactor implementation using IOCP.���cCsDd|_g|_tjtjtd|�|_i|_tj	�|_
g|_tj	�|_dS)Nr)
r)�_resultsr
�CreateIoCompletionPort�INVALID_HANDLE_VALUEr[�_iocp�_cacherRrSr9�
_unregistered�_stopped_serving)rZconcurrencyrrrr�s
zIocpProactor.__init__cCsd|jjt|j�t|j�fS)Nz<%s overlapped#=%s result#=%s>)rr1�lenr�r�)rrrr�__repr__�szIocpProactor.__repr__cCs
||_dS)N)r))rrrrr�set_loop�szIocpProactor.set_loopNcCs |js|j|�|j}g|_|S)N)r�r=)r�timeoutrXrrr�select�s

zIocpProactor.selectcCs|jj�}|j|�|S)N)r)r{r/)r�valuer?rrr�_result�s

zIocpProactor._resultrcCsz|j|�tjt�}y4t|tj�r6|j|j�||�n|j|j�|�Wnt	k
rb|j
d�SXdd�}|j|||�S)N�cSsJy|j�Stk
rD}z |jtjkr2t|j��n�WYdd}~XnXdS)N)�	getresultr(rAr
�ERROR_NETNAME_DELETED�ConnectionResetErrorr~)ro�keyrr+rrr�finish_recv�sz&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocpr
�
Overlappedr[�
isinstance�socketZWSARecvrtZReadFile�BrokenPipeErrorr��	_register)r�conn�nbytesr_rr�rrr�recv�s

	zIocpProactor.recvcCsZ|j|�tjt�}t|tj�r4|j|j�||�n|j|j�|�dd�}|j	|||�S)NcSsJy|j�Stk
rD}z |jtjkr2t|j��n�WYdd}~XnXdS)N)r�r(rAr
r�r�r~)ror�rr+rrr�finish_send�sz&IocpProactor.send.<locals>.finish_send)
r�r
r�r[r�r�ZWSASendrtZ	WriteFiler�)rr��bufr_rr�rrr�send�s

	zIocpProactor.sendcsz|j��|j�j��tjt�}|j�j��j����fdd�}tdd��}|j	|�|�}||��}t
j||jd�|S)NcsD|j�tjd�j��}�jtjtj|��j	�j
����j�fS)Nz@P)r��structZpackrt�
setsockoptr��
SOL_SOCKETr
ZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)ror�rr�)r��listenerrr�
finish_accept�s
z*IocpProactor.accept.<locals>.finish_acceptcss4y|EdHWn tjk
r.|j��YnXdS)N)rrurb)r%r�rrr�accept_coro�s
z(IocpProactor.accept.<locals>.accept_coro)r)
r��_get_accept_socket�familyr
r�r[ZAcceptExrtrr�rZ
ensure_futurer))rr�rr�r�r%�coror)r�r�r�accept�s

		
zIocpProactor.acceptcs�|j��ytj�j��j�WnBtk
rb}z&|jtjkr@��j	�ddkrR�WYdd}~XnXtj
t�}|j�j�|��fdd�}|j
|�|�S)Nrrcs|j��jtjtjd��S)Nr)r�r�r�r�r
ZSO_UPDATE_CONNECT_CONTEXT)ror�r)r�rr�finish_connects
z,IocpProactor.connect.<locals>.finish_connect)r�r
Z	BindLocalrtr�r(rA�errnoZ	WSAEINVALZgetsocknamer�r[Z	ConnectExr�)rr�r �err�r)r�r�connect�s

zIocpProactor.connectcsJ|j��tjt�}|j�j��}|r0|j��S�fdd�}|j|�|�S)Ncs|j��S)N)r�)ror�r)rarr�finish_accept_pipesz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�r
r�r[ZConnectNamedPipertr�r�)rrarZ	connectedr�r)rarrs
s


zIocpProactor.accept_pipeccszt}xjytj|�}PWn0tk
rF}z|jtjkr6�WYdd}~XnXt|dt�}tj	||j
d�EdHqWtj|�S)N�)r)
�CONNECT_PIPE_INIT_DELAYr
ZConnectPiper(rAZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYrZsleepr)r	r\)rr Zdelayr:r+rrrrjs
zIocpProactor.connect_pipecCs|j||d�S)z�Wait for a handle.

        Return a Future object. The result of the future is True if the wait
        completed, or False if the wait did not complete (on timeout).
        F)�_wait_for_handle)rr:r�rrr�wait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd�}||_|S)NT)r�rE)rrFZ
done_callbackr?rrrrO7szIocpProactor._wait_cancelcs�|dkrtj}ntj|d�}tjt�}tj||j|j	|�}|rTt
||||jd��nt|||||jd���j
rv�j
d=�fdd�}�|d|f|j|j	<�S)Ng@�@)rrcs�j�S)N)r=)ror�r)rmrr�finish_wait_for_handleRsz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handlerr)r<�INFINITE�math�ceilr
r�r[ZRegisterWaitWithQueuer�r rDr)rHrr�)rr:r�Z
_is_cancel�msrr;r�r)rmrr�>s


	zIocpProactor._wait_for_handlecCs0||jkr,|jj|�tj|j�|jdd�dS)Nr)r9r]r
r�rtr�)r�objrrrr�^s
z IocpProactor._register_with_iocpcCs�t||jd�}|jr|jd=|jsjy|dd|�}Wn,tk
r^}z|j|�WYdd}~XnX|j|�||||f|j|j<|S)N)rrr)	rr)rrr(r.r/r�r )rrr��callbackrmr�r�rrrr�hs

zIocpProactor._registercCs|jj|�dS)a
Unregister an overlapped object.

        Call this method when its future has been cancelled. The event can
        already be signalled (pending in the proactor event queue). It is also
        safe if the event is never signalled (because it was cancelled).
        N)r�r>)rrrrrrN�szIocpProactor._unregistercCstj|�}|jd�|S)Nr)r�r�)rr��srrrr��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��ntj|d�}|tkr>td���xtj|j|�}|dkrZPd}|\}}}}y|jj|�\}}	}
}WnVt	k
r�|j
j�r�|j
jdd||||fd��|dtj
fkr�tj|�wBYnX|
|jkr�|j�qB|j�sBy||||	�}Wn:tk
�r@}
z|j|
�|jj|�WYdd}
~
XqBX|j|�|jj|�qBWx |jD]}	|jj|	jd��qdW|jj�dS)Nrznegative timeoutg@�@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#�status)r��
ValueErrorr�r�r
ZGetQueuedCompletionStatusr�r��pop�KeyErrorr)Z	get_debugr*r�r<rMr�r'�doner(r.r�r>r/r�r rc)rr�r�r�r�Ztransferredr�r rmrr�r�r�r�rrrr=�sJ






zIocpProactor._pollcCs|jj|�dS)N)r�r])rr�rrr�
_stop_serving�szIocpProactor._stop_servingcCs�x�t|jj��D]�\}\}}}}|j�r*qt|t�r6qy|j�Wqtk
r�}z8|jdk	r�d||d�}|j	rz|j	|d<|jj
|�WYdd}~XqXqWx|jr�|jd�s�tj
d�q�Wg|_|jdk	r�tj|j�d|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)�listr��itemsZ	cancelledr�rDr'r(r)rr*r=r�debugr�r�r<rM)rr r?rr�r�r+r,rrrrb�s, 


"

zIocpProactor.closecCs|j�dS)N)rb)rrrrrd�szIocpProactor.__del__)r�)N)r)r)N)N)r1r2r3r4rr�r�r�r�r�r�r�r�rsrrjr�rOr�r�r�rNr�r=r�rbrdrrrrr�s.





 
	
7 c@seZdZdd�ZdS)r|c
sPtj|f|||||d�|���_�fdd�}�jjjt�jj��}	|	j|�dS)N)rr�r�r�r�cs�jj�}�j|�dS)N)�_procZpollZ_process_exited)rm�
returncode)rrrr��s
z4_WindowsSubprocessTransport._start.<locals>.callback)	r	�Popenr�r)rIr��intr7rv)
rr~rr�r�r�r�r�r�rmr)rr�_start�sz"_WindowsSubprocessTransport._startN)r1r2r3r�rrrrr|�sr|c@seZdZeZdS)�_WindowsDefaultEventLoopPolicyN)r1r2r3r
Z
_loop_factoryrrrrr�sr�)-r4r<r�r�r�r�rR�rrrrrrr	r
Z
coroutinesr�logr�__all__r[r�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerr6rDrH�objectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r
ZBaseDefaultEventLoopPolicyr�rrrrr�<module>sL0J4;]kPK=�\$��dvv unix_events.cpython-36.opt-1.pycnu�[���3


 \���
@s dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZddlmZdddddgZejdkr�ed��dd�Zy
ejZWnek
�r,dd�ZYnXGdd�dej�Z e!ed��rVdd�Z"nddl#Z#d d�Z"Gd!d"�d"ej$�Z%Gd#d$�d$ej&ej'�Z(e!ed%��r�ej)Z*nddl#Z#d&d'�Z*Gd(d)�d)ej+�Z,Gd*d�d�Z-Gd+d,�d,e-�Z.Gd-d�de.�Z/Gd.d�de.�Z0Gd/d0�d0ej1�Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.�N�)�base_events)�base_subprocess)�compat)�	constants)�
coroutines)�events)�futures)�selector_events)�	selectors)�
transports)�	coroutine)�logger�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N�)�signum�framerr�+/usr/lib64/python3.6/asyncio/unix_events.py�_sighandler_noop%srcCs|S)Nr)�pathrrr�<lambda>.srcs�eZdZdZd"�fdd�	Zdd�Z�fdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd#dd�Zd$dd�Z
ed%dd��Zdd�Zedddd�dd��Zed&dddd�d d!��Z�ZS)'�_UnixSelectorEventLoopzdUnix event loop.

    Adds signal handling and UNIX Domain Socket support to SelectorEventLoop.
    Ncst�j|�i|_dS)N)�super�__init__�_signal_handlers)�self�selector)�	__class__rrr7sz_UnixSelectorEventLoop.__init__cCstj�S)N)�socketZ
socketpair)rrrr�_socketpair;sz"_UnixSelectorEventLoop._socketpaircs^t�j�tj�s2xFt|j�D]}|j|�qWn(|jrZtjd|�d�t	|d�|jj
�dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)�source)r�close�sys�
is_finalizing�listr�remove_signal_handler�warnings�warn�ResourceWarning�clear)r�sig)r!rrr%>s
z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|�qWdS)N)�_handle_signal)r�datarrrr�_process_self_dataLs
z)_UnixSelectorEventLoop._process_self_datac+GsHtj|�stj|�rtd��|j|�|j�ytj|jj	��Wn2t
tfk
rt}ztt
|���WYdd}~XnXtj|||�}||j|<ytj|t�tj|d�Wn�tk
�rB}zz|j|=|j�sytjd�Wn4t
tfk
�r}ztjd|�WYdd}~XnX|jtjk�r0tdj|���n�WYdd}~XnXdS)z�Add a handler for a signal.  UNIX only.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        z3coroutines cannot be used with add_signal_handler()NFrzset_wakeup_fd(-1) failed: %szsig {} cannot be caught���)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signalZ
_check_closed�signal�
set_wakeup_fdZ_csock�fileno�
ValueError�OSError�RuntimeError�strrZHandlerr�siginterruptr�info�errno�EINVAL�format)rr.�callback�args�exc�handleZnexcrrr�add_signal_handlerSs0



z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|�}|dkrdS|jr*|j|�n
|j|�dS)z2Internal helper that is the actual signal handler.N)r�getZ
_cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/�sz%_UnixSelectorEventLoop._handle_signalc&Cs�|j|�y|j|=Wntk
r*dSX|tjkr>tj}ntj}ytj||�Wn@tk
r�}z$|jtj	kr�t
dj|���n�WYdd}~XnX|js�ytjd�Wn2t
tfk
r�}ztjd|�WYdd}~XnXdS)zwRemove a handler for a signal.  UNIX only.

        Return True if a signal handler was removed, False if not.
        Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr2)r4r�KeyErrorr5�SIGINT�default_int_handler�SIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)�s(

z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|t�stdj|���d|ko,tjknsDtdj|tj���dS)z�Internal helper to validate a signal.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        zsig must be an int, not {!r}rzsig {} out of range(1, {})N)�
isinstance�intr3r@r5�NSIGr8)rr.rrrr4�s

z$_UnixSelectorEventLoop._check_signalcCst|||||�S)N)�_UnixReadPipeTransport)r�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�S)N)�_UnixWritePipeTransport)rrOrPrQrRrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc	ks�tj���}
|j�}t||||||||f||d�|	��}|
j|j�|j|�y|EdHWn&tk
r~}
z
|
}WYdd}
~
XnXd}|dk	r�|j�|j	�EdH|�WdQRX|S)N)rQrR)
r�get_child_watcherZ
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�	Exceptionr%Z_wait)rrPrB�shell�stdin�stdout�stderr�bufsizerR�kwargs�watcherrQ�transprC�errrrr�_make_subprocess_transport�s$




z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|�dS)N)Zcall_soon_threadsafeZ_process_exited)r�pid�
returncoderbrrrrY�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostnameccs�|r|dkr&td��n|dk	r&td��|dk	r�|dk	r>td��tjtjtjd�}y |jd�|j||�EdHWq�|j��Yq�XnB|dkr�td��|jtjks�tj	|j
�r�tdj|���|jd�|j||||�EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r})
r8r"�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr%�familyr�_is_stream_socket�typer@Z_create_connection_transport)r�protocol_factoryrrgrhri�	transportrPrrr�create_unix_connection�s8


z-_UnixSelectorEventLoop.create_unix_connection�d)rh�backlogrgc
!Cs�t|t�rtd��|dk	�r0|dk	r,td��t|�}tjtjtj�}|dd
kr�y tj	t
j|�j�rnt
j|�WnBt
k
r�Yn0tk
r�}ztjd||�WYdd}~XnXy|j|�Wnjtk
�r}z8|j�|jtjk�rdj|�}ttj|�d�n�WYdd}~Xn|j��YnXn>|dk�rBtd��|jtjk�s`tj|j��rntdj|���tj||g�}	|j|�|jd	�|j||||	�|	S)Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timer�z2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rru)rK�boolr3r8�_fspathr"rjrk�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr9r�errorZbindr%r>Z
EADDRINUSEr@rmrrnroZServerZlistenrlZ_start_serving)
rrprrhrtrgrcrC�msgZserverrrr�create_unix_serversP

 




z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)�__name__�
__module__�__qualname__�__doc__rr#r%r1rEr/r)r4rSrUr
rdrYrrr��
__classcell__rr)r!rr1s,-
 


%r�set_blockingcCstj|d�dS)NF)rzr�)�fdrrr�_set_nonblockingBsr�cCs,tj|tj�}|tjB}tj|tj|�dS)N)�fcntlZF_GETFLrz�
O_NONBLOCKZF_SETFL)r��flagsrrrr�Gs
cs�eZdZdZd �fdd�	Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
jrhdd�Zd!dd�Zdd�Zdd�Z�ZS)"rN�iNcs�t�j|�||jd<||_||_|j�|_||_d|_t	j
|j�j}tj
|�pbtj|�pbtj|�s~d|_d|_d|_td��t|j�|jj|jj|�|jj|jj|j|j�|dk	r�|jjtj|d�dS)NrOFz)Pipe transport is for pipes/sockets only.)rr�_extra�_loop�_piper7�_fileno�	_protocol�_closingrz�fstatr{rx�S_ISFIFOry�S_ISCHRr8r��	call_soon�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)r�looprOrPrQrR�mode)r!rrrQs,






z_UnixReadPipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�t|jdd�}|jdk	r�|dk	r�tj	||jt
j�}|r�|jd�q�|jd�n |jdk	r�|jd�n
|jd�dd	j|�S)
N�closed�closingzfd=%s�	_selector�polling�idle�openz<%s>� )
r!r�r��appendr�r��getattrr�r
�_test_selector_eventrZ
EVENT_READ�join)rr=r r�rrr�__repr__ns$




z_UnixReadPipeTransport.__repr__cCs�ytj|j|j�}WnDttfk
r,Yn�tk
rX}z|j|d�WYdd}~Xn^X|rl|jj	|�nJ|j
j�r�tj
d|�d|_|j
j|j�|j
j|jj�|j
j|jd�dS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rz�readr��max_size�BlockingIOError�InterruptedErrorr9�_fatal_errorr�Z
data_receivedr��	get_debugrr=r��_remove_readerr�Zeof_received�_call_connection_lost)rr0rCrrrr��s
z"_UnixReadPipeTransport._read_readycCs|jj|j�dS)N)r�r�r�)rrrr�
pause_reading�sz$_UnixReadPipeTransport.pause_readingcCs|jj|j|j�dS)N)r�r�r�r�)rrrr�resume_reading�sz%_UnixReadPipeTransport.resume_readingcCs
||_dS)N)r�)rrPrrr�set_protocol�sz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r�)rrrr�get_protocol�sz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r�)rrrr�
is_closing�sz!_UnixReadPipeTransport.is_closingcCs|js|jd�dS)N)r��_close)rrrrr%�sz_UnixReadPipeTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)r$)r�r*r+r,r%)rrrr�__del__�s
z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r4|jtjkr4|jj�rLtjd||dd�n|jj||||j	d��|j
|�dS)Nz%r: %sT)�exc_info)�message�	exceptionrqrP)rKr9r>ZEIOr�r�r�debug�call_exception_handlerr�r�)rrCr�rrrr��s
z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j�|jj|j|�dS)NT)r�r�r�r�r�r�)rrCrrrr��sz_UnixReadPipeTransport._closecCs4z|jj|�Wd|jj�d|_d|_d|_XdS)N)r��connection_lostr�r%r�)rrCrrrr��s
z,_UnixReadPipeTransport._call_connection_losti)NN)r�)r�r�r�r�rr�r�r�r�r�r�r�r%r�PY34r�r�r�r�r�rr)r!rrNMs
rNcs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejr|dd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rTNc
s�t�j||�||jd<||_|j�|_||_t�|_d|_	d|_
tj|j�j
}tj|�}tj|�}tj|�}	|px|px|	s�d|_d|_d|_td��t|j�|jj|jj|�|	s�|r�tjjd�r�|jj|jj|j|j�|dk	r�|jjtj|d�dS)NrOrFz?Pipe transport is only for pipes, sockets and character devices�aix)rrr�r�r7r�r��	bytearray�_buffer�
_conn_lostr�rzr�r{rxr�r�ryr8r�r�r�r�r&�platform�
startswithr�r�r	r�)
rr�rOrPrQrRr�Zis_charZis_fifoZ	is_socket)r!rrr�s2






z _UnixWritePipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�t|jdd�}|jdk	r�|dk	r�tj	||jt
j�}|r�|jd�n
|jd�|j�}|jd|�n |jdk	r�|jd�n
|jd�d	d
j
|�S)Nr�r�zfd=%sr�r�r�z
bufsize=%sr�z<%s>r�)r!r�r�r�r�r�r�r�r
r�rZEVENT_WRITE�get_write_buffer_sizer�)rr=r r�r_rrrr��s(





z _UnixWritePipeTransport.__repr__cCs
t|j�S)N)�lenr�)rrrrr�sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jj�rtjd|�|jr*|jt��n|j�dS)Nz%r was closed by peer)r�r�rr=r�r��BrokenPipeError)rrrrr�s

z#_UnixWritePipeTransport._read_readycCst|t�rt|�}|sdS|js&|jrN|jtjkr<tjd�|jd7_dS|j	�s�yt
j|j|�}WnTt
tfk
r�d}Yn:tk
r�}z|jd7_|j|d�dSd}~XnX|t|�kr�dS|dkr�t|�|d�}|jj|j|j�|j	|7_	|j�dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rKr��
memoryviewr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�rz�writer�r�r�rZr�r�r�Z_add_writer�_write_readyZ_maybe_pause_protocol)rr0�nrCrrrr�s2

z_UnixWritePipeTransport.writecCs�ytj|j|j�}Wnjttfk
r,Yn�tk
r~}z8|jj�|jd7_|j	j
|j�|j|d�WYdd}~XnfX|t|j�kr�|jj�|j	j
|j�|j
�|jr�|j	j|j�|jd�dS|dkr�|jd|�=dS)Nrz#Fatal write error on pipe transportr)rzr�r�r�r�r�rZr-r�r��_remove_writerr�r�Z_maybe_resume_protocolr�r�r�)rr�rCrrrr�>s&


z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr�
can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCs8|jr
dSd|_|js4|jj|j�|jj|jd�dS)NT)r�r�r�r�r�r�r�)rrrr�	write_eof[sz!_UnixWritePipeTransport.write_eofcCs
||_dS)N)r�)rrPrrrr�dsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r�)rrrrr�gsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r�)rrrrr�jsz"_UnixWritePipeTransport.is_closingcCs|jdk	r|jr|j�dS)N)r�r�r�)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)r$)r�r*r+r,r%)rrrrr�vs
z_UnixWritePipeTransport.__del__cCs|jd�dS)N)r�)rrrr�abort|sz_UnixWritePipeTransport.abort�Fatal error on pipe transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)r�)r�r�rqrP)
rKrZ_FATAL_ERROR_IGNOREr�r�rr�r�r�r�)rrCr�rrrr�s
z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j�|jj�|jj|j�|jj|j|�dS)NT)	r�r�r�r�r�r-r�r�r�)rrCrrrr��s
z_UnixWritePipeTransport._closecCs4z|jj|�Wd|jj�d|_d|_d|_XdS)N)r�r�r�r%r�)rrCrrrr��s
z-_UnixWritePipeTransport._call_connection_lost)NN)r�)N)r�r�r�rr�r�r�r�r�r�r�r�r�r�r%rr�r�r�r�r�r�r�rr)r!rrT�s$%	!	

rT�set_inheritablecCsNttdd�}tj|tj�}|s4tj|tj||B�ntj|tj||@�dS)NZ
FD_CLOEXECr)r�r�ZF_GETFDZF_SETFD)r�ZinheritableZcloexec_flag�oldrrr�_set_inheritable�s
r�c@seZdZdd�ZdS)rWc		Ksvd}|tjkr*|jj�\}}t|j�d�tj|f||||d|d�|��|_|dk	rr|j�t	|j
�d|d�|j_dS)NF)r[r\r]r^Zuniversal_newlinesr_�wb)�	buffering)�
subprocess�PIPEr�r#r�r7�Popen�_procr%r��detachr\)	rrBr[r\r]r^r_r`Zstdin_wrrr�_start�s
z_UnixSubprocessTransport._startN)r�r�r�r�rrrrrW�srWc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)raHAbstract base class for monitoring child processes.

    Objects derived from this class monitor a collection of subprocesses and
    report their termination or interruption by a signal.

    New callbacks are registered with .add_child_handler(). Starting a new
    process must be done within a 'with' block to allow the watcher to suspend
    its activity until the new process if fully registered (this is needed to
    prevent a race condition in some implementations).

    Example:
        with watcher:
            proc = subprocess.Popen("sleep 1")
            watcher.add_child_handler(proc.pid, callback)

    Notes:
        Implementations of this class must be thread-safe.

        Since child watcher objects may catch the SIGCHLD signal and call
        waitpid(-1), there should be only one active object per process.
    cGs
t��dS)aRegister a new child handler.

        Arrange for callback(pid, returncode, *args) to be called when
        process 'pid' terminates. Specifying another callback for the same
        process replaces the previous handler.

        Note: callback() must be thread-safe.
        N)�NotImplementedError)rrerArBrrrrX�s	z&AbstractChildWatcher.add_child_handlercCs
t��dS)z�Removes the handler for process 'pid'.

        The function returns True if the handler was successfully removed,
        False if there was nothing to remove.N)r�)rrerrr�remove_child_handler�sz)AbstractChildWatcher.remove_child_handlercCs
t��dS)z�Attach the watcher to an event loop.

        If the watcher was previously attached to an event loop, then it is
        first detached before attaching to the new loop.

        Note: loop may be None.
        N)r�)rr�rrr�attach_loop�sz AbstractChildWatcher.attach_loopcCs
t��dS)zlClose the watcher.

        This must be called to make sure that any underlying resource is freed.
        N)r�)rrrrr%�szAbstractChildWatcher.closecCs
t��dS)zdEnter the watcher's context and allow starting new processes

        This function must return selfN)r�)rrrr�	__enter__szAbstractChildWatcher.__enter__cCs
t��dS)zExit the watcher's contextN)r�)r�a�b�crrr�__exit__	szAbstractChildWatcher.__exit__N)
r�r�r�r�rXr�r�r%r�r�rrrrr�s
c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dS)N)r��
_callbacks)rrrrrszBaseChildWatcher.__init__cCs|jd�dS)N)r�)rrrrr%szBaseChildWatcher.closecCs
t��dS)N)r�)r�expected_pidrrr�_do_waitpidszBaseChildWatcher._do_waitpidcCs
t��dS)N)r�)rrrr�_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCsf|jdk	r$|dkr$|jr$tjdt�|jdk	r<|jjtj�||_|dk	rb|jtj|j	�|j
�dS)NzCA loop is being detached from a child watcher with pending handlers)r�r�r*r+�RuntimeWarningr)r5�SIGCHLDrE�	_sig_chldr�)rr�rrrr�s
zBaseChildWatcher.attach_loopcCsFy|j�Wn4tk
r@}z|jjd|d��WYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handler)r�r�)r�rZr�r�)rrCrrrr�1szBaseChildWatcher._sig_chldcCs2tj|�rtj|�Stj|�r*tj|�S|SdS)N)rz�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)r�statusrrr�_compute_returncode=s



z$BaseChildWatcher._compute_returncodeN)
r�r�r�rr%r�r�r�r�r�rrrrr�sr�csPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)rad'Safe' child watcher implementation.

    This implementation avoids disrupting other code spawning processes by
    polling explicitly each process in the SIGCHLD handler instead of calling
    os.waitpid(-1).

    This is a safe solution but it has a significant overhead when handling a
    big number of children (O(n) each time SIGCHLD is raised)
    cs|jj�t�j�dS)N)r�r-rr%)r)r!rrr%Vs
zSafeChildWatcher.closecCs|S)Nr)rrrrr�ZszSafeChildWatcher.__enter__cCsdS)Nr)rr�r�r�rrrr�]szSafeChildWatcher.__exit__cGs.|jdkrtd��||f|j|<|j|�dS)NzICannot add child handler, the child watcher does not have a loop attached)r�r:r�r�)rrerArBrrrrX`s

z"SafeChildWatcher.add_child_handlercCs&y|j|=dStk
r dSXdS)NTF)r�rG)rrerrrr�ks
z%SafeChildWatcher.remove_child_handlercCs"xt|j�D]}|j|�qWdS)N)r(r�r�)rrerrrr�rsz SafeChildWatcher._do_waitpid_allcCs�ytj|tj�\}}Wn(tk
r>|}d}tjd|�Yn0X|dkrLdS|j|�}|jj�rntj	d||�y|j
j|�\}}Wn.tk
r�|jj�r�tjd|dd�YnX|||f|��dS)N�z8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rT)r�)
rz�waitpid�WNOHANG�ChildProcessErrorrr�r�r�r�r�r��poprG)rr�rer�rfrArBrrrr�ws*


zSafeChildWatcher._do_waitpid)r�r�r�r�r%r�r�rXr�r�r�r�rr)r!rrKs	csTeZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)raW'Fast' child watcher implementation.

    This implementation reaps every terminated processes by calling
    os.waitpid(-1) directly, possibly breaking other code spawning processes
    and waiting for their termination.

    There is no noticeable overhead when handling a big number of children
    (O(1) each time a child terminates).
    cs$t�j�tj�|_i|_d|_dS)Nr)rr�	threadingZLock�_lock�_zombies�_forks)r)r!rrr�s

zFastChildWatcher.__init__cs"|jj�|jj�t�j�dS)N)r�r-r�rr%)r)r!rrr%�s

zFastChildWatcher.closec
Cs$|j�|jd7_|SQRXdS)Nr)r�r�)rrrrr��szFastChildWatcher.__enter__c
CsV|j�:|jd8_|js$|jr(dSt|j�}|jj�WdQRXtjd|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)r�r�r�r;r-rr�)rr�r�r�Zcollateral_victimsrrrr��s
zFastChildWatcher.__exit__cGsl|jdkrtd��|j�:y|jj|�}Wn"tk
rL||f|j|<dSXWdQRX|||f|��dS)NzICannot add child handler, the child watcher does not have a loop attached)r�r:r�r�r�rGr�)rrerArBrfrrrrX�s
z"FastChildWatcher.add_child_handlercCs&y|j|=dStk
r dSXdS)NTF)r�rG)rrerrrr��s
z%FastChildWatcher.remove_child_handlercCs�x�ytjdtj�\}}Wntk
r,dSX|dkr:dS|j|�}|j�vy|jj|�\}}WnBtk
r�|j	r�||j
|<|jj�r�t
jd||�wd}YnX|jj�r�t
jd||�WdQRX|dkr�t
jd||�q|||f|��qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr2)rzr�r�r�r�r�r�r�rGr�r�r�r�rr�r�)rrer�rfrArBrrrr��s6





z FastChildWatcher._do_waitpid_all)r�r�r�r�rr%r�r�rXr�r�r�rr)r!rr�s	csHeZdZdZeZ�fdd�Zdd�Z�fdd�Zdd	�Z	d
d�Z
�ZS)�_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cst�j�d|_dS)N)rr�_watcher)r)r!rrrs
z$_UnixDefaultEventLoopPolicy.__init__c
CsHtj�8|jdkr:t�|_ttj�tj�r:|jj|j	j
�WdQRXdS)N)rr�r�rrKr��current_thread�_MainThreadr��_localr�)rrrr�
_init_watchers
z)_UnixDefaultEventLoopPolicy._init_watchercs6t�j|�|jdk	r2ttj�tj�r2|jj|�dS)z�Set the event loop.

        As a side effect, if a child watcher was set before, then calling
        .set_event_loop() from the main thread will call .attach_loop(loop) on
        the child watcher.
        N)r�set_event_loopr�rKr�r�rr�)rr�)r!rrrs
z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j�|jS)zzGet the watcher for child processes.

        If not yet set, a SafeChildWatcher object is automatically created.
        N)r�r)rrrrrV&s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk	r|jj�||_dS)z$Set the watcher for child processes.N)r�r%)rrarrr�set_child_watcher0s

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�r�rZ
_loop_factoryrrrrVrr�rr)r!rr�s
r�)5r�r>rzr5r"rxr�r&r�r*�rrrrrrr	r
rrr
�logr�__all__r��ImportErrorr�fspathrw�AttributeErrorZBaseSelectorEventLoopr�hasattrr�r�Z
ReadTransportrNZ_FlowControlMixinZWriteTransportrTr�r�ZBaseSubprocessTransportrWrr�rrZBaseDefaultEventLoopPolicyr�rrrrrr�<module>sn


O
F=On2PK=�\4]�j!j!coroutines.cpython-36.pycnu�[���3


 \+�@s�dddgZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
l
mZejdZejjo�eejjd��ZyejZejZWnek
r�dZdZYnXy
ejZWnek
r�d
d�ZYnXyddlmZ m!Z"Wne#k
�r*dZ Z"YnXdd�Z$e$�Z%[$dd�Z&Gdd�d�Z'dd�Ze(�Z)dd�Zej*e'fZ+e dk	�r�e+e f7Z+edk	�r�efe+Z+dd�Z,dd�Z-dS)�	coroutine�iscoroutinefunction�iscoroutine�N�)�compat)�	constants)�events)�base_futures)�loggerZ
YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF�)�funcrr�*/usr/lib64/python3.6/asyncio/coroutines.py�<lambda>/sr)�	Coroutine�	AwaitablecCsFGdd�d�}dd�}d}|�}||�}t|�|j|�|j|fkS)	Nc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
z!has_yield_from_bug.<locals>.MyGencSs
d|_dS)N)�	send_args)�selfrrr
�__init__;sz*has_yield_from_bug.<locals>.MyGen.__init__cSs|S)Nr)rrrr
�__iter__=sz*has_yield_from_bug.<locals>.MyGen.__iter__cSsdS)N�*r)rrrr
�__next__?sz*has_yield_from_bug.<locals>.MyGen.__next__cWs
||_dS)N)r)rZwhatrrr
�sendAsz&has_yield_from_bug.<locals>.MyGen.sendN)�__name__�
__module__�__qualname__rrrrrrrr
�MyGen:srcss|EdHdS)Nr)�genrrr
�yield_from_genDsz*has_yield_from_bug.<locals>.yield_from_genr��)rrr)�nextrr)rr�valuer�cororrr
�has_yield_from_bug9s

r#cCs
t|d�S)N)�CoroWrapper)rrrr
�
debug_wrapperPsr%c@s�eZdZd%dd�Zdd�Zdd�Zdd	�Zer8d
d�Zndd�Zd&d
d�Z	dd�Z
edd��Zedd��Z
edd��Zejr�dd�Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zd#d$�ZdS)'r$NcCsZtj|�stj|�st|��||_||_tjtj	d��|_
t|dd�|_t|dd�|_
dS)Nrrr)�inspect�isgeneratorr�AssertionErrorrrr�
extract_stack�sys�	_getframe�_source_traceback�getattrrr)rrrrrr
r[szCoroWrapper.__init__cCs@t|�}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>���)�_format_coroutiner,�	__class__r)r�	coro_repr�framerrr
�__repr__cs

zCoroWrapper.__repr__cCs|S)Nr)rrrr
rjszCoroWrapper.__iter__cCs|jjd�S)N)rr)rrrr
rmszCoroWrapper.__next__cGsBtj�}|j}|jdkst�|jj|jtkr6|d}|jj	|�S)Nr)
r*r+�f_back�f_lastir(�f_code�co_code�_YIELD_FROMrr)rr!r2Zcallerrrr
ruszCoroWrapper.sendcCs|jj|�S)N)rr)rr!rrr
r}scCs|jj|||�S)N)r�throw)r�typer!�	tracebackrrr
r9�szCoroWrapper.throwcCs
|jj�S)N)r�close)rrrr
r<�szCoroWrapper.closecCs|jjS)N)r�gi_frame)rrrr
r=�szCoroWrapper.gi_framecCs|jjS)N)r�
gi_running)rrrr
r>�szCoroWrapper.gi_runningcCs|jjS)N)r�gi_code)rrrr
r?�szCoroWrapper.gi_codecCs,t|jdd�}|dk	r(tdj|j|���|S)N�cr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r-r�RuntimeError�format)rr@rrr
�	__await__�szCoroWrapper.__await__cCs|jjS)N)r�gi_yieldfrom)rrrr
rD�szCoroWrapper.gi_yieldfromcCs|jjS)N)rr@)rrrr
r@�szCoroWrapper.cr_awaitcCs|jjS)N)r�
cr_running)rrrr
rE�szCoroWrapper.cr_runningcCs|jjS)N)r�cr_code)rrrr
rF�szCoroWrapper.cr_codecCs|jjS)N)r�cr_frame)rrrr
rG�szCoroWrapper.cr_framecCs�t|dd�}t|dd�}|dkr,t|dd�}|dk	r�|jd
kr�d|}t|df�}|r�djtj|��}|dtj�d	�7}||j�7}tj	|�dS)Nrr=rGrz%r was never yielded fromr,�zB
Coroutine object created at (most recent call last, truncated to z last lines):
r.)
r-r5�joinr;�format_listrZDEBUG_STACK_DEPTH�rstripr
�error)rrr2�msg�tbrrr
�__del__�szCoroWrapper.__del__)N)NN)rrrrr3rr�_YIELD_FROM_BUGrr9r<�propertyr=r>r?rZPY35rCrDr@rErFrGrOrrrr
r$Xs(


r$cspt��r�Stj��r��ntj���fdd���tsNtdkrD�}qft��}ntj����fdd��}t|_|S)z�Decorator to mark coroutines.

    If the coroutine is not yielded from before it is destroyed,
    an error message is logged.
    c?sv�||�}tj|�s(tj|�s(t|t�r4|EdH}n>tdk	rry
|j}Wntk
rZYnXt|t�rr|�EdH}|S)N)	r	Zisfuturer&r'�
isinstancer$�
_AwaitableABCrC�AttributeError)�args�kw�resZ
await_meth)rrr
r"�s



zcoroutine.<locals>.coroNcs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)N)rrrrr.)r$r,r-rr)rU�kwds�w)r"rrr
�wrapper�szcoroutine.<locals>.wrapper)�_inspect_iscoroutinefunctionr&�isgeneratorfunction�	functools�wraps�_DEBUG�_types_coroutine�
_is_coroutine)rrZr)r"rr
r�s


cCst|dd�tkpt|�S)z6Return True if func is a decorated coroutine function.raN)r-rar[)rrrr
r�scCs
t|t�S)z)Return True if obj is a coroutine object.)rR�_COROUTINE_TYPES)�objrrr
rsc
Cs&t|�st�t|d�r�t|d�r�t|dt|dt|�j��}dj|�}d}y
|j}Wn4tk
r�y
|j	}Wntk
r�YnXYnX|r�dj|�S|Sd}t
|t�r�|j}|j
}|dk	r�dj|�}n|}|dkr�tj|fi�}d}t|d�o�|j�r|j}nt|d��r|j�r|j}d}t|d��r>|j�r>|j}nt|d	��rX|j�rX|j}d
}|�rp|j�rp|j}d}|}t
|t��r�tj|j��r�|jdk	�r�tj|j�}	|	dk	�r�|	\}}|dk�r�d|||f}nd
|||f}n:|dk	�r|j}d|||f}n|�r"|j}d|||f}|S)NrFr?rrz{}()Fz
{} runningrGr=z<empty co_filename>rz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)rr(�hasattrr-r:rrBrErTr>rRr$rrrZ_format_callbackrFr?rGr=�co_filenamer&r\Z_get_function_source�f_lineno�co_firstlineno)
r"Z	coro_nameZrunningrZ	coro_codeZ
coro_frame�filename�linenor1�sourcerrr
r/sz







r/).�__all__r]r&Zopcode�osr*r;�typesrHrrrr	�logr
Zopmapr8�flags�ignore_environment�bool�environ�getr_rr`�
CoroutineTypeZ_types_CoroutineTyperTrr[�collections.abcrZ
_CoroutineABCrrS�ImportErrorr#rPr%r$�objectra�
GeneratorTyperbrr/rrrr
�<module>sZ




j:




PK=�\	��[?[?test_utils.cpython-36.opt-2.pycnu�[���3


 \�:�
@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZddlmZmZyddlZWnek
r�dZYnXddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lm Z ddl!m"Z"ej#dk�rDddl$m%Z%nddlm%Z%dd�Z&e&d�Z'e&d�Z(dd�Z)dd�Z*dQdd�Z+dd�Z,Gdd�de�Z-Gd d!�d!e�Z.Gd"d#�d#�Z/Gd$d%�d%e/e.�Z0d&d'�d(d)�Z1e2ed*��rVGd+d,�d,ej3e�Z4Gd-d.�d.e4e�Z5Gd/d0�d0e5�Z6Gd1d2�d2e/e6�Z7d3d4�Z8ej9d5d6��Z:ej9d&d'�d7d8��Z;ej9d9dd&d:�d;d<��Z<d=d>�Z=Gd?d@�d@ej>�Z?GdAdB�dBej@�ZAdCdD�ZBGdEdF�dFeC�ZDdGdH�ZEGdIdJ�dJejF�ZFej9dKdL��ZGejHejIejJfdMdN�ZKdOdP�ZLdS)R�N)�mock)�
HTTPServer)�WSGIRequestHandler�
WSGIServer�)�base_events)�compat)�events)�futures)�	selectors)�tasks)�	coroutine)�logger)�supportZwin32)�
socketpaircCs`ttd�r*tjjtj|�}tjj|�r*|Stjjtjjtj�d|�}tjj|�rT|St	|��dS)N�
TEST_HOME_DIR�test)
�hasattrr�os�path�joinr�isfile�dirname�__file__�FileNotFoundError)�filename�fullname�r�*/usr/lib64/python3.6/asyncio/test_utils.py�	data_file-s
rzssl_cert.pemzssl_key.pemcCstdkrdStjtj�SdS)N)�ssl�
SSLContextZPROTOCOL_SSLv23rrrr�dummy_ssl_context<sr"c
Cs@tdd��}|�}|j|�}d|_z|j|�Wd|j�XdS)NcSsdS)Nrrrrr�onceDszrun_briefly.<locals>.onceF)r
Zcreate_taskZ_log_destroy_pending�run_until_complete�close)�loopr#�gen�trrr�run_brieflyCs
r)�cCsTtj�|}xB|�sN|dk	r8|tj�}|dkr8tj��|jtjd|d��qWdS)Nrg����MbP?)r&)�timer
�TimeoutErrorr$rZsleep)r&Zpred�timeoutZdeadlinerrr�	run_untilRsr.cCs|j|j�|j�dS)N)Z	call_soon�stopZrun_forever)r&rrr�run_once\sr0c@seZdZdd�Zdd�ZdS)�SilentWSGIRequestHandlercCstj�S)N)�io�StringIO)�selfrrr�
get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4�format�argsrrr�log_messagelsz$SilentWSGIRequestHandler.log_messageN)�__name__�
__module__�__qualname__r5r8rrrrr1gsr1cs(eZdZdZ�fdd�Zdd�Z�ZS)�SilentWSGIServer�cs"t�j�\}}|j|j�||fS)N)�super�get_request�
settimeout�request_timeout)r4�request�client_addr)�	__class__rrr?tszSilentWSGIServer.get_requestcCsdS)Nr)r4rB�client_addressrrr�handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF�
__classcell__rr)rDrr<psr<c@seZdZdd�ZdS)�SSLWSGIServerMixincCs^t}t}tj�}|j||�|j|dd�}y|j|||�|j�Wntk
rXYnXdS)NT)Zserver_side)	�ONLYKEY�ONLYCERTr r!Zload_cert_chainZwrap_socketZRequestHandlerClassr%�OSError)r4rBrEZkeyfileZcertfile�contextZssockrrr�finish_requestsz!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@seZdZdS)�
SSLWSGIServerN)r9r:r;rrrrrN�srNF)�use_sslc
#svdd�}|r|n|}||t���j|��j�_tj�fdd�d�}|j�z
�VWd�j��j�|j	�XdS)NcSsd}dg}|||�dgS)Nz200 OK�Content-type�
text/plainsTest message)rPrQr)�environZstart_responseZstatusZheadersrrr�app�s
z_run_test_server.<locals>.appcs�jdd�S)Ng�������?)Z
poll_interval)Z
serve_foreverr)�httpdrr�<lambda>�sz"_run_test_server.<locals>.<lambda>)�target)
r1Zset_appZserver_address�address�	threadingZThread�start�shutdownZserver_closer)rWrO�
server_cls�server_ssl_clsrSZserver_classZ
server_threadr)rTr�_run_test_server�s


r]ZAF_UNIXc@seZdZdd�ZdS)�UnixHTTPServercCstjj|�d|_d|_dS)Nz	127.0.0.1�P)�socketserver�UnixStreamServer�server_bindZserver_nameZserver_port)r4rrrrb�szUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^�sr^cs(eZdZdZdd�Z�fdd�Z�ZS)�UnixWSGIServerr=cCstj|�|j�dS)N)r^rbZ
setup_environ)r4rrrrb�s
zUnixWSGIServer.server_bindcs"t�j�\}}|j|j�|dfS)N�	127.0.0.1�)rdre)r>r?r@rA)r4rBrC)rDrrr?�szUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrc�srcc@seZdZdd�ZdS)�SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrF�sz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrf�srfc@seZdZdS)�UnixSSLWSGIServerN)r9r:r;rrrrrg�srgc	Cstj��}|jSQRXdS)N)�tempfileZNamedTemporaryFile�name)�filerrr�gen_unix_socket_path�s
rkccs<t�}z
|VWdytj|�Wntk
r4YnXXdS)N)rkr�unlinkrK)rrrr�unix_socket_path�s
rmc
cs,t��}t||ttd�EdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrr�run_test_unix_server�srnz	127.0.0.1)�host�portrOccst||f|ttd�EdHdS)N)rWrOr[r\)r]r<rN)rorprOrrr�run_test_server�s
rqcCsPi}x4t|�D](}|jd�r(|jd�r(qtdd�||<qWtd|f|j|��S)N�__)�return_valueZTestProtocol)�dir�
startswith�endswith�MockCallback�type�	__bases__)�baseZdctrirrr�make_test_protocol�sr{c@s6eZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)
�TestSelectorcCs
i|_dS)N)�keys)r4rrr�__init__szTestSelector.__init__NcCstj|d||�}||j|<|S)Nr)rZSelectorKeyr})r4�fileobjr	�data�keyrrr�registers
zTestSelector.registercCs|jj|�S)N)r}�pop)r4rrrr�
unregisterszTestSelector.unregistercCsgS)Nr)r4r-rrr�selectszTestSelector.selectcCs|jS)N)r})r4rrr�get_mapszTestSelector.get_map)N)r9r:r;r~r�r�r�r�rrrrr|s

r|cs�eZdZd,�fdd�	Zdd�Zdd�Z�fdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Z�fd$d%�Z�fd&d'�Zd(d)�Zd*d+�Z�ZS)-�TestLoopNcsvt�j�|dkr"dd�}d|_nd|_|�|_t|j�d|_d|_g|_t�|_	i|_
i|_|j�t
j�|_dS)Ncss
dVdS)Nrrrrrr',szTestLoop.__init__.<locals>.genFTrg��&�.>)r>r~�_check_on_close�_gen�next�_timeZ_clock_resolution�_timersr|Z	_selector�readers�writers�reset_counters�weakref�WeakValueDictionary�_transports)r4r')rDrrr~(s

zTestLoop.__init__cCs|jS)N)r�)r4rrrr+?sz
TestLoop.timecCs|r|j|7_dS)N)r�)r4�advancerrr�advance_timeBszTestLoop.advance_timecsBt�j�|jr>y|jjd�Wntk
r4Yn
Xtd��dS)NrzTime generator is not finished)r>r%r�r��send�
StopIteration�AssertionError)r4)rDrrr%Gs
zTestLoop.closecGstj|||�|j|<dS)N)r	�Handler�)r4�fd�callbackr7rrr�_add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)�remove_reader_countr�)r4r�rrr�_remove_readerTs

zTestLoop._remove_readercGsh||jkrtd|�d���|j|}|j|krDtd|j�d|����|j|krdtd|j�d|����dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )r�r�Z	_callbackZ_args)r4r�r�r7�handlerrr�
assert_reader\s



zTestLoop.assert_readercCs||jkrtd|�d���dS)Nzfd z is registered)r�r�)r4r�rrr�assert_no_readergs
zTestLoop.assert_no_readercGstj|||�|j|<dS)N)r	r�r�)r4r�r�r7rrr�_add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)�remove_writer_countr�)r4r�rrr�_remove_writerns

zTestLoop._remove_writercGs|j|}dS)N)r�)r4r�r�r7r�rrr�
assert_writervs
zTestLoop.assert_writercCs8y|j|}Wntk
r"YnXtdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r��KeyError�RuntimeErrorr6)r4r�Z	transportrrr�_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j|�|j||f|��S)N)r�r�)r4r�r�r7rrr�
add_reader�s
zTestLoop.add_readercCs|j|�|j|�S)N)r�r�)r4r�rrr�
remove_reader�s
zTestLoop.remove_readercGs|j|�|j||f|��S)N)r�r�)r4r�r�r7rrr�
add_writer�s
zTestLoop.add_writercCs|j|�|j|�S)N)r�r�)r4r�rrr�
remove_writer�s
zTestLoop.remove_writercCstjt�|_tjt�|_dS)N)�collections�defaultdict�intr�r�)r4rrrr��szTestLoop.reset_counterscs:t�j�x$|jD]}|jj|�}|j|�qWg|_dS)N)r>�	_run_oncer�r�r�r�)r4�whenr�)rDrrr��s

zTestLoop._run_oncecs |jj|�t�j||f|��S)N)r��appendr>�call_at)r4r�r�r7)rDrrr��szTestLoop.call_atcCsdS)Nr)r4Z
event_listrrr�_process_events�szTestLoop._process_eventscCsdS)Nr)r4rrr�_write_to_self�szTestLoop._write_to_self)N)r9r:r;r~r+r�r%r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rGrr)rDrr�s*

r�cKstjfddgi|��S)N�spec�__call__)rZMock)�kwargsrrrrw�srwc@seZdZdd�ZdS)�MockPatterncCsttjt|�|tj��S)N)�bool�re�search�str�S)r4�otherrrr�__eq__�szMockPattern.__eq__N)r9r:r;r�rrrrr��s	r�cCs$tj|�}|dkr td|f��|S)Nzunable to get the source of %r)r	Z_get_function_source�
ValueError)�func�sourcerrr�get_function_source�s
r�c@sVeZdZedd��Zdd�dd�Zddd	�Zd
d�Zdd
�Zdd�Z	e
jsRdd�ZdS)�TestCasecCs&|j}|dk	r|jdd�|j�dS)NT)�wait)Z_default_executorrZr%)r&Zexecutorrrr�
close_loop�szTestCase.close_loopT)�cleanupcCs tjd�|r|j|j|�dS)N)r	�set_event_loopZ
addCleanupr�)r4r&r�rrrr��s
zTestCase.set_event_loopNcCst|�}|j|�|S)N)r�r�)r4r'r&rrr�
new_test_loop�s
zTestCase.new_test_loopcCs|jt_dS)N)�_get_running_loopr	)r4rrr�unpatch_get_running_loop�sz!TestCase.unpatch_get_running_loopcCs tj|_dd�t_tj�|_dS)NcSsdS)NrrrrrrU�sz TestCase.setUp.<locals>.<lambda>)r	r�rZthreading_setup�_thread_cleanup)r4rrr�setUp�s
zTestCase.setUpcCsB|j�tjd�|jtj�d�|j�tj|j	�tj
�dS)N)NNN)r�r	r�ZassertEqual�sys�exc_infoZ
doCleanupsrZthreading_cleanupr�Z
reap_children)r4rrr�tearDown�s
zTestCase.tearDowncOsGdd�d�}|�S)Nc@seZdZdd�Zdd�ZdS)z!TestCase.subTest.<locals>.EmptyCMcSsdS)Nr)r4rrr�	__enter__�sz+TestCase.subTest.<locals>.EmptyCM.__enter__cWsdS)Nr)r4�excrrr�__exit__�sz*TestCase.subTest.<locals>.EmptyCM.__exit__N)r9r:r;r�r�rrrr�EmptyCM�sr�r)r4r7r�r�rrr�subTest�szTestCase.subTest)N)
r9r:r;�staticmethodr�r�r�r�r�r�rZPY34r�rrrrr��s

r�ccs2tj}ztjtjd�dVWdtj|�XdS)Nr)r�levelZsetLevel�loggingZCRITICAL)Z	old_levelrrr�disable_logger�s

r�cCs*tjtj�}||_||_||_d|j_|S)Ng)rZ	MagicMock�socket�protorx�familyZ
gettimeoutrs)r�rxr�Zsockrrr�mock_nonblocking_socketsr�cCstjddd�S)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrr�force_legacy_ssl_supportsr�)r*)Mr��
contextlibr2r�rr�r�r`r�rhrXr+Zunittestr�rZhttp.serverrZwsgiref.simple_serverrrr �ImportErrorrerrr	r
rrZ
coroutinesr
�logrrr�platformZ
windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrk�contextmanagerrmrnrqr{ZBaseSelectorr|Z
BaseEventLoopr�rwr�r�r�r�r�ZIPPROTO_TCPZSOCK_STREAMZAF_INETr�r�rrrr�<module>s�


	


4
PK=�\G��4GGbase_tasks.cpython-36.opt-2.pycnu�[���3


 \��@sDddlZddlZddlmZddlmZdd�Zdd�Zd	d
�ZdS)�N�)�base_futures)�
coroutinescCsTtj|�}|jrd|d<tj|j�}|jdd|�|jdk	rP|jdd|j�|S)NZ
cancellingrrz	coro=<%s>�zwait_for=%r)rZ_future_repr_infoZ_must_cancelrZ_format_coroutine�_coro�insertZ_fut_waiter)�task�info�coro�r�*/usr/lib64/python3.6/asyncio/base_tasks.py�_task_repr_infos

r
cCs�g}y|jj}Wntk
r,|jj}YnX|dk	rxx6|dk	rl|dk	rZ|dkrRP|d8}|j|�|j}q8W|j�nL|jdk	r�|jj}x8|dk	r�|dk	r�|dkr�P|d8}|j|j	�|j
}q�W|S)Nrr)r�cr_frame�AttributeError�gi_frame�append�f_back�reverse�
_exception�
__traceback__�tb_frame�tb_next)r�limitZframes�f�tbrrr�_task_get_stacks0






rcCs�g}t�}xj|j|d�D]Z}|j}|j}|j}|j}	||krP|j|�tj|�tj	|||j
�}
|j|||	|
f�qW|j}|s�t
d||d�n*|dk	r�t
d||d�nt
d||d�tj||d�|dk	r�x$tj|j|�D]}
t
|
|dd�q�WdS)N)rzNo stack for %r)�filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):�)r�end)�setZ	get_stack�f_lineno�f_code�co_filename�co_name�add�	linecache�
checkcache�getline�	f_globalsrr�print�	traceback�
print_list�format_exception_only�	__class__)rrr�extracted_listZcheckedr�lineno�co�filename�name�line�excrrr�_task_print_stack3s0


r5)r%r*rrrr
rr5rrrr�<module>sPK=�\i|MZ�.�.tasks.cpython-36.opt-2.pycnu�[���3


 \�a�
@s�dddddddddd	d
ddg
Zd
dlZd
dlZd
dlZd
dlZd
dlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZddl
m
Z
Gdd�dej�ZeZyd
dlZWnek
r�YnXejZZejjZejjZejjZe
dded�dd��Zdd�Ze
dd�dd��Ze
dd��Zddd�d d�Ze
d.dd�d!d��Zdd�d"d#�Zee�d<de_[dd�d$d�Z e
d%d&��Z!Gd'd(�d(ej�Z"dd)d*�d+d	�Z#dd�d,d
�Z$d-d�Z%dS)/�Task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�async�gather�shield�
ensure_future�run_coroutine_threadsafe�N�)�
base_tasks)�compat)�
coroutines)�events)�futures)�	coroutinecs�eZdZej�ZiZdZeddd��Z	eddd��Z
dd��fdd	�
Zej
rTd
d�Zdd
�Zdd�dd�Zddd�dd�Zdd�Zd�fdd�	Zdd�Z�ZS)rTNcCs|dkrtj�}|jj|�S)N)r�get_event_loop�_current_tasks�get)�cls�loop�r�%/usr/lib64/python3.6/asyncio/tasks.py�current_task.szTask.current_taskcs$�dkrtj���fdd�|jD�S)Ncsh|]}|j�kr|�qSr)�_loop)�.0�t)rrr�	<setcomp>Bsz!Task.all_tasks.<locals>.<setcomp>)rr�
_all_tasks)rrr)rr�	all_tasks:szTask.all_tasks)rcsNt�j|d�|jr|jd=||_d|_d|_|jj|j�|j	j
j|�dS)N)rrF���)�super�__init__�_source_traceback�_coro�_fut_waiter�_must_cancelr�	call_soon�_step�	__class__r"�add)�self�coror)r-rrr&Dsz
Task.__init__cCsH|jtjkr8|jr8|dd�}|jr,|j|d<|jj|�tjj|�dS)Nz%Task was destroyed but it is pending!)�task�messageZsource_traceback)	Z_staterZ_PENDING�_log_destroy_pendingr'rZcall_exception_handler�Future�__del__)r/�contextrrrr5Ss
zTask.__del__cCs
tj|�S)N)rZ_task_repr_info)r/rrr�
_repr_info^szTask._repr_info)�limitcCstj||�S)N)rZ_task_get_stack)r/r8rrr�	get_stackaszTask.get_stack)r8�filecCstj|||�S)N)rZ_task_print_stack)r/r8r:rrr�print_stackxs	zTask.print_stackcCs4d|_|j�rdS|jdk	r*|jj�r*dSd|_dS)NFT)Z_log_traceback�doner)�cancelr*)r/rrrr=�s

zTask.cancelcsf|jr t|tj�stj�}d|_|j}d|_||jj|j<�zy"|dkrT|j	d�}n
|j
|�}Wn�tk
r�}z.|jr�d|_|jtj��n|j
|j�WYdd}~X�n�tjk
r�t�j�Y�n|tk
r�}z|j|�WYdd}~X�nPtk
�r(}z|j|��WYdd}~X�n Xt|dd�}|dk	�r�|j|jk	�rl|jj|jtdj||���n||�r�||k�r�|jj|jtdj|���n2d|_|j|j�||_|j�r�|jj��r�d|_n|jj|jtdj||���n^|dk�r|jj|j�nDtj|��r.|jj|jtdj||���n|jj|jtdj|���Wd|jjj|j�d}XdS)NF�_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r})r*�
isinstancer�CancelledErrorr(r)r-rr�send�throw�
StopIteration�
set_exception�
set_result�valuer%r=�	Exception�
BaseException�getattrr+r,�RuntimeError�formatr>�add_done_callback�_wakeup�inspectZisgenerator�pop)r/�excr0�resultZblocking)r-rrr,�s~



z
Task._stepcCsJy|j�Wn,tk
r8}z|j|�WYdd}~Xn
X|j�d}dS)N)rQrGr,)r/�futurerPrrrrM�szTask._wakeup)N)N)N)�__name__�
__module__�__qualname__�weakref�WeakSetr"rr3�classmethodrr#r&rZPY34r5r7r9r;r=r,rM�
__classcell__rr)r-rrs 
	!T)r�timeout�return_whenc#s�tj|�stj|�r&tdt|�j��|s2td��|tt	t
fkrNtdj|����dkr^tj
���fdd�t|�D�}t|||��EdHS)Nz expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}csh|]}t|�d��qS))r)r)r�f)rrrr!7szwait.<locals>.<setcomp>)r�isfuturer�iscoroutine�	TypeError�typerS�
ValueErrorrrrrKrr�set�_wait)�fsrrZr[r)rrrscGs|j�s|jd�dS)N)r<rE)�waiter�argsrrr�_release_waiter<srg)rccs�|dkrtj�}|dkr"|EdHS|j�}|j|t|�}tjt|�}t||d�}|j|�zhy|EdHWn*t	j
k
r�|j|�|j��YnX|j
�r�|j�S|j|�|j�t	j��Wd|j�XdS)N)r)rr�
create_future�
call_laterrg�	functools�partialrrLrr@�remove_done_callbackr=r<rQ�TimeoutError)�futrZrre�timeout_handle�cbrrrrAs,



c#s�|j��d�|dk	r"|j|t���t|������fdd�}x|D]}|j|�qBWz�EdHWd�dk	rt�j�Xt�t�}}x4|D],}|j|�|j�r�|j	|�q�|j	|�q�W||fS)Ncs\�d8��dks6�tks6�tkrX|j�rX|j�dk	rX�dk	rF�j��j�sX�jd�dS)Nrr)rr�	cancelled�	exceptionr=r<rE)r\)�counterr[rorerr�_on_completion|sz_wait.<locals>._on_completion)
rhrirg�lenrLr=rbrlr<r.)rdrZr[rrtr\r<�pendingr)rsr[rorerrcos&



rc)rrZc#s�tj|�stj|�r&tdt|�j���dk	r2�ntj���fdd�t	|�D��ddl
m}|�d��d����fdd�}���fd	d
��t�fdd��}x�D]}|j
��q�W�r�|dk	rʈj||��xtt���D]}|�Vq�WdS)
Nz expect a list of futures, not %scsh|]}t|�d��qS))r)r)rr\)rrrr!�szas_completed.<locals>.<setcomp>r)�Queue)rcs.x �D]}|j���jd�qW�j�dS)N)rl�
put_nowait�clear)r\)rtr<�todorr�_on_timeout�s

z!as_completed.<locals>._on_timeoutcs6�sdS�j|��j|��r2�dk	r2�j�dS)N)�removerxr=)r\)r<rorzrrrt�s

z$as_completed.<locals>._on_completionc3s$�j�EdH}|dkrtj�|j�S)N)rrrmrQ)r\)r<rr�
_wait_for_one�sz#as_completed.<locals>._wait_for_one)rr]rr^r_r`rSrrrbZqueuesrwrrLri�rangeru)rdrrZrwr{r}r\�_r)rtr<rrorzrr�s 

c
csX|dkrdV|S|dkr"tj�}|j�}|jj|tj||�}z
|EdHS|j�XdS)Nr)rrrhrrirZ_set_result_unless_cancelledr=)ZdelayrQrrR�hrrrr�s
cCstjdtdd�t||d�S)Nz;asyncio.async() function is deprecated, use ensure_future()�)�
stacklevel)r)�warnings�warn�DeprecationWarningr)�coro_or_futurerrrr�async_�sr�cCs�tj|�r(|dk	r$||jk	r$td��|Stj|�r^|dkrBtj�}|j|�}|j	rZ|j	d=|St
jr~tj
|�r~tt|�|d�Std��dS)Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rr]rrarr^rrZcreate_taskr'rZPY35rNZisawaitabler�_wrap_awaitabler_)r�rr1rrrr�s


ccs|j�EdHS)N)�	__await__)Z	awaitablerrrr�sr�cs*eZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFutureN)rcst�j|d�||_d|_dS)N)rF)r%r&�	_children�_cancel_requested)r/�childrenr)r-rrr&$sz_GatheringFuture.__init__cCs:|j�rdSd}x|jD]}|j�rd}qW|r6d|_|S)NFT)r<r�r=r�)r/ZretZchildrrrr=)sz_GatheringFuture.cancel)rSrTrUr&r=rYrr)r-rr�sr�F)r�return_exceptionscs|s*|dkrtj�}|j���jg��Si�xjt|�D]^}tj|�sht||d�}|dkr`|j}d|_	n&|}|dkr||j}n|j|k	r�t
d��|�|<q8W�fdd�|D�}t|��t||d��d�dg�������fdd�}x&t
|�D]\}}|jtj||��q�W�S)	N)rFz)futures are tied to different event loopscsg|]}�|�qSrr)r�arg)�
arg_to_futrr�
<listcomp>hszgather.<locals>.<listcomp>rcs��j�r|j�s|j�dS|j�r@tj�}�sl�j|�dSn,|jdk	rf|j�}�sl�j|�dSn|j}|�|<�d7���kr��jr��jtj��n
�j	��dS)Nr)
r<rqrrrr@rDZ
_exceptionZ_resultr�rE)�irn�res)�	nchildren�	nfinished�outer�resultsr�rr�_done_callbackns*


zgather.<locals>._done_callback)rrrhrErbrr]rrr3rarur��	enumeraterLrjrk)rr�Zcoros_or_futuresr�rnr�r�r�r)r�r�r�r�r�r�rr
8s8



cs@t||d�}|j�r|S|j}|j���fdd�}|j|��S)N)rcs\�j�r|j�s|j�dS|j�r.�j�n*|j�}|dk	rJ�j|�n�j|j��dS)N)rqrrr=rDrErQ)�innerrP)r�rrr��s
zshield.<locals>._done_callback)rr<rrhrL)r�rr�r�r)r�rr�s
cs:tj��std��tjj�����fdd�}�j|��S)NzA coroutine object is requiredcsTytjt��d���Wn6tk
rN}z�j�r<�j|��WYdd}~XnXdS)N)r)rZ
_chain_futurerrGZset_running_or_notify_cancelrD)rP)r0rRrrr�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rr^r_�
concurrentrr4Zcall_soon_threadsafe)r0rr�r)r0rRrrr
�s


)N)&�__all__Zconcurrent.futuresr�rjrNr�rV�rrrrrrr4rZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrgrrcrrr��globalsrSrr�r�r
rr
rrrr�<module>sX
s
--8

W5PK=�\h8�"��"windows_utils.cpython-36.opt-1.pycnu�[���3


 \��@s�dZddlZejdkred��ddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddddd	gZd
Z
e	jZe	jZej�Zeed�r�ejZnejejdfdd�Zdde
d�dd�ZGdd	�d	�ZGdd�de	j�ZdS)z*
Various Windows specific bits and pieces
�NZwin32z
win32 only�
socketpair�pipe�Popen�PIPE�
PipeHandlei c
Cs|tjkrd}n|tjkr d}ntd��|tjkr:td��|dkrJtd��tj|||�}z�|j|df�|jd�|j�dd	�\}}tj|||�}yP|jd
�y|j	||f�Wnt
tfk
r�YnX|jd�|j�\}}	Wn|j
��YnXWd|j
�X||fS)z�A socket pair usable as a self-pipe, for Windows.

        Origin: https://gist.github.com/4325783, by Geert Jansen.
        Public domain.
        z	127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supported�N�FT)�socket�AF_INETZAF_INET6�
ValueError�SOCK_STREAMZbindZlistenZgetsocknameZsetblockingZconnect�BlockingIOError�InterruptedErrorZaccept�close)
Zfamily�type�proto�hostZlsockZaddrZportZcsockZssock�_�r�-/usr/lib64/python3.6/asyncio/windows_utils.pyr%s8






FT)�duplex�
overlapped�bufsizecCs"tjdtj�tt�fd�}|r>tj}tjtj	B}||}}ntj
}tj	}d|}}|tjO}|drp|tjO}|dr�tj}nd}d}	}
yZtj
||tjd||tjtj�}	tj||dtjtj|tj�}
tj|	dd�}|jd�|	|
fS|	dk	�rtj|	�|
dk	�rtj|
��YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-%d-%d-)�prefixrrNT)r)�tempfileZmktemp�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ	PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@








c@s\eZdZdZdd�Zdd�Zedd��Zdd	�Ze	j
d
�dd�Zd
d�Zdd�Z
dd�ZdS)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like.

    The IOCP event loop can use these instead of socket objects.
    cCs
||_dS)N)�_handle)�self�handlerrr�__init__�szPipeHandle.__init__cCs*|jdk	rd|j}nd}d|jj|fS)Nz	handle=%r�closedz<%s %s>)r"�	__class__�__name__)r#r$rrr�__repr__�s
zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$�szPipeHandle.handlecCs|jdkrtd��|jS)NzI/O operatioon on closed pipe)r"r)r#rrr�fileno�s
zPipeHandle.fileno)r cCs|jdk	r||j�d|_dS)N)r")r#r rrrr�s

zPipeHandle.closecCs*|jdk	r&tjd|t|d�|j�dS)Nzunclosed %r)�source)r"�warnings�warn�ResourceWarningr)r#rrr�__del__�s
zPipeHandle.__del__cCs|S)Nr)r#rrr�	__enter__�szPipeHandle.__enter__cCs|j�dS)N)r)r#�t�v�tbrrr�__exit__�szPipeHandle.__exit__N)r(�
__module__�__qualname__�__doc__r%r)�propertyr$r*rr rr/r0r4rrrrr�scs"eZdZdZd�fdd�	Z�ZS)rz�Replacement for subprocess.Popen using overlapped pipe handles.

    The stdin, stdout, stderr are None or instances of PipeHandle.
    Ncs|d}}}d}	}
}|tkr@tddd�\}}	tj|tj�}n|}|tkrhtdd�\}
}
tj|
d�}n|}|tkr�td	d�\}}tj|d�}n|tkr�|}n|}z�y t�j|f|||d�|��Wn4x$|	|
|fD]}|dk	r�t	j
|�q�W�Yn>X|	dk	�rt|	�|_|
dk	�r"t|
�|_
|dk	�r6t|�|_Wd|tk�rNtj|�|tk�rbtj|�|tk�rvtj|�XdS)
NFT)rr)rr)�stdin�stdout�stderr)FT)TF)TF)rr�msvcrtZopen_osfhandler�O_RDONLY�STDOUT�superr%rr rr9r:r;r)r#�argsr9r:r;�kwdsZ	stdin_rfdZ
stdout_wfdZ
stderr_wfdZstdin_whZ	stdout_rhZ	stderr_rhZstdin_rhZ	stdout_whZ	stderr_wh�h)r'rrr%�sH









zPopen.__init__)NNN)r(r5r6r7r%�
__classcell__rr)r'rr�s)TT)r7�sys�platform�ImportErrorr�	itertoolsr<rr	�
subprocessrr,�__all__ZBUFSIZErr>�countr�hasattrrr
rrrrrrrr�<module>s,

.0-PK=�\�gғg�g unix_events.cpython-36.opt-2.pycnu�[���3


 \���
@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZddl	mZdd	l	mZdd
l	mZddl	mZddl	mZdd
lmZddlmZdddddgZejdkr�ed��dd�Zy
ejZWnek
�r(dd�ZYnXGdd�dej�Ze ed��rRdd�Z!nddl"Z"dd�Z!Gd d!�d!ej#�Z$Gd"d#�d#ej%ej&�Z'e ed$��r�ej(Z)nddl"Z"d%d&�Z)Gd'd(�d(ej*�Z+Gd)d�d�Z,Gd*d+�d+e,�Z-Gd,d�de-�Z.Gd-d�de-�Z/Gd.d/�d/ej0�Z1eZ2e1Z3dS)0�N�)�base_events)�base_subprocess)�compat)�	constants)�
coroutines)�events)�futures)�selector_events)�	selectors)�
transports)�	coroutine)�logger�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)N�)�signum�framerr�+/usr/lib64/python3.6/asyncio/unix_events.py�_sighandler_noop%srcCs|S)Nr)�pathrrr�<lambda>.srcs�eZdZd!�fdd�	Zdd�Z�fdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
d"dd�Zd#dd�Ze
d$dd��Zdd�Ze
dddd�dd��Ze
d%dddd�dd ��Z�ZS)&�_UnixSelectorEventLoopNcst�j|�i|_dS)N)�super�__init__�_signal_handlers)�self�selector)�	__class__rrr7sz_UnixSelectorEventLoop.__init__cCstj�S)N)�socketZ
socketpair)rrrr�_socketpair;sz"_UnixSelectorEventLoop._socketpaircs^t�j�tj�s2xFt|j�D]}|j|�qWn(|jrZtjd|�d�t	|d�|jj
�dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)�source)r�close�sys�
is_finalizing�listr�remove_signal_handler�warnings�warn�ResourceWarning�clear)r�sig)r!rrr%>s
z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|�qWdS)N)�_handle_signal)r�datarrrr�_process_self_dataLs
z)_UnixSelectorEventLoop._process_self_datac+GsHtj|�stj|�rtd��|j|�|j�ytj|jj	��Wn2t
tfk
rt}ztt
|���WYdd}~XnXtj|||�}||j|<ytj|t�tj|d�Wn�tk
�rB}zz|j|=|j�sytjd�Wn4t
tfk
�r}ztjd|�WYdd}~XnX|jtjk�r0tdj|���n�WYdd}~XnXdS)Nz3coroutines cannot be used with add_signal_handler()Frzset_wakeup_fd(-1) failed: %szsig {} cannot be caught���)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signalZ
_check_closed�signal�
set_wakeup_fdZ_csock�fileno�
ValueError�OSError�RuntimeError�strrZHandlerr�siginterruptr�info�errno�EINVAL�format)rr.�callback�args�exc�handleZnexcrrr�add_signal_handlerSs0



z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|�}|dkrdS|jr*|j|�n
|j|�dS)N)r�getZ
_cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/�sz%_UnixSelectorEventLoop._handle_signalc&Cs�|j|�y|j|=Wntk
r*dSX|tjkr>tj}ntj}ytj||�Wn@tk
r�}z$|jtj	kr�t
dj|���n�WYdd}~XnX|js�ytjd�Wn2t
tfk
r�}ztjd|�WYdd}~XnXdS)NFzsig {} cannot be caughtrzset_wakeup_fd(-1) failed: %sTr2)r4r�KeyErrorr5�SIGINT�default_int_handler�SIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)�s(

z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|t�stdj|���d|ko,tjknsDtdj|tj���dS)Nzsig must be an int, not {!r}rzsig {} out of range(1, {}))�
isinstance�intr3r@r5�NSIGr8)rr.rrrr4�s

z$_UnixSelectorEventLoop._check_signalcCst|||||�S)N)�_UnixReadPipeTransport)r�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�S)N)�_UnixWritePipeTransport)rrOrPrQrRrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc	ks�tj���}
|j�}t||||||||f||d�|	��}|
j|j�|j|�y|EdHWn&tk
r~}
z
|
}WYdd}
~
XnXd}|dk	r�|j�|j	�EdH|�WdQRX|S)N)rQrR)
r�get_child_watcherZ
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�	Exceptionr%Z_wait)rrPrB�shell�stdin�stdout�stderr�bufsizerR�kwargs�watcherrQ�transprC�errrrr�_make_subprocess_transport�s$




z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|�dS)N)Zcall_soon_threadsafeZ_process_exited)r�pid�
returncoderbrrrrY�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostnameccs�|r|dkr&td��n|dk	r&td��|dk	r�|dk	r>td��tjtjtjd�}y |jd�|j||�EdHWq�|j��Yq�XnB|dkr�td��|jtjks�tj	|j
�r�tdj|���|jd�|j||||�EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r})
r8r"�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr%�familyr�_is_stream_socket�typer@Z_create_connection_transport)r�protocol_factoryrrgrhri�	transportrPrrr�create_unix_connection�s8


z-_UnixSelectorEventLoop.create_unix_connection�d)rh�backlogrgc
!Cs�t|t�rtd��|dk	�r0|dk	r,td��t|�}tjtjtj�}|dd
kr�y tj	t
j|�j�rnt
j|�WnBt
k
r�Yn0tk
r�}ztjd||�WYdd}~XnXy|j|�Wnjtk
�r}z8|j�|jtjk�rdj|�}ttj|�d�n�WYdd}~Xn|j��YnXn>|dk�rBtd��|jtjk�s`tj|j��rntdj|���tj||g�}	|j|�|jd	�|j||||	�|	S)Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timer�z2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rru)rK�boolr3r8�_fspathr"rjrk�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr9r�errorZbindr%r>Z
EADDRINUSEr@rmrrnroZServerZlistenrlZ_start_serving)
rrprrhrtrgrcrC�msgZserverrrr�create_unix_serversP

 




z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)�__name__�
__module__�__qualname__rr#r%r1rEr/r)r4rSrUr
rdrYrrr��
__classcell__rr)r!rr1s*-
 


%r�set_blockingcCstj|d�dS)NF)rzr�)�fdrrr�_set_nonblockingBsr�cCs,tj|tj�}|tjB}tj|tj|�dS)N)�fcntlZF_GETFLrz�
O_NONBLOCKZF_SETFL)r��flagsrrrr�Gs
cs�eZdZdZd �fdd�	Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
jrhdd�Zd!dd�Zdd�Zdd�Z�ZS)"rN�iNcs�t�j|�||jd<||_||_|j�|_||_d|_t	j
|j�j}tj
|�pbtj|�pbtj|�s~d|_d|_d|_td��t|j�|jj|jj|�|jj|jj|j|j�|dk	r�|jjtj|d�dS)NrOFz)Pipe transport is for pipes/sockets only.)rr�_extra�_loop�_piper7�_fileno�	_protocol�_closingrz�fstatr{rx�S_ISFIFOry�S_ISCHRr8r��	call_soon�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)r�looprOrPrQrR�mode)r!rrrQs,






z_UnixReadPipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�t|jdd�}|jdk	r�|dk	r�tj	||jt
j�}|r�|jd�q�|jd�n |jdk	r�|jd�n
|jd�dd	j|�S)
N�closed�closingzfd=%s�	_selector�polling�idle�openz<%s>� )
r!r�r��appendr�r��getattrr�r
�_test_selector_eventrZ
EVENT_READ�join)rr=r r�rrr�__repr__ns$




z_UnixReadPipeTransport.__repr__cCs�ytj|j|j�}WnDttfk
r,Yn�tk
rX}z|j|d�WYdd}~Xn^X|rl|jj	|�nJ|j
j�r�tj
d|�d|_|j
j|j�|j
j|jj�|j
j|jd�dS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rz�readr��max_size�BlockingIOError�InterruptedErrorr9�_fatal_errorr�Z
data_receivedr��	get_debugrr=r��_remove_readerr�Zeof_received�_call_connection_lost)rr0rCrrrr��s
z"_UnixReadPipeTransport._read_readycCs|jj|j�dS)N)r�r�r�)rrrr�
pause_reading�sz$_UnixReadPipeTransport.pause_readingcCs|jj|j|j�dS)N)r�r�r�r�)rrrr�resume_reading�sz%_UnixReadPipeTransport.resume_readingcCs
||_dS)N)r�)rrPrrr�set_protocol�sz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r�)rrrr�get_protocol�sz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r�)rrrr�
is_closing�sz!_UnixReadPipeTransport.is_closingcCs|js|jd�dS)N)r��_close)rrrrr%�sz_UnixReadPipeTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)r$)r�r*r+r,r%)rrrr�__del__�s
z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r4|jtjkr4|jj�rLtjd||dd�n|jj||||j	d��|j
|�dS)Nz%r: %sT)�exc_info)�message�	exceptionrqrP)rKr9r>ZEIOr�r�r�debug�call_exception_handlerr�r�)rrCr�rrrr��s
z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j�|jj|j|�dS)NT)r�r�r�r�r�r�)rrCrrrr��sz_UnixReadPipeTransport._closecCs4z|jj|�Wd|jj�d|_d|_d|_XdS)N)r��connection_lostr�r%r�)rrCrrrr��s
z,_UnixReadPipeTransport._call_connection_losti)NN)r�)r�r�r�r�rr�r�r�r�r�r�r�r%r�PY34r�r�r�r�r�rr)r!rrNMs
rNcs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejr|dd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rTNc
s�t�j||�||jd<||_|j�|_||_t�|_d|_	d|_
tj|j�j
}tj|�}tj|�}tj|�}	|px|px|	s�d|_d|_d|_td��t|j�|jj|jj|�|	s�|r�tjjd�r�|jj|jj|j|j�|dk	r�|jjtj|d�dS)NrOrFz?Pipe transport is only for pipes, sockets and character devices�aix)rrr�r�r7r�r��	bytearray�_buffer�
_conn_lostr�rzr�r{rxr�r�ryr8r�r�r�r�r&�platform�
startswithr�r�r	r�)
rr�rOrPrQrRr�Zis_charZis_fifoZ	is_socket)r!rrr�s2






z _UnixWritePipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�t|jdd�}|jdk	r�|dk	r�tj	||jt
j�}|r�|jd�n
|jd�|j�}|jd|�n |jdk	r�|jd�n
|jd�d	d
j
|�S)Nr�r�zfd=%sr�r�r�z
bufsize=%sr�z<%s>r�)r!r�r�r�r�r�r�r�r
r�rZEVENT_WRITE�get_write_buffer_sizer�)rr=r r�r_rrrr��s(





z _UnixWritePipeTransport.__repr__cCs
t|j�S)N)�lenr�)rrrrr�sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jj�rtjd|�|jr*|jt��n|j�dS)Nz%r was closed by peer)r�r�rr=r�r��BrokenPipeError)rrrrr�s

z#_UnixWritePipeTransport._read_readycCst|t�rt|�}|sdS|js&|jrN|jtjkr<tjd�|jd7_dS|j	�s�yt
j|j|�}WnTt
tfk
r�d}Yn:tk
r�}z|jd7_|j|d�dSd}~XnX|t|�kr�dS|dkr�t|�|d�}|jj|j|j�|j	|7_	|j�dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rKr��
memoryviewr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�rz�writer�r�r�rZr�r�r�Z_add_writer�_write_readyZ_maybe_pause_protocol)rr0�nrCrrrr�s2

z_UnixWritePipeTransport.writecCs�ytj|j|j�}Wnjttfk
r,Yn�tk
r~}z8|jj�|jd7_|j	j
|j�|j|d�WYdd}~XnfX|t|j�kr�|jj�|j	j
|j�|j
�|jr�|j	j|j�|jd�dS|dkr�|jd|�=dS)Nrz#Fatal write error on pipe transportr)rzr�r�r�r�r�rZr-r�r��_remove_writerr�r�Z_maybe_resume_protocolr�r�r�)rr�rCrrrr�>s&


z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr�
can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCs8|jr
dSd|_|js4|jj|j�|jj|jd�dS)NT)r�r�r�r�r�r�r�)rrrr�	write_eof[sz!_UnixWritePipeTransport.write_eofcCs
||_dS)N)r�)rrPrrrr�dsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r�)rrrrr�gsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r�)rrrrr�jsz"_UnixWritePipeTransport.is_closingcCs|jdk	r|jr|j�dS)N)r�r�r�)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)r$)r�r*r+r,r%)rrrrr�vs
z_UnixWritePipeTransport.__del__cCs|jd�dS)N)r�)rrrr�abort|sz_UnixWritePipeTransport.abort�Fatal error on pipe transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)r�)r�r�rqrP)
rKrZ_FATAL_ERROR_IGNOREr�r�rr�r�r�r�)rrCr�rrrr�s
z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j�|jj�|jj|j�|jj|j|�dS)NT)	r�r�r�r�r�r-r�r�r�)rrCrrrr��s
z_UnixWritePipeTransport._closecCs4z|jj|�Wd|jj�d|_d|_d|_XdS)N)r�r�r�r%r�)rrCrrrr��s
z-_UnixWritePipeTransport._call_connection_lost)NN)r�)N)r�r�r�rr�r�r�r�r�r�r�r�r�r�r%rr�r�r�r�r�r�r�rr)r!rrT�s$%	!	

rT�set_inheritablecCsNttdd�}tj|tj�}|s4tj|tj||B�ntj|tj||@�dS)NZ
FD_CLOEXECr)r�r�ZF_GETFDZF_SETFD)r�ZinheritableZcloexec_flag�oldrrr�_set_inheritable�s
r�c@seZdZdd�ZdS)rWc		Ksvd}|tjkr*|jj�\}}t|j�d�tj|f||||d|d�|��|_|dk	rr|j�t	|j
�d|d�|j_dS)NF)r[r\r]r^Zuniversal_newlinesr_�wb)�	buffering)�
subprocess�PIPEr�r#r�r7�Popen�_procr%r��detachr\)	rrBr[r\r]r^r_r`Zstdin_wrrr�_start�s
z_UnixSubprocessTransport._startN)r�r�r�r�rrrrrW�srWc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rcGs
t��dS)N)�NotImplementedError)rrerArBrrrrX�s	z&AbstractChildWatcher.add_child_handlercCs
t��dS)N)r�)rrerrr�remove_child_handler�sz)AbstractChildWatcher.remove_child_handlercCs
t��dS)N)r�)rr�rrr�attach_loop�sz AbstractChildWatcher.attach_loopcCs
t��dS)N)r�)rrrrr%�szAbstractChildWatcher.closecCs
t��dS)N)r�)rrrr�	__enter__szAbstractChildWatcher.__enter__cCs
t��dS)N)r�)r�a�b�crrr�__exit__	szAbstractChildWatcher.__exit__N)	r�r�r�rXr�r�r%r�r�rrrrr�s
c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dS)N)r��
_callbacks)rrrrrszBaseChildWatcher.__init__cCs|jd�dS)N)r�)rrrrr%szBaseChildWatcher.closecCs
t��dS)N)r�)r�expected_pidrrr�_do_waitpidszBaseChildWatcher._do_waitpidcCs
t��dS)N)r�)rrrr�_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCsf|jdk	r$|dkr$|jr$tjdt�|jdk	r<|jjtj�||_|dk	rb|jtj|j	�|j
�dS)NzCA loop is being detached from a child watcher with pending handlers)r�r�r*r+�RuntimeWarningr)r5�SIGCHLDrE�	_sig_chldr�)rr�rrrr�s
zBaseChildWatcher.attach_loopcCsFy|j�Wn4tk
r@}z|jjd|d��WYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handler)r�r�)r�rZr�r�)rrCrrrr�1szBaseChildWatcher._sig_chldcCs2tj|�rtj|�Stj|�r*tj|�S|SdS)N)rz�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)r�statusrrr�_compute_returncode=s



z$BaseChildWatcher._compute_returncodeN)
r�r�r�rr%r�r�r�r�r�rrrrr�sr�csLeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs|jj�t�j�dS)N)r�r-rr%)r)r!rrr%Vs
zSafeChildWatcher.closecCs|S)Nr)rrrrr�ZszSafeChildWatcher.__enter__cCsdS)Nr)rr�r�r�rrrr�]szSafeChildWatcher.__exit__cGs.|jdkrtd��||f|j|<|j|�dS)NzICannot add child handler, the child watcher does not have a loop attached)r�r:r�r�)rrerArBrrrrX`s

z"SafeChildWatcher.add_child_handlercCs&y|j|=dStk
r dSXdS)NTF)r�rG)rrerrrr�ks
z%SafeChildWatcher.remove_child_handlercCs"xt|j�D]}|j|�qWdS)N)r(r�r�)rrerrrr�rsz SafeChildWatcher._do_waitpid_allcCs�ytj|tj�\}}Wn(tk
r>|}d}tjd|�Yn0X|dkrLdS|j|�}|jj�rntj	d||�y|j
j|�\}}Wn.tk
r�|jj�r�tjd|dd�YnX|||f|��dS)N�z8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rT)r�)
rz�waitpid�WNOHANG�ChildProcessErrorrr�r�r�r�r�r��poprG)rr�rer�rfrArBrrrr�ws*


zSafeChildWatcher._do_waitpid)r�r�r�r%r�r�rXr�r�r�r�rr)r!rrKscsPeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs$t�j�tj�|_i|_d|_dS)Nr)rr�	threadingZLock�_lock�_zombies�_forks)r)r!rrr�s

zFastChildWatcher.__init__cs"|jj�|jj�t�j�dS)N)r�r-r�rr%)r)r!rrr%�s

zFastChildWatcher.closec
Cs$|j�|jd7_|SQRXdS)Nr)r�r�)rrrrr��szFastChildWatcher.__enter__c
CsV|j�:|jd8_|js$|jr(dSt|j�}|jj�WdQRXtjd|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)r�r�r�r;r-rr�)rr�r�r�Zcollateral_victimsrrrr��s
zFastChildWatcher.__exit__cGsl|jdkrtd��|j�:y|jj|�}Wn"tk
rL||f|j|<dSXWdQRX|||f|��dS)NzICannot add child handler, the child watcher does not have a loop attached)r�r:r�r�r�rGr�)rrerArBrfrrrrX�s
z"FastChildWatcher.add_child_handlercCs&y|j|=dStk
r dSXdS)NTF)r�rG)rrerrrr��s
z%FastChildWatcher.remove_child_handlercCs�x�ytjdtj�\}}Wntk
r,dSX|dkr:dS|j|�}|j�vy|jj|�\}}WnBtk
r�|j	r�||j
|<|jj�r�t
jd||�wd}YnX|jj�r�t
jd||�WdQRX|dkr�t
jd||�q|||f|��qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr2)rzr�r�r�r�r�r�r�rGr�r�r�r�rr�r�)rrer�rfrArBrrrr��s6





z FastChildWatcher._do_waitpid_all)r�r�r�rr%r�r�rXr�r�r�rr)r!rr�s
csDeZdZeZ�fdd�Zdd�Z�fdd�Zdd�Zd	d
�Z	�Z
S)�_UnixDefaultEventLoopPolicycst�j�d|_dS)N)rr�_watcher)r)r!rrrs
z$_UnixDefaultEventLoopPolicy.__init__c
CsHtj�8|jdkr:t�|_ttj�tj�r:|jj|j	j
�WdQRXdS)N)rr�r�rrKr��current_thread�_MainThreadr��_localr�)rrrr�
_init_watchers
z)_UnixDefaultEventLoopPolicy._init_watchercs6t�j|�|jdk	r2ttj�tj�r2|jj|�dS)N)r�set_event_loopr�rKr�r�r�r�)rr�)r!rrrs
z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j�|jS)N)r�r)rrrrrV&s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk	r|jj�||_dS)N)r�r%)rrarrr�set_child_watcher0s

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�rZ
_loop_factoryrrrrVrr�rr)r!rr�s
r�)4r>rzr5r"rxr�r&r�r*�rrrrrrr	r
rrr
�logr�__all__r��ImportErrorr�fspathrw�AttributeErrorZBaseSelectorEventLoopr�hasattrr�r�Z
ReadTransportrNZ_FlowControlMixinZWriteTransportrTr�r�ZBaseSubprocessTransportrWrr�rrZBaseDefaultEventLoopPolicyr�rrrrrr�<module>sl


O
F=On2PK=�\/F\:windows_utils.cpython-36.pycnu�[���3


 \��@s�dZddlZejdkred��ddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddddd	gZd
Z
e	jZe	jZej�Zeed�r�ejZnejejdfdd�Zdde
d�dd�ZGdd	�d	�ZGdd�de	j�ZdS)z*
Various Windows specific bits and pieces
�NZwin32z
win32 only�
socketpair�pipe�Popen�PIPE�
PipeHandlei c
Cs|tjkrd}n|tjkr d}ntd��|tjkr:td��|dkrJtd��tj|||�}z�|j|df�|jd�|j�dd	�\}}tj|||�}yP|jd
�y|j	||f�Wnt
tfk
r�YnX|jd�|j�\}}	Wn|j
��YnXWd|j
�X||fS)z�A socket pair usable as a self-pipe, for Windows.

        Origin: https://gist.github.com/4325783, by Geert Jansen.
        Public domain.
        z	127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supported�N�FT)�socket�AF_INETZAF_INET6�
ValueError�SOCK_STREAMZbindZlistenZgetsocknameZsetblockingZconnect�BlockingIOError�InterruptedErrorZaccept�close)
Zfamily�type�proto�hostZlsockZaddrZportZcsockZssock�_�r�-/usr/lib64/python3.6/asyncio/windows_utils.pyr%s8






FT)�duplex�
overlapped�bufsizecCs"tjdtj�tt�fd�}|r>tj}tjtj	B}||}}ntj
}tj	}d|}}|tjO}|drp|tjO}|dr�tj}nd}d}	}
yZtj
||tjd||tjtj�}	tj||dtjtj|tj�}
tj|	dd�}|jd�|	|
fS|	dk	�rtj|	�|
dk	�rtj|
��YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-%d-%d-)�prefixrrNT)r)�tempfileZmktemp�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ	PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@








c@s\eZdZdZdd�Zdd�Zedd��Zdd	�Ze	j
d
�dd�Zd
d�Zdd�Z
dd�ZdS)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like.

    The IOCP event loop can use these instead of socket objects.
    cCs
||_dS)N)�_handle)�self�handlerrr�__init__�szPipeHandle.__init__cCs*|jdk	rd|j}nd}d|jj|fS)Nz	handle=%r�closedz<%s %s>)r"�	__class__�__name__)r#r$rrr�__repr__�s
zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$�szPipeHandle.handlecCs|jdkrtd��|jS)NzI/O operatioon on closed pipe)r"r)r#rrr�fileno�s
zPipeHandle.fileno)r cCs|jdk	r||j�d|_dS)N)r")r#r rrrr�s

zPipeHandle.closecCs*|jdk	r&tjd|t|d�|j�dS)Nzunclosed %r)�source)r"�warnings�warn�ResourceWarningr)r#rrr�__del__�s
zPipeHandle.__del__cCs|S)Nr)r#rrr�	__enter__�szPipeHandle.__enter__cCs|j�dS)N)r)r#�t�v�tbrrr�__exit__�szPipeHandle.__exit__N)r(�
__module__�__qualname__�__doc__r%r)�propertyr$r*rr rr/r0r4rrrrr�scs"eZdZdZd�fdd�	Z�ZS)rz�Replacement for subprocess.Popen using overlapped pipe handles.

    The stdin, stdout, stderr are None or instances of PipeHandle.
    Ncs�|jd�st�|jdd�dks$t�d}}}d}	}
}|tkrdtd	dd�\}}	tj|tj�}n|}|tkr�td
d�\}
}
tj|
d�}n|}|tkr�tdd�\}}tj|d�}n|tkr�|}n|}z�y t	�j
|f|||d�|��Wn8x(|	|
|fD]}|dk	�r�tj|��q�W�Yn>X|	dk	�r6t
|	�|_|
dk	�rJt
|
�|_|dk	�r^t
|�|_Wd|tk�rvtj|�|tk�r�tj|�|tk�r�tj|�XdS)NZuniversal_newlinesrrFT)rr)r)�stdin�stdout�stderr)FT)TF)TF)�get�AssertionErrorrr�msvcrtZopen_osfhandler�O_RDONLY�STDOUT�superr%rr rr9r:r;r)r#�argsr9r:r;�kwdsZ	stdin_rfdZ
stdout_wfdZ
stderr_wfdZstdin_whZ	stdout_rhZ	stderr_rhZstdin_rhZ	stdout_whZ	stderr_wh�h)r'rrr%�sL










zPopen.__init__)NNN)r(r5r6r7r%�
__classcell__rr)r'rr�s)TT)r7�sys�platform�ImportErrorr�	itertoolsr>rr	�
subprocessrr,�__all__ZBUFSIZErr@�countr�hasattrrr
rrrrrrrr�<module>s,

.0-PK=�\�X��"�"locks.cpython-36.opt-2.pycnu�[���3


 \�<�@s�dddddgZddlZddlmZdd	lmZdd
lmZddlmZGdd
�d
�ZGdd�d�Z	Gdd�de	�Z
Gdd�d�ZGdd�de	�ZGdd�de	�Z
Gdd�de
�ZdS)�Lock�Event�	Condition�	Semaphore�BoundedSemaphore�N�)�compat)�events)�futures)�	coroutinec@s$eZdZdd�Zdd�Zdd�ZdS)�_ContextManagercCs
||_dS)N)�_lock)�self�lock�r�%/usr/lib64/python3.6/asyncio/locks.py�__init__sz_ContextManager.__init__cCsdS)Nr)rrrr�	__enter__sz_ContextManager.__enter__cGsz|jj�Wdd|_XdS)N)r
�release)r�argsrrr�__exit__$sz_ContextManager.__exit__N)�__name__�
__module__�__qualname__rrrrrrrr
src@sNeZdZdd�Zdd�Zedd��ZejrJdd�Z	ed	d
��Z
edd��Zd
S)�_ContextManagerMixincCstd��dS)Nz9"yield from" should be used as context manager expression)�RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|j�EdHt|�S)N)�acquirer)rrrr�__iter__5sz_ContextManagerMixin.__iter__ccs|j�EdHt|�S)N)rr)rrrr�	__await__Hsz_ContextManagerMixin.__await__ccs|j�EdHdS)N)r)rrrr�
__aenter__Msz_ContextManagerMixin.__aenter__cCs|j�dS)N)r)r�exc_type�exc�tbrrr�	__aexit__Tsz_ContextManagerMixin.__aexit__N)rrrrrrrrZPY35rrr#rrrrr+srcsNeZdZdd�dd�Z�fdd�Zdd�Zed	d
��Zdd�Zd
d�Z	�Z
S)rN)�loopcCs.tj�|_d|_|dk	r ||_n
tj�|_dS)NF)�collections�deque�_waiters�_locked�_loopr	�get_event_loop)rr$rrrr�s

z
Lock.__init__csDt�j�}|jrdnd}|jr0dj|t|j��}dj|dd�|�S)N�locked�unlockedz
{},waiters:{}z	<{} [{}]>r���)�super�__repr__r(r'�format�len)r�res�extra)�	__class__rrr/�s

z
Lock.__repr__cCs|jS)N)r()rrrrr+�szLock.lockedccs�|jr&tdd�|jD��r&d|_dS|jj�}|jj|�y"z|EdHWd|jj|�XWn&tjk
r�|js~|j	��YnXd|_dS)Ncss|]}|j�VqdS)N)�	cancelled)�.0�wrrr�	<genexpr>�szLock.acquire.<locals>.<genexpr>T)
r(�allr'r)�
create_future�append�remover
�CancelledError�_wake_up_first)r�futrrrr�s
zLock.acquirecCs"|jrd|_|j�ntd��dS)NFzLock is not acquired.)r(r>r)rrrrr�s
zLock.releasecCs>ytt|j��}Wntk
r&dSX|j�s:|jd�dS)NT)�next�iterr'�
StopIteration�done�
set_result)rr?rrrr>�szLock._wake_up_first)rrrrr/r+rrrr>�
__classcell__rr)r4rrYs6csNeZdZdd�dd�Z�fdd�Zdd�Zd	d
�Zdd�Zed
d��Z	�Z
S)rN)r$cCs.tj�|_d|_|dk	r ||_n
tj�|_dS)NF)r%r&r'�_valuer)r	r*)rr$rrrr�s

zEvent.__init__csDt�j�}|jrdnd}|jr0dj|t|j��}dj|dd�|�S)N�setZunsetz
{},waiters:{}z	<{} [{}]>rr-)r.r/rFr'r0r1)rr2r3)r4rrr/�s

zEvent.__repr__cCs|jS)N)rF)rrrr�is_set�szEvent.is_setcCs2|js.d|_x |jD]}|j�s|jd�qWdS)NT)rFr'rCrD)rr?rrrrG�s
z	Event.setcCs
d|_dS)NF)rF)rrrr�clearszEvent.clearccsB|jr
dS|jj�}|jj|�z|EdHdS|jj|�XdS)NT)rFr)r:r'r;r<)rr?rrr�wait
s

z
Event.wait)rrrrr/rHrGrIrrJrErr)r4rr�s	csVeZdZddd�dd�Z�fdd�Zedd��Zed	d
��Zddd
�Zdd�Z	�Z
S)rN)r$cCsp|dk	r||_n
tj�|_|dkr0t|jd�}n|j|jk	rDtd��||_|j|_|j|_|j|_t	j
�|_dS)N)r$z"loop argument must agree with lock)r)r	r*r�
ValueErrorr
r+rrr%r&r')rrr$rrrr+s
zCondition.__init__csFt�j�}|j�rdnd}|jr2dj|t|j��}dj|dd�|�S)Nr+r,z
{},waiters:{}z	<{} [{}]>rr-)r.r/r+r'r0r1)rr2r3)r4rrr/>s

zCondition.__repr__ccs�|j�std��|j�z8|jj�}|jj|�z|EdHdS|jj|�XWdd}x4y|j�EdHPWqXt	j
k
r�d}YqXXqXW|r�t	j
�XdS)Nzcannot wait on un-acquired lockTF)r+rrr)r:r'r;r<rr
r=)rr?r5rrrrJEs&

zCondition.waitccs(|�}x|s"|j�EdH|�}qW|S)N)rJ)rZ	predicate�resultrrr�wait_forks

zCondition.wait_forrcCsL|j�std��d}x2|jD](}||kr*P|j�s|d7}|jd�qWdS)Nz!cannot notify on un-acquired lockrrF)r+rr'rCrD)r�n�idxr?rrr�notifyyszCondition.notifycCs|jt|j��dS)N)rPr1r')rrrr�
notify_all�szCondition.notify_all)N)r)rrrrr/rrJrMrPrQrErr)r4rr!s
&
csPeZdZddd�dd�Z�fdd�Zdd	�Zd
d�Zedd
��Zdd�Z	�Z
S)rrN)r$cCs>|dkrtd��||_tj�|_|dk	r0||_n
tj�|_dS)Nrz$Semaphore initial value must be >= 0)rKrFr%r&r'r)r	r*)r�valuer$rrrr�s
zSemaphore.__init__csNt�j�}|j�rdn
dj|j�}|jr:dj|t|j��}dj|dd�|�S)Nr+zunlocked,value:{}z
{},waiters:{}z	<{} [{}]>rr-)r.r/r+r0rFr'r1)rr2r3)r4rrr/�s
zSemaphore.__repr__cCs0x*|jr*|jj�}|j�s|jd�dSqWdS)N)r'�popleftrCrD)rZwaiterrrr�
_wake_up_next�s


zSemaphore._wake_up_nextcCs
|jdkS)Nr)rF)rrrrr+�szSemaphore.lockedc	cszxf|jdkrf|jj�}|jj|�y|EdHWq|j�|jdkr\|j�r\|j��YqXqW|jd8_dS)NrrT)rFr)r:r'r;Zcancelr5rT)rr?rrrr�s

zSemaphore.acquirecCs|jd7_|j�dS)Nr)rFrT)rrrrr�szSemaphore.release)r)rrrrr/rTr+rrrrErr)r4rr�s
cs0eZdZddd��fdd�Z�fdd�Z�ZS)	rrN)r$cs||_t�j||d�dS)N)r$)�_bound_valuer.r)rrRr$)r4rrr�szBoundedSemaphore.__init__cs"|j|jkrtd��t�j�dS)Nz(BoundedSemaphore released too many times)rFrUrKr.r)r)r4rrr�szBoundedSemaphore.release)r)rrrrrrErr)r4rr�s)�__all__r%�rr	r
Z
coroutinesrrrrrrrrrrrr�<module>s.ByMPK=�\����log.cpython-36.opt-2.pycnu�[���3


 \|�@sddlZeje�ZdS)�N)ZloggingZ	getLogger�__package__Zlogger�rr�#/usr/lib64/python3.6/asyncio/log.py�<module>sPK=�\��ь��constants.cpython-36.pycnu�[���3


 \s�@sdZdZdZdZdS)z
Constants.���
N)�__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTH�rr�)/usr/lib64/python3.6/asyncio/constants.py�<module>sPK=�\�ny�0$0$base_subprocess.cpython-36.pycnu�[���3


 \�#�@s�ddlZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
Gdd	�d	ej�ZGd
d�dej
�ZGdd
�d
eej�ZdS)�N�)�compat)�	protocols)�
transports)�	coroutine)�loggercs�eZdZd0�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jrTdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zed*d+��Zd,d-�Zd.d/�Z�ZS)1�BaseSubprocessTransportNc
s&t�j|
�d|_||_||_d|_d|_d|_g|_t	j
�|_i|_d|_
|tjkr`d|jd<|tjkrtd|jd<|tjkr�d|jd<y"|jf||||||d�|��Wn|j��YnX|jj|_|j|jd<|jj��rt|ttf�r�|}n|d}tjd||j�|jj|j|	��dS)NFrr�)�args�shell�stdin�stdout�stderr�bufsize�
subprocesszprocess %r created: pid %s)�super�__init__�_closed�	_protocol�_loop�_proc�_pid�_returncode�
_exit_waiters�collections�deque�_pending_calls�_pipes�	_finishedr�PIPE�_start�close�pidZ_extra�	get_debug�
isinstance�bytes�strr�debugZcreate_task�_connect_pipes)
�self�loop�protocolr
rrr
rr�waiterZextra�kwargsZprogram)�	__class__��//usr/lib64/python3.6/asyncio/base_subprocess.pyrs@








z BaseSubprocessTransport.__init__cCs|jjg}|jr|jd�|jdk	r4|jd|j�|jdk	rP|jd|j�n |jdk	rf|jd�n
|jd�|jjd�}|dk	r�|jd|j�|jjd�}|jjd	�}|dk	r�||kr�|jd
|j�n0|dk	r�|jd|j�|dk	r�|jd|j�d
dj	|�S)N�closedzpid=%sz
returncode=%sZrunningznot startedrzstdin=%srr	zstdout=stderr=%sz	stdout=%sz	stderr=%sz<%s>� )
r.�__name__r�appendrrr�get�pipe�join)r)�inforr
rr/r/r0�__repr__9s,





z BaseSubprocessTransport.__repr__cKst�dS)N)�NotImplementedError)r)r
rrr
rrr-r/r/r0r VszBaseSubprocessTransport._startcCs
||_dS)N)r)r)r+r/r/r0�set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0�get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0�
is_closing_sz"BaseSubprocessTransport.is_closingcCs�|jr
dSd|_x&|jj�D]}|dkr*q|jj�qW|jdk	r�|jdkr�|jj�dkr�|jj	�rpt
jd|�y|jj�Wnt
k
r�YnXdS)NTz$Close running child process: kill %r)rr�valuesr6r!rrZpollrr#rZwarning�kill�ProcessLookupError)r)�protor/r/r0r!bs 


zBaseSubprocessTransport.closecCs&|js"tjd|t|d�|j�dS)Nzunclosed transport %r)�source)r�warnings�warn�ResourceWarningr!)r)r/r/r0�__del__�szBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0�get_pid�szBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0�get_returncode�sz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)�fdr/r/r0�get_pipe_transport�s
z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrt��dS)N)rr@)r)r/r/r0�_check_proc�s
z#BaseSubprocessTransport._check_proccCs|j�|jj|�dS)N)rKr�send_signal)r)�signalr/r/r0rL�sz#BaseSubprocessTransport.send_signalcCs|j�|jj�dS)N)rKr�	terminate)r)r/r/r0rN�sz!BaseSubprocessTransport.terminatecCs|j�|jj�dS)N)rKrr?)r)r/r/r0r?�szBaseSubprocessTransport.killc	#s^y�j}�j}|jdk	rB|j�fdd�|j�EdH\}}|�jd<|jdk	rv|j�fdd�|j�EdH\}}|�jd<|jdk	r�|j�fdd�|j�EdH\}}|�jd<�jdk	s�t	�|j
�jj��x"�jD]\}}|j
|f|��q�Wd�_WnDt
k
�r8}z&|dk	�r(|j��r(|j|�WYdd}~Xn"X|dk	�rZ|j��rZ|jd�dS)Ncs
t�d�S)Nr)�WriteSubprocessPipeProtor/)r)r/r0�<lambda>�sz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>rcs
t�d�S)Nr)�ReadSubprocessPipeProtor/)r)r/r0rP�srcs
t�d�S)Nr	)rQr/)r)r/r0rP�sr	)rrrZconnect_write_piperr
Zconnect_read_piperr�AssertionError�	call_soonr�connection_made�	Exception�	cancelledZ
set_exception�
set_result)	r)r,�procr*�_r6�callback�data�excr/)r)r0r(�s8









z&BaseSubprocessTransport._connect_pipescGs2|jdk	r|jj||f�n|jj|f|��dS)N)rr4rrS)r)�cbr[r/r/r0�_call�s
zBaseSubprocessTransport._callcCs|j|jj||�|j�dS)N)r^rZpipe_connection_lost�_try_finish)r)rIr\r/r/r0�_pipe_connection_lost�sz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||�dS)N)r^rZpipe_data_received)r)rIr[r/r/r0�_pipe_data_received�sz+BaseSubprocessTransport._pipe_data_receivedcCs�|dk	st|��|jdks$t|j��|jj�r<tjd||�||_|jjdkrV||j_|j|j	j
�|j�x |jD]}|j
�st|j|�qtWd|_dS)Nz%r exited with return code %r)rRrrr#rr8r�
returncoder^rZprocess_exitedr_rrVrW)r)rbr,r/r/r0�_process_exited�s
z'BaseSubprocessTransport._process_exitedccs0|jdk	r|jS|jj�}|jj|�|EdHS)zdWait until the process exit and return the process return code.

        This method is a coroutine.N)rrZ
create_futurerr4)r)r,r/r/r0�_wait�s


zBaseSubprocessTransport._waitcCsJ|jst�|jdkrdStdd�|jj�D��rFd|_|j|jd�dS)Ncss|]}|dk	o|jVqdS)N)�disconnected)�.0�pr/r/r0�	<genexpr>�sz6BaseSubprocessTransport._try_finish.<locals>.<genexpr>T)rrRr�allrr>r^�_call_connection_lost)r)r/r/r0r_�s
z#BaseSubprocessTransport._try_finishcCs*z|jj|�Wdd|_d|_d|_XdS)N)r�connection_lostrr)r)r\r/r/r0rj�s
z-BaseSubprocessTransport._call_connection_lost)NN)r3�
__module__�__qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r^r`rarcrdr_rj�
__classcell__r/r/)r.r0rs0)%	rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)rOcCs||_||_d|_d|_dS)NF)rXrIr6re)r)rXrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs
||_dS)N)r6)r)Z	transportr/r/r0rTsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|�d|_dS)NT)rerXr`rI)r)r\r/r/r0rksz(WriteSubprocessPipeProto.connection_lostcCs|jjj�dS)N)rXr�
pause_writing)r)r/r/r0rosz&WriteSubprocessPipeProto.pause_writingcCs|jjj�dS)N)rXr�resume_writing)r)r/r/r0rpsz'WriteSubprocessPipeProto.resume_writingN)	r3rlrmrrTr9rkrorpr/r/r/r0rOsrOc@seZdZdd�ZdS)rQcCs|jj|j|�dS)N)rXrarI)r)r[r/r/r0�
data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rlrmrqr/r/r/r0rQ!srQ)rrrC�rrrZ
coroutinesr�logrZSubprocessTransportrZBaseProtocolrOZProtocolrQr/r/r/r0�<module>s{PK=�\VWX�EEtest_utils.cpython-36.pycnu�[���3


 \�:�
@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddl
mZddlmZddlmZmZyddlZWnek
r�dZYnXddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddl m!Z!ddl"m#Z#e	j$dk�rHddl%m&Z&nddlm&Z&dd�Z'e'd�Z(e'd�Z)dd�Z*dd�Z+dRdd�Z,dd�Z-Gdd �d e�Z.Gd!d"�d"e�Z/Gd#d$�d$�Z0Gd%d&�d&e0e/�Z1d'd(�d)d*�Z2e3ed+��rZGd,d-�d-ej4e�Z5Gd.d/�d/e5e�Z6Gd0d1�d1e6�Z7Gd2d3�d3e0e7�Z8d4d5�Z9ej:d6d7��Z;ej:d'd(�d8d9��Z<ej:d:dd'd;�d<d=��Z=d>d?�Z>Gd@dA�dAej?�Z@GdBdC�dCejA�ZBdDdE�ZCGdFdG�dGeD�ZEdHdI�ZFGdJdK�dKe
jG�ZGej:dLdM��ZHejIejJejKfdNdO�ZLdPdQ�ZMdS)SzUtilities shared by tests.�N)�mock)�
HTTPServer)�WSGIRequestHandler�
WSGIServer�)�base_events)�compat)�events)�futures)�	selectors)�tasks)�	coroutine)�logger)�supportZwin32)�
socketpaircCs`ttd�r*tjjtj|�}tjj|�r*|Stjjtjjtj�d|�}tjj|�rT|St	|��dS)N�
TEST_HOME_DIR�test)
�hasattrr�os�path�joinr�isfile�dirname�__file__�FileNotFoundError)�filename�fullname�r�*/usr/lib64/python3.6/asyncio/test_utils.py�	data_file-s
rzssl_cert.pemzssl_key.pemcCstdkrdStjtj�SdS)N)�ssl�
SSLContextZPROTOCOL_SSLv23rrrr�dummy_ssl_context<sr"c
Cs@tdd��}|�}|j|�}d|_z|j|�Wd|j�XdS)NcSsdS)Nrrrrr�onceDszrun_briefly.<locals>.onceF)r
Zcreate_taskZ_log_destroy_pending�run_until_complete�close)�loopr#�gen�trrr�run_brieflyCs
r)�cCsTtj�|}xB|�sN|dk	r8|tj�}|dkr8tj��|jtjd|d��qWdS)Nrg����MbP?)r&)�timer
�TimeoutErrorr$rZsleep)r&Zpred�timeoutZdeadlinerrr�	run_untilRsr.cCs|j|j�|j�dS)z�Legacy API to run once through the event loop.

    This is the recommended pattern for test code.  It will poll the
    selector once and run all callbacks scheduled in response to I/O
    events.
    N)Z	call_soon�stopZrun_forever)r&rrr�run_once\sr0c@seZdZdd�Zdd�ZdS)�SilentWSGIRequestHandlercCstj�S)N)�io�StringIO)�selfrrr�
get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4�format�argsrrr�log_messagelsz$SilentWSGIRequestHandler.log_messageN)�__name__�
__module__�__qualname__r5r8rrrrr1gsr1cs(eZdZdZ�fdd�Zdd�Z�ZS)�SilentWSGIServer�cs"t�j�\}}|j|j�||fS)N)�super�get_request�
settimeout�request_timeout)r4�request�client_addr)�	__class__rrr?tszSilentWSGIServer.get_requestcCsdS)Nr)r4rB�client_addressrrr�handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF�
__classcell__rr)rDrr<psr<c@seZdZdd�ZdS)�SSLWSGIServerMixincCs^t}t}tj�}|j||�|j|dd�}y|j|||�|j�Wntk
rXYnXdS)NT)Zserver_side)	�ONLYKEY�ONLYCERTr r!Zload_cert_chainZwrap_socketZRequestHandlerClassr%�OSError)r4rBrEZkeyfileZcertfile�contextZssockrrr�finish_requestsz!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@seZdZdS)�
SSLWSGIServerN)r9r:r;rrrrrN�srNF)�use_sslc
#svdd�}|r|n|}||t���j|��j�_tj�fdd�d�}|j�z
�VWd�j��j�|j	�XdS)NcSsd}dg}|||�dgS)Nz200 OK�Content-type�
text/plainsTest message)rPrQr)�environZstart_responseZstatusZheadersrrr�app�s
z_run_test_server.<locals>.appcs�jdd�S)Ng�������?)Z
poll_interval)Z
serve_foreverr)�httpdrr�<lambda>�sz"_run_test_server.<locals>.<lambda>)�target)
r1Zset_appZserver_address�address�	threadingZThread�start�shutdownZserver_closer)rWrO�
server_cls�server_ssl_clsrSZserver_classZ
server_threadr)rTr�_run_test_server�s


r]ZAF_UNIXc@seZdZdd�ZdS)�UnixHTTPServercCstjj|�d|_d|_dS)Nz	127.0.0.1�P)�socketserver�UnixStreamServer�server_bindZserver_nameZserver_port)r4rrrrb�szUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^�sr^cs(eZdZdZdd�Z�fdd�Z�ZS)�UnixWSGIServerr=cCstj|�|j�dS)N)r^rbZ
setup_environ)r4rrrrb�s
zUnixWSGIServer.server_bindcs"t�j�\}}|j|j�|dfS)N�	127.0.0.1�)rdre)r>r?r@rA)r4rBrC)rDrrr?�szUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrc�srcc@seZdZdd�ZdS)�SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrF�sz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrf�srfc@seZdZdS)�UnixSSLWSGIServerN)r9r:r;rrrrrg�srgc	Cstj��}|jSQRXdS)N)�tempfileZNamedTemporaryFile�name)�filerrr�gen_unix_socket_path�s
rkccs<t�}z
|VWdytj|�Wntk
r4YnXXdS)N)rkr�unlinkrK)rrrr�unix_socket_path�s
rmc
cs,t��}t||ttd�EdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrr�run_test_unix_server�srnz	127.0.0.1)�host�portrOccst||f|ttd�EdHdS)N)rWrOr[r\)r]r<rN)rorprOrrr�run_test_server�s
rqcCsPi}x4t|�D](}|jd�r(|jd�r(qtdd�||<qWtd|f|j|��S)N�__)�return_valueZTestProtocol)�dir�
startswith�endswith�MockCallback�type�	__bases__)�baseZdctrirrr�make_test_protocol�sr{c@s6eZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)
�TestSelectorcCs
i|_dS)N)�keys)r4rrr�__init__szTestSelector.__init__NcCstj|d||�}||j|<|S)Nr)rZSelectorKeyr})r4�fileobjr	�data�keyrrr�registers
zTestSelector.registercCs|jj|�S)N)r}�pop)r4rrrr�
unregisterszTestSelector.unregistercCsgS)Nr)r4r-rrr�selectszTestSelector.selectcCs|jS)N)r})r4rrr�get_mapszTestSelector.get_map)N)r9r:r;r~r�r�r�r�rrrrr|s

r|cs�eZdZdZd-�fdd�	Zdd�Zdd�Z�fd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Z�fd%d&�Z�fd'd(�Zd)d*�Zd+d,�Z�ZS).�TestLoopa�Loop for unittests.

    It manages self time directly.
    If something scheduled to be executed later then
    on next loop iteration after all ready handlers done
    generator passed to __init__ is calling.

    Generator should be like this:

        def gen():
            ...
            when = yield ...
            ... = yield time_advance

    Value returned by yield is absolute time of next scheduled handler.
    Value passed to yield is time advance to move loop's time forward.
    Ncsvt�j�|dkr"dd�}d|_nd|_|�|_t|j�d|_d|_g|_t�|_	i|_
i|_|j�t
j�|_dS)Ncss
dVdS)Nrrrrrr',szTestLoop.__init__.<locals>.genFTrg��&�.>)r>r~�_check_on_close�_gen�next�_timeZ_clock_resolution�_timersr|Z	_selector�readers�writers�reset_counters�weakref�WeakValueDictionary�_transports)r4r')rDrrr~(s

zTestLoop.__init__cCs|jS)N)r�)r4rrrr+?sz
TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r�)r4�advancerrr�advance_timeBszTestLoop.advance_timecsBt�j�|jr>y|jjd�Wntk
r4Yn
Xtd��dS)NrzTime generator is not finished)r>r%r�r��send�
StopIteration�AssertionError)r4)rDrrr%Gs
zTestLoop.closecGstj|||�|j|<dS)N)r	�Handler�)r4�fd�callbackr7rrr�_add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)�remove_reader_countr�)r4r�rrr�_remove_readerTs

zTestLoop._remove_readercGsh||jkrtd|�d���|j|}|j|krDtd|j�d|����|j|krdtd|j�d|����dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )r�r��	_callback�_args)r4r�r�r7�handlerrr�
assert_reader\s



zTestLoop.assert_readercCs||jkrtd|�d���dS)Nzfd z is registered)r�r�)r4r�rrr�assert_no_readergs
zTestLoop.assert_no_readercGstj|||�|j|<dS)N)r	r�r�)r4r�r�r7rrr�_add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)�remove_writer_countr�)r4r�rrr�_remove_writerns

zTestLoop._remove_writercGs^||jkstdj|���|j|}|j|ks>tdj|j|���|j|ksZtdj|j|���dS)Nzfd {} is not registeredz{!r} != {!r})r�r�r6r�r�)r4r�r�r7r�rrr�
assert_writervs
zTestLoop.assert_writercCs8y|j|}Wntk
r"YnXtdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r��KeyError�RuntimeErrorr6)r4r�Z	transportrrr�_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j|�|j||f|��S)zAdd a reader callback.)r�r�)r4r�r�r7rrr�
add_reader�s
zTestLoop.add_readercCs|j|�|j|�S)zRemove a reader callback.)r�r�)r4r�rrr�
remove_reader�s
zTestLoop.remove_readercGs|j|�|j||f|��S)zAdd a writer callback..)r�r�)r4r�r�r7rrr�
add_writer�s
zTestLoop.add_writercCs|j|�|j|�S)zRemove a writer callback.)r�r�)r4r�rrr�
remove_writer�s
zTestLoop.remove_writercCstjt�|_tjt�|_dS)N)�collections�defaultdict�intr�r�)r4rrrr��szTestLoop.reset_counterscs:t�j�x$|jD]}|jj|�}|j|�qWg|_dS)N)r>�	_run_oncer�r�r�r�)r4�whenr�)rDrrr��s

zTestLoop._run_oncecs |jj|�t�j||f|��S)N)r��appendr>�call_at)r4r�r�r7)rDrrr��szTestLoop.call_atcCsdS)Nr)r4Z
event_listrrr�_process_events�szTestLoop._process_eventscCsdS)Nr)r4rrr�_write_to_self�szTestLoop._write_to_self)N)r9r:r;�__doc__r~r+r�r%r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rGrr)rDrr�s,

r�cKstjfddgi|��S)N�spec�__call__)rZMock)�kwargsrrrrw�srwc@seZdZdZdd�ZdS)�MockPatternz�A regex based str with a fuzzy __eq__.

    Use this helper with 'mock.assert_called_with', or anywhere
    where a regex comparison between strings is needed.

    For instance:
       mock_call.assert_called_with(MockPattern('spam.*ham'))
    cCsttjt|�|tj��S)N)�bool�re�search�str�S)r4�otherrrr�__eq__�szMockPattern.__eq__N)r9r:r;r�r�rrrrr��sr�cCs$tj|�}|dkr td|f��|S)Nzunable to get the source of %r)r	Z_get_function_source�
ValueError)�func�sourcerrr�get_function_source�s
r�c@sVeZdZedd��Zdd�dd�Zddd	�Zd
d�Zdd
�Zdd�Z	e
jsRdd�ZdS)�TestCasecCs&|j}|dk	r|jdd�|j�dS)NT)�wait)Z_default_executorrZr%)r&Zexecutorrrr�
close_loop�szTestCase.close_loopT)�cleanupcCs,|dk	st�tjd�|r(|j|j|�dS)N)r�r	�set_event_loopZ
addCleanupr�)r4r&r�rrrr��s
zTestCase.set_event_loopNcCst|�}|j|�|S)N)r�r�)r4r'r&rrr�
new_test_loop�s
zTestCase.new_test_loopcCs|jt_dS)N)�_get_running_loopr	)r4rrr�unpatch_get_running_loop�sz!TestCase.unpatch_get_running_loopcCs tj|_dd�t_tj�|_dS)NcSsdS)NrrrrrrU�sz TestCase.setUp.<locals>.<lambda>)r	r�rZthreading_setup�_thread_cleanup)r4rrr�setUp�s
zTestCase.setUpcCsB|j�tjd�|jtj�d�|j�tj|j	�tj
�dS)N)NNN)r�r	r�ZassertEqual�sys�exc_infoZ
doCleanupsrZthreading_cleanupr�Z
reap_children)r4rrr�tearDown�s
zTestCase.tearDowncOsGdd�d�}|�S)Nc@seZdZdd�Zdd�ZdS)z!TestCase.subTest.<locals>.EmptyCMcSsdS)Nr)r4rrr�	__enter__�sz+TestCase.subTest.<locals>.EmptyCM.__enter__cWsdS)Nr)r4�excrrr�__exit__�sz*TestCase.subTest.<locals>.EmptyCM.__exit__N)r9r:r;r�r�rrrr�EmptyCM�sr�r)r4r7r�r�rrr�subTest�szTestCase.subTest)N)
r9r:r;�staticmethodr�r�r�r�r�r�rZPY34r�rrrrr��s

r�ccs2tj}ztjtjd�dVWdtj|�XdS)zrContext manager to disable asyncio logger.

    For example, it can be used to ignore warnings in debug mode.
    rN)r�levelZsetLevel�loggingZCRITICAL)Z	old_levelrrr�disable_logger�s

r�cCs*tjtj�}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ	MagicMock�socket�protorx�familyZ
gettimeoutrs)r�rxr�Zsockrrr�mock_nonblocking_socketsr�cCstjddd�S)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrr�force_legacy_ssl_supportsr�)r*)Nr�r��
contextlibr2r�rr�r�r`r�rhrXr+Zunittestr�rZhttp.serverrZwsgiref.simple_serverrrr �ImportErrorrerrr	r
rrZ
coroutinesr
�logrrr�platformZ
windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrk�contextmanagerrmrnrqr{ZBaseSelectorr|Z
BaseEventLoopr�rwr�r�r�r�r�ZIPPROTO_TCPZSOCK_STREAMZAF_INETr�r�rrrr�<module>s�


	


4
PK=�\��S�zz base_events.cpython-36.opt-2.pycnu�[���3


 \��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd	lmZd
gZdZdZeeefZe ed
�Z!d(Z"dd�Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dej)ddd�dd�Z*e ed��rNd d!�Z+nd"d!�Z+d#d$�Z,Gd%d&�d&ej-�Z.Gd'd
�d
ej/�Z0dS))�N�)�compat)�
coroutines)�events)�futures)�tasks)�	coroutine)�logger�
BaseEventLoop�dg�?�AF_INET6�icCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�+/usr/lib64/python3.6/asyncio/base_events.py�_format_handle?s
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeHs


rcCsLttd�std��n4y|jtjtjd�Wntk
rFtd��YnXdS)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr�OSError)�sockrrr�_set_reuseportQs

r&cCs&ttd�r|d@tjkS|tjkSdS)N�
SOCK_NONBLOCK�)rr �SOCK_STREAM)�	sock_typerrr�_is_stream_socket\s
r+cCs&ttd�r|d@tjkS|tjkSdS)Nr'r()rr �
SOCK_DGRAM)r*rrr�_is_dgram_sockeths
r-cCsvttd�sdS|dtjtjhks(|dkr,dSt|�r<tj}nt|�rLtj}ndS|dkr^d}nVt|t�rv|dkrvd}n>t|t�r�|dkr�d}n&yt	|�}Wnt
tfk
r�dSX|tjkr�tj
g}tr�|jtj�n|g}t|t�r�|jd�}d|k�rdSxp|D]h}yJtj||�t�r@|tjk�r@|||d||ddffS|||d||ffSWntk
�rjYnX�qWdS)N�	inet_ptonr��Zidna�%)rr �IPPROTO_TCPZIPPROTO_UDPr+r-r�bytesr�int�	TypeErrorr!�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder.r$)�host�port�family�type�protoZafs�afrrr�_ipaddr_infopsL





rA)r=r>r?�flagsc
CsZ|dd�\}}t|||||�}|dk	r@|j�}	|	j|g�|	S|j||||||d�SdS)N�)r=r>r?rB)rA�
create_future�
set_result�getaddrinfo)
�addressr=r>r?rB�loopr;r<�info�futrrr�_ensure_resolved�srK�TCP_NODELAYcCs>|jtjtjhkr:t|j�r:|jtjkr:|jtjtj	d�dS)Nr)
r=r r7rr+r>r?r2r"rL)r%rrr�_set_nodelay�s
rMcCsdS)Nr)r%rrrrM�scCs.|j}t|t�r t|t�r dS|jj�dS)N)Z
_exceptionr�
BaseException�	Exception�_loop�stop)rJ�excrrr�_run_until_complete_cb�s

rSc@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
dS)�ServercCs||_||_d|_g|_dS)Nr)rP�sockets�
_active_count�_waiters)�selfrHrUrrr�__init__�szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>)�	__class__�__name__rU)rXrrr�__repr__�szServer.__repr__cCs|jd7_dS)Nr)rV)rXrrr�_attach�szServer._attachcCs.|jd8_|jdkr*|jdkr*|j�dS)Nrr)rVrU�_wakeup)rXrrr�_detach�szServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|�qW|jdkrD|j�dS)Nr)rUrPZ
_stop_servingrVr^)rXrUr%rrr�close�s

zServer.closecCs0|j}d|_x|D]}|j�s|j|�qWdS)N)rW�donerE)rX�waiters�waiterrrrr^�s

zServer._wakeupccs<|jdks|jdkrdS|jj�}|jj|�|EdHdS)N)rUrWrPrDr9)rXrcrrr�wait_closed�s

zServer.wait_closedN)r[�
__module__�__qualname__rYr\r]r_r`r^rrdrrrrrT�s
rTc
@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd�d
d
d�dd�Z	d�dd
d
d
d�dd�Z
d�dd�Zd�dd�Zd�dd�Z
ed�dd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zed'd(��Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zej�r�d3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdMdMdMdN�dOdP�Z*d�dQdR�Z+ed�d
dMdMdMd
d
d
dS�dTdU��Z,ed�dVdW��Z-ed�dMdMdMd
d
d
d
dX�dYdZ��Z.ed[d\��Z/ed�e0j1e0j2d
d]d
d
d
d^�d_d`��Z3ed
da�dbdc��Z4eddde��Z5edfdg��Z6dhdi�Z7ee8j9e8j9e8j9ddjdMdk�dldm��Z:ee8j9e8j9e8j9dddMdk�dndo��Z;dpdq�Z<drds�Z=dtdu�Z>dvdw�Z?dxdy�Z@dzd{�ZAd|d}�ZBd~d�ZCd�d��ZDd�d��ZEd�d��ZFd
S)�r
cCs�d|_d|_d|_tj�|_g|_d|_d|_d|_	t
jd�j|_
d|_|jtjjodttjjd���d|_d|_d|_d|_ttd�r�tj�|_nd|_d|_dS)NrF�	monotonicZPYTHONASYNCIODEBUGg�������?�get_asyncgen_hooks) �_timer_cancelled_count�_closed�	_stopping�collections�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�timeZget_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debug�sysrB�ignore_environment�bool�os�environ�get�slow_callback_duration�_current_handle�
_task_factory�_coroutine_wrapper_setr�weakref�WeakSet�
_asyncgens�_asyncgens_shutdown_called)rXrrrrY�s(

zBaseEventLoop.__init__cCs d|jj|j�|j�|j�fS)Nz"<%s running=%s closed=%s debug=%s>)rZr[�
is_running�	is_closed�	get_debug)rXrrrr\ szBaseEventLoop.__repr__cCstj|d�S)N)rH)rZFuture)rXrrrrD%szBaseEventLoop.create_futurecCs@|j�|jdkr0tj||d�}|jr<|jd=n|j||�}|S)N)rHr���)�
_check_closedr~rr�_source_traceback)rX�coroZtaskrrr�create_task)s

zBaseEventLoop.create_taskcCs$|dk	rt|�rtd��||_dS)Nz'task factory must be a callable or None)�callabler5r~)rX�factoryrrr�set_task_factory7s
zBaseEventLoop.set_task_factorycCs|jS)N)r~)rXrrr�get_task_factoryEszBaseEventLoop.get_task_factoryN)�extra�servercCst�dS)N)�NotImplementedError)rXr%�protocolrcr�r�rrr�_make_socket_transportIsz$BaseEventLoop._make_socket_transportF)�server_side�server_hostnamer�r�c	Cst�dS)N)r�)	rXZrawsockr��
sslcontextrcr�r�r�r�rrr�_make_ssl_transportNsz!BaseEventLoop._make_ssl_transportcCst�dS)N)r�)rXr%r�rGrcr�rrr�_make_datagram_transportTsz&BaseEventLoop._make_datagram_transportcCst�dS)N)r�)rX�piper�rcr�rrr�_make_read_pipe_transportYsz'BaseEventLoop._make_read_pipe_transportcCst�dS)N)r�)rXr�r�rcr�rrr�_make_write_pipe_transport^sz(BaseEventLoop._make_write_pipe_transportc	
Kst�dS)N)r�)
rXr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transportcsz(BaseEventLoop._make_subprocess_transportcCst�dS)N)r�)rXrrr�_write_to_selfjszBaseEventLoop._write_to_selfcCst�dS)N)r�)rX�
event_listrrr�_process_eventssszBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)rj�RuntimeError)rXrrrr�wszBaseEventLoop._check_closedcCs*|jj|�|j�s&|j|j|j��dS)N)r��discardr��call_soon_threadsafer��aclose)rX�agenrrr�_asyncgen_finalizer_hook{sz&BaseEventLoop._asyncgen_finalizer_hookcCs,|jrtjdj|�t|d�|jj|�dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call)�source)r��warnings�warn�format�ResourceWarningr��add)rXr�rrr�_asyncgen_firstiter_hook�s
z&BaseEventLoop._asyncgen_firstiter_hookccs�d|_|jdkst|j�r dSt|j�}|jj�tjdd�|D�d|d��}|EdH}x8t||�D]*\}}t|t	�rf|j
dj|�||d��qfWdS)NTcSsg|]}|j��qSr)r�)�.0Zagrrr�
<listcomp>�sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})�message�	exceptionZasyncgen)r�r��len�list�clearr�gather�ziprrO�call_exception_handlerr�)rXZ
closing_agensZ
shutdown_coroZresults�resultr�rrr�shutdown_asyncgens�s"




z BaseEventLoop.shutdown_asyncgenscCs�|j�|j�rtd��tj�dk	r,td��|j|j�tj�|_	|j
dk	rftj�}tj
|j|jd�z$tj|�x|j�|jrtPqtWWdd|_d|_	tjd�|jd�|j
dk	r�tj
|�XdS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)�	firstiter�	finalizerF)r�r�r�rZ_get_running_loop�_set_coroutine_wrapper�_debug�	threading�	get_identrqr�rvrh�set_asyncgen_hooksr�r�Z_set_running_loop�	_run_oncerk)rXZold_agen_hooksrrr�run_forever�s0







zBaseEventLoop.run_forevercCs�|j�tj|�}tj||d�}|r,d|_|jt�z>y|j�Wn,|rj|j	�rj|j
�rj|j��YnXWd|jt�X|j	�s�t
d��|j�S)N)rHFz+Event loop stopped before Future completed.)r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrSr�raZ	cancelledr�Zremove_done_callbackr�r�)rXZfutureZnew_taskrrr�run_until_complete�s 
z BaseEventLoop.run_until_completecCs
d|_dS)NT)rk)rXrrrrQ�szBaseEventLoop.stopcCsj|j�rtd��|jrdS|jr,tjd|�d|_|jj�|jj�|j	}|dk	rfd|_	|j
dd�dS)Nz!Cannot close a running event loopzClose %rTF)�wait)r�r�rjr�r	�debugrnr�rorpZshutdown)rX�executorrrrr`�s

zBaseEventLoop.closecCs|jS)N)rj)rXrrrr�szBaseEventLoop.is_closedcCs0|j�s,tjd|t|d�|j�s,|j�dS)Nzunclosed event loop %r)r�)r�r�r�r�r�r`)rXrrr�__del__s
zBaseEventLoop.__del__cCs
|jdk	S)N)rq)rXrrrr�szBaseEventLoop.is_runningcCstj�S)N)rrrg)rXrrrrrszBaseEventLoop.timecGs,|j|j�||f|��}|jr(|jd=|S)Nrr�)�call_atrrr�)rXZdelay�callbackr��timerrrr�
call_later szBaseEventLoop.call_latercGsX|j�|jr"|j�|j|d�tj||||�}|jr@|jd=tj|j	|�d|_	|S)Nr�rTr�)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushro)rX�whenr�r�r�rrrr�5szBaseEventLoop.call_atcGs@|j�|jr"|j�|j|d�|j||�}|jr<|jd=|S)N�	call_soonrr�)r�r�r�r��
_call_soonr�)rXr�r�rrrrr�Es
zBaseEventLoop.call_sooncCs>tj|�stj|�r"tdj|���t|�s:tdj||���dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZiscoroutineZiscoroutinefunctionr5r�r�)rXr��methodrrrr�Xs

zBaseEventLoop._check_callbackcCs,tj|||�}|jr|jd=|jj|�|S)Nrr�)rZHandler�rnr9)rXr�r�rrrrr�cs
zBaseEventLoop._call_sooncCs,|jdkrdStj�}||jkr(td��dS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rqr�r�r�)rXZ	thread_idrrrr�js	

zBaseEventLoop._check_threadcGs@|j�|jr|j|d�|j||�}|jr4|jd=|j�|S)Nr�rr�)r�r�r�r�r�r�)rXr�r�rrrrr�{sz"BaseEventLoop.call_soon_threadsafecGsZ|j�|jr|j|d�|dkr@|j}|dkr@tjj�}||_tj|j|f|��|d�S)N�run_in_executor)rH)	r�r�r�rp�
concurrentrZThreadPoolExecutorZwrap_futureZsubmit)rXr��funcr�rrrr��s
zBaseEventLoop.run_in_executorcCs
||_dS)N)rp)rXr�rrr�set_default_executor�sz"BaseEventLoop.set_default_executorcCs�d||fg}|r |jd|�|r2|jd|�|rD|jd|�|rV|jd|�dj|�}tjd|�|j�}tj||||||�}	|j�|}
d||
d	|	f}|
|jkr�tj|�n
tj|�|	S)
Nz%s:%rz	family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@�@)	r9�joinr	r�rrr rFr|rI)rXr;r<r=r>r?rB�msg�t0Zaddrinfo�dtrrr�_getaddrinfo_debug�s(


z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc	Cs>|jr |jd|j||||||�S|jdtj||||||�SdS)N)r�r�r�r rF)rXr;r<r=r>r?rBrrrrF�s


zBaseEventLoop.getaddrinfocCs|jdtj||�S)N)r�r �getnameinfo)rXZsockaddrrBrrrr��szBaseEventLoop.getnameinfo)�sslr=r?rBr%�
local_addrr�c#s|
dk	r|rtd��|
dkr2|r2|s.td��|}
|dk	sD|dk	�r�|dk	rTtd��t||f|tj|||d�}|g}|	dk	r�t|	|tj|||d�}
|j|
�nd}
tj||d�EdH|j�}|s�td��|
dk	r�|
j�}|s�td��g}�x�|D�]B\}}}}}y�tj|||d�}|j	d�|
dk	�r�x�|D]j\}}}}}y|j
|�PWnHtk
�r�}z*t|jd	j||j
j���}|j|�WYdd}~XnX�q.W|j�d}w�|j�r�tjd
||�|j||�EdHWn^tk
�r}z"|dk	�r�|j�|j|�WYdd}~Xq�|dk	�r,|j��Yq�XPq�Wt|�dk�rR|d�nJt|d��t�fd
d�|D���r~|d�tdjdjdd�|D�����n,|dk�r�td��t|j��s�tdj|���|j||||
�EdH\}}|j�r
|jd�}tjd|||||�||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|��kVqdS)N)r)r�rR)�modelrr�	<genexpr>sz2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, css|]}t|�VqdS)N)r)r�rRrrrr�#sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rr�r�r$�setblocking�bind�errnor��strerror�lowerr`r�r	r��sock_connectr�r�allr�r+r>�_create_connection_transport�get_extra_info)rX�protocol_factoryr;r<r�r=r?rBr%r�r��f1�fs�f2�infosZladdr_infos�
exceptionsr>ZcnamerG�_ZladdrrR�	transportr�r)r�r�create_connection�s�





"




zBaseEventLoop.create_connectionc
	cs�|jd�|�}|j�}|rFt|t�r*dn|}|j||||||d�}	n|j|||�}	y|EdHWn|	j��YnX|	|fS)NF)r�r�)r�rDrrxr�r�r`)
rXr%r�r�r�r�r�rcr�r�rrrr�=s
z*BaseEventLoop._create_connection_transport)r=r?rB�
reuse_address�
reuse_port�allow_broadcastr%c#s8|
dk	r�t|
j�s tdj|
����s@�s@|s@|s@|s@|s@|s@|	r~t��||||||	d�}djdd�|j�D��}tdj|���|
jd�d}
�n*�p��s�|dkr�td	��||fdff}n�tj	�}x�d�fd
�ffD]~\}}|dk	r�t
||tj|||d�EdH}|�st
d��xB|D]:\}}}}}||f}||k�r>ddg||<||||<�qWq�W��fd
d�|j�D�}|�sztd��g}|dk�r�tjdk�o�tjdk}�x|D�]\\}}\}}d}
d}
y�tj|tj|d�}
|�r�|
jtjtjd
�|�r�t|
�|	�r|
jtjtjd
�|
jd���r,|
j|���rH|j|
|�EdH|}
Wn^t
k
�r�}z"|
dk	�rp|
j�|j|�WYdd}~Xn"|
dk	�r�|
j��YnXP�q�W|d�|�}|j�}|j|
||
|�}|j�r
��r�tjd��||�ntj d�||�y|EdHWn|j��YnX||fS)Nz#A UDP Socket was expected, got {!r})r��remote_addrr=r?rBr�r�r�z, css"|]\}}|rdj||�VqdS)z{}={}N)r�)r��k�vrrrr�isz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyr)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}�r|ddkp*�o*|ddks||f�qS)rNrr)r��keyZ	addr_pair)r�r�rrr��sz:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address information�posix�cygwin)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)!r-r>r!r��dictr��itemsr�rl�OrderedDictrKr r,r$ry�namerv�platformr"r#�SO_REUSEADDRr&ZSO_BROADCASTr�r�r`r9rDr�r�r	rIr�)rXr�r�r�r=r?rBr�r�r�r%ZoptsZproblemsZr_addrZaddr_pairs_infoZ
addr_infos�idxZaddrr�Zfamr�ZprorGrr�Z
local_addressZremote_addressrRr�rcr�r)r�r�r�create_datagram_endpointUs�








z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||d�EdH}|s0tdj|���|S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r�)rXr;r<r=rBr�rrr�_create_server_getaddrinfo�s
z(BaseEventLoop._create_server_getaddrinfor)r=rBr%�backlogr�r�r�c #s�t|t�rtd��|dk	s$�dk	�r|dk	r4td��|	dkrPtjdkoNtjdk}	g}|dkrddg}n$t|t�s|t|t	j
�r�|g}n|}����fdd�|D�}
tj|
d�i�EdH}t
tjj|��}d	}�z �x|D�]
}|\}}}}}ytj|||�}Wn6tjk
�r2�j�r,tjd
|||dd�w�YnX|j|�|	�rV|jtjtjd�|
�rdt|�t�r�|tjk�r�ttd
��r�|jtjtjd�y|j |�Wq�t!k
�r�}z t!|j"d||j#j$�f��WYdd}~Xq�Xq�Wd}Wd|�sx|D]}|j%��q�WXn2|dk�r"td��t&|j'��s<tdj(|���|g}t)�|�}x4|D],}|j*|�|j+d	��j,|||||��qRW�j�r�tj-d|�|S)Nz*ssl argument must be an SSLContext or Nonez8host/port and sock can not be specified at the same timerrr0csg|]}�j|���d��qS))r=rB)r)r�r;)r=rBr<rXrrr�sz/BaseEventLoop.create_server.<locals>.<listcomp>rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)�exc_info�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z
%r is serving).rrxr5r!ryrrvrrrl�Iterablerr��set�	itertools�chain�
from_iterabler �errorr�r	�warningr9r"r#r	r&r8rrrZIPV6_V6ONLYr�r$r�r�r�r`r+r>r�rTZlistenr�Z_start_servingrI)rXr�r;r<r=rBr%r
r�r�r�rUZhostsr�r�Z	completed�resr@Zsocktyper?Z	canonnameZsa�errr�r)r=rBr<rXr�
create_server�s�


(





zBaseEventLoop.create_server)r�ccs^t|j�stdj|���|j|||ddd�EdH\}}|jrV|jd�}tjd|||�||fS)Nz&A Stream Socket was expected, got {!r}r0T)r�r z%r handled: (%r, %r))	r+r>r!r�r�r�r�r	r�)rXr�r%r�r�r�rrr�connect_accepted_socketAs


z%BaseEventLoop.connect_accepted_socketccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz Read pipe %r connected: (%r, %r))rDr�r`r�r	r��fileno)rXr�r�r�rcr�rrr�connect_read_pipeXszBaseEventLoop.connect_read_pipeccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz!Write pipe %r connected: (%r, %r))rDr�r`r�r	r�r)rXr�r�r�rcr�rrr�connect_write_pipeisz BaseEventLoop.connect_write_pipecCs�|g}|dk	r |jdt|��|dk	rF|tjkrF|jdt|��n4|dk	r`|jdt|��|dk	rz|jdt|��tjdj|��dS)Nzstdin=%szstdout=stderr=%sz	stdout=%sz	stderr=%s� )r9rrrr	r�r�)rXr�r�r�r�rIrrr�_log_subprocesszszBaseEventLoop._log_subprocessT)r�r�r��universal_newlinesr�r�c
ks�t|ttf�std��|r"td��|s.td��|dkr>td��|�}
d}|jrfd|}|j||||�|j|
|d||||f|	�EdH}|jr�|dk	r�tjd||�||
fS)	Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r)	rr3rr!r�rr�r	rI)
rXr��cmdr�r�r�r r�r�r�r��	debug_logr�rrr�subprocess_shell�s$zBaseEventLoop.subprocess_shellcos�|rtd��|rtd��|dkr(td��|f|	}x,|D]$}t|ttf�s8tdt|�j��q8W|�}
d}|jr�d|}|j||||�|j	|
|d||||f|
�EdH}|jr�|dk	r�t
jd||�||
fS)	Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r)r!rrr3r5r>r[r�rr�r	rI)rXr�Zprogramr�r�r�r r�r�r�r�Z
popen_args�argr�r"r�rrr�subprocess_exec�s,

zBaseEventLoop.subprocess_execcCs|jS)N)rt)rXrrr�get_exception_handler�sz#BaseEventLoop.get_exception_handlercCs*|dk	r t|�r tdj|���||_dS)Nz/A callable object or None is expected, got {!r})r�r5r�rt)rXZhandlerrrr�set_exception_handler�sz#BaseEventLoop.set_exception_handlerc	Cs|jd�}|sd}|jd�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}x�t|�D]�}|d
kr~qp||}|dkr�djtj|��}d}||j	�7}n2|dkr�djtj|��}d	}||j	�7}nt
|�}|jd
j||��qpWt
jdj|�|d�dS)Nr�z!Unhandled exception in event loopr�FZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last):
z+Handle created at (most recent call last):
z{}: {}�
)r>r�r�)r{r>�
__traceback__r}r��sortedr��	traceback�format_list�rstriprr9r�r	r)	rX�contextr�r�rZ	log_linesr�value�tbrrr�default_exception_handler�s6


z'BaseEventLoop.default_exception_handlercCs�|jdkr>y|j|�Wq�tk
r:tjddd�Yq�Xnny|j||�Wn\tk
r�}z@y|jd||d��Wn"tk
r�tjddd�YnXWYdd}~XnXdS)Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)r�r�r.zeException in default exception handler while handling an unexpected error in custom exception handler)rtr1rOr	r)rXr.rRrrrr�s"
z$BaseEventLoop.call_exception_handlercCs|jr
dS|jj|�dS)N)�
_cancelledrnr9)rXrrrr�
_add_callback9szBaseEventLoop._add_callbackcCs|j|�|j�dS)N)r3r�)rXrrrr�_add_callback_signalsafeAs
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)rori)rXrrrr�_timer_handle_cancelledFsz%BaseEventLoop._timer_handle_cancelledcCs�t|j�}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|�q,Wtj|�||_d|_n8x6|jr�|jdjr�|jd8_tj	|j�}d|_qfWd}|j
s�|jr�d}n*|jr�|jdj}t
td||j��t�}|jo�|dk�r�|j�}|jj|�}|j�|}|dk�rtj}	ntj}	t|�}
|dk�rLtj|	d|d|
�nD|
�rntj|	d|d|d|
�n"|dk�r�tj|	d|d|d�n|jj|�}|j|�|j�|j}xD|j�r�|jd}|j|k�r�Ptj	|j�}d|_|j
j|��q�Wt|j
�}x�t|�D]|}
|j
j�}|j�r*�q|j�r�zD||_|j�}|j�|j�|}||jk�rttj d	t!|�|�Wdd|_Xn|j��qWd}dS)
NFrrg�?zpoll took %.3f ms: %s eventsg@�@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"r�ro�_MIN_SCHEDULED_TIMER_HANDLESri�%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr2r9r��heapify�heappoprnrkZ_when�min�maxrr�MAXIMUM_SELECT_TIMEOUTr�Z	_selectorZselect�logging�INFO�DEBUGr	�logr�rs�range�popleftr}Z_runr|rr)rXZsched_countZ
new_scheduledrZtimeoutr�r�r�r��levelZneventZend_timeZntodo�irrrr�Ks�











zBaseEventLoop._run_oncecCs�ytj}tj}Wntk
r$dSXt|�}|j|kr<dStj}|�}|rz|d|fkrjtj	d|t
�q�||�d|_n,|d|fkr�tj	d|t
�n|d�d|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF)rv�set_coroutine_wrapper�get_coroutine_wrapper�AttributeErrorrxrrZ
debug_wrapperr�r��RuntimeWarning)rX�enabledZset_wrapperZget_wrapper�wrapperZcurrent_wrapperrrrr��s.

z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r�)rXrrrr��szBaseEventLoop.get_debugcCs||_|j�r|j|�dS)N)r�r�r�)rXrIrrrru�szBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)NN)F)NN)NN)Gr[rerfrYr\rDr�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�rQr`r�rZPY34r�r�rrr�r�r�r�r�r�r�r�r�r�rFr�r�r�rrr r6Z
AI_PASSIVErrrrrrrr#r%r&r'r1r�r3r4r5r�r�r�rurrrrr
�s�!


		%	

u	`
12c!i�Q)1rlZconcurrent.futuresr�r��inspectrr=ryr rr�rrr+rvr�r�r0rrrrrrr@r	�__all__r6r7�BrokenPipeError�ConnectionResetError�ConnectionAbortedErrorZ_FATAL_ERROR_IGNORErr8r<rrr&r+r-rAr)rKrMrSZAbstractServerrTZAbstractEventLoopr
rrrr�<module>sT
		;


/PK=�\�#�~� � queues.cpython-36.opt-1.pycnu�[���3


 \�@s�dZdddddgZddlZddlZdd	lmZdd
lmZddlmZddlm	Z	Gd
d�de
�ZGdd�de
�ZGdd�d�Z
Gdd�de
�ZGdd�de
�Zejs�e
Zejd�dS)ZQueues�Queue�
PriorityQueue�	LifoQueue�	QueueFull�
QueueEmpty�N�)�compat)�events)�locks)�	coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object
    which is empty.
    N)�__name__�
__module__�__qualname__�__doc__�rr�&/usr/lib64/python3.6/asyncio/queues.pyrsc@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue
    object which is full.
    N)rr
rrrrrrrsc@s�eZdZdZd)dd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�Zdd�Zedd��Zdd �Zed!d"��Zd#d$�Zd%d&�Zed'd(��ZdS)*raA queue, useful for coordinating producer and consumer coroutines.

    If maxsize is less than or equal to zero, the queue size is infinite. If it
    is an integer greater than 0, then "yield from put()" will block when the
    queue reaches maxsize, until an item is removed by get().

    Unlike the standard library Queue, you can reliably know this Queue's size
    with qsize(), since your single-threaded asyncio application won't be
    interrupted between calling qsize() and doing an operation on the Queue.
    rN)�loopcCsb|dkrtj�|_n||_||_tj�|_tj�|_d|_t	j
|jd�|_|jj�|j
|�dS)Nr)r)r	Zget_event_loop�_loop�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr
ZEvent�	_finished�set�_init)�self�maxsizerrrr�__init__(s


zQueue.__init__cCstj�|_dS)N)rr�_queue)rrrrrr:szQueue._initcCs
|jj�S)N)r �popleft)rrrr�_get=sz
Queue._getcCs|jj|�dS)N)r �append)r�itemrrr�_put@sz
Queue._putcCs*x$|r$|j�}|j�s|jd�PqWdS)N)r!�doneZ
set_result)r�waitersZwaiterrrr�_wakeup_nextEs

zQueue._wakeup_nextcCsdjt|�jt|�|j��S)Nz<{} at {:#x} {}>)�format�typer�id�_format)rrrr�__repr__MszQueue.__repr__cCsdjt|�j|j��S)Nz<{} {}>)r)r*rr,)rrrr�__str__Qsz
Queue.__str__cCszdj|j�}t|dd�r,|djt|j��7}|jrF|djt|j��7}|jr`|djt|j��7}|jrv|dj|j�7}|S)Nzmaxsize={!r}r z _queue={!r}z
 _getters[{}]z
 _putters[{}]z	 tasks={})	r)r�getattr�listr r�lenrr)r�resultrrrr,Tsz
Queue._formatcCs
t|j�S)zNumber of items in the queue.)r1r )rrrr�qsize`szQueue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz
Queue.maxsizecCs|jS)z3Return True if the queue is empty, False otherwise.)r )rrrr�emptyiszQueue.emptycCs |jdkrdS|j�|jkSdS)z�Return True if there are maxsize items in the queue.

        Note: if the Queue was initialized with maxsize=0 (the default),
        then full() is never True.
        rFN)rr3)rrrr�fullms
z
Queue.fullc	cstxh|j�rh|jj�}|jj|�y|EdHWq|j�|j�r^|j�r^|j|j��YqXqW|j|�S)z�Put an item into the queue.

        Put an item into the queue. If the queue is full, wait until a free
        slot is available before adding item.

        This method is a coroutine.
        N)	r5r�
create_futurerr#�cancel�	cancelledr(�
put_nowait)rr$Zputterrrr�putxs	

z	Queue.putcCs>|j�rt�|j|�|jd7_|jj�|j|j�dS)zyPut an item into the queue without blocking.

        If no free slot is immediately available, raise QueueFull.
        rN)r5rr%rr�clearr(r)rr$rrrr9�s

zQueue.put_nowaitccs�x�|j�r�|jj�}|jj|�y|EdHWq|j�y|jj|�Wntk
rbYnX|j�r�|j�r�|j	|j��YqXqW|j
�S)z�Remove and return an item from the queue.

        If queue is empty, wait until an item is available.

        This method is a coroutine.
        N)r4rr6rr#r7�remove�
ValueErrorr8r(�
get_nowait)r�getterrrr�get�s

z	Queue.getcCs$|j�rt�|j�}|j|j�|S)z�Remove and return an item from the queue.

        Return an item if one is immediately available, else raise QueueEmpty.
        )r4rr"r(r)rr$rrrr>�s
zQueue.get_nowaitcCs8|jdkrtd��|jd8_|jdkr4|jj�dS)a$Indicate that a formerly enqueued task is complete.

        Used by queue consumers. For each get() used to fetch a task,
        a subsequent call to task_done() tells the queue that the processing
        on the task is complete.

        If a join() is currently blocking, it will resume when all items have
        been processed (meaning that a task_done() call was received for every
        item that had been put() into the queue).

        Raises ValueError if called more times than there were items placed in
        the queue.
        rz!task_done() called too many timesrN)rr=rr)rrrr�	task_done�s


zQueue.task_doneccs|jdkr|jj�EdHdS)aBlock until all items in the queue have been gotten and processed.

        The count of unfinished tasks goes up whenever an item is added to the
        queue. The count goes down whenever a consumer calls task_done() to
        indicate that the item was retrieved and all work on it is complete.
        When the count of unfinished tasks drops to zero, join() unblocks.
        rN)rr�wait)rrrr�join�s	
z
Queue.join)r)rr
rrrrr"r%r(r-r.r,r3�propertyrr4r5rr:r9r@r>rArCrrrrrs&
c@s4eZdZdZdd�Zejfdd�Zejfdd�Z	dS)	rz�A subclass of Queue; retrieves entries in priority order (lowest first).

    Entries are typically tuples of the form: (priority number, data).
    cCs
g|_dS)N)r )rrrrrr�szPriorityQueue._initcCs||j|�dS)N)r )rr$�heappushrrrr%�szPriorityQueue._putcCs
||j�S)N)r )r�heappoprrrr"�szPriorityQueue._getN)
rr
rrr�heapqrEr%rFr"rrrrr�sc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rzEA subclass of Queue that retrieves most recently added entries first.cCs
g|_dS)N)r )rrrrrr�szLifoQueue._initcCs|jj|�dS)N)r r#)rr$rrrr%�szLifoQueue._putcCs
|jj�S)N)r �pop)rrrrr"�szLifoQueue._getN)rr
rrrr%r"rrrrr�s�
JoinableQueue)r�__all__rrG�rr	r
Z
coroutinesr�	ExceptionrrrrrZPY35rIr#rrrr�<module>s H
PK=�\#���]w]wunix_events.cpython-36.pycnu�[���3


 \���
@s dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZddlmZdddddgZejdkr�ed��dd�Zy
ejZWnek
�r,dd�ZYnXGdd�dej�Z e!ed��rVdd�Z"nddl#Z#d d�Z"Gd!d"�d"ej$�Z%Gd#d$�d$ej&ej'�Z(e!ed%��r�ej)Z*nddl#Z#d&d'�Z*Gd(d)�d)ej+�Z,Gd*d�d�Z-Gd+d,�d,e-�Z.Gd-d�de.�Z/Gd.d�de.�Z0Gd/d0�d0ej1�Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.�N�)�base_events)�base_subprocess)�compat)�	constants)�
coroutines)�events)�futures)�selector_events)�	selectors)�
transports)�	coroutine)�logger�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N�)�signum�framerr�+/usr/lib64/python3.6/asyncio/unix_events.py�_sighandler_noop%srcCs|S)Nr)�pathrrr�<lambda>.srcs�eZdZdZd"�fdd�	Zdd�Z�fdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd#dd�Zd$dd�Z
ed%dd��Zdd�Zedddd�dd��Zed&dddd�d d!��Z�ZS)'�_UnixSelectorEventLoopzdUnix event loop.

    Adds signal handling and UNIX Domain Socket support to SelectorEventLoop.
    Ncst�j|�i|_dS)N)�super�__init__�_signal_handlers)�self�selector)�	__class__rrr7sz_UnixSelectorEventLoop.__init__cCstj�S)N)�socketZ
socketpair)rrrr�_socketpair;sz"_UnixSelectorEventLoop._socketpaircs^t�j�tj�s2xFt|j�D]}|j|�qWn(|jrZtjd|�d�t	|d�|jj
�dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)�source)r�close�sys�
is_finalizing�listr�remove_signal_handler�warnings�warn�ResourceWarning�clear)r�sig)r!rrr%>s
z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|�qWdS)N)�_handle_signal)r�datarrrr�_process_self_dataLs
z)_UnixSelectorEventLoop._process_self_datac+GsHtj|�stj|�rtd��|j|�|j�ytj|jj	��Wn2t
tfk
rt}ztt
|���WYdd}~XnXtj|||�}||j|<ytj|t�tj|d�Wn�tk
�rB}zz|j|=|j�sytjd�Wn4t
tfk
�r}ztjd|�WYdd}~XnX|jtjk�r0tdj|���n�WYdd}~XnXdS)z�Add a handler for a signal.  UNIX only.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        z3coroutines cannot be used with add_signal_handler()NFrzset_wakeup_fd(-1) failed: %szsig {} cannot be caught���)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signalZ
_check_closed�signal�
set_wakeup_fdZ_csock�fileno�
ValueError�OSError�RuntimeError�strrZHandlerr�siginterruptr�info�errno�EINVAL�format)rr.�callback�args�exc�handleZnexcrrr�add_signal_handlerSs0



z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|�}|dkrdS|jr*|j|�n
|j|�dS)z2Internal helper that is the actual signal handler.N)r�getZ
_cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/�sz%_UnixSelectorEventLoop._handle_signalc&Cs�|j|�y|j|=Wntk
r*dSX|tjkr>tj}ntj}ytj||�Wn@tk
r�}z$|jtj	kr�t
dj|���n�WYdd}~XnX|js�ytjd�Wn2t
tfk
r�}ztjd|�WYdd}~XnXdS)zwRemove a handler for a signal.  UNIX only.

        Return True if a signal handler was removed, False if not.
        Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr2)r4r�KeyErrorr5�SIGINT�default_int_handler�SIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)�s(

z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|t�stdj|���d|ko,tjknsDtdj|tj���dS)z�Internal helper to validate a signal.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        zsig must be an int, not {!r}rzsig {} out of range(1, {})N)�
isinstance�intr3r@r5�NSIGr8)rr.rrrr4�s

z$_UnixSelectorEventLoop._check_signalcCst|||||�S)N)�_UnixReadPipeTransport)r�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�S)N)�_UnixWritePipeTransport)rrOrPrQrRrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc	ks�tj���}
|j�}t||||||||f||d�|	��}|
j|j�|j|�y|EdHWn&tk
r~}
z
|
}WYdd}
~
XnXd}|dk	r�|j�|j	�EdH|�WdQRX|S)N)rQrR)
r�get_child_watcherZ
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�	Exceptionr%Z_wait)rrPrB�shell�stdin�stdout�stderr�bufsizerR�kwargs�watcherrQ�transprC�errrrr�_make_subprocess_transport�s$




z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|�dS)N)Zcall_soon_threadsafeZ_process_exited)r�pid�
returncoderbrrrrY�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostnameccs|dkst|t�st�|r,|dkr<td��n|dk	r<td��|dk	r�|dk	rTtd��tjtjtjd�}y |jd�|j||�EdHWq�|j	��Yq�XnB|dkr�td��|j
tjks�tj|j
�r�tdj|���|jd�|j||||�EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r})rKr;�AssertionErrorr8r"�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr%�familyr�_is_stream_socket�typer@Z_create_connection_transport)r�protocol_factoryrrgrhri�	transportrPrrr�create_unix_connection�s:


z-_UnixSelectorEventLoop.create_unix_connection�d)rh�backlogrgc
!Cs�t|t�rtd��|dk	�r0|dk	r,td��t|�}tjtjtj�}|dd
kr�y tj	t
j|�j�rnt
j|�WnBt
k
r�Yn0tk
r�}ztjd||�WYdd}~XnXy|j|�Wnjtk
�r}z8|j�|jtjk�rdj|�}ttj|�d�n�WYdd}~Xn|j��YnXn>|dk�rBtd��|jtjk�s`tj|j��rntdj|���tj||g�}	|j|�|jd	�|j||||	�|	S)Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timer�z2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rrv)rK�boolr3r8�_fspathr"rkrl�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr9r�errorZbindr%r>Z
EADDRINUSEr@rnrrorpZServerZlistenrmZ_start_serving)
rrqrrhrurgrcrC�msgZserverrrr�create_unix_serversP

 




z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)�__name__�
__module__�__qualname__�__doc__rr#r%r1rEr/r)r4rSrUr
rdrYrsr��
__classcell__rr)r!rr1s,-
 


%r�set_blockingcCstj|d�dS)NF)r{r�)�fdrrr�_set_nonblockingBsr�cCs,tj|tj�}|tjB}tj|tj|�dS)N)�fcntlZF_GETFLr{�
O_NONBLOCKZF_SETFL)r��flagsrrrr�Gs
cs�eZdZdZd �fdd�	Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
jrhdd�Zd!dd�Zdd�Zdd�Z�ZS)"rN�iNcs�t�j|�||jd<||_||_|j�|_||_d|_t	j
|j�j}tj
|�pbtj|�pbtj|�s~d|_d|_d|_td��t|j�|jj|jj|�|jj|jj|j|j�|dk	r�|jjtj|d�dS)NrOFz)Pipe transport is for pipes/sockets only.)rr�_extra�_loop�_piper7�_fileno�	_protocol�_closingr{�fstatr|ry�S_ISFIFOrz�S_ISCHRr8r��	call_soon�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)r�looprOrPrQrR�mode)r!rrrQs,






z_UnixReadPipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�t|jdd�}|jdk	r�|dk	r�tj	||jt
j�}|r�|jd�q�|jd�n |jdk	r�|jd�n
|jd�dd	j|�S)
N�closed�closingzfd=%s�	_selector�polling�idle�openz<%s>� )
r!r�r��appendr�r��getattrr�r
�_test_selector_eventrZ
EVENT_READ�join)rr=r r�rrr�__repr__ns$




z_UnixReadPipeTransport.__repr__cCs�ytj|j|j�}WnDttfk
r,Yn�tk
rX}z|j|d�WYdd}~Xn^X|rl|jj	|�nJ|j
j�r�tj
d|�d|_|j
j|j�|j
j|jj�|j
j|jd�dS)Nz"Fatal read error on pipe transportz%r was closed by peerT)r{�readr��max_size�BlockingIOError�InterruptedErrorr9�_fatal_errorr�Z
data_receivedr��	get_debugrr=r��_remove_readerr�Zeof_received�_call_connection_lost)rr0rCrrrr��s
z"_UnixReadPipeTransport._read_readycCs|jj|j�dS)N)r�r�r�)rrrr�
pause_reading�sz$_UnixReadPipeTransport.pause_readingcCs|jj|j|j�dS)N)r�r�r�r�)rrrr�resume_reading�sz%_UnixReadPipeTransport.resume_readingcCs
||_dS)N)r�)rrPrrr�set_protocol�sz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r�)rrrr�get_protocol�sz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r�)rrrr�
is_closing�sz!_UnixReadPipeTransport.is_closingcCs|js|jd�dS)N)r��_close)rrrrr%�sz_UnixReadPipeTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)r$)r�r*r+r,r%)rrrr�__del__�s
z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r4|jtjkr4|jj�rLtjd||dd�n|jj||||j	d��|j
|�dS)Nz%r: %sT)�exc_info)�message�	exceptionrrrP)rKr9r>ZEIOr�r�r�debug�call_exception_handlerr�r�)rrCr�rrrr��s
z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j�|jj|j|�dS)NT)r�r�r�r�r�r�)rrCrrrr��sz_UnixReadPipeTransport._closecCs4z|jj|�Wd|jj�d|_d|_d|_XdS)N)r��connection_lostr�r%r�)rrCrrrr��s
z,_UnixReadPipeTransport._call_connection_losti)NN)r�)r�r�r�r�rr�r�r�r�r�r�r�r%r�PY34r�r�r�r�r�rr)r!rrNMs
rNcs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejr|dd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rTNc
s�t�j||�||jd<||_|j�|_||_t�|_d|_	d|_
tj|j�j
}tj|�}tj|�}tj|�}	|px|px|	s�d|_d|_d|_td��t|j�|jj|jj|�|	s�|r�tjjd�r�|jj|jj|j|j�|dk	r�|jjtj|d�dS)NrOrFz?Pipe transport is only for pipes, sockets and character devices�aix)rrr�r�r7r�r��	bytearray�_buffer�
_conn_lostr�r{r�r|ryr�r�rzr8r�r�r�r�r&�platform�
startswithr�r�r	r�)
rr�rOrPrQrRr�Zis_charZis_fifoZ	is_socket)r!rrr�s2






z _UnixWritePipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�t|jdd�}|jdk	r�|dk	r�tj	||jt
j�}|r�|jd�n
|jd�|j�}|jd|�n |jdk	r�|jd�n
|jd�d	d
j
|�S)Nr�r�zfd=%sr�r�r�z
bufsize=%sr�z<%s>r�)r!r�r�r�r�r�r�r�r
r�rZEVENT_WRITE�get_write_buffer_sizer�)rr=r r�r_rrrr��s(





z _UnixWritePipeTransport.__repr__cCs
t|j�S)N)�lenr�)rrrrr�sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jj�rtjd|�|jr*|jt��n|j�dS)Nz%r was closed by peer)r�r�rr=r�r��BrokenPipeError)rrrrr�s

z#_UnixWritePipeTransport._read_readycCs0t|tttf�stt|���t|t�r.t|�}|s6dS|jsB|jrj|jtj	krXt
jd�|jd7_dS|j�syt
j|j|�}WnTttfk
r�d}Yn:tk
r�}z|jd7_|j|d�dSd}~XnX|t|�kr�dS|dk�rt|�|d�}|jj|j|j�|j|7_|j�dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rK�bytesr��
memoryviewrj�reprr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r{�writer�r�r�rZr�r�r�Z_add_writer�_write_readyZ_maybe_pause_protocol)rr0�nrCrrrr�s4


z_UnixWritePipeTransport.writecCs�|jstd��ytj|j|j�}Wnjttfk
r:Yn�tk
r�}z8|jj�|j	d7_	|j
j|j�|j|d�WYdd}~XnfX|t
|j�kr�|jj�|j
j|j�|j�|jr�|j
j|j�|jd�dS|dkr�|jd|�=dS)NzData should not be emptyrz#Fatal write error on pipe transportr)r�rjr{r�r�r�r�rZr-r�r��_remove_writerr�r�Z_maybe_resume_protocolr�r�r�)rr�rCrrrr�>s(


z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr�
can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCsB|jr
dS|jst�d|_|js>|jj|j�|jj|jd�dS)NT)	r�r�rjr�r�r�r�r�r�)rrrr�	write_eof[s
z!_UnixWritePipeTransport.write_eofcCs
||_dS)N)r�)rrPrrrr�dsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r�)rrrrr�gsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r�)rrrrr�jsz"_UnixWritePipeTransport.is_closingcCs|jdk	r|jr|j�dS)N)r�r�r�)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)r$)r�r*r+r,r%)rrrrr�vs
z_UnixWritePipeTransport.__del__cCs|jd�dS)N)r�)rrrr�abort|sz_UnixWritePipeTransport.abort�Fatal error on pipe transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)r�)r�r�rrrP)
rKrZ_FATAL_ERROR_IGNOREr�r�rr�r�r�r�)rrCr�rrrr�s
z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j�|jj�|jj|j�|jj|j|�dS)NT)	r�r�r�r�r�r-r�r�r�)rrCrrrr��s
z_UnixWritePipeTransport._closecCs4z|jj|�Wd|jj�d|_d|_d|_XdS)N)r�r�r�r%r�)rrCrrrr��s
z-_UnixWritePipeTransport._call_connection_lost)NN)r�)N)r�r�r�rr�r�r�r�r�r�r�r�r�r�r%rr�r�r�r�r�r�r�rr)r!rrT�s$%	!	

rT�set_inheritablecCsNttdd�}tj|tj�}|s4tj|tj||B�ntj|tj||@�dS)NZ
FD_CLOEXECr)r�r�ZF_GETFDZF_SETFD)r�ZinheritableZcloexec_flag�oldrrr�_set_inheritable�s
r�c@seZdZdd�ZdS)rWc		Ksvd}|tjkr*|jj�\}}t|j�d�tj|f||||d|d�|��|_|dk	rr|j�t	|j
�d|d�|j_dS)NF)r[r\r]r^Zuniversal_newlinesr_�wb)�	buffering)�
subprocess�PIPEr�r#r�r7�Popen�_procr%r��detachr\)	rrBr[r\r]r^r_r`Zstdin_wrrr�_start�s
z_UnixSubprocessTransport._startN)r�r�r�r�rrrrrW�srWc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)raHAbstract base class for monitoring child processes.

    Objects derived from this class monitor a collection of subprocesses and
    report their termination or interruption by a signal.

    New callbacks are registered with .add_child_handler(). Starting a new
    process must be done within a 'with' block to allow the watcher to suspend
    its activity until the new process if fully registered (this is needed to
    prevent a race condition in some implementations).

    Example:
        with watcher:
            proc = subprocess.Popen("sleep 1")
            watcher.add_child_handler(proc.pid, callback)

    Notes:
        Implementations of this class must be thread-safe.

        Since child watcher objects may catch the SIGCHLD signal and call
        waitpid(-1), there should be only one active object per process.
    cGs
t��dS)aRegister a new child handler.

        Arrange for callback(pid, returncode, *args) to be called when
        process 'pid' terminates. Specifying another callback for the same
        process replaces the previous handler.

        Note: callback() must be thread-safe.
        N)�NotImplementedError)rrerArBrrrrX�s	z&AbstractChildWatcher.add_child_handlercCs
t��dS)z�Removes the handler for process 'pid'.

        The function returns True if the handler was successfully removed,
        False if there was nothing to remove.N)r�)rrerrr�remove_child_handler�sz)AbstractChildWatcher.remove_child_handlercCs
t��dS)z�Attach the watcher to an event loop.

        If the watcher was previously attached to an event loop, then it is
        first detached before attaching to the new loop.

        Note: loop may be None.
        N)r�)rr�rrr�attach_loop�sz AbstractChildWatcher.attach_loopcCs
t��dS)zlClose the watcher.

        This must be called to make sure that any underlying resource is freed.
        N)r�)rrrrr%�szAbstractChildWatcher.closecCs
t��dS)zdEnter the watcher's context and allow starting new processes

        This function must return selfN)r�)rrrr�	__enter__szAbstractChildWatcher.__enter__cCs
t��dS)zExit the watcher's contextN)r�)r�a�b�crrr�__exit__	szAbstractChildWatcher.__exit__N)
r�r�r�r�rXr�r�r%r�r�rrrrr�s
c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dS)N)r��
_callbacks)rrrrrszBaseChildWatcher.__init__cCs|jd�dS)N)r�)rrrrr%szBaseChildWatcher.closecCs
t��dS)N)r�)r�expected_pidrrr�_do_waitpidszBaseChildWatcher._do_waitpidcCs
t��dS)N)r�)rrrr�_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs~|dkst|tj�st�|jdk	r<|dkr<|jr<tjdt�|jdk	rT|jj	t
j�||_|dk	rz|jt
j|j
�|j�dS)NzCA loop is being detached from a child watcher with pending handlers)rKrZAbstractEventLooprjr�r�r*r+�RuntimeWarningr)r5�SIGCHLDrE�	_sig_chldr�)rr�rrrr�s
zBaseChildWatcher.attach_loopcCsFy|j�Wn4tk
r@}z|jjd|d��WYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handler)r�r�)r�rZr�r�)rrCrrrr�1szBaseChildWatcher._sig_chldcCs2tj|�rtj|�Stj|�r*tj|�S|SdS)N)r{�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)r�statusrrr�_compute_returncode=s



z$BaseChildWatcher._compute_returncodeN)
r�r�r�rr%r�r�r�r�r�rrrrr�sr�csPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)rad'Safe' child watcher implementation.

    This implementation avoids disrupting other code spawning processes by
    polling explicitly each process in the SIGCHLD handler instead of calling
    os.waitpid(-1).

    This is a safe solution but it has a significant overhead when handling a
    big number of children (O(n) each time SIGCHLD is raised)
    cs|jj�t�j�dS)N)r�r-rr%)r)r!rrr%Vs
zSafeChildWatcher.closecCs|S)Nr)rrrrr�ZszSafeChildWatcher.__enter__cCsdS)Nr)rr�r�r�rrrr�]szSafeChildWatcher.__exit__cGs.|jdkrtd��||f|j|<|j|�dS)NzICannot add child handler, the child watcher does not have a loop attached)r�r:r�r�)rrerArBrrrrX`s

z"SafeChildWatcher.add_child_handlercCs&y|j|=dStk
r dSXdS)NTF)r�rG)rrerrrr�ks
z%SafeChildWatcher.remove_child_handlercCs"xt|j�D]}|j|�qWdS)N)r(r�r�)rrerrrr�rsz SafeChildWatcher._do_waitpid_allcCs�|dkst�ytj|tj�\}}Wn(tk
rJ|}d}tjd|�Yn0X|dkrXdS|j|�}|jj	�rztj
d||�y|jj|�\}}Wn.t
k
r�|jj	�r�tjd|dd�YnX|||f|��dS)Nr�z8Unknown child process pid %d, will report returncode 255z$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rT)r�)rjr{�waitpid�WNOHANG�ChildProcessErrorrr�r�r�r�r�r��poprG)rr�rer�rfrArBrrrr�ws,


zSafeChildWatcher._do_waitpid)r�r�r�r�r%r�r�rXr�r�r�r�rr)r!rrKs	csTeZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)raW'Fast' child watcher implementation.

    This implementation reaps every terminated processes by calling
    os.waitpid(-1) directly, possibly breaking other code spawning processes
    and waiting for their termination.

    There is no noticeable overhead when handling a big number of children
    (O(1) each time a child terminates).
    cs$t�j�tj�|_i|_d|_dS)Nr)rr�	threadingZLock�_lock�_zombies�_forks)r)r!rrr�s

zFastChildWatcher.__init__cs"|jj�|jj�t�j�dS)N)r�r-r�rr%)r)r!rrr%�s

zFastChildWatcher.closec
Cs$|j�|jd7_|SQRXdS)Nr)r�r�)rrrrr��szFastChildWatcher.__enter__c
CsV|j�:|jd8_|js$|jr(dSt|j�}|jj�WdQRXtjd|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)r�r�r�r;r-rr�)rr�r�r�Zcollateral_victimsrrrr��s
zFastChildWatcher.__exit__cGsz|jstd��|jdkr td��|j�:y|jj|�}Wn"tk
rZ||f|j|<dSXWdQRX|||f|��dS)NzMust use the context managerzICannot add child handler, the child watcher does not have a loop attached)	r�rjr�r:r�r�r�rGr�)rrerArBrfrrrrX�s
z"FastChildWatcher.add_child_handlercCs&y|j|=dStk
r dSXdS)NTF)r�rG)rrerrrr��s
z%FastChildWatcher.remove_child_handlercCs�x�ytjdtj�\}}Wntk
r,dSX|dkr:dS|j|�}|j�vy|jj|�\}}WnBtk
r�|j	r�||j
|<|jj�r�t
jd||�wd}YnX|jj�r�t
jd||�WdQRX|dkr�t
jd||�q|||f|��qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr2)r{r�r�r�r�r�r�r�rGr�r�r�r�rr�r�)rrer�rfrArBrrrr��s6





z FastChildWatcher._do_waitpid_all)r�r�r�r�rr%r�r�rXr�r�r�rr)r!rr�s	csHeZdZdZeZ�fdd�Zdd�Z�fdd�Zdd	�Z	d
d�Z
�ZS)�_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cst�j�d|_dS)N)rr�_watcher)r)r!rrrs
z$_UnixDefaultEventLoopPolicy.__init__c
CsHtj�8|jdkr:t�|_ttj�tj�r:|jj|j	j
�WdQRXdS)N)rr�rrrKr��current_thread�_MainThreadr��_localr�)rrrr�
_init_watchers
z)_UnixDefaultEventLoopPolicy._init_watchercs6t�j|�|jdk	r2ttj�tj�r2|jj|�dS)z�Set the event loop.

        As a side effect, if a child watcher was set before, then calling
        .set_event_loop() from the main thread will call .attach_loop(loop) on
        the child watcher.
        N)r�set_event_looprrKr�rrr�)rr�)r!rrrs
z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j�|jS)zzGet the watcher for child processes.

        If not yet set, a SafeChildWatcher object is automatically created.
        N)rr)rrrrrV&s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs4|dkst|t�st�|jdk	r*|jj�||_dS)z$Set the watcher for child processes.N)rKrrjrr%)rrarrr�set_child_watcher0s

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�r�rZ
_loop_factoryrrrrVrr�rr)r!rrs
r)5r�r>r{r5r"ryr�r&r�r*�rrrrrrr	r
rrr
�logr�__all__r��ImportErrorr�fspathrx�AttributeErrorZBaseSelectorEventLoopr�hasattrr�r�Z
ReadTransportrNZ_FlowControlMixinZWriteTransportrTr�r�ZBaseSubprocessTransportrWrr�rrZBaseDefaultEventLoopPolicyrrrrrrr�<module>sn


O
F=On2PK=�\����M�Mstreams.cpython-36.pycnu�[���3


 \�_�@sLdZdddddddgZdd	lZeed
�r6ejddg�d
dlmZd
dlmZd
dlmZd
dlm	Z	d
dlm
Z
d
dlmZd"Z
Gdd�de�ZGdd�de�Ze
d#d	e
d�dd��Ze
d$d	e
d�dd��Zeed
��re
d%d	e
d�dd��Ze
d&d	e
d�dd��ZGdd�de	j�ZGdd�dee	j�ZGd d�d�ZGd!d�d�Zd	S)'zStream-related things.�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�IncompleteReadError�LimitOverrunError�NZAF_UNIX�open_unix_connection�start_unix_server�)�
coroutines)�compat)�events)�	protocols)�	coroutine)�logger��cs(eZdZdZ�fdd�Zdd�Z�ZS)rz�
    Incomplete read error. Attributes:

    - partial: read bytes string before the end of stream was reached
    - expected: total number of expected bytes (or None if unknown)
    cs(t�jdt|�|f�||_||_dS)Nz-%d bytes read on a total of %r expected bytes)�super�__init__�len�partial�expected)�selfrr)�	__class__��'/usr/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst|�|j|jffS)N)�typerr)rrrr�
__reduce__&szIncompleteReadError.__reduce__)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__rr)rrrscs(eZdZdZ�fdd�Zdd�Z�ZS)rz�Reached the buffer limit while looking for a separator.

    Attributes:
    - consumed: total number of to be consumed bytes.
    cst�j|�||_dS)N)rr�consumed)r�messager$)rrrr0szLimitOverrunError.__init__cCst|�|jd|jffS)Nr)r�argsr$)rrrrr4szLimitOverrunError.__reduce__)rr r!r"rrr#rr)rrr*s)�loop�limitc	+sb|dkrtj�}t||d�}t||d��|j�fdd�||f|�EdH\}}t|�||�}||fS)a�A wrapper for create_connection() returning a (reader, writer) pair.

    The reader returned is a StreamReader instance; the writer is a
    StreamWriter instance.

    The arguments are all the usual arguments to create_connection()
    except protocol_factory; most common are positional host and port,
    with various optional keyword arguments following.

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    (If you want to customize the StreamReader and/or
    StreamReaderProtocol classes, just copy the code -- there's
    really nothing special here except some convenience.)
    N)r(r')r'cs�S)Nrr)�protocolrr�<lambda>Qsz!open_connection.<locals>.<lambda>)r�get_event_looprrZcreate_connectionr)	�host�portr'r(�kwds�reader�	transport�_�writerr)r)rr8s c+s8�dkrtj�����fdd�}�j|||f|�EdHS)a�Start a socket server, call back for each client connected.

    The first parameter, `client_connected_cb`, takes two parameters:
    client_reader, client_writer.  client_reader is a StreamReader
    object, while client_writer is a StreamWriter object.  This
    parameter can either be a plain callback function or a coroutine;
    if it is a coroutine, it will be automatically converted into a
    Task.

    The rest of the arguments are all the usual arguments to
    loop.create_server() except protocol_factory; most common are
    positional host and port, with various optional keyword arguments
    following.  The return value is the same as loop.create_server().

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    The return value is the same as loop.create_server(), i.e. a
    Server object which can be used to stop the service.
    Ncst��d�}t|��d�}|S)N)r(r')r')rr)r/r))�client_connected_cbr(r'rr�factoryqszstart_server.<locals>.factory)rr+Z
create_server)r3r,r-r'r(r.r4r)r3r(r'rrVsc+s`|dkrtj�}t||d�}t||d��|j�fdd�|f|�EdH\}}t|�||�}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.N)r(r')r'cs�S)Nrr)r)rrr*�sz&open_unix_connection.<locals>.<lambda>)rr+rrZcreate_unix_connectionr)�pathr'r(r.r/r0r1r2r)r)rr	}sc+s6�dkrtj�����fdd�}�j||f|�EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncst��d�}t|��d�}|S)N)r(r')r')rr)r/r))r3r(r'rrr4�sz"start_unix_server.<locals>.factory)rr+Zcreate_unix_server)r3r5r'r(r.r4r)r3r(r'rr
�sc@s>eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zedd��Z	dS)�FlowControlMixina)Reusable flow control logic for StreamWriter.drain().

    This implements the protocol methods pause_writing(),
    resume_reading() and connection_lost().  If the subclass overrides
    these it must call the super methods.

    StreamWriter.drain() must wait for _drain_helper() coroutine.
    NcCs0|dkrtj�|_n||_d|_d|_d|_dS)NF)rr+�_loop�_paused�
_drain_waiter�_connection_lost)rr'rrrr�szFlowControlMixin.__init__cCs,|jst�d|_|jj�r(tjd|�dS)NTz%r pauses writing)r8�AssertionErrorr7�	get_debugr�debug)rrrr�
pause_writing�s
zFlowControlMixin.pause_writingcCsP|js
t�d|_|jj�r&tjd|�|j}|dk	rLd|_|j�sL|jd�dS)NFz%r resumes writing)	r8r;r7r<rr=r9�done�
set_result)r�waiterrrr�resume_writing�s

zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|j�r4dS|dkrH|jd�n
|j|�dS)NT)r:r8r9r?r@�
set_exception)r�excrArrr�connection_lost�sz FlowControlMixin.connection_lostccsP|jrtd��|jsdS|j}|dks2|j�s2t�|jj�}||_|EdHdS)NzConnection lost)r:�ConnectionResetErrorr8r9�	cancelledr;r7�
create_future)rrArrr�
_drain_helper�s
zFlowControlMixin._drain_helper)N)
rr r!r"rr>rBrErrIrrrrr6�s
	r6csFeZdZdZd
�fdd�	Zdd�Z�fdd�Zd	d
�Zdd�Z�Z	S)ra=Helper class to adapt between Protocol and StreamReader.

    (This is a helper class instead of making StreamReader itself a
    Protocol subclass, because the StreamReader has other potential
    uses, and to prevent the user of the StreamReader to accidentally
    call inappropriate methods of the protocol.)
    Ncs*t�j|d�||_d|_||_d|_dS)N)r'F)rr�_stream_reader�_stream_writer�_client_connected_cb�	_over_ssl)rZ
stream_readerr3r')rrrr�s
zStreamReaderProtocol.__init__cCsd|jj|�|jd�dk	|_|jdk	r`t|||j|j�|_|j|j|j�}tj	|�r`|jj
|�dS)NZ
sslcontext)rJ�
set_transport�get_extra_inforMrLrr7rKrZiscoroutineZcreate_task)rr0�resrrr�connection_made�s


z$StreamReaderProtocol.connection_madecsF|jdk	r*|dkr|jj�n|jj|�t�j|�d|_d|_dS)N)rJ�feed_eofrCrrErK)rrD)rrrrE�s
z$StreamReaderProtocol.connection_lostcCs|jj|�dS)N)rJ�	feed_data)r�datarrr�
data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj�|jrdSdS)NFT)rJrRrM)rrrr�eof_receiveds
z!StreamReaderProtocol.eof_received)NN)
rr r!r"rrQrErUrVr#rr)rrr�s
c@sjeZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zddd�Z
edd��ZdS)ra'Wraps a Transport.

    This exposes write(), writelines(), [can_]write_eof(),
    get_extra_info() and close().  It adds drain() which returns an
    optional Future on which you can wait for flow control.  It also
    adds a transport property which references the Transport
    directly.
    cCs2||_||_|dks"t|t�s"t�||_||_dS)N)�
_transport�	_protocol�
isinstancerr;�_readerr7)rr0r)r/r'rrrrs
zStreamWriter.__init__cCs:|jjd|jg}|jdk	r,|jd|j�ddj|�S)Nztransport=%rz	reader=%rz<%s>� )rrrWrZ�append�join)r�inforrr�__repr__!s
zStreamWriter.__repr__cCs|jS)N)rW)rrrrr0'szStreamWriter.transportcCs|jj|�dS)N)rW�write)rrTrrrr`+szStreamWriter.writecCs|jj|�dS)N)rW�
writelines)rrTrrrra.szStreamWriter.writelinescCs
|jj�S)N)rW�	write_eof)rrrrrb1szStreamWriter.write_eofcCs
|jj�S)N)rW�
can_write_eof)rrrrrc4szStreamWriter.can_write_eofcCs
|jj�S)N)rW�close)rrrrrd7szStreamWriter.closeNcCs|jj||�S)N)rWrO)r�name�defaultrrrrO:szStreamWriter.get_extra_infoccsN|jdk	r |jj�}|dk	r |�|jdk	r:|jj�r:dV|jj�EdHdS)z~Flush the write buffer.

        The intended use is to write

          w.write(data)
          yield from w.drain()
        N)rZ�	exceptionrWZ
is_closingrXrI)rrDrrr�drain=s	



zStreamWriter.drain)N)rr r!r"rr_�propertyr0r`rarbrcrdrOrrhrrrrrs
c@s�eZdZedfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zed'dd��Zed)dd��Zed d!��Zejr�ed"d#��Zed$d%��Zejr�d&d#�ZdS)*rNcCsZ|dkrtd��||_|dkr*tj�|_n||_t�|_d|_d|_d|_	d|_
d|_dS)NrzLimit cannot be <= 0F)�
ValueError�_limitrr+r7�	bytearray�_buffer�_eof�_waiter�
_exceptionrWr8)rr(r'rrrrXszStreamReader.__init__cCs�dg}|jr |jdt|j��|jr0|jd�|jtkrJ|jd|j�|jr`|jd|j�|jrv|jd|j�|jr�|jd|j�|j	r�|jd�d	d
j
|�S)Nrz%d bytes�eofzl=%dzw=%rze=%rzt=%rZpausedz<%s>r[)rmr\rrnrk�_DEFAULT_LIMITrorprWr8r])rr^rrrr_ks 


zStreamReader.__repr__cCs|jS)N)rp)rrrrrg}szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|j�s,|j|�dS)N)rprorGrC)rrDrArrrrC�szStreamReader.set_exceptioncCs*|j}|dk	r&d|_|j�s&|jd�dS)z1Wakeup read*() functions waiting for data or EOF.N)rorGr@)rrArrr�_wakeup_waiter�s
zStreamReader._wakeup_waitercCs|jdkstd��||_dS)NzTransport already set)rWr;)rr0rrrrN�szStreamReader.set_transportcCs*|jr&t|j�|jkr&d|_|jj�dS)NF)r8rrmrkrW�resume_reading)rrrr�_maybe_resume_transport�sz$StreamReader._maybe_resume_transportcCsd|_|j�dS)NT)rnrs)rrrrrR�szStreamReader.feed_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)rnrm)rrrr�at_eof�szStreamReader.at_eofcCs�|jstd��|sdS|jj|�|j�|jdk	r�|jr�t|j�d|jkr�y|jj	�Wnt
k
rzd|_YnXd|_dS)Nzfeed_data after feed_eofrT)rnr;rm�extendrsrWr8rrkZ
pause_reading�NotImplementedError)rrTrrrrS�s
zStreamReader.feed_dataccsf|jdk	rtd|��|js&td��|jr<d|_|jj�|jj�|_z|jEdHWdd|_XdS)zpWait until feed_data() or feed_eof() is called.

        If stream was paused, automatically resume it.
        NzH%s() called while another coroutine is already waiting for incoming dataz_wait_for_data after EOFF)	ro�RuntimeErrorrnr;r8rWrtr7rH)rZ	func_namerrr�_wait_for_data�s


zStreamReader._wait_for_dataccs�d}t|�}y|j|�EdH}Wn�tk
rB}z|jSd}~Xnftk
r�}zJ|jj||j�rv|jd|j|�=n
|jj�|j	�t
|jd��WYdd}~XnX|S)a�Read chunk of data from the stream until newline (b'
') is found.

        On success, return chunk that ends with newline. If only partial
        line can be read due to EOF, return incomplete line without
        terminating newline. When EOF was reached while no bytes read, empty
        bytes object is returned.

        If limit is reached, ValueError will be raised. In that case, if
        newline was found, complete line including newline will be removed
        from internal buffer. Else, internal buffer will be cleared. Limit is
        compared against part of the line without newline.

        If stream was paused, this function will automatically resume it if
        needed.
        �
Nr)r�	readuntilrrrrm�
startswithr$�clearrurjr&)r�sep�seplen�line�errr�readline�s
 zStreamReader.readliner{ccs�t|�}|dkrtd��|jdk	r(|j�d}x�t|j�}|||kr||jj||�}|dkr\P|d|}||jkr|td|��|jr�t|j�}|jj	�t
|d��|jd�EdHq.W||jkr�td|��|jd||�}|jd||�=|j�t|�S)	aVRead data from the stream until ``separator`` is found.

        On success, the data and separator will be removed from the
        internal buffer (consumed). Returned data will include the
        separator at the end.

        Configured stream limit is used to check result. Limit sets the
        maximal length of data that can be returned, not counting the
        separator.

        If an EOF occurs and the complete separator is still not found,
        an IncompleteReadError exception will be raised, and the internal
        buffer will be reset.  The IncompleteReadError.partial attribute
        may contain the separator partially.

        If the data cannot be read because of over limit, a
        LimitOverrunError exception  will be raised, and the data
        will be left in the internal buffer, so it can be read again.
        rz,Separator should be at least one-byte stringNrz2Separator is not found, and chunk exceed the limitr|z2Separator is found, but chunk is longer than limit���)
rrjrprm�findrkrrn�bytesr~rrzru)rZ	separatorr��offsetZbuflenZisep�chunkrrrr|�s:






zStreamReader.readuntilrccs�|jdk	r|j�|dkrdS|dkrZg}x&|j|j�EdH}|sBP|j|�q*Wdj|�S|jrz|jrz|jd�EdHt|jd|��}|jd|�=|j	�|S)a�Read up to `n` bytes from the stream.

        If n is not provided, or set to -1, read until EOF and return all read
        bytes. If the EOF was received and the internal buffer is empty, return
        an empty bytes object.

        If n is zero, return empty bytes object immediately.

        If n is positive, this function try to read `n` bytes, and may return
        less or equal bytes than requested, but at least one byte. If EOF was
        received before any byte is read, this function returns empty byte
        object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        Nr��read)
rpr�rkr\r]rmrnrzr�ru)r�nZblocks�blockrTrrrr�Ps$

zStreamReader.readccs�|dkrtd��|jdk	r |j�|dkr,dSxFt|j�|krr|jr`t|j�}|jj�t||��|jd�EdHq.Wt|j�|kr�t|j�}|jj�nt|jd|��}|jd|�=|j	�|S)a�Read exactly `n` bytes.

        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.

        if n is zero, return empty bytes object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        rz*readexactly size can not be less than zeroNr��readexactly)
rjrprrmrnr�r~rrzru)rr�Z
incompleterTrrrr��s&




zStreamReader.readexactlycCs|S)Nr)rrrr�	__aiter__�szStreamReader.__aiter__ccs|j�EdH}|dkrt�|S)Nr�)r��StopAsyncIteration)r�valrrr�	__anext__�szStreamReader.__anext__cCs|S)Nr)rrrrr��s)r{r�)r�)rr r!rrrr_rgrCrsrNrurRrvrSrrzr�r|r�r�r
ZPY35r�r�ZPY352rrrrrVs,	 [2*i)NN)NN)N)N)r"�__all__Zsocket�hasattrrw�rr
rrr�logrrr�EOFErrorr�	Exceptionrrrr	r
ZProtocolr6rrrrrrr�<module>sB
"B3GPK=�\mʀ��L�Lstreams.cpython-36.opt-1.pycnu�[���3


 \�_�@sLdZdddddddgZdd	lZeed
�r6ejddg�d
dlmZd
dlmZd
dlmZd
dlm	Z	d
dlm
Z
d
dlmZd"Z
Gdd�de�ZGdd�de�Ze
d#d	e
d�dd��Ze
d$d	e
d�dd��Zeed
��re
d%d	e
d�dd��Ze
d&d	e
d�dd��ZGdd�de	j�ZGdd�dee	j�ZGd d�d�ZGd!d�d�Zd	S)'zStream-related things.�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�IncompleteReadError�LimitOverrunError�NZAF_UNIX�open_unix_connection�start_unix_server�)�
coroutines)�compat)�events)�	protocols)�	coroutine)�logger��cs(eZdZdZ�fdd�Zdd�Z�ZS)rz�
    Incomplete read error. Attributes:

    - partial: read bytes string before the end of stream was reached
    - expected: total number of expected bytes (or None if unknown)
    cs(t�jdt|�|f�||_||_dS)Nz-%d bytes read on a total of %r expected bytes)�super�__init__�len�partial�expected)�selfrr)�	__class__��'/usr/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst|�|j|jffS)N)�typerr)rrrr�
__reduce__&szIncompleteReadError.__reduce__)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__rr)rrrscs(eZdZdZ�fdd�Zdd�Z�ZS)rz�Reached the buffer limit while looking for a separator.

    Attributes:
    - consumed: total number of to be consumed bytes.
    cst�j|�||_dS)N)rr�consumed)r�messager$)rrrr0szLimitOverrunError.__init__cCst|�|jd|jffS)Nr)r�argsr$)rrrrr4szLimitOverrunError.__reduce__)rr r!r"rrr#rr)rrr*s)�loop�limitc	+sb|dkrtj�}t||d�}t||d��|j�fdd�||f|�EdH\}}t|�||�}||fS)a�A wrapper for create_connection() returning a (reader, writer) pair.

    The reader returned is a StreamReader instance; the writer is a
    StreamWriter instance.

    The arguments are all the usual arguments to create_connection()
    except protocol_factory; most common are positional host and port,
    with various optional keyword arguments following.

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    (If you want to customize the StreamReader and/or
    StreamReaderProtocol classes, just copy the code -- there's
    really nothing special here except some convenience.)
    N)r(r')r'cs�S)Nrr)�protocolrr�<lambda>Qsz!open_connection.<locals>.<lambda>)r�get_event_looprrZcreate_connectionr)	�host�portr'r(�kwds�reader�	transport�_�writerr)r)rr8s c+s8�dkrtj�����fdd�}�j|||f|�EdHS)a�Start a socket server, call back for each client connected.

    The first parameter, `client_connected_cb`, takes two parameters:
    client_reader, client_writer.  client_reader is a StreamReader
    object, while client_writer is a StreamWriter object.  This
    parameter can either be a plain callback function or a coroutine;
    if it is a coroutine, it will be automatically converted into a
    Task.

    The rest of the arguments are all the usual arguments to
    loop.create_server() except protocol_factory; most common are
    positional host and port, with various optional keyword arguments
    following.  The return value is the same as loop.create_server().

    Additional optional keyword arguments are loop (to set the event loop
    instance to use) and limit (to set the buffer limit passed to the
    StreamReader).

    The return value is the same as loop.create_server(), i.e. a
    Server object which can be used to stop the service.
    Ncst��d�}t|��d�}|S)N)r(r')r')rr)r/r))�client_connected_cbr(r'rr�factoryqszstart_server.<locals>.factory)rr+Z
create_server)r3r,r-r'r(r.r4r)r3r(r'rrVsc+s`|dkrtj�}t||d�}t||d��|j�fdd�|f|�EdH\}}t|�||�}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.N)r(r')r'cs�S)Nrr)r)rrr*�sz&open_unix_connection.<locals>.<lambda>)rr+rrZcreate_unix_connectionr)�pathr'r(r.r/r0r1r2r)r)rr	}sc+s6�dkrtj�����fdd�}�j||f|�EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncst��d�}t|��d�}|S)N)r(r')r')rr)r/r))r3r(r'rrr4�sz"start_unix_server.<locals>.factory)rr+Zcreate_unix_server)r3r5r'r(r.r4r)r3r(r'rr
�sc@s>eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zedd��Z	dS)�FlowControlMixina)Reusable flow control logic for StreamWriter.drain().

    This implements the protocol methods pause_writing(),
    resume_reading() and connection_lost().  If the subclass overrides
    these it must call the super methods.

    StreamWriter.drain() must wait for _drain_helper() coroutine.
    NcCs0|dkrtj�|_n||_d|_d|_d|_dS)NF)rr+�_loop�_paused�
_drain_waiter�_connection_lost)rr'rrrr�szFlowControlMixin.__init__cCs d|_|jj�rtjd|�dS)NTz%r pauses writing)r8r7�	get_debugr�debug)rrrr�
pause_writing�s
zFlowControlMixin.pause_writingcCsFd|_|jj�rtjd|�|j}|dk	rBd|_|j�sB|jd�dS)NFz%r resumes writing)r8r7r;rr<r9�done�
set_result)r�waiterrrr�resume_writing�s
zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|j�r4dS|dkrH|jd�n
|j|�dS)NT)r:r8r9r>r?�
set_exception)r�excr@rrr�connection_lost�sz FlowControlMixin.connection_lostccs<|jrtd��|jsdS|j}|jj�}||_|EdHdS)NzConnection lost)r:�ConnectionResetErrorr8r9r7�
create_future)rr@rrr�
_drain_helper�s
zFlowControlMixin._drain_helper)N)
rr r!r"rr=rArDrrGrrrrr6�s
	r6csFeZdZdZd
�fdd�	Zdd�Z�fdd�Zd	d
�Zdd�Z�Z	S)ra=Helper class to adapt between Protocol and StreamReader.

    (This is a helper class instead of making StreamReader itself a
    Protocol subclass, because the StreamReader has other potential
    uses, and to prevent the user of the StreamReader to accidentally
    call inappropriate methods of the protocol.)
    Ncs*t�j|d�||_d|_||_d|_dS)N)r'F)rr�_stream_reader�_stream_writer�_client_connected_cb�	_over_ssl)rZ
stream_readerr3r')rrrr�s
zStreamReaderProtocol.__init__cCsd|jj|�|jd�dk	|_|jdk	r`t|||j|j�|_|j|j|j�}tj	|�r`|jj
|�dS)NZ
sslcontext)rH�
set_transport�get_extra_inforKrJrr7rIrZiscoroutineZcreate_task)rr0�resrrr�connection_made�s


z$StreamReaderProtocol.connection_madecsF|jdk	r*|dkr|jj�n|jj|�t�j|�d|_d|_dS)N)rH�feed_eofrBrrDrI)rrC)rrrrD�s
z$StreamReaderProtocol.connection_lostcCs|jj|�dS)N)rH�	feed_data)r�datarrr�
data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj�|jrdSdS)NFT)rHrPrK)rrrr�eof_receiveds
z!StreamReaderProtocol.eof_received)NN)
rr r!r"rrOrDrSrTr#rr)rrr�s
c@sjeZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zddd�Z
edd��ZdS)ra'Wraps a Transport.

    This exposes write(), writelines(), [can_]write_eof(),
    get_extra_info() and close().  It adds drain() which returns an
    optional Future on which you can wait for flow control.  It also
    adds a transport property which references the Transport
    directly.
    cCs||_||_||_||_dS)N)�
_transport�	_protocol�_readerr7)rr0r)r/r'rrrrszStreamWriter.__init__cCs:|jjd|jg}|jdk	r,|jd|j�ddj|�S)Nztransport=%rz	reader=%rz<%s>� )rrrUrW�append�join)r�inforrr�__repr__!s
zStreamWriter.__repr__cCs|jS)N)rU)rrrrr0'szStreamWriter.transportcCs|jj|�dS)N)rU�write)rrRrrrr]+szStreamWriter.writecCs|jj|�dS)N)rU�
writelines)rrRrrrr^.szStreamWriter.writelinescCs
|jj�S)N)rU�	write_eof)rrrrr_1szStreamWriter.write_eofcCs
|jj�S)N)rU�
can_write_eof)rrrrr`4szStreamWriter.can_write_eofcCs
|jj�S)N)rU�close)rrrrra7szStreamWriter.closeNcCs|jj||�S)N)rUrM)r�name�defaultrrrrM:szStreamWriter.get_extra_infoccsN|jdk	r |jj�}|dk	r |�|jdk	r:|jj�r:dV|jj�EdHdS)z~Flush the write buffer.

        The intended use is to write

          w.write(data)
          yield from w.drain()
        N)rW�	exceptionrUZ
is_closingrVrG)rrCrrr�drain=s	



zStreamWriter.drain)N)rr r!r"rr\�propertyr0r]r^r_r`rarMrrerrrrrs
c@s�eZdZedfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zed'dd��Zed)dd��Zed d!��Zejr�ed"d#��Zed$d%��Zejr�d&d#�ZdS)*rNcCsZ|dkrtd��||_|dkr*tj�|_n||_t�|_d|_d|_d|_	d|_
d|_dS)NrzLimit cannot be <= 0F)�
ValueError�_limitrr+r7�	bytearray�_buffer�_eof�_waiter�
_exceptionrUr8)rr(r'rrrrXszStreamReader.__init__cCs�dg}|jr |jdt|j��|jr0|jd�|jtkrJ|jd|j�|jr`|jd|j�|jrv|jd|j�|jr�|jd|j�|j	r�|jd�d	d
j
|�S)Nrz%d bytes�eofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rX)rjrYrrkrh�_DEFAULT_LIMITrlrmrUr8rZ)rr[rrrr\ks 


zStreamReader.__repr__cCs|jS)N)rm)rrrrrd}szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|j�s,|j|�dS)N)rmrl�	cancelledrB)rrCr@rrrrB�szStreamReader.set_exceptioncCs*|j}|dk	r&d|_|j�s&|jd�dS)z1Wakeup read*() functions waiting for data or EOF.N)rlrpr?)rr@rrr�_wakeup_waiter�s
zStreamReader._wakeup_waitercCs
||_dS)N)rU)rr0rrrrL�szStreamReader.set_transportcCs*|jr&t|j�|jkr&d|_|jj�dS)NF)r8rrjrhrU�resume_reading)rrrr�_maybe_resume_transport�sz$StreamReader._maybe_resume_transportcCsd|_|j�dS)NT)rkrq)rrrrrP�szStreamReader.feed_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)rkrj)rrrr�at_eof�szStreamReader.at_eofcCsv|sdS|jj|�|j�|jdk	rr|jrrt|j�d|jkrry|jj�Wntk
rjd|_YnXd|_dS)NrT)	rj�extendrqrUr8rrhZ
pause_reading�NotImplementedError)rrRrrrrQ�s
zStreamReader.feed_dataccsV|jdk	rtd|��|jr,d|_|jj�|jj�|_z|jEdHWdd|_XdS)zpWait until feed_data() or feed_eof() is called.

        If stream was paused, automatically resume it.
        NzH%s() called while another coroutine is already waiting for incoming dataF)rl�RuntimeErrorr8rUrrr7rF)rZ	func_namerrr�_wait_for_data�s


zStreamReader._wait_for_dataccs�d}t|�}y|j|�EdH}Wn�tk
rB}z|jSd}~Xnftk
r�}zJ|jj||j�rv|jd|j|�=n
|jj�|j	�t
|jd��WYdd}~XnX|S)a�Read chunk of data from the stream until newline (b'
') is found.

        On success, return chunk that ends with newline. If only partial
        line can be read due to EOF, return incomplete line without
        terminating newline. When EOF was reached while no bytes read, empty
        bytes object is returned.

        If limit is reached, ValueError will be raised. In that case, if
        newline was found, complete line including newline will be removed
        from internal buffer. Else, internal buffer will be cleared. Limit is
        compared against part of the line without newline.

        If stream was paused, this function will automatically resume it if
        needed.
        �
Nr)r�	readuntilrrrrj�
startswithr$�clearrsrgr&)r�sep�seplen�line�errr�readline�s
 zStreamReader.readlineryccs�t|�}|dkrtd��|jdk	r(|j�d}x�t|j�}|||kr||jj||�}|dkr\P|d|}||jkr|td|��|jr�t|j�}|jj	�t
|d��|jd�EdHq.W||jkr�td|��|jd||�}|jd||�=|j�t|�S)	aVRead data from the stream until ``separator`` is found.

        On success, the data and separator will be removed from the
        internal buffer (consumed). Returned data will include the
        separator at the end.

        Configured stream limit is used to check result. Limit sets the
        maximal length of data that can be returned, not counting the
        separator.

        If an EOF occurs and the complete separator is still not found,
        an IncompleteReadError exception will be raised, and the internal
        buffer will be reset.  The IncompleteReadError.partial attribute
        may contain the separator partially.

        If the data cannot be read because of over limit, a
        LimitOverrunError exception  will be raised, and the data
        will be left in the internal buffer, so it can be read again.
        rz,Separator should be at least one-byte stringNrz2Separator is not found, and chunk exceed the limitrzz2Separator is found, but chunk is longer than limit���)
rrgrmrj�findrhrrk�bytesr|rrxrs)rZ	separatorr~�offsetZbuflenZisep�chunkrrrrz�s:






zStreamReader.readuntilrccs�|jdk	r|j�|dkrdS|dkrZg}x&|j|j�EdH}|sBP|j|�q*Wdj|�S|jrz|jrz|jd�EdHt|jd|��}|jd|�=|j	�|S)a�Read up to `n` bytes from the stream.

        If n is not provided, or set to -1, read until EOF and return all read
        bytes. If the EOF was received and the internal buffer is empty, return
        an empty bytes object.

        If n is zero, return empty bytes object immediately.

        If n is positive, this function try to read `n` bytes, and may return
        less or equal bytes than requested, but at least one byte. If EOF was
        received before any byte is read, this function returns empty byte
        object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        Nr��read)
rmr�rhrYrZrjrkrxr�rs)r�nZblocks�blockrRrrrr�Ps$

zStreamReader.readccs�|dkrtd��|jdk	r |j�|dkr,dSxFt|j�|krr|jr`t|j�}|jj�t||��|jd�EdHq.Wt|j�|kr�t|j�}|jj�nt|jd|��}|jd|�=|j	�|S)a�Read exactly `n` bytes.

        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.

        if n is zero, return empty bytes object.

        Returned value is not limited with limit, configured at stream
        creation.

        If stream was paused, this function will automatically resume it if
        needed.
        rz*readexactly size can not be less than zeroNr��readexactly)
rgrmrrjrkr�r|rrxrs)rr�Z
incompleterRrrrr��s&




zStreamReader.readexactlycCs|S)Nr)rrrr�	__aiter__�szStreamReader.__aiter__ccs|j�EdH}|dkrt�|S)Nr�)r��StopAsyncIteration)r�valrrr�	__anext__�szStreamReader.__anext__cCs|S)Nr)rrrrr��s)ryr�)r�)rr r!rorr\rdrBrqrLrsrPrtrQrrxr�rzr�r�r
ZPY35r�r�ZPY352rrrrrVs,	 [2*i)NN)NN)N)N)r"�__all__Zsocket�hasattrru�rr
rrr�logrro�EOFErrorr�	Exceptionrrrr	r
ZProtocolr6rrrrrrr�<module>sB
"B3GPK=�\ U��44sslproto.cpython-36.opt-2.pycnu�[���3


 \�e�
@s�ddlZddlZyddlZWnek
r4dZYnXddlmZddlmZddlmZddlmZddl	m
Z
dd	�Zd
d�ZdZ
d
ZdZdZGdd�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�base_events)�compat)�	protocols)�
transports)�loggercCsj|rtd��ttd�r*tj�}|sfd|_n<tjtj�}|jtjO_|jtj	O_|j
�tj|_|S)Nz(Server side SSL needs a valid SSLContext�create_default_contextF)
�
ValueError�hasattr�sslr�check_hostnameZ
SSLContextZPROTOCOL_SSLv23ZoptionsZOP_NO_SSLv2ZOP_NO_SSLv3Zset_default_verify_pathsZ
CERT_REQUIRED�verify_mode)�server_side�server_hostname�
sslcontext�r�(/usr/lib64/python3.6/asyncio/sslproto.py�_create_transport_contexts
rcCs
ttd�S)N�	MemoryBIO)r
rrrrr�_is_sslproto_available%srZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@szeZdZdZddd�Zedd��Zedd	��Zed
d��Zedd
��Z	ddd�Z
ddd�Zdd�Zddd�Z
ddd�ZdS) �_SSLPipe�iNcCsH||_||_||_t|_tj�|_tj�|_d|_	d|_
d|_d|_dS)NF)
�_context�_server_side�_server_hostname�
_UNWRAPPED�_staterr�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextrrrrr�__init__Ds

z_SSLPipe.__init__cCs|jS)N)r)r#rrrr$Zsz_SSLPipe.contextcCs|jS)N)r)r#rrr�
ssl_object_sz_SSLPipe.ssl_objectcCs|jS)N)r )r#rrr�need_ssldatagsz_SSLPipe.need_ssldatacCs
|jtkS)N)r�_WRAPPED)r#rrr�wrappedmsz_SSLPipe.wrappedcCsR|jtkrtd��|jj|j|j|j|jd�|_	t
|_||_|jddd�\}}|S)Nz"handshake in progress or completed)rr�T)�only_handshake)
rr�RuntimeErrorrZwrap_biorrrrr�
_DO_HANDSHAKEr!�feed_ssldata)r#�callback�ssldata�appdatarrr�do_handshakevs	
z_SSLPipe.do_handshakecCsB|jtkrtd��|jtkr$td��t|_||_|jd�\}}|S)Nzno security layer presentzshutdown in progressr*)rrr,�	_SHUTDOWNr"r.)r#r/r0r1rrr�shutdown�s	

z_SSLPipe.shutdowncCs|jj�|jd�\}}dS)Nr*)rZ	write_eofr.)r#r0r1rrr�feed_eof�s
z_SSLPipe.feed_eofFcCs�|jtkr"|r|g}ng}g|fSd|_|r8|jj|�g}g}y�|jtkrx|jj�t|_|j	rl|j	d�|rx||fS|jtkr�xn|jj
|j�}|j|�|s�Pq�WnJ|jt
kr�|jj�d|_t|_|jr�|j�n|jtkr�|j|jj
��Wnxtjtjfk
�rl}zRt|dd�tjtjtjfk�rN|jtk�rL|j	�rL|j	|��|jtjk|_WYdd}~XnX|jj�r�|j|jj
��||fS)NF�errno)rrr r�writer-rr2r(r!�read�max_size�appendr3Zunwrapr"r�SSLError�CertificateError�getattr�SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITE�SSL_ERROR_SYSCALLr6r�pending)r#�datar+r1r0�chunk�excrrrr.�sV











 
z_SSLPipe.feed_ssldatarcCs|jtkr6|t|�kr&||d�g}ng}|t|�fSg}t|�}x�d|_y(|t|�krp||jj||d��7}Wn\tjk
r�}z>|j	dkr�tj
|_|jtj
tjtj
fkr��|jtj
k|_WYdd}~XnX|jjr�|j|jj��|t|�ks�|jrDPqDW||fS)NFZPROTOCOL_IS_SHUTDOWN)rr�len�
memoryviewr rr7rr;�reasonr>r6r?r@rrAr:r8)r#rB�offsetr0ZviewrDrrr�feed_appdata�s2


 z_SSLPipe.feed_appdatai)N)N)N)F)r)�__name__�
__module__�__qualname__r9r%�propertyr$r&r'r)r2r4r5r.rIrrrrr0s
	



Jrc@s�eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Ze	j
rHdd�Zdd�Zdd�Z
ddd�Zdd�Zdd�Zdd�Zdd�ZdS) �_SSLProtocolTransportcCs||_||_d|_dS)NF)�_loop�
_ssl_protocol�_closed)r#�loopZssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||�S)N)rP�_get_extra_info)r#�name�defaultrrr�get_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs||j_dS)N)rP�
_app_protocol)r#�protocolrrr�set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rPrW)r#rrr�get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rQ)r#rrr�
is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jj�dS)NT)rQrP�_start_shutdown)r#rrr�close<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d�|j�dS)Nzunclosed transport %r)�source)rQ�warnings�warn�ResourceWarningr])r#rrr�__del__Ksz_SSLProtocolTransport.__del__cCs|jjj�dS)N)rP�
_transport�
pause_reading)r#rrrrdQsz#_SSLProtocolTransport.pause_readingcCs|jjj�dS)N)rPrc�resume_reading)r#rrrreYsz$_SSLProtocolTransport.resume_readingcCs|jjj||�dS)N)rPrc�set_write_buffer_limits)r#ZhighZlowrrrrfasz-_SSLProtocolTransport.set_write_buffer_limitscCs|jjj�S)N)rPrc�get_write_buffer_size)r#rrrrgvsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttf�s$tdjt|�j���|s,dS|jj	|�dS)Nz/data: expecting a bytes-like instance, got {!r})
�
isinstance�bytes�	bytearrayrF�	TypeError�format�typerJrP�_write_appdata)r#rBrrrr7zsz_SSLProtocolTransport.writecCsdS)NFr)r#rrr�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|jj�dS)N)rP�_abort)r#rrr�abort�sz_SSLProtocolTransport.abort)N)NN)rJrKrLr%rVrYrZr[r]rZPY34rbrdrerfrgr7rorqrrrrrN&s


rNc@s�eZdZd'dd�Zd(dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
d)dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd*d!d"�Zd#d$�Zd%d&�ZdS)+�SSLProtocolFNTcCs�tdkrtd��|st||�}||_|r6|r6||_nd|_||_t|d�|_tj	�|_
d|_||_||_
||_t|j
|�|_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)rr,rrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrOrWrN�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownrc�_call_connection_made)r#rRZapp_protocolrZwaiterrrZcall_connection_maderrrr%�s,


zSSLProtocol.__init__cCsD|jdkrdS|jj�s:|dk	r.|jj|�n|jjd�d|_dS)N)rzZ	cancelledZ
set_exceptionZ
set_result)r#rDrrr�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|j�dS)N)rcrrsrrr|�_start_handshake)r#�	transportrrr�connection_made�s

zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|�d|_d|_|j|�dS)NF)r}rO�	call_soonrW�connection_lostrcr{r�)r#rDrrrr��szSSLProtocol.connection_lostcCs|jj�dS)N)rW�
pause_writing)r#rrrr��szSSLProtocol.pause_writingcCs|jj�dS)N)rW�resume_writing)r#rrrr��szSSLProtocol.resume_writingcCs�|jdkrdSy|jj|�\}}WnHtjk
rj}z*|jj�rTtjd||j|j	�|j
�dSd}~XnXx|D]}|jj|�qrWx(|D] }|r�|j
j|�q�|j�Pq�WdS)Nz%r: SSL error %s (reason %s))r|r.rr;rO�	get_debugr�warningr6rGrprcr7rW�
data_receivedr\)r#rBr0r1�erCrrrr��s"



zSSLProtocol.data_receivedc
CsTzB|jj�rtjd|�|jt�|js@|jj�}|r@tj	d�Wd|j
j�XdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl)rOr�r�debugr��ConnectionResetErrorr~rW�eof_receivedr�rcr])r#Z	keep_openrrrr�s


zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk	r,|jj||�S|SdS)N)rurcrV)r#rTrUrrrrS!s



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|j�nd|_|jd�dS)NTr*)rr~rprn)r#rrrr\)s
zSSLProtocol._start_shutdowncCs.|jj|df�|jt|�7_|j�dS)Nr)rxr:ryrE�_process_write_backlog)r#rBrrrrn2szSSLProtocol._write_appdatacCsH|jj�r$tjd|�|jj�|_nd|_d|_|jjd�|j	�dS)Nz%r starts SSL handshakeTr*r)r*r)
rOr�rr��time�_handshake_start_timer~rxr:r�)r#rrrr�7s
zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk	r|�|j�}t|jd�sR|jrR|jjtj	krRtj
||j�Wn~tk
r�}zb|jj
�r�t|tj�r�tjd|dd�ntjd|dd�|jj�t|t�r�|j|�dS�WYdd}~XnX|jj
��r|jj�|j}tjd||d�|jj||j�|j�|d	�|j�r4|jj|j �|j�d|_!|jj"|j#�dS)
NFrz5%r: SSL handshake failed on verifying the certificateT)�exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compressionr&)$r~r|r&Zgetpeercertr
rsrr
rZ	CERT_NONEZmatch_hostname�
BaseExceptionrOr�rhr<rr�rcr]�	Exceptionr�r�r�r�ru�updater�r�r�rWr�r{r}r�r�)r#Z
handshake_excZsslobjr�rDZdtrrr�_on_handshake_completeCsD




z"SSLProtocol._on_handshake_completecCs>|jdks|jdkrdSy�x�tt|j��D]�}|jd\}}|rT|jj||�\}}n*|rl|jj|j�}d}n|jj|j	�}d}x|D]}|jj
|�q�W|t|�kr�||f|jd<|jjr�|jj�P|jd=|j
t|�8_
q*WWnRtk
�r8}z4|j�r|j|�n|j|d�t|t��s(�WYdd}~XnXdS)NrrzFatal error on SSL transport)rcr|�rangerErxrIr2r�r4�	_finalizer7Z_pausedreryr�r~�_fatal_errorrhr�)r#�irBrHr0rCrDrrrr�ws8

z"SSLProtocol._process_write_backlog�Fatal error on transportcCsXt|tj�r*|jj�rBtjd||dd�n|jj|||j|d��|jrT|jj	|�dS)Nz%r: %sT)r�)�messageZ	exceptionr�rX)
rhrZ_FATAL_ERROR_IGNORErOr�rr�Zcall_exception_handlerrcZ_force_close)r#rDr�rrrr��s

zSSLProtocol._fatal_errorcCsd|_|jdk	r|jj�dS)N)r|rcr])r#rrrr��s
zSSLProtocol._finalizec
Cs(z|jdk	r|jj�Wd|j�XdS)N)rcrqr�)r#rrrrp�s
zSSLProtocol._abort)FNT)N)N)r�)rJrKrLr%r�r�r�r�r�r�r�rSr\rnr�r�r�r�r�rprrrrrr�s$
"


	4,
rr)rvr_r�ImportError�rrrr�logrrrrr-r(r3�objectrZ_FlowControlMixinZ	TransportrNZProtocolrrrrrr�<module>s*
wnPK=�\�f��I�Itasks.cpython-36.opt-1.pycnu�[���3


 \�a�
@s�dZddddddddd	d
ddd
g
ZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
ddlmZGdd�de
j�ZeZyddlZWnek
r�YnXejZZej
jZej
jZej
jZedded�dd��Zdd�Zedd�dd��Zedd��Zddd �d!d�Zed/dd�d"d��Zdd�d#d$�Zee�d	<d	e_ [dd�d%d�Z!ed&d'��Z"Gd(d)�d)e
j�Z#dd*d+�d,d
�Z$dd�d-d�Z%d.d
�Z&dS)0z0Support for tasks, coroutines and the scheduler.�Task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�async�gather�shield�
ensure_future�run_coroutine_threadsafe�N�)�
base_tasks)�compat)�
coroutines)�events)�futures)�	coroutinecs�eZdZdZej�ZiZdZe	ddd��Z
e	ddd��Zdd��fd	d
�
Ze
jrXdd�Zd
d�Zdd�dd�Zddd�dd�Zdd�Zd�fdd�	Zdd�Z�ZS)rz A coroutine wrapped in a Future.TNcCs|dkrtj�}|jj|�S)z�Return the currently running task in an event loop or None.

        By default the current task for the current event loop is returned.

        None is returned when called not in the context of a Task.
        N)r�get_event_loop�_current_tasks�get)�cls�loop�r�%/usr/lib64/python3.6/asyncio/tasks.py�current_task.szTask.current_taskcs$�dkrtj���fdd�|jD�S)z|Return a set of all tasks for an event loop.

        By default all tasks for the current event loop are returned.
        Ncsh|]}|j�kr|�qSr)�_loop)�.0�t)rrr�	<setcomp>Bsz!Task.all_tasks.<locals>.<setcomp>)rr�
_all_tasks)rrr)rr�	all_tasks:szTask.all_tasks)rcsNt�j|d�|jr|jd=||_d|_d|_|jj|j�|j	j
j|�dS)N)rrF���)�super�__init__�_source_traceback�_coro�_fut_waiter�_must_cancelr�	call_soon�_step�	__class__r"�add)�self�coror)r-rrr&Dsz
Task.__init__cCsH|jtjkr8|jr8|dd�}|jr,|j|d<|jj|�tjj|�dS)Nz%Task was destroyed but it is pending!)�task�messageZsource_traceback)	Z_staterZ_PENDING�_log_destroy_pendingr'rZcall_exception_handler�Future�__del__)r/�contextrrrr5Ss
zTask.__del__cCs
tj|�S)N)rZ_task_repr_info)r/rrr�
_repr_info^szTask._repr_info)�limitcCstj||�S)a�Return the list of stack frames for this task's coroutine.

        If the coroutine is not done, this returns the stack where it is
        suspended.  If the coroutine has completed successfully or was
        cancelled, this returns an empty list.  If the coroutine was
        terminated by an exception, this returns the list of traceback
        frames.

        The frames are always ordered from oldest to newest.

        The optional limit gives the maximum number of frames to
        return; by default all available frames are returned.  Its
        meaning differs depending on whether a stack or a traceback is
        returned: the newest frames of a stack are returned, but the
        oldest frames of a traceback are returned.  (This matches the
        behavior of the traceback module.)

        For reasons beyond our control, only one stack frame is
        returned for a suspended coroutine.
        )rZ_task_get_stack)r/r8rrr�	get_stackaszTask.get_stack)r8�filecCstj|||�S)anPrint the stack or traceback for this task's coroutine.

        This produces output similar to that of the traceback module,
        for the frames retrieved by get_stack().  The limit argument
        is passed to get_stack().  The file argument is an I/O stream
        to which the output is written; by default output is written
        to sys.stderr.
        )rZ_task_print_stack)r/r8r:rrr�print_stackxs	zTask.print_stackcCs4d|_|j�rdS|jdk	r*|jj�r*dSd|_dS)a�Request that this task cancel itself.

        This arranges for a CancelledError to be thrown into the
        wrapped coroutine on the next cycle through the event loop.
        The coroutine then has a chance to clean up or even deny
        the request using try/except/finally.

        Unlike Future.cancel, this does not guarantee that the
        task will be cancelled: the exception might be caught and
        acted upon, delaying cancellation of the task or preventing
        cancellation completely.  The task may also return a value or
        raise a different exception.

        Immediately after this method is called, Task.cancelled() will
        not return True (unless the task was already cancelled).  A
        task will be marked as cancelled when the wrapped coroutine
        terminates with a CancelledError exception (even if cancel()
        was not called).
        FNT)Z_log_traceback�doner)�cancelr*)r/rrrr=�s

zTask.cancelcsf|jr t|tj�stj�}d|_|j}d|_||jj|j<�zy"|dkrT|j	d�}n
|j
|�}Wn�tk
r�}z.|jr�d|_|jtj��n|j
|j�WYdd}~X�n�tjk
r�t�j�Y�n|tk
r�}z|j|�WYdd}~X�nPtk
�r(}z|j|��WYdd}~X�n Xt|dd�}|dk	�r�|j|jk	�rl|jj|jtdj||���n||�r�||k�r�|jj|jtdj|���n2d|_|j|j�||_|j�r�|jj��r�d|_n|jj|jtdj||���n^|dk�r|jj|j�nDtj|��r.|jj|jtdj||���n|jj|jtdj|���Wd|jjj|j�d}XdS)NF�_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r})r*�
isinstancer�CancelledErrorr(r)r-rr�send�throw�
StopIteration�
set_exception�
set_result�valuer%r=�	Exception�
BaseException�getattrr+r,�RuntimeError�formatr>�add_done_callback�_wakeup�inspectZisgenerator�pop)r/�excr0�resultZblocking)r-rrr,�s~



z
Task._stepcCsJy|j�Wn,tk
r8}z|j|�WYdd}~Xn
X|j�d}dS)N)rQrGr,)r/�futurerPrrrrM�szTask._wakeup)N)N)N)�__name__�
__module__�__qualname__�__doc__�weakref�WeakSetr"rr3�classmethodrr#r&rZPY34r5r7r9r;r=r,rM�
__classcell__rr)r-rrs"	!T)r�timeout�return_whenc#s�tj|�stj|�r&tdt|�j��|s2td��|tt	t
fkrNtdj|����dkr^tj
���fdd�t|�D�}t|||��EdHS)a�Wait for the Futures and coroutines given by fs to complete.

    The sequence futures must not be empty.

    Coroutines will be wrapped in Tasks.

    Returns two sets of Future: (done, pending).

    Usage:

        done, pending = yield from asyncio.wait(fs)

    Note: This does not raise TimeoutError! Futures that aren't done
    when the timeout occurs are returned in the second set.
    z expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}Ncsh|]}t|�d��qS))r)r)r�f)rrrr!7szwait.<locals>.<setcomp>)r�isfuturer�iscoroutine�	TypeError�typerS�
ValueErrorrrrrKrr�set�_wait)�fsrr[r\r)rrrscGs|j�s|jd�dS)N)r<rE)�waiter�argsrrr�_release_waiter<srh)rccs�|dkrtj�}|dkr"|EdHS|j�}|j|t|�}tjt|�}t||d�}|j|�zhy|EdHWn*t	j
k
r�|j|�|j��YnX|j
�r�|j�S|j|�|j�t	j��Wd|j�XdS)a�Wait for the single Future or coroutine to complete, with timeout.

    Coroutine will be wrapped in Task.

    Returns result of the Future or coroutine.  When a timeout occurs,
    it cancels the task and raises TimeoutError.  To avoid the task
    cancellation, wrap it in shield().

    If the wait is cancelled, the task is also cancelled.

    This function is a coroutine.
    N)r)rr�
create_future�
call_laterrh�	functools�partialrrLrr@�remove_done_callbackr=r<rQ�TimeoutError)�futr[rrf�timeout_handle�cbrrrrAs,



c#s�|j��d�|dk	r"|j|t���t|������fdd�}x|D]}|j|�qBWz�EdHWd�dk	rt�j�Xt�t�}}x4|D],}|j|�|j�r�|j	|�q�|j	|�q�W||fS)zeInternal helper for wait() and wait_for().

    The fs argument must be a collection of Futures.
    Ncs\�d8��dks6�tks6�tkrX|j�rX|j�dk	rX�dk	rF�j��j�sX�jd�dS)Nrr)rr�	cancelled�	exceptionr=r<rE)r])�counterr\rprfrr�_on_completion|sz_wait.<locals>._on_completion)
rirjrh�lenrLr=rcrmr<r.)rer[r\rrur]r<�pendingr)rtr\rprfrrdos&



rd)rr[c#s�tj|�stj|�r&tdt|�j���dk	r2�ntj���fdd�t	|�D��ddl
m}|�d��d����fdd	�}���fd
d��t�fdd
��}x�D]}|j
��q�W�r�|dk	rʈj||��xtt���D]}|�Vq�WdS)amReturn an iterator whose values are coroutines.

    When waiting for the yielded coroutines you'll get the results (or
    exceptions!) of the original Futures (or coroutines), in the order
    in which and as soon as they complete.

    This differs from PEP 3148; the proper way to use this is:

        for f in as_completed(fs):
            result = yield from f  # The 'yield from' may raise.
            # Use result.

    If a timeout is specified, the 'yield from' will raise
    TimeoutError when the timeout occurs before all Futures are done.

    Note: The futures 'f' are not necessarily members of fs.
    z expect a list of futures, not %sNcsh|]}t|�d��qS))r)r)rr])rrrr!�szas_completed.<locals>.<setcomp>r)�Queue)rcs.x �D]}|j���jd�qW�j�dS)N)rm�
put_nowait�clear)r])rur<�todorr�_on_timeout�s

z!as_completed.<locals>._on_timeoutcs6�sdS�j|��j|��r2�dk	r2�j�dS)N)�removeryr=)r])r<rpr{rrru�s

z$as_completed.<locals>._on_completionc3s$�j�EdH}|dkrtj�|j�S)N)rrrnrQ)r])r<rr�
_wait_for_one�sz#as_completed.<locals>._wait_for_one)rr^rr_r`rarSrrrcZqueuesrxrrLrj�rangerv)rerr[rxr|r~r]�_r)rur<rrpr{rr�s 

c
csX|dkrdV|S|dkr"tj�}|j�}|jj|tj||�}z
|EdHS|j�XdS)z9Coroutine that completes after a given time (in seconds).rN)rrrirrjrZ_set_result_unless_cancelledr=)ZdelayrQrrR�hrrrr�s
cCstjdtdd�t||d�S)z�Wrap a coroutine in a future.

    If the argument is a Future, it is returned directly.

    This function is deprecated in 3.5. Use asyncio.ensure_future() instead.
    z;asyncio.async() function is deprecated, use ensure_future()�)�
stacklevel)r)�warnings�warn�DeprecationWarningr)�coro_or_futurerrrr�async_�sr�cCs�tj|�r(|dk	r$||jk	r$td��|Stj|�r^|dkrBtj�}|j|�}|j	rZ|j	d=|St
jr~tj
|�r~tt|�|d�Std��dS)zmWrap a coroutine or an awaitable in a future.

    If the argument is a Future, it is returned directly.
    Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rr^rrbrr_rrZcreate_taskr'rZPY35rNZisawaitabler�_wrap_awaitabler`)r�rr1rrrr�s


ccs|j�EdHS)z�Helper for asyncio.ensure_future().

    Wraps awaitable (an object with __await__) into a coroutine
    that will later be wrapped in a Task by ensure_future().
    N)�	__await__)Z	awaitablerrrr�sr�cs.eZdZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFuturez�Helper for gather().

    This overrides cancel() to cancel all the children and act more
    like Task.cancel(), which doesn't immediately mark itself as
    cancelled.
    N)rcst�j|d�||_d|_dS)N)rF)r%r&�	_children�_cancel_requested)r/�childrenr)r-rrr&$sz_GatheringFuture.__init__cCs:|j�rdSd}x|jD]}|j�rd}qW|r6d|_|S)NFT)r<r�r=r�)r/ZretZchildrrrr=)sz_GatheringFuture.cancel)rSrTrUrVr&r=rZrr)r-rr�sr�F)r�return_exceptionscs|s*|dkrtj�}|j���jg��Si�xjt|�D]^}tj|�sht||d�}|dkr`|j}d|_	n&|}|dkr||j}n|j|k	r�t
d��|�|<q8W�fdd�|D�}t|��t||d��d�dg�������fdd	�}x&t
|�D]\}}|jtj||��q�W�S)
a7Return a future aggregating results from the given coroutines
    or futures.

    Coroutines will be wrapped in a future and scheduled in the event
    loop. They will not necessarily be scheduled in the same order as
    passed in.

    All futures must share the same event loop.  If all the tasks are
    done successfully, the returned future's result is the list of
    results (in the order of the original sequence, not necessarily
    the order of results arrival).  If *return_exceptions* is True,
    exceptions in the tasks are treated the same as successful
    results, and gathered in the result list; otherwise, the first
    raised exception will be immediately propagated to the returned
    future.

    Cancellation: if the outer Future is cancelled, all children (that
    have not completed yet) are also cancelled.  If any child is
    cancelled, this is treated as if it raised CancelledError --
    the outer Future is *not* cancelled in this case.  (This is to
    prevent the cancellation of one child to cause other children to
    be cancelled.)
    N)rFz)futures are tied to different event loopscsg|]}�|�qSrr)r�arg)�
arg_to_futrr�
<listcomp>hszgather.<locals>.<listcomp>rcs��j�r|j�s|j�dS|j�r@tj�}�sl�j|�dSn,|jdk	rf|j�}�sl�j|�dSn|j}|�|<�d7���kr��jr��jtj��n
�j	��dS)Nr)
r<rrrsrr@rDZ
_exceptionZ_resultr�rE)�iro�res)�	nchildren�	nfinished�outer�resultsr�rr�_done_callbackns*


zgather.<locals>._done_callback)rrrirErcrr^rrr3rbrvr��	enumeraterLrkrl)rr�Zcoros_or_futuresr�ror�r�r�r)r�r�r�r�r�r�rr
8s8



cs@t||d�}|j�r|S|j}|j���fdd�}|j|��S)a=Wait for a future, shielding it from cancellation.

    The statement

        res = yield from shield(something())

    is exactly equivalent to the statement

        res = yield from something()

    *except* that if the coroutine containing it is cancelled, the
    task running in something() is not cancelled.  From the POV of
    something(), the cancellation did not happen.  But its caller is
    still cancelled, so the yield-from expression still raises
    CancelledError.  Note: If something() is cancelled by other means
    this will still cancel shield().

    If you want to completely ignore cancellation (not recommended)
    you can combine shield() with a try/except clause, as follows:

        try:
            res = yield from shield(something())
        except CancelledError:
            res = None
    )rcs\�j�r|j�s|j�dS|j�r.�j�n*|j�}|dk	rJ�j|�n�j|j��dS)N)rrrsr=rDrErQ)�innerrP)r�rrr��s
zshield.<locals>._done_callback)rr<rrirL)r�rr�r�r)r�rr�s
cs:tj��std��tjj�����fdd�}�j|��S)zsSubmit a coroutine object to a given event loop.

    Return a concurrent.futures.Future to access the result.
    zA coroutine object is requiredcsTytjt��d���Wn6tk
rN}z�j�r<�j|��WYdd}~XnXdS)N)r)rZ
_chain_futurerrGZset_running_or_notify_cancelrD)rP)r0rRrrr�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rr_r`�
concurrentrr4Zcall_soon_threadsafe)r0rr�r)r0rRrrr
�s


)N)'rV�__all__Zconcurrent.futuresr�rkrNr�rW�rrrrrrr4rZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrhrrdrrr��globalsrSrr�r�r
rr
rrrr�<module>sZ
s
--8

W5PK��\�Q9��entities.cpython-36.opt-1.pycnu�[���3


 \3&��@s6%dZddddgZddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��d�d��Z�d�d�d�d�d�d�d�d�d�d	�d
�d	�d
�d�d�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d"�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d9�d:�d;�d<�d�d7�d:�d1�d=�d1�d=�d>�d?�d@�dA�d7�dB�dC�dD�dC�dD�dE�dF�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dN�dO�dP�dQ�dR�dR�dS�dT�dI�dU�dV�dW�dX�dX�dX�dY�dJ�dZ�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�de�df�dg�dh�di�dj�dk�dl�dm�dn�do�dp�dq�dr�ds�dt�du�dv�dw�dx�dy�dz�d{�d|�d}�d~�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dK�d��d��d��d��dZ�d��d��dL�dM�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdːdʐdːd̐d͐dΐdϐdАdѐdҐdӐdӐdӐdԐdՐdՐd֐d֐dƐdאdؐdِdڐdڐdېdܐdݐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�dߐd�d�d�d�d�d�d�d�d�d�d��d@�d@�d��d��d��d��d��d��d��d��d��d��d��d��d��d�d�d�d�d�d�d�d�dG�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d�d�d�dB�d�d�d�d�d�d�d�d�d�d�d�d �d �d�d�d�d�d�d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�dd2�d#�d3�d4�d5�d6�d6�d7�d8�d9�d:�d;�d<�d=�d>�d?�d@�d�dA�d-�dB�dC�dD�dD�dD�dE�dE�dF�d2�dG�dH�dI�dI�dI�dJ�dJ�dK�dL�dM�dN�dO�dP�dQ�dF�dA�dR�dS�dT�dS�dU�dV�dW�dQ�d��dF�d'�dX�dY�d*�dZ�d[�d\�d]�d^�d_�d`�da�d(�d'�d(�db�dc�dd�d3�d?�d@�de�df�dg�dh�di�dj�dk�dl�dm�dn�do�dp�dq�dr�ds�dt�du�dv�dw�dx�dy�dr�dc�dz�d{�d|�d}�d~�d�d��d�d��d��d��d��d��d��d��d��d��d��d��d��d5�d��dT�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dS�d��d��d��d��d��d��d��d��d��d��d��d��ddÐdĐdĐd��d��d��d��dŐdƐdǐdȐdɐdʐdːd̐d͐dΐdp�dϐdАdѐdҐdӐdԐdՐd֐d֐dאdؐdِdڐdېdېdܐdݐdݐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�d�dِd�d�d�d�d�dG�d�d�d�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d�d�d�d�d�d�d�d�d�d	�d�d
�d�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�dB�d��d��d��d�d
�d��d�d�d�d�d�d�d�d�d�d	�d�d�d�d �d!�d"�d�d#�d �d��d��d
�d�d$�d$�dŐd%�dېd&�d'�d(�dY�d)�d*�d+�d,�d-�d.�d/�d0�d0�d1�d2�d3�d4�d&�d5�d6�d7�d8�d9�d:�d;�d<�d=�d��d&�d>�d-�d?�d@�d��d��dA�d)�dB�dC�dB�dC�dD�dE�dF�dE�dF�dG�dH�dI�dJ�dK�dL�dL�dY�dM�dN�dO�dP�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dM�dX�dY�dM�dQ�dZ�dM�d[�d\�d]�d]�d��d^�d_�d`�d[�da�db�dc�dd�db�dc�da�de�df�dD�dg�dh�di�dj�dk�dl�dm�dn�do�df�dp�dp�dZ�dq�d��dr�ds�dt�du�d��dg�dv�dw�dx�dy�dz�d{�dz�d{�d|�d}�d~�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dX�d��d��d��d��d9�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��ddÐd��dĐdŐdƐdǐdW�dȐdɐdʐdːd̐d��d��dX�d��d��d͐d��dÐdΐdϐd?�dАdѐdg�dҐdӐd)�dY�d)�d͐dԐd+�dՐd+�d֐dאdؐdِdڐdېdܐdݐdސdߐdҐd�d�d�d̐dːd�d�d�d�d�d�d�d�d��d�d�d�d�dːd�d�d�d�d�d�d�dѐd�d�d�d�d�dg�dҐd�d�d��d��d��d��dӐdM�d��d��d��d��d��d��d��d��d��d��d�d�d��d�d�d�dΐd�dZ�d�d�d[�d�d�d�d\�d�d��d�d	�d
�d�d�d
�d�d�d�d�d�d�do�d�d�d͐do�dԐd�d�d�d�d��d�d�d�d�d�d�d��d�d�d�d �d!�d!�d!�d��d!�d"�d#�d�dؐd$�d%�d&�d'�dېds�d(�d)�d*�d+�d+�d,�d,�d-�d.�d.�d/�d0�d0�dm�d֐d1�d2�d3�d4�d5�d6�d7�d$�d8�d9�d:�d;�d<�d=�d=�d>�dA�d?�d֐d֐d@�d��dU�dA�dB�dC�d1�dB�dD�dE�dF�dB�d9�dG�d�dH�dI�dJ�dJ�d7�dK�dL�dM�dN�dO�dP�dQ�dN�dR�dR�dS�dT�dT�dU�dV�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�de�de�df�dg�dg�dg�dg�dh�di�dj�d	�d��dk�dl�dl�dm�dn�do�dp�dp�do�dq�dq�dr�ds�dt�du�du�dv�dw�dx�dy�dz�d{�d|�dz�d}�d~�d�d��d��d��d��d�d��dw�dx�d��d��d��d��d��d��d��d��d��d��d��d��d��d��dT�dS�d��d��d��d��dh�d��d��d��db�dj�dl�du�dp�do�dv�d��dq�ds�dU�dV�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d\�dN�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dd��dd��d��d��d��d��dÐdĐdŐdƐdǐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdԐdՐd֐dאdؐdِdڐdڐdېdܐdݐdܐdݐd�d�dސdߐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��d�d�d�d�d�d��d��d�d��d��d��d��d�d��d��d��dǐd�d��d�d��d�d�d�d�d�d�d�d�d�d�d�d�d�d�d	�d�d
�d�d
�d�d�d
�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�da�d�d�da�d�d�d�d�d�d�d�d�d�d��d �d!�d"�d#�d$�d%�d9�d&�d'�d(�dאd)�d-�d*�d-�d+�d,�d��d-�dV�d.�d/�d0�d0�d0�d1�d2�d0�d3�d3�d4�d5�d6�d6�d7�d8�d9�d:�d;�d<�d8�d9�d:�d8�d<�d:�d=�d<�d>�d?�d@�d=�dA�dB�d4�d>�d?�d@�dC�dC�dD�dE�dF�dG�d�dG�dG�d=�dH�dI�dJ�dK�dL�dM�dN�dO�dR�dP�dQ�dR�dS�dT�d;�dU�dV�d��dW�dW�dW�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�da�d_�db�db�dc�d]�dd�de�df�dg�dh�di�d:�d�dj�dk�dl�dm�dn�do�dp�dq�dP�dn�d,�dn�dr�ds�dt�du�dv�dw�dx�dy�dz�d{�d|�ds�d}�d~�d�d��d�d�d��d��d��d��d��d��d��d�d�d�d�dz�dԐdz�d��d��d��d��d��dj�d��d��d��d��d��d_�dd�d]�dd�df�d��dm�d|�d��d��d@�d��d��dj�d��d��d��d��dn�d��d0�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dX�d��d��d��d��d��dt�d�d�d��d��d��d��dt�d��d��d��d��d��d��d�d��d��d��d��d��d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdːdW�d̐d5�d͐d�d�dΐdΐdϐdАdN�dN�dѐdҐdӐd�dԐdՐd֐dאdؐd(�d��d>�da�dd�dِdڐdڐdېdܐdݐdݐdސdߐd�d�d�d�d�d�d�d�d�d��d��dN�d�d�d>�d�d�d�d�d�d�d�d�d�d�d�d��d��da�d��d��d��d��d\�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dp�dp�dd�d��d�dN�d�d�d�d�dh�d��d%�d,�d�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d
�d�d�d�d��d��d��d��d��d��dȐd��dĐdŐdƐdȐdz�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d�d�d�d�d"�d!�d$�d%�d&�d6�d'�d�d�d(�d)�d)�d*�d+�d,�d-�d�d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d8�d8�d9�d:�d;�d;�d7�dސd<�d=�d=�d7�dސd>�d?�d>�d?�dސdC�d�d��d7�d@�d@�d��dA�dB�dS�di�dl�dC�dD�dE�dF�dG�dАdH�dI�dI�dJ�dy�d'�dېdK�d��d��dL�dK�dM�d4�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dX�dY�d^�d��dc�dZ�d[�dZ�d[�d\�d_�dِd]�d^�d_�d`�da�db�dc�db�dc�dd�de�df�dg�dh�di�dj�dk�dl�dm�dn�dm�dn�do�dސd��dp�dq�dq�dr�ds�dt�du�dF�dF�d�dv�dS�dw�dc�dx�dy�dz�d{�d|�dِd_�dِd}�df�d~�d`�d~�di�dސd��dx�dڐde�d�d��d�d��d��d��d1�d��d��d��d��d��d��d��d��d��d��d��d��dJ�dq�d��d��d��d��d��d��d��d��d��d��d%�d)�dG�d`�d~�d��dݐd��d��d��d��d;�dِd��d��d��d��d��d��d��d��d^�d��d��dl�d�d��d��d��d��d��d��d��d>�d��d��d��d%�d��d��dِd��d��d��d��dG�d��d��d��d��d��d��d��d��d��d��d��d��dm�d�d��d��d��d��d��d��d��d��d��d��d��da�db�dc�di�d��d��d[�d�d��d��dZ�d�d�d��dd�d��d��de�df�d\�d�d��d��dg�dk�dj�dl�dm�d��d��d��d��ddÐdĐdŐdƐdǐdȐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdԐdӐdՐd֐dאdؐdِdڐdېdܐdݐdg�dސdߐdݐd�d�d�d�dd�d�d�d�d�d�d���ZiZiZx*ej�D]\ZZeee<e	e�ee<�%q
W[[�d�S(�z!HTML character entity references.�html5�name2codepoint�codepoint2name�
entitydefs������i�������i���i�i! i���������i�i���i�������i���i�i�i���i�iR������i�i�������i�i�i3 i�i�i`i���i�i�������i���i���ixi����������i5!i��&i'"i "��iH"����i i��i" i)"����i�i�ic&iE"�i�!i*"�i�!i  i�!�i�if&�������i"i i i�ia"i�����i� i"i�i"���iD i�ie"�>i�!i�!ie&i& �������i!i"i+"i��i"��i�i�!i�i)#�i�!i#i id"i
#i"i�%i i9 i �<�i ��i"i�i"�i i`"i"�i	"i�"��i�����iS��i> i�i�i�"i("����i�"��i"i0 i�"i�i�i���i2 i"i"i��"i�!i"i*#�i�!i	#i i!�i#i�i i: i i iai�"��i�i�i<"i`&i�"i�"i"i�"���i�"��i�i4"i�i�i	 �i���i"!i�!�i�!���i�i��i!i����i�i
 i )��AElig�Aacute�Acirc�AgraveZAlpha�Aring�Atilde�AumlZBeta�CcedilZChiZDaggerZDelta�ETH�Eacute�Ecirc�EgraveZEpsilonZEta�EumlZGamma�Iacute�Icirc�IgraveZIota�IumlZKappaZLambdaZMu�NtildeZNuZOElig�Oacute�Ocirc�OgraveZOmegaZOmicron�Oslash�Otilde�OumlZPhiZPiZPrimeZPsiZRhoZScaronZSigma�THORNZTauZTheta�Uacute�Ucirc�UgraveZUpsilon�UumlZXi�YacuteZYumlZZeta�aacute�acirc�acute�aelig�agraveZalefsymZalpha�amp�andZang�aringZasymp�atilde�aumlZbdquoZbeta�brvbarZbullZcap�ccedil�cedil�centZchiZcircZclubsZcong�copyZcrarrZcup�currenZdArrZdaggerZdarr�degZdeltaZdiams�divide�eacute�ecirc�egrave�emptyZemspZensp�epsilonZequivZeta�eth�eumlZeuroZexistZfnofZforall�frac12�frac14�frac34ZfraslZgamma�ge�gtZhArrZharrZheartsZhellip�iacute�icirc�iexcl�igraveZimageZinfin�intZiota�iquestZisin�iumlZkappaZlArr�lambdaZlang�laquoZlarrZlceilZldquo�leZlfloorZlowastZlozZlrmZlsaquoZlsquo�lt�macrZmdash�micro�middotZminusZmuZnabla�nbspZndash�neZni�notZnotinZnsub�ntildeZnu�oacute�ocircZoelig�ograveZolineZomegaZomicronZoplus�or�ordf�ordm�oslash�otildeZotimes�ouml�para�partZpermilZperpZphiZpiZpiv�plusmn�poundZprimeZprodZpropZpsi�quotZrArrZradicZrang�raquoZrarrZrceilZrdquo�real�regZrfloorZrhoZrlmZrsaquoZrsquoZsbquoZscaronZsdot�sect�shyZsigmaZsigmafZsimZspades�subZsube�sumZsup�sup1�sup2�sup3Zsupe�szligZtauZthere4ZthetaZthetasymZthinsp�thorn�tilde�timesZtradeZuArr�uacuteZuarr�ucirc�ugrave�umlZupsihZupsilon�uumlZweierpZxi�yacute�yen�yumlZzetaZzwjZzwnj�Á�áuĂuău∾u∿u∾̳�Â�â�´uАuа�Æ�æu⁡u𝔄u𝔞�À�àuℵuΑuαuĀuāu⨿�&u⩓u∧u⩕u⩜u⩘u⩚u∠u⦤u∡u⦨u⦩u⦪u⦫u⦬u⦭u⦮u⦯u∟u⊾u⦝u∢�Åu⍼uĄuąu𝔸u𝕒u≈u⩯u⩰u≊u≋�'�åu𝒜u𝒶u≔�*u≍�Ã�ã�Ä�äu∳u⨑u≌u϶u‵u∽u⋍u∖u⫧u⊽u⌆u⌅u⎵u⎶uБuбu„u∵u⦰uℬuΒuβuℶu≬u𝔅u𝔟u⋂u◯u⋃u⨀u⨁u⨂u⨆u★u▽u△u⨄u⋁u⋀u⤍u⧫u▪u▴u▾u◂u▸u␣u▒u░u▓u█u=⃥u≡⃥u⫭u⌐u𝔹u𝕓u⊥u⋈u⧉u╗u╖u╕u┐u╔u╓u╒u┌u═u─u╦u╤u╥u┬u╩u╧u╨u┴u⊟u⊞u⊠u╝u╜u╛u┘u╚u╙u╘u└u║u│u╬u╫u╪u┼u╣u╢u╡u┤u╠u╟u╞u├u˘�¦u𝒷u⁏�\u⧅u⟈u•u≎u⪮u≏uĆuću⋒u∩u⩄u⩉u⩋u⩇u⩀uⅅu∩︀u⁁uˇuℭu⩍uČuč�Ç�çuĈuĉu∰u⩌u⩐uĊuċ�¸u⦲�¢�·u𝔠uЧuчu✓uΧuχu○uˆu≗u↺u↻u⊛u⊚u⊝u⊙�®uⓈu⊖u⊕u⊗u⧃u⨐u⫯u⧂u∲u”u’u♣u∷�:u⩴�,�@u∁u∘uℂu≅u⩭u≡u∯u∮u𝕔u∐�©u℗u↵u⨯u✗u𝒞u𝒸u⫏u⫑u⫐u⫒u⋯u⤸u⤵u⋞u⋟u↶u⤽u⋓u∪u⩈u⩆u⩊u⊍u⩅u∪︀u↷u⤼u⋎u⋏�¤u∱u⌭u‡u†uℸu↡u⇓u↓u‐u⫤u⊣u⤏u˝uĎuďuДuдuⅆu⇊u⤑u⩷�°u∇uΔuδu⦱u⥿u𝔇u𝔡u⥥u⇃u⇂u˙�`u˜u⋄u♦�¨uϝu⋲�÷u⋇uЂuђu⌞u⌍�$u𝔻u𝕕u⃜u≐u≑u∸u∔u⊡u⇐u⇔u⟸u⟺u⟹u⇒u⊨u⇑u⇕u∥u⤓u⇵ȗu⥐u⥞u↽u⥖u⥟u⇁u⥗u⊤u↧u⤐u⌟u⌌u𝒟u𝒹uЅuѕu⧶uĐuđu⋱u▿u⥯u⦦uЏuџu⟿�É�éu⩮uĚuěu≖�Ê�êu≕uЭuэuĖuėuⅇu≒u𝔈u𝔢u⪚�È�èu⪖u⪘u⪙u∈u⏧uℓu⪕u⪗uĒuēu∅u◻u▫u u u uŊuŋu uĘuęu𝔼u𝕖u⋕u⧣u⩱uεuΕuϵu≂u⩵�=u≟u⇌u⩸u⧥u⥱u≓uℰuℯu⩳uΗuη�Ð�ð�Ë�ëu€�!u∃uФuфu♀uffiuffufflu𝔉u𝔣ufiu◼Zfju♭uflu▱uƒu𝔽u𝕗u∀u⋔u⫙uℱu⨍�½u⅓�¼u⅕u⅙u⅛u⅔u⅖�¾u⅗u⅜u⅘u⅚u⅝u⅞u⁄u⌢u𝒻uǵuΓuγuϜu⪆uĞuğuĢuĜuĝuГuгuĠuġu≧u≥u⪌u⋛u⩾u⪩u⪀u⪂u⪄u⋛︀u⪔u𝔊u𝔤u⋙u≫uℷuЃuѓu≷u⪥u⪒u⪤u⪊u≩u⪈u⋧u𝔾u𝕘u⪢u≳u𝒢uℊu⪎u⪐�>u⪧u⩺u⋗u⦕u⩼u⥸u≩︀u uℋuЪuъu↔u⥈u↭�^uℏuĤuĥu♥u…u⊹uℌu𝔥u⤥u⤦u⇿u∻u↩u↪uℍu𝕙u―u𝒽uĦuħu⁃�Í�íu⁣�Î�îuИuиuİuЕuе�¡uℑu𝔦�Ì�ìuⅈu⨌u∭u⧜u℩uIJuijuĪuīuℐuıu⊷uƵu℅u∞u⧝u∬u∫u⊺uℤu⨗u⨼u⁢uЁuёuĮuįu𝕀u𝕚uΙuι�¿u𝒾u⋵u⋹u⋴u⋳uĨuĩuІuі�Ï�ïuĴuĵuЙuйu𝔍u𝔧uȷu𝕁u𝕛u𝒥u𝒿uЈuјuЄuєuΚuκuϰuĶuķuКuкu𝔎u𝔨uĸuХuхuЌuќu𝕂u𝕜u𝒦u𝓀u⇚uĹuĺu⦴uℒuΛuλu⟪u⟨u⦑u⪅�«u↞u←u⇤u⤟u⤝u↫u⤹u⥳u↢u⪫u⤛u⤙u⪭u⪭︀u⤎u⤌u❲�{�[u⦋u⦏u⦍uĽuľuĻuļu⌈uЛuлu⤶u“u⥧u⥋u↲u≦u≤u⇆u⟦u⥡u⥙u⌊u↼u⇇u⇋u⥎u↤u⥚u⋋u⊲u⧏u⊴u⥑u⥠u↿u⥘u⥒u⪋u⋚u⩽u⪨u⩿u⪁u⪃u⋚︀u⪓u⋖u≶u⪡u≲u⥼u𝔏u𝔩u⪑u⥢u⥪u▄uЉuљu⋘u≪u⥫u◺uĿuŀu⎰u⪉u≨u⪇u⋦u⟬u⇽u⟵u⟷u⟼u⟶u↬u⦅u𝕃u𝕝u⨭u⨴u∗�_u↙u↘u◊�(u⦓u⥭u‎u⊿u‹u𝓁u↰u⪍u⪏u‘u‚uŁuł�<u⪦u⩹u⋉u⥶u⩻u◃u⦖u⥊u⥦u≨︀�¯u♂u✠u⤅u↦u↥u▮u⨩uМuмu—u∺u uℳu𝔐u𝔪u℧�µu∣u⫰u−u⨪u∓u⫛u⊧u𝕄u𝕞u𝓂uΜuμu⊸uŃuńu∠⃒u≉u⩰̸u≋̸uʼnu♮uℕ� u≎̸u≏̸u⩃uŇuňuŅuņu≇u⩭̸u⩂uНuнu–u≠u⤤u⇗u↗u≐̸u​u≢u⤨u≂̸�
u∄u𝔑u𝔫u≧̸u≱u⩾̸u⋙̸u≵u≫⃒u≯u≫̸u⇎u↮u⫲u∋u⋼u⋺uЊuњu⇍u↚u‥u≦̸u≰u⩽̸u≮u⋘̸u≴u≪⃒u⋪u⋬u≪̸u∤u⁠u𝕟�¬u⫬u≭u∦u∉u≹u⋵̸u⋹̸u⋷u⋶u⧏̸u≸u⪢̸u⪡̸u∌u⋾u⋽u⊀u⪯̸u⋠u⋫u⧐̸u⋭u⊏̸u⋢u⊐̸u⋣u⊂⃒u⊈u⊁u⪰̸u⋡u≿̸u⊃⃒u⊉u≁u≄u⫽⃥u∂̸u⨔u⇏u↛u⤳̸u↝̸u𝒩u𝓃u⊄u⫅̸u⊅u⫆̸�Ñ�ñuΝuν�#u№u u≍⃒u⊯u⊮u⊭u⊬u≥⃒u>⃒u⤄u⧞u⤂u≤⃒u<⃒u⊴⃒u⤃u⊵⃒u∼⃒u⤣u⇖u↖u⤧�Ó�ó�Ô�ôuОuоuŐuőu⨸u⦼uŒuœu⦿u𝔒u𝔬u˛�Ò�òu⧁u⦵uΩu⦾u⦻u‾u⧀uŌuōuωuΟuοu⦶u𝕆u𝕠u⦷u⦹u⩔u∨u⩝uℴ�ª�ºu⊶u⩖u⩗u⩛u𝒪�Ø�øu⊘�Õ�õu⨷u⨶�Ö�öu⌽u⏞u⎴u⏜�¶u⫳u⫽u∂uПuп�%�.u‰u‱u𝔓u𝔭uΦuφuϕu☎uΠuπuϖuℎ�+u⨣u⨢u⨥u⩲�±u⨦u⨧u⨕uℙu𝕡�£u⪻u≺u⪷u≼u⪳u⪯u≾u⪹u⪵u⋨u″u′u∏u⌮u⌒u⌓u∝u⊰u𝒫u𝓅uΨuψu u𝔔u𝔮uℚu𝕢u⁗u𝒬u𝓆u⨖�?�"u⇛u∽̱uŔuŕu√u⦳u⟫u⟩u⦒u⦥�»u↠u→u⥵u⇥u⤠u⤳u⤞u⥅u⥴u⤖u↣u↝u⤜u⤚u∶u❳�}�]u⦌u⦎u⦐uŘuřuŖuŗu⌉uРuрu⤷u⥩u↳uℜuℛuℝu▭u⥽u⌋u𝔯u⥤u⇀u⥬uΡuρuϱu⇄u⟧u⥝u⥕u⇉u⊢u⥛u⋌u⊳u⧐u⊵u⥏u⥜u↾u⥔u⥓u˚u‏u⎱u⫮u⟭u⇾u⦆u𝕣u⨮u⨵u⥰�)u⦔u⨒u›u𝓇u↱u⋊u▹u⧎u⧴u⥨u℞uŚuśu⪼u≻u⪸uŠušu≽u⪴u⪰uŞuşuŜuŝu⪺u⪶u⋩u⨓u≿uСuсu⋅u⩦u⇘�§�;u⤩u✶u𝔖u𝔰u♯uЩuщuШuшu↑�­uΣuσuςu∼u⩪u≃u⪞u⪠u⪝u⪟u≆u⨤u⥲u⨳u⧤u⌣u⪪u⪬u⪬︀uЬuь�/u⧄u⌿u𝕊u𝕤u♠u⊓u⊓︀u⊔u⊔︀u⊏u⊑u⊐u⊒u□u𝒮u𝓈u⋆u☆u⋐u⊂u⪽u⫅u⊆u⫃u⫁u⫋u⊊u⪿u⥹u⫇u⫕u⫓u∑u♪�¹�²�³u⋑u⊃u⪾u⫘u⫆u⊇u⫄u⟉u⫗u⥻u⫂u⫌u⊋u⫀u⫈u⫔u⫖u⇙u⤪�ß�	u⌖uΤuτuŤuťuŢuţuТuтu⃛u⌕u𝔗u𝔱u∴uΘuθuϑu  u �Þ�þ�×u⨱u⨰u⌶u⫱u𝕋u𝕥u⫚u‴u™u▵u≜u◬u⨺u⨹u⧍u⨻u⏢u𝒯u𝓉uЦuцuЋuћuŦuŧ�Ú�úu↟u⥉uЎuўuŬuŭ�Û�ûuУuуu⇅uŰuűu⥮u⥾u𝔘u𝔲�Ù�ùu⥣u▀u⌜u⌏u◸uŪuūu⏟u⏝u⊎uŲuųu𝕌u𝕦u⤒u↕uϒuυuΥu⇈u⌝u⌎uŮuůu◹u𝒰u𝓊u⋰uŨuũ�Ü�üu⦧u⦜u⊊︀u⫋︀u⊋︀u⫌︀u⫫u⫨u⫩uВuвu⊫u⊩u⫦u⊻u≚u⋮u‖�|u❘u≀u𝔙u𝔳u𝕍u𝕧u𝒱u𝓋u⊪u⦚uŴuŵu⩟u≙u℘u𝔚u𝔴u𝕎u𝕨u𝒲u𝓌u𝔛u𝔵uΞuξu⋻u𝕏u𝕩u𝒳u𝓍�Ý�ýuЯuяuŶuŷuЫuы�¥u𝔜u𝔶uЇuїu𝕐u𝕪u𝒴u𝓎uЮuю�ÿuŸuŹuźuŽužuЗuзuŻużuℨuΖuζu𝔷uЖuжu⇝u𝕫u𝒵u𝓏u‍u‌(�rjr�zAacute;zaacute;zAbreve;zabreve;zac;zacd;zacE;rkr�zAcirc;zacirc;r�zacute;zAcy;zacy;rir�zAElig;zaelig;zaf;zAfr;zafr;rlr�zAgrave;zagrave;zalefsym;zaleph;zAlpha;zalpha;zAmacr;zamacr;zamalg;ZAMPr�zAMP;zamp;zAnd;zand;zandand;zandd;z	andslope;zandv;zang;zange;zangle;zangmsd;z	angmsdaa;z	angmsdab;z	angmsdac;z	angmsdad;z	angmsdae;z	angmsdaf;z	angmsdag;z	angmsdah;zangrt;zangrtvb;z	angrtvbd;zangsph;zangst;zangzarr;zAogon;zaogon;zAopf;zaopf;zap;zapacir;zapE;zape;zapid;zapos;zApplyFunction;zapprox;z	approxeq;rmr�zAring;zaring;zAscr;zascr;zAssign;zast;zasymp;zasympeq;rnr�zAtilde;zatilde;ror�zAuml;zauml;z	awconint;zawint;z	backcong;zbackepsilon;z
backprime;zbacksim;z
backsimeq;z
Backslash;zBarv;zbarvee;zBarwed;zbarwed;z	barwedge;zbbrk;z	bbrktbrk;zbcong;zBcy;zbcy;zbdquo;zbecaus;zBecause;zbecause;zbemptyv;zbepsi;zbernou;zBernoullis;zBeta;zbeta;zbeth;zbetween;zBfr;zbfr;zbigcap;zbigcirc;zbigcup;zbigodot;z	bigoplus;z
bigotimes;z	bigsqcup;zbigstar;zbigtriangledown;zbigtriangleup;z	biguplus;zbigvee;z	bigwedge;zbkarow;z
blacklozenge;zblacksquare;zblacktriangle;zblacktriangledown;zblacktriangleleft;zblacktriangleright;zblank;zblk12;zblk14;zblk34;zblock;zbne;zbnequiv;zbNot;zbnot;zBopf;zbopf;zbot;zbottom;zbowtie;zboxbox;zboxDL;zboxDl;zboxdL;zboxdl;zboxDR;zboxDr;zboxdR;zboxdr;zboxH;zboxh;zboxHD;zboxHd;zboxhD;zboxhd;zboxHU;zboxHu;zboxhU;zboxhu;z	boxminus;zboxplus;z	boxtimes;zboxUL;zboxUl;zboxuL;zboxul;zboxUR;zboxUr;zboxuR;zboxur;zboxV;zboxv;zboxVH;zboxVh;zboxvH;zboxvh;zboxVL;zboxVl;zboxvL;zboxvl;zboxVR;zboxVr;zboxvR;zboxvr;zbprime;zBreve;zbreve;r�zbrvbar;zBscr;zbscr;zbsemi;zbsim;zbsime;zbsol;zbsolb;z	bsolhsub;zbull;zbullet;zbump;zbumpE;zbumpe;zBumpeq;zbumpeq;zCacute;zcacute;zCap;zcap;zcapand;z	capbrcup;zcapcap;zcapcup;zcapdot;zCapitalDifferentialD;zcaps;zcaret;zcaron;zCayleys;zccaps;zCcaron;zccaron;rpr�zCcedil;zccedil;zCcirc;zccirc;zCconint;zccups;zccupssm;zCdot;zcdot;r�zcedil;zCedilla;zcemptyv;r�zcent;z
CenterDot;z
centerdot;zCfr;zcfr;zCHcy;zchcy;zcheck;z
checkmark;zChi;zchi;zcir;zcirc;zcirceq;zcirclearrowleft;zcirclearrowright;zcircledast;zcircledcirc;zcircleddash;z
CircleDot;z	circledR;z	circledS;zCircleMinus;zCirclePlus;zCircleTimes;zcirE;zcire;z	cirfnint;zcirmid;zcirscir;zClockwiseContourIntegral;zCloseCurlyDoubleQuote;zCloseCurlyQuote;zclubs;z	clubsuit;zColon;zcolon;zColone;zcolone;zcoloneq;zcomma;zcommat;zcomp;zcompfn;zcomplement;z
complexes;zcong;zcongdot;z
Congruent;zConint;zconint;zContourIntegral;zCopf;zcopf;zcoprod;z
Coproduct;ZCOPYr�zCOPY;zcopy;zcopysr;z CounterClockwiseContourIntegral;zcrarr;zCross;zcross;zCscr;zcscr;zcsub;zcsube;zcsup;zcsupe;zctdot;zcudarrl;zcudarrr;zcuepr;zcuesc;zcularr;zcularrp;zCup;zcup;z	cupbrcap;zCupCap;zcupcap;zcupcup;zcupdot;zcupor;zcups;zcurarr;zcurarrm;zcurlyeqprec;zcurlyeqsucc;z	curlyvee;zcurlywedge;r�zcurren;zcurvearrowleft;zcurvearrowright;zcuvee;zcuwed;z	cwconint;zcwint;zcylcty;zDagger;zdagger;zdaleth;zDarr;zdArr;zdarr;zdash;zDashv;zdashv;zdbkarow;zdblac;zDcaron;zdcaron;zDcy;zdcy;zDD;zdd;zddagger;zddarr;z	DDotrahd;zddotseq;r�zdeg;zDel;zDelta;zdelta;zdemptyv;zdfisht;zDfr;zdfr;zdHar;zdharl;zdharr;zDiacriticalAcute;zDiacriticalDot;zDiacriticalDoubleAcute;zDiacriticalGrave;zDiacriticalTilde;zdiam;zDiamond;zdiamond;zdiamondsuit;zdiams;zdie;zDifferentialD;zdigamma;zdisin;zdiv;r�zdivide;zdivideontimes;zdivonx;zDJcy;zdjcy;zdlcorn;zdlcrop;zdollar;zDopf;zdopf;zDot;zdot;zDotDot;zdoteq;z	doteqdot;z	DotEqual;z	dotminus;zdotplus;z
dotsquare;zdoublebarwedge;zDoubleContourIntegral;z
DoubleDot;zDoubleDownArrow;zDoubleLeftArrow;zDoubleLeftRightArrow;zDoubleLeftTee;zDoubleLongLeftArrow;zDoubleLongLeftRightArrow;zDoubleLongRightArrow;zDoubleRightArrow;zDoubleRightTee;zDoubleUpArrow;zDoubleUpDownArrow;zDoubleVerticalBar;z
DownArrow;z
Downarrow;z
downarrow;z
DownArrowBar;zDownArrowUpArrow;z
DownBreve;zdowndownarrows;zdownharpoonleft;zdownharpoonright;zDownLeftRightVector;zDownLeftTeeVector;zDownLeftVector;zDownLeftVectorBar;zDownRightTeeVector;zDownRightVector;zDownRightVectorBar;zDownTee;z
DownTeeArrow;z	drbkarow;zdrcorn;zdrcrop;zDscr;zdscr;zDScy;zdscy;zdsol;zDstrok;zdstrok;zdtdot;zdtri;zdtrif;zduarr;zduhar;zdwangle;zDZcy;zdzcy;z	dzigrarr;rrr�zEacute;zeacute;zeaster;zEcaron;zecaron;zecir;rsr�zEcirc;zecirc;zecolon;zEcy;zecy;zeDDot;zEdot;zeDot;zedot;zee;zefDot;zEfr;zefr;zeg;rtr�zEgrave;zegrave;zegs;zegsdot;zel;zElement;z	elinters;zell;zels;zelsdot;zEmacr;zemacr;zempty;z	emptyset;zEmptySmallSquare;zemptyv;zEmptyVerySmallSquare;zemsp13;zemsp14;zemsp;zENG;zeng;zensp;zEogon;zeogon;zEopf;zeopf;zepar;zeparsl;zeplus;zepsi;zEpsilon;zepsilon;zepsiv;zeqcirc;zeqcolon;zeqsim;zeqslantgtr;zeqslantless;zEqual;zequals;zEqualTilde;zequest;zEquilibrium;zequiv;zequivDD;z	eqvparsl;zerarr;zerDot;zEscr;zescr;zesdot;zEsim;zesim;zEta;zeta;rqr�zETH;zeth;rur�zEuml;zeuml;zeuro;zexcl;zexist;zExists;zexpectation;z
ExponentialE;z
exponentiale;zfallingdotseq;zFcy;zfcy;zfemale;zffilig;zfflig;zffllig;zFfr;zffr;zfilig;zFilledSmallSquare;zFilledVerySmallSquare;zfjlig;zflat;zfllig;zfltns;zfnof;zFopf;zfopf;zForAll;zforall;zfork;zforkv;zFouriertrf;z	fpartint;r�zfrac12;zfrac13;r�zfrac14;zfrac15;zfrac16;zfrac18;zfrac23;zfrac25;r�zfrac34;zfrac35;zfrac38;zfrac45;zfrac56;zfrac58;zfrac78;zfrasl;zfrown;zFscr;zfscr;zgacute;zGamma;zgamma;zGammad;zgammad;zgap;zGbreve;zgbreve;zGcedil;zGcirc;zgcirc;zGcy;zgcy;zGdot;zgdot;zgE;zge;zgEl;zgel;zgeq;zgeqq;z	geqslant;zges;zgescc;zgesdot;zgesdoto;z	gesdotol;zgesl;zgesles;zGfr;zgfr;zGg;zgg;zggg;zgimel;zGJcy;zgjcy;zgl;zgla;zglE;zglj;zgnap;z	gnapprox;zgnE;zgne;zgneq;zgneqq;zgnsim;zGopf;zgopf;zgrave;z
GreaterEqual;zGreaterEqualLess;zGreaterFullEqual;zGreaterGreater;zGreaterLess;zGreaterSlantEqual;z
GreaterTilde;zGscr;zgscr;zgsim;zgsime;zgsiml;ZGTr�zGT;zGt;zgt;zgtcc;zgtcir;zgtdot;zgtlPar;zgtquest;z
gtrapprox;zgtrarr;zgtrdot;z
gtreqless;zgtreqqless;zgtrless;zgtrsim;z
gvertneqq;zgvnE;zHacek;zhairsp;zhalf;zhamilt;zHARDcy;zhardcy;zhArr;zharr;zharrcir;zharrw;zHat;zhbar;zHcirc;zhcirc;zhearts;z
heartsuit;zhellip;zhercon;zHfr;zhfr;z
HilbertSpace;z	hksearow;z	hkswarow;zhoarr;zhomtht;zhookleftarrow;zhookrightarrow;zHopf;zhopf;zhorbar;zHorizontalLine;zHscr;zhscr;zhslash;zHstrok;zhstrok;z
HumpDownHump;z
HumpEqual;zhybull;zhyphen;rvr�zIacute;ziacute;zic;rwr�zIcirc;zicirc;zIcy;zicy;zIdot;zIEcy;ziecy;r�ziexcl;ziff;zIfr;zifr;rxr�zIgrave;zigrave;zii;ziiiint;ziiint;ziinfin;ziiota;zIJlig;zijlig;zIm;zImacr;zimacr;zimage;zImaginaryI;z	imagline;z	imagpart;zimath;zimof;zimped;zImplies;zin;zincare;zinfin;z	infintie;zinodot;zInt;zint;zintcal;z	integers;z	Integral;z	intercal;z
Intersection;z	intlarhk;zintprod;zInvisibleComma;zInvisibleTimes;zIOcy;ziocy;zIogon;ziogon;zIopf;ziopf;zIota;ziota;ziprod;r�ziquest;zIscr;ziscr;zisin;zisindot;zisinE;zisins;zisinsv;zisinv;zit;zItilde;zitilde;zIukcy;ziukcy;ryr�zIuml;ziuml;zJcirc;zjcirc;zJcy;zjcy;zJfr;zjfr;zjmath;zJopf;zjopf;zJscr;zjscr;zJsercy;zjsercy;zJukcy;zjukcy;zKappa;zkappa;zkappav;zKcedil;zkcedil;zKcy;zkcy;zKfr;zkfr;zkgreen;zKHcy;zkhcy;zKJcy;zkjcy;zKopf;zkopf;zKscr;zkscr;zlAarr;zLacute;zlacute;z	laemptyv;zlagran;zLambda;zlambda;zLang;zlang;zlangd;zlangle;zlap;zLaplacetrf;r�zlaquo;zLarr;zlArr;zlarr;zlarrb;zlarrbfs;zlarrfs;zlarrhk;zlarrlp;zlarrpl;zlarrsim;zlarrtl;zlat;zlAtail;zlatail;zlate;zlates;zlBarr;zlbarr;zlbbrk;zlbrace;zlbrack;zlbrke;zlbrksld;zlbrkslu;zLcaron;zlcaron;zLcedil;zlcedil;zlceil;zlcub;zLcy;zlcy;zldca;zldquo;zldquor;zldrdhar;z	ldrushar;zldsh;zlE;zle;zLeftAngleBracket;z
LeftArrow;z
Leftarrow;z
leftarrow;z
LeftArrowBar;zLeftArrowRightArrow;zleftarrowtail;zLeftCeiling;zLeftDoubleBracket;zLeftDownTeeVector;zLeftDownVector;zLeftDownVectorBar;z
LeftFloor;zleftharpoondown;zleftharpoonup;zleftleftarrows;zLeftRightArrow;zLeftrightarrow;zleftrightarrow;zleftrightarrows;zleftrightharpoons;zleftrightsquigarrow;zLeftRightVector;zLeftTee;z
LeftTeeArrow;zLeftTeeVector;zleftthreetimes;z
LeftTriangle;zLeftTriangleBar;zLeftTriangleEqual;zLeftUpDownVector;zLeftUpTeeVector;z
LeftUpVector;zLeftUpVectorBar;zLeftVector;zLeftVectorBar;zlEg;zleg;zleq;zleqq;z	leqslant;zles;zlescc;zlesdot;zlesdoto;z	lesdotor;zlesg;zlesges;zlessapprox;zlessdot;z
lesseqgtr;zlesseqqgtr;zLessEqualGreater;zLessFullEqual;zLessGreater;zlessgtr;z	LessLess;zlesssim;zLessSlantEqual;z
LessTilde;zlfisht;zlfloor;zLfr;zlfr;zlg;zlgE;zlHar;zlhard;zlharu;zlharul;zlhblk;zLJcy;zljcy;zLl;zll;zllarr;z	llcorner;zLleftarrow;zllhard;zlltri;zLmidot;zlmidot;zlmoust;zlmoustache;zlnap;z	lnapprox;zlnE;zlne;zlneq;zlneqq;zlnsim;zloang;zloarr;zlobrk;zLongLeftArrow;zLongleftarrow;zlongleftarrow;zLongLeftRightArrow;zLongleftrightarrow;zlongleftrightarrow;zlongmapsto;zLongRightArrow;zLongrightarrow;zlongrightarrow;zlooparrowleft;zlooparrowright;zlopar;zLopf;zlopf;zloplus;zlotimes;zlowast;zlowbar;zLowerLeftArrow;zLowerRightArrow;zloz;zlozenge;zlozf;zlpar;zlparlt;zlrarr;z	lrcorner;zlrhar;zlrhard;zlrm;zlrtri;zlsaquo;zLscr;zlscr;zLsh;zlsh;zlsim;zlsime;zlsimg;zlsqb;zlsquo;zlsquor;zLstrok;zlstrok;ZLTr�zLT;zLt;zlt;zltcc;zltcir;zltdot;zlthree;zltimes;zltlarr;zltquest;zltri;zltrie;zltrif;zltrPar;z	lurdshar;zluruhar;z
lvertneqq;zlvnE;r�zmacr;zmale;zmalt;zmaltese;zMap;zmap;zmapsto;zmapstodown;zmapstoleft;z	mapstoup;zmarker;zmcomma;zMcy;zmcy;zmdash;zmDDot;zmeasuredangle;zMediumSpace;z
Mellintrf;zMfr;zmfr;zmho;r�zmicro;zmid;zmidast;zmidcir;r�zmiddot;zminus;zminusb;zminusd;zminusdu;z
MinusPlus;zmlcp;zmldr;zmnplus;zmodels;zMopf;zmopf;zmp;zMscr;zmscr;zmstpos;zMu;zmu;z	multimap;zmumap;znabla;zNacute;znacute;znang;znap;znapE;znapid;znapos;znapprox;znatur;znatural;z	naturals;r�znbsp;znbump;znbumpe;zncap;zNcaron;zncaron;zNcedil;zncedil;zncong;z	ncongdot;zncup;zNcy;zncy;zndash;zne;znearhk;zneArr;znearr;znearrow;znedot;zNegativeMediumSpace;zNegativeThickSpace;zNegativeThinSpace;zNegativeVeryThinSpace;znequiv;znesear;znesim;zNestedGreaterGreater;zNestedLessLess;zNewLine;znexist;znexists;zNfr;znfr;zngE;znge;zngeq;zngeqq;z
ngeqslant;znges;znGg;zngsim;znGt;zngt;zngtr;znGtv;znhArr;znharr;znhpar;zni;znis;znisd;zniv;zNJcy;znjcy;znlArr;znlarr;znldr;znlE;znle;znLeftarrow;znleftarrow;znLeftrightarrow;znleftrightarrow;znleq;znleqq;z
nleqslant;znles;znless;znLl;znlsim;znLt;znlt;znltri;znltrie;znLtv;znmid;zNoBreak;zNonBreakingSpace;zNopf;znopf;r�zNot;znot;z
NotCongruent;z
NotCupCap;zNotDoubleVerticalBar;zNotElement;z	NotEqual;zNotEqualTilde;z
NotExists;zNotGreater;zNotGreaterEqual;zNotGreaterFullEqual;zNotGreaterGreater;zNotGreaterLess;zNotGreaterSlantEqual;zNotGreaterTilde;zNotHumpDownHump;z
NotHumpEqual;znotin;z	notindot;znotinE;znotinva;znotinvb;znotinvc;zNotLeftTriangle;zNotLeftTriangleBar;zNotLeftTriangleEqual;zNotLess;z
NotLessEqual;zNotLessGreater;zNotLessLess;zNotLessSlantEqual;z
NotLessTilde;zNotNestedGreaterGreater;zNotNestedLessLess;znotni;znotniva;znotnivb;znotnivc;zNotPrecedes;zNotPrecedesEqual;zNotPrecedesSlantEqual;zNotReverseElement;zNotRightTriangle;zNotRightTriangleBar;zNotRightTriangleEqual;zNotSquareSubset;zNotSquareSubsetEqual;zNotSquareSuperset;zNotSquareSupersetEqual;z
NotSubset;zNotSubsetEqual;zNotSucceeds;zNotSucceedsEqual;zNotSucceedsSlantEqual;zNotSucceedsTilde;zNotSuperset;zNotSupersetEqual;z	NotTilde;zNotTildeEqual;zNotTildeFullEqual;zNotTildeTilde;zNotVerticalBar;znpar;z
nparallel;znparsl;znpart;znpolint;znpr;znprcue;znpre;znprec;znpreceq;znrArr;znrarr;znrarrc;znrarrw;znRightarrow;znrightarrow;znrtri;znrtrie;znsc;znsccue;znsce;zNscr;znscr;z
nshortmid;znshortparallel;znsim;znsime;znsimeq;znsmid;znspar;znsqsube;znsqsupe;znsub;znsubE;znsube;znsubset;z
nsubseteq;znsubseteqq;znsucc;znsucceq;znsup;znsupE;znsupe;znsupset;z
nsupseteq;znsupseteqq;zntgl;rzr�zNtilde;zntilde;zntlg;zntriangleleft;zntrianglelefteq;zntriangleright;zntrianglerighteq;zNu;znu;znum;znumero;znumsp;znvap;znVDash;znVdash;znvDash;znvdash;znvge;znvgt;znvHarr;znvinfin;znvlArr;znvle;znvlt;znvltrie;znvrArr;znvrtrie;znvsim;znwarhk;znwArr;znwarr;znwarrow;znwnear;r{r�zOacute;zoacute;zoast;zocir;r|r�zOcirc;zocirc;zOcy;zocy;zodash;zOdblac;zodblac;zodiv;zodot;zodsold;zOElig;zoelig;zofcir;zOfr;zofr;zogon;r}r�zOgrave;zograve;zogt;zohbar;zohm;zoint;zolarr;zolcir;zolcross;zoline;zolt;zOmacr;zomacr;zOmega;zomega;zOmicron;zomicron;zomid;zominus;zOopf;zoopf;zopar;zOpenCurlyDoubleQuote;zOpenCurlyQuote;zoperp;zoplus;zOr;zor;zorarr;zord;zorder;zorderof;r�zordf;r�zordm;zorigof;zoror;zorslope;zorv;zoS;zOscr;zoscr;r~r�zOslash;zoslash;zosol;rr�zOtilde;zotilde;zOtimes;zotimes;z	otimesas;r�r�zOuml;zouml;zovbar;zOverBar;z
OverBrace;zOverBracket;zOverParenthesis;zpar;r�zpara;z	parallel;zparsim;zparsl;zpart;z	PartialD;zPcy;zpcy;zpercnt;zperiod;zpermil;zperp;zpertenk;zPfr;zpfr;zPhi;zphi;zphiv;zphmmat;zphone;zPi;zpi;z
pitchfork;zpiv;zplanck;zplanckh;zplankv;zplus;z	plusacir;zplusb;zpluscir;zplusdo;zplusdu;zpluse;z
PlusMinus;r�zplusmn;zplussim;zplustwo;zpm;zPoincareplane;z	pointint;zPopf;zpopf;r�zpound;zPr;zpr;zprap;zprcue;zprE;zpre;zprec;zprecapprox;zpreccurlyeq;z	Precedes;zPrecedesEqual;zPrecedesSlantEqual;zPrecedesTilde;zpreceq;zprecnapprox;z	precneqq;z	precnsim;zprecsim;zPrime;zprime;zprimes;zprnap;zprnE;zprnsim;zprod;zProduct;z	profalar;z	profline;z	profsurf;zprop;zProportion;z
Proportional;zpropto;zprsim;zprurel;zPscr;zpscr;zPsi;zpsi;zpuncsp;zQfr;zqfr;zqint;zQopf;zqopf;zqprime;zQscr;zqscr;zquaternions;zquatint;zquest;zquesteq;ZQUOTr�zQUOT;zquot;zrAarr;zrace;zRacute;zracute;zradic;z	raemptyv;zRang;zrang;zrangd;zrange;zrangle;r�zraquo;zRarr;zrArr;zrarr;zrarrap;zrarrb;zrarrbfs;zrarrc;zrarrfs;zrarrhk;zrarrlp;zrarrpl;zrarrsim;zRarrtl;zrarrtl;zrarrw;zrAtail;zratail;zratio;z
rationals;zRBarr;zrBarr;zrbarr;zrbbrk;zrbrace;zrbrack;zrbrke;zrbrksld;zrbrkslu;zRcaron;zrcaron;zRcedil;zrcedil;zrceil;zrcub;zRcy;zrcy;zrdca;zrdldhar;zrdquo;zrdquor;zrdsh;zRe;zreal;zrealine;z	realpart;zreals;zrect;ZREGr�zREG;zreg;zReverseElement;zReverseEquilibrium;zReverseUpEquilibrium;zrfisht;zrfloor;zRfr;zrfr;zrHar;zrhard;zrharu;zrharul;zRho;zrho;zrhov;zRightAngleBracket;zRightArrow;zRightarrow;zrightarrow;zRightArrowBar;zRightArrowLeftArrow;zrightarrowtail;z
RightCeiling;zRightDoubleBracket;zRightDownTeeVector;zRightDownVector;zRightDownVectorBar;zRightFloor;zrightharpoondown;zrightharpoonup;zrightleftarrows;zrightleftharpoons;zrightrightarrows;zrightsquigarrow;z	RightTee;zRightTeeArrow;zRightTeeVector;zrightthreetimes;zRightTriangle;zRightTriangleBar;zRightTriangleEqual;zRightUpDownVector;zRightUpTeeVector;zRightUpVector;zRightUpVectorBar;zRightVector;zRightVectorBar;zring;z
risingdotseq;zrlarr;zrlhar;zrlm;zrmoust;zrmoustache;zrnmid;zroang;zroarr;zrobrk;zropar;zRopf;zropf;zroplus;zrotimes;z
RoundImplies;zrpar;zrpargt;z	rppolint;zrrarr;zRrightarrow;zrsaquo;zRscr;zrscr;zRsh;zrsh;zrsqb;zrsquo;zrsquor;zrthree;zrtimes;zrtri;zrtrie;zrtrif;z	rtriltri;zRuleDelayed;zruluhar;zrx;zSacute;zsacute;zsbquo;zSc;zsc;zscap;zScaron;zscaron;zsccue;zscE;zsce;zScedil;zscedil;zScirc;zscirc;zscnap;zscnE;zscnsim;z	scpolint;zscsim;zScy;zscy;zsdot;zsdotb;zsdote;zsearhk;zseArr;zsearr;zsearrow;r�zsect;zsemi;zseswar;z	setminus;zsetmn;zsext;zSfr;zsfr;zsfrown;zsharp;zSHCHcy;zshchcy;zSHcy;zshcy;zShortDownArrow;zShortLeftArrow;z	shortmid;zshortparallel;zShortRightArrow;z
ShortUpArrow;r�zshy;zSigma;zsigma;zsigmaf;zsigmav;zsim;zsimdot;zsime;zsimeq;zsimg;zsimgE;zsiml;zsimlE;zsimne;zsimplus;zsimrarr;zslarr;zSmallCircle;zsmallsetminus;zsmashp;z	smeparsl;zsmid;zsmile;zsmt;zsmte;zsmtes;zSOFTcy;zsoftcy;zsol;zsolb;zsolbar;zSopf;zsopf;zspades;z
spadesuit;zspar;zsqcap;zsqcaps;zsqcup;zsqcups;zSqrt;zsqsub;zsqsube;z	sqsubset;zsqsubseteq;zsqsup;zsqsupe;z	sqsupset;zsqsupseteq;zsqu;zSquare;zsquare;zSquareIntersection;z
SquareSubset;zSquareSubsetEqual;zSquareSuperset;zSquareSupersetEqual;zSquareUnion;zsquarf;zsquf;zsrarr;zSscr;zsscr;zssetmn;zssmile;zsstarf;zStar;zstar;zstarf;zstraightepsilon;zstraightphi;zstrns;zSub;zsub;zsubdot;zsubE;zsube;zsubedot;zsubmult;zsubnE;zsubne;zsubplus;zsubrarr;zSubset;zsubset;z	subseteq;z
subseteqq;zSubsetEqual;z
subsetneq;zsubsetneqq;zsubsim;zsubsub;zsubsup;zsucc;zsuccapprox;zsucccurlyeq;z	Succeeds;zSucceedsEqual;zSucceedsSlantEqual;zSucceedsTilde;zsucceq;zsuccnapprox;z	succneqq;z	succnsim;zsuccsim;z	SuchThat;zSum;zsum;zsung;r�zsup1;r�zsup2;r�zsup3;zSup;zsup;zsupdot;zsupdsub;zsupE;zsupe;zsupedot;z	Superset;zSupersetEqual;zsuphsol;zsuphsub;zsuplarr;zsupmult;zsupnE;zsupne;zsupplus;zSupset;zsupset;z	supseteq;z
supseteqq;z
supsetneq;zsupsetneqq;zsupsim;zsupsub;zsupsup;zswarhk;zswArr;zswarr;zswarrow;zswnwar;r�zszlig;zTab;ztarget;zTau;ztau;ztbrk;zTcaron;ztcaron;zTcedil;ztcedil;zTcy;ztcy;ztdot;ztelrec;zTfr;ztfr;zthere4;z
Therefore;z
therefore;zTheta;ztheta;z	thetasym;zthetav;zthickapprox;z	thicksim;zThickSpace;zthinsp;z
ThinSpace;zthkap;zthksim;r�r�zTHORN;zthorn;zTilde;ztilde;zTildeEqual;zTildeFullEqual;zTildeTilde;r�ztimes;ztimesb;z	timesbar;ztimesd;ztint;ztoea;ztop;ztopbot;ztopcir;zTopf;ztopf;ztopfork;ztosa;ztprime;zTRADE;ztrade;z	triangle;z
triangledown;z
triangleleft;ztrianglelefteq;z
triangleq;ztriangleright;ztrianglerighteq;ztridot;ztrie;z	triminus;z
TripleDot;ztriplus;ztrisb;ztritime;z	trpezium;zTscr;ztscr;zTScy;ztscy;zTSHcy;ztshcy;zTstrok;ztstrok;ztwixt;ztwoheadleftarrow;ztwoheadrightarrow;r�r�zUacute;zuacute;zUarr;zuArr;zuarr;z	Uarrocir;zUbrcy;zubrcy;zUbreve;zubreve;r�r�zUcirc;zucirc;zUcy;zucy;zudarr;zUdblac;zudblac;zudhar;zufisht;zUfr;zufr;r�r�zUgrave;zugrave;zuHar;zuharl;zuharr;zuhblk;zulcorn;z	ulcorner;zulcrop;zultri;zUmacr;zumacr;r�zuml;z	UnderBar;zUnderBrace;z
UnderBracket;zUnderParenthesis;zUnion;z
UnionPlus;zUogon;zuogon;zUopf;zuopf;zUpArrow;zUparrow;zuparrow;zUpArrowBar;zUpArrowDownArrow;zUpDownArrow;zUpdownarrow;zupdownarrow;zUpEquilibrium;zupharpoonleft;zupharpoonright;zuplus;zUpperLeftArrow;zUpperRightArrow;zUpsi;zupsi;zupsih;zUpsilon;zupsilon;zUpTee;zUpTeeArrow;zupuparrows;zurcorn;z	urcorner;zurcrop;zUring;zuring;zurtri;zUscr;zuscr;zutdot;zUtilde;zutilde;zutri;zutrif;zuuarr;r�r�zUuml;zuuml;zuwangle;zvangrt;zvarepsilon;z	varkappa;zvarnothing;zvarphi;zvarpi;z
varpropto;zvArr;zvarr;zvarrho;z	varsigma;z
varsubsetneq;zvarsubsetneqq;z
varsupsetneq;zvarsupsetneqq;z	vartheta;zvartriangleleft;zvartriangleright;zVbar;zvBar;zvBarv;zVcy;zvcy;zVDash;zVdash;zvDash;zvdash;zVdashl;zVee;zvee;zveebar;zveeeq;zvellip;zVerbar;zverbar;zVert;zvert;zVerticalBar;z
VerticalLine;zVerticalSeparator;zVerticalTilde;zVeryThinSpace;zVfr;zvfr;zvltri;zvnsub;zvnsup;zVopf;zvopf;zvprop;zvrtri;zVscr;zvscr;zvsubnE;zvsubne;zvsupnE;zvsupne;zVvdash;zvzigzag;zWcirc;zwcirc;zwedbar;zWedge;zwedge;zwedgeq;zweierp;zWfr;zwfr;zWopf;zwopf;zwp;zwr;zwreath;zWscr;zwscr;zxcap;zxcirc;zxcup;zxdtri;zXfr;zxfr;zxhArr;zxharr;zXi;zxi;zxlArr;zxlarr;zxmap;zxnis;zxodot;zXopf;zxopf;zxoplus;zxotime;zxrArr;zxrarr;zXscr;zxscr;zxsqcup;zxuplus;zxutri;zxvee;zxwedge;r�r�zYacute;zyacute;zYAcy;zyacy;zYcirc;zycirc;zYcy;zycy;r�zyen;zYfr;zyfr;zYIcy;zyicy;zYopf;zyopf;zYscr;zyscr;zYUcy;zyucy;r�zYuml;zyuml;zZacute;zzacute;zZcaron;zzcaron;zZcy;zzcy;zZdot;zzdot;zzeetrf;zZeroWidthSpace;zZeta;zzeta;zZfr;zzfr;zZHcy;zzhcy;zzigrarr;zZopf;zzopf;zZscr;zzscr;zzwj;zzwnj;N)
�__doc__�__all__rrrr�items�nameZ	codepoint�chr�r`r`�%/usr/lib64/python3.6/html/entities.py�<module>stPK��\�˫Q__parser.cpython-36.opt-1.pycnu�[���3


 \��@s�dZddddddgZddlmZmZdd	lmZmZdd
lm	Z	Gdd�d�Z
Gdd�de
�ZGd
d�d�ZGdd�de�Z
dS)z-A parser of RFC 2822 and MIME email messages.�Parser�HeaderParser�BytesParser�BytesHeaderParser�
FeedParser�BytesFeedParser�)�StringIO�
TextIOWrapper)rr)�compat32c@s0eZdZd
ed�dd�Zddd�Zddd	�ZdS)
rN)�policycCs||_||_dS)a�Parser of RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The string must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the string or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        N)�_classr)�selfrr�r�$/usr/lib64/python3.6/email/parser.py�__init__szParser.__init__FcCsDt|j|jd�}|r|j�x|jd�}|s.P|j|�qW|j�S)a\Create a message structure from the data in a file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        )ri )rrrZ_set_headersonly�readZfeed�close)r
�fp�headersonlyZ
feedparser�datarrr�parse*s
zParser.parsecCs|jt|�|d�S)a-Create a message structure from a string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        )r)rr)r
�textrrrr�parsestr<szParser.parsestr)N)F)F)�__name__�
__module__�__qualname__r
rrrrrrrrs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||d�S)NT)rr)r
rrrrrrIszHeaderParser.parsecCstj||d�S)NT)rr)r
rrrrrrLszHeaderParser.parsestrN)T)T)rrrrrrrrrrHs
c@s(eZdZdd�Zd	dd�Zd
dd�ZdS)rcOst||�|_dS)a�Parser of binary RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The input must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the input or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.
        N)r�parser)r
�args�kwrrrrRszBytesParser.__init__Fc
Cs,t|ddd�}z|jj||�S|j�XdS)acCreate a message structure from the data in a binary file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        �ascii�surrogateescape)�encoding�errorsN)r	rr�detach)r
rrrrrrdszBytesParser.parsecCs|jddd�}|jj||�S)a2Create a message structure from a byte string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        �ASCIIr )r")�decoderr)r
rrrrr�
parsebytessszBytesParser.parsebytesN)F)F)rrrrrr&rrrrrPs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||dd�S)NT)r)rr)r
rrrrrr�szBytesHeaderParser.parsecCstj||dd�S)NT)r)rr&)r
rrrrrr&�szBytesHeaderParser.parsebytesN)T)T)rrrrr&rrrrrs
N)�__doc__�__all__�iorr	Zemail.feedparserrrZemail._policybaser
rrrrrrrr�<module>s7/PK��\�˫Q__parser.cpython-36.pycnu�[���3


 \��@s�dZddddddgZddlmZmZdd	lmZmZdd
lm	Z	Gdd�d�Z
Gdd�de
�ZGd
d�d�ZGdd�de�Z
dS)z-A parser of RFC 2822 and MIME email messages.�Parser�HeaderParser�BytesParser�BytesHeaderParser�
FeedParser�BytesFeedParser�)�StringIO�
TextIOWrapper)rr)�compat32c@s0eZdZd
ed�dd�Zddd�Zddd	�ZdS)
rN)�policycCs||_||_dS)a�Parser of RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The string must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the string or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        N)�_classr)�selfrr�r�$/usr/lib64/python3.6/email/parser.py�__init__szParser.__init__FcCsDt|j|jd�}|r|j�x|jd�}|s.P|j|�qW|j�S)a\Create a message structure from the data in a file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        )ri )rrrZ_set_headersonly�readZfeed�close)r
�fp�headersonlyZ
feedparser�datarrr�parse*s
zParser.parsecCs|jt|�|d�S)a-Create a message structure from a string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        )r)rr)r
�textrrrr�parsestr<szParser.parsestr)N)F)F)�__name__�
__module__�__qualname__r
rrrrrrrrs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||d�S)NT)rr)r
rrrrrrIszHeaderParser.parsecCstj||d�S)NT)rr)r
rrrrrrLszHeaderParser.parsestrN)T)T)rrrrrrrrrrHs
c@s(eZdZdd�Zd	dd�Zd
dd�ZdS)rcOst||�|_dS)a�Parser of binary RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The input must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceded by a `Unix-from' header.  The
        header block is terminated either by the end of the input or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.
        N)r�parser)r
�args�kwrrrrRszBytesParser.__init__Fc
Cs,t|ddd�}z|jj||�S|j�XdS)acCreate a message structure from the data in a binary file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        �ascii�surrogateescape)�encoding�errorsN)r	rr�detach)r
rrrrrrdszBytesParser.parsecCs|jddd�}|jj||�S)a2Create a message structure from a byte string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        �ASCIIr )r")�decoderr)r
rrrrr�
parsebytessszBytesParser.parsebytesN)F)F)rrrrrr&rrrrrPs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||dd�S)NT)r)rr)r
rrrrrr�szBytesHeaderParser.parsecCstj||dd�S)NT)r)rr&)r
rrrrrr&�szBytesHeaderParser.parsebytesN)T)T)rrrrr&rrrrrs
N)�__doc__�__all__�iorr	Zemail.feedparserrrZemail._policybaser
rrrrrrrr�<module>s7/PK��\�x�D����entities.cpython-36.opt-2.pycnu�[���3


 \3&��@s0%ddddgZdddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��d��Z�d�d�d�d�d�d�d�d�d�d�d	�d�d	�d
�d
�d�d�d
�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d!�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d9�d:�d;�d�d6�d9�d0�d<�d0�d<�d=�d>�d?�d@�d6�dA�dB�dC�dB�dC�dD�dE�dD�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dN�dO�dP�dQ�dQ�dR�dS�dH�dT�dU�dV�dW�dW�dW�dX�dI�dY�dY�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�de�df�dg�dh�di�dj�dk�dl�dm�dn�do�dp�dq�dr�ds�dt�du�dv�dw�dx�dy�dz�d{�d|�d}�d~�d�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dJ�d��d��d��d��dY�d��d��dK�dL�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdҐdҐdӐdԐdԐdՐdՐdŐd֐dאdؐdِdِdڐdېdܐdݐdސdߐd�d�d�d�d�d�d�d�d�d�d�dސd�d�d�d�d�d�d�d�d�d�d�d?�d?�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d�d�d�d�d�d�d�dF�d�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d�d�dA�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d��d1�d"�d2�d3�d4�d5�d5�d6�d7�d8�d9�d:�d;�d<�d=�d>�d?�d
�d@�d,�dA�dB�dC�dC�dC�dD�dD�dE�d1�dF�dG�dH�dH�dH�dI�dI�dJ�dK�dL�dM�dN�dO�dP�dE�d@�dQ�dR�dS�dR�dT�dU�dV�dP�d��dE�d&�dW�dX�d)�dY�dZ�d[�d\�d]�d^�d_�d`�d'�d&�d'�da�db�dc�d2�d>�d?�dd�de�df�dg�dh�di�dj�dk�dl�dm�dn�do�dp�dq�dr�ds�dt�du�dv�dw�dx�dq�db�dy�dz�d{�d|�d}�d~�d�d~�d�d��d��d��d��d��d��d��d��d��d��d��d4�d��dS�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dR�d��d��d��d��d��d��d��d��d��d��d��d��d��ddÐdÐd��d��d��d��dĐdŐdƐdǐdȐdɐdʐdːd̐d͐do�dΐdϐdАdѐdҐdӐdԐdՐdՐd֐dאdؐdِdڐdڐdېdܐdܐdݐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�dؐd�d�d�d�d�dF�d�d�d�d�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d�d�d�d�d�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d�d�d�d�d�dA�d��d��d��d�d�d��d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d�d"�d�d��d��d�d�d#�d#�dĐd$�dڐd%�d&�d'�dX�d(�d)�d*�d+�d,�d-�d.�d/�d/�d0�d1�d2�d3�d%�d4�d5�d6�d7�d8�d9�d:�d;�d<�d��d%�d=�d,�d>�d?�d��d��d@�d(�dA�dB�dA�dB�dC�dD�dE�dD�dE�dF�dG�dH�dI�dJ�dK�dK�dX�dL�dM�dN�dO�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dL�dW�dX�dL�dP�dY�dL�dZ�d[�d\�d\�d��d]�d^�d_�dZ�d`�da�db�dc�da�db�d`�dd�de�dC�df�dg�dh�di�dj�dk�dl�dm�dn�de�do�do�dY�dp�d��dq�dr�ds�dt�d��df�du�dv�dw�dx�dy�dz�dy�dz�d{�d|�d}�d~�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dW�d��d��d��d��d8�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dd��dÐdĐdŐdƐdV�dǐdȐdɐdʐdːd��d��dW�d��d��d̐d��dd͐dΐd>�dϐdАdf�dѐdҐd(�dX�d(�d̐dӐd*�dԐd*�dՐd֐dאdؐdِdڐdېdܐdݐdސdѐdߐd�d�dːdʐd�d�d�d�d�d�d�d�d��d�d�d�d�dʐd�d�d�d�d�d�d�dАd�d�d�d�d�df�dѐd�d�d�d��d��d��dҐdL�d��d��d��d��d��d��d��d��d��d��d��d��d��d�d�d�d͐d�dY�d�d�dZ�d�d�d�d[�d�d��d�d�d	�d
�d�d�d
�d�d�d�d�d�dn�d�d�d̐dn�dӐd�d�d�d�d��d�d�d�d�d�d�d��d�d�d�d�d �d �d �d��d �d!�d"�d�dאd#�d$�d%�d&�dڐdr�d'�d(�d)�d*�d*�d+�d+�d,�d-�d-�d.�d/�d/�dl�dՐd0�d1�d2�d3�d4�d5�d6�d#�d7�d8�d9�d:�d;�d<�d<�d=�d@�d>�dՐdՐd?�d��dT�d@�dA�dB�d0�dA�dC�dD�dE�dA�d8�dF�d�dG�dH�dI�dI�d6�dJ�dK�dL�dM�dN�dO�dP�dM�dQ�dQ�dR�dS�dS�dT�dU�dV�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�dd�de�df�df�df�df�dg�dh�di�d�d��dj�dk�dk�dl�dm�dn�do�do�dn�dp�dp�dq�dr�ds�dt�dt�du�dv�dw�dx�dy�dz�d{�dy�d|�d}�d~�d�d��d��d��d~�d�dv�dw�d��d��d��d��d��d��d��d��d��d��d��d��d��d��dS�dR�d��d��d��d��dg�d��d��d��da�di�dk�dt�do�dn�du�d��dp�dr�dT�dU�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d[�dM�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdԐdՐd֐dאdؐdِdِdڐdېdܐdېdܐd�d�dݐdސdݐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��dߐd�d�d�d�d�d��d�d��d��d��d��d�d��d��d��dƐd�d��d�d��d��d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d	�d
�d	�d
�d�d�d
�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d`�d�d�d`�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d$�d8�d%�d&�d'�d֐d(�d,�d)�d,�d*�d+�d��d,�dU�d-�d.�d/�d/�d/�d0�d1�d/�d2�d2�d3�d4�d5�d5�d6�d7�d8�d9�d:�d;�d7�d8�d9�d7�d;�d9�d<�d;�d=�d>�d?�d<�d@�dA�d3�d=�d>�d?�dB�dB�dC�dD�dE�dF�d�dF�dF�d<�dG�dH�dI�dJ�dK�dL�dM�dN�dQ�dO�dP�dQ�dR�dS�d:�dT�dU�d��dV�dV�dV�dV�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�d^�da�da�db�d\�dc�dd�de�df�dg�dh�d9�d�di�dj�dk�dl�dm�dn�do�dp�dO�dm�d+�dm�dq�dr�ds�dt�du�dv�dw�dx�dy�dz�d{�dr�d|�d}�d~�d�d�d�d��d��d��d��d��d��d��d�d�d�d�dy�dӐdy�d��d��d��d��d��di�d��d��d��d��d��d^�dc�d\�dc�de�d��dl�d{�d��d��d?�d��d��di�d��d��d��d��dm�d��d/�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dW�d��d��d��d��d��ds�d�d�d��d��d��d��ds�d��d��d��d��d��d��d�d��d��d��d��d��d��d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdV�dːd4�d̐d�d�d͐d͐dΐdϐdM�dM�dАdѐdҐd�dӐdԐdՐd֐dאd'�d��d=�d`�dc�dؐdِdِdڐdېdܐdܐdݐdސdߐdߐd�d�d�d�d�d�d�d��d��dM�d�d�d=�d�d�d�d�d�d�d�d�d�d�d�d�d�d`�d��d��d��d��d[�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��do�do�dc�d��d��dM�d�d�d�d�dg�d��d$�d+�d�d�d�d�d�d�d�d	�d
�d�d�d�d�d�d�d�d
�d	�d
�d�d�d��d��d��d��d��d��dǐd��dÐdĐdŐdǐdy�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d�d�d�d�d!�d �d#�d$�d%�d5�d&�d�d�d'�d(�d(�d)�d*�d+�d,�d�d-�d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d7�d7�d8�d9�d:�d:�d6�dݐd;�d<�d<�d6�dݐd=�d>�d=�d>�dݐdB�dߐd��d6�d?�d?�d��d@�dA�dR�dh�dk�dB�dC�dD�dE�dF�dϐdG�dH�dH�dI�dx�d&�dڐdJ�d��d��dK�dJ�dL�d3�dM�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dX�d]�d��db�dY�dZ�dY�dZ�d[�d^�dؐd\�d]�d^�d_�d`�da�db�da�db�dc�dd�de�df�dg�dh�di�dj�dk�dl�dm�dl�dm�dn�dݐd��do�dp�dp�dq�dr�ds�dt�dE�dE�d�du�dR�dv�db�dw�dx�dy�dz�d{�dؐd^�dؐd|�de�d}�d_�d}�dh�dݐd��dw�dِdd�d~�d�d~�d��d�d�d0�d��d��d��d��d��d��d��d��d��d��d��d��dI�dp�d��d��d��d��d��d��d��d��d��d��d$�d(�dF�d_�d}�d��dܐd��d��d��d��d:�dؐd��d��d��d��d��d��d��d��d]�d��d��dk�d��d��d��d��d��d��d��d��d=�d��d��d��d$�d��d��dؐd��d��d��d��dF�d��d��d��d��d��d��d��d��d��d��d��d��dl�d�d��d��d��d��d��d��d��d��d��d��d��d`�da�db�dh�d��d��dZ�d�d��d��dY�d�d�d��dc�d��d��dd�de�d[�d�d��d��df�dj�di�dk�dl�d��d��d��d��d��ddÐdĐdŐdƐdǐdǐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdҐdԐdՐd֐dאdؐdِdڐdېdܐdf�dݐdސdܐdߐd�d�d�dc�d�d�d�d�d�d���ZiZiZx*ej�D]\ZZeee<ee�ee<�%qW[[�d�S(��html5�name2codepoint�codepoint2name�
entitydefs������i�������i���i�i! i���������i�i���i�������i���i�i�i���i�iR������i�i�������i�i�i3 i�i�i`i���i�i�������i���i���ixi����������i5!i��&i'"i "��iH"����i i��i" i)"����i�i�ic&iE"�i�!i*"�i�!i  i�!�i�if&�������i"i i i�ia"i�����i� i"i�i"���iD i�ie"�>i�!i�!ie&i& �������i!i"i+"i��i"��i�i�!i�i)#�i�!i#i id"i
#i"i�%i i9 i �<�i ��i"i�i"�i i`"i"�i	"i�"��i�����iS��i> i�i�i�"i("����i�"��i"i0 i�"i�i�i���i2 i"i"i��"i�!i"i*#�i�!i	#i i!�i#i�i i: i i iai�"��i�i�i<"i`&i�"i�"i"i�"���i�"��i�i4"i�i�i	 �i���i"!i�!�i�!���i�i��i!i����i�i
 i )��AElig�Aacute�Acirc�AgraveZAlpha�Aring�Atilde�AumlZBeta�CcedilZChiZDaggerZDelta�ETH�Eacute�Ecirc�EgraveZEpsilonZEta�EumlZGamma�Iacute�Icirc�IgraveZIota�IumlZKappaZLambdaZMu�NtildeZNuZOElig�Oacute�Ocirc�OgraveZOmegaZOmicron�Oslash�Otilde�OumlZPhiZPiZPrimeZPsiZRhoZScaronZSigma�THORNZTauZTheta�Uacute�Ucirc�UgraveZUpsilon�UumlZXi�YacuteZYumlZZeta�aacute�acirc�acute�aelig�agraveZalefsymZalpha�amp�andZang�aringZasymp�atilde�aumlZbdquoZbeta�brvbarZbullZcap�ccedil�cedil�centZchiZcircZclubsZcong�copyZcrarrZcup�currenZdArrZdaggerZdarr�degZdeltaZdiams�divide�eacute�ecirc�egrave�emptyZemspZensp�epsilonZequivZeta�eth�eumlZeuroZexistZfnofZforall�frac12�frac14�frac34ZfraslZgamma�ge�gtZhArrZharrZheartsZhellip�iacute�icirc�iexcl�igraveZimageZinfin�intZiota�iquestZisin�iumlZkappaZlArr�lambdaZlang�laquoZlarrZlceilZldquo�leZlfloorZlowastZlozZlrmZlsaquoZlsquo�lt�macrZmdash�micro�middotZminusZmuZnabla�nbspZndash�neZni�notZnotinZnsub�ntildeZnu�oacute�ocircZoelig�ograveZolineZomegaZomicronZoplus�or�ordf�ordm�oslash�otildeZotimes�ouml�para�partZpermilZperpZphiZpiZpiv�plusmn�poundZprimeZprodZpropZpsi�quotZrArrZradicZrang�raquoZrarrZrceilZrdquo�real�regZrfloorZrhoZrlmZrsaquoZrsquoZsbquoZscaronZsdot�sect�shyZsigmaZsigmafZsimZspades�subZsube�sumZsup�sup1�sup2�sup3Zsupe�szligZtauZthere4ZthetaZthetasymZthinsp�thorn�tilde�timesZtradeZuArr�uacuteZuarr�ucirc�ugrave�umlZupsihZupsilon�uumlZweierpZxi�yacute�yen�yumlZzetaZzwjZzwnj�Á�áuĂuău∾u∿u∾̳�Â�â�´uАuа�Æ�æu⁡u𝔄u𝔞�À�àuℵuΑuαuĀuāu⨿�&u⩓u∧u⩕u⩜u⩘u⩚u∠u⦤u∡u⦨u⦩u⦪u⦫u⦬u⦭u⦮u⦯u∟u⊾u⦝u∢�Åu⍼uĄuąu𝔸u𝕒u≈u⩯u⩰u≊u≋�'�åu𝒜u𝒶u≔�*u≍�Ã�ã�Ä�äu∳u⨑u≌u϶u‵u∽u⋍u∖u⫧u⊽u⌆u⌅u⎵u⎶uБuбu„u∵u⦰uℬuΒuβuℶu≬u𝔅u𝔟u⋂u◯u⋃u⨀u⨁u⨂u⨆u★u▽u△u⨄u⋁u⋀u⤍u⧫u▪u▴u▾u◂u▸u␣u▒u░u▓u█u=⃥u≡⃥u⫭u⌐u𝔹u𝕓u⊥u⋈u⧉u╗u╖u╕u┐u╔u╓u╒u┌u═u─u╦u╤u╥u┬u╩u╧u╨u┴u⊟u⊞u⊠u╝u╜u╛u┘u╚u╙u╘u└u║u│u╬u╫u╪u┼u╣u╢u╡u┤u╠u╟u╞u├u˘�¦u𝒷u⁏�\u⧅u⟈u•u≎u⪮u≏uĆuću⋒u∩u⩄u⩉u⩋u⩇u⩀uⅅu∩︀u⁁uˇuℭu⩍uČuč�Ç�çuĈuĉu∰u⩌u⩐uĊuċ�¸u⦲�¢�·u𝔠uЧuчu✓uΧuχu○uˆu≗u↺u↻u⊛u⊚u⊝u⊙�®uⓈu⊖u⊕u⊗u⧃u⨐u⫯u⧂u∲u”u’u♣u∷�:u⩴�,�@u∁u∘uℂu≅u⩭u≡u∯u∮u𝕔u∐�©u℗u↵u⨯u✗u𝒞u𝒸u⫏u⫑u⫐u⫒u⋯u⤸u⤵u⋞u⋟u↶u⤽u⋓u∪u⩈u⩆u⩊u⊍u⩅u∪︀u↷u⤼u⋎u⋏�¤u∱u⌭u‡u†uℸu↡u⇓u↓u‐u⫤u⊣u⤏u˝uĎuďuДuдuⅆu⇊u⤑u⩷�°u∇uΔuδu⦱u⥿u𝔇u𝔡u⥥u⇃u⇂u˙�`u˜u⋄u♦�¨uϝu⋲�÷u⋇uЂuђu⌞u⌍�$u𝔻u𝕕u⃜u≐u≑u∸u∔u⊡u⇐u⇔u⟸u⟺u⟹u⇒u⊨u⇑u⇕u∥u⤓u⇵ȗu⥐u⥞u↽u⥖u⥟u⇁u⥗u⊤u↧u⤐u⌟u⌌u𝒟u𝒹uЅuѕu⧶uĐuđu⋱u▿u⥯u⦦uЏuџu⟿�É�éu⩮uĚuěu≖�Ê�êu≕uЭuэuĖuėuⅇu≒u𝔈u𝔢u⪚�È�èu⪖u⪘u⪙u∈u⏧uℓu⪕u⪗uĒuēu∅u◻u▫u u u uŊuŋu uĘuęu𝔼u𝕖u⋕u⧣u⩱uεuΕuϵu≂u⩵�=u≟u⇌u⩸u⧥u⥱u≓uℰuℯu⩳uΗuη�Ð�ð�Ë�ëu€�!u∃uФuфu♀uffiuffufflu𝔉u𝔣ufiu◼Zfju♭uflu▱uƒu𝔽u𝕗u∀u⋔u⫙uℱu⨍�½u⅓�¼u⅕u⅙u⅛u⅔u⅖�¾u⅗u⅜u⅘u⅚u⅝u⅞u⁄u⌢u𝒻uǵuΓuγuϜu⪆uĞuğuĢuĜuĝuГuгuĠuġu≧u≥u⪌u⋛u⩾u⪩u⪀u⪂u⪄u⋛︀u⪔u𝔊u𝔤u⋙u≫uℷuЃuѓu≷u⪥u⪒u⪤u⪊u≩u⪈u⋧u𝔾u𝕘u⪢u≳u𝒢uℊu⪎u⪐�>u⪧u⩺u⋗u⦕u⩼u⥸u≩︀u uℋuЪuъu↔u⥈u↭�^uℏuĤuĥu♥u…u⊹uℌu𝔥u⤥u⤦u⇿u∻u↩u↪uℍu𝕙u―u𝒽uĦuħu⁃�Í�íu⁣�Î�îuИuиuİuЕuе�¡uℑu𝔦�Ì�ìuⅈu⨌u∭u⧜u℩uIJuijuĪuīuℐuıu⊷uƵu℅u∞u⧝u∬u∫u⊺uℤu⨗u⨼u⁢uЁuёuĮuįu𝕀u𝕚uΙuι�¿u𝒾u⋵u⋹u⋴u⋳uĨuĩuІuі�Ï�ïuĴuĵuЙuйu𝔍u𝔧uȷu𝕁u𝕛u𝒥u𝒿uЈuјuЄuєuΚuκuϰuĶuķuКuкu𝔎u𝔨uĸuХuхuЌuќu𝕂u𝕜u𝒦u𝓀u⇚uĹuĺu⦴uℒuΛuλu⟪u⟨u⦑u⪅�«u↞u←u⇤u⤟u⤝u↫u⤹u⥳u↢u⪫u⤛u⤙u⪭u⪭︀u⤎u⤌u❲�{�[u⦋u⦏u⦍uĽuľuĻuļu⌈uЛuлu⤶u“u⥧u⥋u↲u≦u≤u⇆u⟦u⥡u⥙u⌊u↼u⇇u⇋u⥎u↤u⥚u⋋u⊲u⧏u⊴u⥑u⥠u↿u⥘u⥒u⪋u⋚u⩽u⪨u⩿u⪁u⪃u⋚︀u⪓u⋖u≶u⪡u≲u⥼u𝔏u𝔩u⪑u⥢u⥪u▄uЉuљu⋘u≪u⥫u◺uĿuŀu⎰u⪉u≨u⪇u⋦u⟬u⇽u⟵u⟷u⟼u⟶u↬u⦅u𝕃u𝕝u⨭u⨴u∗�_u↙u↘u◊�(u⦓u⥭u‎u⊿u‹u𝓁u↰u⪍u⪏u‘u‚uŁuł�<u⪦u⩹u⋉u⥶u⩻u◃u⦖u⥊u⥦u≨︀�¯u♂u✠u⤅u↦u↥u▮u⨩uМuмu—u∺u uℳu𝔐u𝔪u℧�µu∣u⫰u−u⨪u∓u⫛u⊧u𝕄u𝕞u𝓂uΜuμu⊸uŃuńu∠⃒u≉u⩰̸u≋̸uʼnu♮uℕ� u≎̸u≏̸u⩃uŇuňuŅuņu≇u⩭̸u⩂uНuнu–u≠u⤤u⇗u↗u≐̸u​u≢u⤨u≂̸�
u∄u𝔑u𝔫u≧̸u≱u⩾̸u⋙̸u≵u≫⃒u≯u≫̸u⇎u↮u⫲u∋u⋼u⋺uЊuњu⇍u↚u‥u≦̸u≰u⩽̸u≮u⋘̸u≴u≪⃒u⋪u⋬u≪̸u∤u⁠u𝕟�¬u⫬u≭u∦u∉u≹u⋵̸u⋹̸u⋷u⋶u⧏̸u≸u⪢̸u⪡̸u∌u⋾u⋽u⊀u⪯̸u⋠u⋫u⧐̸u⋭u⊏̸u⋢u⊐̸u⋣u⊂⃒u⊈u⊁u⪰̸u⋡u≿̸u⊃⃒u⊉u≁u≄u⫽⃥u∂̸u⨔u⇏u↛u⤳̸u↝̸u𝒩u𝓃u⊄u⫅̸u⊅u⫆̸�Ñ�ñuΝuν�#u№u u≍⃒u⊯u⊮u⊭u⊬u≥⃒u>⃒u⤄u⧞u⤂u≤⃒u<⃒u⊴⃒u⤃u⊵⃒u∼⃒u⤣u⇖u↖u⤧�Ó�ó�Ô�ôuОuоuŐuőu⨸u⦼uŒuœu⦿u𝔒u𝔬u˛�Ò�òu⧁u⦵uΩu⦾u⦻u‾u⧀uŌuōuωuΟuοu⦶u𝕆u𝕠u⦷u⦹u⩔u∨u⩝uℴ�ª�ºu⊶u⩖u⩗u⩛u𝒪�Ø�øu⊘�Õ�õu⨷u⨶�Ö�öu⌽u⏞u⎴u⏜�¶u⫳u⫽u∂uПuп�%�.u‰u‱u𝔓u𝔭uΦuφuϕu☎uΠuπuϖuℎ�+u⨣u⨢u⨥u⩲�±u⨦u⨧u⨕uℙu𝕡�£u⪻u≺u⪷u≼u⪳u⪯u≾u⪹u⪵u⋨u″u′u∏u⌮u⌒u⌓u∝u⊰u𝒫u𝓅uΨuψu u𝔔u𝔮uℚu𝕢u⁗u𝒬u𝓆u⨖�?�"u⇛u∽̱uŔuŕu√u⦳u⟫u⟩u⦒u⦥�»u↠u→u⥵u⇥u⤠u⤳u⤞u⥅u⥴u⤖u↣u↝u⤜u⤚u∶u❳�}�]u⦌u⦎u⦐uŘuřuŖuŗu⌉uРuрu⤷u⥩u↳uℜuℛuℝu▭u⥽u⌋u𝔯u⥤u⇀u⥬uΡuρuϱu⇄u⟧u⥝u⥕u⇉u⊢u⥛u⋌u⊳u⧐u⊵u⥏u⥜u↾u⥔u⥓u˚u‏u⎱u⫮u⟭u⇾u⦆u𝕣u⨮u⨵u⥰�)u⦔u⨒u›u𝓇u↱u⋊u▹u⧎u⧴u⥨u℞uŚuśu⪼u≻u⪸uŠušu≽u⪴u⪰uŞuşuŜuŝu⪺u⪶u⋩u⨓u≿uСuсu⋅u⩦u⇘�§�;u⤩u✶u𝔖u𝔰u♯uЩuщuШuшu↑�­uΣuσuςu∼u⩪u≃u⪞u⪠u⪝u⪟u≆u⨤u⥲u⨳u⧤u⌣u⪪u⪬u⪬︀uЬuь�/u⧄u⌿u𝕊u𝕤u♠u⊓u⊓︀u⊔u⊔︀u⊏u⊑u⊐u⊒u□u𝒮u𝓈u⋆u☆u⋐u⊂u⪽u⫅u⊆u⫃u⫁u⫋u⊊u⪿u⥹u⫇u⫕u⫓u∑u♪�¹�²�³u⋑u⊃u⪾u⫘u⫆u⊇u⫄u⟉u⫗u⥻u⫂u⫌u⊋u⫀u⫈u⫔u⫖u⇙u⤪�ß�	u⌖uΤuτuŤuťuŢuţuТuтu⃛u⌕u𝔗u𝔱u∴uΘuθuϑu  u �Þ�þ�×u⨱u⨰u⌶u⫱u𝕋u𝕥u⫚u‴u™u▵u≜u◬u⨺u⨹u⧍u⨻u⏢u𝒯u𝓉uЦuцuЋuћuŦuŧ�Ú�úu↟u⥉uЎuўuŬuŭ�Û�ûuУuуu⇅uŰuűu⥮u⥾u𝔘u𝔲�Ù�ùu⥣u▀u⌜u⌏u◸uŪuūu⏟u⏝u⊎uŲuųu𝕌u𝕦u⤒u↕uϒuυuΥu⇈u⌝u⌎uŮuůu◹u𝒰u𝓊u⋰uŨuũ�Ü�üu⦧u⦜u⊊︀u⫋︀u⊋︀u⫌︀u⫫u⫨u⫩uВuвu⊫u⊩u⫦u⊻u≚u⋮u‖�|u❘u≀u𝔙u𝔳u𝕍u𝕧u𝒱u𝓋u⊪u⦚uŴuŵu⩟u≙u℘u𝔚u𝔴u𝕎u𝕨u𝒲u𝓌u𝔛u𝔵uΞuξu⋻u𝕏u𝕩u𝒳u𝓍�Ý�ýuЯuяuŶuŷuЫuы�¥u𝔜u𝔶uЇuїu𝕐u𝕪u𝒴u𝓎uЮuю�ÿuŸuŹuźuŽužuЗuзuŻużuℨuΖuζu𝔷uЖuжu⇝u𝕫u𝒵u𝓏u‍u‌(�rjr�zAacute;zaacute;zAbreve;zabreve;zac;zacd;zacE;rkr�zAcirc;zacirc;r�zacute;zAcy;zacy;rir�zAElig;zaelig;zaf;zAfr;zafr;rlr�zAgrave;zagrave;zalefsym;zaleph;zAlpha;zalpha;zAmacr;zamacr;zamalg;ZAMPr�zAMP;zamp;zAnd;zand;zandand;zandd;z	andslope;zandv;zang;zange;zangle;zangmsd;z	angmsdaa;z	angmsdab;z	angmsdac;z	angmsdad;z	angmsdae;z	angmsdaf;z	angmsdag;z	angmsdah;zangrt;zangrtvb;z	angrtvbd;zangsph;zangst;zangzarr;zAogon;zaogon;zAopf;zaopf;zap;zapacir;zapE;zape;zapid;zapos;zApplyFunction;zapprox;z	approxeq;rmr�zAring;zaring;zAscr;zascr;zAssign;zast;zasymp;zasympeq;rnr�zAtilde;zatilde;ror�zAuml;zauml;z	awconint;zawint;z	backcong;zbackepsilon;z
backprime;zbacksim;z
backsimeq;z
Backslash;zBarv;zbarvee;zBarwed;zbarwed;z	barwedge;zbbrk;z	bbrktbrk;zbcong;zBcy;zbcy;zbdquo;zbecaus;zBecause;zbecause;zbemptyv;zbepsi;zbernou;zBernoullis;zBeta;zbeta;zbeth;zbetween;zBfr;zbfr;zbigcap;zbigcirc;zbigcup;zbigodot;z	bigoplus;z
bigotimes;z	bigsqcup;zbigstar;zbigtriangledown;zbigtriangleup;z	biguplus;zbigvee;z	bigwedge;zbkarow;z
blacklozenge;zblacksquare;zblacktriangle;zblacktriangledown;zblacktriangleleft;zblacktriangleright;zblank;zblk12;zblk14;zblk34;zblock;zbne;zbnequiv;zbNot;zbnot;zBopf;zbopf;zbot;zbottom;zbowtie;zboxbox;zboxDL;zboxDl;zboxdL;zboxdl;zboxDR;zboxDr;zboxdR;zboxdr;zboxH;zboxh;zboxHD;zboxHd;zboxhD;zboxhd;zboxHU;zboxHu;zboxhU;zboxhu;z	boxminus;zboxplus;z	boxtimes;zboxUL;zboxUl;zboxuL;zboxul;zboxUR;zboxUr;zboxuR;zboxur;zboxV;zboxv;zboxVH;zboxVh;zboxvH;zboxvh;zboxVL;zboxVl;zboxvL;zboxvl;zboxVR;zboxVr;zboxvR;zboxvr;zbprime;zBreve;zbreve;r�zbrvbar;zBscr;zbscr;zbsemi;zbsim;zbsime;zbsol;zbsolb;z	bsolhsub;zbull;zbullet;zbump;zbumpE;zbumpe;zBumpeq;zbumpeq;zCacute;zcacute;zCap;zcap;zcapand;z	capbrcup;zcapcap;zcapcup;zcapdot;zCapitalDifferentialD;zcaps;zcaret;zcaron;zCayleys;zccaps;zCcaron;zccaron;rpr�zCcedil;zccedil;zCcirc;zccirc;zCconint;zccups;zccupssm;zCdot;zcdot;r�zcedil;zCedilla;zcemptyv;r�zcent;z
CenterDot;z
centerdot;zCfr;zcfr;zCHcy;zchcy;zcheck;z
checkmark;zChi;zchi;zcir;zcirc;zcirceq;zcirclearrowleft;zcirclearrowright;zcircledast;zcircledcirc;zcircleddash;z
CircleDot;z	circledR;z	circledS;zCircleMinus;zCirclePlus;zCircleTimes;zcirE;zcire;z	cirfnint;zcirmid;zcirscir;zClockwiseContourIntegral;zCloseCurlyDoubleQuote;zCloseCurlyQuote;zclubs;z	clubsuit;zColon;zcolon;zColone;zcolone;zcoloneq;zcomma;zcommat;zcomp;zcompfn;zcomplement;z
complexes;zcong;zcongdot;z
Congruent;zConint;zconint;zContourIntegral;zCopf;zcopf;zcoprod;z
Coproduct;ZCOPYr�zCOPY;zcopy;zcopysr;z CounterClockwiseContourIntegral;zcrarr;zCross;zcross;zCscr;zcscr;zcsub;zcsube;zcsup;zcsupe;zctdot;zcudarrl;zcudarrr;zcuepr;zcuesc;zcularr;zcularrp;zCup;zcup;z	cupbrcap;zCupCap;zcupcap;zcupcup;zcupdot;zcupor;zcups;zcurarr;zcurarrm;zcurlyeqprec;zcurlyeqsucc;z	curlyvee;zcurlywedge;r�zcurren;zcurvearrowleft;zcurvearrowright;zcuvee;zcuwed;z	cwconint;zcwint;zcylcty;zDagger;zdagger;zdaleth;zDarr;zdArr;zdarr;zdash;zDashv;zdashv;zdbkarow;zdblac;zDcaron;zdcaron;zDcy;zdcy;zDD;zdd;zddagger;zddarr;z	DDotrahd;zddotseq;r�zdeg;zDel;zDelta;zdelta;zdemptyv;zdfisht;zDfr;zdfr;zdHar;zdharl;zdharr;zDiacriticalAcute;zDiacriticalDot;zDiacriticalDoubleAcute;zDiacriticalGrave;zDiacriticalTilde;zdiam;zDiamond;zdiamond;zdiamondsuit;zdiams;zdie;zDifferentialD;zdigamma;zdisin;zdiv;r�zdivide;zdivideontimes;zdivonx;zDJcy;zdjcy;zdlcorn;zdlcrop;zdollar;zDopf;zdopf;zDot;zdot;zDotDot;zdoteq;z	doteqdot;z	DotEqual;z	dotminus;zdotplus;z
dotsquare;zdoublebarwedge;zDoubleContourIntegral;z
DoubleDot;zDoubleDownArrow;zDoubleLeftArrow;zDoubleLeftRightArrow;zDoubleLeftTee;zDoubleLongLeftArrow;zDoubleLongLeftRightArrow;zDoubleLongRightArrow;zDoubleRightArrow;zDoubleRightTee;zDoubleUpArrow;zDoubleUpDownArrow;zDoubleVerticalBar;z
DownArrow;z
Downarrow;z
downarrow;z
DownArrowBar;zDownArrowUpArrow;z
DownBreve;zdowndownarrows;zdownharpoonleft;zdownharpoonright;zDownLeftRightVector;zDownLeftTeeVector;zDownLeftVector;zDownLeftVectorBar;zDownRightTeeVector;zDownRightVector;zDownRightVectorBar;zDownTee;z
DownTeeArrow;z	drbkarow;zdrcorn;zdrcrop;zDscr;zdscr;zDScy;zdscy;zdsol;zDstrok;zdstrok;zdtdot;zdtri;zdtrif;zduarr;zduhar;zdwangle;zDZcy;zdzcy;z	dzigrarr;rrr�zEacute;zeacute;zeaster;zEcaron;zecaron;zecir;rsr�zEcirc;zecirc;zecolon;zEcy;zecy;zeDDot;zEdot;zeDot;zedot;zee;zefDot;zEfr;zefr;zeg;rtr�zEgrave;zegrave;zegs;zegsdot;zel;zElement;z	elinters;zell;zels;zelsdot;zEmacr;zemacr;zempty;z	emptyset;zEmptySmallSquare;zemptyv;zEmptyVerySmallSquare;zemsp13;zemsp14;zemsp;zENG;zeng;zensp;zEogon;zeogon;zEopf;zeopf;zepar;zeparsl;zeplus;zepsi;zEpsilon;zepsilon;zepsiv;zeqcirc;zeqcolon;zeqsim;zeqslantgtr;zeqslantless;zEqual;zequals;zEqualTilde;zequest;zEquilibrium;zequiv;zequivDD;z	eqvparsl;zerarr;zerDot;zEscr;zescr;zesdot;zEsim;zesim;zEta;zeta;rqr�zETH;zeth;rur�zEuml;zeuml;zeuro;zexcl;zexist;zExists;zexpectation;z
ExponentialE;z
exponentiale;zfallingdotseq;zFcy;zfcy;zfemale;zffilig;zfflig;zffllig;zFfr;zffr;zfilig;zFilledSmallSquare;zFilledVerySmallSquare;zfjlig;zflat;zfllig;zfltns;zfnof;zFopf;zfopf;zForAll;zforall;zfork;zforkv;zFouriertrf;z	fpartint;r�zfrac12;zfrac13;r�zfrac14;zfrac15;zfrac16;zfrac18;zfrac23;zfrac25;r�zfrac34;zfrac35;zfrac38;zfrac45;zfrac56;zfrac58;zfrac78;zfrasl;zfrown;zFscr;zfscr;zgacute;zGamma;zgamma;zGammad;zgammad;zgap;zGbreve;zgbreve;zGcedil;zGcirc;zgcirc;zGcy;zgcy;zGdot;zgdot;zgE;zge;zgEl;zgel;zgeq;zgeqq;z	geqslant;zges;zgescc;zgesdot;zgesdoto;z	gesdotol;zgesl;zgesles;zGfr;zgfr;zGg;zgg;zggg;zgimel;zGJcy;zgjcy;zgl;zgla;zglE;zglj;zgnap;z	gnapprox;zgnE;zgne;zgneq;zgneqq;zgnsim;zGopf;zgopf;zgrave;z
GreaterEqual;zGreaterEqualLess;zGreaterFullEqual;zGreaterGreater;zGreaterLess;zGreaterSlantEqual;z
GreaterTilde;zGscr;zgscr;zgsim;zgsime;zgsiml;ZGTr�zGT;zGt;zgt;zgtcc;zgtcir;zgtdot;zgtlPar;zgtquest;z
gtrapprox;zgtrarr;zgtrdot;z
gtreqless;zgtreqqless;zgtrless;zgtrsim;z
gvertneqq;zgvnE;zHacek;zhairsp;zhalf;zhamilt;zHARDcy;zhardcy;zhArr;zharr;zharrcir;zharrw;zHat;zhbar;zHcirc;zhcirc;zhearts;z
heartsuit;zhellip;zhercon;zHfr;zhfr;z
HilbertSpace;z	hksearow;z	hkswarow;zhoarr;zhomtht;zhookleftarrow;zhookrightarrow;zHopf;zhopf;zhorbar;zHorizontalLine;zHscr;zhscr;zhslash;zHstrok;zhstrok;z
HumpDownHump;z
HumpEqual;zhybull;zhyphen;rvr�zIacute;ziacute;zic;rwr�zIcirc;zicirc;zIcy;zicy;zIdot;zIEcy;ziecy;r�ziexcl;ziff;zIfr;zifr;rxr�zIgrave;zigrave;zii;ziiiint;ziiint;ziinfin;ziiota;zIJlig;zijlig;zIm;zImacr;zimacr;zimage;zImaginaryI;z	imagline;z	imagpart;zimath;zimof;zimped;zImplies;zin;zincare;zinfin;z	infintie;zinodot;zInt;zint;zintcal;z	integers;z	Integral;z	intercal;z
Intersection;z	intlarhk;zintprod;zInvisibleComma;zInvisibleTimes;zIOcy;ziocy;zIogon;ziogon;zIopf;ziopf;zIota;ziota;ziprod;r�ziquest;zIscr;ziscr;zisin;zisindot;zisinE;zisins;zisinsv;zisinv;zit;zItilde;zitilde;zIukcy;ziukcy;ryr�zIuml;ziuml;zJcirc;zjcirc;zJcy;zjcy;zJfr;zjfr;zjmath;zJopf;zjopf;zJscr;zjscr;zJsercy;zjsercy;zJukcy;zjukcy;zKappa;zkappa;zkappav;zKcedil;zkcedil;zKcy;zkcy;zKfr;zkfr;zkgreen;zKHcy;zkhcy;zKJcy;zkjcy;zKopf;zkopf;zKscr;zkscr;zlAarr;zLacute;zlacute;z	laemptyv;zlagran;zLambda;zlambda;zLang;zlang;zlangd;zlangle;zlap;zLaplacetrf;r�zlaquo;zLarr;zlArr;zlarr;zlarrb;zlarrbfs;zlarrfs;zlarrhk;zlarrlp;zlarrpl;zlarrsim;zlarrtl;zlat;zlAtail;zlatail;zlate;zlates;zlBarr;zlbarr;zlbbrk;zlbrace;zlbrack;zlbrke;zlbrksld;zlbrkslu;zLcaron;zlcaron;zLcedil;zlcedil;zlceil;zlcub;zLcy;zlcy;zldca;zldquo;zldquor;zldrdhar;z	ldrushar;zldsh;zlE;zle;zLeftAngleBracket;z
LeftArrow;z
Leftarrow;z
leftarrow;z
LeftArrowBar;zLeftArrowRightArrow;zleftarrowtail;zLeftCeiling;zLeftDoubleBracket;zLeftDownTeeVector;zLeftDownVector;zLeftDownVectorBar;z
LeftFloor;zleftharpoondown;zleftharpoonup;zleftleftarrows;zLeftRightArrow;zLeftrightarrow;zleftrightarrow;zleftrightarrows;zleftrightharpoons;zleftrightsquigarrow;zLeftRightVector;zLeftTee;z
LeftTeeArrow;zLeftTeeVector;zleftthreetimes;z
LeftTriangle;zLeftTriangleBar;zLeftTriangleEqual;zLeftUpDownVector;zLeftUpTeeVector;z
LeftUpVector;zLeftUpVectorBar;zLeftVector;zLeftVectorBar;zlEg;zleg;zleq;zleqq;z	leqslant;zles;zlescc;zlesdot;zlesdoto;z	lesdotor;zlesg;zlesges;zlessapprox;zlessdot;z
lesseqgtr;zlesseqqgtr;zLessEqualGreater;zLessFullEqual;zLessGreater;zlessgtr;z	LessLess;zlesssim;zLessSlantEqual;z
LessTilde;zlfisht;zlfloor;zLfr;zlfr;zlg;zlgE;zlHar;zlhard;zlharu;zlharul;zlhblk;zLJcy;zljcy;zLl;zll;zllarr;z	llcorner;zLleftarrow;zllhard;zlltri;zLmidot;zlmidot;zlmoust;zlmoustache;zlnap;z	lnapprox;zlnE;zlne;zlneq;zlneqq;zlnsim;zloang;zloarr;zlobrk;zLongLeftArrow;zLongleftarrow;zlongleftarrow;zLongLeftRightArrow;zLongleftrightarrow;zlongleftrightarrow;zlongmapsto;zLongRightArrow;zLongrightarrow;zlongrightarrow;zlooparrowleft;zlooparrowright;zlopar;zLopf;zlopf;zloplus;zlotimes;zlowast;zlowbar;zLowerLeftArrow;zLowerRightArrow;zloz;zlozenge;zlozf;zlpar;zlparlt;zlrarr;z	lrcorner;zlrhar;zlrhard;zlrm;zlrtri;zlsaquo;zLscr;zlscr;zLsh;zlsh;zlsim;zlsime;zlsimg;zlsqb;zlsquo;zlsquor;zLstrok;zlstrok;ZLTr�zLT;zLt;zlt;zltcc;zltcir;zltdot;zlthree;zltimes;zltlarr;zltquest;zltri;zltrie;zltrif;zltrPar;z	lurdshar;zluruhar;z
lvertneqq;zlvnE;r�zmacr;zmale;zmalt;zmaltese;zMap;zmap;zmapsto;zmapstodown;zmapstoleft;z	mapstoup;zmarker;zmcomma;zMcy;zmcy;zmdash;zmDDot;zmeasuredangle;zMediumSpace;z
Mellintrf;zMfr;zmfr;zmho;r�zmicro;zmid;zmidast;zmidcir;r�zmiddot;zminus;zminusb;zminusd;zminusdu;z
MinusPlus;zmlcp;zmldr;zmnplus;zmodels;zMopf;zmopf;zmp;zMscr;zmscr;zmstpos;zMu;zmu;z	multimap;zmumap;znabla;zNacute;znacute;znang;znap;znapE;znapid;znapos;znapprox;znatur;znatural;z	naturals;r�znbsp;znbump;znbumpe;zncap;zNcaron;zncaron;zNcedil;zncedil;zncong;z	ncongdot;zncup;zNcy;zncy;zndash;zne;znearhk;zneArr;znearr;znearrow;znedot;zNegativeMediumSpace;zNegativeThickSpace;zNegativeThinSpace;zNegativeVeryThinSpace;znequiv;znesear;znesim;zNestedGreaterGreater;zNestedLessLess;zNewLine;znexist;znexists;zNfr;znfr;zngE;znge;zngeq;zngeqq;z
ngeqslant;znges;znGg;zngsim;znGt;zngt;zngtr;znGtv;znhArr;znharr;znhpar;zni;znis;znisd;zniv;zNJcy;znjcy;znlArr;znlarr;znldr;znlE;znle;znLeftarrow;znleftarrow;znLeftrightarrow;znleftrightarrow;znleq;znleqq;z
nleqslant;znles;znless;znLl;znlsim;znLt;znlt;znltri;znltrie;znLtv;znmid;zNoBreak;zNonBreakingSpace;zNopf;znopf;r�zNot;znot;z
NotCongruent;z
NotCupCap;zNotDoubleVerticalBar;zNotElement;z	NotEqual;zNotEqualTilde;z
NotExists;zNotGreater;zNotGreaterEqual;zNotGreaterFullEqual;zNotGreaterGreater;zNotGreaterLess;zNotGreaterSlantEqual;zNotGreaterTilde;zNotHumpDownHump;z
NotHumpEqual;znotin;z	notindot;znotinE;znotinva;znotinvb;znotinvc;zNotLeftTriangle;zNotLeftTriangleBar;zNotLeftTriangleEqual;zNotLess;z
NotLessEqual;zNotLessGreater;zNotLessLess;zNotLessSlantEqual;z
NotLessTilde;zNotNestedGreaterGreater;zNotNestedLessLess;znotni;znotniva;znotnivb;znotnivc;zNotPrecedes;zNotPrecedesEqual;zNotPrecedesSlantEqual;zNotReverseElement;zNotRightTriangle;zNotRightTriangleBar;zNotRightTriangleEqual;zNotSquareSubset;zNotSquareSubsetEqual;zNotSquareSuperset;zNotSquareSupersetEqual;z
NotSubset;zNotSubsetEqual;zNotSucceeds;zNotSucceedsEqual;zNotSucceedsSlantEqual;zNotSucceedsTilde;zNotSuperset;zNotSupersetEqual;z	NotTilde;zNotTildeEqual;zNotTildeFullEqual;zNotTildeTilde;zNotVerticalBar;znpar;z
nparallel;znparsl;znpart;znpolint;znpr;znprcue;znpre;znprec;znpreceq;znrArr;znrarr;znrarrc;znrarrw;znRightarrow;znrightarrow;znrtri;znrtrie;znsc;znsccue;znsce;zNscr;znscr;z
nshortmid;znshortparallel;znsim;znsime;znsimeq;znsmid;znspar;znsqsube;znsqsupe;znsub;znsubE;znsube;znsubset;z
nsubseteq;znsubseteqq;znsucc;znsucceq;znsup;znsupE;znsupe;znsupset;z
nsupseteq;znsupseteqq;zntgl;rzr�zNtilde;zntilde;zntlg;zntriangleleft;zntrianglelefteq;zntriangleright;zntrianglerighteq;zNu;znu;znum;znumero;znumsp;znvap;znVDash;znVdash;znvDash;znvdash;znvge;znvgt;znvHarr;znvinfin;znvlArr;znvle;znvlt;znvltrie;znvrArr;znvrtrie;znvsim;znwarhk;znwArr;znwarr;znwarrow;znwnear;r{r�zOacute;zoacute;zoast;zocir;r|r�zOcirc;zocirc;zOcy;zocy;zodash;zOdblac;zodblac;zodiv;zodot;zodsold;zOElig;zoelig;zofcir;zOfr;zofr;zogon;r}r�zOgrave;zograve;zogt;zohbar;zohm;zoint;zolarr;zolcir;zolcross;zoline;zolt;zOmacr;zomacr;zOmega;zomega;zOmicron;zomicron;zomid;zominus;zOopf;zoopf;zopar;zOpenCurlyDoubleQuote;zOpenCurlyQuote;zoperp;zoplus;zOr;zor;zorarr;zord;zorder;zorderof;r�zordf;r�zordm;zorigof;zoror;zorslope;zorv;zoS;zOscr;zoscr;r~r�zOslash;zoslash;zosol;rr�zOtilde;zotilde;zOtimes;zotimes;z	otimesas;r�r�zOuml;zouml;zovbar;zOverBar;z
OverBrace;zOverBracket;zOverParenthesis;zpar;r�zpara;z	parallel;zparsim;zparsl;zpart;z	PartialD;zPcy;zpcy;zpercnt;zperiod;zpermil;zperp;zpertenk;zPfr;zpfr;zPhi;zphi;zphiv;zphmmat;zphone;zPi;zpi;z
pitchfork;zpiv;zplanck;zplanckh;zplankv;zplus;z	plusacir;zplusb;zpluscir;zplusdo;zplusdu;zpluse;z
PlusMinus;r�zplusmn;zplussim;zplustwo;zpm;zPoincareplane;z	pointint;zPopf;zpopf;r�zpound;zPr;zpr;zprap;zprcue;zprE;zpre;zprec;zprecapprox;zpreccurlyeq;z	Precedes;zPrecedesEqual;zPrecedesSlantEqual;zPrecedesTilde;zpreceq;zprecnapprox;z	precneqq;z	precnsim;zprecsim;zPrime;zprime;zprimes;zprnap;zprnE;zprnsim;zprod;zProduct;z	profalar;z	profline;z	profsurf;zprop;zProportion;z
Proportional;zpropto;zprsim;zprurel;zPscr;zpscr;zPsi;zpsi;zpuncsp;zQfr;zqfr;zqint;zQopf;zqopf;zqprime;zQscr;zqscr;zquaternions;zquatint;zquest;zquesteq;ZQUOTr�zQUOT;zquot;zrAarr;zrace;zRacute;zracute;zradic;z	raemptyv;zRang;zrang;zrangd;zrange;zrangle;r�zraquo;zRarr;zrArr;zrarr;zrarrap;zrarrb;zrarrbfs;zrarrc;zrarrfs;zrarrhk;zrarrlp;zrarrpl;zrarrsim;zRarrtl;zrarrtl;zrarrw;zrAtail;zratail;zratio;z
rationals;zRBarr;zrBarr;zrbarr;zrbbrk;zrbrace;zrbrack;zrbrke;zrbrksld;zrbrkslu;zRcaron;zrcaron;zRcedil;zrcedil;zrceil;zrcub;zRcy;zrcy;zrdca;zrdldhar;zrdquo;zrdquor;zrdsh;zRe;zreal;zrealine;z	realpart;zreals;zrect;ZREGr�zREG;zreg;zReverseElement;zReverseEquilibrium;zReverseUpEquilibrium;zrfisht;zrfloor;zRfr;zrfr;zrHar;zrhard;zrharu;zrharul;zRho;zrho;zrhov;zRightAngleBracket;zRightArrow;zRightarrow;zrightarrow;zRightArrowBar;zRightArrowLeftArrow;zrightarrowtail;z
RightCeiling;zRightDoubleBracket;zRightDownTeeVector;zRightDownVector;zRightDownVectorBar;zRightFloor;zrightharpoondown;zrightharpoonup;zrightleftarrows;zrightleftharpoons;zrightrightarrows;zrightsquigarrow;z	RightTee;zRightTeeArrow;zRightTeeVector;zrightthreetimes;zRightTriangle;zRightTriangleBar;zRightTriangleEqual;zRightUpDownVector;zRightUpTeeVector;zRightUpVector;zRightUpVectorBar;zRightVector;zRightVectorBar;zring;z
risingdotseq;zrlarr;zrlhar;zrlm;zrmoust;zrmoustache;zrnmid;zroang;zroarr;zrobrk;zropar;zRopf;zropf;zroplus;zrotimes;z
RoundImplies;zrpar;zrpargt;z	rppolint;zrrarr;zRrightarrow;zrsaquo;zRscr;zrscr;zRsh;zrsh;zrsqb;zrsquo;zrsquor;zrthree;zrtimes;zrtri;zrtrie;zrtrif;z	rtriltri;zRuleDelayed;zruluhar;zrx;zSacute;zsacute;zsbquo;zSc;zsc;zscap;zScaron;zscaron;zsccue;zscE;zsce;zScedil;zscedil;zScirc;zscirc;zscnap;zscnE;zscnsim;z	scpolint;zscsim;zScy;zscy;zsdot;zsdotb;zsdote;zsearhk;zseArr;zsearr;zsearrow;r�zsect;zsemi;zseswar;z	setminus;zsetmn;zsext;zSfr;zsfr;zsfrown;zsharp;zSHCHcy;zshchcy;zSHcy;zshcy;zShortDownArrow;zShortLeftArrow;z	shortmid;zshortparallel;zShortRightArrow;z
ShortUpArrow;r�zshy;zSigma;zsigma;zsigmaf;zsigmav;zsim;zsimdot;zsime;zsimeq;zsimg;zsimgE;zsiml;zsimlE;zsimne;zsimplus;zsimrarr;zslarr;zSmallCircle;zsmallsetminus;zsmashp;z	smeparsl;zsmid;zsmile;zsmt;zsmte;zsmtes;zSOFTcy;zsoftcy;zsol;zsolb;zsolbar;zSopf;zsopf;zspades;z
spadesuit;zspar;zsqcap;zsqcaps;zsqcup;zsqcups;zSqrt;zsqsub;zsqsube;z	sqsubset;zsqsubseteq;zsqsup;zsqsupe;z	sqsupset;zsqsupseteq;zsqu;zSquare;zsquare;zSquareIntersection;z
SquareSubset;zSquareSubsetEqual;zSquareSuperset;zSquareSupersetEqual;zSquareUnion;zsquarf;zsquf;zsrarr;zSscr;zsscr;zssetmn;zssmile;zsstarf;zStar;zstar;zstarf;zstraightepsilon;zstraightphi;zstrns;zSub;zsub;zsubdot;zsubE;zsube;zsubedot;zsubmult;zsubnE;zsubne;zsubplus;zsubrarr;zSubset;zsubset;z	subseteq;z
subseteqq;zSubsetEqual;z
subsetneq;zsubsetneqq;zsubsim;zsubsub;zsubsup;zsucc;zsuccapprox;zsucccurlyeq;z	Succeeds;zSucceedsEqual;zSucceedsSlantEqual;zSucceedsTilde;zsucceq;zsuccnapprox;z	succneqq;z	succnsim;zsuccsim;z	SuchThat;zSum;zsum;zsung;r�zsup1;r�zsup2;r�zsup3;zSup;zsup;zsupdot;zsupdsub;zsupE;zsupe;zsupedot;z	Superset;zSupersetEqual;zsuphsol;zsuphsub;zsuplarr;zsupmult;zsupnE;zsupne;zsupplus;zSupset;zsupset;z	supseteq;z
supseteqq;z
supsetneq;zsupsetneqq;zsupsim;zsupsub;zsupsup;zswarhk;zswArr;zswarr;zswarrow;zswnwar;r�zszlig;zTab;ztarget;zTau;ztau;ztbrk;zTcaron;ztcaron;zTcedil;ztcedil;zTcy;ztcy;ztdot;ztelrec;zTfr;ztfr;zthere4;z
Therefore;z
therefore;zTheta;ztheta;z	thetasym;zthetav;zthickapprox;z	thicksim;zThickSpace;zthinsp;z
ThinSpace;zthkap;zthksim;r�r�zTHORN;zthorn;zTilde;ztilde;zTildeEqual;zTildeFullEqual;zTildeTilde;r�ztimes;ztimesb;z	timesbar;ztimesd;ztint;ztoea;ztop;ztopbot;ztopcir;zTopf;ztopf;ztopfork;ztosa;ztprime;zTRADE;ztrade;z	triangle;z
triangledown;z
triangleleft;ztrianglelefteq;z
triangleq;ztriangleright;ztrianglerighteq;ztridot;ztrie;z	triminus;z
TripleDot;ztriplus;ztrisb;ztritime;z	trpezium;zTscr;ztscr;zTScy;ztscy;zTSHcy;ztshcy;zTstrok;ztstrok;ztwixt;ztwoheadleftarrow;ztwoheadrightarrow;r�r�zUacute;zuacute;zUarr;zuArr;zuarr;z	Uarrocir;zUbrcy;zubrcy;zUbreve;zubreve;r�r�zUcirc;zucirc;zUcy;zucy;zudarr;zUdblac;zudblac;zudhar;zufisht;zUfr;zufr;r�r�zUgrave;zugrave;zuHar;zuharl;zuharr;zuhblk;zulcorn;z	ulcorner;zulcrop;zultri;zUmacr;zumacr;r�zuml;z	UnderBar;zUnderBrace;z
UnderBracket;zUnderParenthesis;zUnion;z
UnionPlus;zUogon;zuogon;zUopf;zuopf;zUpArrow;zUparrow;zuparrow;zUpArrowBar;zUpArrowDownArrow;zUpDownArrow;zUpdownarrow;zupdownarrow;zUpEquilibrium;zupharpoonleft;zupharpoonright;zuplus;zUpperLeftArrow;zUpperRightArrow;zUpsi;zupsi;zupsih;zUpsilon;zupsilon;zUpTee;zUpTeeArrow;zupuparrows;zurcorn;z	urcorner;zurcrop;zUring;zuring;zurtri;zUscr;zuscr;zutdot;zUtilde;zutilde;zutri;zutrif;zuuarr;r�r�zUuml;zuuml;zuwangle;zvangrt;zvarepsilon;z	varkappa;zvarnothing;zvarphi;zvarpi;z
varpropto;zvArr;zvarr;zvarrho;z	varsigma;z
varsubsetneq;zvarsubsetneqq;z
varsupsetneq;zvarsupsetneqq;z	vartheta;zvartriangleleft;zvartriangleright;zVbar;zvBar;zvBarv;zVcy;zvcy;zVDash;zVdash;zvDash;zvdash;zVdashl;zVee;zvee;zveebar;zveeeq;zvellip;zVerbar;zverbar;zVert;zvert;zVerticalBar;z
VerticalLine;zVerticalSeparator;zVerticalTilde;zVeryThinSpace;zVfr;zvfr;zvltri;zvnsub;zvnsup;zVopf;zvopf;zvprop;zvrtri;zVscr;zvscr;zvsubnE;zvsubne;zvsupnE;zvsupne;zVvdash;zvzigzag;zWcirc;zwcirc;zwedbar;zWedge;zwedge;zwedgeq;zweierp;zWfr;zwfr;zWopf;zwopf;zwp;zwr;zwreath;zWscr;zwscr;zxcap;zxcirc;zxcup;zxdtri;zXfr;zxfr;zxhArr;zxharr;zXi;zxi;zxlArr;zxlarr;zxmap;zxnis;zxodot;zXopf;zxopf;zxoplus;zxotime;zxrArr;zxrarr;zXscr;zxscr;zxsqcup;zxuplus;zxutri;zxvee;zxwedge;r�r�zYacute;zyacute;zYAcy;zyacy;zYcirc;zycirc;zYcy;zycy;r�zyen;zYfr;zyfr;zYIcy;zyicy;zYopf;zyopf;zYscr;zyscr;zYUcy;zyucy;r�zYuml;zyuml;zZacute;zzacute;zZcaron;zzcaron;zZcy;zzcy;zZdot;zzdot;zzeetrf;zZeroWidthSpace;zZeta;zzeta;zZfr;zzfr;zZHcy;zzhcy;zzigrarr;zZopf;zzopf;zZscr;zzscr;zzwj;zzwnj;N)	�__all__rrrr�items�nameZ	codepoint�chr�r_r_�%/usr/lib64/python3.6/html/entities.py�<module>sr
PK��\��U��
�
parser.cpython-36.opt-2.pycnu�[���3


 \��@s|ddddddgZddlmZmZddlmZmZdd	lmZGd
d�d�Z	Gdd�de	�Z
Gdd�d�ZGd
d�de�ZdS)�Parser�HeaderParser�BytesParser�BytesHeaderParser�
FeedParser�BytesFeedParser�)�StringIO�
TextIOWrapper)rr)�compat32c@s0eZdZd
ed�dd�Zddd�Zddd	�ZdS)
rN)�policycCs||_||_dS)N)�_classr)�selfrr�r�$/usr/lib64/python3.6/email/parser.py�__init__szParser.__init__FcCsDt|j|jd�}|r|j�x|jd�}|s.P|j|�qW|j�S)N)ri )rrrZ_set_headersonly�readZfeed�close)r
�fp�headersonlyZ
feedparser�datarrr�parse*s
zParser.parsecCs|jt|�|d�S)N)r)rr)r
�textrrrr�parsestr<szParser.parsestr)N)F)F)�__name__�
__module__�__qualname__r
rrrrrrrrs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||d�S)NT)rr)r
rrrrrrIszHeaderParser.parsecCstj||d�S)NT)rr)r
rrrrrrLszHeaderParser.parsestrN)T)T)rrrrrrrrrrHs
c@s(eZdZdd�Zd	dd�Zd
dd�ZdS)rcOst||�|_dS)N)r�parser)r
�args�kwrrrrRszBytesParser.__init__Fc
Cs,t|ddd�}z|jj||�S|j�XdS)N�ascii�surrogateescape)�encoding�errors)r	rr�detach)r
rrrrrrdszBytesParser.parsecCs|jddd�}|jj||�S)N�ASCIIr )r")�decoderr)r
rrrrr�
parsebytessszBytesParser.parsebytesN)F)F)rrrrrr&rrrrrPs
c@s eZdZddd�Zddd�ZdS)	rTcCstj||dd�S)NT)r)rr)r
rrrrrr�szBytesHeaderParser.parsecCstj||dd�S)NT)r)rr&)r
rrrrrr&�szBytesHeaderParser.parsebytesN)T)T)rrrrr&rrrrrs
N)
�__all__�iorr	Zemail.feedparserrrZemail._policybaser
rrrrrrrr�<module>s7/PK��\�Q9��entities.cpython-36.pycnu�[���3


 \3&��@s6%dZddddgZddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��d�d��Z�d�d�d�d�d�d�d�d�d�d	�d
�d	�d
�d�d�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d"�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d9�d:�d;�d<�d�d7�d:�d1�d=�d1�d=�d>�d?�d@�dA�d7�dB�dC�dD�dC�dD�dE�dF�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dN�dO�dP�dQ�dR�dR�dS�dT�dI�dU�dV�dW�dX�dX�dX�dY�dJ�dZ�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�de�df�dg�dh�di�dj�dk�dl�dm�dn�do�dp�dq�dr�ds�dt�du�dv�dw�dx�dy�dz�d{�d|�d}�d~�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dK�d��d��d��d��dZ�d��d��dL�dM�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdːdʐdːd̐d͐dΐdϐdАdѐdҐdӐdӐdӐdԐdՐdՐd֐d֐dƐdאdؐdِdڐdڐdېdܐdݐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�dߐd�d�d�d�d�d�d�d�d�d�d��d@�d@�d��d��d��d��d��d��d��d��d��d��d��d��d��d�d�d�d�d�d�d�d�dG�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d�d�d�dB�d�d�d�d�d�d�d�d�d�d�d�d �d �d�d�d�d�d�d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�dd2�d#�d3�d4�d5�d6�d6�d7�d8�d9�d:�d;�d<�d=�d>�d?�d@�d�dA�d-�dB�dC�dD�dD�dD�dE�dE�dF�d2�dG�dH�dI�dI�dI�dJ�dJ�dK�dL�dM�dN�dO�dP�dQ�dF�dA�dR�dS�dT�dS�dU�dV�dW�dQ�d��dF�d'�dX�dY�d*�dZ�d[�d\�d]�d^�d_�d`�da�d(�d'�d(�db�dc�dd�d3�d?�d@�de�df�dg�dh�di�dj�dk�dl�dm�dn�do�dp�dq�dr�ds�dt�du�dv�dw�dx�dy�dr�dc�dz�d{�d|�d}�d~�d�d��d�d��d��d��d��d��d��d��d��d��d��d��d��d5�d��dT�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dS�d��d��d��d��d��d��d��d��d��d��d��d��ddÐdĐdĐd��d��d��d��dŐdƐdǐdȐdɐdʐdːd̐d͐dΐdp�dϐdАdѐdҐdӐdԐdՐd֐d֐dאdؐdِdڐdېdېdܐdݐdݐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�d�dِd�d�d�d�d�dG�d�d�d�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d�d�d�d�d�d�d�d�d�d	�d�d
�d�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�dB�d��d��d��d�d
�d��d�d�d�d�d�d�d�d�d�d	�d�d�d�d �d!�d"�d�d#�d �d��d��d
�d�d$�d$�dŐd%�dېd&�d'�d(�dY�d)�d*�d+�d,�d-�d.�d/�d0�d0�d1�d2�d3�d4�d&�d5�d6�d7�d8�d9�d:�d;�d<�d=�d��d&�d>�d-�d?�d@�d��d��dA�d)�dB�dC�dB�dC�dD�dE�dF�dE�dF�dG�dH�dI�dJ�dK�dL�dL�dY�dM�dN�dO�dP�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dM�dX�dY�dM�dQ�dZ�dM�d[�d\�d]�d]�d��d^�d_�d`�d[�da�db�dc�dd�db�dc�da�de�df�dD�dg�dh�di�dj�dk�dl�dm�dn�do�df�dp�dp�dZ�dq�d��dr�ds�dt�du�d��dg�dv�dw�dx�dy�dz�d{�dz�d{�d|�d}�d~�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dX�d��d��d��d��d9�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��ddÐd��dĐdŐdƐdǐdW�dȐdɐdʐdːd̐d��d��dX�d��d��d͐d��dÐdΐdϐd?�dАdѐdg�dҐdӐd)�dY�d)�d͐dԐd+�dՐd+�d֐dאdؐdِdڐdېdܐdݐdސdߐdҐd�d�d�d̐dːd�d�d�d�d�d�d�d�d��d�d�d�d�dːd�d�d�d�d�d�d�dѐd�d�d�d�d�dg�dҐd�d�d��d��d��d��dӐdM�d��d��d��d��d��d��d��d��d��d��d�d�d��d�d�d�dΐd�dZ�d�d�d[�d�d�d�d\�d�d��d�d	�d
�d�d�d
�d�d�d�d�d�d�do�d�d�d͐do�dԐd�d�d�d�d��d�d�d�d�d�d�d��d�d�d�d �d!�d!�d!�d��d!�d"�d#�d�dؐd$�d%�d&�d'�dېds�d(�d)�d*�d+�d+�d,�d,�d-�d.�d.�d/�d0�d0�dm�d֐d1�d2�d3�d4�d5�d6�d7�d$�d8�d9�d:�d;�d<�d=�d=�d>�dA�d?�d֐d֐d@�d��dU�dA�dB�dC�d1�dB�dD�dE�dF�dB�d9�dG�d�dH�dI�dJ�dJ�d7�dK�dL�dM�dN�dO�dP�dQ�dN�dR�dR�dS�dT�dT�dU�dV�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�de�de�df�dg�dg�dg�dg�dh�di�dj�d	�d��dk�dl�dl�dm�dn�do�dp�dp�do�dq�dq�dr�ds�dt�du�du�dv�dw�dx�dy�dz�d{�d|�dz�d}�d~�d�d��d��d��d��d�d��dw�dx�d��d��d��d��d��d��d��d��d��d��d��d��d��d��dT�dS�d��d��d��d��dh�d��d��d��db�dj�dl�du�dp�do�dv�d��dq�ds�dU�dV�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d\�dN�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dd��dd��d��d��d��d��dÐdĐdŐdƐdǐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdԐdՐd֐dאdؐdِdڐdڐdېdܐdݐdܐdݐd�d�dސdߐdސdߐd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d��d�d�d�d�d�d��d��d�d��d��d��d��d�d��d��d��dǐd�d��d�d��d�d�d�d�d�d�d�d�d�d�d�d�d�d�d	�d�d
�d�d
�d�d�d
�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�da�d�d�da�d�d�d�d�d�d�d�d�d�d��d �d!�d"�d#�d$�d%�d9�d&�d'�d(�dאd)�d-�d*�d-�d+�d,�d��d-�dV�d.�d/�d0�d0�d0�d1�d2�d0�d3�d3�d4�d5�d6�d6�d7�d8�d9�d:�d;�d<�d8�d9�d:�d8�d<�d:�d=�d<�d>�d?�d@�d=�dA�dB�d4�d>�d?�d@�dC�dC�dD�dE�dF�dG�d�dG�dG�d=�dH�dI�dJ�dK�dL�dM�dN�dO�dR�dP�dQ�dR�dS�dT�d;�dU�dV�d��dW�dW�dW�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�da�d_�db�db�dc�d]�dd�de�df�dg�dh�di�d:�d�dj�dk�dl�dm�dn�do�dp�dq�dP�dn�d,�dn�dr�ds�dt�du�dv�dw�dx�dy�dz�d{�d|�ds�d}�d~�d�d��d�d�d��d��d��d��d��d��d��d�d�d�d�dz�dԐdz�d��d��d��d��d��dj�d��d��d��d��d��d_�dd�d]�dd�df�d��dm�d|�d��d��d@�d��d��dj�d��d��d��d��dn�d��d0�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dX�d��d��d��d��d��dt�d�d�d��d��d��d��dt�d��d��d��d��d��d��d�d��d��d��d��d��d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdːdW�d̐d5�d͐d�d�dΐdΐdϐdАdN�dN�dѐdҐdӐd�dԐdՐd֐dאdؐd(�d��d>�da�dd�dِdڐdڐdېdܐdݐdݐdސdߐd�d�d�d�d�d�d�d�d�d��d��dN�d�d�d>�d�d�d�d�d�d�d�d�d�d�d�d��d��da�d��d��d��d��d\�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��dp�dp�dd�d��d�dN�d�d�d�d�dh�d��d%�d,�d�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d
�d�d�d�d��d��d��d��d��d��dȐd��dĐdŐdƐdȐdz�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d�d�d�d�d"�d!�d$�d%�d&�d6�d'�d�d�d(�d)�d)�d*�d+�d,�d-�d�d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d8�d8�d9�d:�d;�d;�d7�dސd<�d=�d=�d7�dސd>�d?�d>�d?�dސdC�d�d��d7�d@�d@�d��dA�dB�dS�di�dl�dC�dD�dE�dF�dG�dАdH�dI�dI�dJ�dy�d'�dېdK�d��d��dL�dK�dM�d4�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dX�dY�d^�d��dc�dZ�d[�dZ�d[�d\�d_�dِd]�d^�d_�d`�da�db�dc�db�dc�dd�de�df�dg�dh�di�dj�dk�dl�dm�dn�dm�dn�do�dސd��dp�dq�dq�dr�ds�dt�du�dF�dF�d�dv�dS�dw�dc�dx�dy�dz�d{�d|�dِd_�dِd}�df�d~�d`�d~�di�dސd��dx�dڐde�d�d��d�d��d��d��d1�d��d��d��d��d��d��d��d��d��d��d��d��dJ�dq�d��d��d��d��d��d��d��d��d��d��d%�d)�dG�d`�d~�d��dݐd��d��d��d��d;�dِd��d��d��d��d��d��d��d��d^�d��d��dl�d�d��d��d��d��d��d��d��d>�d��d��d��d%�d��d��dِd��d��d��d��dG�d��d��d��d��d��d��d��d��d��d��d��d��dm�d�d��d��d��d��d��d��d��d��d��d��d��da�db�dc�di�d��d��d[�d�d��d��dZ�d�d�d��dd�d��d��de�df�d\�d�d��d��dg�dk�dj�dl�dm�d��d��d��d��ddÐdĐdŐdƐdǐdȐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdԐdӐdՐd֐dאdؐdِdڐdېdܐdݐdg�dސdߐdݐd�d�d�d�dd�d�d�d�d�d�d���ZiZiZx*ej�D]\ZZeee<e	e�ee<�%q
W[[�d�S(�z!HTML character entity references.�html5�name2codepoint�codepoint2name�
entitydefs������i�������i���i�i! i���������i�i���i�������i���i�i�i���i�iR������i�i�������i�i�i3 i�i�i`i���i�i�������i���i���ixi����������i5!i��&i'"i "��iH"����i i��i" i)"����i�i�ic&iE"�i�!i*"�i�!i  i�!�i�if&�������i"i i i�ia"i�����i� i"i�i"���iD i�ie"�>i�!i�!ie&i& �������i!i"i+"i��i"��i�i�!i�i)#�i�!i#i id"i
#i"i�%i i9 i �<�i ��i"i�i"�i i`"i"�i	"i�"��i�����iS��i> i�i�i�"i("����i�"��i"i0 i�"i�i�i���i2 i"i"i��"i�!i"i*#�i�!i	#i i!�i#i�i i: i i iai�"��i�i�i<"i`&i�"i�"i"i�"���i�"��i�i4"i�i�i	 �i���i"!i�!�i�!���i�i��i!i����i�i
 i )��AElig�Aacute�Acirc�AgraveZAlpha�Aring�Atilde�AumlZBeta�CcedilZChiZDaggerZDelta�ETH�Eacute�Ecirc�EgraveZEpsilonZEta�EumlZGamma�Iacute�Icirc�IgraveZIota�IumlZKappaZLambdaZMu�NtildeZNuZOElig�Oacute�Ocirc�OgraveZOmegaZOmicron�Oslash�Otilde�OumlZPhiZPiZPrimeZPsiZRhoZScaronZSigma�THORNZTauZTheta�Uacute�Ucirc�UgraveZUpsilon�UumlZXi�YacuteZYumlZZeta�aacute�acirc�acute�aelig�agraveZalefsymZalpha�amp�andZang�aringZasymp�atilde�aumlZbdquoZbeta�brvbarZbullZcap�ccedil�cedil�centZchiZcircZclubsZcong�copyZcrarrZcup�currenZdArrZdaggerZdarr�degZdeltaZdiams�divide�eacute�ecirc�egrave�emptyZemspZensp�epsilonZequivZeta�eth�eumlZeuroZexistZfnofZforall�frac12�frac14�frac34ZfraslZgamma�ge�gtZhArrZharrZheartsZhellip�iacute�icirc�iexcl�igraveZimageZinfin�intZiota�iquestZisin�iumlZkappaZlArr�lambdaZlang�laquoZlarrZlceilZldquo�leZlfloorZlowastZlozZlrmZlsaquoZlsquo�lt�macrZmdash�micro�middotZminusZmuZnabla�nbspZndash�neZni�notZnotinZnsub�ntildeZnu�oacute�ocircZoelig�ograveZolineZomegaZomicronZoplus�or�ordf�ordm�oslash�otildeZotimes�ouml�para�partZpermilZperpZphiZpiZpiv�plusmn�poundZprimeZprodZpropZpsi�quotZrArrZradicZrang�raquoZrarrZrceilZrdquo�real�regZrfloorZrhoZrlmZrsaquoZrsquoZsbquoZscaronZsdot�sect�shyZsigmaZsigmafZsimZspades�subZsube�sumZsup�sup1�sup2�sup3Zsupe�szligZtauZthere4ZthetaZthetasymZthinsp�thorn�tilde�timesZtradeZuArr�uacuteZuarr�ucirc�ugrave�umlZupsihZupsilon�uumlZweierpZxi�yacute�yen�yumlZzetaZzwjZzwnj�Á�áuĂuău∾u∿u∾̳�Â�â�´uАuа�Æ�æu⁡u𝔄u𝔞�À�àuℵuΑuαuĀuāu⨿�&u⩓u∧u⩕u⩜u⩘u⩚u∠u⦤u∡u⦨u⦩u⦪u⦫u⦬u⦭u⦮u⦯u∟u⊾u⦝u∢�Åu⍼uĄuąu𝔸u𝕒u≈u⩯u⩰u≊u≋�'�åu𝒜u𝒶u≔�*u≍�Ã�ã�Ä�äu∳u⨑u≌u϶u‵u∽u⋍u∖u⫧u⊽u⌆u⌅u⎵u⎶uБuбu„u∵u⦰uℬuΒuβuℶu≬u𝔅u𝔟u⋂u◯u⋃u⨀u⨁u⨂u⨆u★u▽u△u⨄u⋁u⋀u⤍u⧫u▪u▴u▾u◂u▸u␣u▒u░u▓u█u=⃥u≡⃥u⫭u⌐u𝔹u𝕓u⊥u⋈u⧉u╗u╖u╕u┐u╔u╓u╒u┌u═u─u╦u╤u╥u┬u╩u╧u╨u┴u⊟u⊞u⊠u╝u╜u╛u┘u╚u╙u╘u└u║u│u╬u╫u╪u┼u╣u╢u╡u┤u╠u╟u╞u├u˘�¦u𝒷u⁏�\u⧅u⟈u•u≎u⪮u≏uĆuću⋒u∩u⩄u⩉u⩋u⩇u⩀uⅅu∩︀u⁁uˇuℭu⩍uČuč�Ç�çuĈuĉu∰u⩌u⩐uĊuċ�¸u⦲�¢�·u𝔠uЧuчu✓uΧuχu○uˆu≗u↺u↻u⊛u⊚u⊝u⊙�®uⓈu⊖u⊕u⊗u⧃u⨐u⫯u⧂u∲u”u’u♣u∷�:u⩴�,�@u∁u∘uℂu≅u⩭u≡u∯u∮u𝕔u∐�©u℗u↵u⨯u✗u𝒞u𝒸u⫏u⫑u⫐u⫒u⋯u⤸u⤵u⋞u⋟u↶u⤽u⋓u∪u⩈u⩆u⩊u⊍u⩅u∪︀u↷u⤼u⋎u⋏�¤u∱u⌭u‡u†uℸu↡u⇓u↓u‐u⫤u⊣u⤏u˝uĎuďuДuдuⅆu⇊u⤑u⩷�°u∇uΔuδu⦱u⥿u𝔇u𝔡u⥥u⇃u⇂u˙�`u˜u⋄u♦�¨uϝu⋲�÷u⋇uЂuђu⌞u⌍�$u𝔻u𝕕u⃜u≐u≑u∸u∔u⊡u⇐u⇔u⟸u⟺u⟹u⇒u⊨u⇑u⇕u∥u⤓u⇵ȗu⥐u⥞u↽u⥖u⥟u⇁u⥗u⊤u↧u⤐u⌟u⌌u𝒟u𝒹uЅuѕu⧶uĐuđu⋱u▿u⥯u⦦uЏuџu⟿�É�éu⩮uĚuěu≖�Ê�êu≕uЭuэuĖuėuⅇu≒u𝔈u𝔢u⪚�È�èu⪖u⪘u⪙u∈u⏧uℓu⪕u⪗uĒuēu∅u◻u▫u u u uŊuŋu uĘuęu𝔼u𝕖u⋕u⧣u⩱uεuΕuϵu≂u⩵�=u≟u⇌u⩸u⧥u⥱u≓uℰuℯu⩳uΗuη�Ð�ð�Ë�ëu€�!u∃uФuфu♀uffiuffufflu𝔉u𝔣ufiu◼Zfju♭uflu▱uƒu𝔽u𝕗u∀u⋔u⫙uℱu⨍�½u⅓�¼u⅕u⅙u⅛u⅔u⅖�¾u⅗u⅜u⅘u⅚u⅝u⅞u⁄u⌢u𝒻uǵuΓuγuϜu⪆uĞuğuĢuĜuĝuГuгuĠuġu≧u≥u⪌u⋛u⩾u⪩u⪀u⪂u⪄u⋛︀u⪔u𝔊u𝔤u⋙u≫uℷuЃuѓu≷u⪥u⪒u⪤u⪊u≩u⪈u⋧u𝔾u𝕘u⪢u≳u𝒢uℊu⪎u⪐�>u⪧u⩺u⋗u⦕u⩼u⥸u≩︀u uℋuЪuъu↔u⥈u↭�^uℏuĤuĥu♥u…u⊹uℌu𝔥u⤥u⤦u⇿u∻u↩u↪uℍu𝕙u―u𝒽uĦuħu⁃�Í�íu⁣�Î�îuИuиuİuЕuе�¡uℑu𝔦�Ì�ìuⅈu⨌u∭u⧜u℩uIJuijuĪuīuℐuıu⊷uƵu℅u∞u⧝u∬u∫u⊺uℤu⨗u⨼u⁢uЁuёuĮuįu𝕀u𝕚uΙuι�¿u𝒾u⋵u⋹u⋴u⋳uĨuĩuІuі�Ï�ïuĴuĵuЙuйu𝔍u𝔧uȷu𝕁u𝕛u𝒥u𝒿uЈuјuЄuєuΚuκuϰuĶuķuКuкu𝔎u𝔨uĸuХuхuЌuќu𝕂u𝕜u𝒦u𝓀u⇚uĹuĺu⦴uℒuΛuλu⟪u⟨u⦑u⪅�«u↞u←u⇤u⤟u⤝u↫u⤹u⥳u↢u⪫u⤛u⤙u⪭u⪭︀u⤎u⤌u❲�{�[u⦋u⦏u⦍uĽuľuĻuļu⌈uЛuлu⤶u“u⥧u⥋u↲u≦u≤u⇆u⟦u⥡u⥙u⌊u↼u⇇u⇋u⥎u↤u⥚u⋋u⊲u⧏u⊴u⥑u⥠u↿u⥘u⥒u⪋u⋚u⩽u⪨u⩿u⪁u⪃u⋚︀u⪓u⋖u≶u⪡u≲u⥼u𝔏u𝔩u⪑u⥢u⥪u▄uЉuљu⋘u≪u⥫u◺uĿuŀu⎰u⪉u≨u⪇u⋦u⟬u⇽u⟵u⟷u⟼u⟶u↬u⦅u𝕃u𝕝u⨭u⨴u∗�_u↙u↘u◊�(u⦓u⥭u‎u⊿u‹u𝓁u↰u⪍u⪏u‘u‚uŁuł�<u⪦u⩹u⋉u⥶u⩻u◃u⦖u⥊u⥦u≨︀�¯u♂u✠u⤅u↦u↥u▮u⨩uМuмu—u∺u uℳu𝔐u𝔪u℧�µu∣u⫰u−u⨪u∓u⫛u⊧u𝕄u𝕞u𝓂uΜuμu⊸uŃuńu∠⃒u≉u⩰̸u≋̸uʼnu♮uℕ� u≎̸u≏̸u⩃uŇuňuŅuņu≇u⩭̸u⩂uНuнu–u≠u⤤u⇗u↗u≐̸u​u≢u⤨u≂̸�
u∄u𝔑u𝔫u≧̸u≱u⩾̸u⋙̸u≵u≫⃒u≯u≫̸u⇎u↮u⫲u∋u⋼u⋺uЊuњu⇍u↚u‥u≦̸u≰u⩽̸u≮u⋘̸u≴u≪⃒u⋪u⋬u≪̸u∤u⁠u𝕟�¬u⫬u≭u∦u∉u≹u⋵̸u⋹̸u⋷u⋶u⧏̸u≸u⪢̸u⪡̸u∌u⋾u⋽u⊀u⪯̸u⋠u⋫u⧐̸u⋭u⊏̸u⋢u⊐̸u⋣u⊂⃒u⊈u⊁u⪰̸u⋡u≿̸u⊃⃒u⊉u≁u≄u⫽⃥u∂̸u⨔u⇏u↛u⤳̸u↝̸u𝒩u𝓃u⊄u⫅̸u⊅u⫆̸�Ñ�ñuΝuν�#u№u u≍⃒u⊯u⊮u⊭u⊬u≥⃒u>⃒u⤄u⧞u⤂u≤⃒u<⃒u⊴⃒u⤃u⊵⃒u∼⃒u⤣u⇖u↖u⤧�Ó�ó�Ô�ôuОuоuŐuőu⨸u⦼uŒuœu⦿u𝔒u𝔬u˛�Ò�òu⧁u⦵uΩu⦾u⦻u‾u⧀uŌuōuωuΟuοu⦶u𝕆u𝕠u⦷u⦹u⩔u∨u⩝uℴ�ª�ºu⊶u⩖u⩗u⩛u𝒪�Ø�øu⊘�Õ�õu⨷u⨶�Ö�öu⌽u⏞u⎴u⏜�¶u⫳u⫽u∂uПuп�%�.u‰u‱u𝔓u𝔭uΦuφuϕu☎uΠuπuϖuℎ�+u⨣u⨢u⨥u⩲�±u⨦u⨧u⨕uℙu𝕡�£u⪻u≺u⪷u≼u⪳u⪯u≾u⪹u⪵u⋨u″u′u∏u⌮u⌒u⌓u∝u⊰u𝒫u𝓅uΨuψu u𝔔u𝔮uℚu𝕢u⁗u𝒬u𝓆u⨖�?�"u⇛u∽̱uŔuŕu√u⦳u⟫u⟩u⦒u⦥�»u↠u→u⥵u⇥u⤠u⤳u⤞u⥅u⥴u⤖u↣u↝u⤜u⤚u∶u❳�}�]u⦌u⦎u⦐uŘuřuŖuŗu⌉uРuрu⤷u⥩u↳uℜuℛuℝu▭u⥽u⌋u𝔯u⥤u⇀u⥬uΡuρuϱu⇄u⟧u⥝u⥕u⇉u⊢u⥛u⋌u⊳u⧐u⊵u⥏u⥜u↾u⥔u⥓u˚u‏u⎱u⫮u⟭u⇾u⦆u𝕣u⨮u⨵u⥰�)u⦔u⨒u›u𝓇u↱u⋊u▹u⧎u⧴u⥨u℞uŚuśu⪼u≻u⪸uŠušu≽u⪴u⪰uŞuşuŜuŝu⪺u⪶u⋩u⨓u≿uСuсu⋅u⩦u⇘�§�;u⤩u✶u𝔖u𝔰u♯uЩuщuШuшu↑�­uΣuσuςu∼u⩪u≃u⪞u⪠u⪝u⪟u≆u⨤u⥲u⨳u⧤u⌣u⪪u⪬u⪬︀uЬuь�/u⧄u⌿u𝕊u𝕤u♠u⊓u⊓︀u⊔u⊔︀u⊏u⊑u⊐u⊒u□u𝒮u𝓈u⋆u☆u⋐u⊂u⪽u⫅u⊆u⫃u⫁u⫋u⊊u⪿u⥹u⫇u⫕u⫓u∑u♪�¹�²�³u⋑u⊃u⪾u⫘u⫆u⊇u⫄u⟉u⫗u⥻u⫂u⫌u⊋u⫀u⫈u⫔u⫖u⇙u⤪�ß�	u⌖uΤuτuŤuťuŢuţuТuтu⃛u⌕u𝔗u𝔱u∴uΘuθuϑu  u �Þ�þ�×u⨱u⨰u⌶u⫱u𝕋u𝕥u⫚u‴u™u▵u≜u◬u⨺u⨹u⧍u⨻u⏢u𝒯u𝓉uЦuцuЋuћuŦuŧ�Ú�úu↟u⥉uЎuўuŬuŭ�Û�ûuУuуu⇅uŰuűu⥮u⥾u𝔘u𝔲�Ù�ùu⥣u▀u⌜u⌏u◸uŪuūu⏟u⏝u⊎uŲuųu𝕌u𝕦u⤒u↕uϒuυuΥu⇈u⌝u⌎uŮuůu◹u𝒰u𝓊u⋰uŨuũ�Ü�üu⦧u⦜u⊊︀u⫋︀u⊋︀u⫌︀u⫫u⫨u⫩uВuвu⊫u⊩u⫦u⊻u≚u⋮u‖�|u❘u≀u𝔙u𝔳u𝕍u𝕧u𝒱u𝓋u⊪u⦚uŴuŵu⩟u≙u℘u𝔚u𝔴u𝕎u𝕨u𝒲u𝓌u𝔛u𝔵uΞuξu⋻u𝕏u𝕩u𝒳u𝓍�Ý�ýuЯuяuŶuŷuЫuы�¥u𝔜u𝔶uЇuїu𝕐u𝕪u𝒴u𝓎uЮuю�ÿuŸuŹuźuŽužuЗuзuŻużuℨuΖuζu𝔷uЖuжu⇝u𝕫u𝒵u𝓏u‍u‌(�rjr�zAacute;zaacute;zAbreve;zabreve;zac;zacd;zacE;rkr�zAcirc;zacirc;r�zacute;zAcy;zacy;rir�zAElig;zaelig;zaf;zAfr;zafr;rlr�zAgrave;zagrave;zalefsym;zaleph;zAlpha;zalpha;zAmacr;zamacr;zamalg;ZAMPr�zAMP;zamp;zAnd;zand;zandand;zandd;z	andslope;zandv;zang;zange;zangle;zangmsd;z	angmsdaa;z	angmsdab;z	angmsdac;z	angmsdad;z	angmsdae;z	angmsdaf;z	angmsdag;z	angmsdah;zangrt;zangrtvb;z	angrtvbd;zangsph;zangst;zangzarr;zAogon;zaogon;zAopf;zaopf;zap;zapacir;zapE;zape;zapid;zapos;zApplyFunction;zapprox;z	approxeq;rmr�zAring;zaring;zAscr;zascr;zAssign;zast;zasymp;zasympeq;rnr�zAtilde;zatilde;ror�zAuml;zauml;z	awconint;zawint;z	backcong;zbackepsilon;z
backprime;zbacksim;z
backsimeq;z
Backslash;zBarv;zbarvee;zBarwed;zbarwed;z	barwedge;zbbrk;z	bbrktbrk;zbcong;zBcy;zbcy;zbdquo;zbecaus;zBecause;zbecause;zbemptyv;zbepsi;zbernou;zBernoullis;zBeta;zbeta;zbeth;zbetween;zBfr;zbfr;zbigcap;zbigcirc;zbigcup;zbigodot;z	bigoplus;z
bigotimes;z	bigsqcup;zbigstar;zbigtriangledown;zbigtriangleup;z	biguplus;zbigvee;z	bigwedge;zbkarow;z
blacklozenge;zblacksquare;zblacktriangle;zblacktriangledown;zblacktriangleleft;zblacktriangleright;zblank;zblk12;zblk14;zblk34;zblock;zbne;zbnequiv;zbNot;zbnot;zBopf;zbopf;zbot;zbottom;zbowtie;zboxbox;zboxDL;zboxDl;zboxdL;zboxdl;zboxDR;zboxDr;zboxdR;zboxdr;zboxH;zboxh;zboxHD;zboxHd;zboxhD;zboxhd;zboxHU;zboxHu;zboxhU;zboxhu;z	boxminus;zboxplus;z	boxtimes;zboxUL;zboxUl;zboxuL;zboxul;zboxUR;zboxUr;zboxuR;zboxur;zboxV;zboxv;zboxVH;zboxVh;zboxvH;zboxvh;zboxVL;zboxVl;zboxvL;zboxvl;zboxVR;zboxVr;zboxvR;zboxvr;zbprime;zBreve;zbreve;r�zbrvbar;zBscr;zbscr;zbsemi;zbsim;zbsime;zbsol;zbsolb;z	bsolhsub;zbull;zbullet;zbump;zbumpE;zbumpe;zBumpeq;zbumpeq;zCacute;zcacute;zCap;zcap;zcapand;z	capbrcup;zcapcap;zcapcup;zcapdot;zCapitalDifferentialD;zcaps;zcaret;zcaron;zCayleys;zccaps;zCcaron;zccaron;rpr�zCcedil;zccedil;zCcirc;zccirc;zCconint;zccups;zccupssm;zCdot;zcdot;r�zcedil;zCedilla;zcemptyv;r�zcent;z
CenterDot;z
centerdot;zCfr;zcfr;zCHcy;zchcy;zcheck;z
checkmark;zChi;zchi;zcir;zcirc;zcirceq;zcirclearrowleft;zcirclearrowright;zcircledast;zcircledcirc;zcircleddash;z
CircleDot;z	circledR;z	circledS;zCircleMinus;zCirclePlus;zCircleTimes;zcirE;zcire;z	cirfnint;zcirmid;zcirscir;zClockwiseContourIntegral;zCloseCurlyDoubleQuote;zCloseCurlyQuote;zclubs;z	clubsuit;zColon;zcolon;zColone;zcolone;zcoloneq;zcomma;zcommat;zcomp;zcompfn;zcomplement;z
complexes;zcong;zcongdot;z
Congruent;zConint;zconint;zContourIntegral;zCopf;zcopf;zcoprod;z
Coproduct;ZCOPYr�zCOPY;zcopy;zcopysr;z CounterClockwiseContourIntegral;zcrarr;zCross;zcross;zCscr;zcscr;zcsub;zcsube;zcsup;zcsupe;zctdot;zcudarrl;zcudarrr;zcuepr;zcuesc;zcularr;zcularrp;zCup;zcup;z	cupbrcap;zCupCap;zcupcap;zcupcup;zcupdot;zcupor;zcups;zcurarr;zcurarrm;zcurlyeqprec;zcurlyeqsucc;z	curlyvee;zcurlywedge;r�zcurren;zcurvearrowleft;zcurvearrowright;zcuvee;zcuwed;z	cwconint;zcwint;zcylcty;zDagger;zdagger;zdaleth;zDarr;zdArr;zdarr;zdash;zDashv;zdashv;zdbkarow;zdblac;zDcaron;zdcaron;zDcy;zdcy;zDD;zdd;zddagger;zddarr;z	DDotrahd;zddotseq;r�zdeg;zDel;zDelta;zdelta;zdemptyv;zdfisht;zDfr;zdfr;zdHar;zdharl;zdharr;zDiacriticalAcute;zDiacriticalDot;zDiacriticalDoubleAcute;zDiacriticalGrave;zDiacriticalTilde;zdiam;zDiamond;zdiamond;zdiamondsuit;zdiams;zdie;zDifferentialD;zdigamma;zdisin;zdiv;r�zdivide;zdivideontimes;zdivonx;zDJcy;zdjcy;zdlcorn;zdlcrop;zdollar;zDopf;zdopf;zDot;zdot;zDotDot;zdoteq;z	doteqdot;z	DotEqual;z	dotminus;zdotplus;z
dotsquare;zdoublebarwedge;zDoubleContourIntegral;z
DoubleDot;zDoubleDownArrow;zDoubleLeftArrow;zDoubleLeftRightArrow;zDoubleLeftTee;zDoubleLongLeftArrow;zDoubleLongLeftRightArrow;zDoubleLongRightArrow;zDoubleRightArrow;zDoubleRightTee;zDoubleUpArrow;zDoubleUpDownArrow;zDoubleVerticalBar;z
DownArrow;z
Downarrow;z
downarrow;z
DownArrowBar;zDownArrowUpArrow;z
DownBreve;zdowndownarrows;zdownharpoonleft;zdownharpoonright;zDownLeftRightVector;zDownLeftTeeVector;zDownLeftVector;zDownLeftVectorBar;zDownRightTeeVector;zDownRightVector;zDownRightVectorBar;zDownTee;z
DownTeeArrow;z	drbkarow;zdrcorn;zdrcrop;zDscr;zdscr;zDScy;zdscy;zdsol;zDstrok;zdstrok;zdtdot;zdtri;zdtrif;zduarr;zduhar;zdwangle;zDZcy;zdzcy;z	dzigrarr;rrr�zEacute;zeacute;zeaster;zEcaron;zecaron;zecir;rsr�zEcirc;zecirc;zecolon;zEcy;zecy;zeDDot;zEdot;zeDot;zedot;zee;zefDot;zEfr;zefr;zeg;rtr�zEgrave;zegrave;zegs;zegsdot;zel;zElement;z	elinters;zell;zels;zelsdot;zEmacr;zemacr;zempty;z	emptyset;zEmptySmallSquare;zemptyv;zEmptyVerySmallSquare;zemsp13;zemsp14;zemsp;zENG;zeng;zensp;zEogon;zeogon;zEopf;zeopf;zepar;zeparsl;zeplus;zepsi;zEpsilon;zepsilon;zepsiv;zeqcirc;zeqcolon;zeqsim;zeqslantgtr;zeqslantless;zEqual;zequals;zEqualTilde;zequest;zEquilibrium;zequiv;zequivDD;z	eqvparsl;zerarr;zerDot;zEscr;zescr;zesdot;zEsim;zesim;zEta;zeta;rqr�zETH;zeth;rur�zEuml;zeuml;zeuro;zexcl;zexist;zExists;zexpectation;z
ExponentialE;z
exponentiale;zfallingdotseq;zFcy;zfcy;zfemale;zffilig;zfflig;zffllig;zFfr;zffr;zfilig;zFilledSmallSquare;zFilledVerySmallSquare;zfjlig;zflat;zfllig;zfltns;zfnof;zFopf;zfopf;zForAll;zforall;zfork;zforkv;zFouriertrf;z	fpartint;r�zfrac12;zfrac13;r�zfrac14;zfrac15;zfrac16;zfrac18;zfrac23;zfrac25;r�zfrac34;zfrac35;zfrac38;zfrac45;zfrac56;zfrac58;zfrac78;zfrasl;zfrown;zFscr;zfscr;zgacute;zGamma;zgamma;zGammad;zgammad;zgap;zGbreve;zgbreve;zGcedil;zGcirc;zgcirc;zGcy;zgcy;zGdot;zgdot;zgE;zge;zgEl;zgel;zgeq;zgeqq;z	geqslant;zges;zgescc;zgesdot;zgesdoto;z	gesdotol;zgesl;zgesles;zGfr;zgfr;zGg;zgg;zggg;zgimel;zGJcy;zgjcy;zgl;zgla;zglE;zglj;zgnap;z	gnapprox;zgnE;zgne;zgneq;zgneqq;zgnsim;zGopf;zgopf;zgrave;z
GreaterEqual;zGreaterEqualLess;zGreaterFullEqual;zGreaterGreater;zGreaterLess;zGreaterSlantEqual;z
GreaterTilde;zGscr;zgscr;zgsim;zgsime;zgsiml;ZGTr�zGT;zGt;zgt;zgtcc;zgtcir;zgtdot;zgtlPar;zgtquest;z
gtrapprox;zgtrarr;zgtrdot;z
gtreqless;zgtreqqless;zgtrless;zgtrsim;z
gvertneqq;zgvnE;zHacek;zhairsp;zhalf;zhamilt;zHARDcy;zhardcy;zhArr;zharr;zharrcir;zharrw;zHat;zhbar;zHcirc;zhcirc;zhearts;z
heartsuit;zhellip;zhercon;zHfr;zhfr;z
HilbertSpace;z	hksearow;z	hkswarow;zhoarr;zhomtht;zhookleftarrow;zhookrightarrow;zHopf;zhopf;zhorbar;zHorizontalLine;zHscr;zhscr;zhslash;zHstrok;zhstrok;z
HumpDownHump;z
HumpEqual;zhybull;zhyphen;rvr�zIacute;ziacute;zic;rwr�zIcirc;zicirc;zIcy;zicy;zIdot;zIEcy;ziecy;r�ziexcl;ziff;zIfr;zifr;rxr�zIgrave;zigrave;zii;ziiiint;ziiint;ziinfin;ziiota;zIJlig;zijlig;zIm;zImacr;zimacr;zimage;zImaginaryI;z	imagline;z	imagpart;zimath;zimof;zimped;zImplies;zin;zincare;zinfin;z	infintie;zinodot;zInt;zint;zintcal;z	integers;z	Integral;z	intercal;z
Intersection;z	intlarhk;zintprod;zInvisibleComma;zInvisibleTimes;zIOcy;ziocy;zIogon;ziogon;zIopf;ziopf;zIota;ziota;ziprod;r�ziquest;zIscr;ziscr;zisin;zisindot;zisinE;zisins;zisinsv;zisinv;zit;zItilde;zitilde;zIukcy;ziukcy;ryr�zIuml;ziuml;zJcirc;zjcirc;zJcy;zjcy;zJfr;zjfr;zjmath;zJopf;zjopf;zJscr;zjscr;zJsercy;zjsercy;zJukcy;zjukcy;zKappa;zkappa;zkappav;zKcedil;zkcedil;zKcy;zkcy;zKfr;zkfr;zkgreen;zKHcy;zkhcy;zKJcy;zkjcy;zKopf;zkopf;zKscr;zkscr;zlAarr;zLacute;zlacute;z	laemptyv;zlagran;zLambda;zlambda;zLang;zlang;zlangd;zlangle;zlap;zLaplacetrf;r�zlaquo;zLarr;zlArr;zlarr;zlarrb;zlarrbfs;zlarrfs;zlarrhk;zlarrlp;zlarrpl;zlarrsim;zlarrtl;zlat;zlAtail;zlatail;zlate;zlates;zlBarr;zlbarr;zlbbrk;zlbrace;zlbrack;zlbrke;zlbrksld;zlbrkslu;zLcaron;zlcaron;zLcedil;zlcedil;zlceil;zlcub;zLcy;zlcy;zldca;zldquo;zldquor;zldrdhar;z	ldrushar;zldsh;zlE;zle;zLeftAngleBracket;z
LeftArrow;z
Leftarrow;z
leftarrow;z
LeftArrowBar;zLeftArrowRightArrow;zleftarrowtail;zLeftCeiling;zLeftDoubleBracket;zLeftDownTeeVector;zLeftDownVector;zLeftDownVectorBar;z
LeftFloor;zleftharpoondown;zleftharpoonup;zleftleftarrows;zLeftRightArrow;zLeftrightarrow;zleftrightarrow;zleftrightarrows;zleftrightharpoons;zleftrightsquigarrow;zLeftRightVector;zLeftTee;z
LeftTeeArrow;zLeftTeeVector;zleftthreetimes;z
LeftTriangle;zLeftTriangleBar;zLeftTriangleEqual;zLeftUpDownVector;zLeftUpTeeVector;z
LeftUpVector;zLeftUpVectorBar;zLeftVector;zLeftVectorBar;zlEg;zleg;zleq;zleqq;z	leqslant;zles;zlescc;zlesdot;zlesdoto;z	lesdotor;zlesg;zlesges;zlessapprox;zlessdot;z
lesseqgtr;zlesseqqgtr;zLessEqualGreater;zLessFullEqual;zLessGreater;zlessgtr;z	LessLess;zlesssim;zLessSlantEqual;z
LessTilde;zlfisht;zlfloor;zLfr;zlfr;zlg;zlgE;zlHar;zlhard;zlharu;zlharul;zlhblk;zLJcy;zljcy;zLl;zll;zllarr;z	llcorner;zLleftarrow;zllhard;zlltri;zLmidot;zlmidot;zlmoust;zlmoustache;zlnap;z	lnapprox;zlnE;zlne;zlneq;zlneqq;zlnsim;zloang;zloarr;zlobrk;zLongLeftArrow;zLongleftarrow;zlongleftarrow;zLongLeftRightArrow;zLongleftrightarrow;zlongleftrightarrow;zlongmapsto;zLongRightArrow;zLongrightarrow;zlongrightarrow;zlooparrowleft;zlooparrowright;zlopar;zLopf;zlopf;zloplus;zlotimes;zlowast;zlowbar;zLowerLeftArrow;zLowerRightArrow;zloz;zlozenge;zlozf;zlpar;zlparlt;zlrarr;z	lrcorner;zlrhar;zlrhard;zlrm;zlrtri;zlsaquo;zLscr;zlscr;zLsh;zlsh;zlsim;zlsime;zlsimg;zlsqb;zlsquo;zlsquor;zLstrok;zlstrok;ZLTr�zLT;zLt;zlt;zltcc;zltcir;zltdot;zlthree;zltimes;zltlarr;zltquest;zltri;zltrie;zltrif;zltrPar;z	lurdshar;zluruhar;z
lvertneqq;zlvnE;r�zmacr;zmale;zmalt;zmaltese;zMap;zmap;zmapsto;zmapstodown;zmapstoleft;z	mapstoup;zmarker;zmcomma;zMcy;zmcy;zmdash;zmDDot;zmeasuredangle;zMediumSpace;z
Mellintrf;zMfr;zmfr;zmho;r�zmicro;zmid;zmidast;zmidcir;r�zmiddot;zminus;zminusb;zminusd;zminusdu;z
MinusPlus;zmlcp;zmldr;zmnplus;zmodels;zMopf;zmopf;zmp;zMscr;zmscr;zmstpos;zMu;zmu;z	multimap;zmumap;znabla;zNacute;znacute;znang;znap;znapE;znapid;znapos;znapprox;znatur;znatural;z	naturals;r�znbsp;znbump;znbumpe;zncap;zNcaron;zncaron;zNcedil;zncedil;zncong;z	ncongdot;zncup;zNcy;zncy;zndash;zne;znearhk;zneArr;znearr;znearrow;znedot;zNegativeMediumSpace;zNegativeThickSpace;zNegativeThinSpace;zNegativeVeryThinSpace;znequiv;znesear;znesim;zNestedGreaterGreater;zNestedLessLess;zNewLine;znexist;znexists;zNfr;znfr;zngE;znge;zngeq;zngeqq;z
ngeqslant;znges;znGg;zngsim;znGt;zngt;zngtr;znGtv;znhArr;znharr;znhpar;zni;znis;znisd;zniv;zNJcy;znjcy;znlArr;znlarr;znldr;znlE;znle;znLeftarrow;znleftarrow;znLeftrightarrow;znleftrightarrow;znleq;znleqq;z
nleqslant;znles;znless;znLl;znlsim;znLt;znlt;znltri;znltrie;znLtv;znmid;zNoBreak;zNonBreakingSpace;zNopf;znopf;r�zNot;znot;z
NotCongruent;z
NotCupCap;zNotDoubleVerticalBar;zNotElement;z	NotEqual;zNotEqualTilde;z
NotExists;zNotGreater;zNotGreaterEqual;zNotGreaterFullEqual;zNotGreaterGreater;zNotGreaterLess;zNotGreaterSlantEqual;zNotGreaterTilde;zNotHumpDownHump;z
NotHumpEqual;znotin;z	notindot;znotinE;znotinva;znotinvb;znotinvc;zNotLeftTriangle;zNotLeftTriangleBar;zNotLeftTriangleEqual;zNotLess;z
NotLessEqual;zNotLessGreater;zNotLessLess;zNotLessSlantEqual;z
NotLessTilde;zNotNestedGreaterGreater;zNotNestedLessLess;znotni;znotniva;znotnivb;znotnivc;zNotPrecedes;zNotPrecedesEqual;zNotPrecedesSlantEqual;zNotReverseElement;zNotRightTriangle;zNotRightTriangleBar;zNotRightTriangleEqual;zNotSquareSubset;zNotSquareSubsetEqual;zNotSquareSuperset;zNotSquareSupersetEqual;z
NotSubset;zNotSubsetEqual;zNotSucceeds;zNotSucceedsEqual;zNotSucceedsSlantEqual;zNotSucceedsTilde;zNotSuperset;zNotSupersetEqual;z	NotTilde;zNotTildeEqual;zNotTildeFullEqual;zNotTildeTilde;zNotVerticalBar;znpar;z
nparallel;znparsl;znpart;znpolint;znpr;znprcue;znpre;znprec;znpreceq;znrArr;znrarr;znrarrc;znrarrw;znRightarrow;znrightarrow;znrtri;znrtrie;znsc;znsccue;znsce;zNscr;znscr;z
nshortmid;znshortparallel;znsim;znsime;znsimeq;znsmid;znspar;znsqsube;znsqsupe;znsub;znsubE;znsube;znsubset;z
nsubseteq;znsubseteqq;znsucc;znsucceq;znsup;znsupE;znsupe;znsupset;z
nsupseteq;znsupseteqq;zntgl;rzr�zNtilde;zntilde;zntlg;zntriangleleft;zntrianglelefteq;zntriangleright;zntrianglerighteq;zNu;znu;znum;znumero;znumsp;znvap;znVDash;znVdash;znvDash;znvdash;znvge;znvgt;znvHarr;znvinfin;znvlArr;znvle;znvlt;znvltrie;znvrArr;znvrtrie;znvsim;znwarhk;znwArr;znwarr;znwarrow;znwnear;r{r�zOacute;zoacute;zoast;zocir;r|r�zOcirc;zocirc;zOcy;zocy;zodash;zOdblac;zodblac;zodiv;zodot;zodsold;zOElig;zoelig;zofcir;zOfr;zofr;zogon;r}r�zOgrave;zograve;zogt;zohbar;zohm;zoint;zolarr;zolcir;zolcross;zoline;zolt;zOmacr;zomacr;zOmega;zomega;zOmicron;zomicron;zomid;zominus;zOopf;zoopf;zopar;zOpenCurlyDoubleQuote;zOpenCurlyQuote;zoperp;zoplus;zOr;zor;zorarr;zord;zorder;zorderof;r�zordf;r�zordm;zorigof;zoror;zorslope;zorv;zoS;zOscr;zoscr;r~r�zOslash;zoslash;zosol;rr�zOtilde;zotilde;zOtimes;zotimes;z	otimesas;r�r�zOuml;zouml;zovbar;zOverBar;z
OverBrace;zOverBracket;zOverParenthesis;zpar;r�zpara;z	parallel;zparsim;zparsl;zpart;z	PartialD;zPcy;zpcy;zpercnt;zperiod;zpermil;zperp;zpertenk;zPfr;zpfr;zPhi;zphi;zphiv;zphmmat;zphone;zPi;zpi;z
pitchfork;zpiv;zplanck;zplanckh;zplankv;zplus;z	plusacir;zplusb;zpluscir;zplusdo;zplusdu;zpluse;z
PlusMinus;r�zplusmn;zplussim;zplustwo;zpm;zPoincareplane;z	pointint;zPopf;zpopf;r�zpound;zPr;zpr;zprap;zprcue;zprE;zpre;zprec;zprecapprox;zpreccurlyeq;z	Precedes;zPrecedesEqual;zPrecedesSlantEqual;zPrecedesTilde;zpreceq;zprecnapprox;z	precneqq;z	precnsim;zprecsim;zPrime;zprime;zprimes;zprnap;zprnE;zprnsim;zprod;zProduct;z	profalar;z	profline;z	profsurf;zprop;zProportion;z
Proportional;zpropto;zprsim;zprurel;zPscr;zpscr;zPsi;zpsi;zpuncsp;zQfr;zqfr;zqint;zQopf;zqopf;zqprime;zQscr;zqscr;zquaternions;zquatint;zquest;zquesteq;ZQUOTr�zQUOT;zquot;zrAarr;zrace;zRacute;zracute;zradic;z	raemptyv;zRang;zrang;zrangd;zrange;zrangle;r�zraquo;zRarr;zrArr;zrarr;zrarrap;zrarrb;zrarrbfs;zrarrc;zrarrfs;zrarrhk;zrarrlp;zrarrpl;zrarrsim;zRarrtl;zrarrtl;zrarrw;zrAtail;zratail;zratio;z
rationals;zRBarr;zrBarr;zrbarr;zrbbrk;zrbrace;zrbrack;zrbrke;zrbrksld;zrbrkslu;zRcaron;zrcaron;zRcedil;zrcedil;zrceil;zrcub;zRcy;zrcy;zrdca;zrdldhar;zrdquo;zrdquor;zrdsh;zRe;zreal;zrealine;z	realpart;zreals;zrect;ZREGr�zREG;zreg;zReverseElement;zReverseEquilibrium;zReverseUpEquilibrium;zrfisht;zrfloor;zRfr;zrfr;zrHar;zrhard;zrharu;zrharul;zRho;zrho;zrhov;zRightAngleBracket;zRightArrow;zRightarrow;zrightarrow;zRightArrowBar;zRightArrowLeftArrow;zrightarrowtail;z
RightCeiling;zRightDoubleBracket;zRightDownTeeVector;zRightDownVector;zRightDownVectorBar;zRightFloor;zrightharpoondown;zrightharpoonup;zrightleftarrows;zrightleftharpoons;zrightrightarrows;zrightsquigarrow;z	RightTee;zRightTeeArrow;zRightTeeVector;zrightthreetimes;zRightTriangle;zRightTriangleBar;zRightTriangleEqual;zRightUpDownVector;zRightUpTeeVector;zRightUpVector;zRightUpVectorBar;zRightVector;zRightVectorBar;zring;z
risingdotseq;zrlarr;zrlhar;zrlm;zrmoust;zrmoustache;zrnmid;zroang;zroarr;zrobrk;zropar;zRopf;zropf;zroplus;zrotimes;z
RoundImplies;zrpar;zrpargt;z	rppolint;zrrarr;zRrightarrow;zrsaquo;zRscr;zrscr;zRsh;zrsh;zrsqb;zrsquo;zrsquor;zrthree;zrtimes;zrtri;zrtrie;zrtrif;z	rtriltri;zRuleDelayed;zruluhar;zrx;zSacute;zsacute;zsbquo;zSc;zsc;zscap;zScaron;zscaron;zsccue;zscE;zsce;zScedil;zscedil;zScirc;zscirc;zscnap;zscnE;zscnsim;z	scpolint;zscsim;zScy;zscy;zsdot;zsdotb;zsdote;zsearhk;zseArr;zsearr;zsearrow;r�zsect;zsemi;zseswar;z	setminus;zsetmn;zsext;zSfr;zsfr;zsfrown;zsharp;zSHCHcy;zshchcy;zSHcy;zshcy;zShortDownArrow;zShortLeftArrow;z	shortmid;zshortparallel;zShortRightArrow;z
ShortUpArrow;r�zshy;zSigma;zsigma;zsigmaf;zsigmav;zsim;zsimdot;zsime;zsimeq;zsimg;zsimgE;zsiml;zsimlE;zsimne;zsimplus;zsimrarr;zslarr;zSmallCircle;zsmallsetminus;zsmashp;z	smeparsl;zsmid;zsmile;zsmt;zsmte;zsmtes;zSOFTcy;zsoftcy;zsol;zsolb;zsolbar;zSopf;zsopf;zspades;z
spadesuit;zspar;zsqcap;zsqcaps;zsqcup;zsqcups;zSqrt;zsqsub;zsqsube;z	sqsubset;zsqsubseteq;zsqsup;zsqsupe;z	sqsupset;zsqsupseteq;zsqu;zSquare;zsquare;zSquareIntersection;z
SquareSubset;zSquareSubsetEqual;zSquareSuperset;zSquareSupersetEqual;zSquareUnion;zsquarf;zsquf;zsrarr;zSscr;zsscr;zssetmn;zssmile;zsstarf;zStar;zstar;zstarf;zstraightepsilon;zstraightphi;zstrns;zSub;zsub;zsubdot;zsubE;zsube;zsubedot;zsubmult;zsubnE;zsubne;zsubplus;zsubrarr;zSubset;zsubset;z	subseteq;z
subseteqq;zSubsetEqual;z
subsetneq;zsubsetneqq;zsubsim;zsubsub;zsubsup;zsucc;zsuccapprox;zsucccurlyeq;z	Succeeds;zSucceedsEqual;zSucceedsSlantEqual;zSucceedsTilde;zsucceq;zsuccnapprox;z	succneqq;z	succnsim;zsuccsim;z	SuchThat;zSum;zsum;zsung;r�zsup1;r�zsup2;r�zsup3;zSup;zsup;zsupdot;zsupdsub;zsupE;zsupe;zsupedot;z	Superset;zSupersetEqual;zsuphsol;zsuphsub;zsuplarr;zsupmult;zsupnE;zsupne;zsupplus;zSupset;zsupset;z	supseteq;z
supseteqq;z
supsetneq;zsupsetneqq;zsupsim;zsupsub;zsupsup;zswarhk;zswArr;zswarr;zswarrow;zswnwar;r�zszlig;zTab;ztarget;zTau;ztau;ztbrk;zTcaron;ztcaron;zTcedil;ztcedil;zTcy;ztcy;ztdot;ztelrec;zTfr;ztfr;zthere4;z
Therefore;z
therefore;zTheta;ztheta;z	thetasym;zthetav;zthickapprox;z	thicksim;zThickSpace;zthinsp;z
ThinSpace;zthkap;zthksim;r�r�zTHORN;zthorn;zTilde;ztilde;zTildeEqual;zTildeFullEqual;zTildeTilde;r�ztimes;ztimesb;z	timesbar;ztimesd;ztint;ztoea;ztop;ztopbot;ztopcir;zTopf;ztopf;ztopfork;ztosa;ztprime;zTRADE;ztrade;z	triangle;z
triangledown;z
triangleleft;ztrianglelefteq;z
triangleq;ztriangleright;ztrianglerighteq;ztridot;ztrie;z	triminus;z
TripleDot;ztriplus;ztrisb;ztritime;z	trpezium;zTscr;ztscr;zTScy;ztscy;zTSHcy;ztshcy;zTstrok;ztstrok;ztwixt;ztwoheadleftarrow;ztwoheadrightarrow;r�r�zUacute;zuacute;zUarr;zuArr;zuarr;z	Uarrocir;zUbrcy;zubrcy;zUbreve;zubreve;r�r�zUcirc;zucirc;zUcy;zucy;zudarr;zUdblac;zudblac;zudhar;zufisht;zUfr;zufr;r�r�zUgrave;zugrave;zuHar;zuharl;zuharr;zuhblk;zulcorn;z	ulcorner;zulcrop;zultri;zUmacr;zumacr;r�zuml;z	UnderBar;zUnderBrace;z
UnderBracket;zUnderParenthesis;zUnion;z
UnionPlus;zUogon;zuogon;zUopf;zuopf;zUpArrow;zUparrow;zuparrow;zUpArrowBar;zUpArrowDownArrow;zUpDownArrow;zUpdownarrow;zupdownarrow;zUpEquilibrium;zupharpoonleft;zupharpoonright;zuplus;zUpperLeftArrow;zUpperRightArrow;zUpsi;zupsi;zupsih;zUpsilon;zupsilon;zUpTee;zUpTeeArrow;zupuparrows;zurcorn;z	urcorner;zurcrop;zUring;zuring;zurtri;zUscr;zuscr;zutdot;zUtilde;zutilde;zutri;zutrif;zuuarr;r�r�zUuml;zuuml;zuwangle;zvangrt;zvarepsilon;z	varkappa;zvarnothing;zvarphi;zvarpi;z
varpropto;zvArr;zvarr;zvarrho;z	varsigma;z
varsubsetneq;zvarsubsetneqq;z
varsupsetneq;zvarsupsetneqq;z	vartheta;zvartriangleleft;zvartriangleright;zVbar;zvBar;zvBarv;zVcy;zvcy;zVDash;zVdash;zvDash;zvdash;zVdashl;zVee;zvee;zveebar;zveeeq;zvellip;zVerbar;zverbar;zVert;zvert;zVerticalBar;z
VerticalLine;zVerticalSeparator;zVerticalTilde;zVeryThinSpace;zVfr;zvfr;zvltri;zvnsub;zvnsup;zVopf;zvopf;zvprop;zvrtri;zVscr;zvscr;zvsubnE;zvsubne;zvsupnE;zvsupne;zVvdash;zvzigzag;zWcirc;zwcirc;zwedbar;zWedge;zwedge;zwedgeq;zweierp;zWfr;zwfr;zWopf;zwopf;zwp;zwr;zwreath;zWscr;zwscr;zxcap;zxcirc;zxcup;zxdtri;zXfr;zxfr;zxhArr;zxharr;zXi;zxi;zxlArr;zxlarr;zxmap;zxnis;zxodot;zXopf;zxopf;zxoplus;zxotime;zxrArr;zxrarr;zXscr;zxscr;zxsqcup;zxuplus;zxutri;zxvee;zxwedge;r�r�zYacute;zyacute;zYAcy;zyacy;zYcirc;zycirc;zYcy;zycy;r�zyen;zYfr;zyfr;zYIcy;zyicy;zYopf;zyopf;zYscr;zyscr;zYUcy;zyucy;r�zYuml;zyuml;zZacute;zzacute;zZcaron;zzcaron;zZcy;zzcy;zZdot;zzdot;zzeetrf;zZeroWidthSpace;zZeta;zzeta;zZfr;zzfr;zZHcy;zzhcy;zzigrarr;zZopf;zzopf;zZscr;zzscr;zzwj;zzwnj;N)
�__doc__�__all__rrrr�items�nameZ	codepoint�chr�r`r`�%/usr/lib64/python3.6/html/entities.py�<module>stPKb��\�N�xxiterators.cpython-36.opt-1.pycnu�[���3


 \W�@sLdZdddgZddlZddlmZdd�Zdd	d�Zddd�Zddd
�ZdS)z1Various types of useful iterators and generators.�body_line_iterator�typed_subpart_iterator�walk�N)�StringIOccs2|V|j�r.x|j�D]}|j�EdHqWdS)z�Walk over the message tree, yielding each subpart.

    The walk is performed in depth-first order.  This method is a
    generator.
    N)�is_multipart�get_payloadr)�self�subpart�r
�'/usr/lib64/python3.6/email/iterators.pyrsFccs:x4|j�D](}|j|d�}t|t�r
t|�EdHq
WdS)z�Iterate over the parts, returning string payloads line-by-line.

    Optional decode (default False) is passed through to .get_payload().
    )�decodeN)rr�
isinstance�strr)�msgrr	Zpayloadr
r
rr"s
�textccs<x6|j�D]*}|j�|kr
|dks.|j�|kr
|Vq
WdS)z�Iterate over the subparts with a given MIME type.

    Use `maintype' as the main MIME type to match against; this defaults to
    "text".  Optional `subtype' is the MIME subtype to match against; if
    omitted, only the main type is matched.
    N)rZget_content_maintypeZget_content_subtype)rZmaintype�subtyper	r
r
rr-scCs�|dkrtj}d|d}t||j�d|d�|rJtd|j�|d�n
t|d�|j�r�x"|j�D]}t|||d|�qfWdS)	zA handy debugging aidN� ��)�end�filez [%s])r�)�sys�stdout�printZget_content_typeZget_default_typerr�
_structure)r�fp�levelZinclude_defaultZtabr	r
r
rr;s
r)F)rN)NrF)	�__doc__�__all__r�iorrrrrr
r
r
r�<module>s

PKb��\��Y�;�;_policybase.cpython-36.pycnu�[���3

���i�<�@s�dZddlZddlmZddlmZddlmZdddgZGd	d
�d
�Z	dd�Z
d
d�ZGdd�de	ejd�Z
eGdd�de
��Ze�ZdS)zwPolicy framework for the email package.

Allows fine grained feature control of how the package parses and emits data.
�N)�header)�charset)�_has_surrogates�Policy�Compat32�compat32cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�_PolicyBasea�Policy Object basic framework.

    This class is useless unless subclassed.  A subclass should define
    class attributes with defaults for any values that are to be
    managed by the Policy object.  The constructor will then allow
    non-default values to be set for these attributes at instance
    creation time.  The instance will be callable, taking these same
    attributes keyword arguments, and returning a new instance
    identical to the called instance except for those values changed
    by the keyword arguments.  Instances may be added, yielding new
    instances with any non-default values from the right hand
    operand overriding those in the left hand operand.  That is,

        A + B == A(<non-default values of B>)

    The repr of an instance can be used to reconstruct the object
    if and only if the repr of the values can be used to reconstruct
    those values.

    csLxF|j�D]:\}}t||�r0tt|�j||�q
tdj||jj���q
WdS)z�Create new Policy, possibly overriding some defaults.

        See class docstring for a list of overridable attributes.

        z*{!r} is an invalid keyword argument for {}N)	�items�hasattr�superr�__setattr__�	TypeError�format�	__class__�__name__)�self�kw�name�value)r��)/usr/lib64/python3.6/email/_policybase.py�__init__)s
z_PolicyBase.__init__cCs*dd�|jj�D�}dj|jjdj|��S)NcSsg|]\}}dj||��qS)z{}={!r})r)�.0rrrrr�
<listcomp>8sz(_PolicyBase.__repr__.<locals>.<listcomp>z{}({})z, )�__dict__r	rrr�join)r�argsrrr�__repr__7sz_PolicyBase.__repr__cKsz|jj|j�}x$|jj�D]\}}tj|||�qWx@|j�D]4\}}t||�sdtdj||jj	���tj|||�q>W|S)z�Return a new instance with specified attributes changed.

        The new instance has the same attribute values as the current object,
        except for the changes passed in as keyword arguments.

        z*{!r} is an invalid keyword argument for {})
r�__new__rr	�objectrr
r
rr)rrZ	newpolicy�attrrrrr�clone<s
z_PolicyBase.clonecCs,t||�rd}nd}t|j|jj|���dS)Nz'{!r} object attribute {!r} is read-onlyz!{!r} object has no attribute {!r})r
�AttributeErrorrrr)rrr�msgrrrrNs
z_PolicyBase.__setattr__cCs|jf|j�S)z�Non-default values from right operand override those from left.

        The object returned is a new instance of the subclass.

        )r!r)r�otherrrr�__add__Usz_PolicyBase.__add__)
r�
__module__�__qualname__�__doc__rrr!rr%�
__classcell__rr)rrrsrcCs,|jdd�d}|jdd�d}|d|S)N�
�r)�rsplit�split)�docZ	added_docrrr�_append_doc^sr/cCs�|jr(|jjd�r(t|jdj|j�|_xf|jj�D]X\}}|jr4|jjd�r4x<dd�|jD�D](}tt||�d�}|r`t||j�|_Pq`Wq4W|S)N�+rcss |]}|j�D]
}|VqqdS)N)�mro)r�base�crrr�	<genexpr>hsz%_extend_docstrings.<locals>.<genexpr>r()r(�
startswithr/�	__bases__rr	�getattr)�clsrr r3r.rrr�_extend_docstringscs
r9c@s�eZdZdZdZdZdZdZdZdZ	dZ
dd	�Zd
d�Zdd
�Z
ejdd��Zejdd��Zejdd��Zejdd��Zejdd��ZdS)ra�
Controls for how messages are interpreted and formatted.

    Most of the classes and many of the methods in the email package accept
    Policy objects as parameters.  A Policy object contains a set of values and
    functions that control how input is interpreted and how output is rendered.
    For example, the parameter 'raise_on_defect' controls whether or not an RFC
    violation results in an error being raised or not, while 'max_line_length'
    controls the maximum length of output lines when a Message is serialized.

    Any valid attribute may be overridden when a Policy is created by passing
    it as a keyword argument to the constructor.  Policy objects are immutable,
    but a new Policy object can be created with only certain values changed by
    calling the Policy instance with keyword arguments.  Policy objects can
    also be added, producing a new Policy object in which the non-default
    attributes set in the right hand operand overwrite those specified in the
    left operand.

    Settable attributes:

    raise_on_defect     -- If true, then defects should be raised as errors.
                           Default: False.

    linesep             -- string containing the value to use as separation
                           between output lines.  Default '\n'.

    cte_type            -- Type of allowed content transfer encodings

                           7bit  -- ASCII only
                           8bit  -- Content-Transfer-Encoding: 8bit is allowed

                           Default: 8bit.  Also controls the disposition of
                           (RFC invalid) binary data in headers; see the
                           documentation of the binary_fold method.

    max_line_length     -- maximum length of lines, excluding 'linesep',
                           during serialization.  None or 0 means no line
                           wrapping is done.  Default is 78.

    mangle_from_        -- a flag that, when True escapes From_ lines in the
                           body of the message by putting a `>' in front of
                           them. This is used when the message is being
                           serialized by a generator. Default: True.

    message_factory     -- the class to use to create new message objects.
                           If the value is None, the default is Message.

    verify_generated_headers
                        -- if true, the generator verifies that each header
                           they are properly folded, so that a parser won't
                           treat it as multiple headers, start-of-body, or
                           part of another header.
                           This is a check against custom Header & fold()
                           implementations.
    Fr*Z8bit�NNTcCs|jr
|�|j||�dS)aZBased on policy, either raise defect or call register_defect.

            handle_defect(obj, defect)

        defect should be a Defect subclass, but in any case must be an
        Exception subclass.  obj is the object on which the defect should be
        registered if it is not raised.  If the raise_on_defect is True, the
        defect is raised as an error, otherwise the object and the defect are
        passed to register_defect.

        This method is intended to be called by parsers that discover defects.
        The email package parsers always call it with Defect instances.

        N)�raise_on_defect�register_defect)r�obj�defectrrr�
handle_defect�szPolicy.handle_defectcCs|jj|�dS)a�Record 'defect' on 'obj'.

        Called by handle_defect if raise_on_defect is False.  This method is
        part of the Policy API so that Policy subclasses can implement custom
        defect handling.  The default implementation calls the append method of
        the defects attribute of obj.  The objects used by the email package by
        default that get passed to this method will always have a defects
        attribute with an append method.

        N)Zdefects�append)rr=r>rrrr<�szPolicy.register_defectcCsdS)a[Return the maximum allowed number of headers named 'name'.

        Called when a header is added to a Message object.  If the returned
        value is not 0 or None, and there are already a number of headers with
        the name 'name' equal to the value returned, a ValueError is raised.

        Because the default behavior of Message's __setitem__ is to append the
        value to the list of headers, it is easy to create duplicate headers
        without realizing it.  This method allows certain headers to be limited
        in the number of instances of that header that may be added to a
        Message programmatically.  (The limit is not observed by the parser,
        which will faithfully produce as many headers as exist in the message
        being parsed.)

        The default implementation returns None for all header names.
        Nr)rrrrr�header_max_count�szPolicy.header_max_countcCst�dS)aZGiven a list of linesep terminated strings constituting the lines of
        a single header, return the (name, value) tuple that should be stored
        in the model.  The input lines should retain their terminating linesep
        characters.  The lines passed in by the email package may contain
        surrogateescaped binary data.
        N)�NotImplementedError)r�sourcelinesrrr�header_source_parse�szPolicy.header_source_parsecCst�dS)z�Given the header name and the value provided by the application
        program, return the (name, value) that should be stored in the model.
        N)rB)rrrrrr�header_store_parse�szPolicy.header_store_parsecCst�dS)awGiven the header name and the value from the model, return the value
        to be returned to the application program that is requesting that
        header.  The value passed in by the email package may contain
        surrogateescaped binary data if the lines were parsed by a BytesParser.
        The returned value should not contain any surrogateescaped data.

        N)rB)rrrrrr�header_fetch_parse�s	zPolicy.header_fetch_parsecCst�dS)a�Given the header name and the value from the model, return a string
        containing linesep characters that implement the folding of the header
        according to the policy controls.  The value passed in by the email
        package may contain surrogateescaped binary data if the lines were
        parsed by a BytesParser.  The returned value should not contain any
        surrogateescaped data.

        N)rB)rrrrrr�folds
zPolicy.foldcCst�dS)a%Given the header name and the value from the model, return binary
        data containing linesep characters that implement the folding of the
        header according to the policy controls.  The value passed in by the
        email package may contain surrogateescaped binary data.

        N)rB)rrrrrr�fold_binaryszPolicy.fold_binary)rr&r'r(r;�linesep�cte_type�max_line_length�mangle_from_Zmessage_factoryZverify_generated_headersr?r<rA�abc�abstractmethodrDrErFrGrHrrrrrps 7

)�	metaclassc@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)rz�+
    This particular policy is the backward compatibility Policy.  It
    replicates the behavior of the email package version 5.1.
    TcCs0t|t�s|St|�r(tj|tj|d�S|SdS)N)r�header_name)�
isinstance�strrr�Header�_charset�UNKNOWN8BIT)rrrrrr�_sanitize_header!s

zCompat32._sanitize_headercCs>|djdd�\}}|jd�dj|dd��}||jd�fS)a:+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.

        r�:r+z 	�Nz
)r-�lstripr�rstrip)rrCrrrrrrD-szCompat32.header_source_parsecCs||fS)z>+
        The name and value are returned unmodified.
        r)rrrrrrrE9szCompat32.header_store_parsecCs|j||�S)z�+
        If the value contains binary data, it is converted into a Header object
        using the unknown-8bit charset.  Otherwise it is returned unmodified.
        )rV)rrrrrrrF?szCompat32.header_fetch_parsecCs|j||dd�S)a+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  Non-ASCII binary data are CTE encoded using the
        unknown-8bit charset.

        T)�sanitize)�_fold)rrrrrrrGFsz
Compat32.foldcCs"|j|||jdkd�}|jdd�S)a�+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  If cte_type is 7bit, non-ascii binary data is CTE
        encoded using the unknown-8bit charset.  Otherwise the original source
        header is used, with its existing line breaks and/or binary data.

        Z7bit)r[�ascii�surrogateescape)r\rJ�encode)rrrZfoldedrrrrHPs	zCompat32.fold_binarycCs�g}|jd|�t|t�r\t|�rL|r<tj|tj|d�}qZ|j|�d}q`tj||d�}n|}|dk	r�d}|jdk	r||j}|j|j	|j
|d��|j|j
�dj|�S)Nz%s: )rrP)rPr)rI�
maxlinelenrX)r@rQrRrrrSrTrUrKr_rIr)rrrr[�parts�hr`rrrr\\s&



zCompat32._foldN)rr&r'r(rLrVrDrErFrGrHr\rrrrrs
)r(rMZemailrrrTZemail.utilsr�__all__rr/r9�ABCMetarrrrrrr�<module>sL
(fPKb��\��8�%�%policy.cpython-36.opt-1.pycnu�[���3


 \�(�@s�dZddlZddlmZmZmZmZddlmZddl	m
Z
ddlmZddl
mZdd	d
ddd
ddgZejd�ZeGdd�de��Ze�Ze`ejdd�Zejdd�Zejddd�Zejdd�ZdS)zcThis will be the home for the policy that hooks in the new
code that adds all the email6 features.
�N)�Policy�Compat32�compat32�_extend_docstrings)�_has_surrogates)�HeaderRegistry)�raw_data_manager)�EmailMessagerrr�EmailPolicy�default�strict�SMTP�HTTPz\n|\rcspeZdZdZeZdZdZe�Z	e
Z�fdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�Zddd�Z�ZS)r
aQ+
    PROVISIONAL

    The API extensions enabled by this policy are currently provisional.
    Refer to the documentation for details.

    This policy adds new header parsing and folding algorithms.  Instead of
    simple strings, headers are custom objects with custom attributes
    depending on the type of the field.  The folding algorithm fully
    implements RFCs 2047 and 5322.

    In addition to the settable attributes listed above that apply to
    all Policies, this policy adds the following additional attributes:

    utf8                -- if False (the default) message headers will be
                           serialized as ASCII, using encoded words to encode
                           any non-ASCII characters in the source strings.  If
                           True, the message headers will be serialized using
                           utf8 and will not contain encoded words (see RFC
                           6532 for more on this serialization format).

    refold_source       -- if the value for a header in the Message object
                           came from the parsing of some source, this attribute
                           indicates whether or not a generator should refold
                           that value when transforming the message back into
                           stream form.  The possible values are:

                           none  -- all source values use original folding
                           long  -- source values that have any line that is
                                    longer than max_line_length will be
                                    refolded
                           all  -- all values are refolded.

                           The default is 'long'.

    header_factory      -- a callable that takes two arguments, 'name' and
                           'value', where 'name' is a header field name and
                           'value' is an unfolded header field value, and
                           returns a string-like object that represents that
                           header.  A default header_factory is provided that
                           understands some of the RFC5322 header field types.
                           (Currently address fields and date fields have
                           special treatment, while all other fields are
                           treated as unstructured.  This list will be
                           completed before the extension is marked stable.)

    content_manager     -- an object with at least two methods: get_content
                           and set_content.  When the get_content or
                           set_content method of a Message object is called,
                           it calls the corresponding method of this object,
                           passing it the message object as its first argument,
                           and any arguments or keywords that were passed to
                           it as additional arguments.  The default
                           content_manager is
                           :data:`~email.contentmanager.raw_data_manager`.

    F�longcs*d|krtj|dt��t�jf|�dS)N�header_factory)�object�__setattr__r�super�__init__)�self�kw)�	__class__��$/usr/lib64/python3.6/email/policy.pyr\szEmailPolicy.__init__cCs|j|jS)z�+
        The implementation for this class returns the max_count attribute from
        the specialized header class that would be used to construct a header
        of type 'name'.
        )rZ	max_count)r�namerrr�header_max_countcszEmailPolicy.header_max_countcCs>|djdd�\}}|jd�dj|dd��}||jd�fS)ac+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.  (This
        is the same as Compat32).

        r�:�z 	�Nz
)�split�lstrip�join�rstrip)rZsourcelinesr�valuerrr�header_source_parseus	zEmailPolicy.header_source_parsecCsVt|d�r$|jj�|j�kr$||fSt|t�rFt|j��dkrFtd��||j||�fS)a�+
        The name is returned unchanged.  If the input value has a 'name'
        attribute and it matches the name ignoring case, the value is returned
        unchanged.  Otherwise the name and value are passed to header_factory
        method, and the resulting custom header object is returned as the
        value.  In this case a ValueError is raised if the input value contains
        CR or LF characters.

        rrzDHeader values may not contain linefeed or carriage return characters)	�hasattrr�lower�
isinstance�str�len�
splitlines�
ValueErrorr)rrr#rrr�header_store_parse�s

zEmailPolicy.header_store_parsecCs*t|d�r|Sdjtj|��}|j||�S)ai+
        If the value has a 'name' attribute, it is returned to unmodified.
        Otherwise the name and the value with any linesep characters removed
        are passed to the header_factory method, and the resulting custom
        header object is returned.  Any surrogateescaped bytes get turned
        into the unicode unknown-character glyph.

        rr)r%r!�linesep_splitterrr)rrr#rrr�header_fetch_parse�s	
zEmailPolicy.header_fetch_parsecCs|j||dd�S)a+
        Header folding is controlled by the refold_source policy setting.  A
        value is considered to be a 'source value' if and only if it does not
        have a 'name' attribute (having a 'name' attribute means it is a header
        object of some sort).  If a source value needs to be refolded according
        to the policy, it is converted into a custom header object by passing
        the name and the value with any linesep characters removed to the
        header_factory method.  Folding of a custom header object is done by
        calling its fold method with the current policy.

        Source values are split into lines using splitlines.  If the value is
        not to be refolded, the lines are rejoined using the linesep from the
        policy and returned.  The exception is lines containing non-ascii
        binary data.  In that case the value is refolded regardless of the
        refold_source setting, which causes the binary data to be CTE encoded
        using the unknown-8bit charset.

        T)�
refold_binary)�_fold)rrr#rrr�fold�szEmailPolicy.foldcCs0|j|||jdkd�}|jr dnd}|j|d�S)a+
        The same as fold if cte_type is 7bit, except that the returned value is
        bytes.

        If cte_type is 8bit, non-ASCII binary data is converted back into
        bytes.  Headers with binary data are not refolded, regardless of the
        refold_header setting, since there is no way to know whether the binary
        data consists of single byte characters or multibyte characters.

        If utf8 is true, headers are encoded to utf8, otherwise to ascii with
        non-ASCII unicode rendered as encoded words.

        Z7bit)r/�utf8�ascii�surrogateescape)r0Zcte_typer2�encode)rrr#Zfolded�charsetrrr�fold_binary�szEmailPolicy.fold_binarycs�t|d�r|j|d�S|jr"|jntd��|j�}|jdkp�|jdko�|rft|d�t|�d�kp�t�fdd	�|d
d�D��}|s�|r�t|�r�|j	|dj
|��j|d�S|d|jj
|�|jS)
Nr)Zpolicy�inf�allrr�c3s|]}t|��kVqdS)N)r))�.0�x)�maxlenrr�	<genexpr>�sz$EmailPolicy._fold.<locals>.<genexpr>rrz: )r%r1�max_line_length�floatr*�
refold_sourcer)�anyrrr!�linesep)rrr#r/�linesZrefoldr)r=rr0�s


 zEmailPolicy._fold)F)�__name__�
__module__�__qualname__�__doc__r	Zmessage_factoryr2rArrrZcontent_managerrrr$r,r.r1r7r0�
__classcell__rr)rrr
s;
T)Zraise_on_defectz
)rC)rCr?)r2)rH�reZemail._policybaserrrrZemail.utilsrZemail.headerregistryrZemail.contentmanagerrZ
email.messager	�__all__�compiler-r
rrZclonerr
rZSMTPUTF8rrrr�<module>s0
@PKb��\���Ajjencoders.cpython-36.pycnu�[���3


 \��@sTdZddddgZddlmZddlmZdd	�Zd
d�Z	dd�Z
dd�Zd
d�ZdS)z Encodings and related functions.�encode_7or8bit�
encode_base64�encode_noop�
encode_quopri�)�encodebytes)�encodestringcCst|dd�}|jdd�S)NT)Z	quotetabs� s=20)�
_encodestring�replace)�s�enc�r
�&/usr/lib64/python3.6/email/encoders.py�_qencodesrcCs0|jdd�}tt|�d�}|j|�d|d<dS)zlEncode the message's payload in Base64.

    Also, add an appropriate Content-Transfer-Encoding header.
    T)�decode�ascii�base64zContent-Transfer-EncodingN)�get_payload�str�_bencode�set_payload)�msg�orig�encdatar
r
rrs
cCs*|jdd�}t|�}|j|�d|d<dS)zvEncode the message's payload in quoted-printable.

    Also, add an appropriate Content-Transfer-Encoding header.
    T)rzquoted-printablezContent-Transfer-EncodingN)rrr)rrrr
r
rr&s
cCsX|jdd�}|dkr d|d<dSy|jd�Wntk
rJd|d<Yn
Xd|d<dS)z9Set the Content-Transfer-Encoding header to 7bit or 8bit.T)rNZ7bitzContent-Transfer-EncodingrZ8bit)rr�UnicodeError)rrr
r
rr2scCsdS)zDo nothing.Nr
)rr
r
rrDsN)
�__doc__�__all__rrr�quoprirr	rrrrrr
r
r
r�<module>sPKb��\M��v�R�R#headerregistry.cpython-36.opt-1.pycnu�[���3


 \O�@sjdZddlmZddlmZddlmZddlmZGdd�d�ZGdd	�d	�Z	Gd
d�de
�Zdd
�ZGdd�d�Z
Gdd�de
�ZGdd�d�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGd d!�d!�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'�Zeeeeeeeeeeeeeeeeeeed(�ZGd)d*�d*�Zd+S),a;Representing and manipulating email headers via custom objects.

This module provides an implementation of the HeaderRegistry API.
The implementation is designed to flexibly follow RFC5322 rules.

Eventually HeaderRegistry will be a public API, but it isn't yet,
and will probably change some before that happens.

�)�MappingProxyType)�utils)�errors)�_header_value_parserc@s^eZdZddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCsl|dk	rV|s|rtd��tj|�\}}|r:tdj||���|jrJ|jd�|j}|j}||_||_	||_
dS)a�Create an object representing a full email address.

        An address can have a 'display_name', a 'username', and a 'domain'.  In
        addition to specifying the username and domain separately, they may be
        specified together by using the addr_spec keyword *instead of* the
        username and domain keywords.  If an addr_spec string is specified it
        must be properly quoted according to RFC 5322 rules; an error will be
        raised if it is not.

        An Address object has display_name, username, domain, and addr_spec
        attributes, all of which are read-only.  The addr_spec and the string
        value of the object are both quoted according to RFC5322 rules, but
        without any Content Transfer Encoding.

        Nz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)�	TypeError�parserZ
get_addr_spec�
ValueError�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_specZa_s�rest�r�,/usr/lib64/python3.6/email/headerregistry.py�__init__s

zAddress.__init__cCs|jS)N)r)rrrrr7szAddress.display_namecCs|jS)N)r)rrrrr;szAddress.usernamecCs|jS)N)r)rrrrr?szAddress.domaincCsTt|j�}t|�t|tj�kr.tj|j�}n|j}|jrH|d|jS|sPdS|S)z�The addr_spec (username@domain) portion of the address, quoted
        according to RFC 5322 rules, but with no Content Transfer Encoding.
        �@z<>)�setr�lenr	Z
DOT_ATOM_ENDS�quote_stringr)r�namesetZlprrrrCs
zAddress.addr_speccCsdj|jj|j|j|j�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrr)rrrr�__repr__SszAddress.__repr__cCs^t|j�}t|�t|tj�kr.tj|j�}n|j}|rX|jdkrFdn|j}dj||�S|jS)Nz<>rz{} <{}>)rrrr	�SPECIALSrrr)rr�disprrrr�__str__Xs
zAddress.__str__cCs8t|�t|�krdS|j|jko6|j|jko6|j|jkS)NF)�typerrr)r�otherrrr�__eq__cs
zAddress.__eq__)rrrN)r �
__module__�__qualname__r�propertyrrrrr!r$r'rrrrrs
%rc@sFeZdZddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs||_|rt|�nt�|_dS)aCreate an object representing an address group.

        An address group consists of a display_name followed by colon and a
        list of addresses (see Address) terminated by a semi-colon.  The Group
        is created by specifying a display_name and a possibly empty list of
        Address objects.  A Group can also be used to represent a single
        address that is not in a group, which is convenient when manipulating
        lists that are a combination of Groups and individual Addresses.  In
        this case the display_name should be set to None.  In particular, the
        string representation of a Group whose display_name is None is the same
        as the Address object, if there is one and only one Address object in
        the addresses list.

        N)r�tuple�
_addresses)rr�	addressesrrrrmszGroup.__init__cCs|jS)N)r)rrrrrszGroup.display_namecCs|jS)N)r-)rrrrr.�szGroup.addressescCsdj|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rrr rr.)rrrrr!�szGroup.__repr__cCs�|jdkr&t|j�dkr&t|jd�S|j}|dk	r\t|�}t|�t|tj�kr\tj|�}djdd�|jD��}|r~d|n|}dj	||�S)N�rz, css|]}t|�VqdS)N)�str)�.0�xrrr�	<genexpr>�sz Group.__str__.<locals>.<genexpr>� z{}:{};)
rrr.r0rr	r"r�joinr)rr#rZadrstrrrrr$�s
z
Group.__str__cCs,t|�t|�krdS|j|jko*|j|jkS)NF)r%rr.)rr&rrrr'�szGroup.__eq__)NN)
r r(r)rr*rr.r!r$r'rrrrr+ks
r+c@sTeZdZdZdd�Zdd�Zedd��Zedd	��Zd
d�Z	e
dd
��Zdd�ZdS)�
BaseHeadera|Base class for message headers.

    Implements generic behavior and provides tools for subclasses.

    A subclass must define a classmethod named 'parse' that takes an unfolded
    value string and a dictionary as its arguments.  The dictionary will
    contain one key, 'defects', initialized to an empty list.  After the call
    the dictionary must contain two additional keys: parse_tree, set to the
    parse tree obtained from parsing the header, and 'decoded', set to the
    string value of the idealized representation of the data from the value.
    (That is, encoded words are decoded, and values that have canonical
    representations are so represented.)

    The defects key is intended to collect parsing defects, which the message
    parser will subsequently dispose of as appropriate.  The parser should not,
    insofar as practical, raise any errors.  Defects should be added to the
    list instead.  The standard header parsers register defects for RFC
    compliance issues, for obsolete RFC syntax, and for unrecoverable parsing
    errors.

    The parse method may add additional keys to the dictionary.  In this case
    the subclass must define an 'init' method, which will be passed the
    dictionary as its keyword arguments.  The method should use (usually by
    setting them as the value of similarly named attributes) and remove all the
    extra keys added by its parse method, and then use super to call its parent
    class with the remaining arguments and keywords.

    The subclass should also make sure that a 'max_count' attribute is defined
    that is either None or 1. XXX: need to better define this API.

    cCs\dgi}|j||�tj|d�r4tj|d�|d<tj||d�}|d=|j|f|�|S)N�defects�decoded)�parserZ_has_surrogates�	_sanitizer0�__new__�init)�cls�name�value�kwdsrrrrr;�szBaseHeader.__new__cCs||_||_||_dS)N)�_name�_parse_tree�_defects)rr>�
parse_treer7rrrr<�szBaseHeader.initcCs|jS)N)rA)rrrrr>�szBaseHeader.namecCs
t|j�S)N)r,rC)rrrrr7�szBaseHeader.defectscCst|jj|jjt|�f|jfS)N)�_reconstruct_headerrr �	__bases__r0�__dict__)rrrr�
__reduce__�s
zBaseHeader.__reduce__cCstj||�S)N)r0r;)r=r?rrr�_reconstruct�szBaseHeader._reconstructcCs`tjtjtj|jd�tjdd�g�g�}|jrH|jtjtjdd�g��|j|j�|j	|d�S)atFold header according to policy.

        The parsed representation of the header is folded according to
        RFC5322 rules, as modified by the policy.  If the parse tree
        contains surrogateescaped bytes, the bytes are CTE encoded using
        the charset 'unknown-8bit".

        Any non-ASCII characters in the parse tree are CTE encoded using
        charset utf-8. XXX: make this a policy setting.

        The returned value is an ASCII-only string possibly containing linesep
        characters, and ending with a linesep character.  The string includes
        the header name and the ': ' separator.

        zheader-name�:z
header-sepr4Zfws)�policy)
r	ZHeaderZHeaderLabelZ
ValueTerminalr>rB�appendZCFWSListZWhiteSpaceTerminal�fold)rrK�headerrrrrM�szBaseHeader.foldN)
r r(r)�__doc__r;r<r*r>r7rH�classmethodrIrMrrrrr6�s 

r6cCst||i�j|�S)N)r%rI)Zcls_name�basesr?rrrrEsrEc@s&eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs"|j|�|d<t|d�|d<dS)NrDr8)�value_parserr0)r=r?r@rrrr9szUnstructuredHeader.parse)
r r(r)�	max_count�staticmethodr	�get_unstructuredrSrPr9rrrrrR	s
rRc@seZdZdZdS)�UniqueUnstructuredHeaderr/N)r r(r)rTrrrrrWsrWcsFeZdZdZdZeej�Ze	dd��Z
�fdd�Zedd��Z
�ZS)	�
DateHeadera�Header whose value consists of a single timestamp.

    Provides an additional attribute, datetime, which is either an aware
    datetime using a timezone, or a naive datetime if the timezone
    in the input string is -0000.  Also accepts a datetime as input.
    The 'value' attribute is the normalized form of the timestamp,
    which means it is the output of format_datetime on the datetime.
    NcCsz|s6|djtj��d|d<d|d<tj�|d<dSt|t�rJtj|�}||d<tj	|d�|d<|j
|d�|d<dS)Nr7�datetimerr8rD)rLrZHeaderMissingRequiredValuer	Z	TokenList�
isinstancer0rZparsedate_to_datetimeZformat_datetimerS)r=r?r@rrrr9)s

zDateHeader.parsecs|jd�|_t�j||�dS)NrY)�pop�	_datetime�superr<)r�args�kw)rrrr<7szDateHeader.initcCs|jS)N)r\)rrrrrY;szDateHeader.datetime)r r(r)rOrTrUr	rVrSrPr9r<r*rY�
__classcell__rr)rrrXs	
rXc@seZdZdZdS)�UniqueDateHeaderr/N)r r(r)rTrrrrra@sracsPeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�ZS)�
AddressHeaderNcCstj|�\}}|S)N)r	Zget_address_list)r?�address_listrrrrSIszAddressHeader.value_parsercCs�t|t�rZ|j|�|d<}g}x,|jD]"}|jt|jdd�|jD���q(Wt|j	�}n"t
|d�sj|g}dd�|D�}g}||d<||d<djd	d�|D��|d
<d|kr�|j|d
�|d<dS)NrDcSs*g|]"}t|jpd|jpd|jp"d��qS)r)rrr
r)r1Zmbrrr�
<listcomp>Xsz'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs&g|]}t|d�std|g�n|�qS)r.N)�hasattrr+)r1�itemrrrrdas�groupsr7z, cSsg|]}t|��qSr)r0)r1rgrrrrdgsr8)rZr0rSr.rLr+rZ
all_mailboxes�listrrfr5)r=r?r@rcrhZaddrr7rrrr9Os$


zAddressHeader.parsecs(t|jd��|_d|_t�j||�dS)Nrh)r,r[�_groupsr-r]r<)rr^r_)rrrr<kszAddressHeader.initcCs|jS)N)rj)rrrrrhpszAddressHeader.groupscCs&|jdkr tdd�|jD��|_|jS)NcSsg|]}|jD]}|�qqSr)r.)r1�group�addressrrrrdwsz+AddressHeader.addresses.<locals>.<listcomp>)r-r,rj)rrrrr.ts
zAddressHeader.addresses)
r r(r)rTrUrSrPr9r<r*rhr.r`rr)rrrbEsrbc@seZdZdZdS)�UniqueAddressHeaderr/N)r r(r)rTrrrrrm|srmc@seZdZedd��ZdS)�SingleAddressHeadercCs(t|j�dkrtdj|j���|jdS)Nr/z9value of single address header {} is not a single addressr)rr.r
rr>)rrrrrl�s
zSingleAddressHeader.addressN)r r(r)r*rlrrrrrn�srnc@seZdZdZdS)�UniqueSingleAddressHeaderr/N)r r(r)rTrrrrro�srocsZeZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�ZS)�MIMEVersionHeaderr/cCs�|j|�|d<}t|�|d<|dj|j�|jdkr<dn|j|d<|j|d<|jdk	rtdj|d|d�|d<nd|d<dS)NrDr8r7�major�minorz{}.{}�version)rSr0�extendrrrrqr)r=r?r@rDrrrr9�s

zMIMEVersionHeader.parsecs6|jd�|_|jd�|_|jd�|_t�j||�dS)Nrsrqrr)r[�_version�_major�_minorr]r<)rr^r_)rrrr<�szMIMEVersionHeader.initcCs|jS)N)rv)rrrrrq�szMIMEVersionHeader.majorcCs|jS)N)rw)rrrrrr�szMIMEVersionHeader.minorcCs|jS)N)ru)rrrrrs�szMIMEVersionHeader.version)r r(r)rTrUr	Zparse_mime_versionrSrPr9r<r*rqrrrsr`rr)rrrp�s
rpcs8eZdZdZedd��Z�fdd�Zedd��Z�Z	S)�ParameterizedMIMEHeaderr/cCsZ|j|�|d<}t|�|d<|dj|j�|jdkrBi|d<ndd�|jD�|d<dS)NrDr8r7�paramscSs&i|]\}}tj|�tj|�j��qSr)rr:�lower)r1r>r?rrr�
<dictcomp>�sz1ParameterizedMIMEHeader.parse.<locals>.<dictcomp>)rSr0rtrry)r=r?r@rDrrrr9�s

zParameterizedMIMEHeader.parsecs|jd�|_t�j||�dS)Nry)r[�_paramsr]r<)rr^r_)rrrr<�szParameterizedMIMEHeader.initcCs
t|j�S)N)rr|)rrrrry�szParameterizedMIMEHeader.params)
r r(r)rTrPr9r<r*ryr`rr)rrrx�s
rxcsJeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�ZS)	�ContentTypeHeadercs2t�j||�tj|jj�|_tj|jj�|_dS)N)	r]r<rr:rB�maintype�	_maintype�subtype�_subtype)rr^r_)rrrr<�szContentTypeHeader.initcCs|jS)N)r)rrrrr~�szContentTypeHeader.maintypecCs|jS)N)r�)rrrrr��szContentTypeHeader.subtypecCs|jd|jS)N�/)r~r�)rrrr�content_type�szContentTypeHeader.content_type)
r r(r)rUr	Zparse_content_type_headerrSr<r*r~r�r�r`rr)rrr}�s

r}cs2eZdZeej�Z�fdd�Zedd��Z	�Z
S)�ContentDispositionHeadercs2t�j||�|jj}|dkr"|ntj|�|_dS)N)r]r<rB�content_dispositionrr:�_content_disposition)rr^r_Zcd)rrrr<�szContentDispositionHeader.initcCs|jS)N)r�)rrrrr��sz,ContentDispositionHeader.content_disposition)r r(r)rUr	Z parse_content_disposition_headerrSr<r*r�r`rr)rrr��s
r�csBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�ContentTransferEncodingHeaderr/cCs2|j|�|d<}t|�|d<|dj|j�dS)NrDr8r7)rSr0rtr)r=r?r@rDrrrr9�sz#ContentTransferEncodingHeader.parsecs"t�j||�tj|jj�|_dS)N)r]r<rr:rB�cte�_cte)rr^r_)rrrr<sz"ContentTransferEncodingHeader.initcCs|jS)N)r�)rrrrr�sz!ContentTransferEncodingHeader.cte)r r(r)rTrUr	Z&parse_content_transfer_encoding_headerrSrPr9r<r*r�r`rr)rrr��s

r�)ZsubjectZdatezresent-datez	orig-dateZsenderz
resent-senderZtoz	resent-toZccz	resent-ccZbccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-typezcontent-dispositionzcontent-transfer-encodingc@s8eZdZdZeedfdd�Zdd�Zdd�Zd	d
�Z	dS)�HeaderRegistryz%A header_factory and header registry.TcCs&i|_||_||_|r"|jjt�dS)a�Create a header_factory that works with the Policy API.

        base_class is the class that will be the last class in the created
        header class's __bases__ list.  default_class is the class that will be
        used if "name" (see __call__) does not appear in the registry.
        use_default_map controls whether or not the default mapping of names to
        specialized classes is copied in to the registry when the factory is
        created.  The default is True.

        N)�registry�
base_class�
default_class�update�_default_header_map)rr�r�Zuse_default_maprrrr's
zHeaderRegistry.__init__cCs||j|j�<dS)zLRegister cls as the specialized class for handling "name" headers.

        N)r�rz)rr>r=rrr�map_to_type9szHeaderRegistry.map_to_typecCs,|jj|j�|j�}td|j||jfi�S)N�_)r��getrzr�r%r r�)rr>r=rrr�__getitem__?szHeaderRegistry.__getitem__cCs||||�S)a�Create a header instance for header 'name' from 'value'.

        Creates a header instance by creating a specialized class for parsing
        and representing the specified header by combining the factory
        base_class with a specialized class from the registry or the
        default_class, and passing the name and value to the constructed
        class's constructor.

        r)rr>r?rrr�__call__Cs
zHeaderRegistry.__call__N)
r r(r)rOr6rRrr�r�r�rrrrr�#sr�N)rO�typesrZemailrrrr	rr+r0r6rErRrWrXrarbrmrnrorprxr}r�r�r�r�rrrr�<module>	sR[6d'7
%PKb��\R���base64mime.cpython-36.opt-1.pycnu�[���3


 \�
�@stdZddddddgZddlmZdd	lmZmZd
ZdZdZ	d
Z
dd�Zddd�Zdefdd�Z
dd�ZeZeZdS)a�Base64 content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode arbitrary 8-bit data using the three 8-bit bytes in four 7-bit
characters encoding known as Base64.

It is used in the MIME standards for email to attach images, audio, and text
using some 8-bit character sets to messages.

This module provides an interface to encode and decode both headers and bodies
with Base64 encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:, From:, Cc:, etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character conversion
necessary for proper internationalized headers; it only does dumb encoding and
decoding.  To deal with the various line wrapping issues, use the email.header
module.
�body_decode�body_encode�decode�decodestring�
header_encode�
header_length�)�	b64encode)�
b2a_base64�
a2b_base64z
�
��cCs*tt|�d�\}}|d}|r&|d7}|S)z6Return the length of s when it is encoded with base64.��)�divmod�len)�	bytearrayZgroups_of_3Zleftover�n�r�(/usr/lib64/python3.6/email/base64mime.pyr2s
�
iso-8859-1cCs6|sdSt|t�r|j|�}t|�jd�}d||fS)z�Encode a single header line with Base64 encoding in a given charset.

    charset names the character set to use to encode the header.  It defaults
    to iso-8859-1.  Base64 encoding is defined in RFC 2045.
    r�asciiz=?%s?b?%s?=)�
isinstance�str�encoderr)Zheader_bytes�charsetZencodedrrrr=s

�LcCs�|s|Sg}|dd}x^tdt|�|�D]J}t||||��jd�}|jt�rj|tkrj|dd�|}|j|�q*Wtj|�S)a1Encode a string with base64.

    Each line will be wrapped at, at most, maxlinelen characters (defaults to
    76 characters).

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.
    rrrrN����)	�rangerr	r�endswith�NL�append�EMPTYSTRING�join)�sZ
maxlinelenZeolZencvecZ
max_unencoded�i�encrrrrLs
cCs.|s
t�St|t�r"t|jd��St|�SdS)z�Decode a raw base64 string, returning a bytes object.

    This function does not parse a full MIME header value encoded with
    base64 (like =?iso-8859-1?b?bmloISBuaWgh?=) -- please use the high
    level email.header class for that functionality.
    zraw-unicode-escapeN)�bytesrrr
r)�stringrrrrfs

N)r)�__doc__�__all__�base64rZbinasciir	r
ZCRLFr!r#ZMISC_LENrrrrrrrrrr�<module>s$
PKb��\l�Ɠzz#contentmanager.cpython-36.opt-1.pycnu�[���3


 \�)�@s:ddlZddlZddlZddlZddlmZGdd�d�Ze�Zd%dd�Zej	de�d	d
�Z
xdj�D]Zej	ee
�qhWdd
�Z
x dj�D]Zej	dee
�q�Wdd�Zej	de�dd�Zdd�Zdd�Zdd�Zd&dd�Zejee�d'd d!�Zejejje�d(d#d$�Zx eeefD]Zejee��q WdS))�N)�
quoprimimec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContentManagercCsi|_i|_dS)N)�get_handlers�set_handlers)�self�r�,/usr/lib64/python3.6/email/contentmanager.py�__init__	szContentManager.__init__cCs||j|<dS)N)r)r�key�handlerrrr�add_get_handler
szContentManager.add_get_handlercOs||j�}||jkr(|j||f|�|�S|j�}||jkrP|j||f|�|�Sd|jkrp|jd|f|�|�St|��dS)N�)Zget_content_typer�get_content_maintype�KeyError)r�msg�args�kwZcontent_type�maintyperrr�get_contents


zContentManager.get_contentcCs||j|<dS)N)r)rZtypekeyrrrr�add_set_handlerszContentManager.add_set_handlercOs>|j�dkrtd��|j||�}|j�|||f|�|�dS)NZ	multipartz"set_content not valid on multipart)r�	TypeError�_find_set_handlerZ
clear_content)rr�objrrrrrr�set_contents
zContentManager.set_contentc	Cs�d}x�t|�jD]�}||jkr(|j|S|j}t|dd�}|rLdj||f�n|}|dkr\|}||jkrp|j|S||jkr�|j|S|j}||jkr|j|SqWd|jkr�|jdSt|��dS)N�
__module__r
�.)�type�__mro__r�__qualname__�getattr�join�__name__r)	rrrZfull_path_for_error�typZqname�modname�	full_path�namerrrr's&








z ContentManager._find_set_handlerN)	r!rrr	rrrrrrrrrrs	r�replacecCs&|jdd�}|jdd�}|j||d�S)NT)�decode�charset�ASCII)�errors)�get_payloadZ	get_paramr')rr*Zcontentr(rrr�get_text_content@sr,�textcCs|jdd�S)NT)r')r+)rrrr�get_non_text_contentGsr.zaudio image video applicationcCs
|jd�S)Nr)r+)rrrr�get_message_contentMsr/zrfc822 external-bodyzmessage/cCst|jd��S)Nr)�bytesr+)rrrr�%get_and_fixup_unknown_message_contentSsr1�messagecs�dj||f�|d<|r�t|dd�s<|j��fdd�|D�}y,x&|D]}|jrX|jd�|||j<qDWWn@tjjk
r�}z tdj	|j
|jd���|�WYdd}~XnXdS)	N�/zContent-Typerr%csg|]}�j�j|g���qSr)Zheader_factoryZheader_source_parse)�.0�header)�mprr�
<listcomp>dsz _prepare_set.<locals>.<listcomp>zInvalid header: {})�policy)r �hasattrr8Zdefectsr%�emailr*ZHeaderDefect�
ValueError�formatZfold)rr�subtype�headersr5�excr)r6r�_prepare_set_s


r@cCs||dkr|dk	rd}|dk	r$||d<|dk	r>|jd|ddd�|dk	rN||d<|dk	rxx |j�D]\}}|j||�q`WdS)NZ
attachmentzContent-Disposition�filenameT)r5r&z
Content-ID)�	set_param�items)r�dispositionrA�cid�paramsr
�valuerrr�
_finalize_setpsrHcCsZg}|dd}x>tdt|�|�D]*}||||�}|jtj|�jd��q"Wdj|�S)N��r�asciir
)�range�len�append�binascii�
b2a_base64r'r )�data�max_line_lengthZ
encoded_linesZunencoded_bytes_per_line�iZthislinerrr�_encode_base64�srTcs||j|�j�}|jjd���fdd�}dd�}|dkr�yd||�jd�fStk
r\YnX|jdkr�tdd	�|D��|jkr�d||�jdd
�fS||dd��}tj	|jd�|j�}t
j|�}	t|�t|	�kr�d
}nd}t|�dkr�||fS|dk�r
||�jd�}
nj|dk�r&||�jdd
�}
nN|dk�rJtj	||�jd�|j�}
n*|d
k�rft
||�|j�}
ntdj|���||
fS)NrKcs�j|��S)N)r )�lines)�lineseprr�
embedded_body�sz#_encode_text.<locals>.embedded_bodycSsdj|�dS)N�
)r )rUrrr�normal_body�sz!_encode_text.<locals>.normal_body�7bit�8bitcss|]}t|�VqdS)N)rM)r4�xrrr�	<genexpr>�sz_encode_text.<locals>.<genexpr>�surrogateescape�
zlatin-1�base64zquoted-printablez$Unknown content transfer encoding {})�encode�
splitlinesrVr'�UnicodeDecodeErrorZcte_type�maxrRrZbody_encoderOrPrMrTr;r<)�stringr(�cter8rUrWrYZsniffZsniff_qpZsniff_base64rQr)rVr�_encode_text�s@






rg�plain�utf-8c
Csdt|d||	�t||||j�\}}
|j|
�|jdtjjj||�dd�||d<t	|||||�dS)Nr-r(T)r&zContent-Transfer-Encoding)
r@rgr8�set_payloadrBr:r(ZALIASES�getrH)rrer=r(rfrDrArErFr>Zpayloadrrr�set_text_content�s
rl�rfc822c		Cs�|dkrtd��|dkr@|dkr.tdj|���|dkr:dn|}n0|dkrd|d
kr^td	j|���d}n|dkrpd}t|d
||�|j|g�||d<t|||||�dS)N�partialz4message/partial is not supported for Message objectsrmrZr[�binaryz*message/rfc822 parts do not support cte={}z
external-bodyz1message/external-body parts do not support cte={}r2zContent-Transfer-Encoding)NrZr[ro)NrZ)r;r<r@rjrH)	rr2r=rfrDrArErFr>rrr�set_message_content�s$rpr`c

Cs�t||||	�|dkr(t||jjd�}nN|dkrNtj|dddd�}|jd�}n(|dkrb|jd�n|d
krv|jdd�}|j|�||d<t	|||||�dS)Nr`)rRzquoted-printableFT)�istextr5Z	quotetabsrKrZr[ror^zContent-Transfer-Encoding)r[ro)
r@rTr8rRrOZb2a_qpr'rarjrH)
rrQrr=rfrDrArErFr>rrr�set_bytes_content�s
rr)r&)rhriNNNNNN)rmNNNNNN)r`NNNNN)rOZ
email.charsetr:Z
email.messageZemail.errorsrrZraw_data_managerr,rr.�splitrr/r=r1r@rHrTrgrlr�strrpr2ZMessagerrr0�	bytearray�
memoryviewr"rrrr�<module>sD6
	'
	

PKb��\+M�

iterators.cpython-36.opt-2.pycnu�[���3


 \W�@sHdddgZddlZddlmZdd�Zd
dd�Zdd
d�Zddd�ZdS)�body_line_iterator�typed_subpart_iterator�walk�N)�StringIOccs2|V|j�r.x|j�D]}|j�EdHqWdS)N)�is_multipart�get_payloadr)�self�subpart�r
�'/usr/lib64/python3.6/email/iterators.pyrsFccs:x4|j�D](}|j|d�}t|t�r
t|�EdHq
WdS)N)�decode)rr�
isinstance�strr)�msgrr	Zpayloadr
r
rr"s
�textccs<x6|j�D]*}|j�|kr
|dks.|j�|kr
|Vq
WdS)N)rZget_content_maintypeZget_content_subtype)rZmaintype�subtyper	r
r
rr-scCs�|dkrtj}d|d}t||j�d|d�|rJtd|j�|d�n
t|d�|j�r�x"|j�D]}t|||d|�qfWdS)N� ��)�end�filez [%s])r�)�sys�stdout�printZget_content_typeZget_default_typerr�
_structure)r�fp�levelZinclude_defaultZtabr	r
r
rr;s
r)F)rN)NrF)�__all__r�iorrrrrr
r
r
r�<module>s

PKb��\�=�8�$�$utils.cpython-36.opt-2.pycnu�[���3

���i�J�@s�dddddddddd	d
ddd
dgZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	m
Z
ddl	mZmZmZddlmZdZdZdZdZdZejd�Zejd�ZdZdadd�Zdd �Zd!d"�Zd#d$�Z dHd&d�Z!d'd(�Z"d)d*�Z#d+Z$dd,�d-d�Z%d.d/�Z&d0d1�Z'd2d3�Z(ejd4ej)ej*B�Z+d5d6�Z,dId8d�Z-dJd9d�Z.dKd:d�Z/d;d
�Z0dd,�d<d
�Z1d=d�Z2d>d�Z3dLd?d�Z4ejd@ej5�Z6dAd�Z7dMdDd�Z8dOdFdG�Z9dS)P�collapse_rfc2231_value�
decode_params�decode_rfc2231�encode_rfc2231�
formataddr�
formatdate�format_datetime�getaddresses�
make_msgid�	mktime_tz�	parseaddr�	parsedate�parsedate_tz�parsedate_to_datetime�unquote�N)�quote)�AddressList)r
)rr
�
_parsedate_tz)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]z/etc/python/email.cfgcCstdkrt�atS)N)�_cached_strict_addr_parsing�_use_strict_email_parsing_impl�rr�#/usr/lib64/python3.6/email/utils.py�_use_strict_email_parsing7srcCs�ttjjd��}|rdSytt�}Wntk
r8YnBX|�6ddl}|jdd	d�}|j	|�|j
dddd�}WdQRX|r�dSdS)
NZ(PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSINGFr�#)Z
interpolationZcomment_prefixesZemail_addr_parsing)ZfallbackT)r)�bool�os�environ�get�open�_EMAIL_CONFIG_FILE�FileNotFoundError�configparserZConfigParserZ	read_fileZ
getboolean)Zdisabled�filer$�configrrrr?s"
rcCs&y|j�dStk
r dSXdS)NFT)�encode�UnicodeEncodeError)�srrr�_has_surrogates\s
r*cCs|jdd�}|jdd�S)Nzutf-8�surrogateescape�replace)r'�decode)�stringZoriginal_bytesrrr�	_sanitizeisr/�utf-8c
Cs�|\}}|jd�|r�y|jd�Wn8tk
r\t|t�rFt|�}|j|�}d||fSXd}tj|�rpd}tj	d|�}d||||fS|S)N�asciiz%s <%s>r�"z\\\g<0>z%s%s%s <%s>)
r'r(�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�nameZaddressZencoded_nameZquotesrrrrus 




ccs`d}d}xDt|�D]8\}}|r2|d|fVd}q|dkr@d}q||fVqW|r\|dfVdS)NrF�\T)�	enumerate)�addr�pos�escape�chrrr�_iter_escaped_chars�srAcCs�d|kr|Sd}d}g}xPt|�D]D\}}|dkr"|dkr@|}q"||krZ|j|||��|d}d}q"W|t|�kr�|j||d��dj|�S)Nr2r�r)rA�append�len�join)r=�startZopen_pos�resultr>r@rrr�_strip_quoted_realnames�s rHT)�strictcCs�|dkrt�}|s4tjdd�|D��}t|�}|jSdd�|D�}t|�}tj|�}t|�}t|j�}d}x&|D]}t|�}|d|jd�7}qpWt	|�|kr�d	gS|S)
Ncss|]}t|�VqdS)N)r4)�.0�vrrr�	<genexpr>�szgetaddresses.<locals>.<genexpr>cSsg|]}t|��qSr)r4)rJrKrrr�
<listcomp>�sz getaddresses.<locals>.<listcomp>rrB�,r)rr)
r�
COMMASPACErE�_AddressList�addresslist�_pre_parse_validation�_post_parse_validationrH�countrD)ZfieldvaluesrI�all�ar=rG�nrKrrrr�s$


cCsXt|�}d}xBt|�D]6\}}|dkr0|d7}q|dkr|d8}|dkrdSqW|dkS)Nr�(rB�)F)rHrA)r=Zopensr>r@rrr�_check_parenthesis�s
rZcCs,g}x"|D]}t|�sd}|j|�q
W|S)Nz('', ''))rZrC)Zemail_header_fields�accepted_valuesrKrrrrRs
rRcCs0g}x&|D]}d|dkrd}|j|�q
W|S)N�[rBr)rr)rC)Zparsed_email_header_tuplesr[rKrrrrS
s
rSa_
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<atom>.*?)         # non-greedy up to the next ?= is the atom
  \?=                   # literal ?=
  cCsfddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrBr���r)�	timetuple�zonerrr�_format_timetuple_and_zone"srdFcCsR|dkrtj�}|s|r,tjj|tjj�}ntjj|�}|rH|j�}d}t||�S)NF)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr+scCsV|j�}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}n
|jd�}t||�S)Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)rb�tzinforfrgrh�
ValueErrorZstrftimerd)rmrl�nowrcrrrrHs

cCs^ttj�d�}tj�}tjd�}|dkr0d}nd|}|dkrHtj�}d|||||f}|S)N�d�@r�.z<%d.%d.%d%s@%s>)�intrer�getpid�randomZgetrandbits�socketZgetfqdn)ZidstringZdomainrj�pidZrandintZmsgidrrrr	[s

cCsNt|��^}}|dkr(tj|dd��Stj|dd�dtjtj|d��i�S)Nr]rn)�seconds)rrfrg�	timedelta)�dataZdtuple�tzrrrrrs
cCs�|dkrt�}|s,t|�j}|s$dS|dSt|t�r>|d}t|t�sLdSt|g�d}tt|�j�}|szt|�dkr~dS|dS)NrrrB)rr)rr)rr)	rrPrQr3�listr4rRrSrD)r=rIZaddrsrrrrzs 


cCs`t|�dkr\|jd�r<|jd�r<|dd�jdd�jdd�S|jd�r\|jd�r\|dd	�S|S)
NrBr2z\\r;z\"�<�>���r�)rD�
startswith�endswithr,)r4rrrr�scCs&|jtd�}t|�dkr"dd|fS|S)Nr^)�split�TICKrD)r)�partsrrrr�s
cCsDtjj|d|pdd�}|dkr*|dkr*|S|dkr6d}d|||fS)Nrr1)Zsafe�encodingz%s'%s'%s)�urllib�parser)r)r9�languagerrrr�sz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Csx|dd�}g}i}|jd�\}}|j||f�x�|r�|jd�\}}|jd�rTd}nd}t|�}tj|�}|r�|jdd�\}}|dk	r�t|�}|j|g�j|||f�q2|j|dt	|�f�q2W|�rtx�|j
�D]�\}}g}d}	|j�x6|D].\}}
}|�rtj
j|
dd	�}
d}	|j|
�q�Wt	tj|��}|	�r^t|�\}}}|j|||d|ff�q�|j|d|f�q�W|S)
Nr�*TFr:�numz"%s"zlatin-1)r�)�poprCr�r�rfc2231_continuation�match�grouprt�
setdefaultr�items�sortr�r��EMPTYSTRINGrEr)
ZparamsZ
new_paramsZrfc2231_paramsr:�valueZencodedZmor�Z
continuationsZextendedr)r9r�rrrr�sD

r,�us-asciicCsjt|t�st|�dkr t|�S|\}}}|dkr6|}t|d�}yt|||�Stk
rdt|�SXdS)Nr_zraw-unicode-escape)r3�tuplerDr�bytesr4�LookupError)r��errorsZfallback_charsetr9r��textZrawbytesrrrr�s

rBc	Cs|dkrtjjtjj�j�S|jdk	r.|j�S|j�dd�|f}tj|�}tj	|�}y tj
|jd�}tj||j�}Wn�t
k
r�|tjtj|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�tj|tj|�}n
tj|�}YnX|j|d�S)NrB)ryr]r)rnr�)rfrprgrhrirnrbreZmktimerkrzZ	tm_gmtoffZtm_zone�AttributeErrorZgmtimeZdaylightZtm_isdstZaltzoneZtznamer,)	rmZisdstZtmryZlocaltmZdeltar|�dstZgmtoffrrrrks$


rk)r0)NFF)F)NN)NN)r,r�r�)Nr�):�__all__r�rerervrwrfZurllib.parser�Zemail._parseaddrrrrPr
rr
rZ
email.charsetrrOr�ZUEMPTYSTRINGZCRLFr��compiler5r7r"rrrr*r/rrArHZsupports_strict_parsingrrZrRrS�VERBOSE�
IGNORECASEZecrerdrrr	rrrrr�ASCIIr�rrrkrrrr�<module>s�



!1

	


$
8
PKb��\�N�xxiterators.cpython-36.pycnu�[���3


 \W�@sLdZdddgZddlZddlmZdd�Zdd	d�Zddd�Zddd
�ZdS)z1Various types of useful iterators and generators.�body_line_iterator�typed_subpart_iterator�walk�N)�StringIOccs2|V|j�r.x|j�D]}|j�EdHqWdS)z�Walk over the message tree, yielding each subpart.

    The walk is performed in depth-first order.  This method is a
    generator.
    N)�is_multipart�get_payloadr)�self�subpart�r
�'/usr/lib64/python3.6/email/iterators.pyrsFccs:x4|j�D](}|j|d�}t|t�r
t|�EdHq
WdS)z�Iterate over the parts, returning string payloads line-by-line.

    Optional decode (default False) is passed through to .get_payload().
    )�decodeN)rr�
isinstance�strr)�msgrr	Zpayloadr
r
rr"s
�textccs<x6|j�D]*}|j�|kr
|dks.|j�|kr
|Vq
WdS)z�Iterate over the subparts with a given MIME type.

    Use `maintype' as the main MIME type to match against; this defaults to
    "text".  Optional `subtype' is the MIME subtype to match against; if
    omitted, only the main type is matched.
    N)rZget_content_maintypeZget_content_subtype)rZmaintype�subtyper	r
r
rr-scCs�|dkrtj}d|d}t||j�d|d�|rJtd|j�|d�n
t|d�|j�r�x"|j�D]}t|||d|�qfWdS)	zA handy debugging aidN� ��)�end�filez [%s])r�)�sys�stdout�printZget_content_typeZget_default_typerr�
_structure)r�fp�levelZinclude_defaultZtabr	r
r
rr;s
r)F)rN)NrF)	�__doc__�__all__r�iorrrrrr
r
r
r�<module>s

PKb��\v��K
K
policy.cpython-36.opt-2.pycnu�[���3


 \�(�@s�ddlZddlmZmZmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddd	d
ddd
dgZejd�ZeGdd
�d
e��Ze�Ze`ejdd�Zejdd�Zejddd�Zejdd�ZdS)�N)�Policy�Compat32�compat32�_extend_docstrings)�_has_surrogates)�HeaderRegistry)�raw_data_manager)�EmailMessagerrr�EmailPolicy�default�strict�SMTP�HTTPz\n|\rcsleZdZeZdZdZe�Ze	Z
�fdd�Zdd�Zdd�Z
d	d
�Zdd�Zd
d�Zdd�Zddd�Z�ZS)r
F�longcs*d|krtj|dt��t�jf|�dS)N�header_factory)�object�__setattr__r�super�__init__)�self�kw)�	__class__��$/usr/lib64/python3.6/email/policy.pyr\szEmailPolicy.__init__cCs|j|jS)N)rZ	max_count)r�namerrr�header_max_countcszEmailPolicy.header_max_countcCs>|djdd�\}}|jd�dj|dd��}||jd�fS)Nr�:�z 	�z
)�split�lstrip�join�rstrip)rZsourcelinesr�valuerrr�header_source_parseus	zEmailPolicy.header_source_parsecCsVt|d�r$|jj�|j�kr$||fSt|t�rFt|j��dkrFtd��||j||�fS)NrrzDHeader values may not contain linefeed or carriage return characters)	�hasattrr�lower�
isinstance�str�len�
splitlines�
ValueErrorr)rrr#rrr�header_store_parse�s

zEmailPolicy.header_store_parsecCs*t|d�r|Sdjtj|��}|j||�S)Nrr)r%r!�linesep_splitterrr)rrr#rrr�header_fetch_parse�s	
zEmailPolicy.header_fetch_parsecCs|j||dd�S)NT)�
refold_binary)�_fold)rrr#rrr�fold�szEmailPolicy.foldcCs0|j|||jdkd�}|jr dnd}|j|d�S)NZ7bit)r/�utf8�ascii�surrogateescape)r0Zcte_typer2�encode)rrr#Zfolded�charsetrrr�fold_binary�szEmailPolicy.fold_binarycs�t|d�r|j|d�S|jr"|jntd��|j�}|jdkp�|jdko�|rft|d�t|�d�kp�t�fdd	�|d
d�D��}|s�|r�t|�r�|j	|dj
|��j|d�S|d|jj
|�|jS)
Nr)Zpolicy�inf�allrr�c3s|]}t|��kVqdS)N)r))�.0�x)�maxlenrr�	<genexpr>�sz$EmailPolicy._fold.<locals>.<genexpr>rrz: )r%r1�max_line_length�floatr*�
refold_sourcer)�anyrrr!�linesep)rrr#r/�linesZrefoldr)r=rr0�s


 zEmailPolicy._fold)F)�__name__�
__module__�__qualname__r	Zmessage_factoryr2rArrrZcontent_managerrrr$r,r.r1r7r0�
__classcell__rr)rrr
s=
T)Zraise_on_defectz
)rC)rCr?)r2)�reZemail._policybaserrrrZemail.utilsrZemail.headerregistryrZemail.contentmanagerrZ
email.messager	�__all__�compiler-r
rrZclonerr
rZSMTPUTF8rrrr�<module>s.
@PKb��\��b@b@header.cpython-36.pycnu�[���3


 \&^�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z
e
jZdZd	Z
d
ZdZdZd
ZdZed�Zed�ZejdejejBejB�Zejd�Zejd�ZejjZdd�Zddd�ZGdd�d�Z Gdd�d�Z!Gdd�de"�Z#dS)z+Header encoding and decoding functionality.�Header�
decode_header�make_header�N)�HeaderParseError)�charset�
� � ���Nz 	zus-asciizutf-8ai
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:cCs�t|d�rdd�|jD�Stj|�s.|dfgSg}x�|j�D]�}tj|�}d}xp|r�|jd�}|rn|j�}d}|r�|j|ddf�|rP|jd�j	�}|jd�j	�}|jd�}|j|||f�qPWq<Wg}	xVt
|�D]J\}
}|
dkr�|dr�||
d	dr�||
ddj�r�|	j|
d�q�Wxt|	�D]}||=�q*Wg}
x�|D]�\}}}|dk�rh|
j||f�n�|d
k�r�t
jj|�}|
j||f�n~|dk�rt|�d}|�r�|d
dd|�7}yt
jj|�}Wn tjk
�r�td��YnX|
j||f�ntd|���qDWg}d}}x~|
D]v\}}t|t��rBt|d�}|dk�rV|}|}nB||k�rx|j||f�|}|}n |dk�r�|t|7}n||7}�q$W|j||f�|S)a;Decode a message header value without converting charset.

    Returns a list of (string, charset) pairs containing each of the decoded
    parts of the header.  Charset is None for non-encoded parts of the header,
    otherwise a lower-case string containing the name of the character set
    specified in the encoded string.

    header may be a string that may or may not contain RFC2047 encoded words,
    or it may be a Header object.

    An email.errors.HeaderParseError may be raised when certain decoding error
    occurs (e.g. a base64 decoding exception).
    �_chunkscSs(g|] \}}tj|t|��t|�f�qS�)�_charsetZ_encode�str)�.0�stringrrr�$/usr/lib64/python3.6/email/header.py�
<listcomp>Msz!decode_header.<locals>.<listcomp>NTrF���q�b�z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
�ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr�AssertionError�
isinstancer�bytes�BSPACE)�headerZwords�line�parts�firstZ	unencodedr�encodingZencodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetrrrr=sz






4






cCsLt|||d�}x8|D]0\}}|dk	r8t|t�r8t|�}|j||�qW|S)a�Create a Header from a sequence of pairs as returned by decode_header()

    decode_header() takes a header value string and returns a sequence of
    pairs of the format (decoded_string, charset) where charset is the string
    name of the character set.

    This function takes one of those sequence of pairs and returns a Header
    instance.  Optional maxlinelen, header_name, and continuation_ws are as in
    the Header constructor.
    )�
maxlinelen�header_name�continuation_wsN)rr-�Charsetr!)Zdecoded_seqr9r:r;�h�srrrrr�sc@sJeZdZddd�Zdd�Zdd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)rNr�strictcCs||dkrt}nt|t�s t|�}||_||_g|_|dk	rH|j|||�|dkrTt}||_|dkrjd|_	nt
|�d|_	dS)aDCreate a MIME-compliant header that can contain many character sets.

        Optional s is the initial header value.  If None, the initial header
        value is not set.  You can later append to the header with .append()
        method calls.  s may be a byte string or a Unicode string, but see the
        .append() documentation for semantics.

        Optional charset serves two purposes: it has the same meaning as the
        charset argument to the .append() method.  It also sets the default
        character set for all subsequent .append() calls that omit the charset
        argument.  If charset is not provided in the constructor, the us-ascii
        charset is used both as s's initial charset and as the default for
        subsequent .append() calls.

        The maximum line length can be specified explicitly via maxlinelen. For
        splitting the first line to a shorter value (to account for the field
        header which isn't included in s, e.g. `Subject') pass in the name of
        the field in header_name.  The default maxlinelen is 78 as recommended
        by RFC 2822.

        continuation_ws must be RFC 2822 compliant folding whitespace (usually
        either a space or a hard tab) which will be prepended to continuation
        lines.

        errors is passed through to the .append() call.
        Nrr)�USASCIIr-r<r�_continuation_wsr
r!�
MAXLINELEN�_maxlinelen�
_headerlenr()�selfr>rr9r:r;�errorsrrr�__init__�s
zHeader.__init__c	Cs�|j�g}d}d}x�|jD]�\}}|}|tjkrJ|jdd�}|jdd�}|r�|o^|j|d�}|dkr�|d	kr�|r�|jt�d}n|d
kr�|r�|jt�|o�|j|d�}|}|j|�qWt	j
|�S)z&Return the string value of the header.N�ascii�surrogateescape�replacer�us-asciir)NrK)NrK)NrK���)�
_normalizer
r�UNKNOWN8BIT�encoder)�	_nonctextr!�SPACE�EMPTYSTRING�join)	rEZuchunks�lastcs�	lastspacerrZnextcsZoriginal_bytes�hasspacerrr�__str__�s*


zHeader.__str__cCs|t|�kS)N)r)rE�otherrrr�__eq__sz
Header.__eq__cCs�|dkr|j}nt|t�s"t|�}t|t�sZ|jp4d}|tjkrN|jdd�}n|j||�}|jpbd}|tjkr�y|j||�Wn"t	k
r�|dkr��t
}YnX|jj||f�dS)a.Append a string to the MIME header.

        Optional charset, if given, should be a Charset instance or the name
        of a character set (which will be converted to a Charset instance).  A
        value of None (the default) means that the charset given in the
        constructor is used.

        s may be a byte string or a Unicode string.  If it is a byte string
        (i.e. isinstance(s, str) is false), then charset is the encoding of
        that byte string, and a UnicodeError will be raised if the string
        cannot be decoded with that charset.  If s is a Unicode string, then
        charset is a hint specifying the character set of the characters in
        the string.  In either case, when producing an RFC 2822 compliant
        header using RFC 2047 rules, the string will be encoded using the
        output codec of the charset.  If the string cannot be encoded to the
        output codec, a UnicodeError will be raised.

        Optional `errors' is passed as the errors argument to the decode
        call if s is a byte string.
        Nzus-asciirI)
rr-r<rZinput_codecrNr)Zoutput_codecrO�UnicodeEncodeError�UTF8r
r!)rEr>rrFZ
input_charsetZoutput_charsetrrrr!	s$






z
Header.appendcCs|j�p|dkS)z=True if string s is not a ctext character of RFC822.
        �(�)�\)r\r]r^)r$)rEr>rrrrP4szHeader._nonctext�;, 	rcCs�|j�|dkr|j}|dkr"d}t|j||j|�}d}d}}�x4|jD�](\}}	|dk	r�|ol|j|d�}|d
kr�|s�|	dkr�|j�n|	dkr�|r�|j�|o�|j|d
�}|	}d}|j�}
|
r�|j	d|
d|	�n|j	dd|	�xr|
dd�D]b}|j
�|	jdk	�r,|j	|jd|j�|	�n.|j�}|dt
|�t
|��}
|j	|
||	��q�Wt
|
�dkrJ|j
�qJW|j�r�|j�|j|�}tj|��r�td	j|���|S)a�Encode a message header into an RFC-compliant format.

        There are many issues involved in converting a given string for use in
        an email header.  Only certain character sets are readable in most
        email clients, and as header strings can only contain a subset of
        7-bit ASCII, care must be taken to properly convert and encode (with
        Base64 or quoted-printable) header strings.  In addition, there is a
        75-character length limit on any given encoded header field, so
        line-wrapping must be performed, even with double-byte character sets.

        Optional maxlinelen specifies the maximum length of each generated
        line, exclusive of the linesep string.  Individual lines may be longer
        than maxlinelen if a folding point cannot be found.  The first line
        will be shorter by the length of the header name plus ": " if a header
        name was specified at Header construction time.  The default value for
        maxlinelen is determined at header construction time.

        Optional splitchars is a string containing characters which should be
        given extra weight by the splitting algorithm during normal header
        wrapping.  This is in very rough support of RFC 2822's `higher level
        syntactic breaks':  split points preceded by a splitchar are preferred
        during line splitting, with the characters preferred in the order in
        which they appear in the string.  Space and tab may be included in the
        string to indicate whether preference should be given to one over the
        other as a split point when other split chars do not appear in the line
        being split.  Splitchars does not affect RFC 2047 encoded lines.

        Optional linesep is a string to be used to separate the lines of
        the value.  The default value is the most useful for typical
        Python applications, but it can be set to \r\n to produce RFC-compliant
        line separators when needed.
        Nri@B�us-asciirFrrz8header value appears to contain an embedded header: {!r})Nr`)Nr`)Nr`rL)rMrC�_ValueFormatterrDrAr
rP�add_transitionr�feed�newline�header_encodingr r(�_str�_embedded_headerrr�format)rE�
splitcharsr9�linesepZ	formatterrTrVrUrr�linesr1Zsline�fws�valuerrrrO9sR!


z
Header.encodecCs|g}d}g}xL|jD]B\}}||kr0|j|�q|dk	rL|jtj|�|f�|g}|}qW|rr|jtj|�|f�||_dS)N)r
r!rQrS)rEZchunksr8Z
last_chunkrrrrrrM�szHeader._normalize)NNNNrr?)Nr?)r_Nr)
�__name__�
__module__�__qualname__rGrWrYr!rPrOrMrrrrr�s
- 
+
Pc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)racCs0||_||_t|�|_||_g|_t|�|_dS)N)�_maxlenrAr(�_continuation_ws_len�_splitchars�_lines�_Accumulator�
_current_line)rEZ	headerlen�maxlenr;rirrrrG�s
z_ValueFormatter.__init__cCs|j�|j|j�S)N)rdrSrt)rErjrrrrf�sz_ValueFormatter._strcCs
|jt�S)N)rf�NL)rErrrrW�sz_ValueFormatter.__str__cCsp|jj�}|dkr|jj|�t|j�dkrb|jj�rP|jdt|j�7<n|jjt|j��|jj�dS)Nrrrr)rrrL)	rvr�pushr(�	is_onlywsrtrr!�reset)rEZend_of_linerrrrd�s

z_ValueFormatter.newlinecCs|jjdd�dS)Nrr)rvry)rErrrrb�sz_ValueFormatter.add_transitioncCs�|jdkr|j|||j�dS|j||j��}y|jd�}Wntk
rPdSX|dk	rf|j||�y|j�}Wntk
r�dSX|j�|j	j
|j|�x|D]}|jj
|j|�q�WdS)Nr)re�_ascii_splitrsZheader_encode_lines�_maxlengthsr�
IndexError�
_append_chunkrdrvryrArtr!)rErlrrZ
encoded_linesZ
first_line�	last_liner1rrrrc�s$

z_ValueFormatter.feedccs*|jt|j�Vx|j|jVqWdS)N)rqr(rvrr)rErrrr}�sz_ValueFormatter._maxlengthscCsjtjdtd||�}|dr0dg|dd�<n
|jd�x*tt|�gd�D]\}}|j||�qNWdS)Nz([z]+)rrr)�rer�FWSr�zip�iterr)rErlrrir2�partrrrr|�s
z_ValueFormatter._ascii_splitcCs
|jj||�t|j�|jk�rx�|jD]t}xlt|jj�ddd�D]P}|j�rp|j|d}|rp|d|krpP|j|dd}|rD|d|krDPqDWq(Pq(W|jj�\}}|jj	dkr�|j
�|s�d}|jj||�dS|jj|�}|jj
t|j��|jj|�dS)NrrrrLrL)rvryr(rqrs�range�
part_countr$r�
_initial_sizerd�pop_fromrtr!rr{)rErlrZch�iZprevpartr�Z	remainderrrrr�s.z_ValueFormatter._append_chunkN)rnrorprGrfrWrdrbrcr}r|rrrrrra�s%racsjeZdZd�fdd�	Zdd�Zddd�Z�fdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
�fdd�Z�ZS)rurcs||_t�j�dS)N)r��superrG)rEZinitial_size)�	__class__rrrGsz_Accumulator.__init__cCs|j||f�dS)N)r!)rErlrrrrry#sz_Accumulator.pushcCs||d�}g||d�<|S)Nr)rEr�Zpoppedrrrr�&sz_Accumulator.pop_fromcs|j�dkrdSt�j�S)Nrr)rr)r�r�r)rE)r�rrr+sz_Accumulator.popcCstdd�|D�|j�S)Ncss"|]\}}t|�t|�VqdS)N)r()rrlr�rrr�	<genexpr>1sz'_Accumulator.__len__.<locals>.<genexpr>)�sumr�)rErrr�__len__0sz_Accumulator.__len__cCstjdd�|D��S)Ncss |]\}}tj||f�VqdS)N)rRrS)rrlr�rrrr�5sz'_Accumulator.__str__.<locals>.<genexpr>)rRrS)rErrrrW4s
z_Accumulator.__str__NcCs"|dkrg}||dd�<d|_dS)Nr)r�)rEZstartvalrrrr{8sz_Accumulator.resetcCs|jdko|pt|�j�S)Nr)r�rr$)rErrrrz>sz_Accumulator.is_onlywscs
t�j�S)N)r�r�)rE)r�rrr�Asz_Accumulator.part_count)r)r)N)
rnrorprGryr�rr�rWr{rzr��
__classcell__rr)r�rrus

ruz        )NNr)$�__doc__�__all__r�r*Zemail.quoprimimer&Zemail.base64mimeZemail.errorsrrrr<rxrQr/ZSPACE8rRrBr�r@r[�compile�VERBOSE�
IGNORECASE�	MULTILINErZfcrergr'Z_max_appendrrrra�listrurrrr�<module>s@

_
kPKb��\�٢,e%e%generator.cpython-36.opt-2.pycnu�[���3

���i�S�@s�dddgZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
d	Zd
Zejd�Zejdej�Zejd
�Zejd�ZGdd�d�ZGdd�de�ZdZGdd�de�Zeeejd��ZdeZejZdS)�	Generator�DecodedGenerator�BytesGenerator�N)�deepcopy)�StringIO�BytesIO)�_has_surrogates)�HeaderWriteError�_�
z
\r\n|\r|\nz^From z\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]s\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]c@s�eZdZd&dd�dd�Zdd�Zd'dd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
e
Zdd�Zdd�Zdd�Zd d!�Zed(d"d#��Zed$d%��ZdS))rN)�policycCs6|dkr|dkrdn|j}||_||_||_||_dS)NT)�mangle_from_�_fp�
_mangle_from_�maxheaderlenr)�self�outfpr
rr�r�'/usr/lib64/python3.6/email/generator.py�__init__'szGenerator.__init__cCs|jj|�dS)N)r�write)r�srrrrGszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|j|j�|_d|_|j|j�|_|j}|j}zL||_||_|r�|j	�}|s�dt
jt
j
��}|j||j�|j
|�Wd||_||_XdS)N)�linesep)�max_line_length�zFrom nobody )r�clonerr�_NL�_encode�_encoded_NLZ_EMPTY�_encoded_EMPTYZget_unixfrom�timeZctimer�_write)r�msg�unixfromrrZold_gen_policyZold_msg_policyZufromrrr�flattenKs,
zGenerator.flattencCs|j||jd|jd�S)N)r)�	__class__rr)r�fprrrr|szGenerator.clonecCst�S)N)r)rrrr�_new_buffer�szGenerator._new_buffercCs|S)Nr)rrrrrr�szGenerator._encodecCsX|sdStj|�}x*|dd�D]}|j|�|j|j�q W|drT|j|d�dS)N����r)r))�NLCRE�splitrr)r�lines�linerrr�_write_lines�s

zGenerator._write_linescCs�|j}z"d|_|j�|_}|j|�Wd||_|j}|`X|rht|�}|jd|d�|jd|d�t|dd�}|dkr�|j|�n||�|jj|j	��dS)Nzcontent-transfer-encodingrzcontent-typer(�_write_headers)
r�
_munge_cter'�	_dispatchrZreplace_header�getattrr/r�getvalue)rr"ZoldfpZsfpZ	munge_cte�methrrrr!�s"zGenerator._writecCst|j�}|j�}tj||f�jdd�}t|d|d�}|dkrh|jdd�}t|d|d�}|dkrh|j}||�dS)N�-r
Z_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer2�
_writeBody)rr"�main�subZspecificr4Zgenericrrrr1�szGenerator._dispatchcCs�x�|j�D]�\}}|jj||�}|jjr�|jj}|j|jj�sRtd|�d|����|}|j|�rr|dt|��}tj	|�r�td|����|j
|�q
W|j
|j�dS)Nz folded header does not end with z: z folded header contains newline: )�	raw_itemsrZfold�verify_generated_headersr�endswithr	�len�NEWLINE_WITHOUT_FWSP�searchrr)rr"�h�v�foldedr�folded_no_lineseprrrr/�s

zGenerator._write_headerscCs�|j�}|dkrdSt|t�s.tdt|���t|j�r~|jd�}|dk	r~t|�}|d=|j	||�|j�}|d|df|_
|jr�tj
d|�}|j|�dS)Nzstring payload expected: %s�charsetzcontent-transfer-encodingzcontent-typez>From )�get_payload�
isinstance�str�	TypeError�typer�_payloadZ	get_paramrZset_payloadr0r�fcrer=r.)rr"�payloadrHrrr�_handle_text�s"


zGenerator._handle_textcCs�g}|j�}|dkrg}n(t|t�r2|j|�dSt|t�sB|g}x>|D]6}|j�}|j|�}|j|d|jd�|j	|j
��qHW|j�}|s�|jj
|�}|j|�}|j|�|jdk	r�|jr�tjd|j�}	n|j}	|j|	�|j|j�|jd||j�|�r|jj|jd��x4|D],}
|j|jd||j�|jj|
��qW|j|jd|d|j�|jdk	�r�|j�r�tjd|j�}n|j}|j|�dS)NF)r#rz>From z--r)rIrJrKr�listr'rr$r�appendr3Zget_boundaryrr9�_make_boundaryZset_boundary�preamblerrOr=r.r�pop�epilogue)rr"ZmsgtextsZsubparts�partr�g�boundaryZalltextrUZ	body_partrWrrr�_handle_multipart
sJ









zGenerator._handle_multipartcCs0|j}|jdd�|_z|j|�Wd||_XdS)Nr)r)rrr[)rr"�prrr�_handle_multipart_signedGs
z"Generator._handle_multipart_signedcCs�g}x�|j�D]t}|j�}|j|�}|j|d|jd�|j�}|j|j�}|rx|d|jkrx|j	|jj
|dd���q|j	|�qW|jj|jj
|��dS)NF)r#rr(r)r))
rIr'rr$rr3r+rrrSr9rr)rr"ZblocksrXrrY�textr,rrr�_handle_message_delivery_statusRs
z)Generator._handle_message_delivery_statuscCs^|j�}|j|�}|j}t|t�rD|j|jd�d|jd�|j�}n
|j	|�}|j
j|�dS)NrF)r#r)r'rrNrJrRr$rIrr3rrr)rr"rrYrPrrr�_handle_messagegs




zGenerator._handle_messagecCsztjtj�}d	t|d}|dkr(|S|}d}xD|jdtj|�dtj�}|j	|�sZP|dt
|�}|d7}q2W|S)
N�=�z==rz^--z(--)?$�.r(z===============)�randomZ	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINErCrK)�clsr^�tokenrZ�bZcounterZcrerrrrT�s
zGenerator._make_boundarycCstj||�S)N)ri�compile)rlr�flagsrrrrh�szGenerator._compile_re)NN)FN)N)�__name__�
__module__�__qualname__rrr$rr'rr.r!r1r/rQr;r[r]r_r`�classmethodrTrhrrrrrs(

1#:csLeZdZdd�Zdd�Zdd�Zdd�Z�fd	d
�ZeZe	dd��Z
�ZS)
rcCs|jj|jdd��dS)N�ascii�surrogateescape)rr�encode)rrrrrr�szBytesGenerator.writecCst�S)N)r)rrrrr'�szBytesGenerator._new_buffercCs
|jd�S)Nru)rw)rrrrrr�szBytesGenerator._encodecCs�x�|j�D]�\}}|jj||�}|jjr�|jjj�}|j|�sRtd|�d|����|}|j|�rr|dt|��}t	j
|�r�td|����|jj|�q
W|j|j
�dS)Nz folded header does not end with z: z folded header contains newline: )r>rZfold_binaryr?rrwr@r	rA�NEWLINE_WITHOUT_FWSP_BYTESrCrrr)rr"rDrErFrrGrrrr/�s


zBytesGenerator._write_headerscs^|jdkrdSt|j�rJ|jjdkrJ|jr<tjd|j�|_|j|j�ntt	|�j
|�dS)NZ7bitz>From )rNrrZcte_typerrOr=r.�superrrQ)rr")r%rrrQ�s
zBytesGenerator._handle_textcCstj|jd�|�S)Nru)rirorw)rlrrprrrrh�szBytesGenerator._compile_re)rqrrrsrr'rr/rQr;rtrh�
__classcell__rr)r%rr�s

zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s$eZdZddd�dd�Zdd�ZdS)rN)rcCs.tj|||||d�|dkr$t|_n||_dS)N)r)rr�_FMTrg)rrr
rZfmtrrrrr�s
zDecodedGenerator.__init__cCs�x�|j�D]v}|j�}|dkr4t|jdd�|d�q
|dkr>q
t|j|j�|j�|j�|jd�|jdd�|jd	d
�d�|d�q
WdS)Nr^F)�decode)�fileZ	multipartz
[no filename]zContent-Descriptionz[no description]zContent-Transfer-Encodingz
[no encoding])rM�maintype�subtype�filenameZdescription�encoding)	�walkr6�printrIrgZget_content_typer7�get_filename�get)rr"rXr~rrrr1�s 
zDecodedGenerator._dispatch)NNN)rqrrrsrr1rrrrr�sr(z%%0%dd) �__all__rirer rd�copyr�iorrZemail.utilsrZemail.errorsr	r8�NLror*rkrOrBrxrrr{rrA�reprrfZ_widthrgrTrrrr�<module>s.



|?;PKb��\��_j�j�message.cpython-36.opt-1.pycnu�[���3


 \��@s�dZddgZddlZddlZddlZddlmZmZddlm	Z	ddlm
Z
ddlmZm
Z
dd	lmZdd
lmZejZdZejd�Zd
d�Zddd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZdS)z8Basic message object for the email package object model.�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�Policy�compat32)�charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]cCs4t|�jd�\}}}|s$|j�dfS|j�|j�fS)N�;)�str�	partition�strip)�param�a�sep�b�r�%/usr/lib64/python3.6/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}tj|d|d|d�}d||fSy|jd�Wn2tk
r�|d7}tj|dd	�}d||fSX|s�tj|�r�d
|tj	|�fSd||fSn|SdS)a~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.  If value is a
    three tuple (charset, language, value), it will be encoded according
    to RFC2231 rules.  If it contains non-ascii characters it will likewise
    be encoded according to RFC2231 rules, using the utf-8 charset and
    a null language.
    Nr�*��z%s=%s�asciizutf-8�z%s="%s")
�len�
isinstance�tuplerZencode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer#rrr�_formatparam's	
r%cCs�dt|�}g}x�|dd�dkr�|dd�}|jd�}x<|dkrt|jdd|�|jdd|�drt|jd|d�}q:W|dkr�t|�}|d|�}d|kr�|jd�}|d|�j�j�d||dd�j�}|j|j��||d�}qW|S)Nrrr�"z\"r�=)r
�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
*
,r1cCs4t|t�r&|d|dtj|d�fStj|�SdS)Nrrr)rrr�unquote)r$rrr�
_unquotevalue]s
r3c@s�eZdZdZefdd�Zdd�Zddd	d
�Zdd�Zded
d�Z	dd�Z
dd�Zdd�Zdd�Z
dfdd�Zdgdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zdhd1d2�Zd3d4�Zd5d6�Zdid7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&djdKdL�Z'dkdMdN�Z(dldQdR�Z)dmdSdT�Z*dndUdV�Z+dodWdX�Z,dpdYdZ�Z-d[d\�Z.dqd]d^�Z/drd_d`�Z0dadb�Z1ddcl2m3Z3dS)sra�Basic message object.

    A message object is defined as something that has a bunch of RFC 2822
    headers and a payload.  It may optionally have an envelope header
    (a.k.a. Unix-From or From_ header).  If the message is a container (i.e. a
    multipart or a message/rfc822), then the payload is a list of Message
    objects, otherwise it is a string.

    Message objects implement part of the `mapping' interface, which assumes
    there is exactly one occurrence of the header per message.  Some headers
    do in fact appear multiple times (e.g. Received) and for those headers,
    you must use the explicit API to set or get all the headers.  Not all of
    the mapping methods are implemented.
    cCs:||_g|_d|_d|_d|_d|_|_g|_d|_dS)Nz
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr4rrr�__init__xszMessage.__init__cCs|j�S)z9Return the entire formatted message as a string.
        )�	as_string)r;rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|j�S)a�Return the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  For backward compatibility reasons, if maxheaderlen is
        not specified it defaults to 0, so you must override it explicitly
        if you want a different maxheaderlen.  'policy' is passed to the
        Generator instance used to serialize the mesasge; if it is not
        specified the policy associated with the message instance is used.

        If the message object contains binary data that is not encoded
        according to RFC standards, the non-compliant data will be replaced by
        unicode "unknown character" code points.
        r)�	GeneratorNF)�mangle_from_�maxheaderlenr4)�unixfrom)�email.generatorr?r4r�flatten�getvalue)r;rBrAr4r?�fp�grrrr=�szMessage.as_stringcCs|j�S)z?Return the entire formatted message as a bytes object.
        )�as_bytes)r;rrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|j�S)aJReturn the entire formatted message as a bytes object.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  'policy' is passed to the BytesGenerator instance used to
        serialize the message; if not specified the policy associated with
        the message instance is used.
        r)�BytesGeneratorNF)r@r4)rB)rCrJr4rrDrE)r;rBr4rJrFrGrrrrH�szMessage.as_bytescCst|jt�S)z6Return True if the message consists of multiple parts.)rr7�list)r;rrr�is_multipart�szMessage.is_multipartcCs
||_dS)N)r6)r;rBrrr�set_unixfrom�szMessage.set_unixfromcCs|jS)N)r6)r;rrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.y|jj|�Wntk
r@td��YnXdS)z�Add the given payload to the current payload.

        The current payload will always be a list of objects after this method
        is called.  If you want to set the payload to a scalar object, use
        set_payload() instead.
        Nz=Attach is not valid on a message with a non-multipart payload)r7r,�AttributeError�	TypeError)r;�payloadrrr�attach�s

zMessage.attachcCs�|j�r(|rdS|dkr|jS|j|S|dk	rPt|jt�rPtdt|j���|j}t|jdd��j�}t|t��rt	j
|�r�|jdd�}|s�y|j|j
dd�d�}Wn tk
r�|jdd�}YnXn6|�ry|jd�}Wn tk
�r|jd	�}YnX|�s|S|d
k�r tj|�S|dk�rbtdj|j���\}}x|D]}|jj||��qFW|S|dk�r�t|�}	t�}
ytj|	|
dd�|
j�Stjk
�r�|SXt|t��r�|S|S)aZReturn a reference to the payload.

        The payload will either be a list object or a string.  If you mutate
        the list object, you modify the message's payload in place.  Optional
        i returns that index into the payload.

        Optional decode is a flag indicating whether the payload should be
        decoded or not, according to the Content-Transfer-Encoding header
        (default is False).

        When True and the message is not a multipart, the payload will be
        decoded if this header's value is `quoted-printable' or `base64'.  If
        some other encoding is used, or the header is missing, or if the
        payload has bogus data (i.e. bogus base64 or uuencoded data), the
        payload is returned as-is.

        If the message is a multipart and the decode flag is True, then None
        is returned.
        NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper
�replacezraw-unicode-escapezquoted-printable�base64��
x-uuencode�uuencode�uue�x-uueT)�quiet)rWrXrYrZ)rLr7rrKrP�typer
�getr+rZ_has_surrogatesr�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr4Z
handle_defectr�uurE�Error)r;r0r^rQ�cteZbpayloadr$r9ZdefectZin_fileZout_filerrr�get_payload�sV"






zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|j|j�}t|d�rT|jdd�|_n||_|dk	rl|j|�dS)z�Set the payload to the given value.

        Optional charset sets the message's default character set.  See
        set_charset() for details.
        rNr^rrS)�hasattrr7r�Charsetr�output_charsetr^�set_charset)r;rQr
rrr�set_payload/s


zMessage.set_payloadcCs|dkr|jd�d|_dSt|t�s.t|�}||_d|krH|jdd�d|krf|jdd|j�d�n|jd|j��||j�kr�|j|j�|_d|k�r|j	�}y||�Wnjt
k
�r|j}|r�y|jd	d
�}Wn tk
r�|j|j
�}YnX|j|�|_|jd|�YnXdS)a�Set the charset of the payload to a given character set.

        charset can be a Charset instance, a string naming a character set, or
        None.  If it is a string it will be converted to a Charset instance.
        If charset is None, the charset parameter will be removed from the
        Content-Type field.  Anything else will generate a TypeError.

        The message will be assumed to be of type text/* encoded with
        charset.input_charset.  It will be converted to charset.output_charset
        and encoded properly, if needed, when generating the plain text
        representation of the message.  MIME headers (MIME-Version,
        Content-Type, Content-Transfer-Encoding) will be added as needed.
        Nr
zMIME-Versionz1.0zContent-Typez
text/plain)r
zContent-Transfer-EncodingrrS)�	del_paramr8rrj�
add_headerZget_output_charset�	set_paramZbody_encoder7Zget_body_encodingrPrrark)r;r
rgrQrrrrlCs8


zMessage.set_charsetcCs|jS)zKReturn the Charset instance associated with the message's payload.
        )r8)r;rrr�get_charsetrszMessage.get_charsetcCs
t|j�S)z9Return the total number of headers, including duplicates.)rr5)r;rrr�__len__zszMessage.__len__cCs
|j|�S)a-Get a header value.

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, exactly which
        occurrence gets returned is undefined.  Use get_all() to get all
        the values matching a header field name.
        )r])r;�namerrr�__getitem__~s	zMessage.__getitem__cCsv|jj|�}|r\|j�}d}x>|jD]4\}}|j�|kr$|d7}||kr$tdj||���q$W|jj|jj||��dS)z�Set the value of a header.

        Note: this does not overwrite an existing header with the same field
        name.  Use __delitem__() first to delete any existing headers.
        rrz/There may be at most {} {} headers in a messageN)r4Zheader_max_countr+r5�
ValueError�formatr,�header_store_parse)r;rs�valZ	max_countZlname�found�k�vrrr�__setitem__�szMessage.__setitem__cCsD|j�}g}x,|jD]"\}}|j�|kr|j||f�qW||_dS)zwDelete all occurrences of a header, if present.

        Does not raise an exception if the header is missing.
        N)r+r5r,)r;rs�
newheadersrzr{rrr�__delitem__�szMessage.__delitem__cCs|j�dd�|jD�kS)NcSsg|]\}}|j��qSr)r+)�.0rzr{rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r+r5)r;rsrrr�__contains__�szMessage.__contains__ccsx|jD]\}}|VqWdS)N)r5)r;Zfieldr$rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)a.Return a list of all the message's header field names.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSrr)rrzr{rrrr��sz Message.keys.<locals>.<listcomp>)r5)r;rrr�keys�szMessage.keyscs�fdd��jD�S)a)Return a list of all the message's header values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        csg|]\}}�jj||��qSr)r4�header_fetch_parse)rrzr{)r;rrr��sz"Message.values.<locals>.<listcomp>)r5)r;r)r;r�values�s
zMessage.valuescs�fdd��jD�S)a'Get all the message's header fields and values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cs"g|]\}}|�jj||�f�qSr)r4r�)rrzr{)r;rrr��sz!Message.items.<locals>.<listcomp>)r5)r;r)r;r�items�s
z
Message.itemscCs:|j�}x,|jD]"\}}|j�|kr|jj||�SqW|S)z~Get a header value.

        Like __getitem__() but return failobj instead of None when the field
        is missing.
        )r+r5r4r�)r;rs�failobjrzr{rrrr]�s
zMessage.getcCs|jj||f�dS)z�Store name and value in the model without modification.

        This is an "internal" API, intended only for use by a parser.
        N)r5r,)r;rsr$rrr�set_raw�szMessage.set_rawcCst|jj��S)z�Return the (name, value) header pairs without modification.

        This is an "internal" API, intended only for use by a generator.
        )�iterr5�copy)r;rrr�	raw_items�szMessage.raw_itemscCsLg}|j�}x2|jD](\}}|j�|kr|j|jj||��qW|sH|S|S)aQReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original
        message, and may contain duplicates.  Any fields deleted and
        re-inserted are always appended to the header list.

        If no such fields exist, failobj is returned (defaults to None).
        )r+r5r,r4r�)r;rsr�r�rzr{rrr�get_all�s	zMessage.get_allcKstg}xH|j�D]<\}}|dkr2|j|jdd��q|jt|jdd�|��qW|dk	rb|jd|�tj|�||<dS)u�Extended header setting.

        name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.  If a
        parameter value contains non-ASCII characters it can be specified as a
        three-tuple of (charset, language, value), in which case it will be
        encoded according to RFC2231 rules.  Otherwise it will be encoded using
        the utf-8 charset and a language of ''.

        Examples:

        msg.add_header('content-disposition', 'attachment', filename='bud.gif')
        msg.add_header('content-disposition', 'attachment',
                       filename=('utf-8', '', Fußballer.ppt'))
        msg.add_header('content-disposition', 'attachment',
                       filename='Fußballer.ppt'))
        N�_�-r)r�r,rTr%�insert�	SEMISPACErc)r;�_name�_valueZ_params�partsrzr{rrrroszMessage.add_headercCs^|j�}xPttt|j��|j�D].\}\}}|j�|kr |jj||�|j|<Pq Wt|��dS)z�Replace a header.

        Replace the first matching header found in the message, retaining
        header order and case.  If no matching header was found, a KeyError is
        raised.
        N)r+�zip�rangerr5r4rw�KeyError)r;r�r�r0rzr{rrr�replace_header!s$zMessage.replace_headercCsHt�}|jd|�}||kr"|j�St|�dj�}|jd�dkrDdS|S)a0Return the message's content type.

        The returned string is coerced to lower case of the form
        `maintype/subtype'.  If there was no Content-Type header in the
        message, the default type as given by get_default_type() will be
        returned.  Since according to RFC 2045, messages always have a default
        type this will always return a value.

        RFC 2045 defines a message's default type to be text/plain unless it
        appears inside a multipart/digest container, in which case it would be
        message/rfc822.
        zcontent-typer�/rz
text/plain)�objectr]�get_default_typerr+r))r;�missingr$�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|j�}|jd�dS)z�Return the message's main content type.

        This is the `maintype' part of the string returned by
        get_content_type().
        r�r)r��split)r;r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|j�}|jd�dS)z�Returns the message's sub-content type.

        This is the `subtype' part of the string returned by
        get_content_type().
        r�r)r�r�)r;r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jS)aReturn the `default' content type.

        Most messages have a default content type of text/plain, except for
        messages that are subparts of multipart/digest containers.  Such
        subparts have a default content type of message/rfc822.
        )r:)r;rrrr�^szMessage.get_default_typecCs
||_dS)z�Set the `default' content type.

        ctype should be either "text/plain" or "message/rfc822", although this
        is not enforced.  The default content type is not stored in the
        Content-Type header.
        N)r:)r;r�rrr�set_default_typegszMessage.set_default_typec	Cs�t�}|j||�}||kr|Sg}xdt|�D]X}y$|jdd�\}}|j�}|j�}Wn tk
rt|j�}d}YnX|j||f�q,Wtj|�}|S)Nr'rr)	r�r]r1r�rrur,rZ
decode_params)	r;r��headerr�r$�params�prsrxrrr�_get_params_preserveps 

zMessage._get_params_preserve�content-typeTcCs8t�}|j||�}||kr|S|r0dd�|D�S|SdS)amReturn the message's Content-Type parameters, as a list.

        The elements of the returned list are 2-tuples of key/value pairs, as
        split on the `=' sign.  The left hand side of the `=' is the key,
        while the right hand side is the value.  If there is no `=' sign in
        the parameter the value is the empty string.  The value is as
        described in the get_param() method.

        Optional failobj is the object to return if there is no Content-Type
        header.  Optional header is the header to search instead of
        Content-Type.  If unquote is True, the value is unquoted.
        cSsg|]\}}|t|�f�qSr)r3)rrzr{rrrr��sz&Message.get_params.<locals>.<listcomp>N)r�r�)r;r�r�r2r�r�rrr�
get_params�s
zMessage.get_paramscCsJ||kr|Sx8|j||�D](\}}|j�|j�kr|r>t|�S|SqW|S)a�Return the parameter value if found in the Content-Type header.

        Optional failobj is the object to return if there is no Content-Type
        header, or the Content-Type header has no such parameter.  Optional
        header is the header to search instead of Content-Type.

        Parameter keys are always compared case insensitively.  The return
        value can either be a string, or a 3-tuple if the parameter was RFC
        2231 encoded.  When it's a 3-tuple, the elements of the value are of
        the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
        LANGUAGE can be None, in which case you should consider VALUE to be
        encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
        The parameter value (either the returned string, or the VALUE item in
        the 3-tuple) is always unquoted, unless unquote is set to False.

        If your application doesn't care whether the parameter was RFC 2231
        encoded, it can turn the return value into a string as follows:

            rawparam = msg.get_param('foo')
            param = email.utils.collapse_rfc2231_value(rawparam)

        )r�r+r3)r;rr�r�r2rzr{rrrr_�szMessage.get_param�Content-TypercCst|t�r|r|||f}||kr4|j�dkr4d}n
|j|�}|j||d�sv|s^t|||�}q�tj|t|||�g�}nfd}x`|j||d�D]N\}	}
d}|	j�|j�kr�t|||�}nt|	|
|�}|s�|}q�tj||g�}q�W||j|�k�r|�r|j	||�n||=|||<dS)a�Set a parameter in the Content-Type header.

        If the parameter already exists in the header, its value will be
        replaced with the new value.

        If header is Content-Type and has not yet been defined for this
        message, it will be set to "text/plain" and the new parameter and
        value will be appended as per RFC 2045.

        An alternate header can be specified in the header argument, and all
        parameters will be quoted as necessary unless requote is False.

        If charset is specified, the parameter will be encoded according to RFC
        2231.  Optional language specifies the RFC 2231 language, defaulting
        to the empty string.  Both charset and language should be strings.
        zcontent-typez
text/plain)r�r)r�r2N)
rrr+r]r_r%r�rcr�r�)r;rr$r��requoter
ZlanguagerTr�Z	old_paramZ	old_valueZappend_paramrrrrp�s2

zMessage.set_paramcCs�||krdSd}xR|j||d�D]@\}}|j�|j�kr |sJt|||�}q tj|t|||�g�}q W||j|�kr�||=|||<dS)a>Remove the given parameter completely from the Content-Type header.

        The header will be re-written in place without the parameter or its
        value. All values will be quoted as necessary unless requote is
        False.  Optional header specifies an alternative to the Content-Type
        header.
        Nr)r�r2)r�r+r%r�rcr])r;rr�r�Z	new_ctyper�r{rrrrn�szMessage.del_paramcCs�|jd�dkst�|j�dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<x(|dd�D]\}}|j||||�qjWdS)	aKSet the main type and subtype for the Content-Type header.

        type must be a string in the form "maintype/subtype", otherwise a
        ValueError is raised.

        This method replaces the Content-Type header, keeping all the
        parameters in place.  If requote is False, this leaves the existing
        header's quoting as is.  Otherwise, the parameters will be quoted (the
        default).

        An alternative header can be specified in the header argument.  When
        the Content-Type header is set, we'll always also add a MIME-Version
        header.
        r�rzcontent-typezmime-versionz1.0zMIME-VersionN)r�r2)r)rur+r�rp)r;r\r�r�r�r�r{rrr�set_typeszMessage.set_typecCsDt�}|jd|d�}||kr*|jd|d�}||kr6|Stj|�j�S)a@Return the filename associated with the payload if present.

        The filename is extracted from the Content-Disposition header's
        `filename' parameter, and it is unquoted.  If that header is missing
        the `filename' parameter, this method falls back to looking for the
        `name' parameter.
        �filenamezcontent-dispositionrszcontent-type)r�r_r�collapse_rfc2231_valuer)r;r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|jd|�}||kr|Stj|�j�S)z�Return the boundary associated with the payload if present.

        The boundary is extracted from the Content-Type header's `boundary'
        parameter, and it is unquoted.
        �boundary)r�r_rr��rstrip)r;r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCs t�}|j|d�}||kr$tjd��g}d}xB|D]:\}}|j�dkr^|jdd|f�d}q2|j||f�q2W|s�|jdd|f�g}x�|jD]�\}	}
|	j�dk�rg}x6|D].\}}
|
dkr�|j|�q�|jd||
f�q�Wtj|�}
|j|j	j
|	|
��q�|j|	|
f�q�W||_d	S)
a�Set the boundary parameter in Content-Type to 'boundary'.

        This is subtly different than deleting the Content-Type header and
        adding a new one with a new boundary parameter via add_header().  The
        main difference is that using the set_boundary() method preserves the
        order of the Content-Type header in the original message.

        HeaderParseError is raised if the message has no Content-Type header.
        zcontent-typezNo Content-Type header foundFr�z"%s"Trz%s=%sN)r�r�rZHeaderParseErrorr+r,r5r�rcr4rw)r;r�r�r�Z	newparamsZfoundpZpkZpvr}�hr{r�rzrxrrr�set_boundaryCs2


zMessage.set_boundarycCs�t�}|jd|�}||kr|St|t�rr|dp2d}y|djd�}t||�}Wn ttfk
rp|d}YnXy|jd�Wntk
r�|SX|j�S)z�Return the charset parameter of the Content-Type header.

        The returned string is always coerced to lower case.  If there is no
        Content-Type header, or if that header has no charset parameter,
        failobj is returned.
        r
rzus-asciirzraw-unicode-escape)	r�r_rrrr
r`rar+)r;r�r�r
ZpcharsetrHrrr�get_content_charsetqs 
zMessage.get_content_charsetcs�fdd�|j�D�S)a�Return a list containing the charset(s) used in this message.

        The returned list of items describes the Content-Type headers'
        charset parameter for this message and all the subparts in its
        payload.

        Each item will either be a string (the value of the charset parameter
        in the Content-Type header of that part) or the value of the
        'failobj' parameter (defaults to None), if the part does not have a
        main MIME type of "text", or the charset is not defined.

        The list will contain one string for each part of the message, plus
        one for the container message (i.e. self), so that a non-multipart
        message will still return a list of length 1.
        csg|]}|j���qSr)r�)r�part)r�rrr��sz(Message.get_charsets.<locals>.<listcomp>)�walk)r;r�r)r�r�get_charsets�szMessage.get_charsetscCs*|jd�}|dkrdSt|�dj�}|S)z�Return the message's content-disposition if it exists, or None.

        The return values can be either 'inline', 'attachment' or None
        according to the rfc2183.
        zcontent-dispositionNr)r]rr+)r;r$�c_drrr�get_content_disposition�s

zMessage.get_content_disposition)r�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)r�TNrF)r�T)r�T)N)N)N)N)4�__name__�
__module__�__qualname__�__doc__r	r<r>r=rIrHrLrMrNrRrhrmrlrqrrrtr|r~r�r�r�r�r�r]r�r�r�ror�r�r�r�r�r�r�r�r_rprnr�r�r�r�r�r�r�Zemail.iteratorsr�rrrrrisb


Z
/


				

!
2

 


.


cs�eZdZd3dd�Zd4�fdd�	Zdd�Zd	d
�Zdd�Zd6dd�Zd7d8d9d:hZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd;d d!�Zd<d"d#�Zd=d$d%�Zdd&�d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS)>�MIMEPartNcCs(|dkrddlm}|}tj||�dS)Nr)�default)Zemail.policyr�rr<)r;r4r�rrrr<�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)aReturn the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  maxheaderlen is retained for backward compatibility with the
        base Message class, but defaults to None, meaning that the policy value
        for max_line_length controls the header maximum length.  'policy' is
        passed to the Generator instance used to serialize the mesasge; if it
        is not specified the policy associated with the message instance is
        used.
        N)rAr4)r4Zmax_line_length�superr=)r;rBrAr4)�	__class__rrr=�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8)r4)r=r4Zclone)r;rrrr>�szMIMEPart.__str__cCs |jd�}|dkrdS|jdkS)Nzcontent-dispositionF�
attachment)r]Zcontent_disposition)r;r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|j�rdS|j�jd�\}}|dkrB||kr>|j|�|fVdS|dkrNdS|dkr~x"|j�D]}|j||�EdHq`WdSd|kr�|jd�|fVd}|jd�}|r�x"|j�D]}|d|kr�|}Pq�W|dkr�|j�}|r�|dnd}|dk	�r|j||�EdHdS)Nr��text�	multipart�related�startz
content-idr)r�r�r�r*�
iter_parts�
_find_bodyr_rh)	r;r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_bodyr��html�plaincCsDt|�}d}x2|j||�D]"\}}||kr|}|}|dkrPqW|S)aReturn best candidate mime part for display as 'body' of message.

        Do a depth first search, starting with self, looking for the first part
        matching each of the items in preferencelist, and return the part
        corresponding to the first item that has a match, or None if no items
        have a match.  If 'related' is not included in preferencelist, consider
        the root part of any multipart/related encountered as a candidate
        match.  Ignore parts with 'Content-Disposition: attachment'.
        Nr)rr�)r;r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_bodyr�r��alternativec	cs|j�jd�\}}|dks"|dkr&dS|j�j�}|dkr�|dkr�|jd�}|r�d}g}x*|D]"}|jd�|krvd	}q^|j|�q^W|r�|EdHdS|jd
�|EdHdSg}xP|D]H}|j�jd�\}}||f|jkr�|j	�r�||kr�|j|�q�|Vq�WdS)aReturn an iterator over the non-main parts of a multipart.

        Skip the first of each occurrence of text/plain, text/html,
        multipart/related, or multipart/alternative in the multipart (unless
        they have a 'Content-Disposition: attachment' header) and include all
        remaining subparts in the returned iterator.  When applied to a
        multipart/related, return all parts except the root part.  Return an
        empty iterator when applied to a multipart/alternative or a
        non-multipart.
        r�r�r�Nr�r�Fz
content-idTr)
r�r�rhr�r_r]r,�pop�_body_typesr�)	r;r�r�r�r�ryZattachmentsr��seenrrr�iter_attachmentss6






zMIMEPart.iter_attachmentsccs|j�dkr|j�EdHdS)z~Return an iterator over all immediate subparts of a multipart.

        Return an empty iterator for a non-multipart.
        r�N)r�rh)r;rrrr�4szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�S)N)r4r��get_content)r;r��args�kwrrrr�<szMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dS)N)r4r��set_content)r;r�r�r�rrrr�AszMIMEPart.set_contentc
Cs�|j�dkr6|j�}||f}||kr6tdj||���g}g}x>|jD]4\}}|j�jd�rl|j||f�qF|j||f�qFW|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|jd|�dS)Nr�zCannot convert {} to {}zcontent-)r4z
multipart/zContent-Typer�)r�r�rurvr5r+�
startswithr,r\r4r7rp)
r;r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersrsr$r�rrr�_make_multipartFs,


zMIMEPart._make_multipartcCs|jdd|�dS)Nr�r��mixed)r�r�)r�)r;r�rrr�make_relatedaszMIMEPart.make_relatedcCs|jdd|�dS)Nr�r�)r�)r�)r;r�rrr�make_alternativedszMIMEPart.make_alternativecCs|jdf|�dS)Nr�)r�)r;r�rrr�
make_mixedgszMIMEPart.make_mixed)�_dispcOsf|j�dks|j�|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|j|�dS)Nr�Zmake_)r4zcontent-dispositionzContent-Disposition)r�r��getattrr\r4r�rR)r;Z_subtyper�r�r�r�rrr�_add_multipartjszMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r�)r�)r;r�r�rrr�add_relatedtszMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�)r�)r;r�r�rrr�add_alternativewszMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�)r�)r;r�r�rrr�add_attachmentzszMIMEPart.add_attachmentcCsg|_d|_dS)N)r5r7)r;rrr�clear}szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|j�jd�s||f�qS)zcontent-)r+r�)r�nr{rrrr��sz*MIMEPart.clear_content.<locals>.<listcomp>)r5r7)r;rrr�
clear_content�szMIMEPart.clear_content)N)FNN�r�r�r�)r�)r�r�)r�r�)r�r�)r�r�)N)N)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��
__classcell__rr)r�rr��s0

.



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)NzMIME-Versionz1.0)r�r�)r;r�r�)r�rrr��szEmailMessage.set_content)r�r�r�r�r�rr)r�rr�s)NT)r��__all__�rererb�iorrZemailrrZemail._policybaserr	r
r8Zemail._encoded_wordsrrjr��compiler!rr%r1r3rr�rrrrr�<module>s6


"NWPKb��\R�9~Z)Z))_header_value_parser.cpython-36.opt-1.pycnu�[���3

���i���@szdZddlZddlZddlmZddlmZddlmZddl	m
Zddl	mZddl	m
Z
ed	�Zeed
�BZed�ZeeBZeed�Zeed
�Zeed�Bed�ZeeBZeed�BZeeBZeed�ZddhZeeBZdd�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd �d e�Z#Gd!d"�d"e�Z$Gd#d$�d$e�Z%Gd%d&�d&e�Z&Gd'd(�d(e�Z'Gd)d*�d*e'�Z(Gd+d,�d,e�Z)Gd-d.�d.e�Z*Gd/d0�d0e�Z+Gd1d2�d2e�Z,Gd3d4�d4e�Z-Gd5d6�d6e�Z.Gd7d8�d8e�Z/Gd9d:�d:e�Z0Gd;d<�d<e�Z1Gd=d>�d>e�Z2Gd?d@�d@e�Z3GdAdB�dBe�Z4GdCdD�dDe�Z5GdEdF�dFe�Z6GdGdH�dHe�Z7GdIdJ�dJe�Z8GdKdL�dLe!�Z9GdMdN�dNe�Z:GdOdP�dPe�Z;GdQdR�dRe�Z<GdSdT�dTe�Z=GdUdV�dVe=�Z>GdWdX�dXe�Z?GdYdZ�dZe�Z@Gd[d\�d\e�ZAGd]d^�d^e�ZBGd_d`�d`e�ZCGdadb�dbeC�ZDGdcdd�ddeC�ZEGdedf�dfe�ZFGdgdh�dhe�ZGGdidj�dje�ZHGdkdl�dleI�ZJGdmdn�dneJ�ZKGdodp�dpeJ�ZLGdqdr�dreK�ZMeLdds�ZNeLdtdu�ZOeLdvdw�ZPejQdxjRdyjSe���jTZUejQdzjRdyjSe�jVd{d|�jVd}d~���jWZXejQd�jYZZejQdzjRdyjSe�jVd{d|�jVd}d~���jWZ[ejQdzjRdyjSe�jVd{d|�jVd}d~���jWZ\ejQdzjRdyjSe�jVd{d|�jVd}d~���jWZ]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�dÄZd�dńZ�d�dDŽZ�d�dɄZ�d�d˄Z�d�d̈́Z�d�dτZ�d�dфZ�d�dӄZ�d�dՄZ�d�dׄZ�d�dلZ�d�dۄZ�d�d݄Z�d�d߄Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�dS)�alHeader value parser implementing various email-related RFC parsing rules.

The parsing methods defined in this module implement various email related
parsing rules.  Principal among them is RFC 5322, which is the followon
to RFC 2822 and primarily a clarification of the former.  It also implements
RFC 2047 encoded word decoding.

RFC 5322 goes to considerable trouble to maintain backward compatibility with
RFC 822 in the parse phase, while cleaning up the structure on the generation
phase.  This parser supports correct RFC 5322 generation by tagging white space
as folding white space only when folding is allowed in the non-obsolete rule
sets.  Actually, the parser is even more generous when accepting input than RFC
5322 mandates, following the spirit of Postel's Law, which RFC 5322 encourages.
Where possible deviations from the standard are annotated on the 'defects'
attribute of tokens that deviate.

The general structure of the parser follows RFC 5322, and uses its terminology
where there is a direct correspondence.  Where the implementation requires a
somewhat different structure than that used by the formal grammar, new terms
that mimic the closest existing terms are used.  Thus, it really helps to have
a copy of RFC 5322 handy when studying this code.

Input to the parser is a string that has already been unfolded according to
RFC 5322 rules.  According to the RFC this unfolding is the very first step, and
this parser leaves the unfolding step to a higher level message parser, which
will have already detected the line breaks that need unfolding while
determining the beginning and end of each header.

The output of the parser is a TokenList object, which is a list subclass.  A
TokenList is a recursive data structure.  The terminal nodes of the structure
are Terminal objects, which are subclasses of str.  These do not correspond
directly to terminal objects in the formal grammar, but are instead more
practical higher level combinations of true terminals.

All TokenList and Terminal objects have a 'value' attribute, which produces the
semantically meaningful value of that part of the parse subtree.  The value of
all whitespace tokens (no matter how many sub-tokens they may contain) is a
single space, as per the RFC rules.  This includes 'CFWS', which is herein
included in the general class of whitespace tokens.  There is one exception to
the rule that whitespace tokens are collapsed into single spaces in values: in
the value of a 'bare-quoted-string' (a quoted-string with no leading or
trailing whitespace), any whitespace that appeared between the quotation marks
is preserved in the returned value.  Note that in all Terminal strings quoted
pairs are turned into their unquoted values.

All TokenList and Terminal objects also have a string value, which attempts to
be a "canonical" representation of the RFC-compliant form of the substring that
produced the parsed subtree, including minimal use of quoted pair quoting.
Whitespace runs are not collapsed.

Comment tokens also have a 'content' attribute providing the string found
between the parens (including any nested comments) with whitespace preserved.

All TokenList and Terminal objects have a 'defects' attribute which is a
possibly empty list all of the defects found while creating the token.  Defects
may appear on any token in the tree, and a composite list of all defects in the
subtree is available through the 'all_defects' attribute of any node.  (For
Terminal notes x.defects == x.all_defects.)

Each object in a parse tree is called a 'token', and each has a 'token_type'
attribute that gives the name from the RFC 5322 grammar that it represents.
Not all RFC 5322 nodes are produced, and there is one non-RFC 5322 node that
may be produced: 'ptext'.  A 'ptext' is a string of printable ascii characters.
It is returned in place of lists of (ctext/quoted-pair) and
(qtext/quoted-pair).

XXX: provide complete list of token types.
�N)�	hexdigits)�OrderedDict)�
itemgetter)�_encoded_words)�errors)�utilsz 	�(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%�
�
cCs dt|�jdd�jdd�dS)N�"�\z\\z\")�str�replace)�value�r�2/usr/lib64/python3.6/email/_header_value_parser.py�quote_stringbsrcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd�Ze	d	d
��Z
e	dd��Zd
d�Ze	dd��Z
e	dd��Zdd�Zddd�Zddd�Zddd�Z�ZS)�	TokenListNTcst�j||�g|_dS)N)�super�__init__�defects)�self�args�kw)�	__class__rrroszTokenList.__init__cCsdjdd�|D��S)N�css|]}t|�VqdS)N)r)�.0�xrrr�	<genexpr>tsz$TokenList.__str__.<locals>.<genexpr>)�join)rrrr�__str__sszTokenList.__str__csdj|jjt�j��S)Nz{}({}))�formatr�__name__r�__repr__)r)rrrr%vs
zTokenList.__repr__cCsdjdd�|D��S)Nrcss|]}|jr|jVqdS)N)r)rrrrrr |sz"TokenList.value.<locals>.<genexpr>)r!)rrrrrzszTokenList.valuecCstdd�|D�|j�S)Ncss|]}|jVqdS)N)�all_defects)rrrrrr �sz(TokenList.all_defects.<locals>.<genexpr>)�sumr)rrrrr&~szTokenList.all_defectscCs|dj�S)Nr)�startswith_fws)rrrrr(�szTokenList.startswith_fwscCstdd�|D��S)zATrue if all top level tokens of this part may be RFC2047 encoded.css|]}|jVqdS)N)�
as_ew_allowed)r�partrrrr �sz*TokenList.as_ew_allowed.<locals>.<genexpr>)�all)rrrrr)�szTokenList.as_ew_allowedcCs"g}x|D]}|j|j�q
W|S)N)�extend�comments)rr-�tokenrrrr-�s
zTokenList.commentscCst||d�S)N)�policy)�_refold_parse_tree)rr/rrr�fold�szTokenList.foldrcCst|j|d��dS)N)�indent)�print�ppstr)rr2rrr�pprint�szTokenList.pprintcCsdj|j|d��S)Nr)r2)r!�_pp)rr2rrrr4�szTokenList.ppstrccs~dj||jj|j�Vx<|D]4}t|d�s<|dj|�Vq|j|d�EdHqW|jrhdj|j�}nd}dj||�VdS)Nz{}{}/{}(r6z*    !! invalid element in token list: {!r}z    z Defects: {}rz{}){})r#rr$�
token_type�hasattrr6r)rr2r.Zextrarrrr6�s


z
TokenList._pp)r)r)r)r$�
__module__�__qualname__r7�syntactic_break�ew_combine_allowedrr"r%�propertyrr&r(r)r-r1r5r4r6�
__classcell__rr)rrris

rc@s$eZdZedd��Zedd��ZdS)�WhiteSpaceTokenListcCsdS)N� r)rrrrr�szWhiteSpaceTokenList.valuecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)�comment)r7�content)rrrrr�
<listcomp>�sz0WhiteSpaceTokenList.comments.<locals>.<listcomp>r)rrrrr-�szWhiteSpaceTokenList.commentsN)r$r9r:r=rr-rrrrr?�sr?c@seZdZdZdS)�UnstructuredTokenList�unstructuredN)r$r9r:r7rrrrrD�srDc@seZdZdZdS)�Phrase�phraseN)r$r9r:r7rrrrrF�srFc@seZdZdZdS)�WordZwordN)r$r9r:r7rrrrrH�srHc@seZdZdZdS)�CFWSList�cfwsN)r$r9r:r7rrrrrI�srIc@seZdZdZdS)�Atom�atomN)r$r9r:r7rrrrrK�srKc@seZdZdZdZdS)�Tokenr.FN)r$r9r:r7Zencode_as_ewrrrrrM�srMc@seZdZdZdZdZdZdS)�EncodedWordzencoded-wordN)r$r9r:r7�cte�charset�langrrrrrN�srNc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�QuotedStringz
quoted-stringcCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rrrrrrB�s

zQuotedString.contentcCsBg}x2|D]*}|jdkr(|jt|��q
|j|j�q
Wdj|�S)Nzbare-quoted-stringr)r7�appendrrr!)r�resrrrr�quoted_value�s

zQuotedString.quoted_valuecCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rr.rrr�stripped_value�s

zQuotedString.stripped_valueN)r$r9r:r7r=rBrUrVrrrrrR�s
rRc@s$eZdZdZdd�Zedd��ZdS)�BareQuotedStringzbare-quoted-stringcCstdjdd�|D���S)Nrcss|]}t|�VqdS)N)r)rrrrrr �sz+BareQuotedString.__str__.<locals>.<genexpr>)rr!)rrrrr"�szBareQuotedString.__str__cCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz)BareQuotedString.value.<locals>.<genexpr>)r!)rrrrr�szBareQuotedString.valueN)r$r9r:r7r"r=rrrrrrW�srWc@s8eZdZdZdd�Zdd�Zedd��Zedd	��Zd
S)�CommentrAcs(djtdg�fdd��D�dggg��S)Nrrcsg|]}�j|��qSr)�quote)rr)rrrrCsz#Comment.__str__.<locals>.<listcomp>�))r!r')rr)rrr"s
zComment.__str__cCs2|jdkrt|�St|�jdd�jdd�jdd�S)NrArz\\rz\(rZz\))r7rr)rrrrrrYs

z
Comment.quotecCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz"Comment.content.<locals>.<genexpr>)r!)rrrrrBszComment.contentcCs|jgS)N)rB)rrrrr-szComment.commentsN)	r$r9r:r7r"rYr=rBr-rrrrrXs
rXc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressListzaddress-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)�address)r7)rrrrrrC$sz)AddressList.addresses.<locals>.<listcomp>r)rrrr�	addresses"szAddressList.addressescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�	mailboxes)rrrrrr (sz(AddressList.mailboxes.<locals>.<genexpr>)r')rrrrr^&szAddressList.mailboxescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�
all_mailboxes)rrrrrr -sz,AddressList.all_mailboxes.<locals>.<genexpr>)r')rrrrr_+szAddressList.all_mailboxesN)r$r9r:r7r=r]r^r_rrrrr[sr[c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�Addressr\cCs|djdkr|djSdS)Nr�group)r7�display_name)rrrrrb5szAddress.display_namecCs4|djdkr|dgS|djdkr*gS|djS)Nr�mailboxzinvalid-mailbox)r7r^)rrrrr^:s

zAddress.mailboxescCs:|djdkr|dgS|djdkr0|dgS|djS)Nrrczinvalid-mailbox)r7r_)rrrrr_Bs


zAddress.all_mailboxesN)r$r9r:r7r=rbr^r_rrrrr`1sr`c@s(eZdZdZedd��Zedd��ZdS)�MailboxListzmailbox-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc)r7)rrrrrrCPsz)MailboxList.mailboxes.<locals>.<listcomp>r)rrrrr^NszMailboxList.mailboxescCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc�invalid-mailbox)rcre)r7)rrrrrrCTsz-MailboxList.all_mailboxes.<locals>.<listcomp>r)rrrrr_RszMailboxList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrdJsrdc@s(eZdZdZedd��Zedd��ZdS)�	GroupListz
group-listcCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r^)rrrrr^\szGroupList.mailboxescCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r_)rrrrr_bszGroupList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrfXsrfc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�GroupracCs|djdkrgS|djS)N�z
group-list)r7r^)rrrrr^mszGroup.mailboxescCs|djdkrgS|djS)Nrhz
group-list)r7r_)rrrrr_sszGroup.all_mailboxescCs
|djS)Nr)rb)rrrrrbyszGroup.display_nameN)r$r9r:r7r=r^r_rbrrrrrgisrgc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�NameAddrz	name-addrcCst|�dkrdS|djS)N�r)�lenrb)rrrrrb�szNameAddr.display_namecCs
|djS)Nrj���)�
local_part)rrrrrm�szNameAddr.local_partcCs
|djS)Nrjrl)�domain)rrrrrn�szNameAddr.domaincCs
|djS)Nrjrl)�route)rrrrro�szNameAddr.routecCs
|djS)Nrjrl)�	addr_spec)rrrrrp�szNameAddr.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrri~sric@s@eZdZdZedd��Zedd��Zedd��Zedd	��Zd
S)�	AngleAddrz
angle-addrcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rm)rrrrrrm�s

zAngleAddr.local_partcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rn)rrrrrrn�s

zAngleAddr.domaincCs"x|D]}|jdkr|jSqWdS)Nz	obs-route)r7�domains)rrrrrro�s

zAngleAddr.routecCs<x6|D]*}|jdkr|jr |jSt|j�|jSqWdSdS)Nz	addr-specz<>)r7rmrpr)rrrrrrp�s

zAngleAddr.addr_specN)	r$r9r:r7r=rmrnrorprrrrrq�s
rqc@seZdZdZedd��ZdS)�ObsRoutez	obs-routecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)rn)r7rn)rrrrrrC�sz$ObsRoute.domains.<locals>.<listcomp>r)rrrrrr�szObsRoute.domainsN)r$r9r:r7r=rrrrrrrs�srsc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�MailboxrccCs|djdkr|djSdS)Nrz	name-addr)r7rb)rrrrrb�szMailbox.display_namecCs
|djS)Nr)rm)rrrrrm�szMailbox.local_partcCs
|djS)Nr)rn)rrrrrn�szMailbox.domaincCs|djdkr|djSdS)Nrz	name-addr)r7ro)rrrrro�sz
Mailbox.routecCs
|djS)Nr)rp)rrrrrp�szMailbox.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrrt�srtc@s,eZdZdZedd��ZeZZZZ	dS)�InvalidMailboxzinvalid-mailboxcCsdS)Nr)rrrrrb�szInvalidMailbox.display_nameN)
r$r9r:r7r=rbrmrnrorprrrrru�srucs(eZdZdZdZe�fdd��Z�ZS)�DomainrnFcsdjt�jj��S)Nr)r!rr�split)r)rrrrn�sz
Domain.domain)r$r9r:r7r)r=rnr>rr)rrrv�srvc@seZdZdZdS)�DotAtomzdot-atomN)r$r9r:r7rrrrrx�srxc@seZdZdZdZdS)�DotAtomTextz
dot-atom-textTN)r$r9r:r7r)rrrrry�sryc@sDeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dS)�AddrSpecz	addr-specFcCs
|djS)Nr)rm)rrrrrmszAddrSpec.local_partcCst|�dkrdS|djS)N�rjrl)rkrn)rrrrrnszAddrSpec.domaincCs<t|�dkr|djS|djj�|dj|djj�S)Nr{rrjrh)rkr�rstrip�lstrip)rrrrrs
zAddrSpec.valuecCsLt|j�}t|�t|t�kr*t|j�}n|j}|jdk	rH|d|jS|S)N�@)�setrmrk�
DOT_ATOM_ENDSrrn)rZnamesetZlprrrrps

zAddrSpec.addr_specN)
r$r9r:r7r)r=rmrnrrprrrrrz�srzc@seZdZdZdZdS)�ObsLocalPartzobs-local-partFN)r$r9r:r7r)rrrrr� sr�cs4eZdZdZdZedd��Ze�fdd��Z�ZS)�DisplayNamezdisplay-nameFcCs�t|�}|djdkr"|jd�n*|ddjdkrLt|ddd��|d<|djdkrd|j�n*|ddjdkr�t|ddd��|d	<|jS)
NrrJrjrlrlrlrlrlrl)rr7�popr)rrTrrrrb+s
zDisplayName.display_namecs�d}|jrd}nx|D]}|jdkrd}qW|r�d}}|djdksX|ddjdkr\d}|d	jdks||d
djdkr�d}|t|j�|St�jSdS)NFTz
quoted-stringrrrJr@rjrlrlrl)rr7rrbrr)rrYrZpreZpost)rrrr:s

  zDisplayName.value)	r$r9r:r7r<r=rbrr>rr)rrr�&sr�c@s,eZdZdZdZedd��Zedd��ZdS)�	LocalPartz
local-partFcCs&|djdkr|djS|djSdS)Nrz
quoted-string)r7rUr)rrrrrSs
zLocalPart.valuecCs�tg}t}d}x�|dtgD]�}|jdkr.q|r^|jdkr^|djdkr^t|dd��|d<t|t�}|r�|jdkr�|djdkr�|jt|dd���n
|j|�|d	}|}qWt|dd
��}|jS)NFrrJ�dotrjrlrlrlrlrl)�DOTr7r�
isinstancerSr)rrTZlastZ
last_is_tl�tokZis_tlrrrrmZs$


zLocalPart.local_partN)r$r9r:r7r)r=rrmrrrrr�Nsr�cs4eZdZdZdZe�fdd��Zedd��Z�ZS)�
DomainLiteralzdomain-literalFcsdjt�jj��S)Nr)r!rrrw)r)rrrrnwszDomainLiteral.domaincCs"x|D]}|jdkr|jSqWdS)N�ptext)r7r)rrrrr�ip{s

zDomainLiteral.ip)	r$r9r:r7r)r=rnr�r>rr)rrr�rsr�c@seZdZdZdZdZdS)�MIMEVersionzmime-versionN)r$r9r:r7�major�minorrrrrr��sr�c@s4eZdZdZdZdZdZedd��Zedd��Z	dS)	�	Parameter�	parameterFzus-asciicCs|jr|djSdS)Nrjr)�	sectioned�number)rrrr�section_number�szParameter.section_numbercCsbx\|D]T}|jdkr|jS|jdkrx4|D],}|jdkr*x|D]}|jdkr>|jSq>Wq*WqWdS)Nrz
quoted-stringzbare-quoted-stringr)r7rV)rr.rrr�param_value�s






zParameter.param_valueN)
r$r9r:r7r��extendedrPr=r�r�rrrrr��sr�c@seZdZdZdS)�InvalidParameterzinvalid-parameterN)r$r9r:r7rrrrr��sr�c@seZdZdZedd��ZdS)�	Attribute�	attributecCs$x|D]}|jjd�r|jSqWdS)N�attrtext)r7�endswithr)rr.rrrrV�s
zAttribute.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@seZdZdZdZdS)�Section�sectionN)r$r9r:r7r�rrrrr��sr�c@seZdZdZedd��ZdS)�ValuercCs2|d}|jdkr|d}|jjd�r,|jS|jS)NrrJrj�
quoted-stringr��extended-attribute)r�r�r�)r7r�rVr)rr.rrrrV�s
zValue.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@s(eZdZdZdZedd��Zdd�ZdS)�MimeParameterszmime-parametersFccs�t�}x\|D]T}|jjd�sq|djdkr.q|djj�}||krLg||<||j|j|f�qW�x�|j�D�]�\}}t|t	d�d�}|dd}|j
}|jr�t|�dkr�|dddkr�|ddj
jtjd��|dd�}g}d}x�|D]�\}	}
|	|k�r6|
j�s$|
j
jtjd��q�n|
j
jtjd��|d7}|
j}|
j�r�ytjj|�}Wn&tk
�r�tjj|d	d
�}YnRXy|j|d�}Wn"tk
�r�|jdd�}YnXtj|��r�|
j
jtj��|j|�q�Wd
j|�}||fVqpWdS)Nr�rr�)�keyrjz.duplicate parameter name; duplicate(s) ignoredz+duplicate parameter name; duplicate ignoredz(inconsistent RFC2231 parameter numberingzlatin-1)�encoding�surrogateescapezus-asciir)rr7r�r�striprSr��items�sortedrrPr�rkrr�InvalidHeaderDefectr��urllib�parseZunquote_to_bytes�UnicodeEncodeErrorZunquote�decode�LookupErrorr�_has_surrogates�UndecodableBytesDefectr!)r�paramsr.�name�partsZfirst_paramrPZvalue_parts�ir��paramrrrrr��sZ




zMimeParameters.paramscCsXg}x8|jD].\}}|r0|jdj|t|���q|j|�qWdj|�}|rTd|SdS)Nz{}={}z; r@r)r�rSr#rr!)rr�r�rrrrr"s
zMimeParameters.__str__N)r$r9r:r7r;r=r�r"rrrrr��sFr�c@seZdZdZedd��ZdS)�ParameterizedHeaderValueFcCs&x t|�D]}|jdkr
|jSq
WiS)Nzmime-parameters)�reversedr7r�)rr.rrrr�%s

zParameterizedHeaderValue.paramsN)r$r9r:r;r=r�rrrrr�sr�c@seZdZdZdZdZdZdS)�ContentTypezcontent-typeF�textZplainN)r$r9r:r7r)�maintype�subtyperrrrr�-sr�c@seZdZdZdZdZdS)�ContentDispositionzcontent-dispositionFN)r$r9r:r7r)�content_dispositionrrrrr�5sr�c@seZdZdZdZdZdS)�ContentTransferEncodingzcontent-transfer-encodingFZ7bitN)r$r9r:r7r)rOrrrrr�<sr�c@seZdZdZdZdS)�HeaderLabelzheader-labelFN)r$r9r:r7r)rrrrr�Csr�c@seZdZdZdS)�Header�headerN)r$r9r:r7rrrrr�Isr�csreZdZdZdZdZ�fdd�Z�fdd�Zdd�Ze	dd	��Z
d�fdd�	Zd
d�Ze	dd��Z
dd�Z�ZS)�TerminalTcst�j||�}||_g|_|S)N)r�__new__r7r)�clsrr7r)rrrr�XszTerminal.__new__csdj|jjt�j��S)Nz{}({}))r#rr$rr%)r)rrrr%^szTerminal.__repr__cCst|jjd|j�dS)N�/)r3rr$r7)rrrrr5aszTerminal.pprintcCs
t|j�S)N)�listr)rrrrr&dszTerminal.all_defectsrcs2dj||jj|jt�j�|js"dn
dj|j��gS)Nz
{}{}/{}({}){}rz {})r#rr$r7rr%r)rr2)rrrr6hszTerminal._ppcCsdS)Nr)rrrr�pop_trailing_wsqszTerminal.pop_trailing_wscCsgS)Nr)rrrrr-uszTerminal.commentscCst|�|jfS)N)rr7)rrrr�__getnewargs__yszTerminal.__getnewargs__)r)r$r9r:r)r<r;r�r%r5r=r&r6r�r-r�r>rr)rrr�Rs	r�c@s eZdZedd��Zdd�ZdS)�WhiteSpaceTerminalcCsdS)Nr@r)rrrrrszWhiteSpaceTerminal.valuecCsdS)NTr)rrrrr(�sz!WhiteSpaceTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr�}sr�c@s eZdZedd��Zdd�ZdS)�
ValueTerminalcCs|S)Nr)rrrrr�szValueTerminal.valuecCsdS)NFr)rrrrr(�szValueTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr��sr�c@s eZdZedd��Zdd�ZdS)�EWWhiteSpaceTerminalcCsdS)Nrr)rrrrr�szEWWhiteSpaceTerminal.valuecCsdS)Nrr)rrrrr"�szEWWhiteSpaceTerminal.__str__N)r$r9r:r=rr"rrrrr��sr�r��,zlist-separatorr~zroute-component-markerz([{}]+)rz[^{}]+rz\\�]z\]z[\x00-\x20\x7F]cCs>t|�}|r|jjtj|��tj|�r:|jjtjd��dS)z@If input token contains ASCII non-printables, register a defect.z*Non-ASCII characters found in header tokenN)�_non_printable_finderrrSrZNonPrintableDefectrr�r�)�xtextZnon_printablesrrr�_validate_xtext�s

r�cCs�t|d�^}}g}d}d}xbtt|��D]J}||dkrL|rFd}d}nd}q(|rVd}n|||krdP|j||�q(W|d}dj|�dj||d�g|�|fS)akScan printables/quoted-pairs until endchars and return unquoted ptext.

    This function turns a run of qcontent, ccontent-without-comments, or
    dtext-with-quoted-printables into a single string by unquoting any
    quoted printables.  It returns the string, the remaining value, and
    a flag that is True iff there were any quoted printables decoded.

    rjFrTrN)�
_wsp_splitter�rangerkrSr!)r�endcharsZfragment�	remainderZvchars�escape�had_qp�posrrr�_get_ptext_to_endchars�s$	r�cCs.|j�}t|dt|�t|��d�}||fS)z�FWS = 1*WSP

    This isn't the RFC definition.  We're using fws to represent tokens where
    folding can be done, but when we are parsing the *un*folding has already
    been done so we don't need to watch out for CRLF.

    N�fws)r}r�rk)rZnewvaluer�rrr�get_fws�sr�c
Cs�t�}|jd�s tjdj|���|dd�jdd�^}}||dd�krXtjdj|���dj|�}t|�dkr�|dtkr�|dtkr�|jdd�^}}|d|}t|j��dkr�|j	j
tjd	��||_dj|�}yt
jd|d�\}}}}	Wn(tk
�rtjd
j|j���YnX||_||_|j	j|	�xh|�r�|dtk�rdt|�\}
}|j
|
��q6t|d�^}}t|d�}t|�|j
|�dj|�}�q6W||fS)zE encoded-word = "=?" charset "?" encoding "?" encoded-text "?="

    z=?z"expected encoded word but found {}rhNz?=rjrrzwhitespace inside encoded wordz!encoded word format invalid: '{}'�vtext)rN�
startswithr�HeaderParseErrorr#rwr!rkrrrSr�rO�_ewr��
ValueErrorrPrQr,�WSPr�r�r�r�)
r�ewr�r�Zremstr�restr�rPrQrr.�charsr�rrr�get_encoded_word�sH

$




r�cCst�}�x|�r|dtkr4t|�\}}|j|�q
|jd�r�yt|�\}}Wntjk
rdYnrXd}t|�dkr�|dj	dkr�|j
jtjd��d}|r�t|�dkr�|d
j	d	kr�t|dd�|d<|j|�q
t
|d�^}}t|d
�}t|�|j|�dj|�}q
W|S)aOunstructured = (*([FWS] vchar) *WSP) / obs-unstruct
       obs-unstruct = *((*LF *CR *(obs-utext) *LF *CR)) / FWS)
       obs-utext = %d0 / obs-NO-WS-CTL / LF / CR

       obs-NO-WS-CTL is control characters except WSP/CR/LF.

    So, basically, we have printable runs, plus control characters or nulls in
    the obsolete syntax, separated by whitespace.  Since RFC 2047 uses the
    obsolete syntax in its specification, but requires whitespace on either
    side of the encoded words, I can see no reason to need to separate the
    non-printable-non-whitespace from the printable runs if they occur, so we
    parse this into xtext tokens separated by WSP tokens.

    Because an 'unstructured' value must by definition constitute the entire
    value, this 'get' routine does not return a remaining value, only the
    parsed TokenList.

    rz=?Trjr�z&missing whitespace before encoded wordFrhzencoded-wordr�rrl���rlrl)rDr�r�rSr�r�rr�rkr7rr�r�r�r�r�r!)rrEr.Zhave_wsr�r�r�rrr�get_unstructured!s:






r�cCs*t|d�\}}}t|d�}t|�||fS)actext = <printable ascii except \ ( )>

    This is not the RFC ctext, since we are handling nested comments in comment
    and unquoting quoted-pairs here.  We allow anything except the '()'
    characters, but if we find any ASCII other than the RFC defined printable
    ASCII, a NonPrintableDefect is added to the token's defects list.  Since
    quoted pairs are converted to their unquoted values, what is returned is
    a 'ptext' token.  In this case it is a WhiteSpaceTerminal, so it's value
    is ' '.

    z()r�)r�r�r�)rr��_rrr�get_qp_ctextYs
r�cCs*t|d�\}}}t|d�}t|�||fS)aoqcontent = qtext / quoted-pair

    We allow anything except the DQUOTE character, but if we find any ASCII
    other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Any quoted pairs are converted to their
    unquoted values, so what is returned is a 'ptext' token.  In this case it
    is a ValueTerminal.

    r
r�)r�r�r�)rr�r�rrr�get_qcontentjs

r�cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)z�atext = <matches _atext_matcher>

    We allow any non-ATOM_ENDS in atext, but add an InvalidATextDefect to
    the token's defects list if we find non-atext characters.
    zexpected atext but found '{}'N�atext)�_non_atom_end_matcherrr�r#rarkr�r�)r�mr�rrr�	get_atextys
r�cCs|ddkrtjdj|���t�}|dd�}|ddkrPt|�\}}|j|�x�|r�|ddkr�|dtkr|t|�\}}nd|dd�dkr�y"t|�\}}|j	jtj
d��Wq�tjk
r�t|�\}}Yq�Xnt|�\}}|j|�qRW|�s|j	jtj
d	��||fS||dd�fS)
z�bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE

    A quoted-string without the leading or trailing white space.  Its
    value is the text between the quote marks, with whitespace
    preserved and quoted pairs decoded.
    rr
zexpected '"' but found '{}'rjNrhz=?z!encoded word inside quoted stringz"end of header inside quoted string)rr�r#rWr�rSr�r�r�rr�)rZbare_quoted_stringr.rrr�get_bare_quoted_string�s2


r�cCs�|r |ddkr tjdj|���t�}|dd�}x^|r�|ddkr�|dtkr^t|�\}}n&|ddkrxt|�\}}nt|�\}}|j|�q4W|s�|j	jtj
d��||fS||dd�fS)z�comment = "(" *([FWS] ccontent) [FWS] ")"
       ccontent = ctext / quoted-pair / comment

    We handle nested comments here, and quoted-pair in our qp-ctext routine.
    rrzexpected '(' but found '{}'rjNrZzend of header inside comment)rr�r#rXr�r��get_commentr�rSrr�)rrAr.rrrr��s"
r�cCsTt�}xD|rJ|dtkrJ|dtkr2t|�\}}nt|�\}}|j|�qW||fS)z,CFWS = (1*([FWS] comment) [FWS]) / FWS

    r)rI�CFWS_LEADERr�r�r�rS)rrJr.rrr�get_cfws�sr�cCspt�}|r,|dtkr,t|�\}}|j|�t|�\}}|j|�|rh|dtkrht|�\}}|j|�||fS)z�quoted-string = [CFWS] <bare-quoted-string> [CFWS]

    'bare-quoted-string' is an intermediate class defined by this
    parser and not by the RFC grammar.  It is the quoted string
    without any attached CFWS.
    r)rRr�r�rSr�)rZ
quoted_stringr.rrr�get_quoted_string�s


r�cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���|jd�r�yt	|�\}}Wq�tjk
r�t
|�\}}Yq�Xnt
|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)zPatom = [CFWS] 1*atext [CFWS]

    An atom could be an rfc2047 encoded word.
    rzexpected atom but found '{}'z=?)rKr�r�rS�	ATOM_ENDSrr�r#r�r�r�)rrLr.rrr�get_atom�s$



r�cCs�t�}|s|dtkr(tjdj|���xP|rx|dtkrxt|�\}}|j|�|r*|ddkr*|jt�|dd�}q*W|dtkr�tjdjd|���||fS)z( dot-text = 1*atext *("." 1*atext)

    rz8expected atom at a start of dot-atom-text but found '{}'r	rjNz4expected atom at end of dot-atom-text but found '{}'rl)ryr�rr�r#r�rSr�)rZ
dot_atom_textr.rrr�get_dot_atom_text�s

r�cCs�t�}|dtkr(t|�\}}|j|�|jd�rhyt|�\}}Wqttjk
rdt|�\}}YqtXnt|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)z� dot-atom = [CFWS] dot-atom-text [CFWS]

    Any place we can have a dot atom, we could instead have an rfc2047 encoded
    word.
    rz=?)	rxr�r�rSr�r�rr�r�)rZdot_atomr.rrr�get_dot_atoms



r�cCs�|dtkrt|�\}}nd}|ddkr8t|�\}}n*|dtkrVtjdj|���nt|�\}}|dk	rx|g|dd�<||fS)a�word = atom / quoted-string

    Either atom or quoted-string may start with CFWS.  We have to peel off this
    CFWS first to determine which type of word to parse.  Afterward we splice
    the leading CFWS, if any, into the parsed sub-token.

    If neither an atom or a quoted-string is found before the next special, a
    HeaderParseError is raised.

    The token returned is either an Atom or a QuotedString, as appropriate.
    This means the 'word' level of the formal grammar is not represented in the
    parse tree; this is because having that extra layer when manipulating the
    parse tree is more confusing than it is helpful.

    rNr
z1Expected 'atom' or 'quoted-string' but found '{}')r�r�r��SPECIALSrr�r#r�)r�leaderr.rrr�get_word*s
r�cCs�t�}yt|�\}}|j|�Wn(tjk
rH|jjtjd��YnXx�|r�|dtkr�|ddkr�|jt�|jjtj	d��|dd�}qLyt|�\}}WnDtjk
r�|dt
kr�t|�\}}|jjtj	d��n�YnX|j|�qLW||fS)a� phrase = 1*word / obs-phrase
        obs-phrase = word *(word / "." / CFWS)

    This means a phrase can be a sequence of words, periods, and CFWS in any
    order as long as it starts with at least one word.  If anything other than
    words is detected, an ObsoleteHeaderDefect is added to the token's defect
    list.  We also accept a phrase that starts with CFWS followed by a dot;
    this is registered as an InvalidHeaderDefect, since it is not supported by
    even the obsolete grammar.

    zphrase does not start with wordrr	zperiod in 'phrase'rjNzcomment found without atom)rFr�rSrr�rr��PHRASE_ENDSr��ObsoleteHeaderDefectr�r�)rrGr.rrr�
get_phraseIs.




r�cCstt�}d}|dtkr"t|�\}}|s6tjdj|���yt|�\}}Wn^tjk
r�yt|�\}}Wn6tjk
r�|ddkr�|dtkr��t	�}YnXYnX|dk	r�|g|dd�<|j
|�|o�|ddks�|dtk�r2tt|�|�\}}|j
dk�r|jj
tjd��n|jj
tjd��||d<y|jjd�Wn(tk
�rj|jj
tjd	��YnX||fS)
z= local-part = dot-atom / quoted-string / obs-local-part

    Nrz"expected local-part but found '{}'rzinvalid-obs-local-partz<local-part is not dot-atom, quoted-string, or obs-local-partz,local-part is not a dot-atom (contains CFWS)�asciiz)local-part contains non-ASCII characters))r�r�r�rr�r#r�r�r�rrS�get_obs_local_partrr7rr�r�r�encoder�ZNonASCIILocalPartDefect)rrmr�r.�obs_local_partrrr�get_local_partosB




r�cCs�t�}d}�x|o(|ddks,|dtk�r*|ddkrl|rN|jjtjd��|jt�d}|dd�}qnD|ddkr�|jt|dd	��|dd�}|jjtjd
��d}q|r�|djdkr�|jjtjd��yt	|�\}}d}Wn4tj
k
�r|dtk�r�t|�\}}YnX|j|�qW|djdk�s\|djd
k�rn|djdk�rn|jjtjd��|djdk�s�|djd
k�r�|djdk�r�|jjtjd��|j�r�d|_||fS)z' obs-local-part = word *("." word)
    Frrr	zinvalid repeated '.'TrjNzmisplaced-specialz/'\' character outside of quoted-string/ccontentr�zmissing '.' between wordsrJz!Invalid leading '.' in local partrhz"Invalid trailing '.' in local partzinvalid-obs-local-partrlrlrlr�)
r�r�rrSrr�r�r�r7r�r�r�r�)rr�Zlast_non_ws_was_dotr.rrrr��sV"





r�cCs@t|d�\}}}t|d�}|r0|jjtjd��t|�||fS)a dtext = <printable ascii except \ [ ]> / obs-dtext
        obs-dtext = obs-NO-WS-CTL / quoted-pair

    We allow anything except the excluded characters, but if we find any
    ASCII other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Quoted pairs are converted to their
    unquoted values, so what is returned is a ptext token, in this case a
    ValueTerminal.  If there were quoted-printables, an ObsoleteHeaderDefect is
    added to the returned token's defect list.

    z[]r�z(quoted printable found in domain-literal)r�r�rrSrr�r�)rr�r�rrr�	get_dtext�s

rcCs,|rdS|jtjd��|jtdd��dS)NFz"end of input inside domain-literalr�zdomain-literal-endT)rSrr�r�)r�domain_literalrrr�_check_for_early_dl_end�srcCslt�}|dtkr(t|�\}}|j|�|s6tjd��|ddkrRtjdj|���|dd�}t||�rp||fS|jtdd��|dt	kr�t
|�\}}|j|�t|�\}}|j|�t||�r�||fS|dt	kr�t
|�\}}|j|�t||��r||fS|ddk�rtjd	j|���|jtdd
��|dd�}|�rd|dtk�rdt|�\}}|j|�||fS)zB domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]

    rzexpected domain-literal�[z6expected '[' at start of domain-literal but found '{}'rjNzdomain-literal-startr�z4expected ']' at end of domain-literal but found '{}'zdomain-literal-end)r�r�r�rSrr�r#rr�r�r�r)rrr.rrr�get_domain_literal�sD







rcCstt�}d}|dtkr"t|�\}}|s6tjdj|���|ddkrvt|�\}}|dk	rd|g|dd�<|j|�||fSyt|�\}}Wn"tjk
r�t	|�\}}YnX|r�|ddkr�tjd��|dk	r�|g|dd�<|j|�|o�|ddk�rl|j
jtjd��|djd	k�r(|d|dd�<xB|�rj|ddk�rj|jt
�t	|d
d��\}}|j|��q*W||fS)z] domain = dot-atom / domain-literal / obs-domain
        obs-domain = atom *("." atom))

    Nrzexpected domain but found '{}'rr~zInvalid Domainr	z(domain is not a dot-atom (contains CFWS)zdot-atomrj)rvr�r�rr�r#rrSr�r�rr�r7r�)rrnr�r.rrr�
get_domains@




rcCs~t�}t|�\}}|j|�|s.|ddkrH|jjtjd��||fS|jtdd��t|dd��\}}|j|�||fS)z( addr-spec = local-part "@" domain

    rr~z"add-spec local part with no domainzaddress-at-symbolrjN)rzr�rSrrr�r�r)rrpr.rrr�
get_addr_spec.s


rcCs�t�}xf|rl|ddks$|dtkrl|dtkrHt|�\}}|j|�q|ddkr|jt�|dd�}qW|s�|ddkr�tjdj|���|jt�t	|dd��\}}|j|�x�|o�|ddk�rB|jt�|dd�}|s�P|dtk�rt|�\}}|j|�|ddkr�|jt�t	|dd��\}}|j|�q�W|�sTtjd��|ddk�rrtjd	j|���|jt
dd
��||dd�fS)z� obs-route = obs-domain-list ":"
        obs-domain-list = *(CFWS / ",") "@" domain *("," [CFWS] ["@" domain])

        Returns an obs-route token with the appropriate sub-tokens (that is,
        there is no obs-domain-list in the parse tree).
    rr�rjNr~z(expected obs-route domain but found '{}'z%end of header while parsing obs-route�:z4expected ':' marking end of obs-route but found '{}'zend-of-obs-route-marker)rsr�r�rS�
ListSeparatorrr�r#�RouteComponentMarkerrr�)rZ	obs_router.rrr�
get_obs_route>sB






r
cCs�t�}|dtkr(t|�\}}|j|�|s:|ddkrJtjdj|���|jtdd��|dd�}|ddkr�|jtdd��|jjtj	d	��|dd�}||fSyt
|�\}}Wnztjk
�r2y"t|�\}}|jjtjd
��Wn(tjk
�rtjdj|���YnX|j|�t
|�\}}YnX|j|�|�r`|ddk�r`|dd�}n|jjtj	d��|jtdd��|�r�|dtk�r�t|�\}}|j|�||fS)
z� angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
        obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS]

    r�<z"expected angle-addr but found '{}'zangle-addr-startrjN�>zangle-addr-endznull addr-spec in angle-addrz*obsolete route specification in angle-addrz.expected addr-spec or obs-route but found '{}'z"missing trailing '>' on angle-addr)
rqr�r�rSrr�r#r�rr�rr
r�)rZ
angle_addrr.rrr�get_angle_addrgsJ






r
cCs<t�}t|�\}}|j|dd��|jdd�|_||fS)z� display-name = phrase

    Because this is simply a name-rule, we don't return a display-name
    token containing a phrase, but rather a display-name token with
    the content of the phrase.

    N)r�r�r,r)rrbr.rrr�get_display_name�s
rcCs�t�}d}|dtkr6t|�\}}|s6tjdj|���|ddkr�|dtkr^tjdj|���t|�\}}|s~tjdj|���|dk	r�|g|ddd�<d}|j|�t	|�\}}|dk	r�|g|dd�<|j|�||fS)z, name-addr = [display-name] angle-addr

    Nrz!expected name-addr but found '{}'r)
rir�r�rr�r#r�rrSr
)rZ	name_addrr�r.rrr�
get_name_addr�s0

rcCs�t�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnXtdd�|jD��r�d|_|j	|�||fS)z& mailbox = name-addr / addr-spec

    zexpected mailbox but found '{}'css|]}t|tj�VqdS)N)r�rr�)rrrrrr �szget_mailbox.<locals>.<genexpr>zinvalid-mailbox)
rtrrr�rr#�anyr&r7rS)rrcr.rrr�get_mailbox�s
rcCsht�}xX|r^|d|kr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)z� Read everything up to one of the chars in endchars.

    This is outside the formal grammar.  The InvalidMailbox TokenList that is
    returned acts like a Mailbox, but the data attributes are None.

    rzmisplaced-specialrjN)rur�rSr�r�)rr�Zinvalid_mailboxr.rrr�get_invalid_mailbox�srcCs�t�}�x�|o|ddk�r�yt|�\}}|j|�W�ntjk
�r@d}|dtkr�t|�\}}|sz|ddkr�|j|�|jjtjd��n@t	|d�\}}|dk	r�|g|dd�<|j|�|jjtj
d��nb|ddkr�|jjtjd��nBt	|d�\}}|dk	�r |g|dd�<|j|�|jjtj
d��YnX|�r�|ddk�r�|d
}d	|_t	|d�\}}|j|�|jjtj
d��|r
|ddkr
|jt
�|dd�}q
W||fS)aJ mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
        obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])

    For this routine we go outside the formal grammar in order to improve error
    handling.  We recognize the end of the mailbox list only at the end of the
    value or at a ';' (the group terminator).  This is so that we can turn
    invalid mailboxes into InvalidMailbox tokens and continue parsing any
    remaining valid mailboxes.  We also allow all mailbox entries to be null,
    and this condition is handled appropriately at a higher level.

    r�;Nz,;zempty element in mailbox-listzinvalid mailbox in mailbox-listr�rjzinvalid-mailboxrl)rdrrSrr�r�r�rr�rr�r7r,r)rZmailbox_listr.r�rcrrr�get_mailbox_list�sN













rcCst�}|s$|jjtjd��||fSd}|r�|dtkr�t|�\}}|sl|jjtjd��|j|�||fS|ddkr�|j|�||fSt|�\}}t|j	�dkr�|dk	r�|j|�|j
|�|jjtjd��||fS|dk	r�|g|dd�<|j|�||fS)zg group-list = mailbox-list / CFWS / obs-group-list
        obs-group-list = 1*([CFWS] ",") [CFWS]

    zend of header before group-listNrzend of header in group-listrzgroup-list with empty entries)rfrrSrr�r�r�rrkr_r,r�)rZ
group_listr�r.rrr�get_group_list"s8







rcCs"t�}t|�\}}|s$|ddkr4tjdj|���|j|�|jtdd��|dd�}|r�|ddkr�|jtdd��||dd�fSt|�\}}|j|�|s�|jjtj	d	��n|ddkr�tjd
j|���|jtdd��|dd�}|�r|dt
k�rt|�\}}|j|�||fS)z7 group = display-name ":" [group-list] ";" [CFWS]

    rrz8expected ':' at end of group display name but found '{}'zgroup-display-name-terminatorrjNrzgroup-terminatorzend of header in groupz)expected ';' at end of group but found {})rgrrr�r#rSr�rrr�r�r�)rrar.rrr�	get_groupGs2




rcCsxt�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnX|j|�||fS)a� address = mailbox / group

    Note that counter-intuitively, an address can be either a single address or
    a list of addresses (a group).  This is why the returned Address object has
    a 'mailboxes' attribute which treats a single address as a list of length
    one.  When you need to differentiate between to two cases, extract the single
    element, which is either a mailbox or a group token.

    zexpected address but found '{}')r`rrr�rr#rS)rr\r.rrr�get_addresses
rcCs�t�}�x�|�r�yt|�\}}|j|�W�n$tjk
�rP}�zd}|dtkr�t|�\}}|sr|ddkr�|j|�|jjtjd��nFt	|d�\}}|dk	r�|g|dd�<|jt
|g��|jjtjd��nh|ddkr�|jjtjd��nHt	|d�\}}|dk	�r|g|dd�<|jt
|g��|jjtjd��WYdd}~XnX|�r�|ddk�r�|d
d}d|_t	|d�\}}|j
|�|jjtjd��|r
|jtdd	��|dd�}q
W||fS)a� address_list = (address *("," address)) / obs-addr-list
        obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])

    We depart from the formal grammar here by continuing to parse until the end
    of the input, assuming the input to be entirely composed of an
    address-list.  This is always true in email parsing, and allows us
    to skip invalid addresses to parse additional valid ones.

    Nrr�z"address-list entry with no contentzinvalid address in address-listzempty element in address-listrjzinvalid-mailboxzlist-separatorrl)r[rrSrr�r�r�rr�rr`r�r7r,r�)rZaddress_listr.�errr�rcrrr�get_address_list�sN












rcCs�t�}|s |jjtjd��|S|dtkrXt|�\}}|j|�|sX|jjtjd��d}x8|r�|ddkr�|dtkr�||d7}|dd�}q^W|j�s�|jjtjdj	|���|jt
|d	��nt|�|_|jt
|d
��|o�|dtk�r
t|�\}}|j|�|�s |ddk�rX|jdk	�r>|jjtjd��|�rT|jt
|d	��|S|jt
dd��|dd�}|�r�|dtk�r�t|�\}}|j|�|�s�|jdk	�r�|jjtjd��|Sd}x2|�r�|dtk�r�||d7}|dd�}�q�W|j��s2|jjtjd
j	|���|jt
|d	��nt|�|_
|jt
|d
��|�rv|dtk�rvt|�\}}|j|�|�r�|jjtjd��|jt
|d	��|S)zE mime-version = [CFWS] 1*digit [CFWS] "." [CFWS] 1*digit [CFWS]

    z%Missing MIME version number (eg: 1.0)rz0Expected MIME version number but found only CFWSrr	rjNz1Expected MIME major version number but found {!r}r��digitsz0Incomplete MIME version; found only major numberzversion-separatorz1Expected MIME minor version number but found {!r}z'Excess non-CFWS text after MIME version)r�rrSr�HeaderMissingRequiredValuer�r��isdigitr�r#r��intr�r�)rZmime_versionr.rrrr�parse_mime_version�sv













rcCsht�}xX|r^|ddkr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)z� Read everything up to the next ';'.

    This is outside the formal grammar.  The InvalidParameter TokenList that is
    returned acts like a Parameter, but the data attributes are None.

    rrzmisplaced-specialrjN)r�r�rSr�r�)rZinvalid_parameterr.rrr�get_invalid_parametersrcCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)a8ttext = <matches _ttext_matcher>

    We allow any non-TOKEN_ENDS in ttext, but add defects to the token's
    defects list if we find non-ttext characters.  We also register defects for
    *any* non-printables even though the RFC doesn't exclude all of them,
    because we follow the spirit of RFC 5322.

    zexpected ttext but found '{}'N�ttext)�_non_token_end_matcherrr�r#rarkr�r�)rr�r rrr�	get_ttexts	
r"cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)z�token = [CFWS] 1*ttext [CFWS]

    The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or
    tspecials.  We also exclude tabs even though the RFC doesn't.

    The RFC implies the CFWS but is not explicit about it in the BNF.

    rzexpected token but found '{}')	rMr�r�rS�
TOKEN_ENDSrr�r#r")rZmtokenr.rrr�	get_token)s	


r$cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)aQattrtext = 1*(any non-ATTRIBUTE_ENDS character)

    We allow any non-ATTRIBUTE_ENDS in attrtext, but add defects to the
    token's defects list if we find non-attrtext characters.  We also register
    defects for *any* non-printables even though the RFC doesn't exclude all of
    them, because we follow the spirit of RFC 5322.

    z expected attrtext but found {!r}Nr�)�_non_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_attrtext@s	
r&cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)aH [CFWS] 1*attrtext [CFWS]

    This version of the BNF makes the CFWS explicit, and as usual we use a
    value terminal for the actual run of characters.  The RFC equivalent of
    attrtext is the token characters, with the subtraction of '*', "'", and '%'.
    We include tab in the excluded set just as we do for token.

    rzexpected token but found '{}')	r�r�r�rS�ATTRIBUTE_ENDSrr�r#r&)rr�r.rrr�
get_attributeSs	


r(cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)z�attrtext = 1*(any non-ATTRIBUTE_ENDS character plus '%')

    This is a special parsing routine so that we get a value that
    includes % escapes as a single string (which we decode as a single
    string later).

    z)expected extended attrtext but found {!r}Nzextended-attrtext)�#_non_extended_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_extended_attrtextjs
r*cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)z� [CFWS] 1*extended_attrtext [CFWS]

    This is like the non-extended version except we allow % characters, so that
    we can pick up an encoded value as a single string.

    rzexpected token but found '{}')	r�r�r�rS�EXTENDED_ATTRIBUTE_ENDSrr�r#r*)rr�r.rrr�get_extended_attribute|s


r,cCs�t�}|s|ddkr(tjdj|���|jtdd��|dd�}|sX|dj�rhtjdj|���d}x,|r�|dj�r�||d7}|dd�}qnW|dd	kr�|d	kr�|jjtjd
��t	|�|_
|jt|d��||fS)a6 '*' digits

    The formal BNF is more complicated because leading 0s are not allowed.  We
    check for that and add a defect.  We also assume no CFWS is allowed between
    the '*' and the digits, though the RFC is not crystal clear on that.
    The caller should already have dealt with leading CFWS.

    r�*zExpected section but found {}zsection-markerrjNz$Expected section number but found {}r�0z'section number has an invalid leading 0r)r�rr�r#rSr�rrZInvalidHeaderErrorrr�)rr�rrrr�get_section�s&	

r/cCs�t�}|stjd��d}|dtkr0t|�\}}|sDtjdj|���|ddkr^t|�\}}nt|�\}}|dk	r�|g|dd�<|j|�||fS)z  quoted-string / attribute

    z&Expected value but found end of stringNrz Expected value but found only {}r
)	r�rr�r�r�r#r�r,rS)r�vr�r.rrr�	get_value�s 

r1cCsvt�}t|�\}}|j|�|s.|ddkrN|jjtjdj|���||fS|ddkr�y t|�\}}d|_|j|�Wntj	k
r�YnX|s�tj	d��|ddkr�|jt
dd��|dd	�}d|_|dd
kr�tj	d��|jt
d
d��|dd	�}d	}|�r.|dtk�r.t
|�\}}|j|�d	}|}|j�rH|�rH|dd
k�rHt|�\}}|j}d}|jdk�r�|�r�|ddk�r�d}n$t|�\}}	|	�r�|	ddk�r�d}n(yt|�\}}	WnYnX|	�s�d}|�r2|jjtjd��|j|�x,|D]$}
|
jdk�rg|
d	d	�<|
}P�qW|}nd	}|jjtjd��|�rb|ddk�rbd	}nt|�\}}|j�s�|jdk�r�|�s�|ddk�r�|j|�|d	k	�r�|}||fS|jjtjd��|�s|jjtjd��|j|�|d	k�r�||fSn�|d	k	�rFx|D]}
|
jdk�rP�qW|
jdk|j|
�|
j|_|ddk�rdtj	dj|���|jt
dd��|dd	�}|�r�|ddk�r�t|�\}}|j|�|j|_|�s�|ddk�r�tj	dj|���|jt
dd��|dd	�}|d	k	�rJt�}x>|�rB|dtk�r(t|�\}}nt|�\}}|j|��qW|}nt|�\}}|j|�|d	k	�rn|}||fS)aY attribute [section] ["*"] [CFWS] "=" value

    The CFWS is implied by the RFC but not made explicit in the BNF.  This
    simplified form of the BNF from the RFC is made to conform with the RFC BNF
    through some extra checks.  We do it this way because it makes both error
    recovery and working with the resulting parse tree easier.
    rrz)Parameter contains name ({}) but no valuer-TzIncomplete parameterzextended-parameter-markerrjN�=zParameter not followed by '='zparameter-separatorr
F�'z5Quoted string value for extended parameter is invalidzbare-quoted-stringzZParameter marked as extended but appears to have a quoted string value that is non-encodedzcApparent initial-extended-value but attribute was not marked as extended or was not initial sectionz(Missing required charset/lang delimiterszextended-attrtextr�z=Expected RFC2231 char/lang encoding delimiter, but found {!r}zRFC2231-delimiterz;Expected RFC2231 char/lang encoding delimiter, but found {})r�r(rSrrr�r#r/r�r�r�r�r�r�r�rVr�r&r*r7r1rrPrQr�r�r�r�)rr�r.r�r�ZappendtoZqstringZinner_valueZ
semi_validr��tr0rrr�
get_parameter�s�























r5cCsht�}�xZ|�rbyt|�\}}|j|�Wn�tjk
r�}z�d}|dtkrZt|�\}}|sl|j|�|S|ddkr�|dk	r�|j|�|jjtjd��n@t	|�\}}|r�|g|dd�<|j|�|jjtjdj
|���WYdd}~XnX|�r@|ddk�r@|d
}d|_t	|�\}}|j|�|jjtjdj
|���|r
|jt
dd	��|dd�}q
W|S)a! parameter *( ";" parameter )

    That BNF is meant to indicate this routine should only be called after
    finding and handling the leading ';'.  There is no corresponding rule in
    the formal RFC grammar, but it is more convenient for us for the set of
    parameters to be treated as its own TokenList.

    This is 'parse' routine because it consumes the reminaing value, but it
    would never be called to parse a full header.  Instead it is called to
    parse everything after the non-parameter value of a specific MIME header.

    Nrrzparameter entry with no contentzinvalid parameter {!r}rjzinvalid-parameterz)parameter with invalid trailing text {!r}zparameter-separatorrl)r�r5rSrr�r�r�rr�rr#r7r,r�)rZmime_parametersr.rr�r�rrr�parse_mime_parametersQ	sD







 

r6cCs�xX|rX|ddkrX|dtkr@|jt|dd��|dd�}qt|�\}}|j|�qW|sbdS|jtdd��|jt|dd���dS)zBDo our best to find the parameters in an invalid MIME header

    rrzmisplaced-specialrjNzparameter-separator)r�rSr�r�r6)Z	tokenlistrr.rrr�_find_mime_parameters�	sr7cCs�t�}d}|s$|jjtjd��|Syt|�\}}Wn8tjk
rl|jjtjdj|���t	||�|SX|j|�|s�|ddkr�|jjtjd��|r�t	||�|S|j
j�j�|_
|jtdd��|dd	�}yt|�\}}Wn:tjk
�r$|jjtjd
j|���t	||�|SX|j|�|j
j�j�|_|�sJ|S|ddk�r�|jjtjdj|���|`
|`t	||�|S|jtdd
��|jt|dd	���|S)z� maintype "/" subtype *( ";" parameter )

    The maintype and substype are tokens.  Theoretically they could
    be checked against the official IANA list + x-token, but we
    don't do that.
    Fz"Missing content type specificationz(Expected content maintype but found {!r}rr�zInvalid content typezcontent-type-separatorrjNz'Expected content subtype but found {!r}rz<Only parameters are valid after content type, but found {!r}zparameter-separator)r�rrSrrr$r�r�r#r7rr��lowerr�r�r�r6)rZctypeZrecoverr.rrr�parse_content_type_header�	sX











r9c
Cs�t�}|s |jjtjd��|Syt|�\}}Wn8tjk
rh|jjtjdj|���t	||�|SX|j|�|j
j�j�|_
|s�|S|ddkr�|jjtjdj|���t	||�|S|jtdd��|jt|dd���|S)	z* disposition-type *( ";" parameter )

    zMissing content dispositionz+Expected content disposition but found {!r}rrzCOnly parameters are valid after content disposition, but found {!r}zparameter-separatorrjN)r�rrSrrr$r�r�r#r7rr�r8r�r�r6)rZdisp_headerr.rrr� parse_content_disposition_header�	s2






r:cCs�t�}|s |jjtjd��|Syt|�\}}Wn.tjk
r^|jjtjdj|���YnX|j|�|j	j
�j�|_|s�|Sx^|r�|jjtjd��|dt
kr�|jt|dd��|dd�}q�t|�\}}|j|�q�W|S)z mechanism

    z!Missing content transfer encodingz1Expected content transfer encoding but found {!r}z*Extra text after content transfer encodingrzmisplaced-specialrjN)r�rrSrrr$r�r�r#rr�r8rOr�r�r�)rZ
cte_headerr.rrr�&parse_content_transfer_encoding_header�	s.



r;cCsDd}|r@|dr@|ddtkr@|dd}|ddd	�|d
<|S)Nrrjrlrlrlrlrlrlrlrl)r�)�linesZwsprrr�_steal_trailing_WSP_if_exists
s
r=cCs�|jptd�}|jrdnd}dg}d}d}d}tdd�}t|�}	�xz|	�r�|	jd�}
|
|krf|d	8}qDt|
�}|s�|
jd
kr�tj	|�}nt
j	|�}y|j|�|}Wn6tk
r�t
dd�|
jD��r�d
}nd}d}YnX|
jdkr�t|
|||�qD|�r�|�r�|
j�s�d}d}|
j�r�|
j|d�dt|j��}
|j|
k�r�t|
�|t|d�k�rtt|�}|j|�|d|
7<qDt|
d��s�t|
�|	}	nt|||||
j|�}d}qDt|�|t|d�k�r�|d|7<qD|
j�r(t|�d	|k�r(t|�}|�s|
j��r(|j||�qDt|
d��s`t|
�}|
j�sV|d	7}|j|�||	}	qD|
j�r�|�r�|	jd|
�d}qDt|�}|�s�|
j��r�|j||�qD|d|7<qDW|jj|�|jS)zLReturn string of contents of parse_tree folded according to RFC rules.

    z+infzutf-8zus-asciirNrF�wrap_as_ew_blockedrjr�css|]}t|tj�VqdS)N)r�rr�)rrrrrr @
sz%_refold_parse_tree.<locals>.<genexpr>zunknown-8bitTzmime-parameters)r/r�rlrlrlrlrl)Zmax_line_length�float�utf8r�r�r�rr7�
SPECIALSNL�
isdisjoint�NLSETr�r�rr&�_fold_mime_parametersr)r;r1rk�linesepr=rSr8�_fold_as_ewr<r(�insertr!)Z
parse_treer/�maxlenr�r<�last_ewr>Z
want_encodingZend_ew_not_allowedr�r*�tstrrPZencoded_part�newlineZnewpartsrrrr0"
s�










r0cCs�|dk	r<|r<tt|d
|d�|��}|dd|�|d<|dtkr�|d}|dd�}t|d
�|krz|jt|��|d|7<d}|dtkr�|d}|dd�}|dkr�t|d�n|}x�|�r�|t|d�}	|dkr�dn|}
|	t|
�d}|dk�r|jd�q�|d|�}tj||
d	�}
t|
�|	}|dk�r\|d|�}tj|�}
|d|
7<|t|�d�}|r�|jd�t|d�}q�W|d|7<|�r�|SdS)a�Fold string to_encode into lines as encoded word, combining if allowed.
    Return the new value for last_ew, or None if ew_combine_allowed is False.

    If there is already an encoded word in the last line of lines (indicated by
    a non-None value for last_ew) and ew_combine_allowed is true, decode the
    existing ew, combine it with to_encode, and re-encode.  Otherwise, encode
    to_encode.  In either case, split to_encode as necessary so that the
    encoded segments fit within maxlen.

    Nrjrrzus-asciizutf-8�r@)rPrlrlrlrlrlrlrlrlrlrlrlrlrl)rr�r�rkrSr=r�r�)Z	to_encoder<rHrIr<rPZleading_wspZtrailing_wspZnew_last_ewZremaining_spaceZ	encode_asZ
text_spaceZ
first_partr�ZexcessrrrrF�
sF




rFcCs��x�|jD�]�\}}|dj�jd�s6|dd7<|}d}y|j|�d}Wn0tk
r�d}tj|�rxd}d}nd}YnX|r�tjj	|d	|d
�}	dj
|||	�}
ndj
|t|��}
t|d�t|
�d|kr�|dd
|
|d<q
n"t|
�d|k�r|j
d
|
�q
d}|d}x�|�r�t|�tt|��dt|�}
||
dk�rTd}||
d}}x<|d|�}tjj	|d	|d
�}	t|	�|k�r�P|d8}�qfW|j
dj
||||	��d	}|d7}||d�}|�r|dd7<�qWq
WdS)a>Fold TokenList 'part' into the 'lines' list as mime parameters.

    Using the decoded list of parameters and values, format them according to
    the RFC rules, including using RFC2231 encoding if the value cannot be
    expressed in 'encoding' and/or the parameter+value is too long to fit
    within 'maxlen'.

    rjr�strictFTzunknown-8bitr�zutf-8r)Zsaferz
{}*={}''{}z{}={}r@rhrz''r{�NNz {}*{}*={}{}rlrlrlrlrlrl)r�r|r�r�r�rr�r�r�rYr#rrkrSr)r*r<rHr�r�rrPZ
error_handlerZencoding_requiredZ
encoded_valuerJr�Zextra_chromeZ
chrome_lenZ
splitpointZmaxchars�partialrrrrD�
s\


 rD)��__doc__�rer��stringr�collectionsr�operatorrZemailrr�rrrr�r�r�r�r�r�Z	TSPECIALSr#Z	ASPECIALSr'r+rCrArr�rr?rDrFrHrIrKrMrNrRrWrXr[r`rdrfrgrirqrsrtrurvrxryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�rr	�compiler#r!rwr�r�matchr��findallr�r!r%r)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
r
rrrrrrrrrrrr"r$r&r(r*r,r/r1r5r6r7r9r:r;r=r0rFrDrrrr�<module>DsC"	
!($
V	+




   

*8"
&'/'&).9%>D49/j7PKb��\�� S Sheaderregistry.cpython-36.pycnu�[���3


 \O�@sjdZddlmZddlmZddlmZddlmZGdd�d�ZGdd	�d	�Z	Gd
d�de
�Zdd
�ZGdd�d�Z
Gdd�de
�ZGdd�d�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGd d!�d!�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'�Zeeeeeeeeeeeeeeeeeeed(�ZGd)d*�d*�Zd+S),a;Representing and manipulating email headers via custom objects.

This module provides an implementation of the HeaderRegistry API.
The implementation is designed to flexibly follow RFC5322 rules.

Eventually HeaderRegistry will be a public API, but it isn't yet,
and will probably change some before that happens.

�)�MappingProxyType)�utils)�errors)�_header_value_parserc@s^eZdZddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCsl|dk	rV|s|rtd��tj|�\}}|r:tdj||���|jrJ|jd�|j}|j}||_||_	||_
dS)a�Create an object representing a full email address.

        An address can have a 'display_name', a 'username', and a 'domain'.  In
        addition to specifying the username and domain separately, they may be
        specified together by using the addr_spec keyword *instead of* the
        username and domain keywords.  If an addr_spec string is specified it
        must be properly quoted according to RFC 5322 rules; an error will be
        raised if it is not.

        An Address object has display_name, username, domain, and addr_spec
        attributes, all of which are read-only.  The addr_spec and the string
        value of the object are both quoted according to RFC5322 rules, but
        without any Content Transfer Encoding.

        Nz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)�	TypeError�parserZ
get_addr_spec�
ValueError�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_specZa_s�rest�r�,/usr/lib64/python3.6/email/headerregistry.py�__init__s

zAddress.__init__cCs|jS)N)r)rrrrr7szAddress.display_namecCs|jS)N)r)rrrrr;szAddress.usernamecCs|jS)N)r)rrrrr?szAddress.domaincCsTt|j�}t|�t|tj�kr.tj|j�}n|j}|jrH|d|jS|sPdS|S)z�The addr_spec (username@domain) portion of the address, quoted
        according to RFC 5322 rules, but with no Content Transfer Encoding.
        �@z<>)�setr�lenr	Z
DOT_ATOM_ENDS�quote_stringr)r�namesetZlprrrrCs
zAddress.addr_speccCsdj|jj|j|j|j�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrr)rrrr�__repr__SszAddress.__repr__cCs^t|j�}t|�t|tj�kr.tj|j�}n|j}|rX|jdkrFdn|j}dj||�S|jS)Nz<>rz{} <{}>)rrrr	�SPECIALSrrr)rr�disprrrr�__str__Xs
zAddress.__str__cCs8t|�t|�krdS|j|jko6|j|jko6|j|jkS)NF)�typerrr)r�otherrrr�__eq__cs
zAddress.__eq__)rrrN)r �
__module__�__qualname__r�propertyrrrrr!r$r'rrrrrs
%rc@sFeZdZddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs||_|rt|�nt�|_dS)aCreate an object representing an address group.

        An address group consists of a display_name followed by colon and a
        list of addresses (see Address) terminated by a semi-colon.  The Group
        is created by specifying a display_name and a possibly empty list of
        Address objects.  A Group can also be used to represent a single
        address that is not in a group, which is convenient when manipulating
        lists that are a combination of Groups and individual Addresses.  In
        this case the display_name should be set to None.  In particular, the
        string representation of a Group whose display_name is None is the same
        as the Address object, if there is one and only one Address object in
        the addresses list.

        N)r�tuple�
_addresses)rr�	addressesrrrrmszGroup.__init__cCs|jS)N)r)rrrrrszGroup.display_namecCs|jS)N)r-)rrrrr.�szGroup.addressescCsdj|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rrr rr.)rrrrr!�szGroup.__repr__cCs�|jdkr&t|j�dkr&t|jd�S|j}|dk	r\t|�}t|�t|tj�kr\tj|�}djdd�|jD��}|r~d|n|}dj	||�S)N�rz, css|]}t|�VqdS)N)�str)�.0�xrrr�	<genexpr>�sz Group.__str__.<locals>.<genexpr>� z{}:{};)
rrr.r0rr	r"r�joinr)rr#rZadrstrrrrr$�s
z
Group.__str__cCs,t|�t|�krdS|j|jko*|j|jkS)NF)r%rr.)rr&rrrr'�szGroup.__eq__)NN)
r r(r)rr*rr.r!r$r'rrrrr+ks
r+c@sTeZdZdZdd�Zdd�Zedd��Zedd	��Zd
d�Z	e
dd
��Zdd�ZdS)�
BaseHeadera|Base class for message headers.

    Implements generic behavior and provides tools for subclasses.

    A subclass must define a classmethod named 'parse' that takes an unfolded
    value string and a dictionary as its arguments.  The dictionary will
    contain one key, 'defects', initialized to an empty list.  After the call
    the dictionary must contain two additional keys: parse_tree, set to the
    parse tree obtained from parsing the header, and 'decoded', set to the
    string value of the idealized representation of the data from the value.
    (That is, encoded words are decoded, and values that have canonical
    representations are so represented.)

    The defects key is intended to collect parsing defects, which the message
    parser will subsequently dispose of as appropriate.  The parser should not,
    insofar as practical, raise any errors.  Defects should be added to the
    list instead.  The standard header parsers register defects for RFC
    compliance issues, for obsolete RFC syntax, and for unrecoverable parsing
    errors.

    The parse method may add additional keys to the dictionary.  In this case
    the subclass must define an 'init' method, which will be passed the
    dictionary as its keyword arguments.  The method should use (usually by
    setting them as the value of similarly named attributes) and remove all the
    extra keys added by its parse method, and then use super to call its parent
    class with the remaining arguments and keywords.

    The subclass should also make sure that a 'max_count' attribute is defined
    that is either None or 1. XXX: need to better define this API.

    cCs\dgi}|j||�tj|d�r4tj|d�|d<tj||d�}|d=|j|f|�|S)N�defects�decoded)�parserZ_has_surrogates�	_sanitizer0�__new__�init)�cls�name�value�kwdsrrrrr;�szBaseHeader.__new__cCs||_||_||_dS)N)�_name�_parse_tree�_defects)rr>�
parse_treer7rrrr<�szBaseHeader.initcCs|jS)N)rA)rrrrr>�szBaseHeader.namecCs
t|j�S)N)r,rC)rrrrr7�szBaseHeader.defectscCst|jj|jjt|�f|jfS)N)�_reconstruct_headerrr �	__bases__r0�__dict__)rrrr�
__reduce__�s
zBaseHeader.__reduce__cCstj||�S)N)r0r;)r=r?rrr�_reconstruct�szBaseHeader._reconstructcCs`tjtjtj|jd�tjdd�g�g�}|jrH|jtjtjdd�g��|j|j�|j	|d�S)atFold header according to policy.

        The parsed representation of the header is folded according to
        RFC5322 rules, as modified by the policy.  If the parse tree
        contains surrogateescaped bytes, the bytes are CTE encoded using
        the charset 'unknown-8bit".

        Any non-ASCII characters in the parse tree are CTE encoded using
        charset utf-8. XXX: make this a policy setting.

        The returned value is an ASCII-only string possibly containing linesep
        characters, and ending with a linesep character.  The string includes
        the header name and the ': ' separator.

        zheader-name�:z
header-sepr4Zfws)�policy)
r	ZHeaderZHeaderLabelZ
ValueTerminalr>rB�appendZCFWSListZWhiteSpaceTerminal�fold)rrK�headerrrrrM�szBaseHeader.foldN)
r r(r)�__doc__r;r<r*r>r7rH�classmethodrIrMrrrrr6�s 

r6cCst||i�j|�S)N)r%rI)Zcls_name�basesr?rrrrEsrEc@s&eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs"|j|�|d<t|d�|d<dS)NrDr8)�value_parserr0)r=r?r@rrrr9szUnstructuredHeader.parse)
r r(r)�	max_count�staticmethodr	�get_unstructuredrSrPr9rrrrrR	s
rRc@seZdZdZdS)�UniqueUnstructuredHeaderr/N)r r(r)rTrrrrrWsrWcsFeZdZdZdZeej�Ze	dd��Z
�fdd�Zedd��Z
�ZS)	�
DateHeadera�Header whose value consists of a single timestamp.

    Provides an additional attribute, datetime, which is either an aware
    datetime using a timezone, or a naive datetime if the timezone
    in the input string is -0000.  Also accepts a datetime as input.
    The 'value' attribute is the normalized form of the timestamp,
    which means it is the output of format_datetime on the datetime.
    NcCsz|s6|djtj��d|d<d|d<tj�|d<dSt|t�rJtj|�}||d<tj	|d�|d<|j
|d�|d<dS)Nr7�datetimerr8rD)rLrZHeaderMissingRequiredValuer	Z	TokenList�
isinstancer0rZparsedate_to_datetimeZformat_datetimerS)r=r?r@rrrr9)s

zDateHeader.parsecs|jd�|_t�j||�dS)NrY)�pop�	_datetime�superr<)r�args�kw)rrrr<7szDateHeader.initcCs|jS)N)r\)rrrrrY;szDateHeader.datetime)r r(r)rOrTrUr	rVrSrPr9r<r*rY�
__classcell__rr)rrrXs	
rXc@seZdZdZdS)�UniqueDateHeaderr/N)r r(r)rTrrrrra@sracsPeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�ZS)�
AddressHeaderNcCs tj|�\}}|std��|S)Nzthis should not happen)r	Zget_address_list�AssertionError)r?�address_listrrrrSIszAddressHeader.value_parsercCs�t|t�rZ|j|�|d<}g}x,|jD]"}|jt|jdd�|jD���q(Wt|j	�}n"t
|d�sj|g}dd�|D�}g}||d<||d<djd	d�|D��|d
<d|kr�|j|d
�|d<dS)NrDcSs*g|]"}t|jpd|jpd|jp"d��qS)r)rrr
r)r1Zmbrrr�
<listcomp>Xsz'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs&g|]}t|d�std|g�n|�qS)r.N)�hasattrr+)r1�itemrrrreas�groupsr7z, cSsg|]}t|��qSr)r0)r1rhrrrregsr8)rZr0rSr.rLr+rZ
all_mailboxes�listrrgr5)r=r?r@rdriZaddrr7rrrr9Os$


zAddressHeader.parsecs(t|jd��|_d|_t�j||�dS)Nri)r,r[�_groupsr-r]r<)rr^r_)rrrr<kszAddressHeader.initcCs|jS)N)rk)rrrrripszAddressHeader.groupscCs&|jdkr tdd�|jD��|_|jS)NcSsg|]}|jD]}|�qqSr)r.)r1�group�addressrrrrewsz+AddressHeader.addresses.<locals>.<listcomp>)r-r,rk)rrrrr.ts
zAddressHeader.addresses)
r r(r)rTrUrSrPr9r<r*rir.r`rr)rrrbEsrbc@seZdZdZdS)�UniqueAddressHeaderr/N)r r(r)rTrrrrrn|srnc@seZdZedd��ZdS)�SingleAddressHeadercCs(t|j�dkrtdj|j���|jdS)Nr/z9value of single address header {} is not a single addressr)rr.r
rr>)rrrrrm�s
zSingleAddressHeader.addressN)r r(r)r*rmrrrrro�sroc@seZdZdZdS)�UniqueSingleAddressHeaderr/N)r r(r)rTrrrrrp�srpcsZeZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�ZS)�MIMEVersionHeaderr/cCs�|j|�|d<}t|�|d<|dj|j�|jdkr<dn|j|d<|j|d<|jdk	rtdj|d|d�|d<nd|d<dS)NrDr8r7�major�minorz{}.{}�version)rSr0�extendrrsrrr)r=r?r@rDrrrr9�s

zMIMEVersionHeader.parsecs6|jd�|_|jd�|_|jd�|_t�j||�dS)Nrtrrrs)r[�_version�_major�_minorr]r<)rr^r_)rrrr<�szMIMEVersionHeader.initcCs|jS)N)rw)rrrrrr�szMIMEVersionHeader.majorcCs|jS)N)rx)rrrrrs�szMIMEVersionHeader.minorcCs|jS)N)rv)rrrrrt�szMIMEVersionHeader.version)r r(r)rTrUr	Zparse_mime_versionrSrPr9r<r*rrrsrtr`rr)rrrq�s
rqcs8eZdZdZedd��Z�fdd�Zedd��Z�Z	S)�ParameterizedMIMEHeaderr/cCsZ|j|�|d<}t|�|d<|dj|j�|jdkrBi|d<ndd�|jD�|d<dS)NrDr8r7�paramscSs&i|]\}}tj|�tj|�j��qSr)rr:�lower)r1r>r?rrr�
<dictcomp>�sz1ParameterizedMIMEHeader.parse.<locals>.<dictcomp>)rSr0rurrz)r=r?r@rDrrrr9�s

zParameterizedMIMEHeader.parsecs|jd�|_t�j||�dS)Nrz)r[�_paramsr]r<)rr^r_)rrrr<�szParameterizedMIMEHeader.initcCs
t|j�S)N)rr})rrrrrz�szParameterizedMIMEHeader.params)
r r(r)rTrPr9r<r*rzr`rr)rrry�s
rycsJeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�ZS)	�ContentTypeHeadercs2t�j||�tj|jj�|_tj|jj�|_dS)N)	r]r<rr:rB�maintype�	_maintype�subtype�_subtype)rr^r_)rrrr<�szContentTypeHeader.initcCs|jS)N)r�)rrrrr�szContentTypeHeader.maintypecCs|jS)N)r�)rrrrr��szContentTypeHeader.subtypecCs|jd|jS)N�/)rr�)rrrr�content_type�szContentTypeHeader.content_type)
r r(r)rUr	Zparse_content_type_headerrSr<r*rr�r�r`rr)rrr~�s

r~cs2eZdZeej�Z�fdd�Zedd��Z	�Z
S)�ContentDispositionHeadercs2t�j||�|jj}|dkr"|ntj|�|_dS)N)r]r<rB�content_dispositionrr:�_content_disposition)rr^r_Zcd)rrrr<�szContentDispositionHeader.initcCs|jS)N)r�)rrrrr��sz,ContentDispositionHeader.content_disposition)r r(r)rUr	Z parse_content_disposition_headerrSr<r*r�r`rr)rrr��s
r�csBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�ContentTransferEncodingHeaderr/cCs2|j|�|d<}t|�|d<|dj|j�dS)NrDr8r7)rSr0rur)r=r?r@rDrrrr9�sz#ContentTransferEncodingHeader.parsecs"t�j||�tj|jj�|_dS)N)r]r<rr:rB�cte�_cte)rr^r_)rrrr<sz"ContentTransferEncodingHeader.initcCs|jS)N)r�)rrrrr�sz!ContentTransferEncodingHeader.cte)r r(r)rTrUr	Z&parse_content_transfer_encoding_headerrSrPr9r<r*r�r`rr)rrr��s

r�)ZsubjectZdatezresent-datez	orig-dateZsenderz
resent-senderZtoz	resent-toZccz	resent-ccZbccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-typezcontent-dispositionzcontent-transfer-encodingc@s8eZdZdZeedfdd�Zdd�Zdd�Zd	d
�Z	dS)�HeaderRegistryz%A header_factory and header registry.TcCs&i|_||_||_|r"|jjt�dS)a�Create a header_factory that works with the Policy API.

        base_class is the class that will be the last class in the created
        header class's __bases__ list.  default_class is the class that will be
        used if "name" (see __call__) does not appear in the registry.
        use_default_map controls whether or not the default mapping of names to
        specialized classes is copied in to the registry when the factory is
        created.  The default is True.

        N)�registry�
base_class�
default_class�update�_default_header_map)rr�r�Zuse_default_maprrrr's
zHeaderRegistry.__init__cCs||j|j�<dS)zLRegister cls as the specialized class for handling "name" headers.

        N)r�r{)rr>r=rrr�map_to_type9szHeaderRegistry.map_to_typecCs,|jj|j�|j�}td|j||jfi�S)N�_)r��getr{r�r%r r�)rr>r=rrr�__getitem__?szHeaderRegistry.__getitem__cCs||||�S)a�Create a header instance for header 'name' from 'value'.

        Creates a header instance by creating a specialized class for parsing
        and representing the specified header by combining the factory
        base_class with a specialized class from the registry or the
        default_class, and passing the name and value to the constructed
        class's constructor.

        r)rr>r?rrr�__call__Cs
zHeaderRegistry.__call__N)
r r(r)rOr6rRrr�r�r�rrrrr�#sr�N)rO�typesrZemailrrrr	rr+r0r6rErRrWrXrarbrnrorprqryr~r�r�r�r�rrrr�<module>	sR[6d'7
%PKb��\E��=quoprimime.cpython-36.opt-1.pycnu�[���3


 \�&�
@sddZddddddddd	d
g
ZddlZdd
lmZmZmZdZdZdZ	dd�e
d�D�Zedd�Zedd�Z
x,dejd�ejd�D]Zee�ee<q�Wdeed�<xdD]Zee�e
e<q�Wdd�Zdd�Zdd�Zdd�Zd,dd �Zd!d
�Zd"d	�Zd-d$d�Ze
dd�Zxd%D]Zee�ee<�qWd&efd'd�Zefd(d�ZeZeZd)d*�Zd+d�Z dS).aFQuoted-printable content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode US ASCII-like 8-bit data called `quoted-printable'.  It is used to
safely encode text that is in a character set similar to the 7-bit US ASCII
character set, but that includes some 8-bit characters that are normally not
allowed in email bodies or headers.

Quoted-printable is very space-inefficient for encoding binary files; use the
email.base64mime module for that instead.

This module provides an interface to encode and decode both headers and bodies
with quoted-printable encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:/From:/Cc: etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character
conversion necessary for proper internationalized headers; it only
does dumb encoding and decoding.  To deal with the various line
wrapping issues, use the email.header module.
�body_decode�body_encode�body_length�decode�decodestring�
header_decode�
header_encode�
header_length�quote�unquote�N)�
ascii_letters�digits�	hexdigitsz
�
�cCsg|]}d|�qS)z=%02X�)�.0�crr�(/usr/lib64/python3.6/email/quoprimime.py�
<listcomp>7sr�s-!*+/�ascii�_� s_ !"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~	cCst|�t|kS)z>Return True if the octet should be escaped with header quopri.)�chr�_QUOPRI_HEADER_MAP)�octetrrr�header_checkJsrcCst|�t|kS)z<Return True if the octet should be escaped with body quopri.)r�_QUOPRI_BODY_MAP)rrrr�
body_checkOsrcCstdd�|D��S)a:Return a header quoted-printable encoding length.

    Note that this does not include any RFC 2047 chrome added by
    `header_encode()`.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for headers.
    css|]}tt|�VqdS)N)�lenr)rrrrr�	<genexpr>^sz header_length.<locals>.<genexpr>)�sum)�	bytearrayrrrrTs
cCstdd�|D��S)z�Return a body quoted-printable encoding length.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for bodies.
    css|]}tt|�VqdS)N)r r)rrrrrr!hszbody_length.<locals>.<genexpr>)r")r#rrrrascCsft|t�st|�}|s&|j|j��n<t|d�t|�|krT|d||7<n|j|j��dS)N����r%)�
isinstance�strr�append�lstripr )�L�s�maxlenZextrarrr�_max_appendks
r-cCstt|dd�d��S)zDTurn a string in the form =AB to the ASCII character with value 0xabr$��)r�int)r+rrrr
vscCstt|�S)N)�_QUOPRI_MAP�ord)rrrrr	{s�
iso-8859-1cCs$|sdS|jd�jt�}d||fS)a�Encode a single header line with quoted-printable (like) encoding.

    Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but
    used specifically for email header fields to allow charsets with mostly 7
    bit characters (and some 8 bit) to remain more or less readable in non-RFC
    2045 aware mail clients.

    charset names the character set to use in the RFC 2046 header.  It
    defaults to iso-8859-1.
    r�latin1z=?%s?q?%s?=)r�	translater)Zheader_bytes�charset�encodedrrrrss
�Lc
Cs�|dkrtd��|s|S|jt�}d|}|d}g}|j}�x,|j�D�]}d}t|�d|}	x�||	kr�||}
||
ddkr�||||
d��|
d}qd||
ddkr�||||
��|
d}qd||||
�d�|
}qdW|o�|ddk�rX||	}|dk�rt|d�}n(|dk�r2|d
|}n|t|d�}|||d�|�qH|||d	��qHW|dtk�r�|d
�|j|�S)a�Encode with quoted-printable, wrapping at maxlinelen characters.

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.

    Each line will be wrapped at, at most, maxlinelen characters before the
    eol string (maxlinelen defaults to 76 characters, the maximum value
    permitted by RFC 2045).  Long lines will have the 'soft line break'
    quoted-printable character "=" appended to them, so the decoded text will
    be identical to the original text.

    The minimum maxlinelen is 4 to have room for a quoted character ("=XX")
    followed by a soft line break.  Smaller values will generate a
    ValueError.

    �zmaxlinelen must be at least 4�=r$r�z 	r.Nrr%r%r%r%r%r%)	�
ValueErrorr5�_QUOPRI_BODY_ENCODE_MAPr(�
splitlinesr r	�CRLF�join)
ZbodyZ
maxlinelen�eolZ
soft_breakZmaxlinelen1Zencoded_bodyr(�line�startZ	laststart�stopZroom�qrrrr�sD





cCs |s|Sd}x�|j�D]�}|j�}|s0||7}qd}t|�}x�||kr�||}|dkrh||7}|d7}nv|d|kr�|d7}q>n^|d|kr�||dtkr�||dtkr�|t|||d��7}|d7}n||7}|d7}||kr>||7}q>WqW|d	dk�r|j|��r|dd
�}|S)z_Decode a quoted-printable string.

    Lines are separated with eol, which defaults to \n.
    rrr:r$r;r.z
Nr%r%)r>�rstripr rr
�endswith)r7rAZdecodedrB�i�nrrrrr�s8

,
cCs|jd�}t|�S)zCTurn a match in the form =AB to the ASCII character with value 0xabr)�groupr
)�matchr+rrr�_unquote_matchs
rLcCs |jdd�}tjdt|tjd�S)aDecode a string encoded with RFC 2045 MIME header `Q' encoding.

    This function does not parse a full MIME header value encoded with
    quoted-printable (like =?iso-8859-1?q?Hello_World?=) -- please use
    the high level email.header class for that functionality.
    rrz=[a-fA-F0-9]{2})�flags)�replace�re�subrL�ASCII)r+rrrr#s)r)r3)!�__doc__�__all__rO�stringrr
rr?�NLZEMPTYSTRING�ranger1rr�encoderrr2rrrrr-r
r	rr=rrrrrLrrrrr�<module>sP





O0PKb��\p�Jjmmquoprimime.cpython-36.opt-2.pycnu�[���3


 \�&�
@s`dddddddddd	g
Zd
dlZd
dlmZmZmZd
ZdZdZdd�e	d�D�Z
e
dd�Ze
dd�Zx,dej
d�ej
d�D]Zee�ee<q�Wdeed�<xdD]Zee�ee<q�Wdd�Zdd�Zdd�Zdd�Zd+dd�Zd d	�Zd!d�Zd,d#d�Zedd�Zxd$D]Zee�ee<�qWd%efd&d�Zefd'd�ZeZeZd(d)�Zd*d�ZdS)-�body_decode�body_encode�body_length�decode�decodestring�
header_decode�
header_encode�
header_length�quote�unquote�N)�
ascii_letters�digits�	hexdigitsz
�
�cCsg|]}d|�qS)z=%02X�)�.0�crr�(/usr/lib64/python3.6/email/quoprimime.py�
<listcomp>7sr�s-!*+/�ascii�_� s_ !"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~	cCst|�t|kS)N)�chr�_QUOPRI_HEADER_MAP)�octetrrr�header_checkJsrcCst|�t|kS)N)r�_QUOPRI_BODY_MAP)rrrr�
body_checkOsrcCstdd�|D��S)Ncss|]}tt|�VqdS)N)�lenr)rrrrr�	<genexpr>^sz header_length.<locals>.<genexpr>)�sum)�	bytearrayrrrrTs
cCstdd�|D��S)Ncss|]}tt|�VqdS)N)r r)rrrrrr!hszbody_length.<locals>.<genexpr>)r")r#rrrrascCsft|t�st|�}|s&|j|j��n<t|d�t|�|krT|d||7<n|j|j��dS)N����r%)�
isinstance�strr�append�lstripr )�L�s�maxlenZextrarrr�_max_appendks
r-cCstt|dd�d��S)Nr$��)r�int)r+rrrr
vscCstt|�S)N)�_QUOPRI_MAP�ord)rrrrr	{s�
iso-8859-1cCs$|sdS|jd�jt�}d||fS)Nr�latin1z=?%s?q?%s?=)r�	translater)Zheader_bytes�charset�encodedrrrrss
�Lc
Cs�|dkrtd��|s|S|jt�}d|}|d}g}|j}�x,|j�D�]}d}t|�d|}	x�||	kr�||}
||
ddkr�||||
d��|
d}qd||
ddkr�||||
��|
d}qd||||
�d�|
}qdW|o�|d
dk�rX||	}|dk�rt|d�}n(|dk�r2|d|}n|t|d
�}|||d�|�qH|||d��qHW|dtk�r�|d	�|j|�S)N�zmaxlinelen must be at least 4�=r$r�z 	r.rr%r%r%r%r%r%)	�
ValueErrorr5�_QUOPRI_BODY_ENCODE_MAPr(�
splitlinesr r	�CRLF�join)
ZbodyZ
maxlinelen�eolZ
soft_breakZmaxlinelen1Zencoded_bodyr(�line�startZ	laststart�stopZroom�qrrrr�sD





cCs |s|Sd}x�|j�D]�}|j�}|s0||7}qd}t|�}x�||kr�||}|dkrh||7}|d7}nv|d|kr�|d7}q>n^|d|kr�||dtkr�||dtkr�|t|||d��7}|d7}n||7}|d7}||kr>||7}q>WqW|ddk�r|j|��r|dd	�}|S)
Nrrr:r$r;r.z
r%r%)r>�rstripr rr
�endswith)r7rAZdecodedrB�i�nrrrrr�s8

,
cCs|jd�}t|�S)Nr)�groupr
)�matchr+rrr�_unquote_matchs
rLcCs |jdd�}tjdt|tjd�S)Nrrz=[a-fA-F0-9]{2})�flags)�replace�re�subrL�ASCII)r+rrrr#s)r)r3) �__all__rO�stringrr
rr?�NLZEMPTYSTRING�ranger1rr�encoderrr2rrrrr-r
r	rr=rrrrrLrrrrr�<module>sN





O0PKb��\���"charset.cpython-36.opt-2.pycnu�[���3


 \�B�@srddddgZddlmZddlZddlZddlmZddlmZd	Z	d
Z
dZdZd
Z
dZdZe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfd*e
e
dfe
e
dfe
ddfe
ddfe
ddfe
e
dfee
dfd�Zdddddddddddddddddddddddd
d �Zd!d"dd#�Zd+d$d�Zd%d�Zd&d�Zd'd(�ZGd)d�d�ZdS),�Charset�	add_alias�add_charset�	add_codec�)�partialN)�errors)�encode_7or8bit����zus-asciizunknown-8bit�ziso-2022-jpzutf-8)z
iso-8859-1z
iso-8859-2z
iso-8859-3z
iso-8859-4z
iso-8859-9ziso-8859-10ziso-8859-13ziso-8859-14ziso-8859-15ziso-8859-16zwindows-1252Zvisciizus-ascii�big5�gb2312zeuc-jp�	shift_jisziso-2022-jpzkoi8-rzutf-8z
iso-8859-1z
iso-8859-2z
iso-8859-3z
iso-8859-4z
iso-8859-9ziso-8859-10ziso-8859-13ziso-8859-14ziso-8859-15ziso-8859-16zks_c_5601-1987zeuc-jpzeuc-kr)�latin_1zlatin-1Zlatin_2zlatin-2Zlatin_3zlatin-3Zlatin_4zlatin-4Zlatin_5zlatin-5Zlatin_6zlatin-6Zlatin_7zlatin-7Zlatin_8zlatin-8Zlatin_9zlatin-9Zlatin_10zlatin-10�cp949�euc_jp�euc_kr�ascii�eucgb2312_cn�big5_tw)rrzus-asciicCs"|tkrtd��|||ft|<dS)Nz!SHORTEST not allowed for body_enc)�SHORTEST�
ValueError�CHARSETS)�charsetZ
header_encZbody_enc�output_charset�r�%/usr/lib64/python3.6/email/charset.pyrmscCs|t|<dS)N)�ALIASES)�aliasZ	canonicalrrrr�scCs|t|<dS)N)�	CODEC_MAP)rZ	codecnamerrrr�scCs"|tkr|jdd�S|j|�SdS)Nr�surrogateescape)�UNKNOWN8BIT�encode)�string�codecrrr�_encode�sr'c@s\eZdZefdd�Zdd�ZeZdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)rc
Cs�y$t|t�r|jd�n
t|d�}Wntk
rBtj|��YnX|j�}tj||�|_	t
j|j	ttdf�\}}}|s~|j	}||_
||_tj||�|_tj|j	|j	�|_tj|j|j�|_dS)Nr)�
isinstance�strr$�UnicodeErrorrZCharsetError�lowerr�get�
input_charsetrr�BASE64�header_encoding�
body_encodingrr!Zinput_codec�output_codec)�selfr-ZhencZbencZconvrrr�__init__�s&

zCharset.__init__cCs
|jj�S)N)r-r+)r2rrr�__str__�szCharset.__str__cCst|�t|�j�kS)N)r)r+)r2�otherrrr�__eq__�szCharset.__eq__cCs$|jtkrdS|jtkrdStSdS)Nzquoted-printable�base64)r0�QPr.r)r2rrr�get_body_encoding�s


zCharset.get_body_encodingcCs|jp
|jS)N)rr-)r2rrr�get_output_charsetszCharset.get_output_charsetcCs6|jpd}t||�}|j|�}|dkr*|S|j||�S)Nzus-ascii)r1r'�_get_encoder�
header_encode)r2r%r&�header_bytes�encoder_modulerrrr<s


zCharset.header_encodecCs|jpd}t||�}|j|�}t|j|d�}|j�}t|�t}g}	g}
t|�|}x�|D]�}|
j	|�t
j|
�}
|jt|
|��}||krZ|
j
�|	r�|
r�|	j	d�n.|	r�dnd}t
j|
�}t||�}|	j	||��|g}
t|�|}qZWt
j|
�}t||�}|	j	||��|	S)Nzus-ascii)r� r
)r1r'r;rr<r:�len�RFC2047_CHROME_LEN�next�append�EMPTYSTRING�join�
header_length�pop)r2r%Z
maxlengthsr&r=r>�encoderrZextra�linesZcurrent_line�maxlen�	characterZ	this_lineZlengthZ	separatorZjoined_linerrr�header_encode_lines,s6









zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtjj|�}tjj|�}||krPtjStjSndSdS)N)r/r.�email�
base64mimer8�
quoprimimerrF)r2r=Zlen64Zlenqprrrr;js


zCharset._get_encodercCs�|s|S|jtkr4t|t�r(|j|j�}tjj|�S|jt	krjt|t�rT|j|j�}|j
d�}tjj|�St|t�r�|j|j�j
d�}|SdS)N�latin1r)r0r.r(r)r$rrMrN�body_encoder8�decoderO)r2r%rrrrQys	





zCharset.body_encodeN)�__name__�
__module__�__qualname__�DEFAULT_CHARSETr3r4�__repr__r6r9r:r<rLr;rQrrrrr�s,!>)NNN)NNN)�__all__�	functoolsrZemail.base64mimerMZemail.quoprimimerZemail.encodersrr8r.rrArVr#rDrrr!rrrr'rrrrr�<module>s�
	
PKb��\��á�errors.cpython-36.opt-2.pycnu�[���3

���i��@s�Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	ee�ZGd
d�de�ZGdd
�d
e�ZGdd�de	�Z
Gdd�de
�ZGdd�de
�ZGdd�de
�Z
Gdd�de
�ZGdd�de
�ZGdd�de
�ZeZGdd�de
�ZGdd�de
�ZGd d!�d!e
�ZGd"d#�d#e
�ZGd$d%�d%e
�ZGd&d'�d'e
�ZGd(d)�d)e
�ZGd*d+�d+e�ZGd,d-�d-e�ZGd.d/�d/e�ZGd0d1�d1e�ZGd2d3�d3e�Zd4S)5c@seZdZdS)�MessageErrorN)�__name__�
__module__�__qualname__�rr�$/usr/lib64/python3.6/email/errors.pyrsrc@seZdZdS)�MessageParseErrorN)rrrrrrrrsrc@seZdZdS)�HeaderParseErrorN)rrrrrrrrsrc@seZdZdS)�
BoundaryErrorN)rrrrrrrr	sr	c@seZdZdS)�MultipartConversionErrorN)rrrrrrrr
sr
c@seZdZdS)�CharsetErrorN)rrrrrrrrsrc@seZdZdS)�HeaderWriteErrorN)rrrrrrrr srcseZdZd�fdd�	Z�ZS)�
MessageDefectNcs|dk	rt�j|�||_dS)N)�super�__init__�line)�selfr)�	__class__rrr(szMessageDefect.__init__)N)rrrr�
__classcell__rr)rrr
%sr
c@seZdZdS)�NoBoundaryInMultipartDefectN)rrrrrrrr-src@seZdZdS)�StartBoundaryNotFoundDefectN)rrrrrrrr0src@seZdZdS)�CloseBoundaryNotFoundDefectN)rrrrrrrr3src@seZdZdS)�#FirstHeaderLineIsContinuationDefectN)rrrrrrrr6src@seZdZdS)�MisplacedEnvelopeHeaderDefectN)rrrrrrrr9src@seZdZdS)� MissingHeaderBodySeparatorDefectN)rrrrrrrr<src@seZdZdS)�!MultipartInvariantViolationDefectN)rrrrrrrrAsrc@seZdZdS)�-InvalidMultipartContentTransferEncodingDefectN)rrrrrrrrDsrc@seZdZdS)�UndecodableBytesDefectN)rrrrrrrrGsrc@seZdZdS)�InvalidBase64PaddingDefectN)rrrrrrrrJsrc@seZdZdS)�InvalidBase64CharactersDefectN)rrrrrrrrMsrc@seZdZdS)�InvalidBase64LengthDefectN)rrrrrrrrPsrcseZdZ�fdd�Z�ZS)�HeaderDefectcst�j||�dS)N)rr)r�args�kw)rrrrXszHeaderDefect.__init__)rrrrrrr)rrr Usr c@seZdZdS)�InvalidHeaderDefectN)rrrrrrrr#[sr#c@seZdZdS)�HeaderMissingRequiredValueN)rrrrrrrr$^sr$cs$eZdZ�fdd�Zdd�Z�ZS)�NonPrintableDefectcst�j|�||_dS)N)rr�non_printables)rr&)rrrrdszNonPrintableDefect.__init__cCsdj|j�S)Nz6the following ASCII non-printables found in header: {})�formatr&)rrrr�__str__hszNonPrintableDefect.__str__)rrrrr(rrr)rrr%asr%c@seZdZdS)�ObsoleteHeaderDefectN)rrrrrrrr)lsr)c@seZdZdS)�NonASCIILocalPartDefectN)rrrrrrrr*osr*N)�	Exceptionrrrr	�	TypeErrorr
rr�
ValueErrorr
rrrrrrZMalformedHeaderDefectrrrrrrr r#r$r%r)r*rrrr�<module>s4PKb��\JO(X�,�,charset.cpython-36.opt-1.pycnu�[���3


 \�B�@srddddgZddlmZddlZddlZddlmZddlmZd	Z	d
Z
dZdZd
Z
dZdZe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfd*e
e
dfe
e
dfe
ddfe
ddfe
ddfe
e
dfee
dfd�Zdddddddddddddddddddddddd
d �Zd!d"dd#�Zd+d$d�Zd%d�Zd&d�Zd'd(�ZGd)d�d�ZdS),�Charset�	add_alias�add_charset�	add_codec�)�partialN)�errors)�encode_7or8bit����zus-asciizunknown-8bit�ziso-2022-jpzutf-8)z
iso-8859-1z
iso-8859-2z
iso-8859-3z
iso-8859-4z
iso-8859-9ziso-8859-10ziso-8859-13ziso-8859-14ziso-8859-15ziso-8859-16zwindows-1252Zvisciizus-ascii�big5�gb2312zeuc-jp�	shift_jisziso-2022-jpzkoi8-rzutf-8z
iso-8859-1z
iso-8859-2z
iso-8859-3z
iso-8859-4z
iso-8859-9ziso-8859-10ziso-8859-13ziso-8859-14ziso-8859-15ziso-8859-16zks_c_5601-1987zeuc-jpzeuc-kr)�latin_1zlatin-1Zlatin_2zlatin-2Zlatin_3zlatin-3Zlatin_4zlatin-4Zlatin_5zlatin-5Zlatin_6zlatin-6Zlatin_7zlatin-7Zlatin_8zlatin-8Zlatin_9zlatin-9Zlatin_10zlatin-10�cp949�euc_jp�euc_kr�ascii�eucgb2312_cn�big5_tw)rrzus-asciicCs"|tkrtd��|||ft|<dS)a>Add character set properties to the global registry.

    charset is the input character set, and must be the canonical name of a
    character set.

    Optional header_enc and body_enc is either Charset.QP for
    quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for
    the shortest of qp or base64 encoding, or None for no encoding.  SHORTEST
    is only valid for header_enc.  It describes how message headers and
    message bodies in the input charset are to be encoded.  Default is no
    encoding.

    Optional output_charset is the character set that the output should be
    in.  Conversions will proceed from input charset, to Unicode, to the
    output charset when the method Charset.convert() is called.  The default
    is to output in the same character set as the input.

    Both input_charset and output_charset must have Unicode codec entries in
    the module's charset-to-codec mapping; use add_codec(charset, codecname)
    to add codecs the module does not know about.  See the codecs module's
    documentation for more information.
    z!SHORTEST not allowed for body_encN)�SHORTEST�
ValueError�CHARSETS)�charsetZ
header_encZbody_enc�output_charset�r�%/usr/lib64/python3.6/email/charset.pyrmscCs|t|<dS)z�Add a character set alias.

    alias is the alias name, e.g. latin-1
    canonical is the character set's canonical name, e.g. iso-8859-1
    N)�ALIASES)�aliasZ	canonicalrrrr�scCs|t|<dS)a$Add a codec that map characters in the given charset to/from Unicode.

    charset is the canonical name of a character set.  codecname is the name
    of a Python codec, as appropriate for the second argument to the unicode()
    built-in, or to the encode() method of a Unicode string.
    N)�	CODEC_MAP)rZ	codecnamerrrr�scCs"|tkr|jdd�S|j|�SdS)Nr�surrogateescape)�UNKNOWN8BIT�encode)�string�codecrrr�_encode�sr'c@s`eZdZdZefdd�Zdd�ZeZdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)ra@	Map character sets to their email properties.

    This class provides information about the requirements imposed on email
    for a specific character set.  It also provides convenience routines for
    converting between character sets, given the availability of the
    applicable codecs.  Given a character set, it will do its best to provide
    information on how to use that character set in an email in an
    RFC-compliant way.

    Certain character sets must be encoded with quoted-printable or base64
    when used in email headers or bodies.  Certain character sets must be
    converted outright, and are not allowed in email.  Instances of this
    module expose the following information about a character set:

    input_charset: The initial character set specified.  Common aliases
                   are converted to their `official' email names (e.g. latin_1
                   is converted to iso-8859-1).  Defaults to 7-bit us-ascii.

    header_encoding: If the character set must be encoded before it can be
                     used in an email header, this attribute will be set to
                     Charset.QP (for quoted-printable), Charset.BASE64 (for
                     base64 encoding), or Charset.SHORTEST for the shortest of
                     QP or BASE64 encoding.  Otherwise, it will be None.

    body_encoding: Same as header_encoding, but describes the encoding for the
                   mail message's body, which indeed may be different than the
                   header encoding.  Charset.SHORTEST is not allowed for
                   body_encoding.

    output_charset: Some character sets must be converted before they can be
                    used in email headers or bodies.  If the input_charset is
                    one of them, this attribute will contain the name of the
                    charset output will be converted to.  Otherwise, it will
                    be None.

    input_codec: The name of the Python codec used to convert the
                 input_charset to Unicode.  If no conversion codec is
                 necessary, this attribute will be None.

    output_codec: The name of the Python codec used to convert Unicode
                  to the output_charset.  If no conversion codec is necessary,
                  this attribute will have the same value as the input_codec.
    c
Cs�y$t|t�r|jd�n
t|d�}Wntk
rBtj|��YnX|j�}tj||�|_	t
j|j	ttdf�\}}}|s~|j	}||_
||_tj||�|_tj|j	|j	�|_tj|j|j�|_dS)Nr)�
isinstance�strr$�UnicodeErrorrZCharsetError�lowerr�get�
input_charsetrr�BASE64�header_encoding�
body_encodingrr!Zinput_codec�output_codec)�selfr-ZhencZbencZconvrrr�__init__�s&

zCharset.__init__cCs
|jj�S)N)r-r+)r2rrr�__str__�szCharset.__str__cCst|�t|�j�kS)N)r)r+)r2�otherrrr�__eq__�szCharset.__eq__cCs$|jtkrdS|jtkrdStSdS)aPReturn the content-transfer-encoding used for body encoding.

        This is either the string `quoted-printable' or `base64' depending on
        the encoding used, or it is a function in which case you should call
        the function with a single argument, the Message object being
        encoded.  The function should then set the Content-Transfer-Encoding
        header itself to whatever is appropriate.

        Returns "quoted-printable" if self.body_encoding is QP.
        Returns "base64" if self.body_encoding is BASE64.
        Returns conversion function otherwise.
        zquoted-printable�base64N)r0�QPr.r)r2rrr�get_body_encoding�s


zCharset.get_body_encodingcCs|jp
|jS)z�Return the output character set.

        This is self.output_charset if that is not None, otherwise it is
        self.input_charset.
        )rr-)r2rrr�get_output_charsetszCharset.get_output_charsetcCs6|jpd}t||�}|j|�}|dkr*|S|j||�S)a�Header-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        this charset's `header_encoding`.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :return: The encoded string, with RFC 2047 chrome.
        zus-asciiN)r1r'�_get_encoder�
header_encode)r2r%r&�header_bytes�encoder_modulerrrr<s


zCharset.header_encodecCs|jpd}t||�}|j|�}t|j|d�}|j�}t|�t}g}	g}
t|�|}x�|D]�}|
j	|�t
j|
�}
|jt|
|��}||krZ|
j
�|	r�|
r�|	j	d�n.|	r�dnd}t
j|
�}t||�}|	j	||��|g}
t|�|}qZWt
j|
�}t||�}|	j	||��|	S)afHeader-encode a string by converting it first to bytes.

        This is similar to `header_encode()` except that the string is fit
        into maximum line lengths as given by the argument.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :param maxlengths: Maximum line length iterator.  Each element
            returned from this iterator will provide the next maximum line
            length.  This parameter is used as an argument to built-in next()
            and should never be exhausted.  The maximum line lengths should
            not count the RFC 2047 chrome.  These line lengths are only a
            hint; the splitter does the best it can.
        :return: Lines of encoded strings, each with RFC 2047 chrome.
        zus-ascii)rN� r
)r1r'r;rr<r:�len�RFC2047_CHROME_LEN�next�append�EMPTYSTRING�join�
header_length�pop)r2r%Z
maxlengthsr&r=r>�encoderrZextra�linesZcurrent_line�maxlen�	characterZ	this_lineZlengthZ	separatorZjoined_linerrr�header_encode_lines,s6









zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtjj|�}tjj|�}||krPtjStjSndSdS)N)r/r.�email�
base64mimer8�
quoprimimerrF)r2r=Zlen64Zlenqprrrr;js


zCharset._get_encodercCs�|s|S|jtkr4t|t�r(|j|j�}tjj|�S|jt	krjt|t�rT|j|j�}|j
d�}tjj|�St|t�r�|j|j�j
d�}|SdS)avBody-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        self.body_encoding.  If body_encoding is None, we assume the
        output charset is a 7bit encoding, so re-encoding the decoded
        string using the ascii codec produces the correct string version
        of the content.
        �latin1rN)r0r.r(r)r$rrMrN�body_encoder8�decoderO)r2r%rrrrQys	





zCharset.body_encodeN)�__name__�
__module__�__qualname__�__doc__�DEFAULT_CHARSETr3r4�__repr__r6r9r:r<rLr;rQrrrrr�s+!>)NNN)NNN)�__all__�	functoolsrZemail.base64mimerMZemail.quoprimimerZemail.encodersrr8r.rrArWr#rDrrr!rrrr'rrrrr�<module>s�
	
PKb��\p`a�{"{"feedparser.cpython-36.opt-2.pycnu�[���3


 \�X�@s�ddgZddlZddlmZddlmZddlmZddlm	Z	ej
d�Zej
d	�Zej
d
�Z
ej
d	�Zej
d�ZdZd
Ze�ZGdd�de�ZGdd�d�ZGdd�de�ZdS)�
FeedParser�BytesFeedParser�N)�errors)�compat32)�deque)�StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])��
c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�BufferedSubFilecCs$tdd�|_t�|_g|_d|_dS)Nr)�newlineF)r�_partialr�_lines�	_eofstack�_closed)�self�r�(/usr/lib64/python3.6/email/feedparser.py�__init__5szBufferedSubFile.__init__cCs|jj|�dS)N)r�append)rZpredrrr�push_eof_matcher@sz BufferedSubFile.push_eof_matchercCs
|jj�S)N)r�pop)rrrr�pop_eof_matcherCszBufferedSubFile.pop_eof_matchercCs<|jjd�|j|jj��|jjd�|jj�d|_dS)NrT)r�seek�	pushlines�	readlines�truncater)rrrr�closeFs

zBufferedSubFile.closecCsN|js|jrdStS|jj�}x*t|j�D]}||�r*|jj|�dSq*W|S)Nr)r
r�NeedMoreData�popleft�reversedr�
appendleft)r�lineZateofrrr�readlineNs
zBufferedSubFile.readlinecCs|jj|�dS)N)r
r )rr!rrr�
unreadline`szBufferedSubFile.unreadlinecCsx|jj|�d|kr d|kr dS|jjd�|jj�}|jjd�|jj�|djd�sj|jj|j��|j|�dS)Nr	�
r����)r�writerrr�endswithrr)r�data�partsrrr�pushes

zBufferedSubFile.pushcCs|jj|�dS)N)r
�extend)r�linesrrrrzszBufferedSubFile.pushlinescCs|S)Nr)rrrr�__iter__}szBufferedSubFile.__iter__cCs|j�}|dkrt�|S)Nr)r"�
StopIteration)rr!rrr�__next__�szBufferedSubFile.__next__N)
�__name__�
__module__�__qualname__rrrrr"r#r+rr.r0rrrrr
-sr
c@s\eZdZded�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)rN)�policycCs�||_d|_|dkr<|jdkr2ddlm}||_qn|j|_n2||_y||jd�Wntk
rld|_YnXt�|_g|_	|j
�j|_d|_
d|_d|_dS)NFr)�Message)r4T)r4�_old_style_factoryZmessage_factoryZ
email.messager5�_factory�	TypeErrorr
�_input�	_msgstack�	_parsegenr0�_parse�_cur�_last�_headersonly)rr7r4r5rrrr�s$

zFeedParser.__init__cCs
d|_dS)NT)r?)rrrr�_set_headersonly�szFeedParser._set_headersonlycCs|jj|�|j�dS)N)r9r+�_call_parse)rr)rrr�feed�szFeedParser.feedcCs&y|j�Wntk
r YnXdS)N)r<r/)rrrrrA�szFeedParser._call_parsecCsJ|jj�|j�|j�}|j�dkrF|j�rFtj�}|jj	||�|S)N�	multipart)
r9rrA�_pop_message�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr4�
handle_defect)r�root�defectrrrr�s

zFeedParser.closecCsn|jr|j�}n|j|jd�}|jr<|jj�dkr<|jd�|jrR|jdj|�|jj|�||_||_	dS)N)r4zmultipart/digestzmessage/rfc822r%r&)
r6r7r4r=�get_content_typeZset_default_typer:Zattachrr>)r�msgrrr�_new_message�s

zFeedParser._new_messagecCs(|jj�}|jr|jd|_nd|_|S)Nr%r&)r:rr=)r�retvalrrrrD�s

zFeedParser._pop_messageccs6|j�g}xb|jD]X}|tkr(tVqtj|�sbtj|�s`tj�}|jj	|j
|�|jj|�P|j|�qW|j
|�|jr�g}x2|jj�}|tkr�tVq�|dkr�P|j|�q�W|j
jtj|��dS|j
j�dk�r�x�|jjtj�x$|j�D]}|tk�rtVq�Pq�W|j�}|jj�x&|jj�}|tk�rFtV�q(P�q(Wx&|jj�}|tk�rntV�qPP�qPW|dk�r�P|jj|�q�WdS|j
j�dk�r�x(|j�D]}|tk�r�tV�q�P�q�W|j�dS|j
j�dk�r�|j
j�}|dk�rbtj�}|jj	|j
|�g}x.|jD]$}|tk�r<tV�q$|j|��q$W|j
jtj|��dS|j
jdd�j�dk�r�tj�}|jj	|j
|�d	|}tjd
tj |�d�}	d}
g}d
}d
}
�x|jj�}|tk�r�tV�q�|dk�r�P|	j|�}|�r�|j!d��rd}
|j!d�}P|
�r~|�rj|d}t"j#|�}|�r\|dt$|j!d���|d<tj|�|j
_%d
}
|jj|��q�xB|jj�}|tk�r�tV�q�|	j|�}|�s�|jj|�P�q�W|jj|	j�x(|j�D]}|tk�r�tV�q�P�q�W|j&j�dk�rb|j&j'}|dk�r&d|j&_'n:|dk	�r�t"j#|�}|�r�t$|j!d��}|d|�|j&_'nD|j&j(}t)|t*��r�t"j#|�}|�r�|dt$|j!d���}||j&_(|jj�|j�|j
|_&n
|j|��q�W|
�r>tj+�}|jj	|j
|�|j
jtj|��g}x$|jD]}|tk�rtV�q�qWtj|�|j
_'dS|
�s`tj,�}|jj	|j
|�dS|�rndg}ng}x.|jD]$}|tk�r�tV�qz|j|��qzW|�r�|d}t-j|�}|�r�|t$|j!d��d�|d<tj|�|j
_'dSg}x.|jD]$}|tk�rtV�q�|j|��q�W|j
jtj|��dS)Nrzmessage/delivery-status�messagerCzcontent-transfer-encoding�8bit�7bit�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr%r)rOrNrPr&r&).rKr9r�headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr4rFr=r#r�_parse_headersr?r"Zset_payload�EMPTYSTRING�joinrIrr;rDrrEZget_boundaryZNoBoundaryInMultipartDefect�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�search�len�preambler>�epilogueZ_payload�
isinstance�strZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr!rHr-rLrJ�boundaryZ	separatorZ
boundaryreZcapturing_preamblerbrRZclose_boundary_seen�moZlastlineZeolmorcrQZpayload�	firstlineZbolmorrrr;�sf




































zFeedParser._parsegenc	Cs^d}g}�x4t|�D�]&\}}|ddkrV|sJtj|�}|jj|j|�q|j|�q|rx|jj|jj|��dg}}|j	d��r�|dkr�t
j|�}|r�|dt|j
d���}|jj|�qn:|t|�dkr�|jj|�dStj|�}|jjj|�q|jd�}|dk�r*tjd�}|jjj|�q|d|�}|g}qW|�rZ|jj|jj|��dS)Nrrz 	zFrom r%�:zMissing header name.)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr4rFr=rZset_rawZheader_source_parse�
startswithr_r`rar^Zset_unixfromr9r#ZMisplacedEnvelopeHeaderDefectZdefects�findZInvalidHeaderDefect)	rr-Z
lastheaderZ	lastvalue�linenor!rHrh�irrrrV�sF








zFeedParser._parse_headers)N)
r1r2r3rrr@rBrArrKrDr;rVrrrrr�s

~cseZdZ�fdd�Z�ZS)rcst�j|jdd��dS)N�ascii�surrogateescape)�superrB�decode)rr))�	__class__rrrBszBytesFeedParser.feed)r1r2r3rB�
__classcell__rr)rtrrs)�__all__r[ZemailrZemail._policybaser�collectionsr�iorr\rUrfr_ZNLCRE_crackrSrW�NL�objectrr
rrrrrr�<module>s&




[PKb��\E��=quoprimime.cpython-36.pycnu�[���3


 \�&�
@sddZddddddddd	d
g
ZddlZdd
lmZmZmZdZdZdZ	dd�e
d�D�Zedd�Zedd�Z
x,dejd�ejd�D]Zee�ee<q�Wdeed�<xdD]Zee�e
e<q�Wdd�Zdd�Zdd�Zdd�Zd,dd �Zd!d
�Zd"d	�Zd-d$d�Ze
dd�Zxd%D]Zee�ee<�qWd&efd'd�Zefd(d�ZeZeZd)d*�Zd+d�Z dS).aFQuoted-printable content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode US ASCII-like 8-bit data called `quoted-printable'.  It is used to
safely encode text that is in a character set similar to the 7-bit US ASCII
character set, but that includes some 8-bit characters that are normally not
allowed in email bodies or headers.

Quoted-printable is very space-inefficient for encoding binary files; use the
email.base64mime module for that instead.

This module provides an interface to encode and decode both headers and bodies
with quoted-printable encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:/From:/Cc: etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character
conversion necessary for proper internationalized headers; it only
does dumb encoding and decoding.  To deal with the various line
wrapping issues, use the email.header module.
�body_decode�body_encode�body_length�decode�decodestring�
header_decode�
header_encode�
header_length�quote�unquote�N)�
ascii_letters�digits�	hexdigitsz
�
�cCsg|]}d|�qS)z=%02X�)�.0�crr�(/usr/lib64/python3.6/email/quoprimime.py�
<listcomp>7sr�s-!*+/�ascii�_� s_ !"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~	cCst|�t|kS)z>Return True if the octet should be escaped with header quopri.)�chr�_QUOPRI_HEADER_MAP)�octetrrr�header_checkJsrcCst|�t|kS)z<Return True if the octet should be escaped with body quopri.)r�_QUOPRI_BODY_MAP)rrrr�
body_checkOsrcCstdd�|D��S)a:Return a header quoted-printable encoding length.

    Note that this does not include any RFC 2047 chrome added by
    `header_encode()`.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for headers.
    css|]}tt|�VqdS)N)�lenr)rrrrr�	<genexpr>^sz header_length.<locals>.<genexpr>)�sum)�	bytearrayrrrrTs
cCstdd�|D��S)z�Return a body quoted-printable encoding length.

    :param bytearray: An array of bytes (a.k.a. octets).
    :return: The length in bytes of the byte array when it is encoded with
        quoted-printable for bodies.
    css|]}tt|�VqdS)N)r r)rrrrrr!hszbody_length.<locals>.<genexpr>)r")r#rrrrascCsft|t�st|�}|s&|j|j��n<t|d�t|�|krT|d||7<n|j|j��dS)N����r%)�
isinstance�strr�append�lstripr )�L�s�maxlenZextrarrr�_max_appendks
r-cCstt|dd�d��S)zDTurn a string in the form =AB to the ASCII character with value 0xabr$��)r�int)r+rrrr
vscCstt|�S)N)�_QUOPRI_MAP�ord)rrrrr	{s�
iso-8859-1cCs$|sdS|jd�jt�}d||fS)a�Encode a single header line with quoted-printable (like) encoding.

    Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but
    used specifically for email header fields to allow charsets with mostly 7
    bit characters (and some 8 bit) to remain more or less readable in non-RFC
    2045 aware mail clients.

    charset names the character set to use in the RFC 2046 header.  It
    defaults to iso-8859-1.
    r�latin1z=?%s?q?%s?=)r�	translater)Zheader_bytes�charset�encodedrrrrss
�Lc
Cs�|dkrtd��|s|S|jt�}d|}|d}g}|j}�x,|j�D�]}d}t|�d|}	x�||	kr�||}
||
ddkr�||||
d��|
d}qd||
ddkr�||||
��|
d}qd||||
�d�|
}qdW|o�|ddk�rX||	}|dk�rt|d�}n(|dk�r2|d
|}n|t|d�}|||d�|�qH|||d	��qHW|dtk�r�|d
�|j|�S)a�Encode with quoted-printable, wrapping at maxlinelen characters.

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.

    Each line will be wrapped at, at most, maxlinelen characters before the
    eol string (maxlinelen defaults to 76 characters, the maximum value
    permitted by RFC 2045).  Long lines will have the 'soft line break'
    quoted-printable character "=" appended to them, so the decoded text will
    be identical to the original text.

    The minimum maxlinelen is 4 to have room for a quoted character ("=XX")
    followed by a soft line break.  Smaller values will generate a
    ValueError.

    �zmaxlinelen must be at least 4�=r$r�z 	r.Nrr%r%r%r%r%r%)	�
ValueErrorr5�_QUOPRI_BODY_ENCODE_MAPr(�
splitlinesr r	�CRLF�join)
ZbodyZ
maxlinelen�eolZ
soft_breakZmaxlinelen1Zencoded_bodyr(�line�startZ	laststart�stopZroom�qrrrr�sD





cCs |s|Sd}x�|j�D]�}|j�}|s0||7}qd}t|�}x�||kr�||}|dkrh||7}|d7}nv|d|kr�|d7}q>n^|d|kr�||dtkr�||dtkr�|t|||d��7}|d7}n||7}|d7}||kr>||7}q>WqW|d	dk�r|j|��r|dd
�}|S)z_Decode a quoted-printable string.

    Lines are separated with eol, which defaults to \n.
    rrr:r$r;r.z
Nr%r%)r>�rstripr rr
�endswith)r7rAZdecodedrB�i�nrrrrr�s8

,
cCs|jd�}t|�S)zCTurn a match in the form =AB to the ASCII character with value 0xabr)�groupr
)�matchr+rrr�_unquote_matchs
rLcCs |jdd�}tjdt|tjd�S)aDecode a string encoded with RFC 2045 MIME header `Q' encoding.

    This function does not parse a full MIME header value encoded with
    quoted-printable (like =?iso-8859-1?q?Hello_World?=) -- please use
    the high level email.header class for that functionality.
    rrz=[a-fA-F0-9]{2})�flags)�replace�re�subrL�ASCII)r+rrrr#s)r)r3)!�__doc__�__all__rO�stringrr
rr?�NLZEMPTYSTRING�ranger1rr�encoderrr2rrrrr-r
r	rr=rrrrrLrrrrr�<module>sP





O0PKb��\��-K�0�0_parseaddr.cpython-36.opt-1.pycnu�[���3

���i�D�@s�dZddddgZddlZddlZdZdZd	Zd
ddd
dddddddddddddddddddd gZd!d"d#d$d%d&d'gZddddd9d:d;d<d=d>d?d@dAdBd.�Z	d/d�Z
d0d1�Zd2d�Zd3d�Z
d4d�ZGd5d6�d6�ZGd7d8�d8e�ZdS)CzcEmail address parsing code.

Lifted directly from rfc822.py.  This should eventually be rewritten.
�	mktime_tz�	parsedate�parsedate_tz�quote�N� �z, ZjanZfebZmarZaprZmayZjunZjulZaug�sep�octZnovZdecZjanuaryZfebruaryZmarchZaprilZjuneZjulyZaugustZ	septemberZoctoberZnovemberZdecemberZmonZtueZwedZthuZfriZsatZsuni�i,i�iXi�i )ZUTZUTCZGMT�ZZASTZADTZESTZEDTZCSTZCDTZMSTZMDTZPSTZPDTcCs,t|�}|sdS|ddkr$d|d<t|�S)zQConvert a date string to a time tuple.

    Accounts for military timezones.
    N�	r)�
_parsedate_tz�tuple)�data�res�r�(/usr/lib64/python3.6/email/_parseaddr.pyr-scCs�|sdS|j�}|djd�s.|dj�tkr6|d=n.|djd�}|dkrd|d|dd�|d<t|�dkr�|djd�}t|�dkr�||dd�}t|�dk�r|d}|jd�}|dkr�|jd�}|dkr�|d|�||d�g|dd�<n
|jd	�t|�d
k�rdS|dd
�}|\}}}}}|j�}|tk�rZ||j�}}|tk�rZdStj	|�d}|dk�rz|d8}|ddk�r�|dd�}|jd�}|dk�r�||}}|ddk�r�|dd�}|dj
��s�||}}|ddk�r�|dd�}|jd�}t|�d
k�r$|\}	}
d}n~t|�dk�r>|\}	}
}ndt|�dk�r�d|dk�r�|djd�}t|�d
k�r�|\}	}
d}nt|�dk�r�|\}	}
}ndSy,t|�}t|�}t|	�}	t|
�}
t|�}Wntk
�r�dSX|dk�r|dk�r|d7}n|d7}d}|j
�}|tk�r,t|}n>yt|�}Wntk
�rNYnX|dk�rj|jd��rjd}|�r�|dk�r�d}
|}nd}
|
|dd|dd}||||	|
|ddd|g
S)a�Convert date to extended time tuple.

    The last (additional) element is the time zone offset in seconds, except if
    the timezone was specified as -0000.  In that case the last element is
    None.  This indicates a UTC timestamp that explicitly declaims knowledge of
    the source timezone, as opposed to a +0000 timestamp that indicates the
    source timezone really was UTC.

    Nr�,���-��+r���:��0�.�d�Dili�i�<���r!r!r!r!r!r!r!r!)�split�endswith�lower�	_daynames�rfind�len�find�append�_monthnames�index�isdigit�int�
ValueError�upper�
_timezones�
startswith)r�iZstuff�sZddZmmZyyZtmZtzZthhZtmmZtssZtzoffsetZtzsignrrrr9s�


"














rcCs&t|�}t|t�r|dd�S|SdS)z&Convert a time string to a time tuple.Nr)r�
isinstancer
)r�trrrr�s
cCs<|ddkr"tj|dd�d�Stj|�}||dSdS)zETurn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.rN�rr!)r!)�timeZmktime�calendarZtimegm)rr5rrrr�s
cCs|jdd�jdd�S)z�Prepare string to be used in a quoted string.

    Turns backslash and double quote characters into quoted pairs.  These
    are the only characters that need to be quoted inside a quoted string.
    Does not add the surrounding double quotes.
    �\z\\�"z\")�replace)�strrrrr�sc@s|eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zddd�Zdd�ZdS) �
AddrlistClassaAddress parser class by Ben Escoto.

    To understand what this class does, it helps to have a copy of RFC 2822 in
    front of you.

    Note: this class interface is deprecated and may be removed in the future.
    Use email.utils.AddressList instead.
    cCsZd|_d|_d|_d|_|j|j|_|j|j|j|_|jjdd�|_||_g|_	dS)z�Initialize a new instance.

        `field' is an unparsed address header field, containing
        one or more addresses.
        z()<>@,:;."[]rz 	z
rrN)
�specials�pos�LWSZCR�FWS�atomendsr;�
phraseends�field�commentlist)�selfrDrrr�__init__�szAddrlistClass.__init__cCs�g}x�|jt|j�kr�|j|j|jdkr^|j|jdkrN|j|j|j�|jd7_q|j|jdkr�|jj|j��qPqWtj|�S)z&Skip white space and extract comments.z

r�()	r?r'rDr@r)rE�
getcomment�EMPTYSTRING�join)rFZwslistrrr�gotonext�szAddrlistClass.gotonextcCs>g}x4|jt|j�kr8|j�}|r,||7}q|jd�qW|S)zVParse all addresses.

        Returns a list containing all of the addresses.
        r)rr)r?r'rD�
getaddressr))rF�resultZadrrr�getaddrlist�s
zAddrlistClass.getaddrlistcCs�g|_|j�|j}|j}|j�}|j�g}|jt|j�kr\|rXtj|j�|dfg}�n\|j|jdkr�||_||_|j�}tj|j�|fg}�n"|j|jdk�rg}t|j�}|jd7_x�|jt|j�k�r|j�|j|ko�|j|jdk�r|jd7_P||j	�}q�Wn�|j|jdk�rx|j
�}|j�rftj|�ddj|j�d	|fg}ntj|�|fg}n@|�r�tj|j�|dfg}n"|j|j|jk�r�|jd7_|j�|jt|j�k�r�|j|jd
k�r�|jd7_|S)zParse the next address.rz.@rr�;�<z (r�)r)rErLr?�
getphraselistr'rD�SPACErK�getaddrspecrM�getrouteaddrr>)rFZoldposZoldcl�plistZ
returnlistZaddrspecZfieldlenZ	routeaddrrrrrMsL
&$zAddrlistClass.getaddresscCs�|j|jdkrdSd}|jd7_|j�d}x�|jt|j�kr�|rV|j�d}n~|j|jdkrx|jd7_Pn\|j|jdkr�|jd7_d}n8|j|jd	kr�|jd7_n|j�}|jd7_P|j�q4W|S)
z�Parse a route address (Return-path value).

        This method just skips all the route stuff and returns the addrspec.
        rQNFrr�>�@Tr)rDr?rLr'�	getdomainrU)rFZexpectrouteZadlistrrrrV?s.zAddrlistClass.getrouteaddrcCs\g}|j�x�|jt|j�kr�d}|j|jdkrj|rL|dj�rL|j�|jd�|jd7_d}nf|j|jdkr�|jdt|j���n>|j|j|j	kr�|r�|d	j�r�|j�Pn|j|j
��|j�}|r|r|j|�qW|jt|j�k�s|j|jdk�rtj|�S|jd�|jd7_|j�|j
�}|�sNtStj|�|S)
zParse an RFC 2822 addr-spec.TrrFr:z"%s"rYr!r!)rLr?r'rD�strip�popr)r�getquoterB�getatomrJrKrZ)rFZaslistZpreserve_wsZwsZdomainrrrrU_s:
$

zAddrlistClass.getaddrspeccCs�g}x�|jt|j�kr�|j|j|jkr8|jd7_q|j|jdkrZ|jj|j��q|j|jdkrz|j|j��q|j|jdkr�|jd7_|jd�q|j|jdkr�tS|j|j|j	kr�Pq|j|j
��qWtj|�S)z-Get the complete domain name from an address.rrH�[rrY)r?r'rDr@rEr)rI�getdomainliteralrJrBr^rK)rFZsdlistrrrrZ�s"zAddrlistClass.getdomainTcCs�|j|j|krdSdg}d}|jd7_x�|jt|j�kr�|rZ|j|j|j�d}np|j|j|kr||jd7_PnN|r�|j|jdkr�|j|j��q.n(|j|jdkr�d}n|j|j|j�|jd7_q.Wtj|�S)a�Parse a header fragment delimited by special characters.

        `beginchar' is the start character for the fragment.
        If self is not looking at an instance of `beginchar' then
        getdelimited returns the empty string.

        `endchars' is a sequence of allowable end-delimiting characters.
        Parsing stops when one of these is encountered.

        If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed
        within the parsed fragment.
        rFrrHr9T)rDr?r'r)rIrJrK)rFZ	begincharZendcharsZ
allowcommentsZslistrrrr�getdelimited�s(
zAddrlistClass.getdelimitedcCs|jddd�S)z1Get a quote-delimited fragment from self's field.r:z"
F)ra)rFrrrr]�szAddrlistClass.getquotecCs|jddd�S)z7Get a parenthesis-delimited fragment from self's field.rHz)
T)ra)rFrrrrI�szAddrlistClass.getcommentcCsd|jddd�S)z!Parse an RFC 2822 domain-literal.z[%s]r_z]
F)ra)rFrrrr`�szAddrlistClass.getdomainliteralNcCshdg}|dkr|j}xH|jt|j�kr\|j|j|kr:Pn|j|j|j�|jd7_qWtj|�S)aParse an RFC 2822 atom.

        Optional atomends specifies a different set of end token delimiters
        (the default is to use self.atomends).  This is used e.g. in
        getphraselist() since phrase endings must not include the `.' (which
        is legal in phrases).rNr)rBr?r'rDr)rJrK)rFrBZatomlistrrrr^�szAddrlistClass.getatomcCs�g}x�|jt|j�kr�|j|j|jkr8|jd7_q|j|jdkrX|j|j��q|j|jdkrz|jj|j��q|j|j|jkr�Pq|j|j	|j��qW|S)z�Parse a sequence of RFC 2822 phrases.

        A phrase is a sequence of words, which are in turn either RFC 2822
        atoms or quoted-strings.  Phrases are canonicalized by squeezing all
        runs of continuous whitespace into one space.
        rr:rH)
r?r'rDrAr)r]rErIrCr^)rFrWrrrrS�szAddrlistClass.getphraselist)T)N)�__name__�
__module__�__qualname__�__doc__rGrLrOrMrVrUrZrar]rIr`r^rSrrrrr=�s; &
%
r=c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�AddressListz@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs&tj||�|r|j�|_ng|_dS)N)r=rGrO�addresslist)rFrDrrrrG�szAddressList.__init__cCs
t|j�S)N)r'rg)rFrrr�__len__szAddressList.__len__cCsBtd�}|jdd�|_x$|jD]}||jkr |jj|�q W|S)N)rfrgr))rF�other�newaddr�xrrr�__add__s
zAddressList.__add__cCs*x$|jD]}||jkr|jj|�qW|S)N)rgr))rFrirkrrr�__iadd__
s
zAddressList.__iadd__cCs2td�}x$|jD]}||jkr|jj|�qW|S)N)rfrgr))rFrirjrkrrr�__sub__s

zAddressList.__sub__cCs*x$|jD]}||jkr|jj|�qW|S)N)rg�remove)rFrirkrrr�__isub__s
zAddressList.__isub__cCs
|j|S)N)rg)rFr+rrr�__getitem__#szAddressList.__getitem__N)rbrcrdrerGrhrlrmrnrprqrrrrrf�s	rfip���i���i���ip���i����i���iD���i����i��iD���)re�__all__r7r8rTrJZ
COMMASPACEr*r%r0rrrrrr=rfrrrr�<module>s8

u	

/PKb��\Ol�����)_header_value_parser.cpython-36.opt-2.pycnu�[���3

���i���@svddlZddlZddlmZddlmZddlmZddlm	Z
ddlmZddlmZe
d�Zee
d	�BZe
d
�ZeeBZee
d�Zee
d�Zee
d
�Be
d�ZeeBZee
d�BZeeBZee
d�ZddhZeeBZdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gd d!�d!e�Z#Gd"d#�d#e�Z$Gd$d%�d%e�Z%Gd&d'�d'e�Z&Gd(d)�d)e&�Z'Gd*d+�d+e�Z(Gd,d-�d-e�Z)Gd.d/�d/e�Z*Gd0d1�d1e�Z+Gd2d3�d3e�Z,Gd4d5�d5e�Z-Gd6d7�d7e�Z.Gd8d9�d9e�Z/Gd:d;�d;e�Z0Gd<d=�d=e�Z1Gd>d?�d?e�Z2Gd@dA�dAe�Z3GdBdC�dCe�Z4GdDdE�dEe�Z5GdFdG�dGe�Z6GdHdI�dIe�Z7GdJdK�dKe �Z8GdLdM�dMe�Z9GdNdO�dOe�Z:GdPdQ�dQe�Z;GdRdS�dSe�Z<GdTdU�dUe<�Z=GdVdW�dWe�Z>GdXdY�dYe�Z?GdZd[�d[e�Z@Gd\d]�d]e�ZAGd^d_�d_e�ZBGd`da�daeB�ZCGdbdc�dceB�ZDGddde�dee�ZEGdfdg�dge�ZFGdhdi�die�ZGGdjdk�dkeH�ZIGdldm�dmeI�ZJGdndo�doeI�ZKGdpdq�dqeJ�ZLeKddr�ZMeKdsdt�ZNeKdudv�ZOejPdwjQdxjRe���jSZTejPdyjQdxjRe�jUdzd{�jUd|d}���jVZWejPd~�jXZYejPdyjQdxjRe�jUdzd{�jUd|d}���jVZZejPdyjQdxjRe�jUdzd{�jUd|d}���jVZ[ejPdyjQdxjRe�jUdzd{�jUd|d}���jVZ\dd��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d„Z~d�dĄZd�dƄZ�d�dȄZ�d�dʄZ�d�d̄Z�d�d΄Z�d�dЄZ�d�d҄Z�d�dԄZ�d�dքZ�d�d؄Z�d�dڄZ�d�d܄Z�d�dބZ�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�dS)��N)�	hexdigits)�OrderedDict)�
itemgetter)�_encoded_words)�errors)�utilsz 	�(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%�
�
cCs dt|�jdd�jdd�dS)N�"�\z\\z\")�str�replace)�value�r�2/usr/lib64/python3.6/email/_header_value_parser.py�quote_stringbsrcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd�Ze	d	d
��Z
e	dd��Zd
d�Ze	dd��Z
e	dd��Zdd�Zddd�Zddd�Zddd�Z�ZS)�	TokenListNTcst�j||�g|_dS)N)�super�__init__�defects)�self�args�kw)�	__class__rrroszTokenList.__init__cCsdjdd�|D��S)N�css|]}t|�VqdS)N)r)�.0�xrrr�	<genexpr>tsz$TokenList.__str__.<locals>.<genexpr>)�join)rrrr�__str__sszTokenList.__str__csdj|jjt�j��S)Nz{}({}))�formatr�__name__r�__repr__)r)rrrr%vs
zTokenList.__repr__cCsdjdd�|D��S)Nrcss|]}|jr|jVqdS)N)r)rrrrrr |sz"TokenList.value.<locals>.<genexpr>)r!)rrrrrzszTokenList.valuecCstdd�|D�|j�S)Ncss|]}|jVqdS)N)�all_defects)rrrrrr �sz(TokenList.all_defects.<locals>.<genexpr>)�sumr)rrrrr&~szTokenList.all_defectscCs|dj�S)Nr)�startswith_fws)rrrrr(�szTokenList.startswith_fwscCstdd�|D��S)Ncss|]}|jVqdS)N)�
as_ew_allowed)r�partrrrr �sz*TokenList.as_ew_allowed.<locals>.<genexpr>)�all)rrrrr)�szTokenList.as_ew_allowedcCs"g}x|D]}|j|j�q
W|S)N)�extend�comments)rr-�tokenrrrr-�s
zTokenList.commentscCst||d�S)N)�policy)�_refold_parse_tree)rr/rrr�fold�szTokenList.foldrcCst|j|d��dS)N)�indent)�print�ppstr)rr2rrr�pprint�szTokenList.pprintcCsdj|j|d��S)Nr)r2)r!�_pp)rr2rrrr4�szTokenList.ppstrccs~dj||jj|j�Vx<|D]4}t|d�s<|dj|�Vq|j|d�EdHqW|jrhdj|j�}nd}dj||�VdS)Nz{}{}/{}(r6z*    !! invalid element in token list: {!r}z    z Defects: {}rz{}){})r#rr$�
token_type�hasattrr6r)rr2r.Zextrarrrr6�s


z
TokenList._pp)r)r)r)r$�
__module__�__qualname__r7�syntactic_break�ew_combine_allowedrr"r%�propertyrr&r(r)r-r1r5r4r6�
__classcell__rr)rrris

rc@s$eZdZedd��Zedd��ZdS)�WhiteSpaceTokenListcCsdS)N� r)rrrrr�szWhiteSpaceTokenList.valuecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)�comment)r7�content)rrrrr�
<listcomp>�sz0WhiteSpaceTokenList.comments.<locals>.<listcomp>r)rrrrr-�szWhiteSpaceTokenList.commentsN)r$r9r:r=rr-rrrrr?�sr?c@seZdZdZdS)�UnstructuredTokenList�unstructuredN)r$r9r:r7rrrrrD�srDc@seZdZdZdS)�Phrase�phraseN)r$r9r:r7rrrrrF�srFc@seZdZdZdS)�WordZwordN)r$r9r:r7rrrrrH�srHc@seZdZdZdS)�CFWSList�cfwsN)r$r9r:r7rrrrrI�srIc@seZdZdZdS)�Atom�atomN)r$r9r:r7rrrrrK�srKc@seZdZdZdZdS)�Tokenr.FN)r$r9r:r7Zencode_as_ewrrrrrM�srMc@seZdZdZdZdZdZdS)�EncodedWordzencoded-wordN)r$r9r:r7�cte�charset�langrrrrrN�srNc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�QuotedStringz
quoted-stringcCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rrrrrrB�s

zQuotedString.contentcCsBg}x2|D]*}|jdkr(|jt|��q
|j|j�q
Wdj|�S)Nzbare-quoted-stringr)r7�appendrrr!)r�resrrrr�quoted_value�s

zQuotedString.quoted_valuecCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rr.rrr�stripped_value�s

zQuotedString.stripped_valueN)r$r9r:r7r=rBrUrVrrrrrR�s
rRc@s$eZdZdZdd�Zedd��ZdS)�BareQuotedStringzbare-quoted-stringcCstdjdd�|D���S)Nrcss|]}t|�VqdS)N)r)rrrrrr �sz+BareQuotedString.__str__.<locals>.<genexpr>)rr!)rrrrr"�szBareQuotedString.__str__cCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz)BareQuotedString.value.<locals>.<genexpr>)r!)rrrrr�szBareQuotedString.valueN)r$r9r:r7r"r=rrrrrrW�srWc@s8eZdZdZdd�Zdd�Zedd��Zedd	��Zd
S)�CommentrAcs(djtdg�fdd��D�dggg��S)Nrrcsg|]}�j|��qSr)�quote)rr)rrrrCsz#Comment.__str__.<locals>.<listcomp>�))r!r')rr)rrr"s
zComment.__str__cCs2|jdkrt|�St|�jdd�jdd�jdd�S)NrArz\\rz\(rZz\))r7rr)rrrrrrYs

z
Comment.quotecCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz"Comment.content.<locals>.<genexpr>)r!)rrrrrBszComment.contentcCs|jgS)N)rB)rrrrr-szComment.commentsN)	r$r9r:r7r"rYr=rBr-rrrrrXs
rXc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressListzaddress-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)�address)r7)rrrrrrC$sz)AddressList.addresses.<locals>.<listcomp>r)rrrr�	addresses"szAddressList.addressescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�	mailboxes)rrrrrr (sz(AddressList.mailboxes.<locals>.<genexpr>)r')rrrrr^&szAddressList.mailboxescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�
all_mailboxes)rrrrrr -sz,AddressList.all_mailboxes.<locals>.<genexpr>)r')rrrrr_+szAddressList.all_mailboxesN)r$r9r:r7r=r]r^r_rrrrr[sr[c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�Addressr\cCs|djdkr|djSdS)Nr�group)r7�display_name)rrrrrb5szAddress.display_namecCs4|djdkr|dgS|djdkr*gS|djS)Nr�mailboxzinvalid-mailbox)r7r^)rrrrr^:s

zAddress.mailboxescCs:|djdkr|dgS|djdkr0|dgS|djS)Nrrczinvalid-mailbox)r7r_)rrrrr_Bs


zAddress.all_mailboxesN)r$r9r:r7r=rbr^r_rrrrr`1sr`c@s(eZdZdZedd��Zedd��ZdS)�MailboxListzmailbox-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc)r7)rrrrrrCPsz)MailboxList.mailboxes.<locals>.<listcomp>r)rrrrr^NszMailboxList.mailboxescCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc�invalid-mailbox)rcre)r7)rrrrrrCTsz-MailboxList.all_mailboxes.<locals>.<listcomp>r)rrrrr_RszMailboxList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrdJsrdc@s(eZdZdZedd��Zedd��ZdS)�	GroupListz
group-listcCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r^)rrrrr^\szGroupList.mailboxescCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r_)rrrrr_bszGroupList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrfXsrfc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�GroupracCs|djdkrgS|djS)N�z
group-list)r7r^)rrrrr^mszGroup.mailboxescCs|djdkrgS|djS)Nrhz
group-list)r7r_)rrrrr_sszGroup.all_mailboxescCs
|djS)Nr)rb)rrrrrbyszGroup.display_nameN)r$r9r:r7r=r^r_rbrrrrrgisrgc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�NameAddrz	name-addrcCst|�dkrdS|djS)N�r)�lenrb)rrrrrb�szNameAddr.display_namecCs
|djS)Nrj���)�
local_part)rrrrrm�szNameAddr.local_partcCs
|djS)Nrjrl)�domain)rrrrrn�szNameAddr.domaincCs
|djS)Nrjrl)�route)rrrrro�szNameAddr.routecCs
|djS)Nrjrl)�	addr_spec)rrrrrp�szNameAddr.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrri~sric@s@eZdZdZedd��Zedd��Zedd��Zedd	��Zd
S)�	AngleAddrz
angle-addrcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rm)rrrrrrm�s

zAngleAddr.local_partcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rn)rrrrrrn�s

zAngleAddr.domaincCs"x|D]}|jdkr|jSqWdS)Nz	obs-route)r7�domains)rrrrrro�s

zAngleAddr.routecCs<x6|D]*}|jdkr|jr |jSt|j�|jSqWdSdS)Nz	addr-specz<>)r7rmrpr)rrrrrrp�s

zAngleAddr.addr_specN)	r$r9r:r7r=rmrnrorprrrrrq�s
rqc@seZdZdZedd��ZdS)�ObsRoutez	obs-routecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)rn)r7rn)rrrrrrC�sz$ObsRoute.domains.<locals>.<listcomp>r)rrrrrr�szObsRoute.domainsN)r$r9r:r7r=rrrrrrrs�srsc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�MailboxrccCs|djdkr|djSdS)Nrz	name-addr)r7rb)rrrrrb�szMailbox.display_namecCs
|djS)Nr)rm)rrrrrm�szMailbox.local_partcCs
|djS)Nr)rn)rrrrrn�szMailbox.domaincCs|djdkr|djSdS)Nrz	name-addr)r7ro)rrrrro�sz
Mailbox.routecCs
|djS)Nr)rp)rrrrrp�szMailbox.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrrt�srtc@s,eZdZdZedd��ZeZZZZ	dS)�InvalidMailboxzinvalid-mailboxcCsdS)Nr)rrrrrb�szInvalidMailbox.display_nameN)
r$r9r:r7r=rbrmrnrorprrrrru�srucs(eZdZdZdZe�fdd��Z�ZS)�DomainrnFcsdjt�jj��S)Nr)r!rr�split)r)rrrrn�sz
Domain.domain)r$r9r:r7r)r=rnr>rr)rrrv�srvc@seZdZdZdS)�DotAtomzdot-atomN)r$r9r:r7rrrrrx�srxc@seZdZdZdZdS)�DotAtomTextz
dot-atom-textTN)r$r9r:r7r)rrrrry�sryc@sDeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dS)�AddrSpecz	addr-specFcCs
|djS)Nr)rm)rrrrrmszAddrSpec.local_partcCst|�dkrdS|djS)N�rjrl)rkrn)rrrrrnszAddrSpec.domaincCs<t|�dkr|djS|djj�|dj|djj�S)Nr{rrjrh)rkr�rstrip�lstrip)rrrrrs
zAddrSpec.valuecCsLt|j�}t|�t|t�kr*t|j�}n|j}|jdk	rH|d|jS|S)N�@)�setrmrk�
DOT_ATOM_ENDSrrn)rZnamesetZlprrrrps

zAddrSpec.addr_specN)
r$r9r:r7r)r=rmrnrrprrrrrz�srzc@seZdZdZdZdS)�ObsLocalPartzobs-local-partFN)r$r9r:r7r)rrrrr� sr�cs4eZdZdZdZedd��Ze�fdd��Z�ZS)�DisplayNamezdisplay-nameFcCs�t|�}|djdkr"|jd�n*|ddjdkrLt|ddd��|d<|djdkrd|j�n*|ddjdkr�t|ddd��|d	<|jS)
NrrJrjrlrlrlrlrlrl)rr7�popr)rrTrrrrb+s
zDisplayName.display_namecs�d}|jrd}nx|D]}|jdkrd}qW|r�d}}|djdksX|ddjdkr\d}|d	jdks||d
djdkr�d}|t|j�|St�jSdS)NFTz
quoted-stringrrrJr@rjrlrlrl)rr7rrbrr)rrYrZpreZpost)rrrr:s

  zDisplayName.value)	r$r9r:r7r<r=rbrr>rr)rrr�&sr�c@s,eZdZdZdZedd��Zedd��ZdS)�	LocalPartz
local-partFcCs&|djdkr|djS|djSdS)Nrz
quoted-string)r7rUr)rrrrrSs
zLocalPart.valuecCs�tg}t}d}x�|dtgD]�}|jdkr.q|r^|jdkr^|djdkr^t|dd��|d<t|t�}|r�|jdkr�|djdkr�|jt|dd���n
|j|�|d	}|}qWt|dd
��}|jS)NFrrJ�dotrjrlrlrlrlrl)�DOTr7r�
isinstancerSr)rrTZlastZ
last_is_tl�tokZis_tlrrrrmZs$


zLocalPart.local_partN)r$r9r:r7r)r=rrmrrrrr�Nsr�cs4eZdZdZdZe�fdd��Zedd��Z�ZS)�
DomainLiteralzdomain-literalFcsdjt�jj��S)Nr)r!rrrw)r)rrrrnwszDomainLiteral.domaincCs"x|D]}|jdkr|jSqWdS)N�ptext)r7r)rrrrr�ip{s

zDomainLiteral.ip)	r$r9r:r7r)r=rnr�r>rr)rrr�rsr�c@seZdZdZdZdZdS)�MIMEVersionzmime-versionN)r$r9r:r7�major�minorrrrrr��sr�c@s4eZdZdZdZdZdZedd��Zedd��Z	dS)	�	Parameter�	parameterFzus-asciicCs|jr|djSdS)Nrjr)�	sectioned�number)rrrr�section_number�szParameter.section_numbercCsbx\|D]T}|jdkr|jS|jdkrx4|D],}|jdkr*x|D]}|jdkr>|jSq>Wq*WqWdS)Nrz
quoted-stringzbare-quoted-stringr)r7rV)rr.rrr�param_value�s






zParameter.param_valueN)
r$r9r:r7r��extendedrPr=r�r�rrrrr��sr�c@seZdZdZdS)�InvalidParameterzinvalid-parameterN)r$r9r:r7rrrrr��sr�c@seZdZdZedd��ZdS)�	Attribute�	attributecCs$x|D]}|jjd�r|jSqWdS)N�attrtext)r7�endswithr)rr.rrrrV�s
zAttribute.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@seZdZdZdZdS)�Section�sectionN)r$r9r:r7r�rrrrr��sr�c@seZdZdZedd��ZdS)�ValuercCs2|d}|jdkr|d}|jjd�r,|jS|jS)NrrJrj�
quoted-stringr��extended-attribute)r�r�r�)r7r�rVr)rr.rrrrV�s
zValue.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@s(eZdZdZdZedd��Zdd�ZdS)�MimeParameterszmime-parametersFccs�t�}x\|D]T}|jjd�sq|djdkr.q|djj�}||krLg||<||j|j|f�qW�x�|j�D�]�\}}t|t	d�d�}|dd}|j
}|jr�t|�dkr�|dddkr�|ddj
jtjd��|dd�}g}d}x�|D]�\}	}
|	|k�r6|
j�s$|
j
jtjd��q�n|
j
jtjd��|d7}|
j}|
j�r�ytjj|�}Wn&tk
�r�tjj|d	d
�}YnRXy|j|d�}Wn"tk
�r�|jdd�}YnXtj|��r�|
j
jtj��|j|�q�Wd
j|�}||fVqpWdS)Nr�rr�)�keyrjz.duplicate parameter name; duplicate(s) ignoredz+duplicate parameter name; duplicate ignoredz(inconsistent RFC2231 parameter numberingzlatin-1)�encoding�surrogateescapezus-asciir)rr7r�r�striprSr��items�sortedrrPr�rkrr�InvalidHeaderDefectr��urllib�parseZunquote_to_bytes�UnicodeEncodeErrorZunquote�decode�LookupErrorr�_has_surrogates�UndecodableBytesDefectr!)r�paramsr.�name�partsZfirst_paramrPZvalue_parts�ir��paramrrrrr��sZ




zMimeParameters.paramscCsXg}x8|jD].\}}|r0|jdj|t|���q|j|�qWdj|�}|rTd|SdS)Nz{}={}z; r@r)r�rSr#rr!)rr�r�rrrrr"s
zMimeParameters.__str__N)r$r9r:r7r;r=r�r"rrrrr��sFr�c@seZdZdZedd��ZdS)�ParameterizedHeaderValueFcCs&x t|�D]}|jdkr
|jSq
WiS)Nzmime-parameters)�reversedr7r�)rr.rrrr�%s

zParameterizedHeaderValue.paramsN)r$r9r:r;r=r�rrrrr�sr�c@seZdZdZdZdZdZdS)�ContentTypezcontent-typeF�textZplainN)r$r9r:r7r)�maintype�subtyperrrrr�-sr�c@seZdZdZdZdZdS)�ContentDispositionzcontent-dispositionFN)r$r9r:r7r)�content_dispositionrrrrr�5sr�c@seZdZdZdZdZdS)�ContentTransferEncodingzcontent-transfer-encodingFZ7bitN)r$r9r:r7r)rOrrrrr�<sr�c@seZdZdZdZdS)�HeaderLabelzheader-labelFN)r$r9r:r7r)rrrrr�Csr�c@seZdZdZdS)�Header�headerN)r$r9r:r7rrrrr�Isr�csreZdZdZdZdZ�fdd�Z�fdd�Zdd�Ze	dd	��Z
d�fdd�	Zd
d�Ze	dd��Z
dd�Z�ZS)�TerminalTcst�j||�}||_g|_|S)N)r�__new__r7r)�clsrr7r)rrrr�XszTerminal.__new__csdj|jjt�j��S)Nz{}({}))r#rr$rr%)r)rrrr%^szTerminal.__repr__cCst|jjd|j�dS)N�/)r3rr$r7)rrrrr5aszTerminal.pprintcCs
t|j�S)N)�listr)rrrrr&dszTerminal.all_defectsrcs2dj||jj|jt�j�|js"dn
dj|j��gS)Nz
{}{}/{}({}){}rz {})r#rr$r7rr%r)rr2)rrrr6hszTerminal._ppcCsdS)Nr)rrrr�pop_trailing_wsqszTerminal.pop_trailing_wscCsgS)Nr)rrrrr-uszTerminal.commentscCst|�|jfS)N)rr7)rrrr�__getnewargs__yszTerminal.__getnewargs__)r)r$r9r:r)r<r;r�r%r5r=r&r6r�r-r�r>rr)rrr�Rs	r�c@s eZdZedd��Zdd�ZdS)�WhiteSpaceTerminalcCsdS)Nr@r)rrrrrszWhiteSpaceTerminal.valuecCsdS)NTr)rrrrr(�sz!WhiteSpaceTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr�}sr�c@s eZdZedd��Zdd�ZdS)�
ValueTerminalcCs|S)Nr)rrrrr�szValueTerminal.valuecCsdS)NFr)rrrrr(�szValueTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr��sr�c@s eZdZedd��Zdd�ZdS)�EWWhiteSpaceTerminalcCsdS)Nrr)rrrrr�szEWWhiteSpaceTerminal.valuecCsdS)Nrr)rrrrr"�szEWWhiteSpaceTerminal.__str__N)r$r9r:r=rr"rrrrr��sr�r��,zlist-separatorr~zroute-component-markerz([{}]+)rz[^{}]+rz\\�]z\]z[\x00-\x20\x7F]cCs>t|�}|r|jjtj|��tj|�r:|jjtjd��dS)Nz*Non-ASCII characters found in header token)�_non_printable_finderrrSrZNonPrintableDefectrr�r�)�xtextZnon_printablesrrr�_validate_xtext�s

r�cCs�t|d�^}}g}d}d}xbtt|��D]J}||dkrL|rFd}d}nd}q(|rVd}n|||krdP|j||�q(W|d}dj|�dj||d�g|�|fS)NrjFrTr)�
_wsp_splitter�rangerkrSr!)r�endcharsZfragment�	remainderZvchars�escape�had_qp�posrrr�_get_ptext_to_endchars�s$	r�cCs.|j�}t|dt|�t|��d�}||fS)N�fws)r}r�rk)rZnewvaluer�rrr�get_fws�sr�c
Cs�t�}|jd�s tjdj|���|dd�jdd�^}}||dd�krXtjdj|���dj|�}t|�dkr�|dtkr�|dtkr�|jdd�^}}|d|}t|j��dkr�|j	j
tjd��||_dj|�}yt
jd|d�\}}}}	Wn(tk
�rtjd	j|j���YnX||_||_|j	j|	�xh|�r�|dtk�rdt|�\}
}|j
|
��q6t|d�^}}t|d
�}t|�|j
|�dj|�}�q6W||fS)Nz=?z"expected encoded word but found {}rhz?=rjrrzwhitespace inside encoded wordz!encoded word format invalid: '{}'�vtext)rN�
startswithr�HeaderParseErrorr#rwr!rkrrrSr�rO�_ewr��
ValueErrorrPrQr,�WSPr�r�r�r�)
r�ewr�r�Zremstr�restr�rPrQrr.�charsr�rrr�get_encoded_word�sH

$




r�cCst�}�x|�r|dtkr4t|�\}}|j|�q
|jd�r�yt|�\}}Wntjk
rdYnrXd}t|�dkr�|dj	dkr�|j
jtjd��d}|r�t|�dkr�|d
j	d	kr�t|dd�|d<|j|�q
t
|d�^}}t|d
�}t|�|j|�dj|�}q
W|S)Nrz=?Trjr�z&missing whitespace before encoded wordFrhzencoded-wordr�rrl���rlrl)rDr�r�rSr�r�rr�rkr7rr�r�r�r�r�r!)rrEr.Zhave_wsr�r�r�rrr�get_unstructured!s:






r�cCs*t|d�\}}}t|d�}t|�||fS)Nz()r�)r�r�r�)rr��_rrr�get_qp_ctextYs
r�cCs*t|d�\}}}t|d�}t|�||fS)Nr
r�)r�r�r�)rr�r�rrr�get_qcontentjs

r�cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nzexpected atext but found '{}'�atext)�_non_atom_end_matcherrr�r#rarkr�r�)r�mr�rrr�	get_atextys
r�cCs|ddkrtjdj|���t�}|dd�}|ddkrPt|�\}}|j|�x�|r�|ddkr�|dtkr|t|�\}}nd|dd�dkr�y"t|�\}}|j	jtj
d��Wq�tjk
r�t|�\}}Yq�Xnt|�\}}|j|�qRW|�s|j	jtj
d��||fS||dd�fS)	Nrr
zexpected '"' but found '{}'rjrhz=?z!encoded word inside quoted stringz"end of header inside quoted string)rr�r#rWr�rSr�r�r�rr�)rZbare_quoted_stringr.rrr�get_bare_quoted_string�s2


r�cCs�|r |ddkr tjdj|���t�}|dd�}x^|r�|ddkr�|dtkr^t|�\}}n&|ddkrxt|�\}}nt|�\}}|j|�q4W|s�|j	jtj
d��||fS||dd�fS)Nrrzexpected '(' but found '{}'rjrZzend of header inside comment)rr�r#rXr�r��get_commentr�rSrr�)rrAr.rrrr��s"
r�cCsTt�}xD|rJ|dtkrJ|dtkr2t|�\}}nt|�\}}|j|�qW||fS)Nr)rI�CFWS_LEADERr�r�r�rS)rrJr.rrr�get_cfws�sr�cCspt�}|r,|dtkr,t|�\}}|j|�t|�\}}|j|�|rh|dtkrht|�\}}|j|�||fS)Nr)rRr�r�rSr�)rZ
quoted_stringr.rrr�get_quoted_string�s


r�cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���|jd�r�yt	|�\}}Wq�tjk
r�t
|�\}}Yq�Xnt
|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected atom but found '{}'z=?)rKr�r�rS�	ATOM_ENDSrr�r#r�r�r�)rrLr.rrr�get_atom�s$



r�cCs�t�}|s|dtkr(tjdj|���xP|rx|dtkrxt|�\}}|j|�|r*|ddkr*|jt�|dd�}q*W|dtkr�tjdjd|���||fS)Nrz8expected atom at a start of dot-atom-text but found '{}'r	rjz4expected atom at end of dot-atom-text but found '{}'rl)ryr�rr�r#r�rSr�)rZ
dot_atom_textr.rrr�get_dot_atom_text�s

r�cCs�t�}|dtkr(t|�\}}|j|�|jd�rhyt|�\}}Wqttjk
rdt|�\}}YqtXnt|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrz=?)	rxr�r�rSr�r�rr�r�)rZdot_atomr.rrr�get_dot_atoms



r�cCs�|dtkrt|�\}}nd}|ddkr8t|�\}}n*|dtkrVtjdj|���nt|�\}}|dk	rx|g|dd�<||fS)Nrr
z1Expected 'atom' or 'quoted-string' but found '{}')r�r�r��SPECIALSrr�r#r�)r�leaderr.rrr�get_word*s
r�cCs�t�}yt|�\}}|j|�Wn(tjk
rH|jjtjd��YnXx�|r�|dtkr�|ddkr�|jt�|jjtj	d��|dd�}qLyt|�\}}WnDtjk
r�|dt
kr�t|�\}}|jjtj	d��n�YnX|j|�qLW||fS)Nzphrase does not start with wordrr	zperiod in 'phrase'rjzcomment found without atom)rFr�rSrr�rr��PHRASE_ENDSr��ObsoleteHeaderDefectr�r�)rrGr.rrr�
get_phraseIs.




r�cCstt�}d}|dtkr"t|�\}}|s6tjdj|���yt|�\}}Wn^tjk
r�yt|�\}}Wn6tjk
r�|ddkr�|dtkr��t	�}YnXYnX|dk	r�|g|dd�<|j
|�|o�|ddks�|dtk�r2tt|�|�\}}|j
dk�r|jj
tjd��n|jj
tjd��||d<y|jjd�Wn(tk
�rj|jj
tjd��YnX||fS)	Nrz"expected local-part but found '{}'rzinvalid-obs-local-partz<local-part is not dot-atom, quoted-string, or obs-local-partz,local-part is not a dot-atom (contains CFWS)�asciiz)local-part contains non-ASCII characters))r�r�r�rr�r#r�r�r�rrS�get_obs_local_partrr7rr�r�r�encoder�ZNonASCIILocalPartDefect)rrmr�r.�obs_local_partrrr�get_local_partosB




r�cCs�t�}d}�x|o(|ddks,|dtk�r*|ddkrl|rN|jjtjd��|jt�d}|dd�}qnD|ddkr�|jt|dd��|dd�}|jjtjd	��d}q|r�|djd
kr�|jjtjd��yt	|�\}}d}Wn4tj
k
�r|dtk�r�t|�\}}YnX|j|�qW|djd
k�s\|djdk�rn|djd
k�rn|jjtjd
��|djd
k�s�|djdk�r�|djd
k�r�|jjtjd��|j�r�d|_||fS)NFrrr	zinvalid repeated '.'Trjzmisplaced-specialz/'\' character outside of quoted-string/ccontentr�zmissing '.' between wordsrJz!Invalid leading '.' in local partrhz"Invalid trailing '.' in local partzinvalid-obs-local-partrlrlrlr�)
r�r�rrSrr�r�r�r7r�r�r�r�)rr�Zlast_non_ws_was_dotr.rrrr��sV"





r�cCs@t|d�\}}}t|d�}|r0|jjtjd��t|�||fS)Nz[]r�z(quoted printable found in domain-literal)r�r�rrSrr�r�)rr�r�rrr�	get_dtext�s

rcCs,|rdS|jtjd��|jtdd��dS)NFz"end of input inside domain-literalr�zdomain-literal-endT)rSrr�r�)r�domain_literalrrr�_check_for_early_dl_end�srcCslt�}|dtkr(t|�\}}|j|�|s6tjd��|ddkrRtjdj|���|dd�}t||�rp||fS|jtdd��|dt	kr�t
|�\}}|j|�t|�\}}|j|�t||�r�||fS|dt	kr�t
|�\}}|j|�t||��r||fS|ddk�rtjdj|���|jtdd	��|dd�}|�rd|dtk�rdt|�\}}|j|�||fS)
Nrzexpected domain-literal�[z6expected '[' at start of domain-literal but found '{}'rjzdomain-literal-startr�z4expected ']' at end of domain-literal but found '{}'zdomain-literal-end)r�r�r�rSrr�r#rr�r�r�r)rrr.rrr�get_domain_literal�sD







rcCstt�}d}|dtkr"t|�\}}|s6tjdj|���|ddkrvt|�\}}|dk	rd|g|dd�<|j|�||fSyt|�\}}Wn"tjk
r�t	|�\}}YnX|r�|ddkr�tjd��|dk	r�|g|dd�<|j|�|o�|ddk�rl|j
jtjd��|djdk�r(|d|dd�<xB|�rj|ddk�rj|jt
�t	|d	d��\}}|j|��q*W||fS)
Nrzexpected domain but found '{}'rr~zInvalid Domainr	z(domain is not a dot-atom (contains CFWS)zdot-atomrj)rvr�r�rr�r#rrSr�r�rr�r7r�)rrnr�r.rrr�
get_domains@




rcCs~t�}t|�\}}|j|�|s.|ddkrH|jjtjd��||fS|jtdd��t|dd��\}}|j|�||fS)Nrr~z"add-spec local part with no domainzaddress-at-symbolrj)rzr�rSrrr�r�r)rrpr.rrr�
get_addr_spec.s


rcCs�t�}xf|rl|ddks$|dtkrl|dtkrHt|�\}}|j|�q|ddkr|jt�|dd�}qW|s�|ddkr�tjdj|���|jt�t	|dd��\}}|j|�x�|o�|ddk�rB|jt�|dd�}|s�P|dtk�rt|�\}}|j|�|ddkr�|jt�t	|dd��\}}|j|�q�W|�sTtjd��|ddk�rrtjdj|���|jt
dd	��||dd�fS)
Nrr�rjr~z(expected obs-route domain but found '{}'z%end of header while parsing obs-route�:z4expected ':' marking end of obs-route but found '{}'zend-of-obs-route-marker)rsr�r�rS�
ListSeparatorrr�r#�RouteComponentMarkerrr�)rZ	obs_router.rrr�
get_obs_route>sB






r
cCs�t�}|dtkr(t|�\}}|j|�|s:|ddkrJtjdj|���|jtdd��|dd�}|ddkr�|jtdd��|jjtj	d��|dd�}||fSyt
|�\}}Wnztjk
�r2y"t|�\}}|jjtjd	��Wn(tjk
�rtjd
j|���YnX|j|�t
|�\}}YnX|j|�|�r`|ddk�r`|dd�}n|jjtj	d��|jtdd��|�r�|dtk�r�t|�\}}|j|�||fS)Nr�<z"expected angle-addr but found '{}'zangle-addr-startrj�>zangle-addr-endznull addr-spec in angle-addrz*obsolete route specification in angle-addrz.expected addr-spec or obs-route but found '{}'z"missing trailing '>' on angle-addr)
rqr�r�rSrr�r#r�rr�rr
r�)rZ
angle_addrr.rrr�get_angle_addrgsJ






r
cCs<t�}t|�\}}|j|dd��|jdd�|_||fS)N)r�r�r,r)rrbr.rrr�get_display_name�s
rcCs�t�}d}|dtkr6t|�\}}|s6tjdj|���|ddkr�|dtkr^tjdj|���t|�\}}|s~tjdj|���|dk	r�|g|ddd�<d}|j|�t	|�\}}|dk	r�|g|dd�<|j|�||fS)Nrz!expected name-addr but found '{}'r)
rir�r�rr�r#r�rrSr
)rZ	name_addrr�r.rrr�
get_name_addr�s0

rcCs�t�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnXtdd�|jD��r�d|_|j	|�||fS)Nzexpected mailbox but found '{}'css|]}t|tj�VqdS)N)r�rr�)rrrrrr �szget_mailbox.<locals>.<genexpr>zinvalid-mailbox)
rtrrr�rr#�anyr&r7rS)rrcr.rrr�get_mailbox�s
rcCsht�}xX|r^|d|kr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)Nrzmisplaced-specialrj)rur�rSr�r�)rr�Zinvalid_mailboxr.rrr�get_invalid_mailbox�srcCs�t�}�x�|o|ddk�r�yt|�\}}|j|�W�ntjk
�r@d}|dtkr�t|�\}}|sz|ddkr�|j|�|jjtjd��n@t	|d�\}}|dk	r�|g|dd�<|j|�|jjtj
d��nb|ddkr�|jjtjd��nBt	|d�\}}|dk	�r |g|dd�<|j|�|jjtj
d��YnX|�r�|ddk�r�|d	}d|_t	|d�\}}|j|�|jjtj
d��|r
|ddkr
|jt
�|dd�}q
W||fS)
Nr�;z,;zempty element in mailbox-listzinvalid mailbox in mailbox-listr�rjzinvalid-mailboxrl)rdrrSrr�r�r�rr�rr�r7r,r)rZmailbox_listr.r�rcrrr�get_mailbox_list�sN













rcCst�}|s$|jjtjd��||fSd}|r�|dtkr�t|�\}}|sl|jjtjd��|j|�||fS|ddkr�|j|�||fSt|�\}}t|j	�dkr�|dk	r�|j|�|j
|�|jjtjd��||fS|dk	r�|g|dd�<|j|�||fS)Nzend of header before group-listrzend of header in group-listrzgroup-list with empty entries)rfrrSrr�r�r�rrkr_r,r�)rZ
group_listr�r.rrr�get_group_list"s8







rcCs"t�}t|�\}}|s$|ddkr4tjdj|���|j|�|jtdd��|dd�}|r�|ddkr�|jtdd��||dd�fSt|�\}}|j|�|s�|jjtj	d��n|ddkr�tjd	j|���|jtdd��|dd�}|�r|dt
k�rt|�\}}|j|�||fS)
Nrrz8expected ':' at end of group display name but found '{}'zgroup-display-name-terminatorrjrzgroup-terminatorzend of header in groupz)expected ';' at end of group but found {})rgrrr�r#rSr�rrr�r�r�)rrar.rrr�	get_groupGs2




rcCsxt�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnX|j|�||fS)Nzexpected address but found '{}')r`rrr�rr#rS)rr\r.rrr�get_addresses
rcCs�t�}�x�|�r�yt|�\}}|j|�W�n$tjk
�rP}�zd}|dtkr�t|�\}}|sr|ddkr�|j|�|jjtjd��nFt	|d�\}}|dk	r�|g|dd�<|jt
|g��|jjtjd��nh|ddkr�|jjtjd��nHt	|d�\}}|dk	�r|g|dd�<|jt
|g��|jjtjd��WYdd}~XnX|�r�|ddk�r�|d	d}d|_t	|d�\}}|j
|�|jjtjd��|r
|jtdd��|dd�}q
W||fS)
Nrr�z"address-list entry with no contentzinvalid address in address-listzempty element in address-listrjzinvalid-mailboxzlist-separatorrl)r[rrSrr�r�r�rr�rr`r�r7r,r�)rZaddress_listr.�errr�rcrrr�get_address_list�sN












rcCs�t�}|s |jjtjd��|S|dtkrXt|�\}}|j|�|sX|jjtjd��d}x8|r�|ddkr�|dtkr�||d7}|dd�}q^W|j�s�|jjtjdj	|���|jt
|d��nt|�|_|jt
|d	��|o�|dtk�r
t|�\}}|j|�|�s |ddk�rX|jdk	�r>|jjtjd
��|�rT|jt
|d��|S|jt
dd��|dd�}|�r�|dtk�r�t|�\}}|j|�|�s�|jdk	�r�|jjtjd
��|Sd}x2|�r�|dtk�r�||d7}|dd�}�q�W|j��s2|jjtjdj	|���|jt
|d��nt|�|_
|jt
|d	��|�rv|dtk�rvt|�\}}|j|�|�r�|jjtjd
��|jt
|d��|S)Nz%Missing MIME version number (eg: 1.0)rz0Expected MIME version number but found only CFWSrr	rjz1Expected MIME major version number but found {!r}r��digitsz0Incomplete MIME version; found only major numberzversion-separatorz1Expected MIME minor version number but found {!r}z'Excess non-CFWS text after MIME version)r�rrSr�HeaderMissingRequiredValuer�r��isdigitr�r#r��intr�r�)rZmime_versionr.rrrr�parse_mime_version�sv













rcCsht�}xX|r^|ddkr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)Nrrzmisplaced-specialrj)r�r�rSr�r�)rZinvalid_parameterr.rrr�get_invalid_parametersrcCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nzexpected ttext but found '{}'�ttext)�_non_token_end_matcherrr�r#rarkr�r�)rr�r rrr�	get_ttexts	
r"cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected token but found '{}')	rMr�r�rS�
TOKEN_ENDSrr�r#r")rZmtokenr.rrr�	get_token)s	


r$cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nz expected attrtext but found {!r}r�)�_non_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_attrtext@s	
r&cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected token but found '{}')	r�r�r�rS�ATTRIBUTE_ENDSrr�r#r&)rr�r.rrr�
get_attributeSs	


r(cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nz)expected extended attrtext but found {!r}zextended-attrtext)�#_non_extended_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_extended_attrtextjs
r*cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected token but found '{}')	r�r�r�rS�EXTENDED_ATTRIBUTE_ENDSrr�r#r*)rr�r.rrr�get_extended_attribute|s


r,cCs�t�}|s|ddkr(tjdj|���|jtdd��|dd�}|sX|dj�rhtjdj|���d}x,|r�|dj�r�||d7}|dd�}qnW|ddkr�|dkr�|jjtjd	��t	|�|_
|jt|d
��||fS)Nr�*zExpected section but found {}zsection-markerrjz$Expected section number but found {}r�0z'section number has an invalid leading 0r)r�rr�r#rSr�rrZInvalidHeaderErrorrr�)rr�rrrr�get_section�s&	

r/cCs�t�}|stjd��d}|dtkr0t|�\}}|sDtjdj|���|ddkr^t|�\}}nt|�\}}|dk	r�|g|dd�<|j|�||fS)Nz&Expected value but found end of stringrz Expected value but found only {}r
)	r�rr�r�r�r#r�r,rS)r�vr�r.rrr�	get_value�s 

r1cCsvt�}t|�\}}|j|�|s.|ddkrN|jjtjdj|���||fS|ddkr�y t|�\}}d|_|j|�Wntj	k
r�YnX|s�tj	d��|ddkr�|jt
dd��|dd�}d|_|dd	kr�tj	d
��|jt
d	d��|dd�}d}|�r.|dtk�r.t
|�\}}|j|�d}|}|j�rH|�rH|ddk�rHt|�\}}|j}d
}|jdk�r�|�r�|ddk�r�d}n$t|�\}}	|	�r�|	ddk�r�d}n(yt|�\}}	WnYnX|	�s�d}|�r2|jjtjd��|j|�x,|D]$}
|
jdk�rg|
dd�<|
}P�qW|}nd}|jjtjd��|�rb|ddk�rbd}nt|�\}}|j�s�|jdk�r�|�s�|ddk�r�|j|�|dk	�r�|}||fS|jjtjd��|�s|jjtjd��|j|�|dk�r�||fSn�|dk	�rFx|D]}
|
jdk�rP�qW|
jdk|j|
�|
j|_|ddk�rdtj	dj|���|jt
dd��|dd�}|�r�|ddk�r�t|�\}}|j|�|j|_|�s�|ddk�r�tj	dj|���|jt
dd��|dd�}|dk	�rJt�}x>|�rB|dtk�r(t|�\}}nt|�\}}|j|��qW|}nt|�\}}|j|�|dk	�rn|}||fS)Nrrz)Parameter contains name ({}) but no valuer-TzIncomplete parameterzextended-parameter-markerrj�=zParameter not followed by '='zparameter-separatorr
F�'z5Quoted string value for extended parameter is invalidzbare-quoted-stringzZParameter marked as extended but appears to have a quoted string value that is non-encodedzcApparent initial-extended-value but attribute was not marked as extended or was not initial sectionz(Missing required charset/lang delimiterszextended-attrtextr�z=Expected RFC2231 char/lang encoding delimiter, but found {!r}zRFC2231-delimiterz;Expected RFC2231 char/lang encoding delimiter, but found {})r�r(rSrrr�r#r/r�r�r�r�r�r�r�rVr�r&r*r7r1rrPrQr�r�r�r�)rr�r.r�r�ZappendtoZqstringZinner_valueZ
semi_validr��tr0rrr�
get_parameter�s�























r5cCsht�}�xZ|�rbyt|�\}}|j|�Wn�tjk
r�}z�d}|dtkrZt|�\}}|sl|j|�|S|ddkr�|dk	r�|j|�|jjtjd��n@t	|�\}}|r�|g|dd�<|j|�|jjtjdj
|���WYdd}~XnX|�r@|ddk�r@|d	}d|_t	|�\}}|j|�|jjtjdj
|���|r
|jt
dd��|dd�}q
W|S)
Nrrzparameter entry with no contentzinvalid parameter {!r}rjzinvalid-parameterz)parameter with invalid trailing text {!r}zparameter-separatorrl)r�r5rSrr�r�r�rr�rr#r7r,r�)rZmime_parametersr.rr�r�rrr�parse_mime_parametersQ	sD







 

r6cCs�xX|rX|ddkrX|dtkr@|jt|dd��|dd�}qt|�\}}|j|�qW|sbdS|jtdd��|jt|dd���dS)Nrrzmisplaced-specialrjzparameter-separator)r�rSr�r�r6)Z	tokenlistrr.rrr�_find_mime_parameters�	sr7cCs�t�}d}|s$|jjtjd��|Syt|�\}}Wn8tjk
rl|jjtjdj|���t	||�|SX|j|�|s�|ddkr�|jjtjd��|r�t	||�|S|j
j�j�|_
|jtdd��|dd�}yt|�\}}Wn:tjk
�r$|jjtjd	j|���t	||�|SX|j|�|j
j�j�|_|�sJ|S|dd
k�r�|jjtjdj|���|`
|`t	||�|S|jtd
d��|jt|dd���|S)
NFz"Missing content type specificationz(Expected content maintype but found {!r}rr�zInvalid content typezcontent-type-separatorrjz'Expected content subtype but found {!r}rz<Only parameters are valid after content type, but found {!r}zparameter-separator)r�rrSrrr$r�r�r#r7rr��lowerr�r�r�r6)rZctypeZrecoverr.rrr�parse_content_type_header�	sX











r9c
Cs�t�}|s |jjtjd��|Syt|�\}}Wn8tjk
rh|jjtjdj|���t	||�|SX|j|�|j
j�j�|_
|s�|S|ddkr�|jjtjdj|���t	||�|S|jtdd��|jt|dd���|S)NzMissing content dispositionz+Expected content disposition but found {!r}rrzCOnly parameters are valid after content disposition, but found {!r}zparameter-separatorrj)r�rrSrrr$r�r�r#r7rr�r8r�r�r6)rZdisp_headerr.rrr� parse_content_disposition_header�	s2






r:cCs�t�}|s |jjtjd��|Syt|�\}}Wn.tjk
r^|jjtjdj|���YnX|j|�|j	j
�j�|_|s�|Sx^|r�|jjtjd��|dt
kr�|jt|dd��|dd�}q�t|�\}}|j|�q�W|S)Nz!Missing content transfer encodingz1Expected content transfer encoding but found {!r}z*Extra text after content transfer encodingrzmisplaced-specialrj)r�rrSrrr$r�r�r#rr�r8rOr�r�r�)rZ
cte_headerr.rrr�&parse_content_transfer_encoding_header�	s.



r;cCsDd}|r@|dr@|ddtkr@|dd}|ddd	�|d
<|S)Nrrjrlrlrlrlrlrlrlrl)r�)�linesZwsprrr�_steal_trailing_WSP_if_exists
s
r=cCs�|jptd�}|jrdnd}dg}d}d}d}tdd�}t|�}	�xz|	�r�|	jd�}
|
|krf|d8}qDt|
�}|s�|
jd	kr�tj	|�}nt
j	|�}y|j|�|}Wn6tk
r�t
d
d�|
jD��r�d}nd}d
}YnX|
jdkr�t|
|||�qD|�r�|�r�|
j�s�d}d}|
j�r�|
j|d�dt|j��}
|j|
k�r�t|
�|t|d�k�rtt|�}|j|�|d|
7<qDt|
d��s�t|
�|	}	nt|||||
j|�}d}qDt|�|t|d�k�r�|d|7<qD|
j�r(t|�d|k�r(t|�}|�s|
j��r(|j||�qDt|
d��s`t|
�}|
j�sV|d7}|j|�||	}	qD|
j�r�|�r�|	jd|
�d
}qDt|�}|�s�|
j��r�|j||�qD|d|7<qDW|jj|�|jS)Nz+infzutf-8zus-asciirrF�wrap_as_ew_blockedrjr�css|]}t|tj�VqdS)N)r�rr�)rrrrrr @
sz%_refold_parse_tree.<locals>.<genexpr>zunknown-8bitTzmime-parameters)r/r�rlrlrlrlrl)Zmax_line_length�float�utf8r�r�r�rr7�
SPECIALSNL�
isdisjoint�NLSETr�r�rr&�_fold_mime_parametersr)r;r1rk�linesepr=rSr8�_fold_as_ewr<r(�insertr!)Z
parse_treer/�maxlenr�r<�last_ewr>Z
want_encodingZend_ew_not_allowedr�r*�tstrrPZencoded_part�newlineZnewpartsrrrr0"
s�










r0cCs�|dk	r<|r<tt|d	|d�|��}|d
d|�|d<|dtkr�|d}|dd�}t|d�|krz|jt|��|d
|7<d}|dtkr�|d}|dd�}|dkr�t|d�n|}x�|�r�|t|d�}	|dkr�dn|}
|	t|
�d}|dk�r|jd�q�|d|�}tj||
d�}
t|
�|	}|dk�r\|d|�}tj|�}
|d|
7<|t|�d�}|r�|jd�t|d�}q�W|d|7<|�r�|SdS)Nrjrrzus-asciizutf-8�r@)rPrlrlrlrlrlrlrlrlrlrlrlrlrl)rr�r�rkrSr=r�r�)Z	to_encoder<rHrIr<rPZleading_wspZtrailing_wspZnew_last_ewZremaining_spaceZ	encode_asZ
text_spaceZ
first_partr�ZexcessrrrrF�
sF




rFcCs��x�|jD�]�\}}|dj�jd�s6|dd7<|}d}y|j|�d}Wn0tk
r�d}tj|�rxd}d}nd}YnX|r�tjj	|d	|d
�}	dj
|||	�}
ndj
|t|��}
t|d�t|
�d|kr�|dd
|
|d<q
n"t|
�d|k�r|j
d
|
�q
d}|d}x�|�r�t|�tt|��dt|�}
||
dk�rTd}||
d}}x<|d|�}tjj	|d	|d
�}	t|	�|k�r�P|d8}�qfW|j
dj
||||	��d	}|d7}||d�}|�r|dd7<�qWq
WdS)Nrjr�strictFTzunknown-8bitr�zutf-8r)Zsaferz
{}*={}''{}z{}={}r@rhrz''r{�Nz {}*{}*={}{}rlrlrlrlrlrl)r�r|r�r�r�rr�r�r�rYr#rrkrSr)r*r<rHr�r�rrPZ
error_handlerZencoding_requiredZ
encoded_valuerJr�Zextra_chromeZ
chrome_lenZ
splitpointZmaxchars�partialrrrrD�
s\


 rD)��rer��stringr�collectionsr�operatorrZemailrr�rrrr�r�r�r�r�r�Z	TSPECIALSr#Z	ASPECIALSr'r+rCrArr�rr?rDrFrHrIrKrMrNrRrWrXr[r`rdrfrgrirqrsrtrurvrxryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�rr	�compiler#r!rwr�r�matchr��findallr�r!r%r)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
r
rrrrrrrrrrrr"r$r&r(r*r,r/r1r5r6r7r9r:r;r=r0rFrDrrrr�<module>FsC"	
!($
V	+




   

*8"
&'/'&).9%>D49/j7PKc��\��-K�0�0_parseaddr.cpython-36.pycnu�[���3

���i�D�@s�dZddddgZddlZddlZdZdZd	Zd
ddd
dddddddddddddddddddd gZd!d"d#d$d%d&d'gZddddd9d:d;d<d=d>d?d@dAdBd.�Z	d/d�Z
d0d1�Zd2d�Zd3d�Z
d4d�ZGd5d6�d6�ZGd7d8�d8e�ZdS)CzcEmail address parsing code.

Lifted directly from rfc822.py.  This should eventually be rewritten.
�	mktime_tz�	parsedate�parsedate_tz�quote�N� �z, ZjanZfebZmarZaprZmayZjunZjulZaug�sep�octZnovZdecZjanuaryZfebruaryZmarchZaprilZjuneZjulyZaugustZ	septemberZoctoberZnovemberZdecemberZmonZtueZwedZthuZfriZsatZsuni�i,i�iXi�i )ZUTZUTCZGMT�ZZASTZADTZESTZEDTZCSTZCDTZMSTZMDTZPSTZPDTcCs,t|�}|sdS|ddkr$d|d<t|�S)zQConvert a date string to a time tuple.

    Accounts for military timezones.
    N�	r)�
_parsedate_tz�tuple)�data�res�r�(/usr/lib64/python3.6/email/_parseaddr.pyr-scCs�|sdS|j�}|djd�s.|dj�tkr6|d=n.|djd�}|dkrd|d|dd�|d<t|�dkr�|djd�}t|�dkr�||dd�}t|�dk�r|d}|jd�}|dkr�|jd�}|dkr�|d|�||d�g|dd�<n
|jd	�t|�d
k�rdS|dd
�}|\}}}}}|j�}|tk�rZ||j�}}|tk�rZdStj	|�d}|dk�rz|d8}|ddk�r�|dd�}|jd�}|dk�r�||}}|ddk�r�|dd�}|dj
��s�||}}|ddk�r�|dd�}|jd�}t|�d
k�r$|\}	}
d}n~t|�dk�r>|\}	}
}ndt|�dk�r�d|dk�r�|djd�}t|�d
k�r�|\}	}
d}nt|�dk�r�|\}	}
}ndSy,t|�}t|�}t|	�}	t|
�}
t|�}Wntk
�r�dSX|dk�r|dk�r|d7}n|d7}d}|j
�}|tk�r,t|}n>yt|�}Wntk
�rNYnX|dk�rj|jd��rjd}|�r�|dk�r�d}
|}nd}
|
|dd|dd}||||	|
|ddd|g
S)a�Convert date to extended time tuple.

    The last (additional) element is the time zone offset in seconds, except if
    the timezone was specified as -0000.  In that case the last element is
    None.  This indicates a UTC timestamp that explicitly declaims knowledge of
    the source timezone, as opposed to a +0000 timestamp that indicates the
    source timezone really was UTC.

    Nr�,���-��+r���:��0�.�d�Dili�i�<���r!r!r!r!r!r!r!r!)�split�endswith�lower�	_daynames�rfind�len�find�append�_monthnames�index�isdigit�int�
ValueError�upper�
_timezones�
startswith)r�iZstuff�sZddZmmZyyZtmZtzZthhZtmmZtssZtzoffsetZtzsignrrrr9s�


"














rcCs&t|�}t|t�r|dd�S|SdS)z&Convert a time string to a time tuple.Nr)r�
isinstancer
)r�trrrr�s
cCs<|ddkr"tj|dd�d�Stj|�}||dSdS)zETurn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.rN�rr!)r!)�timeZmktime�calendarZtimegm)rr5rrrr�s
cCs|jdd�jdd�S)z�Prepare string to be used in a quoted string.

    Turns backslash and double quote characters into quoted pairs.  These
    are the only characters that need to be quoted inside a quoted string.
    Does not add the surrounding double quotes.
    �\z\\�"z\")�replace)�strrrrr�sc@s|eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zddd�Zdd�ZdS) �
AddrlistClassaAddress parser class by Ben Escoto.

    To understand what this class does, it helps to have a copy of RFC 2822 in
    front of you.

    Note: this class interface is deprecated and may be removed in the future.
    Use email.utils.AddressList instead.
    cCsZd|_d|_d|_d|_|j|j|_|j|j|j|_|jjdd�|_||_g|_	dS)z�Initialize a new instance.

        `field' is an unparsed address header field, containing
        one or more addresses.
        z()<>@,:;."[]rz 	z
rrN)
�specials�pos�LWSZCR�FWS�atomendsr;�
phraseends�field�commentlist)�selfrDrrr�__init__�szAddrlistClass.__init__cCs�g}x�|jt|j�kr�|j|j|jdkr^|j|jdkrN|j|j|j�|jd7_q|j|jdkr�|jj|j��qPqWtj|�S)z&Skip white space and extract comments.z

r�()	r?r'rDr@r)rE�
getcomment�EMPTYSTRING�join)rFZwslistrrr�gotonext�szAddrlistClass.gotonextcCs>g}x4|jt|j�kr8|j�}|r,||7}q|jd�qW|S)zVParse all addresses.

        Returns a list containing all of the addresses.
        r)rr)r?r'rD�
getaddressr))rF�resultZadrrr�getaddrlist�s
zAddrlistClass.getaddrlistcCs�g|_|j�|j}|j}|j�}|j�g}|jt|j�kr\|rXtj|j�|dfg}�n\|j|jdkr�||_||_|j�}tj|j�|fg}�n"|j|jdk�rg}t|j�}|jd7_x�|jt|j�k�r|j�|j|ko�|j|jdk�r|jd7_P||j	�}q�Wn�|j|jdk�rx|j
�}|j�rftj|�ddj|j�d	|fg}ntj|�|fg}n@|�r�tj|j�|dfg}n"|j|j|jk�r�|jd7_|j�|jt|j�k�r�|j|jd
k�r�|jd7_|S)zParse the next address.rz.@rr�;�<z (r�)r)rErLr?�
getphraselistr'rD�SPACErK�getaddrspecrM�getrouteaddrr>)rFZoldposZoldcl�plistZ
returnlistZaddrspecZfieldlenZ	routeaddrrrrrMsL
&$zAddrlistClass.getaddresscCs�|j|jdkrdSd}|jd7_|j�d}x�|jt|j�kr�|rV|j�d}n~|j|jdkrx|jd7_Pn\|j|jdkr�|jd7_d}n8|j|jd	kr�|jd7_n|j�}|jd7_P|j�q4W|S)
z�Parse a route address (Return-path value).

        This method just skips all the route stuff and returns the addrspec.
        rQNFrr�>�@Tr)rDr?rLr'�	getdomainrU)rFZexpectrouteZadlistrrrrV?s.zAddrlistClass.getrouteaddrcCs\g}|j�x�|jt|j�kr�d}|j|jdkrj|rL|dj�rL|j�|jd�|jd7_d}nf|j|jdkr�|jdt|j���n>|j|j|j	kr�|r�|d	j�r�|j�Pn|j|j
��|j�}|r|r|j|�qW|jt|j�k�s|j|jdk�rtj|�S|jd�|jd7_|j�|j
�}|�sNtStj|�|S)
zParse an RFC 2822 addr-spec.TrrFr:z"%s"rYr!r!)rLr?r'rD�strip�popr)r�getquoterB�getatomrJrKrZ)rFZaslistZpreserve_wsZwsZdomainrrrrU_s:
$

zAddrlistClass.getaddrspeccCs�g}x�|jt|j�kr�|j|j|jkr8|jd7_q|j|jdkrZ|jj|j��q|j|jdkrz|j|j��q|j|jdkr�|jd7_|jd�q|j|jdkr�tS|j|j|j	kr�Pq|j|j
��qWtj|�S)z-Get the complete domain name from an address.rrH�[rrY)r?r'rDr@rEr)rI�getdomainliteralrJrBr^rK)rFZsdlistrrrrZ�s"zAddrlistClass.getdomainTcCs�|j|j|krdSdg}d}|jd7_x�|jt|j�kr�|rZ|j|j|j�d}np|j|j|kr||jd7_PnN|r�|j|jdkr�|j|j��q.n(|j|jdkr�d}n|j|j|j�|jd7_q.Wtj|�S)a�Parse a header fragment delimited by special characters.

        `beginchar' is the start character for the fragment.
        If self is not looking at an instance of `beginchar' then
        getdelimited returns the empty string.

        `endchars' is a sequence of allowable end-delimiting characters.
        Parsing stops when one of these is encountered.

        If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed
        within the parsed fragment.
        rFrrHr9T)rDr?r'r)rIrJrK)rFZ	begincharZendcharsZ
allowcommentsZslistrrrr�getdelimited�s(
zAddrlistClass.getdelimitedcCs|jddd�S)z1Get a quote-delimited fragment from self's field.r:z"
F)ra)rFrrrr]�szAddrlistClass.getquotecCs|jddd�S)z7Get a parenthesis-delimited fragment from self's field.rHz)
T)ra)rFrrrrI�szAddrlistClass.getcommentcCsd|jddd�S)z!Parse an RFC 2822 domain-literal.z[%s]r_z]
F)ra)rFrrrr`�szAddrlistClass.getdomainliteralNcCshdg}|dkr|j}xH|jt|j�kr\|j|j|kr:Pn|j|j|j�|jd7_qWtj|�S)aParse an RFC 2822 atom.

        Optional atomends specifies a different set of end token delimiters
        (the default is to use self.atomends).  This is used e.g. in
        getphraselist() since phrase endings must not include the `.' (which
        is legal in phrases).rNr)rBr?r'rDr)rJrK)rFrBZatomlistrrrr^�szAddrlistClass.getatomcCs�g}x�|jt|j�kr�|j|j|jkr8|jd7_q|j|jdkrX|j|j��q|j|jdkrz|jj|j��q|j|j|jkr�Pq|j|j	|j��qW|S)z�Parse a sequence of RFC 2822 phrases.

        A phrase is a sequence of words, which are in turn either RFC 2822
        atoms or quoted-strings.  Phrases are canonicalized by squeezing all
        runs of continuous whitespace into one space.
        rr:rH)
r?r'rDrAr)r]rErIrCr^)rFrWrrrrS�szAddrlistClass.getphraselist)T)N)�__name__�
__module__�__qualname__�__doc__rGrLrOrMrVrUrZrar]rIr`r^rSrrrrr=�s; &
%
r=c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�AddressListz@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs&tj||�|r|j�|_ng|_dS)N)r=rGrO�addresslist)rFrDrrrrG�szAddressList.__init__cCs
t|j�S)N)r'rg)rFrrr�__len__szAddressList.__len__cCsBtd�}|jdd�|_x$|jD]}||jkr |jj|�q W|S)N)rfrgr))rF�other�newaddr�xrrr�__add__s
zAddressList.__add__cCs*x$|jD]}||jkr|jj|�qW|S)N)rgr))rFrirkrrr�__iadd__
s
zAddressList.__iadd__cCs2td�}x$|jD]}||jkr|jj|�qW|S)N)rfrgr))rFrirjrkrrr�__sub__s

zAddressList.__sub__cCs*x$|jD]}||jkr|jj|�qW|S)N)rg�remove)rFrirkrrr�__isub__s
zAddressList.__isub__cCs
|j|S)N)rg)rFr+rrr�__getitem__#szAddressList.__getitem__N)rbrcrdrerGrhrlrmrnrprqrrrrrf�s	rfip���i���i���ip���i����i���iD���i����i��iD���)re�__all__r7r8rTrJZ
COMMASPACEr*r%r0rrrrrr=rfrrrr�<module>s8

u	

/PKc��\]䕟��errors.cpython-36.opt-1.pycnu�[���3

���i��@s�dZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
ee�ZGdd�de�ZGd
d�de�Z	Gdd�de
�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZeZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�ZGd'd(�d(e�ZGd)d*�d*e�ZGd+d,�d,e�ZGd-d.�d.e�ZGd/d0�d0e�ZGd1d2�d2e�ZGd3d4�d4e�Zd5S)6z email package exception classes.c@seZdZdZdS)�MessageErrorz+Base class for errors in the email package.N)�__name__�
__module__�__qualname__�__doc__�rr�$/usr/lib64/python3.6/email/errors.pyrsrc@seZdZdZdS)�MessageParseErrorz&Base class for message parsing errors.N)rrrrrrrrrsrc@seZdZdZdS)�HeaderParseErrorzError while parsing headers.N)rrrrrrrrr	sr	c@seZdZdZdS)�
BoundaryErrorz#Couldn't find terminating boundary.N)rrrrrrrrr
sr
c@seZdZdZdS)�MultipartConversionErrorz(Conversion to a multipart is prohibited.N)rrrrrrrrrsrc@seZdZdZdS)�CharsetErrorzAn illegal charset was given.N)rrrrrrrrrsrc@seZdZdZdS)�HeaderWriteErrorzError while writing headers.N)rrrrrrrrr
 sr
cs"eZdZdZd�fdd�	Z�ZS)�
MessageDefectz Base class for a message defect.Ncs|dk	rt�j|�||_dS)N)�super�__init__�line)�selfr)�	__class__rrr(szMessageDefect.__init__)N)rrrrr�
__classcell__rr)rrr%src@seZdZdZdS)�NoBoundaryInMultipartDefectzBA message claimed to be a multipart but had no boundary parameter.N)rrrrrrrrr-src@seZdZdZdS)�StartBoundaryNotFoundDefectz+The claimed start boundary was never found.N)rrrrrrrrr0src@seZdZdZdS)�CloseBoundaryNotFoundDefectzEA start boundary was found, but not the corresponding close boundary.N)rrrrrrrrr3src@seZdZdZdS)�#FirstHeaderLineIsContinuationDefectz;A message had a continuation line as its first header line.N)rrrrrrrrr6src@seZdZdZdS)�MisplacedEnvelopeHeaderDefectz?A 'Unix-from' header was found in the middle of a header block.N)rrrrrrrrr9src@seZdZdZdS)� MissingHeaderBodySeparatorDefectzEFound line with no leading whitespace and no colon before blank line.N)rrrrrrrrr<src@seZdZdZdS)�!MultipartInvariantViolationDefectz?A message claimed to be a multipart but no subparts were found.N)rrrrrrrrrAsrc@seZdZdZdS)�-InvalidMultipartContentTransferEncodingDefectzEAn invalid content transfer encoding was set on the multipart itself.N)rrrrrrrrrDsrc@seZdZdZdS)�UndecodableBytesDefectz0Header contained bytes that could not be decodedN)rrrrrrrrrGsrc@seZdZdZdS)�InvalidBase64PaddingDefectz/base64 encoded sequence had an incorrect lengthN)rrrrrrrrrJsrc@seZdZdZdS)�InvalidBase64CharactersDefectz=base64 encoded sequence had characters not in base64 alphabetN)rrrrrrrrrMsrc@seZdZdZdS)�InvalidBase64LengthDefectz4base64 encoded sequence had invalid length (1 mod 4)N)rrrrrrrrr Psr cs eZdZdZ�fdd�Z�ZS)�HeaderDefectzBase class for a header defect.cst�j||�dS)N)rr)r�args�kw)rrrrXszHeaderDefect.__init__)rrrrrrrr)rrr!Usr!c@seZdZdZdS)�InvalidHeaderDefectz+Header is not valid, message gives details.N)rrrrrrrrr$[sr$c@seZdZdZdS)�HeaderMissingRequiredValuez(A header that must have a value had noneN)rrrrrrrrr%^sr%cs(eZdZdZ�fdd�Zdd�Z�ZS)�NonPrintableDefectz8ASCII characters outside the ascii-printable range foundcst�j|�||_dS)N)rr�non_printables)rr')rrrrdszNonPrintableDefect.__init__cCsdj|j�S)Nz6the following ASCII non-printables found in header: {})�formatr')rrrr�__str__hszNonPrintableDefect.__str__)rrrrrr)rrr)rrr&asr&c@seZdZdZdS)�ObsoleteHeaderDefectz0Header uses syntax declared obsolete by RFC 5322N)rrrrrrrrr*lsr*c@seZdZdZdS)�NonASCIILocalPartDefectz(local_part contains non-ASCII charactersN)rrrrrrrrr+osr+N)r�	Exceptionrrr	r
�	TypeErrorrrr
�
ValueErrorrrrrrrrZMalformedHeaderDefectrrrrrr r!r$r%r&r*r+rrrr�<module>s6PKc��\�ǜD�)�)#_header_value_parser.cpython-36.pycnu�[���3

���i���@szdZddlZddlZddlmZddlmZddlmZddl	m
Zddl	mZddl	m
Z
ed	�Zeed
�BZed�ZeeBZeed�Zeed
�Zeed�Bed�ZeeBZeed�BZeeBZeed�ZddhZeeBZdd�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd �d e�Z#Gd!d"�d"e�Z$Gd#d$�d$e�Z%Gd%d&�d&e�Z&Gd'd(�d(e�Z'Gd)d*�d*e'�Z(Gd+d,�d,e�Z)Gd-d.�d.e�Z*Gd/d0�d0e�Z+Gd1d2�d2e�Z,Gd3d4�d4e�Z-Gd5d6�d6e�Z.Gd7d8�d8e�Z/Gd9d:�d:e�Z0Gd;d<�d<e�Z1Gd=d>�d>e�Z2Gd?d@�d@e�Z3GdAdB�dBe�Z4GdCdD�dDe�Z5GdEdF�dFe�Z6GdGdH�dHe�Z7GdIdJ�dJe�Z8GdKdL�dLe!�Z9GdMdN�dNe�Z:GdOdP�dPe�Z;GdQdR�dRe�Z<GdSdT�dTe�Z=GdUdV�dVe=�Z>GdWdX�dXe�Z?GdYdZ�dZe�Z@Gd[d\�d\e�ZAGd]d^�d^e�ZBGd_d`�d`e�ZCGdadb�dbeC�ZDGdcdd�ddeC�ZEGdedf�dfe�ZFGdgdh�dhe�ZGGdidj�dje�ZHGdkdl�dleI�ZJGdmdn�dneJ�ZKGdodp�dpeJ�ZLGdqdr�dreK�ZMeLdds�ZNeLdtdu�ZOeLdvdw�ZPejQdxjRdyjSe���jTZUejQdzjRdyjSe�jVd{d|�jVd}d~���jWZXejQd�jYZZejQdzjRdyjSe�jVd{d|�jVd}d~���jWZ[ejQdzjRdyjSe�jVd{d|�jVd}d~���jWZ\ejQdzjRdyjSe�jVd{d|�jVd}d~���jWZ]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�dÄZd�dńZ�d�dDŽZ�d�dɄZ�d�d˄Z�d�d̈́Z�d�dτZ�d�dфZ�d�dӄZ�d�dՄZ�d�dׄZ�d�dلZ�d�dۄZ�d�d݄Z�d�d߄Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�dS)�alHeader value parser implementing various email-related RFC parsing rules.

The parsing methods defined in this module implement various email related
parsing rules.  Principal among them is RFC 5322, which is the followon
to RFC 2822 and primarily a clarification of the former.  It also implements
RFC 2047 encoded word decoding.

RFC 5322 goes to considerable trouble to maintain backward compatibility with
RFC 822 in the parse phase, while cleaning up the structure on the generation
phase.  This parser supports correct RFC 5322 generation by tagging white space
as folding white space only when folding is allowed in the non-obsolete rule
sets.  Actually, the parser is even more generous when accepting input than RFC
5322 mandates, following the spirit of Postel's Law, which RFC 5322 encourages.
Where possible deviations from the standard are annotated on the 'defects'
attribute of tokens that deviate.

The general structure of the parser follows RFC 5322, and uses its terminology
where there is a direct correspondence.  Where the implementation requires a
somewhat different structure than that used by the formal grammar, new terms
that mimic the closest existing terms are used.  Thus, it really helps to have
a copy of RFC 5322 handy when studying this code.

Input to the parser is a string that has already been unfolded according to
RFC 5322 rules.  According to the RFC this unfolding is the very first step, and
this parser leaves the unfolding step to a higher level message parser, which
will have already detected the line breaks that need unfolding while
determining the beginning and end of each header.

The output of the parser is a TokenList object, which is a list subclass.  A
TokenList is a recursive data structure.  The terminal nodes of the structure
are Terminal objects, which are subclasses of str.  These do not correspond
directly to terminal objects in the formal grammar, but are instead more
practical higher level combinations of true terminals.

All TokenList and Terminal objects have a 'value' attribute, which produces the
semantically meaningful value of that part of the parse subtree.  The value of
all whitespace tokens (no matter how many sub-tokens they may contain) is a
single space, as per the RFC rules.  This includes 'CFWS', which is herein
included in the general class of whitespace tokens.  There is one exception to
the rule that whitespace tokens are collapsed into single spaces in values: in
the value of a 'bare-quoted-string' (a quoted-string with no leading or
trailing whitespace), any whitespace that appeared between the quotation marks
is preserved in the returned value.  Note that in all Terminal strings quoted
pairs are turned into their unquoted values.

All TokenList and Terminal objects also have a string value, which attempts to
be a "canonical" representation of the RFC-compliant form of the substring that
produced the parsed subtree, including minimal use of quoted pair quoting.
Whitespace runs are not collapsed.

Comment tokens also have a 'content' attribute providing the string found
between the parens (including any nested comments) with whitespace preserved.

All TokenList and Terminal objects have a 'defects' attribute which is a
possibly empty list all of the defects found while creating the token.  Defects
may appear on any token in the tree, and a composite list of all defects in the
subtree is available through the 'all_defects' attribute of any node.  (For
Terminal notes x.defects == x.all_defects.)

Each object in a parse tree is called a 'token', and each has a 'token_type'
attribute that gives the name from the RFC 5322 grammar that it represents.
Not all RFC 5322 nodes are produced, and there is one non-RFC 5322 node that
may be produced: 'ptext'.  A 'ptext' is a string of printable ascii characters.
It is returned in place of lists of (ctext/quoted-pair) and
(qtext/quoted-pair).

XXX: provide complete list of token types.
�N)�	hexdigits)�OrderedDict)�
itemgetter)�_encoded_words)�errors)�utilsz 	�(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%�
�
cCs dt|�jdd�jdd�dS)N�"�\z\\z\")�str�replace)�value�r�2/usr/lib64/python3.6/email/_header_value_parser.py�quote_stringbsrcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd�Ze	d	d
��Z
e	dd��Zd
d�Ze	dd��Z
e	dd��Zdd�Zddd�Zddd�Zddd�Z�ZS)�	TokenListNTcst�j||�g|_dS)N)�super�__init__�defects)�self�args�kw)�	__class__rrroszTokenList.__init__cCsdjdd�|D��S)N�css|]}t|�VqdS)N)r)�.0�xrrr�	<genexpr>tsz$TokenList.__str__.<locals>.<genexpr>)�join)rrrr�__str__sszTokenList.__str__csdj|jjt�j��S)Nz{}({}))�formatr�__name__r�__repr__)r)rrrr%vs
zTokenList.__repr__cCsdjdd�|D��S)Nrcss|]}|jr|jVqdS)N)r)rrrrrr |sz"TokenList.value.<locals>.<genexpr>)r!)rrrrrzszTokenList.valuecCstdd�|D�|j�S)Ncss|]}|jVqdS)N)�all_defects)rrrrrr �sz(TokenList.all_defects.<locals>.<genexpr>)�sumr)rrrrr&~szTokenList.all_defectscCs|dj�S)Nr)�startswith_fws)rrrrr(�szTokenList.startswith_fwscCstdd�|D��S)zATrue if all top level tokens of this part may be RFC2047 encoded.css|]}|jVqdS)N)�
as_ew_allowed)r�partrrrr �sz*TokenList.as_ew_allowed.<locals>.<genexpr>)�all)rrrrr)�szTokenList.as_ew_allowedcCs"g}x|D]}|j|j�q
W|S)N)�extend�comments)rr-�tokenrrrr-�s
zTokenList.commentscCst||d�S)N)�policy)�_refold_parse_tree)rr/rrr�fold�szTokenList.foldrcCst|j|d��dS)N)�indent)�print�ppstr)rr2rrr�pprint�szTokenList.pprintcCsdj|j|d��S)Nr)r2)r!�_pp)rr2rrrr4�szTokenList.ppstrccs~dj||jj|j�Vx<|D]4}t|d�s<|dj|�Vq|j|d�EdHqW|jrhdj|j�}nd}dj||�VdS)Nz{}{}/{}(r6z*    !! invalid element in token list: {!r}z    z Defects: {}rz{}){})r#rr$�
token_type�hasattrr6r)rr2r.Zextrarrrr6�s


z
TokenList._pp)r)r)r)r$�
__module__�__qualname__r7�syntactic_break�ew_combine_allowedrr"r%�propertyrr&r(r)r-r1r5r4r6�
__classcell__rr)rrris

rc@s$eZdZedd��Zedd��ZdS)�WhiteSpaceTokenListcCsdS)N� r)rrrrr�szWhiteSpaceTokenList.valuecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)�comment)r7�content)rrrrr�
<listcomp>�sz0WhiteSpaceTokenList.comments.<locals>.<listcomp>r)rrrrr-�szWhiteSpaceTokenList.commentsN)r$r9r:r=rr-rrrrr?�sr?c@seZdZdZdS)�UnstructuredTokenList�unstructuredN)r$r9r:r7rrrrrD�srDc@seZdZdZdS)�Phrase�phraseN)r$r9r:r7rrrrrF�srFc@seZdZdZdS)�WordZwordN)r$r9r:r7rrrrrH�srHc@seZdZdZdS)�CFWSList�cfwsN)r$r9r:r7rrrrrI�srIc@seZdZdZdS)�Atom�atomN)r$r9r:r7rrrrrK�srKc@seZdZdZdZdS)�Tokenr.FN)r$r9r:r7Zencode_as_ewrrrrrM�srMc@seZdZdZdZdZdZdS)�EncodedWordzencoded-wordN)r$r9r:r7�cte�charset�langrrrrrN�srNc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�QuotedStringz
quoted-stringcCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rrrrrrB�s

zQuotedString.contentcCsBg}x2|D]*}|jdkr(|jt|��q
|j|j�q
Wdj|�S)Nzbare-quoted-stringr)r7�appendrrr!)r�resrrrr�quoted_value�s

zQuotedString.quoted_valuecCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rr.rrr�stripped_value�s

zQuotedString.stripped_valueN)r$r9r:r7r=rBrUrVrrrrrR�s
rRc@s$eZdZdZdd�Zedd��ZdS)�BareQuotedStringzbare-quoted-stringcCstdjdd�|D���S)Nrcss|]}t|�VqdS)N)r)rrrrrr �sz+BareQuotedString.__str__.<locals>.<genexpr>)rr!)rrrrr"�szBareQuotedString.__str__cCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz)BareQuotedString.value.<locals>.<genexpr>)r!)rrrrr�szBareQuotedString.valueN)r$r9r:r7r"r=rrrrrrW�srWc@s8eZdZdZdd�Zdd�Zedd��Zedd	��Zd
S)�CommentrAcs(djtdg�fdd��D�dggg��S)Nrrcsg|]}�j|��qSr)�quote)rr)rrrrCsz#Comment.__str__.<locals>.<listcomp>�))r!r')rr)rrr"s
zComment.__str__cCs2|jdkrt|�St|�jdd�jdd�jdd�S)NrArz\\rz\(rZz\))r7rr)rrrrrrYs

z
Comment.quotecCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz"Comment.content.<locals>.<genexpr>)r!)rrrrrBszComment.contentcCs|jgS)N)rB)rrrrr-szComment.commentsN)	r$r9r:r7r"rYr=rBr-rrrrrXs
rXc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressListzaddress-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)�address)r7)rrrrrrC$sz)AddressList.addresses.<locals>.<listcomp>r)rrrr�	addresses"szAddressList.addressescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�	mailboxes)rrrrrr (sz(AddressList.mailboxes.<locals>.<genexpr>)r')rrrrr^&szAddressList.mailboxescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�
all_mailboxes)rrrrrr -sz,AddressList.all_mailboxes.<locals>.<genexpr>)r')rrrrr_+szAddressList.all_mailboxesN)r$r9r:r7r=r]r^r_rrrrr[sr[c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�Addressr\cCs|djdkr|djSdS)Nr�group)r7�display_name)rrrrrb5szAddress.display_namecCs4|djdkr|dgS|djdkr*gS|djS)Nr�mailboxzinvalid-mailbox)r7r^)rrrrr^:s

zAddress.mailboxescCs:|djdkr|dgS|djdkr0|dgS|djS)Nrrczinvalid-mailbox)r7r_)rrrrr_Bs


zAddress.all_mailboxesN)r$r9r:r7r=rbr^r_rrrrr`1sr`c@s(eZdZdZedd��Zedd��ZdS)�MailboxListzmailbox-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc)r7)rrrrrrCPsz)MailboxList.mailboxes.<locals>.<listcomp>r)rrrrr^NszMailboxList.mailboxescCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc�invalid-mailbox)rcre)r7)rrrrrrCTsz-MailboxList.all_mailboxes.<locals>.<listcomp>r)rrrrr_RszMailboxList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrdJsrdc@s(eZdZdZedd��Zedd��ZdS)�	GroupListz
group-listcCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r^)rrrrr^\szGroupList.mailboxescCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r_)rrrrr_bszGroupList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrfXsrfc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�GroupracCs|djdkrgS|djS)N�z
group-list)r7r^)rrrrr^mszGroup.mailboxescCs|djdkrgS|djS)Nrhz
group-list)r7r_)rrrrr_sszGroup.all_mailboxescCs
|djS)Nr)rb)rrrrrbyszGroup.display_nameN)r$r9r:r7r=r^r_rbrrrrrgisrgc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�NameAddrz	name-addrcCst|�dkrdS|djS)N�r)�lenrb)rrrrrb�szNameAddr.display_namecCs
|djS)Nrj���)�
local_part)rrrrrm�szNameAddr.local_partcCs
|djS)Nrjrl)�domain)rrrrrn�szNameAddr.domaincCs
|djS)Nrjrl)�route)rrrrro�szNameAddr.routecCs
|djS)Nrjrl)�	addr_spec)rrrrrp�szNameAddr.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrri~sric@s@eZdZdZedd��Zedd��Zedd��Zedd	��Zd
S)�	AngleAddrz
angle-addrcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rm)rrrrrrm�s

zAngleAddr.local_partcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rn)rrrrrrn�s

zAngleAddr.domaincCs"x|D]}|jdkr|jSqWdS)Nz	obs-route)r7�domains)rrrrrro�s

zAngleAddr.routecCs<x6|D]*}|jdkr|jr |jSt|j�|jSqWdSdS)Nz	addr-specz<>)r7rmrpr)rrrrrrp�s

zAngleAddr.addr_specN)	r$r9r:r7r=rmrnrorprrrrrq�s
rqc@seZdZdZedd��ZdS)�ObsRoutez	obs-routecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)rn)r7rn)rrrrrrC�sz$ObsRoute.domains.<locals>.<listcomp>r)rrrrrr�szObsRoute.domainsN)r$r9r:r7r=rrrrrrrs�srsc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�MailboxrccCs|djdkr|djSdS)Nrz	name-addr)r7rb)rrrrrb�szMailbox.display_namecCs
|djS)Nr)rm)rrrrrm�szMailbox.local_partcCs
|djS)Nr)rn)rrrrrn�szMailbox.domaincCs|djdkr|djSdS)Nrz	name-addr)r7ro)rrrrro�sz
Mailbox.routecCs
|djS)Nr)rp)rrrrrp�szMailbox.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrrt�srtc@s,eZdZdZedd��ZeZZZZ	dS)�InvalidMailboxzinvalid-mailboxcCsdS)Nr)rrrrrb�szInvalidMailbox.display_nameN)
r$r9r:r7r=rbrmrnrorprrrrru�srucs(eZdZdZdZe�fdd��Z�ZS)�DomainrnFcsdjt�jj��S)Nr)r!rr�split)r)rrrrn�sz
Domain.domain)r$r9r:r7r)r=rnr>rr)rrrv�srvc@seZdZdZdS)�DotAtomzdot-atomN)r$r9r:r7rrrrrx�srxc@seZdZdZdZdS)�DotAtomTextz
dot-atom-textTN)r$r9r:r7r)rrrrry�sryc@sDeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dS)�AddrSpecz	addr-specFcCs
|djS)Nr)rm)rrrrrmszAddrSpec.local_partcCst|�dkrdS|djS)N�rjrl)rkrn)rrrrrnszAddrSpec.domaincCs<t|�dkr|djS|djj�|dj|djj�S)Nr{rrjrh)rkr�rstrip�lstrip)rrrrrs
zAddrSpec.valuecCsLt|j�}t|�t|t�kr*t|j�}n|j}|jdk	rH|d|jS|S)N�@)�setrmrk�
DOT_ATOM_ENDSrrn)rZnamesetZlprrrrps

zAddrSpec.addr_specN)
r$r9r:r7r)r=rmrnrrprrrrrz�srzc@seZdZdZdZdS)�ObsLocalPartzobs-local-partFN)r$r9r:r7r)rrrrr� sr�cs4eZdZdZdZedd��Ze�fdd��Z�ZS)�DisplayNamezdisplay-nameFcCs�t|�}|djdkr"|jd�n*|ddjdkrLt|ddd��|d<|djdkrd|j�n*|ddjdkr�t|ddd��|d	<|jS)
NrrJrjrlrlrlrlrlrl)rr7�popr)rrTrrrrb+s
zDisplayName.display_namecs�d}|jrd}nx|D]}|jdkrd}qW|r�d}}|djdksX|ddjdkr\d}|d	jdks||d
djdkr�d}|t|j�|St�jSdS)NFTz
quoted-stringrrrJr@rjrlrlrl)rr7rrbrr)rrYrZpreZpost)rrrr:s

  zDisplayName.value)	r$r9r:r7r<r=rbrr>rr)rrr�&sr�c@s,eZdZdZdZedd��Zedd��ZdS)�	LocalPartz
local-partFcCs&|djdkr|djS|djSdS)Nrz
quoted-string)r7rUr)rrrrrSs
zLocalPart.valuecCs�tg}t}d}x�|dtgD]�}|jdkr.q|r^|jdkr^|djdkr^t|dd��|d<t|t�}|r�|jdkr�|djdkr�|jt|dd���n
|j|�|d	}|}qWt|dd
��}|jS)NFrrJ�dotrjrlrlrlrlrl)�DOTr7r�
isinstancerSr)rrTZlastZ
last_is_tl�tokZis_tlrrrrmZs$


zLocalPart.local_partN)r$r9r:r7r)r=rrmrrrrr�Nsr�cs4eZdZdZdZe�fdd��Zedd��Z�ZS)�
DomainLiteralzdomain-literalFcsdjt�jj��S)Nr)r!rrrw)r)rrrrnwszDomainLiteral.domaincCs"x|D]}|jdkr|jSqWdS)N�ptext)r7r)rrrrr�ip{s

zDomainLiteral.ip)	r$r9r:r7r)r=rnr�r>rr)rrr�rsr�c@seZdZdZdZdZdS)�MIMEVersionzmime-versionN)r$r9r:r7�major�minorrrrrr��sr�c@s4eZdZdZdZdZdZedd��Zedd��Z	dS)	�	Parameter�	parameterFzus-asciicCs|jr|djSdS)Nrjr)�	sectioned�number)rrrr�section_number�szParameter.section_numbercCsbx\|D]T}|jdkr|jS|jdkrx4|D],}|jdkr*x|D]}|jdkr>|jSq>Wq*WqWdS)Nrz
quoted-stringzbare-quoted-stringr)r7rV)rr.rrr�param_value�s






zParameter.param_valueN)
r$r9r:r7r��extendedrPr=r�r�rrrrr��sr�c@seZdZdZdS)�InvalidParameterzinvalid-parameterN)r$r9r:r7rrrrr��sr�c@seZdZdZedd��ZdS)�	Attribute�	attributecCs$x|D]}|jjd�r|jSqWdS)N�attrtext)r7�endswithr)rr.rrrrV�s
zAttribute.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@seZdZdZdZdS)�Section�sectionN)r$r9r:r7r�rrrrr��sr�c@seZdZdZedd��ZdS)�ValuercCs2|d}|jdkr|d}|jjd�r,|jS|jS)NrrJrj�
quoted-stringr��extended-attribute)r�r�r�)r7r�rVr)rr.rrrrV�s
zValue.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@s(eZdZdZdZedd��Zdd�ZdS)�MimeParameterszmime-parametersFccs�t�}x\|D]T}|jjd�sq|djdkr.q|djj�}||krLg||<||j|j|f�qW�x�|j�D�]�\}}t|t	d�d�}|dd}|j
}|jr�t|�dkr�|dddkr�|ddj
jtjd��|dd�}g}d}x�|D]�\}	}
|	|k�r6|
j�s$|
j
jtjd��q�n|
j
jtjd��|d7}|
j}|
j�r�ytjj|�}Wn&tk
�r�tjj|d	d
�}YnRXy|j|d�}Wn"tk
�r�|jdd�}YnXtj|��r�|
j
jtj��|j|�q�Wd
j|�}||fVqpWdS)Nr�rr�)�keyrjz.duplicate parameter name; duplicate(s) ignoredz+duplicate parameter name; duplicate ignoredz(inconsistent RFC2231 parameter numberingzlatin-1)�encoding�surrogateescapezus-asciir)rr7r�r�striprSr��items�sortedrrPr�rkrr�InvalidHeaderDefectr��urllib�parseZunquote_to_bytes�UnicodeEncodeErrorZunquote�decode�LookupErrorr�_has_surrogates�UndecodableBytesDefectr!)r�paramsr.�name�partsZfirst_paramrPZvalue_parts�ir��paramrrrrr��sZ




zMimeParameters.paramscCsXg}x8|jD].\}}|r0|jdj|t|���q|j|�qWdj|�}|rTd|SdS)Nz{}={}z; r@r)r�rSr#rr!)rr�r�rrrrr"s
zMimeParameters.__str__N)r$r9r:r7r;r=r�r"rrrrr��sFr�c@seZdZdZedd��ZdS)�ParameterizedHeaderValueFcCs&x t|�D]}|jdkr
|jSq
WiS)Nzmime-parameters)�reversedr7r�)rr.rrrr�%s

zParameterizedHeaderValue.paramsN)r$r9r:r;r=r�rrrrr�sr�c@seZdZdZdZdZdZdS)�ContentTypezcontent-typeF�textZplainN)r$r9r:r7r)�maintype�subtyperrrrr�-sr�c@seZdZdZdZdZdS)�ContentDispositionzcontent-dispositionFN)r$r9r:r7r)�content_dispositionrrrrr�5sr�c@seZdZdZdZdZdS)�ContentTransferEncodingzcontent-transfer-encodingFZ7bitN)r$r9r:r7r)rOrrrrr�<sr�c@seZdZdZdZdS)�HeaderLabelzheader-labelFN)r$r9r:r7r)rrrrr�Csr�c@seZdZdZdS)�Header�headerN)r$r9r:r7rrrrr�Isr�csreZdZdZdZdZ�fdd�Z�fdd�Zdd�Ze	dd	��Z
d�fdd�	Zd
d�Ze	dd��Z
dd�Z�ZS)�TerminalTcst�j||�}||_g|_|S)N)r�__new__r7r)�clsrr7r)rrrr�XszTerminal.__new__csdj|jjt�j��S)Nz{}({}))r#rr$rr%)r)rrrr%^szTerminal.__repr__cCst|jjd|j�dS)N�/)r3rr$r7)rrrrr5aszTerminal.pprintcCs
t|j�S)N)�listr)rrrrr&dszTerminal.all_defectsrcs2dj||jj|jt�j�|js"dn
dj|j��gS)Nz
{}{}/{}({}){}rz {})r#rr$r7rr%r)rr2)rrrr6hszTerminal._ppcCsdS)Nr)rrrr�pop_trailing_wsqszTerminal.pop_trailing_wscCsgS)Nr)rrrrr-uszTerminal.commentscCst|�|jfS)N)rr7)rrrr�__getnewargs__yszTerminal.__getnewargs__)r)r$r9r:r)r<r;r�r%r5r=r&r6r�r-r�r>rr)rrr�Rs	r�c@s eZdZedd��Zdd�ZdS)�WhiteSpaceTerminalcCsdS)Nr@r)rrrrrszWhiteSpaceTerminal.valuecCsdS)NTr)rrrrr(�sz!WhiteSpaceTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr�}sr�c@s eZdZedd��Zdd�ZdS)�
ValueTerminalcCs|S)Nr)rrrrr�szValueTerminal.valuecCsdS)NFr)rrrrr(�szValueTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr��sr�c@s eZdZedd��Zdd�ZdS)�EWWhiteSpaceTerminalcCsdS)Nrr)rrrrr�szEWWhiteSpaceTerminal.valuecCsdS)Nrr)rrrrr"�szEWWhiteSpaceTerminal.__str__N)r$r9r:r=rr"rrrrr��sr�r��,zlist-separatorr~zroute-component-markerz([{}]+)rz[^{}]+rz\\�]z\]z[\x00-\x20\x7F]cCs>t|�}|r|jjtj|��tj|�r:|jjtjd��dS)z@If input token contains ASCII non-printables, register a defect.z*Non-ASCII characters found in header tokenN)�_non_printable_finderrrSrZNonPrintableDefectrr�r�)�xtextZnon_printablesrrr�_validate_xtext�s

r�cCs�t|d�^}}g}d}d}xbtt|��D]J}||dkrL|rFd}d}nd}q(|rVd}n|||krdP|j||�q(W|d}dj|�dj||d�g|�|fS)akScan printables/quoted-pairs until endchars and return unquoted ptext.

    This function turns a run of qcontent, ccontent-without-comments, or
    dtext-with-quoted-printables into a single string by unquoting any
    quoted printables.  It returns the string, the remaining value, and
    a flag that is True iff there were any quoted printables decoded.

    rjFrTrN)�
_wsp_splitter�rangerkrSr!)r�endcharsZfragment�	remainderZvchars�escape�had_qp�posrrr�_get_ptext_to_endchars�s$	r�cCs.|j�}t|dt|�t|��d�}||fS)z�FWS = 1*WSP

    This isn't the RFC definition.  We're using fws to represent tokens where
    folding can be done, but when we are parsing the *un*folding has already
    been done so we don't need to watch out for CRLF.

    N�fws)r}r�rk)rZnewvaluer�rrr�get_fws�sr�c
Cs�t�}|jd�s tjdj|���|dd�jdd�^}}||dd�krXtjdj|���dj|�}t|�dkr�|dtkr�|dtkr�|jdd�^}}|d|}t|j��dkr�|j	j
tjd	��||_dj|�}yt
jd|d�\}}}}	Wn(tk
�rtjd
j|j���YnX||_||_|j	j|	�xh|�r�|dtk�rdt|�\}
}|j
|
��q6t|d�^}}t|d�}t|�|j
|�dj|�}�q6W||fS)zE encoded-word = "=?" charset "?" encoding "?" encoded-text "?="

    z=?z"expected encoded word but found {}rhNz?=rjrrzwhitespace inside encoded wordz!encoded word format invalid: '{}'�vtext)rN�
startswithr�HeaderParseErrorr#rwr!rkrrrSr�rO�_ewr��
ValueErrorrPrQr,�WSPr�r�r�r�)
r�ewr�r�Zremstr�restr�rPrQrr.�charsr�rrr�get_encoded_word�sH

$




r�cCst�}�x|�r|dtkr4t|�\}}|j|�q
|jd�r�yt|�\}}Wntjk
rdYnrXd}t|�dkr�|dj	dkr�|j
jtjd��d}|r�t|�dkr�|d
j	d	kr�t|dd�|d<|j|�q
t
|d�^}}t|d
�}t|�|j|�dj|�}q
W|S)aOunstructured = (*([FWS] vchar) *WSP) / obs-unstruct
       obs-unstruct = *((*LF *CR *(obs-utext) *LF *CR)) / FWS)
       obs-utext = %d0 / obs-NO-WS-CTL / LF / CR

       obs-NO-WS-CTL is control characters except WSP/CR/LF.

    So, basically, we have printable runs, plus control characters or nulls in
    the obsolete syntax, separated by whitespace.  Since RFC 2047 uses the
    obsolete syntax in its specification, but requires whitespace on either
    side of the encoded words, I can see no reason to need to separate the
    non-printable-non-whitespace from the printable runs if they occur, so we
    parse this into xtext tokens separated by WSP tokens.

    Because an 'unstructured' value must by definition constitute the entire
    value, this 'get' routine does not return a remaining value, only the
    parsed TokenList.

    rz=?Trjr�z&missing whitespace before encoded wordFrhzencoded-wordr�rrl���rlrl)rDr�r�rSr�r�rr�rkr7rr�r�r�r�r�r!)rrEr.Zhave_wsr�r�r�rrr�get_unstructured!s:






r�cCs*t|d�\}}}t|d�}t|�||fS)actext = <printable ascii except \ ( )>

    This is not the RFC ctext, since we are handling nested comments in comment
    and unquoting quoted-pairs here.  We allow anything except the '()'
    characters, but if we find any ASCII other than the RFC defined printable
    ASCII, a NonPrintableDefect is added to the token's defects list.  Since
    quoted pairs are converted to their unquoted values, what is returned is
    a 'ptext' token.  In this case it is a WhiteSpaceTerminal, so it's value
    is ' '.

    z()r�)r�r�r�)rr��_rrr�get_qp_ctextYs
r�cCs*t|d�\}}}t|d�}t|�||fS)aoqcontent = qtext / quoted-pair

    We allow anything except the DQUOTE character, but if we find any ASCII
    other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Any quoted pairs are converted to their
    unquoted values, so what is returned is a 'ptext' token.  In this case it
    is a ValueTerminal.

    r
r�)r�r�r�)rr�r�rrr�get_qcontentjs

r�cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)z�atext = <matches _atext_matcher>

    We allow any non-ATOM_ENDS in atext, but add an InvalidATextDefect to
    the token's defects list if we find non-atext characters.
    zexpected atext but found '{}'N�atext)�_non_atom_end_matcherrr�r#rarkr�r�)r�mr�rrr�	get_atextys
r�cCs|ddkrtjdj|���t�}|dd�}|ddkrPt|�\}}|j|�x�|r�|ddkr�|dtkr|t|�\}}nd|dd�dkr�y"t|�\}}|j	jtj
d��Wq�tjk
r�t|�\}}Yq�Xnt|�\}}|j|�qRW|�s|j	jtj
d	��||fS||dd�fS)
z�bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE

    A quoted-string without the leading or trailing white space.  Its
    value is the text between the quote marks, with whitespace
    preserved and quoted pairs decoded.
    rr
zexpected '"' but found '{}'rjNrhz=?z!encoded word inside quoted stringz"end of header inside quoted string)rr�r#rWr�rSr�r�r�rr�)rZbare_quoted_stringr.rrr�get_bare_quoted_string�s2


r�cCs�|r |ddkr tjdj|���t�}|dd�}x^|r�|ddkr�|dtkr^t|�\}}n&|ddkrxt|�\}}nt|�\}}|j|�q4W|s�|j	jtj
d��||fS||dd�fS)z�comment = "(" *([FWS] ccontent) [FWS] ")"
       ccontent = ctext / quoted-pair / comment

    We handle nested comments here, and quoted-pair in our qp-ctext routine.
    rrzexpected '(' but found '{}'rjNrZzend of header inside comment)rr�r#rXr�r��get_commentr�rSrr�)rrAr.rrrr��s"
r�cCsTt�}xD|rJ|dtkrJ|dtkr2t|�\}}nt|�\}}|j|�qW||fS)z,CFWS = (1*([FWS] comment) [FWS]) / FWS

    r)rI�CFWS_LEADERr�r�r�rS)rrJr.rrr�get_cfws�sr�cCspt�}|r,|dtkr,t|�\}}|j|�t|�\}}|j|�|rh|dtkrht|�\}}|j|�||fS)z�quoted-string = [CFWS] <bare-quoted-string> [CFWS]

    'bare-quoted-string' is an intermediate class defined by this
    parser and not by the RFC grammar.  It is the quoted string
    without any attached CFWS.
    r)rRr�r�rSr�)rZ
quoted_stringr.rrr�get_quoted_string�s


r�cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���|jd�r�yt	|�\}}Wq�tjk
r�t
|�\}}Yq�Xnt
|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)zPatom = [CFWS] 1*atext [CFWS]

    An atom could be an rfc2047 encoded word.
    rzexpected atom but found '{}'z=?)rKr�r�rS�	ATOM_ENDSrr�r#r�r�r�)rrLr.rrr�get_atom�s$



r�cCs�t�}|s|dtkr(tjdj|���xP|rx|dtkrxt|�\}}|j|�|r*|ddkr*|jt�|dd�}q*W|dtkr�tjdjd|���||fS)z( dot-text = 1*atext *("." 1*atext)

    rz8expected atom at a start of dot-atom-text but found '{}'r	rjNz4expected atom at end of dot-atom-text but found '{}'rl)ryr�rr�r#r�rSr�)rZ
dot_atom_textr.rrr�get_dot_atom_text�s

r�cCs�t�}|dtkr(t|�\}}|j|�|jd�rhyt|�\}}Wqttjk
rdt|�\}}YqtXnt|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)z� dot-atom = [CFWS] dot-atom-text [CFWS]

    Any place we can have a dot atom, we could instead have an rfc2047 encoded
    word.
    rz=?)	rxr�r�rSr�r�rr�r�)rZdot_atomr.rrr�get_dot_atoms



r�cCs�|dtkrt|�\}}nd}|ddkr8t|�\}}n*|dtkrVtjdj|���nt|�\}}|dk	rx|g|dd�<||fS)a�word = atom / quoted-string

    Either atom or quoted-string may start with CFWS.  We have to peel off this
    CFWS first to determine which type of word to parse.  Afterward we splice
    the leading CFWS, if any, into the parsed sub-token.

    If neither an atom or a quoted-string is found before the next special, a
    HeaderParseError is raised.

    The token returned is either an Atom or a QuotedString, as appropriate.
    This means the 'word' level of the formal grammar is not represented in the
    parse tree; this is because having that extra layer when manipulating the
    parse tree is more confusing than it is helpful.

    rNr
z1Expected 'atom' or 'quoted-string' but found '{}')r�r�r��SPECIALSrr�r#r�)r�leaderr.rrr�get_word*s
r�cCs�t�}yt|�\}}|j|�Wn(tjk
rH|jjtjd��YnXx�|r�|dtkr�|ddkr�|jt�|jjtj	d��|dd�}qLyt|�\}}WnDtjk
r�|dt
kr�t|�\}}|jjtj	d��n�YnX|j|�qLW||fS)a� phrase = 1*word / obs-phrase
        obs-phrase = word *(word / "." / CFWS)

    This means a phrase can be a sequence of words, periods, and CFWS in any
    order as long as it starts with at least one word.  If anything other than
    words is detected, an ObsoleteHeaderDefect is added to the token's defect
    list.  We also accept a phrase that starts with CFWS followed by a dot;
    this is registered as an InvalidHeaderDefect, since it is not supported by
    even the obsolete grammar.

    zphrase does not start with wordrr	zperiod in 'phrase'rjNzcomment found without atom)rFr�rSrr�rr��PHRASE_ENDSr��ObsoleteHeaderDefectr�r�)rrGr.rrr�
get_phraseIs.




r�cCstt�}d}|dtkr"t|�\}}|s6tjdj|���yt|�\}}Wn^tjk
r�yt|�\}}Wn6tjk
r�|ddkr�|dtkr��t	�}YnXYnX|dk	r�|g|dd�<|j
|�|o�|ddks�|dtk�r2tt|�|�\}}|j
dk�r|jj
tjd��n|jj
tjd��||d<y|jjd�Wn(tk
�rj|jj
tjd	��YnX||fS)
z= local-part = dot-atom / quoted-string / obs-local-part

    Nrz"expected local-part but found '{}'rzinvalid-obs-local-partz<local-part is not dot-atom, quoted-string, or obs-local-partz,local-part is not a dot-atom (contains CFWS)�asciiz)local-part contains non-ASCII characters))r�r�r�rr�r#r�r�r�rrS�get_obs_local_partrr7rr�r�r�encoder�ZNonASCIILocalPartDefect)rrmr�r.�obs_local_partrrr�get_local_partosB




r�cCs�t�}d}�x|o(|ddks,|dtk�r*|ddkrl|rN|jjtjd��|jt�d}|dd�}qnD|ddkr�|jt|dd	��|dd�}|jjtjd
��d}q|r�|djdkr�|jjtjd��yt	|�\}}d}Wn4tj
k
�r|dtk�r�t|�\}}YnX|j|�qW|djdk�s\|djd
k�rn|djdk�rn|jjtjd��|djdk�s�|djd
k�r�|djdk�r�|jjtjd��|j�r�d|_||fS)z' obs-local-part = word *("." word)
    Frrr	zinvalid repeated '.'TrjNzmisplaced-specialz/'\' character outside of quoted-string/ccontentr�zmissing '.' between wordsrJz!Invalid leading '.' in local partrhz"Invalid trailing '.' in local partzinvalid-obs-local-partrlrlrlr�)
r�r�rrSrr�r�r�r7r�r�r�r�)rr�Zlast_non_ws_was_dotr.rrrr��sV"





r�cCs@t|d�\}}}t|d�}|r0|jjtjd��t|�||fS)a dtext = <printable ascii except \ [ ]> / obs-dtext
        obs-dtext = obs-NO-WS-CTL / quoted-pair

    We allow anything except the excluded characters, but if we find any
    ASCII other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Quoted pairs are converted to their
    unquoted values, so what is returned is a ptext token, in this case a
    ValueTerminal.  If there were quoted-printables, an ObsoleteHeaderDefect is
    added to the returned token's defect list.

    z[]r�z(quoted printable found in domain-literal)r�r�rrSrr�r�)rr�r�rrr�	get_dtext�s

rcCs,|rdS|jtjd��|jtdd��dS)NFz"end of input inside domain-literalr�zdomain-literal-endT)rSrr�r�)r�domain_literalrrr�_check_for_early_dl_end�srcCslt�}|dtkr(t|�\}}|j|�|s6tjd��|ddkrRtjdj|���|dd�}t||�rp||fS|jtdd��|dt	kr�t
|�\}}|j|�t|�\}}|j|�t||�r�||fS|dt	kr�t
|�\}}|j|�t||��r||fS|ddk�rtjd	j|���|jtdd
��|dd�}|�rd|dtk�rdt|�\}}|j|�||fS)zB domain-literal = [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]

    rzexpected domain-literal�[z6expected '[' at start of domain-literal but found '{}'rjNzdomain-literal-startr�z4expected ']' at end of domain-literal but found '{}'zdomain-literal-end)r�r�r�rSrr�r#rr�r�r�r)rrr.rrr�get_domain_literal�sD







rcCstt�}d}|dtkr"t|�\}}|s6tjdj|���|ddkrvt|�\}}|dk	rd|g|dd�<|j|�||fSyt|�\}}Wn"tjk
r�t	|�\}}YnX|r�|ddkr�tjd��|dk	r�|g|dd�<|j|�|o�|ddk�rl|j
jtjd��|djd	k�r(|d|dd�<xB|�rj|ddk�rj|jt
�t	|d
d��\}}|j|��q*W||fS)z] domain = dot-atom / domain-literal / obs-domain
        obs-domain = atom *("." atom))

    Nrzexpected domain but found '{}'rr~zInvalid Domainr	z(domain is not a dot-atom (contains CFWS)zdot-atomrj)rvr�r�rr�r#rrSr�r�rr�r7r�)rrnr�r.rrr�
get_domains@




rcCs~t�}t|�\}}|j|�|s.|ddkrH|jjtjd��||fS|jtdd��t|dd��\}}|j|�||fS)z( addr-spec = local-part "@" domain

    rr~z"add-spec local part with no domainzaddress-at-symbolrjN)rzr�rSrrr�r�r)rrpr.rrr�
get_addr_spec.s


rcCs�t�}xf|rl|ddks$|dtkrl|dtkrHt|�\}}|j|�q|ddkr|jt�|dd�}qW|s�|ddkr�tjdj|���|jt�t	|dd��\}}|j|�x�|o�|ddk�rB|jt�|dd�}|s�P|dtk�rt|�\}}|j|�|ddkr�|jt�t	|dd��\}}|j|�q�W|�sTtjd��|ddk�rrtjd	j|���|jt
dd
��||dd�fS)z� obs-route = obs-domain-list ":"
        obs-domain-list = *(CFWS / ",") "@" domain *("," [CFWS] ["@" domain])

        Returns an obs-route token with the appropriate sub-tokens (that is,
        there is no obs-domain-list in the parse tree).
    rr�rjNr~z(expected obs-route domain but found '{}'z%end of header while parsing obs-route�:z4expected ':' marking end of obs-route but found '{}'zend-of-obs-route-marker)rsr�r�rS�
ListSeparatorrr�r#�RouteComponentMarkerrr�)rZ	obs_router.rrr�
get_obs_route>sB






r
cCs�t�}|dtkr(t|�\}}|j|�|s:|ddkrJtjdj|���|jtdd��|dd�}|ddkr�|jtdd��|jjtj	d	��|dd�}||fSyt
|�\}}Wnztjk
�r2y"t|�\}}|jjtjd
��Wn(tjk
�rtjdj|���YnX|j|�t
|�\}}YnX|j|�|�r`|ddk�r`|dd�}n|jjtj	d��|jtdd��|�r�|dtk�r�t|�\}}|j|�||fS)
z� angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
        obs-angle-addr = [CFWS] "<" obs-route addr-spec ">" [CFWS]

    r�<z"expected angle-addr but found '{}'zangle-addr-startrjN�>zangle-addr-endznull addr-spec in angle-addrz*obsolete route specification in angle-addrz.expected addr-spec or obs-route but found '{}'z"missing trailing '>' on angle-addr)
rqr�r�rSrr�r#r�rr�rr
r�)rZ
angle_addrr.rrr�get_angle_addrgsJ






r
cCs<t�}t|�\}}|j|dd��|jdd�|_||fS)z� display-name = phrase

    Because this is simply a name-rule, we don't return a display-name
    token containing a phrase, but rather a display-name token with
    the content of the phrase.

    N)r�r�r,r)rrbr.rrr�get_display_name�s
rcCs�t�}d}|dtkr6t|�\}}|s6tjdj|���|ddkr�|dtkr^tjdj|���t|�\}}|s~tjdj|���|dk	r�|g|ddd�<d}|j|�t	|�\}}|dk	r�|g|dd�<|j|�||fS)z, name-addr = [display-name] angle-addr

    Nrz!expected name-addr but found '{}'r)
rir�r�rr�r#r�rrSr
)rZ	name_addrr�r.rrr�
get_name_addr�s0

rcCs�t�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnXtdd�|jD��r�d|_|j	|�||fS)z& mailbox = name-addr / addr-spec

    zexpected mailbox but found '{}'css|]}t|tj�VqdS)N)r�rr�)rrrrrr �szget_mailbox.<locals>.<genexpr>zinvalid-mailbox)
rtrrr�rr#�anyr&r7rS)rrcr.rrr�get_mailbox�s
rcCsht�}xX|r^|d|kr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)z� Read everything up to one of the chars in endchars.

    This is outside the formal grammar.  The InvalidMailbox TokenList that is
    returned acts like a Mailbox, but the data attributes are None.

    rzmisplaced-specialrjN)rur�rSr�r�)rr�Zinvalid_mailboxr.rrr�get_invalid_mailbox�srcCs�t�}�x�|o|ddk�r�yt|�\}}|j|�W�ntjk
�r@d}|dtkr�t|�\}}|sz|ddkr�|j|�|jjtjd��n@t	|d�\}}|dk	r�|g|dd�<|j|�|jjtj
d��nb|ddkr�|jjtjd��nBt	|d�\}}|dk	�r |g|dd�<|j|�|jjtj
d��YnX|�r�|ddk�r�|d
}d	|_t	|d�\}}|j|�|jjtj
d��|r
|ddkr
|jt
�|dd�}q
W||fS)aJ mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
        obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])

    For this routine we go outside the formal grammar in order to improve error
    handling.  We recognize the end of the mailbox list only at the end of the
    value or at a ';' (the group terminator).  This is so that we can turn
    invalid mailboxes into InvalidMailbox tokens and continue parsing any
    remaining valid mailboxes.  We also allow all mailbox entries to be null,
    and this condition is handled appropriately at a higher level.

    r�;Nz,;zempty element in mailbox-listzinvalid mailbox in mailbox-listr�rjzinvalid-mailboxrl)rdrrSrr�r�r�rr�rr�r7r,r)rZmailbox_listr.r�rcrrr�get_mailbox_list�sN













rcCst�}|s$|jjtjd��||fSd}|r�|dtkr�t|�\}}|sl|jjtjd��|j|�||fS|ddkr�|j|�||fSt|�\}}t|j	�dkr�|dk	r�|j|�|j
|�|jjtjd��||fS|dk	r�|g|dd�<|j|�||fS)zg group-list = mailbox-list / CFWS / obs-group-list
        obs-group-list = 1*([CFWS] ",") [CFWS]

    zend of header before group-listNrzend of header in group-listrzgroup-list with empty entries)rfrrSrr�r�r�rrkr_r,r�)rZ
group_listr�r.rrr�get_group_list"s8







rcCs"t�}t|�\}}|s$|ddkr4tjdj|���|j|�|jtdd��|dd�}|r�|ddkr�|jtdd��||dd�fSt|�\}}|j|�|s�|jjtj	d	��n|ddkr�tjd
j|���|jtdd��|dd�}|�r|dt
k�rt|�\}}|j|�||fS)z7 group = display-name ":" [group-list] ";" [CFWS]

    rrz8expected ':' at end of group display name but found '{}'zgroup-display-name-terminatorrjNrzgroup-terminatorzend of header in groupz)expected ';' at end of group but found {})rgrrr�r#rSr�rrr�r�r�)rrar.rrr�	get_groupGs2




rcCsxt�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnX|j|�||fS)a� address = mailbox / group

    Note that counter-intuitively, an address can be either a single address or
    a list of addresses (a group).  This is why the returned Address object has
    a 'mailboxes' attribute which treats a single address as a list of length
    one.  When you need to differentiate between to two cases, extract the single
    element, which is either a mailbox or a group token.

    zexpected address but found '{}')r`rrr�rr#rS)rr\r.rrr�get_addresses
rcCs�t�}�x�|�r�yt|�\}}|j|�W�n$tjk
�rP}�zd}|dtkr�t|�\}}|sr|ddkr�|j|�|jjtjd��nFt	|d�\}}|dk	r�|g|dd�<|jt
|g��|jjtjd��nh|ddkr�|jjtjd��nHt	|d�\}}|dk	�r|g|dd�<|jt
|g��|jjtjd��WYdd}~XnX|�r�|ddk�r�|d
d}d|_t	|d�\}}|j
|�|jjtjd��|r
|jtdd	��|dd�}q
W||fS)a� address_list = (address *("," address)) / obs-addr-list
        obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])

    We depart from the formal grammar here by continuing to parse until the end
    of the input, assuming the input to be entirely composed of an
    address-list.  This is always true in email parsing, and allows us
    to skip invalid addresses to parse additional valid ones.

    Nrr�z"address-list entry with no contentzinvalid address in address-listzempty element in address-listrjzinvalid-mailboxzlist-separatorrl)r[rrSrr�r�r�rr�rr`r�r7r,r�)rZaddress_listr.�errr�rcrrr�get_address_list�sN












rcCs�t�}|s |jjtjd��|S|dtkrXt|�\}}|j|�|sX|jjtjd��d}x8|r�|ddkr�|dtkr�||d7}|dd�}q^W|j�s�|jjtjdj	|���|jt
|d	��nt|�|_|jt
|d
��|o�|dtk�r
t|�\}}|j|�|�s |ddk�rX|jdk	�r>|jjtjd��|�rT|jt
|d	��|S|jt
dd��|dd�}|�r�|dtk�r�t|�\}}|j|�|�s�|jdk	�r�|jjtjd��|Sd}x2|�r�|dtk�r�||d7}|dd�}�q�W|j��s2|jjtjd
j	|���|jt
|d	��nt|�|_
|jt
|d
��|�rv|dtk�rvt|�\}}|j|�|�r�|jjtjd��|jt
|d	��|S)zE mime-version = [CFWS] 1*digit [CFWS] "." [CFWS] 1*digit [CFWS]

    z%Missing MIME version number (eg: 1.0)rz0Expected MIME version number but found only CFWSrr	rjNz1Expected MIME major version number but found {!r}r��digitsz0Incomplete MIME version; found only major numberzversion-separatorz1Expected MIME minor version number but found {!r}z'Excess non-CFWS text after MIME version)r�rrSr�HeaderMissingRequiredValuer�r��isdigitr�r#r��intr�r�)rZmime_versionr.rrrr�parse_mime_version�sv













rcCsht�}xX|r^|ddkr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)z� Read everything up to the next ';'.

    This is outside the formal grammar.  The InvalidParameter TokenList that is
    returned acts like a Parameter, but the data attributes are None.

    rrzmisplaced-specialrjN)r�r�rSr�r�)rZinvalid_parameterr.rrr�get_invalid_parametersrcCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)a8ttext = <matches _ttext_matcher>

    We allow any non-TOKEN_ENDS in ttext, but add defects to the token's
    defects list if we find non-ttext characters.  We also register defects for
    *any* non-printables even though the RFC doesn't exclude all of them,
    because we follow the spirit of RFC 5322.

    zexpected ttext but found '{}'N�ttext)�_non_token_end_matcherrr�r#rarkr�r�)rr�r rrr�	get_ttexts	
r"cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)z�token = [CFWS] 1*ttext [CFWS]

    The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or
    tspecials.  We also exclude tabs even though the RFC doesn't.

    The RFC implies the CFWS but is not explicit about it in the BNF.

    rzexpected token but found '{}')	rMr�r�rS�
TOKEN_ENDSrr�r#r")rZmtokenr.rrr�	get_token)s	


r$cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)aQattrtext = 1*(any non-ATTRIBUTE_ENDS character)

    We allow any non-ATTRIBUTE_ENDS in attrtext, but add defects to the
    token's defects list if we find non-attrtext characters.  We also register
    defects for *any* non-printables even though the RFC doesn't exclude all of
    them, because we follow the spirit of RFC 5322.

    z expected attrtext but found {!r}Nr�)�_non_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_attrtext@s	
r&cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)aH [CFWS] 1*attrtext [CFWS]

    This version of the BNF makes the CFWS explicit, and as usual we use a
    value terminal for the actual run of characters.  The RFC equivalent of
    attrtext is the token characters, with the subtraction of '*', "'", and '%'.
    We include tab in the excluded set just as we do for token.

    rzexpected token but found '{}')	r�r�r�rS�ATTRIBUTE_ENDSrr�r#r&)rr�r.rrr�
get_attributeSs	


r(cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)z�attrtext = 1*(any non-ATTRIBUTE_ENDS character plus '%')

    This is a special parsing routine so that we get a value that
    includes % escapes as a single string (which we decode as a single
    string later).

    z)expected extended attrtext but found {!r}Nzextended-attrtext)�#_non_extended_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_extended_attrtextjs
r*cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)z� [CFWS] 1*extended_attrtext [CFWS]

    This is like the non-extended version except we allow % characters, so that
    we can pick up an encoded value as a single string.

    rzexpected token but found '{}')	r�r�r�rS�EXTENDED_ATTRIBUTE_ENDSrr�r#r*)rr�r.rrr�get_extended_attribute|s


r,cCs�t�}|s|ddkr(tjdj|���|jtdd��|dd�}|sX|dj�rhtjdj|���d}x,|r�|dj�r�||d7}|dd�}qnW|dd	kr�|d	kr�|jjtjd
��t	|�|_
|jt|d��||fS)a6 '*' digits

    The formal BNF is more complicated because leading 0s are not allowed.  We
    check for that and add a defect.  We also assume no CFWS is allowed between
    the '*' and the digits, though the RFC is not crystal clear on that.
    The caller should already have dealt with leading CFWS.

    r�*zExpected section but found {}zsection-markerrjNz$Expected section number but found {}r�0z'section number has an invalid leading 0r)r�rr�r#rSr�rrZInvalidHeaderErrorrr�)rr�rrrr�get_section�s&	

r/cCs�t�}|stjd��d}|dtkr0t|�\}}|sDtjdj|���|ddkr^t|�\}}nt|�\}}|dk	r�|g|dd�<|j|�||fS)z  quoted-string / attribute

    z&Expected value but found end of stringNrz Expected value but found only {}r
)	r�rr�r�r�r#r�r,rS)r�vr�r.rrr�	get_value�s 

r1cCs�t�}t|�\}}|j|�|s.|ddkrN|jjtjdj|���||fS|ddkr�y t|�\}}d|_|j|�Wntj	k
r�YnX|s�tj	d��|ddkr�|jt
dd��|dd	�}d|_|dd
kr�tj	d��|jt
d
d��|dd	�}d	}|�r.|dtk�r.t
|�\}}|j|�d	}|}|j�rH|�rH|dd
k�rHt|�\}}|j}d}|jdk�r�|�r�|ddk�r�d}n$t|�\}}	|	�r�|	ddk�r�d}n(yt|�\}}	WnYnX|	�s�d}|�r2|jjtjd��|j|�x,|D]$}
|
jdk�rg|
d	d	�<|
}P�qW|}nd	}|jjtjd��|�rb|ddk�rbd	}nt|�\}}|j�s�|jdk�r�|�s�|ddk�r�|j|�|d	k	�r�|�s�t|��|}||fS|jjtjd��|�s|jjtjd��|j|�|d	k�r||fSn�|d	k	�rVx|D]}
|
jdk�r"P�q"W|
jdk|j|
�|
j|_|ddk�rttj	dj|���|jt
dd��|dd	�}|�r�|ddk�r�t|�\}}|j|�|j|_|�s�|ddk�r�tj	dj|���|jt
dd��|dd	�}|d	k	�rZt�}x>|�rR|dtk�r8t|�\}}nt|�\}}|j|��qW|}nt|�\}}|j|�|d	k	�r�|�s�t|��|}||fS)aY attribute [section] ["*"] [CFWS] "=" value

    The CFWS is implied by the RFC but not made explicit in the BNF.  This
    simplified form of the BNF from the RFC is made to conform with the RFC BNF
    through some extra checks.  We do it this way because it makes both error
    recovery and working with the resulting parse tree easier.
    rrz)Parameter contains name ({}) but no valuer-TzIncomplete parameterzextended-parameter-markerrjN�=zParameter not followed by '='zparameter-separatorr
F�'z5Quoted string value for extended parameter is invalidzbare-quoted-stringzZParameter marked as extended but appears to have a quoted string value that is non-encodedzcApparent initial-extended-value but attribute was not marked as extended or was not initial sectionz(Missing required charset/lang delimiterszextended-attrtextr�z=Expected RFC2231 char/lang encoding delimiter, but found {!r}zRFC2231-delimiterz;Expected RFC2231 char/lang encoding delimiter, but found {})r�r(rSrrr�r#r/r�r�r�r�r�r�r�rVr�r&r*r7r1�AssertionErrorrrPrQr�r�r�r�)rr�r.r�r�ZappendtoZqstringZinner_valueZ
semi_validr��tr0rrr�
get_parameter�s�























r6cCsht�}�xZ|�rbyt|�\}}|j|�Wn�tjk
r�}z�d}|dtkrZt|�\}}|sl|j|�|S|ddkr�|dk	r�|j|�|jjtjd��n@t	|�\}}|r�|g|dd�<|j|�|jjtjdj
|���WYdd}~XnX|�r@|ddk�r@|d
}d|_t	|�\}}|j|�|jjtjdj
|���|r
|jt
dd	��|dd�}q
W|S)a! parameter *( ";" parameter )

    That BNF is meant to indicate this routine should only be called after
    finding and handling the leading ';'.  There is no corresponding rule in
    the formal RFC grammar, but it is more convenient for us for the set of
    parameters to be treated as its own TokenList.

    This is 'parse' routine because it consumes the reminaing value, but it
    would never be called to parse a full header.  Instead it is called to
    parse everything after the non-parameter value of a specific MIME header.

    Nrrzparameter entry with no contentzinvalid parameter {!r}rjzinvalid-parameterz)parameter with invalid trailing text {!r}zparameter-separatorrl)r�r6rSrr�r�r�rr�rr#r7r,r�)rZmime_parametersr.rr�r�rrr�parse_mime_parametersQ	sD







 

r7cCs�xX|rX|ddkrX|dtkr@|jt|dd��|dd�}qt|�\}}|j|�qW|sbdS|jtdd��|jt|dd���dS)zBDo our best to find the parameters in an invalid MIME header

    rrzmisplaced-specialrjNzparameter-separator)r�rSr�r�r7)Z	tokenlistrr.rrr�_find_mime_parameters�	sr8cCs�t�}d}|s$|jjtjd��|Syt|�\}}Wn8tjk
rl|jjtjdj|���t	||�|SX|j|�|s�|ddkr�|jjtjd��|r�t	||�|S|j
j�j�|_
|jtdd��|dd	�}yt|�\}}Wn:tjk
�r$|jjtjd
j|���t	||�|SX|j|�|j
j�j�|_|�sJ|S|ddk�r�|jjtjdj|���|`
|`t	||�|S|jtdd
��|jt|dd	���|S)z� maintype "/" subtype *( ";" parameter )

    The maintype and substype are tokens.  Theoretically they could
    be checked against the official IANA list + x-token, but we
    don't do that.
    Fz"Missing content type specificationz(Expected content maintype but found {!r}rr�zInvalid content typezcontent-type-separatorrjNz'Expected content subtype but found {!r}rz<Only parameters are valid after content type, but found {!r}zparameter-separator)r�rrSrrr$r�r�r#r8rr��lowerr�r�r�r7)rZctypeZrecoverr.rrr�parse_content_type_header�	sX











r:c
Cs�t�}|s |jjtjd��|Syt|�\}}Wn8tjk
rh|jjtjdj|���t	||�|SX|j|�|j
j�j�|_
|s�|S|ddkr�|jjtjdj|���t	||�|S|jtdd��|jt|dd���|S)	z* disposition-type *( ";" parameter )

    zMissing content dispositionz+Expected content disposition but found {!r}rrzCOnly parameters are valid after content disposition, but found {!r}zparameter-separatorrjN)r�rrSrrr$r�r�r#r8rr�r9r�r�r7)rZdisp_headerr.rrr� parse_content_disposition_header�	s2






r;cCs�t�}|s |jjtjd��|Syt|�\}}Wn.tjk
r^|jjtjdj|���YnX|j|�|j	j
�j�|_|s�|Sx^|r�|jjtjd��|dt
kr�|jt|dd��|dd�}q�t|�\}}|j|�q�W|S)z mechanism

    z!Missing content transfer encodingz1Expected content transfer encoding but found {!r}z*Extra text after content transfer encodingrzmisplaced-specialrjN)r�rrSrrr$r�r�r#rr�r9rOr�r�r�)rZ
cte_headerr.rrr�&parse_content_transfer_encoding_header�	s.



r<cCsDd}|r@|dr@|ddtkr@|dd}|ddd	�|d
<|S)Nrrjrlrlrlrlrlrlrlrl)r�)�linesZwsprrr�_steal_trailing_WSP_if_exists
s
r>cCs�|jptd�}|jrdnd}dg}d}d}d}tdd�}t|�}	�xz|	�r�|	jd�}
|
|krf|d	8}qDt|
�}|s�|
jd
kr�tj	|�}nt
j	|�}y|j|�|}Wn6tk
r�t
dd�|
jD��r�d
}nd}d}YnX|
jdkr�t|
|||�qD|�r�|�r�|
j�s�d}d}|
j�r�|
j|d�dt|j��}
|j|
k�r�t|
�|t|d�k�rtt|�}|j|�|d|
7<qDt|
d��s�t|
�|	}	nt|||||
j|�}d}qDt|�|t|d�k�r�|d|7<qD|
j�r(t|�d	|k�r(t|�}|�s|
j��r(|j||�qDt|
d��s`t|
�}|
j�sV|d	7}|j|�||	}	qD|
j�r�|�r�|	jd|
�d}qDt|�}|�s�|
j��r�|j||�qD|d|7<qDW|jj|�|jS)zLReturn string of contents of parse_tree folded according to RFC rules.

    z+infzutf-8zus-asciirNrF�wrap_as_ew_blockedrjr�css|]}t|tj�VqdS)N)r�rr�)rrrrrr @
sz%_refold_parse_tree.<locals>.<genexpr>zunknown-8bitTzmime-parameters)r/r�rlrlrlrlrl)Zmax_line_length�float�utf8r�r�r�rr7�
SPECIALSNL�
isdisjoint�NLSETr�r�rr&�_fold_mime_parametersr)r;r1rk�linesepr>rSr8�_fold_as_ewr<r(�insertr!)Z
parse_treer/�maxlenr�r=�last_ewr?Z
want_encodingZend_ew_not_allowedr�r*�tstrrPZencoded_part�newlineZnewpartsrrrr0"
s�










r0cCs�|dk	r<|r<tt|d
|d�|��}|dd|�|d<|dtkr�|d}|dd�}t|d
�|krz|jt|��|d|7<d}|dtkr�|d}|dd�}|dkr�t|d�n|}x�|�r�|t|d�}	|dkr�dn|}
|	t|
�d}|dk�r|jd�q�|d|�}tj||
d	�}
t|
�|	}|dk�r\|d|�}tj|�}
|d|
7<|t|�d�}|r�|jd�t|d�}q�W|d|7<|�r�|SdS)a�Fold string to_encode into lines as encoded word, combining if allowed.
    Return the new value for last_ew, or None if ew_combine_allowed is False.

    If there is already an encoded word in the last line of lines (indicated by
    a non-None value for last_ew) and ew_combine_allowed is true, decode the
    existing ew, combine it with to_encode, and re-encode.  Otherwise, encode
    to_encode.  In either case, split to_encode as necessary so that the
    encoded segments fit within maxlen.

    Nrjrrzus-asciizutf-8�r@)rPrlrlrlrlrlrlrlrlrlrlrlrlrl)rr�r�rkrSr>r�r�)Z	to_encoder=rIrJr<rPZleading_wspZtrailing_wspZnew_last_ewZremaining_spaceZ	encode_asZ
text_spaceZ
first_partr�ZexcessrrrrG�
sF




rGcCs��x�|jD�]�\}}|dj�jd�s6|dd7<|}d}y|j|�d}Wn0tk
r�d}tj|�rxd}d}nd}YnX|r�tjj	|d	|d
�}	dj
|||	�}
ndj
|t|��}
t|d�t|
�d|kr�|dd
|
|d<q
n"t|
�d|k�r|j
d
|
�q
d}|d}x�|�r�t|�tt|��dt|�}
||
dk�rTd}||
d}}x<|d|�}tjj	|d	|d
�}	t|	�|k�r�P|d8}�qfW|j
dj
||||	��d	}|d7}||d�}|�r|dd7<�qWq
WdS)a>Fold TokenList 'part' into the 'lines' list as mime parameters.

    Using the decoded list of parameters and values, format them according to
    the RFC rules, including using RFC2231 encoding if the value cannot be
    expressed in 'encoding' and/or the parameter+value is too long to fit
    within 'maxlen'.

    rjr�strictFTzunknown-8bitr�zutf-8r)Zsaferz
{}*={}''{}z{}={}r@rhrz''r{�NNz {}*{}*={}{}rlrlrlrlrlrl)r�r|r�r�r�rr�r�r�rYr#rrkrSr)r*r=rIr�r�rrPZ
error_handlerZencoding_requiredZ
encoded_valuerKr�Zextra_chromeZ
chrome_lenZ
splitpointZmaxchars�partialrrrrE�
s\


 rE)��__doc__�rer��stringr�collectionsr�operatorrZemailrr�rrrr�r�r�r�r�r�Z	TSPECIALSr#Z	ASPECIALSr'r+rDrBrr�rr?rDrFrHrIrKrMrNrRrWrXr[r`rdrfrgrirqrsrtrurvrxryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�rr	�compiler#r!rwr�r�matchr��findallr�r!r%r)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
r
rrrrrrrrrrrr"r$r&r(r*r,r/r1r6r7r8r:r;r<r>r0rGrErrrr�<module>DsC"	
!($
V	+




   

*8"
&'/'&).9%>D49/j7PKc��\y�����#_encoded_words.cpython-36.opt-1.pycnu�[���3


 \F!�@s�dZddlZddlZddlZddlZddlmZmZddlm	Z	ddddd	d
ddgZ
ejejd
�j
dd��Zdd�ZGdd�de�Ze�Zdeed�<dd�Zdd	�Zdd�Zdd�Zdd
�Zeed�Zdd�Zeed�Zeed�Zddd�ZdS) z� Routines for manipulating RFC2047 encoded words.

This is currently a package-private API, but will be considered for promotion
to a public API if there is demand.

�N)�
ascii_letters�digits)�errors�decode_q�encode_q�decode_b�encode_b�len_q�len_b�decode�encodes=([a-fA-F0-9]{2})cCstt|jd�d�g�S)N��)�bytes�int�group)�m�r�,/usr/lib64/python3.6/email/_encoded_words.py�<lambda>AsrcCs|jdd�}t|�gfS)N�_� )�replace�_q_byte_subber)�encodedrrrrCsc@s,eZdZdejd�ejd�Zdd�ZdS)�	_QByteMaps-!*+/�asciicCs.||jkrt|�||<ndj|�||<||S)Nz={:02X})�safe�chr�format)�self�keyrrr�__missing__Ms
z_QByteMap.__missing__N)�__name__�
__module__�__qualname__rrrrr"rrrrrIsr�_� cCsdjdd�|D��S)N�css|]}t|VqdS)N)�_q_byte_map)�.0�xrrr�	<genexpr>Zszencode_q.<locals>.<genexpr>)�join)�bstringrrrrYscCstdd�|D��S)Ncss|]}tt|�VqdS)N)�lenr))r*r+rrrr,]szlen_q.<locals>.<genexpr>)�sum)r.rrrr	\scCs�t|�d}|r ddd|�nd}y$tj||dd�|rDtj�gngfStjk
r�ytj|dd�tj�gfStjk
r�y"tj|ddd�tj�tj�gfStjk
r�|tj�gfSXYnXYnXdS)N�s===�T)ZvalidateFs==)	r/�base64Z	b64decoderZInvalidBase64PaddingDefect�binascii�ErrorZInvalidBase64CharactersDefectZInvalidBase64LengthDefect)rZpad_errZmissing_paddingrrrrds cCstj|�jd�S)Nr)r3Z	b64encoder)r.rrrr�scCs&tt|�d�\}}|d|r dndS)N�r1r)�divmodr/)r.Zgroups_of_3Zleftoverrrrr
�s)�q�bc	Cs�|jd�\}}}}}|jd�\}}}|j�}|jdd�}t||�\}}y|j|�}Wnvtk
r�|jtj	dj
|���|j|d�}YnBtk
r�|jdd�}|j�dkr�|jtjdj
|���YnX||||fS)a�Decode encoded word and return (string, charset, lang, defects) tuple.

    An RFC 2047/2243 encoded word has the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' may be omitted but the other parts may not be.

    This function expects exactly such a string (that is, it does not check the
    syntax and may raise errors if the string is not well formed), and returns
    the encoded_string decoded first from its Content Transfer Encoding and
    then from the resulting bytes into unicode using the specified charset.  If
    the cte-decoded string does not successfully decode using the specified
    character set, a defect is added to the defects list and the unknown octets
    are replaced by the unicode 'unknown' character \uFDFF.

    The specified charset and language are returned.  The default for language,
    which is rarely if ever encountered, is the empty string.

    �?�*r�surrogateescapez:Encoded word contains bytes not decodable using {} charsetzunknown-8bitz<Unknown charset {} in encoded word; decoded as unknown bytes)
�split�	partition�lowerr�
_cte_decodersr�UnicodeError�appendrZUndecodableBytesDefectr�LookupErrorZCharsetError)	Zewr&�charsetZcteZ
cte_string�langr.Zdefects�stringrrrr�s"
�utf-8r(cCs||dkr|jdd�}n
|j|�}|dkrTtd|�}td|�}||dkrPdnd}t||�}|rld|}d	j||||�S)
aEncode string using the CTE encoding that produces the shorter result.

    Produces an RFC 2047/2243 encoded word of the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' is omitted unless the 'lang' parameter is given a value.
    Optional argument charset (defaults to utf-8) specifies the charset to use
    to encode the string to binary before CTE encoding it.  Optional argument
    'encoding' is the cte specifier for the encoding that should be used ('q'
    or 'b'); if it is None (the default) the encoding which produces the
    shortest encoded sequence is used, except that 'q' is preferred if it is up
    to five characters longer.  Optional argument 'lang' (default '') gives the
    RFC 2243 language string to specify in the encoded word.

    zunknown-8bitrr<Nr8r9�r;z=?{}{}?{}?{}?=)r�_cte_encode_length�
_cte_encodersr)rFrD�encodingrEr.ZqlenZblenrrrrr�s
)rGNr()�__doc__�rer3r4�	functoolsrFrrZemailr�__all__�partial�compile�subrr�dictrr)�ordrr	rrr
r@rrJrIrrrrr�<module>sB$
&+PKc��\�>��3�3utils.cpython-36.opt-1.pycnu�[���3

���i�J�@s�dZddddddddd	d
ddd
ddgZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddl
mZ
ddl
mZddl
mZmZmZddlmZdZdZdZdZdZejd�Zejd�ZdZdadd�Zd d!�Zd"d#�Z d$d%�Z!dId'd�Z"d(d)�Z#d*d+�Z$d,Z%dd-�d.d�Z&d/d0�Z'd1d2�Z(d3d4�Z)ejd5ej*ej+B�Z,d6d7�Z-dJd9d�Z.dKd:d�Z/dLd;d	�Z0d<d�Z1dd-�d=d�Z2d>d�Z3d?d�Z4dMd@d�Z5ejdAej6�Z7dBd�Z8dNdEd�Z9dPdGdH�Z:dS)QzMiscellaneous utilities.�collapse_rfc2231_value�
decode_params�decode_rfc2231�encode_rfc2231�
formataddr�
formatdate�format_datetime�getaddresses�
make_msgid�	mktime_tz�	parseaddr�	parsedate�parsedate_tz�parsedate_to_datetime�unquote�N)�quote)�AddressList)r
)rr
�
_parsedate_tz)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]z/etc/python/email.cfgcCstdkrt�atS)z5"Cache implementation for _cached_strict_addr_parsingN)�_cached_strict_addr_parsing�_use_strict_email_parsing_impl�rr�#/usr/lib64/python3.6/email/utils.py�_use_strict_email_parsing7srcCs�ttjjd��}|rdSytt�}Wntk
r8YnBX|�6ddl}|jdd
d�}|j	|�|j
dddd�}WdQRX|r�dSd	S)z]Returns True if strict email parsing is not disabled by
    config file or env variable.
    Z(PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSINGFrN�#)Z
interpolationZcomment_prefixesZemail_addr_parsing)ZfallbackT)r)�bool�os�environ�get�open�_EMAIL_CONFIG_FILE�FileNotFoundError�configparserZConfigParserZ	read_fileZ
getboolean)Zdisabled�filer$�configrrrr?s"
rcCs&y|j�dStk
r dSXdS)z8Return True if s contains surrogate-escaped binary data.FTN)�encode�UnicodeEncodeError)�srrr�_has_surrogates\s
r*cCs|jdd�}|jdd�S)Nzutf-8�surrogateescape�replace)r'�decode)�stringZoriginal_bytesrrr�	_sanitizeisr/�utf-8c
Cs�|\}}|jd�|r�y|jd�Wn8tk
r\t|t�rFt|�}|j|�}d||fSXd}tj|�rpd}tj	d|�}d||||fS|S)a�The inverse of parseaddr(), this takes a 2-tuple of the form
    (realname, email_address) and returns the string value suitable
    for an RFC 2822 From, To or Cc header.

    If the first element of pair is false, then the second element is
    returned unmodified.

    Optional charset if given is the character set that is used to encode
    realname in case realname is not ASCII safe.  Can be an instance of str or
    a Charset-like object which has a header_encode method.  Default is
    'utf-8'.
    �asciiz%s <%s>r�"z\\\g<0>z%s%s%s <%s>)
r'r(�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�nameZaddressZencoded_nameZquotesrrrrus 




ccs`d}d}xDt|�D]8\}}|r2|d|fVd}q|dkr@d}q||fVqW|r\|dfVdS)NrF�\T)�	enumerate)�addr�pos�escape�chrrr�_iter_escaped_chars�srAcCs�d|kr|Sd}d}g}xPt|�D]D\}}|dkr"|dkr@|}q"||krZ|j|||��|d}d}q"W|t|�kr�|j||d��dj|�S)z Strip real names between quotes.r2rN�r)rA�append�len�join)r=�startZopen_pos�resultr>r@rrr�_strip_quoted_realnames�s rHT)�strictcCs�|dkrt�}|s4tjdd�|D��}t|�}|jSdd�|D�}t|�}tj|�}t|�}t|j�}d}x&|D]}t|�}|d|jd�7}qpWt	|�|kr�d
gS|S)z�Return a list of (REALNAME, EMAIL) or ('','') for each fieldvalue.

    When parsing fails for a fieldvalue, a 2-tuple of ('', '') is returned in
    its place.

    If strict is true, use a strict parser which rejects malformed inputs.
    Ncss|]}t|�VqdS)N)r4)�.0�vrrr�	<genexpr>�szgetaddresses.<locals>.<genexpr>cSsg|]}t|��qSr)r4)rJrKrrr�
<listcomp>�sz getaddresses.<locals>.<listcomp>rrB�,r)rr)
r�
COMMASPACErE�_AddressList�addresslist�_pre_parse_validation�_post_parse_validationrH�countrD)ZfieldvaluesrI�all�ar=rG�nrKrrrr�s$


cCsXt|�}d}xBt|�D]6\}}|dkr0|d7}q|dkr|d8}|dkrdSqW|dkS)Nr�(rB�)F)rHrA)r=Zopensr>r@rrr�_check_parenthesis�s
rZcCs,g}x"|D]}t|�sd}|j|�q
W|S)Nz('', ''))rZrC)Zemail_header_fields�accepted_valuesrKrrrrRs
rRcCs0g}x&|D]}d|dkrd}|j|�q
W|S)N�[rBr)rr)rC)Zparsed_email_header_tuplesr[rKrrrrS
s
rSa_
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<atom>.*?)         # non-greedy up to the next ?= is the atom
  \?=                   # literal ?=
  cCsfddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrBr���r)�	timetuple�zonerrr�_format_timetuple_and_zone"srdFcCsR|dkrtj�}|s|r,tjj|tjj�}ntjj|�}|rH|j�}d}t||�S)a�Returns a date string as specified by RFC 2822, e.g.:

    Fri, 09 Nov 2001 01:08:47 -0000

    Optional timeval if given is a floating point time value as accepted by
    gmtime() and localtime(), otherwise the current time is used.

    Optional localtime is a flag that when True, interprets timeval, and
    returns a date relative to the local timezone instead of UTC, properly
    taking daylight savings time into account.

    Optional argument usegmt means that the timezone is written out as
    an ascii string, not numeric one (so "GMT" instead of "+0000"). This
    is needed for HTTP, and is only used when localtime==False.
    NF)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr+scCsV|j�}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}n
|jd�}t||�S)a$Turn a datetime into a date string as specified in RFC 2822.

    If usegmt is True, dt must be an aware datetime with an offset of zero.  In
    this case 'GMT' will be rendered instead of the normal +0000 required by
    RFC2822.  This is to support HTTP headers involving date stamps.
    Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)rb�tzinforfrgrh�
ValueErrorZstrftimerd)rmrl�nowrcrrrrHs

cCs^ttj�d�}tj�}tjd�}|dkr0d}nd|}|dkrHtj�}d|||||f}|S)a{Returns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.  Optional domain if given provides the
    portion of the message id after the '@'.  It defaults to the locally
    defined hostname.
    �d�@Nr�.z<%d.%d.%d%s@%s>)�intrer�getpid�randomZgetrandbits�socketZgetfqdn)ZidstringZdomainrj�pidZrandintZmsgidrrrr	[s

cCsNt|��^}}|dkr(tj|dd��Stj|dd�dtjtj|d��i�S)Nr]rn)�seconds)rrfrg�	timedelta)�dataZdtuple�tzrrrrrs
cCs�|dkrt�}|s,t|�j}|s$dS|dSt|t�r>|d}t|t�sLdSt|g�d}tt|�j�}|szt|�dkr~dS|dS)a
    Parse addr into its constituent realname and email address parts.

    Return a tuple of realname and email address, unless the parse fails, in
    which case return a 2-tuple of ('', '').

    If strict is True, use a strict parser which rejects malformed inputs.
    NrrrB)rr)rr)rr)	rrPrQr3�listr4rRrSrD)r=rIZaddrsrrrrzs 


cCs`t|�dkr\|jd�r<|jd�r<|dd�jdd�jdd�S|jd�r\|jd�r\|dd	�S|S)
zRemove quotes from a string.rBr2z\\r;z\"�<�>���r�)rD�
startswith�endswithr,)r4rrrr�scCs&|jtd�}t|�dkr"dd|fS|S)z#Decode string according to RFC 2231r^N)�split�TICKrD)r)�partsrrrr�s
cCsDtjj|d|pdd�}|dkr*|dkr*|S|dkr6d}d|||fS)z�Encode string according to RFC 2231.

    If neither charset nor language is given, then s is returned as-is.  If
    charset is given but not language, the string is encoded using the empty
    string for language.
    rr1)Zsafe�encodingNz%s'%s'%s)�urllib�parser)r)r9�languagerrrr�sz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Csx|dd�}g}i}|jd�\}}|j||f�x�|r�|jd�\}}|jd�rTd}nd}t|�}tj|�}|r�|jdd�\}}|dk	r�t|�}|j|g�j|||f�q2|j|dt	|�f�q2W|�rtx�|j
�D]�\}}g}d}	|j�x6|D].\}}
}|�rtj
j|
d	d
�}
d}	|j|
�q�Wt	tj|��}|	�r^t|�\}}}|j|||d|ff�q�|j|d|f�q�W|S)zDecode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (param name, string value).
    Nr�*TFr:�numz"%s"zlatin-1)r�)�poprCr�r�rfc2231_continuation�match�grouprt�
setdefaultr�items�sortr�r��EMPTYSTRINGrEr)
ZparamsZ
new_paramsZrfc2231_paramsr:�valueZencodedZmor�Z
continuationsZextendedr)r9r�rrrr�sD

r,�us-asciicCsjt|t�st|�dkr t|�S|\}}}|dkr6|}t|d�}yt|||�Stk
rdt|�SXdS)Nr_zraw-unicode-escape)r3�tuplerDr�bytesr4�LookupError)r��errorsZfallback_charsetr9r��textZrawbytesrrrr�s

rBc	Cs|dkrtjjtjj�j�S|jdk	r.|j�S|j�dd�|f}tj|�}tj	|�}y tj
|jd�}tj||j�}Wn�t
k
r�|tjtj|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�tj|tj|�}n
tj|�}YnX|j|d�S)a�Return local time as an aware datetime object.

    If called without arguments, return current time.  Otherwise *dt*
    argument should be a datetime instance, and it is converted to the
    local time zone according to the system time zone database.  If *dt* is
    naive (that is, dt.tzinfo is None), it is assumed to be in local time.
    In this case, a positive or zero value for *isdst* causes localtime to
    presume initially that summer time (for example, Daylight Saving Time)
    is or is not (respectively) in effect for the specified time.  A
    negative value for *isdst* causes the localtime() function to attempt
    to divine whether summer time is in effect for the specified time.

    NrB)ryr]r)rnr�)rfrprgrhrirnrbreZmktimerkrzZ	tm_gmtoffZtm_zone�AttributeErrorZgmtimeZdaylightZtm_isdstZaltzoneZtznamer,)	rmZisdstZtmryZlocaltmZdeltar|�dstZgmtoffrrrrks$


rk)r0)NFF)F)NN)NN)r,r�r�)Nr�);�__doc__�__all__r�rerervrwrfZurllib.parser�Zemail._parseaddrrrrPr
rr
rZ
email.charsetrrOr�ZUEMPTYSTRINGZCRLFr��compiler5r7r"rrrr*r/rrArHZsupports_strict_parsingrrZrRrS�VERBOSE�
IGNORECASEZecrerdrrr	rrrrr�ASCIIr�rrrkrrrr�<module>s�



!1

	


$
8
PKc��\��~j*j*header.cpython-36.opt-2.pycnu�[���3


 \&^�@s�dddgZddlZddlZddlZddlZddlmZddlmZ	e	j
Z
dZdZd	Z
dZdZdZd
Ze
d�Ze
d�ZejdejejBejB�Zejd�Zejd�ZejjZdd�Zddd�ZGdd�d�ZGdd�d�Z Gdd�de!�Z"dS)�Header�
decode_header�make_header�N)�HeaderParseError)�charset�
� � ���Nz 	zus-asciizutf-8ai
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:cCs�t|d�rdd�|jD�Stj|�s.|dfgSg}x�|j�D]�}tj|�}d}xp|r�|jd�}|rn|j�}d}|r�|j|ddf�|rP|jd�j	�}|jd�j	�}|jd�}|j|||f�qPWq<Wg}	xVt
|�D]J\}
}|
dkr�|dr�||
ddr�||
ddj�r�|	j|
d�q�Wxt|	�D]}||=�q*Wg}
x�|D]�\}}}|dk�rh|
j||f�n�|d	k�r�t
jj|�}|
j||f�n~|d
k�rt|�d}|�r�|ddd|�7}yt
jj|�}Wn tjk
�r�td
��YnX|
j||f�ntd|���qDWg}d}}x~|
D]v\}}t|t��rBt|d�}|dk�rV|}|}nB||k�rx|j||f�|}|}n |dk�r�|t|7}n||7}�q$W|j||f�|S)N�_chunkscSs(g|] \}}tj|t|��t|�f�qS�)�_charsetZ_encode�str)�.0�stringrrr�$/usr/lib64/python3.6/email/header.py�
<listcomp>Msz!decode_header.<locals>.<listcomp>TrF���q�b�z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
�ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr�AssertionError�
isinstancer�bytes�BSPACE)�headerZwords�line�parts�firstZ	unencodedr�encodingZencodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetrrrr=sz






4






cCsLt|||d�}x8|D]0\}}|dk	r8t|t�r8t|�}|j||�qW|S)N)�
maxlinelen�header_name�continuation_ws)rr-�Charsetr!)Zdecoded_seqr9r:r;�h�srrrrr�sc@sJeZdZddd�Zdd�Zdd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)rNr�strictcCs||dkrt}nt|t�s t|�}||_||_g|_|dk	rH|j|||�|dkrTt}||_|dkrjd|_	nt
|�d|_	dS)Nrr)�USASCIIr-r<r�_continuation_wsr
r!�
MAXLINELEN�_maxlinelen�
_headerlenr()�selfr>rr9r:r;�errorsrrr�__init__�s
zHeader.__init__c	Cs�|j�g}d}d}x�|jD]�\}}|}|tjkrJ|jdd�}|jdd�}|r�|o^|j|d�}|dkr�|dkr�|r�|jt�d}n|d	kr�|r�|jt�|o�|j|d
�}|}|j|�qWt	j
|�S)N�ascii�surrogateescape�replacer�us-asciir)NrK)NrK)NrK���)�
_normalizer
r�UNKNOWN8BIT�encoder)�	_nonctextr!�SPACE�EMPTYSTRING�join)	rEZuchunks�lastcs�	lastspacerrZnextcsZoriginal_bytes�hasspacerrr�__str__�s*


zHeader.__str__cCs|t|�kS)N)r)rE�otherrrr�__eq__sz
Header.__eq__cCs�|dkr|j}nt|t�s"t|�}t|t�sZ|jp4d}|tjkrN|jdd�}n|j||�}|jpbd}|tjkr�y|j||�Wn"t	k
r�|dkr��t
}YnX|jj||f�dS)Nzus-asciirI)
rr-r<rZinput_codecrNr)Zoutput_codecrO�UnicodeEncodeError�UTF8r
r!)rEr>rrFZ
input_charsetZoutput_charsetrrrr!	s$






z
Header.appendcCs|j�p|dkS)N�(�)�\)r\r]r^)r$)rEr>rrrrP4szHeader._nonctext�;, 	rcCs�|j�|dkr|j}|dkr"d}t|j||j|�}d}d}}�x4|jD�](\}}	|dk	r�|ol|j|d�}|d	kr�|s�|	d
kr�|j�n|	dkr�|r�|j�|o�|j|d�}|	}d}|j�}
|
r�|j	d|
d|	�n|j	dd|	�xr|
dd�D]b}|j
�|	jdk	�r,|j	|jd|j�|	�n.|j�}|dt
|�t
|��}
|j	|
||	��q�Wt
|
�dkrJ|j
�qJW|j�r�|j�|j|�}tj|��r�tdj|���|S)
Nri@B�us-asciirFrrz8header value appears to contain an embedded header: {!r})Nr`)Nr`)Nr`rL)rMrC�_ValueFormatterrDrAr
rP�add_transitionr�feed�newline�header_encodingr r(�_str�_embedded_headerrr�format)rE�
splitcharsr9�linesepZ	formatterrTrVrUrr�linesr1Zsline�fws�valuerrrrO9sR!


z
Header.encodecCs|g}d}g}xL|jD]B\}}||kr0|j|�q|dk	rL|jtj|�|f�|g}|}qW|rr|jtj|�|f�||_dS)N)r
r!rQrS)rEZchunksr8Z
last_chunkrrrrrrM�szHeader._normalize)NNNNrr?)Nr?)r_Nr)
�__name__�
__module__�__qualname__rGrWrYr!rPrOrMrrrrr�s
- 
+
Pc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)racCs0||_||_t|�|_||_g|_t|�|_dS)N)�_maxlenrAr(�_continuation_ws_len�_splitchars�_lines�_Accumulator�
_current_line)rEZ	headerlen�maxlenr;rirrrrG�s
z_ValueFormatter.__init__cCs|j�|j|j�S)N)rdrSrt)rErjrrrrf�sz_ValueFormatter._strcCs
|jt�S)N)rf�NL)rErrrrW�sz_ValueFormatter.__str__cCsp|jj�}|dkr|jj|�t|j�dkrb|jj�rP|jdt|j�7<n|jjt|j��|jj�dS)Nrrrr)rrrL)	rvr�pushr(�	is_onlywsrtrr!�reset)rEZend_of_linerrrrd�s

z_ValueFormatter.newlinecCs|jjdd�dS)Nrr)rvry)rErrrrb�sz_ValueFormatter.add_transitioncCs�|jdkr|j|||j�dS|j||j��}y|jd�}Wntk
rPdSX|dk	rf|j||�y|j�}Wntk
r�dSX|j�|j	j
|j|�x|D]}|jj
|j|�q�WdS)Nr)re�_ascii_splitrsZheader_encode_lines�_maxlengthsr�
IndexError�
_append_chunkrdrvryrArtr!)rErlrrZ
encoded_linesZ
first_line�	last_liner1rrrrc�s$

z_ValueFormatter.feedccs*|jt|j�Vx|j|jVqWdS)N)rqr(rvrr)rErrrr}�sz_ValueFormatter._maxlengthscCsjtjdtd||�}|dr0dg|dd�<n
|jd�x*tt|�gd�D]\}}|j||�qNWdS)Nz([z]+)rrr)�rer�FWSr�zip�iterr)rErlrrir2�partrrrr|�s
z_ValueFormatter._ascii_splitcCs
|jj||�t|j�|jk�rx�|jD]t}xlt|jj�ddd�D]P}|j�rp|j|d}|rp|d|krpP|j|dd}|rD|d|krDPqDWq(Pq(W|jj�\}}|jj	dkr�|j
�|s�d}|jj||�dS|jj|�}|jj
t|j��|jj|�dS)NrrrrLrL)rvryr(rqrs�range�
part_countr$r�
_initial_sizerd�pop_fromrtr!rr{)rErlrZch�iZprevpartr�Z	remainderrrrr�s.z_ValueFormatter._append_chunkN)rnrorprGrfrWrdrbrcr}r|rrrrrra�s%racsjeZdZd�fdd�	Zdd�Zddd�Z�fdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
�fdd�Z�ZS)rurcs||_t�j�dS)N)r��superrG)rEZinitial_size)�	__class__rrrGsz_Accumulator.__init__cCs|j||f�dS)N)r!)rErlrrrrry#sz_Accumulator.pushcCs||d�}g||d�<|S)Nr)rEr�Zpoppedrrrr�&sz_Accumulator.pop_fromcs|j�dkrdSt�j�S)Nrr)rr)r�r�r)rE)r�rrr+sz_Accumulator.popcCstdd�|D�|j�S)Ncss"|]\}}t|�t|�VqdS)N)r()rrlr�rrr�	<genexpr>1sz'_Accumulator.__len__.<locals>.<genexpr>)�sumr�)rErrr�__len__0sz_Accumulator.__len__cCstjdd�|D��S)Ncss |]\}}tj||f�VqdS)N)rRrS)rrlr�rrrr�5sz'_Accumulator.__str__.<locals>.<genexpr>)rRrS)rErrrrW4s
z_Accumulator.__str__NcCs"|dkrg}||dd�<d|_dS)Nr)r�)rEZstartvalrrrr{8sz_Accumulator.resetcCs|jdko|pt|�j�S)Nr)r�rr$)rErrrrz>sz_Accumulator.is_onlywscs
t�j�S)N)r�r�)rE)r�rrr�Asz_Accumulator.part_count)r)r)N)
rnrorprGryr�rr�rWr{rzr��
__classcell__rr)r�rrus

ruz        )NNr)#�__all__r�r*Zemail.quoprimimer&Zemail.base64mimeZemail.errorsrrrr<rxrQr/ZSPACE8rRrBr�r@r[�compile�VERBOSE�
IGNORECASE�	MULTILINErZfcrergr'Z_max_appendrrrra�listrurrrr�<module>s>

_
kPKc��\�	5T�,�,charset.cpython-36.pycnu�[���3


 \�B�@srddddgZddlmZddlZddlZddlmZddlmZd	Z	d
Z
dZdZd
Z
dZdZe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfe	e	dfd*e
e
dfe
e
dfe
ddfe
ddfe
ddfe
e
dfee
dfd�Zdddddddddddddddddddddddd
d �Zd!d"dd#�Zd+d$d�Zd%d�Zd&d�Zd'd(�ZGd)d�d�ZdS),�Charset�	add_alias�add_charset�	add_codec�)�partialN)�errors)�encode_7or8bit����zus-asciizunknown-8bit�ziso-2022-jpzutf-8)z
iso-8859-1z
iso-8859-2z
iso-8859-3z
iso-8859-4z
iso-8859-9ziso-8859-10ziso-8859-13ziso-8859-14ziso-8859-15ziso-8859-16zwindows-1252Zvisciizus-ascii�big5�gb2312zeuc-jp�	shift_jisziso-2022-jpzkoi8-rzutf-8z
iso-8859-1z
iso-8859-2z
iso-8859-3z
iso-8859-4z
iso-8859-9ziso-8859-10ziso-8859-13ziso-8859-14ziso-8859-15ziso-8859-16zks_c_5601-1987zeuc-jpzeuc-kr)�latin_1zlatin-1Zlatin_2zlatin-2Zlatin_3zlatin-3Zlatin_4zlatin-4Zlatin_5zlatin-5Zlatin_6zlatin-6Zlatin_7zlatin-7Zlatin_8zlatin-8Zlatin_9zlatin-9Zlatin_10zlatin-10�cp949�euc_jp�euc_kr�ascii�eucgb2312_cn�big5_tw)rrzus-asciicCs"|tkrtd��|||ft|<dS)a>Add character set properties to the global registry.

    charset is the input character set, and must be the canonical name of a
    character set.

    Optional header_enc and body_enc is either Charset.QP for
    quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for
    the shortest of qp or base64 encoding, or None for no encoding.  SHORTEST
    is only valid for header_enc.  It describes how message headers and
    message bodies in the input charset are to be encoded.  Default is no
    encoding.

    Optional output_charset is the character set that the output should be
    in.  Conversions will proceed from input charset, to Unicode, to the
    output charset when the method Charset.convert() is called.  The default
    is to output in the same character set as the input.

    Both input_charset and output_charset must have Unicode codec entries in
    the module's charset-to-codec mapping; use add_codec(charset, codecname)
    to add codecs the module does not know about.  See the codecs module's
    documentation for more information.
    z!SHORTEST not allowed for body_encN)�SHORTEST�
ValueError�CHARSETS)�charsetZ
header_encZbody_enc�output_charset�r�%/usr/lib64/python3.6/email/charset.pyrmscCs|t|<dS)z�Add a character set alias.

    alias is the alias name, e.g. latin-1
    canonical is the character set's canonical name, e.g. iso-8859-1
    N)�ALIASES)�aliasZ	canonicalrrrr�scCs|t|<dS)a$Add a codec that map characters in the given charset to/from Unicode.

    charset is the canonical name of a character set.  codecname is the name
    of a Python codec, as appropriate for the second argument to the unicode()
    built-in, or to the encode() method of a Unicode string.
    N)�	CODEC_MAP)rZ	codecnamerrrr�scCs"|tkr|jdd�S|j|�SdS)Nr�surrogateescape)�UNKNOWN8BIT�encode)�string�codecrrr�_encode�sr'c@s`eZdZdZefdd�Zdd�ZeZdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)ra@	Map character sets to their email properties.

    This class provides information about the requirements imposed on email
    for a specific character set.  It also provides convenience routines for
    converting between character sets, given the availability of the
    applicable codecs.  Given a character set, it will do its best to provide
    information on how to use that character set in an email in an
    RFC-compliant way.

    Certain character sets must be encoded with quoted-printable or base64
    when used in email headers or bodies.  Certain character sets must be
    converted outright, and are not allowed in email.  Instances of this
    module expose the following information about a character set:

    input_charset: The initial character set specified.  Common aliases
                   are converted to their `official' email names (e.g. latin_1
                   is converted to iso-8859-1).  Defaults to 7-bit us-ascii.

    header_encoding: If the character set must be encoded before it can be
                     used in an email header, this attribute will be set to
                     Charset.QP (for quoted-printable), Charset.BASE64 (for
                     base64 encoding), or Charset.SHORTEST for the shortest of
                     QP or BASE64 encoding.  Otherwise, it will be None.

    body_encoding: Same as header_encoding, but describes the encoding for the
                   mail message's body, which indeed may be different than the
                   header encoding.  Charset.SHORTEST is not allowed for
                   body_encoding.

    output_charset: Some character sets must be converted before they can be
                    used in email headers or bodies.  If the input_charset is
                    one of them, this attribute will contain the name of the
                    charset output will be converted to.  Otherwise, it will
                    be None.

    input_codec: The name of the Python codec used to convert the
                 input_charset to Unicode.  If no conversion codec is
                 necessary, this attribute will be None.

    output_codec: The name of the Python codec used to convert Unicode
                  to the output_charset.  If no conversion codec is necessary,
                  this attribute will have the same value as the input_codec.
    c
Cs�y$t|t�r|jd�n
t|d�}Wntk
rBtj|��YnX|j�}tj||�|_	t
j|j	ttdf�\}}}|s~|j	}||_
||_tj||�|_tj|j	|j	�|_tj|j|j�|_dS)Nr)�
isinstance�strr$�UnicodeErrorrZCharsetError�lowerr�get�
input_charsetrr�BASE64�header_encoding�
body_encodingrr!Zinput_codec�output_codec)�selfr-ZhencZbencZconvrrr�__init__�s&

zCharset.__init__cCs
|jj�S)N)r-r+)r2rrr�__str__�szCharset.__str__cCst|�t|�j�kS)N)r)r+)r2�otherrrr�__eq__�szCharset.__eq__cCs2|jtkst�|jtkrdS|jtkr*dStSdS)aPReturn the content-transfer-encoding used for body encoding.

        This is either the string `quoted-printable' or `base64' depending on
        the encoding used, or it is a function in which case you should call
        the function with a single argument, the Message object being
        encoded.  The function should then set the Content-Transfer-Encoding
        header itself to whatever is appropriate.

        Returns "quoted-printable" if self.body_encoding is QP.
        Returns "base64" if self.body_encoding is BASE64.
        Returns conversion function otherwise.
        zquoted-printable�base64N)r0r�AssertionError�QPr.r)r2rrr�get_body_encoding�s


zCharset.get_body_encodingcCs|jp
|jS)z�Return the output character set.

        This is self.output_charset if that is not None, otherwise it is
        self.input_charset.
        )rr-)r2rrr�get_output_charsetszCharset.get_output_charsetcCs6|jpd}t||�}|j|�}|dkr*|S|j||�S)a�Header-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        this charset's `header_encoding`.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :return: The encoded string, with RFC 2047 chrome.
        zus-asciiN)r1r'�_get_encoder�
header_encode)r2r%r&�header_bytes�encoder_modulerrrr=s


zCharset.header_encodecCs|jpd}t||�}|j|�}t|j|d�}|j�}t|�t}g}	g}
t|�|}x�|D]�}|
j	|�t
j|
�}
|jt|
|��}||krZ|
j
�|	r�|
r�|	j	d�n.|	r�dnd}t
j|
�}t||�}|	j	||��|g}
t|�|}qZWt
j|
�}t||�}|	j	||��|	S)afHeader-encode a string by converting it first to bytes.

        This is similar to `header_encode()` except that the string is fit
        into maximum line lengths as given by the argument.

        :param string: A unicode string for the header.  It must be possible
            to encode this string to bytes using the character set's
            output codec.
        :param maxlengths: Maximum line length iterator.  Each element
            returned from this iterator will provide the next maximum line
            length.  This parameter is used as an argument to built-in next()
            and should never be exhausted.  The maximum line lengths should
            not count the RFC 2047 chrome.  These line lengths are only a
            hint; the splitter does the best it can.
        :return: Lines of encoded strings, each with RFC 2047 chrome.
        zus-ascii)rN� r
)r1r'r<rr=r;�len�RFC2047_CHROME_LEN�next�append�EMPTYSTRING�join�
header_length�pop)r2r%Z
maxlengthsr&r>r?�encoderrZextra�linesZcurrent_line�maxlen�	characterZ	this_lineZlengthZ	separatorZjoined_linerrr�header_encode_lines,s6









zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtjj|�}tjj|�}||krPtjStjSndSdS)N)r/r.�email�
base64mimer9�
quoprimimerrG)r2r>Zlen64Zlenqprrrr<js


zCharset._get_encodercCs�|s|S|jtkr4t|t�r(|j|j�}tjj|�S|jt	krjt|t�rT|j|j�}|j
d�}tjj|�St|t�r�|j|j�j
d�}|SdS)avBody-encode a string by converting it first to bytes.

        The type of encoding (base64 or quoted-printable) will be based on
        self.body_encoding.  If body_encoding is None, we assume the
        output charset is a 7bit encoding, so re-encoding the decoded
        string using the ascii codec produces the correct string version
        of the content.
        �latin1rN)r0r.r(r)r$rrNrO�body_encoder9�decoderP)r2r%rrrrRys	





zCharset.body_encodeN)�__name__�
__module__�__qualname__�__doc__�DEFAULT_CHARSETr3r4�__repr__r6r:r;r=rMr<rRrrrrr�s+!>)NNN)NNN)�__all__�	functoolsrZemail.base64mimerNZemail.quoprimimerZemail.encodersrr9r.rrBrXr#rErrr!rrrr'rrrrr�<module>s�
	
PKc��\J��]<]<#headerregistry.cpython-36.opt-2.pycnu�[���3


 \O�@sfddlmZddlmZddlmZddlmZGdd�d�ZGdd�d�ZGd	d
�d
e	�Z
dd�ZGd
d�d�ZGdd�de�Z
Gdd�d�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd �d �ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&�Ze
eeeeeeeeeeeeeeeeeed'�ZGd(d)�d)�Zd*S)+�)�MappingProxyType)�utils)�errors)�_header_value_parserc@s^eZdZddd�Zedd��Zedd��Zed	d
��Zedd��Zd
d�Z	dd�Z
dd�ZdS)�Address�NcCsl|dk	rV|s|rtd��tj|�\}}|r:tdj||���|jrJ|jd�|j}|j}||_||_	||_
dS)Nz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r)�	TypeError�parserZ
get_addr_spec�
ValueError�format�all_defects�
local_part�domain�
_display_name�	_username�_domain)�self�display_name�usernamer�	addr_specZa_s�rest�r�,/usr/lib64/python3.6/email/headerregistry.py�__init__s

zAddress.__init__cCs|jS)N)r)rrrrr7szAddress.display_namecCs|jS)N)r)rrrrr;szAddress.usernamecCs|jS)N)r)rrrrr?szAddress.domaincCsTt|j�}t|�t|tj�kr.tj|j�}n|j}|jrH|d|jS|sPdS|S)N�@z<>)�setr�lenr	Z
DOT_ATOM_ENDS�quote_stringr)r�namesetZlprrrrCs
zAddress.addr_speccCsdj|jj|j|j|j�S)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r�	__class__�__name__rrr)rrrr�__repr__SszAddress.__repr__cCs^t|j�}t|�t|tj�kr.tj|j�}n|j}|rX|jdkrFdn|j}dj||�S|jS)Nz<>rz{} <{}>)rrrr	�SPECIALSrrr)rr�disprrrr�__str__Xs
zAddress.__str__cCs8t|�t|�krdS|j|jko6|j|jko6|j|jkS)NF)�typerrr)r�otherrrr�__eq__cs
zAddress.__eq__)rrrN)r �
__module__�__qualname__r�propertyrrrrr!r$r'rrrrrs
%rc@sFeZdZddd�Zedd��Zedd��Zdd	�Zd
d�Zdd
�Z	dS)�GroupNcCs||_|rt|�nt�|_dS)N)r�tuple�
_addresses)rr�	addressesrrrrmszGroup.__init__cCs|jS)N)r)rrrrrszGroup.display_namecCs|jS)N)r-)rrrrr.�szGroup.addressescCsdj|jj|j|j�S)Nz${}(display_name={!r}, addresses={!r})rrr rr.)rrrrr!�szGroup.__repr__cCs�|jdkr&t|j�dkr&t|jd�S|j}|dk	r\t|�}t|�t|tj�kr\tj|�}djdd�|jD��}|r~d|n|}dj	||�S)N�rz, css|]}t|�VqdS)N)�str)�.0�xrrr�	<genexpr>�sz Group.__str__.<locals>.<genexpr>� z{}:{};)
rrr.r0rr	r"r�joinr)rr#rZadrstrrrrr$�s
z
Group.__str__cCs,t|�t|�krdS|j|jko*|j|jkS)NF)r%rr.)rr&rrrr'�szGroup.__eq__)NN)
r r(r)rr*rr.r!r$r'rrrrr+ks
r+c@sPeZdZdd�Zdd�Zedd��Zedd��Zd	d
�Ze	dd��Z
d
d�ZdS)�
BaseHeadercCs\dgi}|j||�tj|d�r4tj|d�|d<tj||d�}|d=|j|f|�|S)N�defects�decoded)�parserZ_has_surrogates�	_sanitizer0�__new__�init)�cls�name�value�kwdsrrrrr;�szBaseHeader.__new__cCs||_||_||_dS)N)�_name�_parse_tree�_defects)rr>�
parse_treer7rrrr<�szBaseHeader.initcCs|jS)N)rA)rrrrr>�szBaseHeader.namecCs
t|j�S)N)r,rC)rrrrr7�szBaseHeader.defectscCst|jj|jjt|�f|jfS)N)�_reconstruct_headerrr �	__bases__r0�__dict__)rrrr�
__reduce__�s
zBaseHeader.__reduce__cCstj||�S)N)r0r;)r=r?rrr�_reconstruct�szBaseHeader._reconstructcCs`tjtjtj|jd�tjdd�g�g�}|jrH|jtjtjdd�g��|j|j�|j	|d�S)Nzheader-name�:z
header-sepr4Zfws)�policy)
r	ZHeaderZHeaderLabelZ
ValueTerminalr>rB�appendZCFWSListZWhiteSpaceTerminal�fold)rrK�headerrrrrM�szBaseHeader.foldN)r r(r)r;r<r*r>r7rH�classmethodrIrMrrrrr6�s"

r6cCst||i�j|�S)N)r%rI)Zcls_name�basesr?rrrrEsrEc@s&eZdZdZeej�Zedd��Z	dS)�UnstructuredHeaderNcCs"|j|�|d<t|d�|d<dS)NrDr8)�value_parserr0)r=r?r@rrrr9szUnstructuredHeader.parse)
r r(r)�	max_count�staticmethodr	�get_unstructuredrRrOr9rrrrrQ	s
rQc@seZdZdZdS)�UniqueUnstructuredHeaderr/N)r r(r)rSrrrrrVsrVcsBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�
DateHeaderNcCsz|s6|djtj��d|d<d|d<tj�|d<dSt|t�rJtj|�}||d<tj	|d�|d<|j
|d�|d<dS)Nr7�datetimerr8rD)rLrZHeaderMissingRequiredValuer	Z	TokenList�
isinstancer0rZparsedate_to_datetimeZformat_datetimerR)r=r?r@rrrr9)s

zDateHeader.parsecs|jd�|_t�j||�dS)NrX)�pop�	_datetime�superr<)r�args�kw)rrrr<7szDateHeader.initcCs|jS)N)r[)rrrrrX;szDateHeader.datetime)r r(r)rSrTr	rUrRrOr9r<r*rX�
__classcell__rr)rrrWs

rWc@seZdZdZdS)�UniqueDateHeaderr/N)r r(r)rSrrrrr`@sr`csPeZdZdZedd��Zedd��Z�fdd�Ze	dd	��Z
e	d
d��Z�ZS)�
AddressHeaderNcCstj|�\}}|S)N)r	Zget_address_list)r?�address_listrrrrRIszAddressHeader.value_parsercCs�t|t�rZ|j|�|d<}g}x,|jD]"}|jt|jdd�|jD���q(Wt|j	�}n"t
|d�sj|g}dd�|D�}g}||d<||d<djd	d�|D��|d
<d|kr�|j|d
�|d<dS)NrDcSs*g|]"}t|jpd|jpd|jp"d��qS)r)rrr
r)r1Zmbrrr�
<listcomp>Xsz'AddressHeader.parse.<locals>.<listcomp>�__iter__cSs&g|]}t|d�std|g�n|�qS)r.N)�hasattrr+)r1�itemrrrrcas�groupsr7z, cSsg|]}t|��qSr)r0)r1rfrrrrcgsr8)rYr0rRr.rLr+rZ
all_mailboxes�listrrer5)r=r?r@rbrgZaddrr7rrrr9Os$


zAddressHeader.parsecs(t|jd��|_d|_t�j||�dS)Nrg)r,rZ�_groupsr-r\r<)rr]r^)rrrr<kszAddressHeader.initcCs|jS)N)ri)rrrrrgpszAddressHeader.groupscCs&|jdkr tdd�|jD��|_|jS)NcSsg|]}|jD]}|�qqSr)r.)r1�group�addressrrrrcwsz+AddressHeader.addresses.<locals>.<listcomp>)r-r,ri)rrrrr.ts
zAddressHeader.addresses)
r r(r)rSrTrRrOr9r<r*rgr.r_rr)rrraEsrac@seZdZdZdS)�UniqueAddressHeaderr/N)r r(r)rSrrrrrl|srlc@seZdZedd��ZdS)�SingleAddressHeadercCs(t|j�dkrtdj|j���|jdS)Nr/z9value of single address header {} is not a single addressr)rr.r
rr>)rrrrrk�s
zSingleAddressHeader.addressN)r r(r)r*rkrrrrrm�srmc@seZdZdZdS)�UniqueSingleAddressHeaderr/N)r r(r)rSrrrrrn�srncsZeZdZdZeej�Zedd��Z	�fdd�Z
edd��Zedd	��Z
ed
d��Z�ZS)�MIMEVersionHeaderr/cCs�|j|�|d<}t|�|d<|dj|j�|jdkr<dn|j|d<|j|d<|jdk	rtdj|d|d�|d<nd|d<dS)NrDr8r7�major�minorz{}.{}�version)rRr0�extendrrqrpr)r=r?r@rDrrrr9�s

zMIMEVersionHeader.parsecs6|jd�|_|jd�|_|jd�|_t�j||�dS)Nrrrprq)rZ�_version�_major�_minorr\r<)rr]r^)rrrr<�szMIMEVersionHeader.initcCs|jS)N)ru)rrrrrp�szMIMEVersionHeader.majorcCs|jS)N)rv)rrrrrq�szMIMEVersionHeader.minorcCs|jS)N)rt)rrrrrr�szMIMEVersionHeader.version)r r(r)rSrTr	Zparse_mime_versionrRrOr9r<r*rprqrrr_rr)rrro�s
rocs8eZdZdZedd��Z�fdd�Zedd��Z�Z	S)�ParameterizedMIMEHeaderr/cCsZ|j|�|d<}t|�|d<|dj|j�|jdkrBi|d<ndd�|jD�|d<dS)NrDr8r7�paramscSs&i|]\}}tj|�tj|�j��qSr)rr:�lower)r1r>r?rrr�
<dictcomp>�sz1ParameterizedMIMEHeader.parse.<locals>.<dictcomp>)rRr0rsrrx)r=r?r@rDrrrr9�s

zParameterizedMIMEHeader.parsecs|jd�|_t�j||�dS)Nrx)rZ�_paramsr\r<)rr]r^)rrrr<�szParameterizedMIMEHeader.initcCs
t|j�S)N)rr{)rrrrrx�szParameterizedMIMEHeader.params)
r r(r)rSrOr9r<r*rxr_rr)rrrw�s
rwcsJeZdZeej�Z�fdd�Zedd��Z	edd��Z
edd��Z�ZS)	�ContentTypeHeadercs2t�j||�tj|jj�|_tj|jj�|_dS)N)	r\r<rr:rB�maintype�	_maintype�subtype�_subtype)rr]r^)rrrr<�szContentTypeHeader.initcCs|jS)N)r~)rrrrr}�szContentTypeHeader.maintypecCs|jS)N)r�)rrrrr�szContentTypeHeader.subtypecCs|jd|jS)N�/)r}r)rrrr�content_type�szContentTypeHeader.content_type)
r r(r)rTr	Zparse_content_type_headerrRr<r*r}rr�r_rr)rrr|�s

r|cs2eZdZeej�Z�fdd�Zedd��Z	�Z
S)�ContentDispositionHeadercs2t�j||�|jj}|dkr"|ntj|�|_dS)N)r\r<rB�content_dispositionrr:�_content_disposition)rr]r^Zcd)rrrr<�szContentDispositionHeader.initcCs|jS)N)r�)rrrrr��sz,ContentDispositionHeader.content_disposition)r r(r)rTr	Z parse_content_disposition_headerrRr<r*r�r_rr)rrr��s
r�csBeZdZdZeej�Zedd��Z	�fdd�Z
edd��Z�Z
S)�ContentTransferEncodingHeaderr/cCs2|j|�|d<}t|�|d<|dj|j�dS)NrDr8r7)rRr0rsr)r=r?r@rDrrrr9�sz#ContentTransferEncodingHeader.parsecs"t�j||�tj|jj�|_dS)N)r\r<rr:rB�cte�_cte)rr]r^)rrrr<sz"ContentTransferEncodingHeader.initcCs|jS)N)r�)rrrrr�sz!ContentTransferEncodingHeader.cte)r r(r)rSrTr	Z&parse_content_transfer_encoding_headerrRrOr9r<r*r�r_rr)rrr��s

r�)ZsubjectZdatezresent-datez	orig-dateZsenderz
resent-senderZtoz	resent-toZccz	resent-ccZbccz
resent-bcc�fromzresent-fromzreply-tozmime-versionzcontent-typezcontent-dispositionzcontent-transfer-encodingc@s4eZdZeedfdd�Zdd�Zdd�Zdd	�Zd
S)�HeaderRegistryTcCs&i|_||_||_|r"|jjt�dS)N)�registry�
base_class�
default_class�update�_default_header_map)rr�r�Zuse_default_maprrrr's
zHeaderRegistry.__init__cCs||j|j�<dS)N)r�ry)rr>r=rrr�map_to_type9szHeaderRegistry.map_to_typecCs,|jj|j�|j�}td|j||jfi�S)N�_)r��getryr�r%r r�)rr>r=rrr�__getitem__?szHeaderRegistry.__getitem__cCs||||�S)Nr)rr>r?rrr�__call__Cs
zHeaderRegistry.__call__N)	r r(r)r6rQrr�r�r�rrrrr�#s
r�N)�typesrZemailrrrr	rr+r0r6rErQrVrWr`rarlrmrnrorwr|r�r�r�r�rrrr�<module>
sP[6d'7
%PKc��\Z�aencoders.cpython-36.opt-2.pycnu�[���3


 \��@sPddddgZddlmZddlmZdd�Zd	d�Zd
d�Z	dd�Z
dd�Zd
S)�encode_7or8bit�
encode_base64�encode_noop�
encode_quopri�)�encodebytes)�encodestringcCst|dd�}|jdd�S)NT)Z	quotetabs� s=20)�
_encodestring�replace)�s�enc�r
�&/usr/lib64/python3.6/email/encoders.py�_qencodesrcCs0|jdd�}tt|�d�}|j|�d|d<dS)NT)�decode�ascii�base64zContent-Transfer-Encoding)�get_payload�str�_bencode�set_payload)�msg�orig�encdatar
r
rrs
cCs*|jdd�}t|�}|j|�d|d<dS)NT)rzquoted-printablezContent-Transfer-Encoding)rrr)rrrr
r
rr&s
cCsX|jdd�}|dkr d|d<dSy|jd�Wntk
rJd|d<Yn
Xd|d<dS)NT)rZ7bitzContent-Transfer-EncodingrZ8bit)rr�UnicodeError)rrr
r
rr2scCsdS)Nr
)rr
r
rrDsN)�__all__rrr�quoprirr	rrrrrr
r
r
r�<module>sPKc��\l�Ɠzz#contentmanager.cpython-36.opt-2.pycnu�[���3


 \�)�@s:ddlZddlZddlZddlZddlmZGdd�d�Ze�Zd%dd�Zej	de�d	d
�Z
xdj�D]Zej	ee
�qhWdd
�Z
x dj�D]Zej	dee
�q�Wdd�Zej	de�dd�Zdd�Zdd�Zdd�Zd&dd�Zejee�d'd d!�Zejejje�d(d#d$�Zx eeefD]Zejee��q WdS))�N)�
quoprimimec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContentManagercCsi|_i|_dS)N)�get_handlers�set_handlers)�self�r�,/usr/lib64/python3.6/email/contentmanager.py�__init__	szContentManager.__init__cCs||j|<dS)N)r)r�key�handlerrrr�add_get_handler
szContentManager.add_get_handlercOs||j�}||jkr(|j||f|�|�S|j�}||jkrP|j||f|�|�Sd|jkrp|jd|f|�|�St|��dS)N�)Zget_content_typer�get_content_maintype�KeyError)r�msg�args�kwZcontent_type�maintyperrr�get_contents


zContentManager.get_contentcCs||j|<dS)N)r)rZtypekeyrrrr�add_set_handlerszContentManager.add_set_handlercOs>|j�dkrtd��|j||�}|j�|||f|�|�dS)NZ	multipartz"set_content not valid on multipart)r�	TypeError�_find_set_handlerZ
clear_content)rr�objrrrrrr�set_contents
zContentManager.set_contentc	Cs�d}x�t|�jD]�}||jkr(|j|S|j}t|dd�}|rLdj||f�n|}|dkr\|}||jkrp|j|S||jkr�|j|S|j}||jkr|j|SqWd|jkr�|jdSt|��dS)N�
__module__r
�.)�type�__mro__r�__qualname__�getattr�join�__name__r)	rrrZfull_path_for_error�typZqname�modname�	full_path�namerrrr's&








z ContentManager._find_set_handlerN)	r!rrr	rrrrrrrrrrs	r�replacecCs&|jdd�}|jdd�}|j||d�S)NT)�decode�charset�ASCII)�errors)�get_payloadZ	get_paramr')rr*Zcontentr(rrr�get_text_content@sr,�textcCs|jdd�S)NT)r')r+)rrrr�get_non_text_contentGsr.zaudio image video applicationcCs
|jd�S)Nr)r+)rrrr�get_message_contentMsr/zrfc822 external-bodyzmessage/cCst|jd��S)Nr)�bytesr+)rrrr�%get_and_fixup_unknown_message_contentSsr1�messagecs�dj||f�|d<|r�t|dd�s<|j��fdd�|D�}y,x&|D]}|jrX|jd�|||j<qDWWn@tjjk
r�}z tdj	|j
|jd���|�WYdd}~XnXdS)	N�/zContent-Typerr%csg|]}�j�j|g���qSr)Zheader_factoryZheader_source_parse)�.0�header)�mprr�
<listcomp>dsz _prepare_set.<locals>.<listcomp>zInvalid header: {})�policy)r �hasattrr8Zdefectsr%�emailr*ZHeaderDefect�
ValueError�formatZfold)rr�subtype�headersr5�excr)r6r�_prepare_set_s


r@cCs||dkr|dk	rd}|dk	r$||d<|dk	r>|jd|ddd�|dk	rN||d<|dk	rxx |j�D]\}}|j||�q`WdS)NZ
attachmentzContent-Disposition�filenameT)r5r&z
Content-ID)�	set_param�items)r�dispositionrA�cid�paramsr
�valuerrr�
_finalize_setpsrHcCsZg}|dd}x>tdt|�|�D]*}||||�}|jtj|�jd��q"Wdj|�S)N��r�asciir
)�range�len�append�binascii�
b2a_base64r'r )�data�max_line_lengthZ
encoded_linesZunencoded_bytes_per_line�iZthislinerrr�_encode_base64�srTcs||j|�j�}|jjd���fdd�}dd�}|dkr�yd||�jd�fStk
r\YnX|jdkr�tdd	�|D��|jkr�d||�jdd
�fS||dd��}tj	|jd�|j�}t
j|�}	t|�t|	�kr�d
}nd}t|�dkr�||fS|dk�r
||�jd�}
nj|dk�r&||�jdd
�}
nN|dk�rJtj	||�jd�|j�}
n*|d
k�rft
||�|j�}
ntdj|���||
fS)NrKcs�j|��S)N)r )�lines)�lineseprr�
embedded_body�sz#_encode_text.<locals>.embedded_bodycSsdj|�dS)N�
)r )rUrrr�normal_body�sz!_encode_text.<locals>.normal_body�7bit�8bitcss|]}t|�VqdS)N)rM)r4�xrrr�	<genexpr>�sz_encode_text.<locals>.<genexpr>�surrogateescape�
zlatin-1�base64zquoted-printablez$Unknown content transfer encoding {})�encode�
splitlinesrVr'�UnicodeDecodeErrorZcte_type�maxrRrZbody_encoderOrPrMrTr;r<)�stringr(�cter8rUrWrYZsniffZsniff_qpZsniff_base64rQr)rVr�_encode_text�s@






rg�plain�utf-8c
Csdt|d||	�t||||j�\}}
|j|
�|jdtjjj||�dd�||d<t	|||||�dS)Nr-r(T)r&zContent-Transfer-Encoding)
r@rgr8�set_payloadrBr:r(ZALIASES�getrH)rrer=r(rfrDrArErFr>Zpayloadrrr�set_text_content�s
rl�rfc822c		Cs�|dkrtd��|dkr@|dkr.tdj|���|dkr:dn|}n0|dkrd|d
kr^td	j|���d}n|dkrpd}t|d
||�|j|g�||d<t|||||�dS)N�partialz4message/partial is not supported for Message objectsrmrZr[�binaryz*message/rfc822 parts do not support cte={}z
external-bodyz1message/external-body parts do not support cte={}r2zContent-Transfer-Encoding)NrZr[ro)NrZ)r;r<r@rjrH)	rr2r=rfrDrArErFr>rrr�set_message_content�s$rpr`c

Cs�t||||	�|dkr(t||jjd�}nN|dkrNtj|dddd�}|jd�}n(|dkrb|jd�n|d
krv|jdd�}|j|�||d<t	|||||�dS)Nr`)rRzquoted-printableFT)�istextr5Z	quotetabsrKrZr[ror^zContent-Transfer-Encoding)r[ro)
r@rTr8rRrOZb2a_qpr'rarjrH)
rrQrr=rfrDrArErFr>rrr�set_bytes_content�s
rr)r&)rhriNNNNNN)rmNNNNNN)r`NNNNN)rOZ
email.charsetr:Z
email.messageZemail.errorsrrZraw_data_managerr,rr.�splitrr/r=r1r@rHrTrgrlr�strrpr2ZMessagerrr0�	bytearray�
memoryviewr"rrrr�<module>sD6
	'
	

PKc��\��b@b@header.cpython-36.opt-1.pycnu�[���3


 \&^�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z
e
jZdZd	Z
d
ZdZdZd
ZdZed�Zed�ZejdejejBejB�Zejd�Zejd�ZejjZdd�Zddd�ZGdd�d�Z Gdd�d�Z!Gdd�de"�Z#dS)z+Header encoding and decoding functionality.�Header�
decode_header�make_header�N)�HeaderParseError)�charset�
� � ���Nz 	zus-asciizutf-8ai
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<encoded>.*?)      # non-greedy up to the next ?= is the encoded string
  \?=                   # literal ?=
  z[\041-\176]+:$z
\n[^ \t]+:cCs�t|d�rdd�|jD�Stj|�s.|dfgSg}x�|j�D]�}tj|�}d}xp|r�|jd�}|rn|j�}d}|r�|j|ddf�|rP|jd�j	�}|jd�j	�}|jd�}|j|||f�qPWq<Wg}	xVt
|�D]J\}
}|
dkr�|dr�||
d	dr�||
ddj�r�|	j|
d�q�Wxt|	�D]}||=�q*Wg}
x�|D]�\}}}|dk�rh|
j||f�n�|d
k�r�t
jj|�}|
j||f�n~|dk�rt|�d}|�r�|d
dd|�7}yt
jj|�}Wn tjk
�r�td��YnX|
j||f�ntd|���qDWg}d}}x~|
D]v\}}t|t��rBt|d�}|dk�rV|}|}nB||k�rx|j||f�|}|}n |dk�r�|t|7}n||7}�q$W|j||f�|S)a;Decode a message header value without converting charset.

    Returns a list of (string, charset) pairs containing each of the decoded
    parts of the header.  Charset is None for non-encoded parts of the header,
    otherwise a lower-case string containing the name of the character set
    specified in the encoded string.

    header may be a string that may or may not contain RFC2047 encoded words,
    or it may be a Header object.

    An email.errors.HeaderParseError may be raised when certain decoding error
    occurs (e.g. a base64 decoding exception).
    �_chunkscSs(g|] \}}tj|t|��t|�f�qS�)�_charsetZ_encode�str)�.0�stringrrr�$/usr/lib64/python3.6/email/header.py�
<listcomp>Msz!decode_header.<locals>.<listcomp>NTrF���q�b�z===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)�hasattrr
�ecre�search�
splitlines�split�pop�lstrip�append�lower�	enumerate�isspace�reversed�email�
quoprimimeZ
header_decode�lenZ
base64mime�decode�binascii�Errorr�AssertionError�
isinstancer�bytes�BSPACE)�headerZwords�line�parts�firstZ	unencodedr�encodingZencodedZdroplist�n�w�dZ
decoded_wordsZencoded_stringZwordZpaderrZ	collapsedZ	last_word�last_charsetrrrr=sz






4






cCsLt|||d�}x8|D]0\}}|dk	r8t|t�r8t|�}|j||�qW|S)a�Create a Header from a sequence of pairs as returned by decode_header()

    decode_header() takes a header value string and returns a sequence of
    pairs of the format (decoded_string, charset) where charset is the string
    name of the character set.

    This function takes one of those sequence of pairs and returns a Header
    instance.  Optional maxlinelen, header_name, and continuation_ws are as in
    the Header constructor.
    )�
maxlinelen�header_name�continuation_wsN)rr-�Charsetr!)Zdecoded_seqr9r:r;�h�srrrrr�sc@sJeZdZddd�Zdd�Zdd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)rNr�strictcCs||dkrt}nt|t�s t|�}||_||_g|_|dk	rH|j|||�|dkrTt}||_|dkrjd|_	nt
|�d|_	dS)aDCreate a MIME-compliant header that can contain many character sets.

        Optional s is the initial header value.  If None, the initial header
        value is not set.  You can later append to the header with .append()
        method calls.  s may be a byte string or a Unicode string, but see the
        .append() documentation for semantics.

        Optional charset serves two purposes: it has the same meaning as the
        charset argument to the .append() method.  It also sets the default
        character set for all subsequent .append() calls that omit the charset
        argument.  If charset is not provided in the constructor, the us-ascii
        charset is used both as s's initial charset and as the default for
        subsequent .append() calls.

        The maximum line length can be specified explicitly via maxlinelen. For
        splitting the first line to a shorter value (to account for the field
        header which isn't included in s, e.g. `Subject') pass in the name of
        the field in header_name.  The default maxlinelen is 78 as recommended
        by RFC 2822.

        continuation_ws must be RFC 2822 compliant folding whitespace (usually
        either a space or a hard tab) which will be prepended to continuation
        lines.

        errors is passed through to the .append() call.
        Nrr)�USASCIIr-r<r�_continuation_wsr
r!�
MAXLINELEN�_maxlinelen�
_headerlenr()�selfr>rr9r:r;�errorsrrr�__init__�s
zHeader.__init__c	Cs�|j�g}d}d}x�|jD]�\}}|}|tjkrJ|jdd�}|jdd�}|r�|o^|j|d�}|dkr�|d	kr�|r�|jt�d}n|d
kr�|r�|jt�|o�|j|d�}|}|j|�qWt	j
|�S)z&Return the string value of the header.N�ascii�surrogateescape�replacer�us-asciir)NrK)NrK)NrK���)�
_normalizer
r�UNKNOWN8BIT�encoder)�	_nonctextr!�SPACE�EMPTYSTRING�join)	rEZuchunks�lastcs�	lastspacerrZnextcsZoriginal_bytes�hasspacerrr�__str__�s*


zHeader.__str__cCs|t|�kS)N)r)rE�otherrrr�__eq__sz
Header.__eq__cCs�|dkr|j}nt|t�s"t|�}t|t�sZ|jp4d}|tjkrN|jdd�}n|j||�}|jpbd}|tjkr�y|j||�Wn"t	k
r�|dkr��t
}YnX|jj||f�dS)a.Append a string to the MIME header.

        Optional charset, if given, should be a Charset instance or the name
        of a character set (which will be converted to a Charset instance).  A
        value of None (the default) means that the charset given in the
        constructor is used.

        s may be a byte string or a Unicode string.  If it is a byte string
        (i.e. isinstance(s, str) is false), then charset is the encoding of
        that byte string, and a UnicodeError will be raised if the string
        cannot be decoded with that charset.  If s is a Unicode string, then
        charset is a hint specifying the character set of the characters in
        the string.  In either case, when producing an RFC 2822 compliant
        header using RFC 2047 rules, the string will be encoded using the
        output codec of the charset.  If the string cannot be encoded to the
        output codec, a UnicodeError will be raised.

        Optional `errors' is passed as the errors argument to the decode
        call if s is a byte string.
        Nzus-asciirI)
rr-r<rZinput_codecrNr)Zoutput_codecrO�UnicodeEncodeError�UTF8r
r!)rEr>rrFZ
input_charsetZoutput_charsetrrrr!	s$






z
Header.appendcCs|j�p|dkS)z=True if string s is not a ctext character of RFC822.
        �(�)�\)r\r]r^)r$)rEr>rrrrP4szHeader._nonctext�;, 	rcCs�|j�|dkr|j}|dkr"d}t|j||j|�}d}d}}�x4|jD�](\}}	|dk	r�|ol|j|d�}|d
kr�|s�|	dkr�|j�n|	dkr�|r�|j�|o�|j|d
�}|	}d}|j�}
|
r�|j	d|
d|	�n|j	dd|	�xr|
dd�D]b}|j
�|	jdk	�r,|j	|jd|j�|	�n.|j�}|dt
|�t
|��}
|j	|
||	��q�Wt
|
�dkrJ|j
�qJW|j�r�|j�|j|�}tj|��r�td	j|���|S)a�Encode a message header into an RFC-compliant format.

        There are many issues involved in converting a given string for use in
        an email header.  Only certain character sets are readable in most
        email clients, and as header strings can only contain a subset of
        7-bit ASCII, care must be taken to properly convert and encode (with
        Base64 or quoted-printable) header strings.  In addition, there is a
        75-character length limit on any given encoded header field, so
        line-wrapping must be performed, even with double-byte character sets.

        Optional maxlinelen specifies the maximum length of each generated
        line, exclusive of the linesep string.  Individual lines may be longer
        than maxlinelen if a folding point cannot be found.  The first line
        will be shorter by the length of the header name plus ": " if a header
        name was specified at Header construction time.  The default value for
        maxlinelen is determined at header construction time.

        Optional splitchars is a string containing characters which should be
        given extra weight by the splitting algorithm during normal header
        wrapping.  This is in very rough support of RFC 2822's `higher level
        syntactic breaks':  split points preceded by a splitchar are preferred
        during line splitting, with the characters preferred in the order in
        which they appear in the string.  Space and tab may be included in the
        string to indicate whether preference should be given to one over the
        other as a split point when other split chars do not appear in the line
        being split.  Splitchars does not affect RFC 2047 encoded lines.

        Optional linesep is a string to be used to separate the lines of
        the value.  The default value is the most useful for typical
        Python applications, but it can be set to \r\n to produce RFC-compliant
        line separators when needed.
        Nri@B�us-asciirFrrz8header value appears to contain an embedded header: {!r})Nr`)Nr`)Nr`rL)rMrC�_ValueFormatterrDrAr
rP�add_transitionr�feed�newline�header_encodingr r(�_str�_embedded_headerrr�format)rE�
splitcharsr9�linesepZ	formatterrTrVrUrr�linesr1Zsline�fws�valuerrrrO9sR!


z
Header.encodecCs|g}d}g}xL|jD]B\}}||kr0|j|�q|dk	rL|jtj|�|f�|g}|}qW|rr|jtj|�|f�||_dS)N)r
r!rQrS)rEZchunksr8Z
last_chunkrrrrrrM�szHeader._normalize)NNNNrr?)Nr?)r_Nr)
�__name__�
__module__�__qualname__rGrWrYr!rPrOrMrrrrr�s
- 
+
Pc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)racCs0||_||_t|�|_||_g|_t|�|_dS)N)�_maxlenrAr(�_continuation_ws_len�_splitchars�_lines�_Accumulator�
_current_line)rEZ	headerlen�maxlenr;rirrrrG�s
z_ValueFormatter.__init__cCs|j�|j|j�S)N)rdrSrt)rErjrrrrf�sz_ValueFormatter._strcCs
|jt�S)N)rf�NL)rErrrrW�sz_ValueFormatter.__str__cCsp|jj�}|dkr|jj|�t|j�dkrb|jj�rP|jdt|j�7<n|jjt|j��|jj�dS)Nrrrr)rrrL)	rvr�pushr(�	is_onlywsrtrr!�reset)rEZend_of_linerrrrd�s

z_ValueFormatter.newlinecCs|jjdd�dS)Nrr)rvry)rErrrrb�sz_ValueFormatter.add_transitioncCs�|jdkr|j|||j�dS|j||j��}y|jd�}Wntk
rPdSX|dk	rf|j||�y|j�}Wntk
r�dSX|j�|j	j
|j|�x|D]}|jj
|j|�q�WdS)Nr)re�_ascii_splitrsZheader_encode_lines�_maxlengthsr�
IndexError�
_append_chunkrdrvryrArtr!)rErlrrZ
encoded_linesZ
first_line�	last_liner1rrrrc�s$

z_ValueFormatter.feedccs*|jt|j�Vx|j|jVqWdS)N)rqr(rvrr)rErrrr}�sz_ValueFormatter._maxlengthscCsjtjdtd||�}|dr0dg|dd�<n
|jd�x*tt|�gd�D]\}}|j||�qNWdS)Nz([z]+)rrr)�rer�FWSr�zip�iterr)rErlrrir2�partrrrr|�s
z_ValueFormatter._ascii_splitcCs
|jj||�t|j�|jk�rx�|jD]t}xlt|jj�ddd�D]P}|j�rp|j|d}|rp|d|krpP|j|dd}|rD|d|krDPqDWq(Pq(W|jj�\}}|jj	dkr�|j
�|s�d}|jj||�dS|jj|�}|jj
t|j��|jj|�dS)NrrrrLrL)rvryr(rqrs�range�
part_countr$r�
_initial_sizerd�pop_fromrtr!rr{)rErlrZch�iZprevpartr�Z	remainderrrrr�s.z_ValueFormatter._append_chunkN)rnrorprGrfrWrdrbrcr}r|rrrrrra�s%racsjeZdZd�fdd�	Zdd�Zddd�Z�fdd	�Zd
d�Zdd
�Zddd�Z	dd�Z
�fdd�Z�ZS)rurcs||_t�j�dS)N)r��superrG)rEZinitial_size)�	__class__rrrGsz_Accumulator.__init__cCs|j||f�dS)N)r!)rErlrrrrry#sz_Accumulator.pushcCs||d�}g||d�<|S)Nr)rEr�Zpoppedrrrr�&sz_Accumulator.pop_fromcs|j�dkrdSt�j�S)Nrr)rr)r�r�r)rE)r�rrr+sz_Accumulator.popcCstdd�|D�|j�S)Ncss"|]\}}t|�t|�VqdS)N)r()rrlr�rrr�	<genexpr>1sz'_Accumulator.__len__.<locals>.<genexpr>)�sumr�)rErrr�__len__0sz_Accumulator.__len__cCstjdd�|D��S)Ncss |]\}}tj||f�VqdS)N)rRrS)rrlr�rrrr�5sz'_Accumulator.__str__.<locals>.<genexpr>)rRrS)rErrrrW4s
z_Accumulator.__str__NcCs"|dkrg}||dd�<d|_dS)Nr)r�)rEZstartvalrrrr{8sz_Accumulator.resetcCs|jdko|pt|�j�S)Nr)r�rr$)rErrrrz>sz_Accumulator.is_onlywscs
t�j�S)N)r�r�)rE)r�rrr�Asz_Accumulator.part_count)r)r)N)
rnrorprGryr�rr�rWr{rzr��
__classcell__rr)r�rrus

ruz        )NNr)$�__doc__�__all__r�r*Zemail.quoprimimer&Zemail.base64mimeZemail.errorsrrrr<rxrQr/ZSPACE8rRrBr�r@r[�compile�VERBOSE�
IGNORECASE�	MULTILINErZfcrergr'Z_max_appendrrrra�listrurrrr�<module>s@

_
kPKc��\�Z��)�)feedparser.cpython-36.pycnu�[���3


 \�X�@s�dZddgZddlZddlmZddlmZddlmZddl	m
Z
ejd	�Zejd
�Z
ejd�Zejd
�Zejd�Zd
ZdZe�ZGdd�de�ZGdd�d�ZGdd�de�ZdS)aFeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.
�
FeedParser�BytesFeedParser�N)�errors)�compat32)�deque)�StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])��
c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BufferedSubFileakA file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    cCs$tdd�|_t�|_g|_d|_dS)Nr)�newlineF)r�_partialr�_lines�	_eofstack�_closed)�self�r�(/usr/lib64/python3.6/email/feedparser.py�__init__5szBufferedSubFile.__init__cCs|jj|�dS)N)r�append)rZpredrrr�push_eof_matcher@sz BufferedSubFile.push_eof_matchercCs
|jj�S)N)r�pop)rrrr�pop_eof_matcherCszBufferedSubFile.pop_eof_matchercCs<|jjd�|j|jj��|jjd�|jj�d|_dS)NrT)r�seek�	pushlines�	readlines�truncater)rrrr�closeFs

zBufferedSubFile.closecCsN|js|jrdStS|jj�}x*t|j�D]}||�r*|jj|�dSq*W|S)Nr)r
r�NeedMoreData�popleft�reversedr�
appendleft)r�lineZateofrrr�readlineNs
zBufferedSubFile.readlinecCs|tk	st�|jj|�dS)N)r�AssertionErrorr
r )rr!rrr�
unreadline`szBufferedSubFile.unreadlinecCsx|jj|�d|kr d|kr dS|jjd�|jj�}|jjd�|jj�|djd�sj|jj|j��|j|�dS)z$Push some new data into this object.r	�
Nr����)r�writerrr�endswithrr)r�data�partsrrr�pushes

zBufferedSubFile.pushcCs|jj|�dS)N)r
�extend)r�linesrrrrzszBufferedSubFile.pushlinescCs|S)Nr)rrrr�__iter__}szBufferedSubFile.__iter__cCs|j�}|dkrt�|S)Nr)r"�
StopIteration)rr!rrr�__next__�szBufferedSubFile.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrr"r$r,rr/r1rrrrr
-sr
c@s`eZdZdZded�dd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rzA feed-style parser of email.N)�policycCs�||_d|_|dkr<|jdkr2ddlm}||_qn|j|_n2||_y||jd�Wntk
rld|_YnXt�|_g|_	|j
�j|_d|_
d|_d|_dS)a_factory is called with no arguments to create a new message obj

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        FNr)�Message)r6T)r6�_old_style_factoryZmessage_factoryZ
email.messager7�_factory�	TypeErrorr
�_input�	_msgstack�	_parsegenr1�_parse�_cur�_last�_headersonly)rr9r6r7rrrr�s$

zFeedParser.__init__cCs
d|_dS)NT)rA)rrrr�_set_headersonly�szFeedParser._set_headersonlycCs|jj|�|j�dS)zPush more data into the parser.N)r;r,�_call_parse)rr*rrr�feed�szFeedParser.feedcCs&y|j�Wntk
r YnXdS)N)r>r0)rrrrrC�szFeedParser._call_parsecCsV|jj�|j�|j�}|js&t�|j�dkrR|j�rRtj	�}|j
j||�|S)z<Parse all remaining data and return the root message object.�	multipart)r;rrC�_pop_messager<r#�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr6�
handle_defect)r�root�defectrrrr�s

zFeedParser.closecCsn|jr|j�}n|j|jd�}|jr<|jj�dkr<|jd�|jrR|jdj|�|jj|�||_||_	dS)N)r6zmultipart/digestzmessage/rfc822r&r')
r8r9r6r?�get_content_typeZset_default_typer<Zattachrr@)r�msgrrr�_new_message�s

zFeedParser._new_messagecCs(|jj�}|jr|jd|_nd|_|S)Nr&r')r<rr?)r�retvalrrrrF�s

zFeedParser._pop_messageccs@|j�g}xb|jD]X}|tkr(tVqtj|�sbtj|�s`tj�}|jj	|j
|�|jj|�P|j|�qW|j
|�|jr�g}x2|jj�}|tkr�tVq�|dkr�P|j|�q�W|j
jtj|��dS|j
j�dk�r�x�|jjtj�x$|j�D]}|tk�rtVq�Pq�W|j�}|jj�x&|jj�}|tk�rFtV�q(P�q(Wx&|jj�}|tk�rntV�qPP�qPW|dk�r�P|jj|�q�WdS|j
j�dk�r�x(|j�D]}|tk�r�tV�q�P�q�W|j�dS|j
j�dk�r�|j
j�}|dk�rbtj�}|jj	|j
|�g}x.|jD]$}|tk�r<tV�q$|j|��q$W|j
jtj|��dS|j
jdd�j�dk�r�tj�}|jj	|j
|�d	|}tjd
tj |�d�}	d}
g}d
}d
}
�x|jj�}|tk�r�tV�q�|dk�r�P|	j|�}|�r�|j!d��rd}
|j!d�}P|
�r~|�rj|d}t"j#|�}|�r\|dt$|j!d���|d<tj|�|j
_%d
}
|jj|��q�xB|jj�}|tk�r�tV�q�|	j|�}|�s�|jj|�P�q�W|jj|	j�x(|j�D]}|tk�r�tV�q�P�q�W|j&j�dk�rb|j&j'}|dk�r&d|j&_'n:|dk	�r�t"j#|�}|�r�t$|j!d��}|d|�|j&_'nD|j&j(}t)|t*��r�t"j#|�}|�r�|dt$|j!d���}||j&_(|jj�|j�|j
|_&n|
�s�t+�|j|��q�W|
�rHtj,�}|jj	|j
|�|j
jtj|��g}x$|jD]}|tk�rtV�q�qWtj|�|j
_'dS|
�sjtj-�}|jj	|j
|�dS|�rxdg}ng}x.|jD]$}|tk�r�tV�q�|j|��q�W|�r�|d}t.j|�}|�r�|t$|j!d��d�|d<tj|�|j
_'dSg}x.|jD]$}|tk�rtV�q|j|��qW|j
jtj|��dS)Nrzmessage/delivery-status�messagerEzcontent-transfer-encoding�8bit�7bit�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr&r)rQrPrRr'r')/rMr;r�headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr6rHr?r$r�_parse_headersrAr"Zset_payload�EMPTYSTRING�joinrKrr=rFrrGZget_boundaryZNoBoundaryInMultipartDefect�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�search�len�preambler@�epilogueZ_payload�
isinstance�strr#ZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr!rJr.rNrL�boundaryZ	separatorZ
boundaryreZcapturing_preamblerdrTZclose_boundary_seen�moZlastlineZeolmorerSZpayload�	firstlineZbolmorrrr=�sh





































zFeedParser._parsegenc	Cspd}g}�xFt|�D�]8\}}|ddkrV|sJtj|�}|jj|j|�q|j|�q|rx|jj|jj|��dg}}|j	d��r�|dkr�t
j|�}|r�|dt|j
d���}|jj|�qn:|t|�dkr�|jj|�dStj|�}|jjj|�q|jd�}|dk�r*tjd�}|jjj|�q|dk�s<td��|d|�}|g}qW|�rl|jj|jj|��dS)	Nrrz 	zFrom r&�:zMissing header name.z3_parse_headers fed line with no : and no leading WS)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr6rHr?rZset_rawZheader_source_parse�
startswithrarbrcr`Zset_unixfromr;r$ZMisplacedEnvelopeHeaderDefectZdefects�findZInvalidHeaderDefectr#)	rr.Z
lastheaderZ	lastvalue�linenor!rJrj�irrrrX�sH








zFeedParser._parse_headers)N)r2r3r4r5rrrBrDrCrrMrFr=rXrrrrr�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst�j|jdd��dS)N�ascii�surrogateescape)�superrD�decode)rr*)�	__class__rrrDszBytesFeedParser.feed)r2r3r4r5rD�
__classcell__rr)rvrrs)r5�__all__r]ZemailrZemail._policybaser�collectionsr�iorr^rWrhraZNLCRE_crackrUrY�NL�objectrr
rrrrrr�<module>s(




[PKc��\l�Ɠzzcontentmanager.cpython-36.pycnu�[���3


 \�)�@s:ddlZddlZddlZddlZddlmZGdd�d�Ze�Zd%dd�Zej	de�d	d
�Z
xdj�D]Zej	ee
�qhWdd
�Z
x dj�D]Zej	dee
�q�Wdd�Zej	de�dd�Zdd�Zdd�Zdd�Zd&dd�Zejee�d'd d!�Zejejje�d(d#d$�Zx eeefD]Zejee��q WdS))�N)�
quoprimimec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContentManagercCsi|_i|_dS)N)�get_handlers�set_handlers)�self�r�,/usr/lib64/python3.6/email/contentmanager.py�__init__	szContentManager.__init__cCs||j|<dS)N)r)r�key�handlerrrr�add_get_handler
szContentManager.add_get_handlercOs||j�}||jkr(|j||f|�|�S|j�}||jkrP|j||f|�|�Sd|jkrp|jd|f|�|�St|��dS)N�)Zget_content_typer�get_content_maintype�KeyError)r�msg�args�kwZcontent_type�maintyperrr�get_contents


zContentManager.get_contentcCs||j|<dS)N)r)rZtypekeyrrrr�add_set_handlerszContentManager.add_set_handlercOs>|j�dkrtd��|j||�}|j�|||f|�|�dS)NZ	multipartz"set_content not valid on multipart)r�	TypeError�_find_set_handlerZ
clear_content)rr�objrrrrrr�set_contents
zContentManager.set_contentc	Cs�d}x�t|�jD]�}||jkr(|j|S|j}t|dd�}|rLdj||f�n|}|dkr\|}||jkrp|j|S||jkr�|j|S|j}||jkr|j|SqWd|jkr�|jdSt|��dS)N�
__module__r
�.)�type�__mro__r�__qualname__�getattr�join�__name__r)	rrrZfull_path_for_error�typZqname�modname�	full_path�namerrrr's&








z ContentManager._find_set_handlerN)	r!rrr	rrrrrrrrrrs	r�replacecCs&|jdd�}|jdd�}|j||d�S)NT)�decode�charset�ASCII)�errors)�get_payloadZ	get_paramr')rr*Zcontentr(rrr�get_text_content@sr,�textcCs|jdd�S)NT)r')r+)rrrr�get_non_text_contentGsr.zaudio image video applicationcCs
|jd�S)Nr)r+)rrrr�get_message_contentMsr/zrfc822 external-bodyzmessage/cCst|jd��S)Nr)�bytesr+)rrrr�%get_and_fixup_unknown_message_contentSsr1�messagecs�dj||f�|d<|r�t|dd�s<|j��fdd�|D�}y,x&|D]}|jrX|jd�|||j<qDWWn@tjjk
r�}z tdj	|j
|jd���|�WYdd}~XnXdS)	N�/zContent-Typerr%csg|]}�j�j|g���qSr)Zheader_factoryZheader_source_parse)�.0�header)�mprr�
<listcomp>dsz _prepare_set.<locals>.<listcomp>zInvalid header: {})�policy)r �hasattrr8Zdefectsr%�emailr*ZHeaderDefect�
ValueError�formatZfold)rr�subtype�headersr5�excr)r6r�_prepare_set_s


r@cCs||dkr|dk	rd}|dk	r$||d<|dk	r>|jd|ddd�|dk	rN||d<|dk	rxx |j�D]\}}|j||�q`WdS)NZ
attachmentzContent-Disposition�filenameT)r5r&z
Content-ID)�	set_param�items)r�dispositionrA�cid�paramsr
�valuerrr�
_finalize_setpsrHcCsZg}|dd}x>tdt|�|�D]*}||||�}|jtj|�jd��q"Wdj|�S)N��r�asciir
)�range�len�append�binascii�
b2a_base64r'r )�data�max_line_lengthZ
encoded_linesZunencoded_bytes_per_line�iZthislinerrr�_encode_base64�srTcs||j|�j�}|jjd���fdd�}dd�}|dkr�yd||�jd�fStk
r\YnX|jdkr�tdd	�|D��|jkr�d||�jdd
�fS||dd��}tj	|jd�|j�}t
j|�}	t|�t|	�kr�d
}nd}t|�dkr�||fS|dk�r
||�jd�}
nj|dk�r&||�jdd
�}
nN|dk�rJtj	||�jd�|j�}
n*|d
k�rft
||�|j�}
ntdj|���||
fS)NrKcs�j|��S)N)r )�lines)�lineseprr�
embedded_body�sz#_encode_text.<locals>.embedded_bodycSsdj|�dS)N�
)r )rUrrr�normal_body�sz!_encode_text.<locals>.normal_body�7bit�8bitcss|]}t|�VqdS)N)rM)r4�xrrr�	<genexpr>�sz_encode_text.<locals>.<genexpr>�surrogateescape�
zlatin-1�base64zquoted-printablez$Unknown content transfer encoding {})�encode�
splitlinesrVr'�UnicodeDecodeErrorZcte_type�maxrRrZbody_encoderOrPrMrTr;r<)�stringr(�cter8rUrWrYZsniffZsniff_qpZsniff_base64rQr)rVr�_encode_text�s@






rg�plain�utf-8c
Csdt|d||	�t||||j�\}}
|j|
�|jdtjjj||�dd�||d<t	|||||�dS)Nr-r(T)r&zContent-Transfer-Encoding)
r@rgr8�set_payloadrBr:r(ZALIASES�getrH)rrer=r(rfrDrArErFr>Zpayloadrrr�set_text_content�s
rl�rfc822c		Cs�|dkrtd��|dkr@|dkr.tdj|���|dkr:dn|}n0|dkrd|d
kr^td	j|���d}n|dkrpd}t|d
||�|j|g�||d<t|||||�dS)N�partialz4message/partial is not supported for Message objectsrmrZr[�binaryz*message/rfc822 parts do not support cte={}z
external-bodyz1message/external-body parts do not support cte={}r2zContent-Transfer-Encoding)NrZr[ro)NrZ)r;r<r@rjrH)	rr2r=rfrDrArErFr>rrr�set_message_content�s$rpr`c

Cs�t||||	�|dkr(t||jjd�}nN|dkrNtj|dddd�}|jd�}n(|dkrb|jd�n|d
krv|jdd�}|j|�||d<t	|||||�dS)Nr`)rRzquoted-printableFT)�istextr5Z	quotetabsrKrZr[ror^zContent-Transfer-Encoding)r[ro)
r@rTr8rRrOZb2a_qpr'rarjrH)
rrQrr=rfrDrArErFr>rrr�set_bytes_content�s
rr)r&)rhriNNNNNN)rmNNNNNN)r`NNNNN)rOZ
email.charsetr:Z
email.messageZemail.errorsrrZraw_data_managerr,rr.�splitrr/r=r1r@rHrTrgrlr�strrpr2ZMessagerrr0�	bytearray�
memoryviewr"rrrr�<module>sD6
	'
	

PKc��\��Y�;�; _policybase.cpython-36.opt-1.pycnu�[���3

���i�<�@s�dZddlZddlmZddlmZddlmZdddgZGd	d
�d
�Z	dd�Z
d
d�ZGdd�de	ejd�Z
eGdd�de
��Ze�ZdS)zwPolicy framework for the email package.

Allows fine grained feature control of how the package parses and emits data.
�N)�header)�charset)�_has_surrogates�Policy�Compat32�compat32cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�_PolicyBasea�Policy Object basic framework.

    This class is useless unless subclassed.  A subclass should define
    class attributes with defaults for any values that are to be
    managed by the Policy object.  The constructor will then allow
    non-default values to be set for these attributes at instance
    creation time.  The instance will be callable, taking these same
    attributes keyword arguments, and returning a new instance
    identical to the called instance except for those values changed
    by the keyword arguments.  Instances may be added, yielding new
    instances with any non-default values from the right hand
    operand overriding those in the left hand operand.  That is,

        A + B == A(<non-default values of B>)

    The repr of an instance can be used to reconstruct the object
    if and only if the repr of the values can be used to reconstruct
    those values.

    csLxF|j�D]:\}}t||�r0tt|�j||�q
tdj||jj���q
WdS)z�Create new Policy, possibly overriding some defaults.

        See class docstring for a list of overridable attributes.

        z*{!r} is an invalid keyword argument for {}N)	�items�hasattr�superr�__setattr__�	TypeError�format�	__class__�__name__)�self�kw�name�value)r��)/usr/lib64/python3.6/email/_policybase.py�__init__)s
z_PolicyBase.__init__cCs*dd�|jj�D�}dj|jjdj|��S)NcSsg|]\}}dj||��qS)z{}={!r})r)�.0rrrrr�
<listcomp>8sz(_PolicyBase.__repr__.<locals>.<listcomp>z{}({})z, )�__dict__r	rrr�join)r�argsrrr�__repr__7sz_PolicyBase.__repr__cKsz|jj|j�}x$|jj�D]\}}tj|||�qWx@|j�D]4\}}t||�sdtdj||jj	���tj|||�q>W|S)z�Return a new instance with specified attributes changed.

        The new instance has the same attribute values as the current object,
        except for the changes passed in as keyword arguments.

        z*{!r} is an invalid keyword argument for {})
r�__new__rr	�objectrr
r
rr)rrZ	newpolicy�attrrrrr�clone<s
z_PolicyBase.clonecCs,t||�rd}nd}t|j|jj|���dS)Nz'{!r} object attribute {!r} is read-onlyz!{!r} object has no attribute {!r})r
�AttributeErrorrrr)rrr�msgrrrrNs
z_PolicyBase.__setattr__cCs|jf|j�S)z�Non-default values from right operand override those from left.

        The object returned is a new instance of the subclass.

        )r!r)r�otherrrr�__add__Usz_PolicyBase.__add__)
r�
__module__�__qualname__�__doc__rrr!rr%�
__classcell__rr)rrrsrcCs,|jdd�d}|jdd�d}|d|S)N�
�r)�rsplit�split)�docZ	added_docrrr�_append_doc^sr/cCs�|jr(|jjd�r(t|jdj|j�|_xf|jj�D]X\}}|jr4|jjd�r4x<dd�|jD�D](}tt||�d�}|r`t||j�|_Pq`Wq4W|S)N�+rcss |]}|j�D]
}|VqqdS)N)�mro)r�base�crrr�	<genexpr>hsz%_extend_docstrings.<locals>.<genexpr>r()r(�
startswithr/�	__bases__rr	�getattr)�clsrr r3r.rrr�_extend_docstringscs
r9c@s�eZdZdZdZdZdZdZdZdZ	dZ
dd	�Zd
d�Zdd
�Z
ejdd��Zejdd��Zejdd��Zejdd��Zejdd��ZdS)ra�
Controls for how messages are interpreted and formatted.

    Most of the classes and many of the methods in the email package accept
    Policy objects as parameters.  A Policy object contains a set of values and
    functions that control how input is interpreted and how output is rendered.
    For example, the parameter 'raise_on_defect' controls whether or not an RFC
    violation results in an error being raised or not, while 'max_line_length'
    controls the maximum length of output lines when a Message is serialized.

    Any valid attribute may be overridden when a Policy is created by passing
    it as a keyword argument to the constructor.  Policy objects are immutable,
    but a new Policy object can be created with only certain values changed by
    calling the Policy instance with keyword arguments.  Policy objects can
    also be added, producing a new Policy object in which the non-default
    attributes set in the right hand operand overwrite those specified in the
    left operand.

    Settable attributes:

    raise_on_defect     -- If true, then defects should be raised as errors.
                           Default: False.

    linesep             -- string containing the value to use as separation
                           between output lines.  Default '\n'.

    cte_type            -- Type of allowed content transfer encodings

                           7bit  -- ASCII only
                           8bit  -- Content-Transfer-Encoding: 8bit is allowed

                           Default: 8bit.  Also controls the disposition of
                           (RFC invalid) binary data in headers; see the
                           documentation of the binary_fold method.

    max_line_length     -- maximum length of lines, excluding 'linesep',
                           during serialization.  None or 0 means no line
                           wrapping is done.  Default is 78.

    mangle_from_        -- a flag that, when True escapes From_ lines in the
                           body of the message by putting a `>' in front of
                           them. This is used when the message is being
                           serialized by a generator. Default: True.

    message_factory     -- the class to use to create new message objects.
                           If the value is None, the default is Message.

    verify_generated_headers
                        -- if true, the generator verifies that each header
                           they are properly folded, so that a parser won't
                           treat it as multiple headers, start-of-body, or
                           part of another header.
                           This is a check against custom Header & fold()
                           implementations.
    Fr*Z8bit�NNTcCs|jr
|�|j||�dS)aZBased on policy, either raise defect or call register_defect.

            handle_defect(obj, defect)

        defect should be a Defect subclass, but in any case must be an
        Exception subclass.  obj is the object on which the defect should be
        registered if it is not raised.  If the raise_on_defect is True, the
        defect is raised as an error, otherwise the object and the defect are
        passed to register_defect.

        This method is intended to be called by parsers that discover defects.
        The email package parsers always call it with Defect instances.

        N)�raise_on_defect�register_defect)r�obj�defectrrr�
handle_defect�szPolicy.handle_defectcCs|jj|�dS)a�Record 'defect' on 'obj'.

        Called by handle_defect if raise_on_defect is False.  This method is
        part of the Policy API so that Policy subclasses can implement custom
        defect handling.  The default implementation calls the append method of
        the defects attribute of obj.  The objects used by the email package by
        default that get passed to this method will always have a defects
        attribute with an append method.

        N)Zdefects�append)rr=r>rrrr<�szPolicy.register_defectcCsdS)a[Return the maximum allowed number of headers named 'name'.

        Called when a header is added to a Message object.  If the returned
        value is not 0 or None, and there are already a number of headers with
        the name 'name' equal to the value returned, a ValueError is raised.

        Because the default behavior of Message's __setitem__ is to append the
        value to the list of headers, it is easy to create duplicate headers
        without realizing it.  This method allows certain headers to be limited
        in the number of instances of that header that may be added to a
        Message programmatically.  (The limit is not observed by the parser,
        which will faithfully produce as many headers as exist in the message
        being parsed.)

        The default implementation returns None for all header names.
        Nr)rrrrr�header_max_count�szPolicy.header_max_countcCst�dS)aZGiven a list of linesep terminated strings constituting the lines of
        a single header, return the (name, value) tuple that should be stored
        in the model.  The input lines should retain their terminating linesep
        characters.  The lines passed in by the email package may contain
        surrogateescaped binary data.
        N)�NotImplementedError)r�sourcelinesrrr�header_source_parse�szPolicy.header_source_parsecCst�dS)z�Given the header name and the value provided by the application
        program, return the (name, value) that should be stored in the model.
        N)rB)rrrrrr�header_store_parse�szPolicy.header_store_parsecCst�dS)awGiven the header name and the value from the model, return the value
        to be returned to the application program that is requesting that
        header.  The value passed in by the email package may contain
        surrogateescaped binary data if the lines were parsed by a BytesParser.
        The returned value should not contain any surrogateescaped data.

        N)rB)rrrrrr�header_fetch_parse�s	zPolicy.header_fetch_parsecCst�dS)a�Given the header name and the value from the model, return a string
        containing linesep characters that implement the folding of the header
        according to the policy controls.  The value passed in by the email
        package may contain surrogateescaped binary data if the lines were
        parsed by a BytesParser.  The returned value should not contain any
        surrogateescaped data.

        N)rB)rrrrrr�folds
zPolicy.foldcCst�dS)a%Given the header name and the value from the model, return binary
        data containing linesep characters that implement the folding of the
        header according to the policy controls.  The value passed in by the
        email package may contain surrogateescaped binary data.

        N)rB)rrrrrr�fold_binaryszPolicy.fold_binary)rr&r'r(r;�linesep�cte_type�max_line_length�mangle_from_Zmessage_factoryZverify_generated_headersr?r<rA�abc�abstractmethodrDrErFrGrHrrrrrps 7

)�	metaclassc@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)rz�+
    This particular policy is the backward compatibility Policy.  It
    replicates the behavior of the email package version 5.1.
    TcCs0t|t�s|St|�r(tj|tj|d�S|SdS)N)r�header_name)�
isinstance�strrr�Header�_charset�UNKNOWN8BIT)rrrrrr�_sanitize_header!s

zCompat32._sanitize_headercCs>|djdd�\}}|jd�dj|dd��}||jd�fS)a:+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.

        r�:r+z 	�Nz
)r-�lstripr�rstrip)rrCrrrrrrD-szCompat32.header_source_parsecCs||fS)z>+
        The name and value are returned unmodified.
        r)rrrrrrrE9szCompat32.header_store_parsecCs|j||�S)z�+
        If the value contains binary data, it is converted into a Header object
        using the unknown-8bit charset.  Otherwise it is returned unmodified.
        )rV)rrrrrrrF?szCompat32.header_fetch_parsecCs|j||dd�S)a+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  Non-ASCII binary data are CTE encoded using the
        unknown-8bit charset.

        T)�sanitize)�_fold)rrrrrrrGFsz
Compat32.foldcCs"|j|||jdkd�}|jdd�S)a�+
        Headers are folded using the Header folding algorithm, which preserves
        existing line breaks in the value, and wraps each resulting line to the
        max_line_length.  If cte_type is 7bit, non-ascii binary data is CTE
        encoded using the unknown-8bit charset.  Otherwise the original source
        header is used, with its existing line breaks and/or binary data.

        Z7bit)r[�ascii�surrogateescape)r\rJ�encode)rrrZfoldedrrrrHPs	zCompat32.fold_binarycCs�g}|jd|�t|t�r\t|�rL|r<tj|tj|d�}qZ|j|�d}q`tj||d�}n|}|dk	r�d}|jdk	r||j}|j|j	|j
|d��|j|j
�dj|�S)Nz%s: )rrP)rPr)rI�
maxlinelenrX)r@rQrRrrrSrTrUrKr_rIr)rrrr[�parts�hr`rrrr\\s&



zCompat32._foldN)rr&r'r(rLrVrDrErFrGrHr\rrrrrs
)r(rMZemailrrrTZemail.utilsr�__all__rr/r9�ABCMetarrrrrrr�<module>sL
(fPKc��\��8�%�%policy.cpython-36.pycnu�[���3


 \�(�@s�dZddlZddlmZmZmZmZddlmZddl	m
Z
ddlmZddl
mZdd	d
ddd
ddgZejd�ZeGdd�de��Ze�Ze`ejdd�Zejdd�Zejddd�Zejdd�ZdS)zcThis will be the home for the policy that hooks in the new
code that adds all the email6 features.
�N)�Policy�Compat32�compat32�_extend_docstrings)�_has_surrogates)�HeaderRegistry)�raw_data_manager)�EmailMessagerrr�EmailPolicy�default�strict�SMTP�HTTPz\n|\rcspeZdZdZeZdZdZe�Z	e
Z�fdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�Zddd�Z�ZS)r
aQ+
    PROVISIONAL

    The API extensions enabled by this policy are currently provisional.
    Refer to the documentation for details.

    This policy adds new header parsing and folding algorithms.  Instead of
    simple strings, headers are custom objects with custom attributes
    depending on the type of the field.  The folding algorithm fully
    implements RFCs 2047 and 5322.

    In addition to the settable attributes listed above that apply to
    all Policies, this policy adds the following additional attributes:

    utf8                -- if False (the default) message headers will be
                           serialized as ASCII, using encoded words to encode
                           any non-ASCII characters in the source strings.  If
                           True, the message headers will be serialized using
                           utf8 and will not contain encoded words (see RFC
                           6532 for more on this serialization format).

    refold_source       -- if the value for a header in the Message object
                           came from the parsing of some source, this attribute
                           indicates whether or not a generator should refold
                           that value when transforming the message back into
                           stream form.  The possible values are:

                           none  -- all source values use original folding
                           long  -- source values that have any line that is
                                    longer than max_line_length will be
                                    refolded
                           all  -- all values are refolded.

                           The default is 'long'.

    header_factory      -- a callable that takes two arguments, 'name' and
                           'value', where 'name' is a header field name and
                           'value' is an unfolded header field value, and
                           returns a string-like object that represents that
                           header.  A default header_factory is provided that
                           understands some of the RFC5322 header field types.
                           (Currently address fields and date fields have
                           special treatment, while all other fields are
                           treated as unstructured.  This list will be
                           completed before the extension is marked stable.)

    content_manager     -- an object with at least two methods: get_content
                           and set_content.  When the get_content or
                           set_content method of a Message object is called,
                           it calls the corresponding method of this object,
                           passing it the message object as its first argument,
                           and any arguments or keywords that were passed to
                           it as additional arguments.  The default
                           content_manager is
                           :data:`~email.contentmanager.raw_data_manager`.

    F�longcs*d|krtj|dt��t�jf|�dS)N�header_factory)�object�__setattr__r�super�__init__)�self�kw)�	__class__��$/usr/lib64/python3.6/email/policy.pyr\szEmailPolicy.__init__cCs|j|jS)z�+
        The implementation for this class returns the max_count attribute from
        the specialized header class that would be used to construct a header
        of type 'name'.
        )rZ	max_count)r�namerrr�header_max_countcszEmailPolicy.header_max_countcCs>|djdd�\}}|jd�dj|dd��}||jd�fS)ac+
        The name is parsed as everything up to the ':' and returned unmodified.
        The value is determined by stripping leading whitespace off the
        remainder of the first line, joining all subsequent lines together, and
        stripping any trailing carriage return or linefeed characters.  (This
        is the same as Compat32).

        r�:�z 	�Nz
)�split�lstrip�join�rstrip)rZsourcelinesr�valuerrr�header_source_parseus	zEmailPolicy.header_source_parsecCsVt|d�r$|jj�|j�kr$||fSt|t�rFt|j��dkrFtd��||j||�fS)a�+
        The name is returned unchanged.  If the input value has a 'name'
        attribute and it matches the name ignoring case, the value is returned
        unchanged.  Otherwise the name and value are passed to header_factory
        method, and the resulting custom header object is returned as the
        value.  In this case a ValueError is raised if the input value contains
        CR or LF characters.

        rrzDHeader values may not contain linefeed or carriage return characters)	�hasattrr�lower�
isinstance�str�len�
splitlines�
ValueErrorr)rrr#rrr�header_store_parse�s

zEmailPolicy.header_store_parsecCs*t|d�r|Sdjtj|��}|j||�S)ai+
        If the value has a 'name' attribute, it is returned to unmodified.
        Otherwise the name and the value with any linesep characters removed
        are passed to the header_factory method, and the resulting custom
        header object is returned.  Any surrogateescaped bytes get turned
        into the unicode unknown-character glyph.

        rr)r%r!�linesep_splitterrr)rrr#rrr�header_fetch_parse�s	
zEmailPolicy.header_fetch_parsecCs|j||dd�S)a+
        Header folding is controlled by the refold_source policy setting.  A
        value is considered to be a 'source value' if and only if it does not
        have a 'name' attribute (having a 'name' attribute means it is a header
        object of some sort).  If a source value needs to be refolded according
        to the policy, it is converted into a custom header object by passing
        the name and the value with any linesep characters removed to the
        header_factory method.  Folding of a custom header object is done by
        calling its fold method with the current policy.

        Source values are split into lines using splitlines.  If the value is
        not to be refolded, the lines are rejoined using the linesep from the
        policy and returned.  The exception is lines containing non-ascii
        binary data.  In that case the value is refolded regardless of the
        refold_source setting, which causes the binary data to be CTE encoded
        using the unknown-8bit charset.

        T)�
refold_binary)�_fold)rrr#rrr�fold�szEmailPolicy.foldcCs0|j|||jdkd�}|jr dnd}|j|d�S)a+
        The same as fold if cte_type is 7bit, except that the returned value is
        bytes.

        If cte_type is 8bit, non-ASCII binary data is converted back into
        bytes.  Headers with binary data are not refolded, regardless of the
        refold_header setting, since there is no way to know whether the binary
        data consists of single byte characters or multibyte characters.

        If utf8 is true, headers are encoded to utf8, otherwise to ascii with
        non-ASCII unicode rendered as encoded words.

        Z7bit)r/�utf8�ascii�surrogateescape)r0Zcte_typer2�encode)rrr#Zfolded�charsetrrr�fold_binary�szEmailPolicy.fold_binarycs�t|d�r|j|d�S|jr"|jntd��|j�}|jdkp�|jdko�|rft|d�t|�d�kp�t�fdd	�|d
d�D��}|s�|r�t|�r�|j	|dj
|��j|d�S|d|jj
|�|jS)
Nr)Zpolicy�inf�allrr�c3s|]}t|��kVqdS)N)r))�.0�x)�maxlenrr�	<genexpr>�sz$EmailPolicy._fold.<locals>.<genexpr>rrz: )r%r1�max_line_length�floatr*�
refold_sourcer)�anyrrr!�linesep)rrr#r/�linesZrefoldr)r=rr0�s


 zEmailPolicy._fold)F)�__name__�
__module__�__qualname__�__doc__r	Zmessage_factoryr2rArrrZcontent_managerrrr$r,r.r1r7r0�
__classcell__rr)rrr
s;
T)Zraise_on_defectz
)rC)rCr?)r2)rH�reZemail._policybaserrrrZemail.utilsrZemail.headerregistryrZemail.contentmanagerrZ
email.messager	�__all__�compiler-r
rrZclonerr
rZSMTPUTF8rrrr�<module>s0
@PKc��\V�74�3�3generator.cpython-36.opt-1.pycnu�[���3

���i�S�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZdd	l
mZd
ZdZejd�Zejd
ej�Zejd�Zejd�ZGdd�d�ZGdd�de�ZdZGdd�de�Zeeejd��ZdeZej Z dS)z:Classes to generate plain text from a message object tree.�	Generator�DecodedGenerator�BytesGenerator�N)�deepcopy)�StringIO�BytesIO)�_has_surrogates)�HeaderWriteError�_�
z
\r\n|\r|\nz^From z\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]s\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]c@s�eZdZdZd'dd�dd�Zdd�Zd(d	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZeZdd�Zdd�Zdd �Zd!d"�Zed)d#d$��Zed%d&��ZdS)*rz�Generates output from a Message object tree.

    This basic generator writes the message to the given file object as plain
    text.
    N)�policycCs6|dkr|dkrdn|j}||_||_||_||_dS)a�Create the generator for message flattening.

        outfp is the output file-like object for writing the message to.  It
        must have a write() method.

        Optional mangle_from_ is a flag that, when True (the default if policy
        is not set), escapes From_ lines in the body of the message by putting
        a `>' in front of them.

        Optional maxheaderlen specifies the longest length for a non-continued
        header.  When a header line is longer (in characters, with tabs
        expanded to 8 spaces) than maxheaderlen, the header will split as
        defined in the Header class.  Set maxheaderlen to zero to disable
        header wrapping.  The default is 78, as recommended (but not required)
        by RFC 2822.

        The policy keyword specifies a policy object that controls a number of
        aspects of the generator's operation.  If no policy is specified,
        the policy associated with the Message object passed to the
        flatten method is used.

        NT)�mangle_from_�_fp�
_mangle_from_�maxheaderlenr)�self�outfpr
rr�r�'/usr/lib64/python3.6/email/generator.py�__init__'szGenerator.__init__cCs|jj|�dS)N)r�write)r�srrrrGszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|j|j�|_d|_|j|j�|_|j}|j}zL||_||_|r�|j	�}|s�dt
jt
j
��}|j||j�|j
|�Wd||_||_XdS)a�Print the message object tree rooted at msg to the output file
        specified when the Generator instance was created.

        unixfrom is a flag that forces the printing of a Unix From_ delimiter
        before the first object in the message tree.  If the original message
        has no From_ delimiter, a `standard' one is crafted.  By default, this
        is False to inhibit the printing of any From_ delimiter.

        Note that for subobjects, no From_ line is printed.

        linesep specifies the characters used to indicate a new line in
        the output.  The default value is determined by the policy specified
        when the Generator instance was created or, if none was specified,
        from the policy associated with the msg.

        N)�linesep)�max_line_length�zFrom nobody )r�clonerr�_NL�_encode�_encoded_NLZ_EMPTY�_encoded_EMPTYZget_unixfrom�timeZctimer�_write)r�msg�unixfromrrZold_gen_policyZold_msg_policyZufromrrr�flattenKs,
zGenerator.flattencCs|j||jd|jd�S)z1Clone this generator with the exact same options.N)r)�	__class__rr)r�fprrrr|szGenerator.clonecCst�S)N)r)rrrr�_new_buffer�szGenerator._new_buffercCs|S)Nr)rrrrrr�szGenerator._encodecCsX|sdStj|�}x*|dd�D]}|j|�|j|j�q W|drT|j|d�dS)N����r)r))�NLCRE�splitrr)r�lines�linerrr�_write_lines�s

zGenerator._write_linescCs�|j}z"d|_|j�|_}|j|�Wd||_|j}|`X|rht|�}|jd|d�|jd|d�t|dd�}|dkr�|j|�n||�|jj|j	��dS)Nzcontent-transfer-encodingrzcontent-typer(�_write_headers)
r�
_munge_cter'�	_dispatchrZreplace_header�getattrr/r�getvalue)rr"ZoldfpZsfpZ	munge_cte�methrrrr!�s"zGenerator._writecCst|j�}|j�}tj||f�jdd�}t|d|d�}|dkrh|jdd�}t|d|d�}|dkrh|j}||�dS)N�-r
Z_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer2�
_writeBody)rr"�main�subZspecificr4Zgenericrrrr1�szGenerator._dispatchcCs�x�|j�D]�\}}|jj||�}|jjr�|jj}|j|jj�sRtd|�d|����|}|j|�rr|dt|��}tj	|�r�td|����|j
|�q
W|j
|j�dS)Nz folded header does not end with z: z folded header contains newline: )�	raw_itemsrZfold�verify_generated_headersr�endswithr	�len�NEWLINE_WITHOUT_FWSP�searchrr)rr"�h�v�foldedr�folded_no_lineseprrrr/�s

zGenerator._write_headerscCs�|j�}|dkrdSt|t�s.tdt|���t|j�r~|jd�}|dk	r~t|�}|d=|j	||�|j�}|d|df|_
|jr�tj
d|�}|j|�dS)Nzstring payload expected: %s�charsetzcontent-transfer-encodingzcontent-typez>From )�get_payload�
isinstance�str�	TypeError�typer�_payloadZ	get_paramrZset_payloadr0r�fcrer=r.)rr"�payloadrHrrr�_handle_text�s"


zGenerator._handle_textcCs�g}|j�}|dkrg}n(t|t�r2|j|�dSt|t�sB|g}x>|D]6}|j�}|j|�}|j|d|jd�|j	|j
��qHW|j�}|s�|jj
|�}|j|�}|j|�|jdk	r�|jr�tjd|j�}	n|j}	|j|	�|j|j�|jd||j�|�r|jj|jd��x4|D],}
|j|jd||j�|jj|
��qW|j|jd|d|j�|jdk	�r�|j�r�tjd|j�}n|j}|j|�dS)NF)r#rz>From z--r)rIrJrKr�listr'rr$r�appendr3Zget_boundaryrr9�_make_boundaryZset_boundary�preamblerrOr=r.r�pop�epilogue)rr"ZmsgtextsZsubparts�partr�g�boundaryZalltextrUZ	body_partrWrrr�_handle_multipart
sJ









zGenerator._handle_multipartcCs0|j}|jdd�|_z|j|�Wd||_XdS)Nr)r)rrr[)rr"�prrr�_handle_multipart_signedGs
z"Generator._handle_multipart_signedcCs�g}x�|j�D]t}|j�}|j|�}|j|d|jd�|j�}|j|j�}|rx|d|jkrx|j	|jj
|dd���q|j	|�qW|jj|jj
|��dS)NF)r#rr(r)r))
rIr'rr$rr3r+rrrSr9rr)rr"ZblocksrXrrY�textr,rrr�_handle_message_delivery_statusRs
z)Generator._handle_message_delivery_statuscCs^|j�}|j|�}|j}t|t�rD|j|jd�d|jd�|j�}n
|j	|�}|j
j|�dS)NrF)r#r)r'rrNrJrRr$rIrr3rrr)rr"rrYrPrrr�_handle_messagegs




zGenerator._handle_messagecCsztjtj�}d	t|d}|dkr(|S|}d}xD|jdtj|�dtj�}|j	|�sZP|dt
|�}|d7}q2W|S)
N�=�z==rz^--z(--)?$�.r(z===============)�randomZ	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINErCrK)�clsr^�tokenrZ�bZcounterZcrerrrrT�s
zGenerator._make_boundarycCstj||�S)N)ri�compile)rlr�flagsrrrrh�szGenerator._compile_re)NN)FN)N)�__name__�
__module__�__qualname__�__doc__rrr$rr'rr.r!r1r/rQr;r[r]r_r`�classmethodrTrhrrrrrs*
1#:csPeZdZdZdd�Zdd�Zdd�Zdd	�Z�fd
d�ZeZ	e
dd
��Z�ZS)ra�Generates a bytes version of a Message object tree.

    Functionally identical to the base Generator except that the output is
    bytes and not string.  When surrogates were used in the input to encode
    bytes, these are decoded back to bytes for output.  If the policy has
    cte_type set to 7bit, then the message is transformed such that the
    non-ASCII bytes are properly content transfer encoded, using the charset
    unknown-8bit.

    The outfp object must accept bytes in its write method.
    cCs|jj|jdd��dS)N�ascii�surrogateescape)rr�encode)rrrrrr�szBytesGenerator.writecCst�S)N)r)rrrrr'�szBytesGenerator._new_buffercCs
|jd�S)Nrv)rx)rrrrrr�szBytesGenerator._encodecCs�x�|j�D]�\}}|jj||�}|jjr�|jjj�}|j|�sRtd|�d|����|}|j|�rr|dt|��}t	j
|�r�td|����|jj|�q
W|j|j
�dS)Nz folded header does not end with z: z folded header contains newline: )r>rZfold_binaryr?rrxr@r	rA�NEWLINE_WITHOUT_FWSP_BYTESrCrrr)rr"rDrErFrrGrrrr/�s


zBytesGenerator._write_headerscs^|jdkrdSt|j�rJ|jjdkrJ|jr<tjd|j�|_|j|j�ntt	|�j
|�dS)NZ7bitz>From )rNrrZcte_typerrOr=r.�superrrQ)rr")r%rrrQ�s
zBytesGenerator._handle_textcCstj|jd�|�S)Nrv)rirorx)rlrrprrrrh�szBytesGenerator._compile_re)
rqrrrsrtrr'rr/rQr;rurh�
__classcell__rr)r%rr�s
zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s(eZdZdZddd�dd�Zdd�ZdS)	rz�Generates a text representation of a message.

    Like the Generator base class, except that non-text parts are substituted
    with a format string representing the part.
    N)rcCs.tj|||||d�|dkr$t|_n||_dS)a�Like Generator.__init__() except that an additional optional
        argument is allowed.

        Walks through all subparts of a message.  If the subpart is of main
        type `text', then it prints the decoded payload of the subpart.

        Otherwise, fmt is a format string that is used instead of the message
        payload.  fmt is expanded with the following keywords (in
        %(keyword)s format):

        type       : Full MIME type of the non-text part
        maintype   : Main MIME type of the non-text part
        subtype    : Sub-MIME type of the non-text part
        filename   : Filename of the non-text part
        description: Description associated with the non-text part
        encoding   : Content transfer encoding of the non-text part

        The default value for fmt is None, meaning

        [Non-text (%(type)s) part of message omitted, filename %(filename)s]
        )rN)rr�_FMTrg)rrr
rZfmtrrrrr�s
zDecodedGenerator.__init__cCs�x�|j�D]v}|j�}|dkr4t|jdd�|d�q
|dkr>q
t|j|j�|j�|j�|jd�|jdd�|jd	d
�d�|d�q
WdS)Nr^F)�decode)�fileZ	multipartz
[no filename]zContent-Descriptionz[no description]zContent-Transfer-Encodingz
[no encoding])rM�maintype�subtype�filenameZdescription�encoding)	�walkr6�printrIrgZget_content_typer7�get_filename�get)rr"rXrrrrr1�s 
zDecodedGenerator._dispatch)NNN)rqrrrsrtrr1rrrrr�sr(z%%0%dd)!rt�__all__rirer rd�copyr�iorrZemail.utilsrZemail.errorsr	r8�NLror*rkrOrBryrrr|rrA�reprrfZ_widthrgrTrrrr�<module>s0



|?;PKc��\�$f�(�(feedparser.cpython-36.opt-1.pycnu�[���3


 \�X�@s�dZddgZddlZddlmZddlmZddlmZddl	m
Z
ejd	�Zejd
�Z
ejd�Zejd
�Zejd�Zd
ZdZe�ZGdd�de�ZGdd�d�ZGdd�de�ZdS)aFeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.
�
FeedParser�BytesFeedParser�N)�errors)�compat32)�deque)�StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])��
c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BufferedSubFileakA file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    cCs$tdd�|_t�|_g|_d|_dS)Nr)�newlineF)r�_partialr�_lines�	_eofstack�_closed)�self�r�(/usr/lib64/python3.6/email/feedparser.py�__init__5szBufferedSubFile.__init__cCs|jj|�dS)N)r�append)rZpredrrr�push_eof_matcher@sz BufferedSubFile.push_eof_matchercCs
|jj�S)N)r�pop)rrrr�pop_eof_matcherCszBufferedSubFile.pop_eof_matchercCs<|jjd�|j|jj��|jjd�|jj�d|_dS)NrT)r�seek�	pushlines�	readlines�truncater)rrrr�closeFs

zBufferedSubFile.closecCsN|js|jrdStS|jj�}x*t|j�D]}||�r*|jj|�dSq*W|S)Nr)r
r�NeedMoreData�popleft�reversedr�
appendleft)r�lineZateofrrr�readlineNs
zBufferedSubFile.readlinecCs|jj|�dS)N)r
r )rr!rrr�
unreadline`szBufferedSubFile.unreadlinecCsx|jj|�d|kr d|kr dS|jjd�|jj�}|jjd�|jj�|djd�sj|jj|j��|j|�dS)z$Push some new data into this object.r	�
Nr����)r�writerrr�endswithrr)r�data�partsrrr�pushes

zBufferedSubFile.pushcCs|jj|�dS)N)r
�extend)r�linesrrrrzszBufferedSubFile.pushlinescCs|S)Nr)rrrr�__iter__}szBufferedSubFile.__iter__cCs|j�}|dkrt�|S)Nr)r"�
StopIteration)rr!rrr�__next__�szBufferedSubFile.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrr"r#r+rr.r0rrrrr
-sr
c@s`eZdZdZded�dd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rzA feed-style parser of email.N)�policycCs�||_d|_|dkr<|jdkr2ddlm}||_qn|j|_n2||_y||jd�Wntk
rld|_YnXt�|_g|_	|j
�j|_d|_
d|_d|_dS)a_factory is called with no arguments to create a new message obj

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        FNr)�Message)r5T)r5�_old_style_factoryZmessage_factoryZ
email.messager6�_factory�	TypeErrorr
�_input�	_msgstack�	_parsegenr0�_parse�_cur�_last�_headersonly)rr8r5r6rrrr�s$

zFeedParser.__init__cCs
d|_dS)NT)r@)rrrr�_set_headersonly�szFeedParser._set_headersonlycCs|jj|�|j�dS)zPush more data into the parser.N)r:r+�_call_parse)rr)rrr�feed�szFeedParser.feedcCs&y|j�Wntk
r YnXdS)N)r=r/)rrrrrB�szFeedParser._call_parsecCsJ|jj�|j�|j�}|j�dkrF|j�rFtj�}|jj	||�|S)z<Parse all remaining data and return the root message object.�	multipart)
r:rrB�_pop_message�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr5�
handle_defect)r�root�defectrrrr�s

zFeedParser.closecCsn|jr|j�}n|j|jd�}|jr<|jj�dkr<|jd�|jrR|jdj|�|jj|�||_||_	dS)N)r5zmultipart/digestzmessage/rfc822r%r&)
r7r8r5r>�get_content_typeZset_default_typer;Zattachrr?)r�msgrrr�_new_message�s

zFeedParser._new_messagecCs(|jj�}|jr|jd|_nd|_|S)Nr%r&)r;rr>)r�retvalrrrrE�s

zFeedParser._pop_messageccs6|j�g}xb|jD]X}|tkr(tVqtj|�sbtj|�s`tj�}|jj	|j
|�|jj|�P|j|�qW|j
|�|jr�g}x2|jj�}|tkr�tVq�|dkr�P|j|�q�W|j
jtj|��dS|j
j�dk�r�x�|jjtj�x$|j�D]}|tk�rtVq�Pq�W|j�}|jj�x&|jj�}|tk�rFtV�q(P�q(Wx&|jj�}|tk�rntV�qPP�qPW|dk�r�P|jj|�q�WdS|j
j�dk�r�x(|j�D]}|tk�r�tV�q�P�q�W|j�dS|j
j�dk�r�|j
j�}|dk�rbtj�}|jj	|j
|�g}x.|jD]$}|tk�r<tV�q$|j|��q$W|j
jtj|��dS|j
jdd�j�dk�r�tj�}|jj	|j
|�d	|}tjd
tj |�d�}	d}
g}d
}d
}
�x|jj�}|tk�r�tV�q�|dk�r�P|	j|�}|�r�|j!d��rd}
|j!d�}P|
�r~|�rj|d}t"j#|�}|�r\|dt$|j!d���|d<tj|�|j
_%d
}
|jj|��q�xB|jj�}|tk�r�tV�q�|	j|�}|�s�|jj|�P�q�W|jj|	j�x(|j�D]}|tk�r�tV�q�P�q�W|j&j�dk�rb|j&j'}|dk�r&d|j&_'n:|dk	�r�t"j#|�}|�r�t$|j!d��}|d|�|j&_'nD|j&j(}t)|t*��r�t"j#|�}|�r�|dt$|j!d���}||j&_(|jj�|j�|j
|_&n
|j|��q�W|
�r>tj+�}|jj	|j
|�|j
jtj|��g}x$|jD]}|tk�rtV�q�qWtj|�|j
_'dS|
�s`tj,�}|jj	|j
|�dS|�rndg}ng}x.|jD]$}|tk�r�tV�qz|j|��qzW|�r�|d}t-j|�}|�r�|t$|j!d��d�|d<tj|�|j
_'dSg}x.|jD]$}|tk�rtV�q�|j|��q�W|j
jtj|��dS)Nrzmessage/delivery-status�messagerDzcontent-transfer-encoding�8bit�7bit�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr%r)rPrOrQr&r&).rLr:r�headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr5rGr>r#r�_parse_headersr@r"Zset_payload�EMPTYSTRING�joinrJrr<rErrFZget_boundaryZNoBoundaryInMultipartDefect�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�search�len�preambler?�epilogueZ_payload�
isinstance�strZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr!rIr-rMrK�boundaryZ	separatorZ
boundaryreZcapturing_preamblercrSZclose_boundary_seen�moZlastlineZeolmordrRZpayload�	firstlineZbolmorrrr<�sf




































zFeedParser._parsegenc	Cs^d}g}�x4t|�D�]&\}}|ddkrV|sJtj|�}|jj|j|�q|j|�q|rx|jj|jj|��dg}}|j	d��r�|dkr�t
j|�}|r�|dt|j
d���}|jj|�qn:|t|�dkr�|jj|�dStj|�}|jjj|�q|jd�}|dk�r*tjd�}|jjj|�q|d|�}|g}qW|�rZ|jj|jj|��dS)Nrrz 	zFrom r%�:zMissing header name.)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr5rGr>rZset_rawZheader_source_parse�
startswithr`rarbr_Zset_unixfromr:r#ZMisplacedEnvelopeHeaderDefectZdefects�findZInvalidHeaderDefect)	rr-Z
lastheaderZ	lastvalue�linenor!rIri�irrrrW�sF








zFeedParser._parse_headers)N)r1r2r3r4rrrArCrBrrLrEr<rWrrrrr�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst�j|jdd��dS)N�ascii�surrogateescape)�superrC�decode)rr))�	__class__rrrCszBytesFeedParser.feed)r1r2r3r4rC�
__classcell__rr)rurrs)r4�__all__r\ZemailrZemail._policybaser�collectionsr�iorr]rVrgr`ZNLCRE_crackrTrX�NL�objectrr
rrrrrr�<module>s(




[PKc��\"}Htt#_encoded_words.cpython-36.opt-2.pycnu�[���3


 \F!�@s�ddlZddlZddlZddlZddlmZmZddlmZdddddd	d
dgZ	ej
ejd�jd
d��Z
dd�ZGdd�de�Ze�Zdeed�<dd�Zdd�Zdd�Zdd�Zdd	�Zeed�Zdd
�Zeed�Zeed�Zddd�ZdS)�N)�
ascii_letters�digits)�errors�decode_q�encode_q�decode_b�encode_b�len_q�len_b�decode�encodes=([a-fA-F0-9]{2})cCstt|jd�d�g�S)N��)�bytes�int�group)�m�r�,/usr/lib64/python3.6/email/_encoded_words.py�<lambda>AsrcCs|jdd�}t|�gfS)N�_� )�replace�_q_byte_subber)�encodedrrrrCsc@s,eZdZdejd�ejd�Zdd�ZdS)�	_QByteMaps-!*+/�asciicCs.||jkrt|�||<ndj|�||<||S)Nz={:02X})�safe�chr�format)�self�keyrrr�__missing__Ms
z_QByteMap.__missing__N)�__name__�
__module__�__qualname__rrrrr"rrrrrIsr�_� cCsdjdd�|D��S)N�css|]}t|VqdS)N)�_q_byte_map)�.0�xrrr�	<genexpr>Zszencode_q.<locals>.<genexpr>)�join)�bstringrrrrYscCstdd�|D��S)Ncss|]}tt|�VqdS)N)�lenr))r*r+rrrr,]szlen_q.<locals>.<genexpr>)�sum)r.rrrr	\scCs�t|�d}|r ddd|�nd}y$tj||dd�|rDtj�gngfStjk
r�ytj|dd�tj�gfStjk
r�y"tj|ddd�tj�tj�gfStjk
r�|tj�gfSXYnXYnXdS)N�s===�T)ZvalidateFs==)	r/�base64Z	b64decoderZInvalidBase64PaddingDefect�binascii�ErrorZInvalidBase64CharactersDefectZInvalidBase64LengthDefect)rZpad_errZmissing_paddingrrrrds cCstj|�jd�S)Nr)r3Z	b64encoder)r.rrrr�scCs&tt|�d�\}}|d|r dndS)N�r1r)�divmodr/)r.Zgroups_of_3Zleftoverrrrr
�s)�q�bc	Cs�|jd�\}}}}}|jd�\}}}|j�}|jdd�}t||�\}}y|j|�}Wnvtk
r�|jtj	dj
|���|j|d�}YnBtk
r�|jdd�}|j�dkr�|jtjdj
|���YnX||||fS)N�?�*r�surrogateescapez:Encoded word contains bytes not decodable using {} charsetzunknown-8bitz<Unknown charset {} in encoded word; decoded as unknown bytes)
�split�	partition�lowerr�
_cte_decodersr�UnicodeError�appendrZUndecodableBytesDefectr�LookupErrorZCharsetError)	Zewr&�charsetZcteZ
cte_string�langr.Zdefects�stringrrrr�s"
�utf-8r(cCs||dkr|jdd�}n
|j|�}|dkrTtd|�}td|�}||dkrPdnd}t||�}|rld|}dj||||�S)	Nzunknown-8bitrr<r8r9�r;z=?{}{}?{}?{}?=)r�_cte_encode_length�
_cte_encodersr)rFrD�encodingrEr.ZqlenZblenrrrrr�s
)rGNr()�rer3r4�	functoolsrFrrZemailr�__all__�partial�compile�subrr�dictrr)�ordrr	rrr
r@rrJrIrrrrr�<module>*s@
&+PKc��\���Ajjencoders.cpython-36.opt-1.pycnu�[���3


 \��@sTdZddddgZddlmZddlmZdd	�Zd
d�Z	dd�Z
dd�Zd
d�ZdS)z Encodings and related functions.�encode_7or8bit�
encode_base64�encode_noop�
encode_quopri�)�encodebytes)�encodestringcCst|dd�}|jdd�S)NT)Z	quotetabs� s=20)�
_encodestring�replace)�s�enc�r
�&/usr/lib64/python3.6/email/encoders.py�_qencodesrcCs0|jdd�}tt|�d�}|j|�d|d<dS)zlEncode the message's payload in Base64.

    Also, add an appropriate Content-Transfer-Encoding header.
    T)�decode�ascii�base64zContent-Transfer-EncodingN)�get_payload�str�_bencode�set_payload)�msg�orig�encdatar
r
rrs
cCs*|jdd�}t|�}|j|�d|d<dS)zvEncode the message's payload in quoted-printable.

    Also, add an appropriate Content-Transfer-Encoding header.
    T)rzquoted-printablezContent-Transfer-EncodingN)rrr)rrrr
r
rr&s
cCsX|jdd�}|dkr d|d<dSy|jd�Wntk
rJd|d<Yn
Xd|d<dS)z9Set the Content-Transfer-Encoding header to 7bit or 8bit.T)rNZ7bitzContent-Transfer-EncodingrZ8bit)rr�UnicodeError)rrr
r
rr2scCsdS)zDo nothing.Nr
)rr
r
rrDsN)
�__doc__�__all__rrr�quoprirr	rrrrrr
r
r
r�<module>sPKc��\]䕟��errors.cpython-36.pycnu�[���3

���i��@s�dZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
ee�ZGdd�de�ZGd
d�de�Z	Gdd�de
�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZeZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�ZGd'd(�d(e�ZGd)d*�d*e�ZGd+d,�d,e�ZGd-d.�d.e�ZGd/d0�d0e�ZGd1d2�d2e�ZGd3d4�d4e�Zd5S)6z email package exception classes.c@seZdZdZdS)�MessageErrorz+Base class for errors in the email package.N)�__name__�
__module__�__qualname__�__doc__�rr�$/usr/lib64/python3.6/email/errors.pyrsrc@seZdZdZdS)�MessageParseErrorz&Base class for message parsing errors.N)rrrrrrrrrsrc@seZdZdZdS)�HeaderParseErrorzError while parsing headers.N)rrrrrrrrr	sr	c@seZdZdZdS)�
BoundaryErrorz#Couldn't find terminating boundary.N)rrrrrrrrr
sr
c@seZdZdZdS)�MultipartConversionErrorz(Conversion to a multipart is prohibited.N)rrrrrrrrrsrc@seZdZdZdS)�CharsetErrorzAn illegal charset was given.N)rrrrrrrrrsrc@seZdZdZdS)�HeaderWriteErrorzError while writing headers.N)rrrrrrrrr
 sr
cs"eZdZdZd�fdd�	Z�ZS)�
MessageDefectz Base class for a message defect.Ncs|dk	rt�j|�||_dS)N)�super�__init__�line)�selfr)�	__class__rrr(szMessageDefect.__init__)N)rrrrr�
__classcell__rr)rrr%src@seZdZdZdS)�NoBoundaryInMultipartDefectzBA message claimed to be a multipart but had no boundary parameter.N)rrrrrrrrr-src@seZdZdZdS)�StartBoundaryNotFoundDefectz+The claimed start boundary was never found.N)rrrrrrrrr0src@seZdZdZdS)�CloseBoundaryNotFoundDefectzEA start boundary was found, but not the corresponding close boundary.N)rrrrrrrrr3src@seZdZdZdS)�#FirstHeaderLineIsContinuationDefectz;A message had a continuation line as its first header line.N)rrrrrrrrr6src@seZdZdZdS)�MisplacedEnvelopeHeaderDefectz?A 'Unix-from' header was found in the middle of a header block.N)rrrrrrrrr9src@seZdZdZdS)� MissingHeaderBodySeparatorDefectzEFound line with no leading whitespace and no colon before blank line.N)rrrrrrrrr<src@seZdZdZdS)�!MultipartInvariantViolationDefectz?A message claimed to be a multipart but no subparts were found.N)rrrrrrrrrAsrc@seZdZdZdS)�-InvalidMultipartContentTransferEncodingDefectzEAn invalid content transfer encoding was set on the multipart itself.N)rrrrrrrrrDsrc@seZdZdZdS)�UndecodableBytesDefectz0Header contained bytes that could not be decodedN)rrrrrrrrrGsrc@seZdZdZdS)�InvalidBase64PaddingDefectz/base64 encoded sequence had an incorrect lengthN)rrrrrrrrrJsrc@seZdZdZdS)�InvalidBase64CharactersDefectz=base64 encoded sequence had characters not in base64 alphabetN)rrrrrrrrrMsrc@seZdZdZdS)�InvalidBase64LengthDefectz4base64 encoded sequence had invalid length (1 mod 4)N)rrrrrrrrr Psr cs eZdZdZ�fdd�Z�ZS)�HeaderDefectzBase class for a header defect.cst�j||�dS)N)rr)r�args�kw)rrrrXszHeaderDefect.__init__)rrrrrrrr)rrr!Usr!c@seZdZdZdS)�InvalidHeaderDefectz+Header is not valid, message gives details.N)rrrrrrrrr$[sr$c@seZdZdZdS)�HeaderMissingRequiredValuez(A header that must have a value had noneN)rrrrrrrrr%^sr%cs(eZdZdZ�fdd�Zdd�Z�ZS)�NonPrintableDefectz8ASCII characters outside the ascii-printable range foundcst�j|�||_dS)N)rr�non_printables)rr')rrrrdszNonPrintableDefect.__init__cCsdj|j�S)Nz6the following ASCII non-printables found in header: {})�formatr')rrrr�__str__hszNonPrintableDefect.__str__)rrrrrr)rrr)rrr&asr&c@seZdZdZdS)�ObsoleteHeaderDefectz0Header uses syntax declared obsolete by RFC 5322N)rrrrrrrrr*lsr*c@seZdZdZdS)�NonASCIILocalPartDefectz(local_part contains non-ASCII charactersN)rrrrrrrrr+osr+N)r�	Exceptionrrr	r
�	TypeErrorrrr
�
ValueErrorrrrrrrrZMalformedHeaderDefectrrrrrr r!r$r%r&r*r+rrrr�<module>s6PKc��\y�����_encoded_words.cpython-36.pycnu�[���3


 \F!�@s�dZddlZddlZddlZddlZddlmZmZddlm	Z	ddddd	d
ddgZ
ejejd
�j
dd��Zdd�ZGdd�de�Ze�Zdeed�<dd�Zdd	�Zdd�Zdd�Zdd
�Zeed�Zdd�Zeed�Zeed�Zddd�ZdS) z� Routines for manipulating RFC2047 encoded words.

This is currently a package-private API, but will be considered for promotion
to a public API if there is demand.

�N)�
ascii_letters�digits)�errors�decode_q�encode_q�decode_b�encode_b�len_q�len_b�decode�encodes=([a-fA-F0-9]{2})cCstt|jd�d�g�S)N��)�bytes�int�group)�m�r�,/usr/lib64/python3.6/email/_encoded_words.py�<lambda>AsrcCs|jdd�}t|�gfS)N�_� )�replace�_q_byte_subber)�encodedrrrrCsc@s,eZdZdejd�ejd�Zdd�ZdS)�	_QByteMaps-!*+/�asciicCs.||jkrt|�||<ndj|�||<||S)Nz={:02X})�safe�chr�format)�self�keyrrr�__missing__Ms
z_QByteMap.__missing__N)�__name__�
__module__�__qualname__rrrrr"rrrrrIsr�_� cCsdjdd�|D��S)N�css|]}t|VqdS)N)�_q_byte_map)�.0�xrrr�	<genexpr>Zszencode_q.<locals>.<genexpr>)�join)�bstringrrrrYscCstdd�|D��S)Ncss|]}tt|�VqdS)N)�lenr))r*r+rrrr,]szlen_q.<locals>.<genexpr>)�sum)r.rrrr	\scCs�t|�d}|r ddd|�nd}y$tj||dd�|rDtj�gngfStjk
r�ytj|dd�tj�gfStjk
r�y"tj|ddd�tj�tj�gfStjk
r�|tj�gfSXYnXYnXdS)N�s===�T)ZvalidateFs==)	r/�base64Z	b64decoderZInvalidBase64PaddingDefect�binascii�ErrorZInvalidBase64CharactersDefectZInvalidBase64LengthDefect)rZpad_errZmissing_paddingrrrrds cCstj|�jd�S)Nr)r3Z	b64encoder)r.rrrr�scCs&tt|�d�\}}|d|r dndS)N�r1r)�divmodr/)r.Zgroups_of_3Zleftoverrrrr
�s)�q�bc	Cs�|jd�\}}}}}|jd�\}}}|j�}|jdd�}t||�\}}y|j|�}Wnvtk
r�|jtj	dj
|���|j|d�}YnBtk
r�|jdd�}|j�dkr�|jtjdj
|���YnX||||fS)a�Decode encoded word and return (string, charset, lang, defects) tuple.

    An RFC 2047/2243 encoded word has the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' may be omitted but the other parts may not be.

    This function expects exactly such a string (that is, it does not check the
    syntax and may raise errors if the string is not well formed), and returns
    the encoded_string decoded first from its Content Transfer Encoding and
    then from the resulting bytes into unicode using the specified charset.  If
    the cte-decoded string does not successfully decode using the specified
    character set, a defect is added to the defects list and the unknown octets
    are replaced by the unicode 'unknown' character \uFDFF.

    The specified charset and language are returned.  The default for language,
    which is rarely if ever encountered, is the empty string.

    �?�*r�surrogateescapez:Encoded word contains bytes not decodable using {} charsetzunknown-8bitz<Unknown charset {} in encoded word; decoded as unknown bytes)
�split�	partition�lowerr�
_cte_decodersr�UnicodeError�appendrZUndecodableBytesDefectr�LookupErrorZCharsetError)	Zewr&�charsetZcteZ
cte_string�langr.Zdefects�stringrrrr�s"
�utf-8r(cCs||dkr|jdd�}n
|j|�}|dkrTtd|�}td|�}||dkrPdnd}t||�}|rld|}d	j||||�S)
aEncode string using the CTE encoding that produces the shorter result.

    Produces an RFC 2047/2243 encoded word of the form:

        =?charset*lang?cte?encoded_string?=

    where '*lang' is omitted unless the 'lang' parameter is given a value.
    Optional argument charset (defaults to utf-8) specifies the charset to use
    to encode the string to binary before CTE encoding it.  Optional argument
    'encoding' is the cte specifier for the encoding that should be used ('q'
    or 'b'); if it is None (the default) the encoding which produces the
    shortest encoded sequence is used, except that 'q' is preferred if it is up
    to five characters longer.  Optional argument 'lang' (default '') gives the
    RFC 2243 language string to specify in the encoded word.

    zunknown-8bitrr<Nr8r9�r;z=?{}{}?{}?{}?=)r�_cte_encode_length�
_cte_encodersr)rFrD�encodingrEr.ZqlenZblenrrrrr�s
)rGNr()�__doc__�rer3r4�	functoolsrFrrZemailr�__all__�partial�compile�subrr�dictrr)�ordrr	rrr
r@rrJrIrrrrr�<module>sB$
&+PKc��\b�UC%C%_parseaddr.cpython-36.opt-2.pycnu�[���3

���i�D�@s�ddddgZddlZddlZdZdZdZd	d
ddd
dddddddddddd
dddddddgZd d!d"d#d$d%d&gZddddd8d9d:d;d<d=d>d?d@dAd-�Zd.d�Z	d/d0�Z
d1d�Zd2d�Zd3d�Z
Gd4d5�d5�ZGd6d7�d7e�ZdS)B�	mktime_tz�	parsedate�parsedate_tz�quote�N� �z, ZjanZfebZmarZaprZmayZjunZjulZaug�sep�octZnovZdecZjanuaryZfebruaryZmarchZaprilZjuneZjulyZaugustZ	septemberZoctoberZnovemberZdecemberZmonZtueZwedZthuZfriZsatZsuni�i,i�iXi�i )ZUTZUTCZGMT�ZZASTZADTZESTZEDTZCSTZCDTZMSTZMDTZPSTZPDTcCs,t|�}|sdS|ddkr$d|d<t|�S)N�	r)�
_parsedate_tz�tuple)�data�res�r�(/usr/lib64/python3.6/email/_parseaddr.pyr-scCs�|sdS|j�}|djd�s.|dj�tkr6|d=n.|djd�}|dkrd|d|dd�|d<t|�dkr�|djd�}t|�dkr�||dd�}t|�dk�r|d}|jd�}|dkr�|jd�}|dkr�|d|�||d�g|dd�<n
|jd�t|�d	k�rdS|dd	�}|\}}}}}|j�}|tk�rZ||j�}}|tk�rZdStj	|�d}|d
k�rz|d
8}|ddk�r�|dd�}|jd�}|dk�r�||}}|ddk�r�|dd�}|dj
��s�||}}|ddk�r�|dd�}|jd�}t|�dk�r$|\}	}
d
}n~t|�dk�r>|\}	}
}ndt|�dk�r�d|dk�r�|djd�}t|�dk�r�|\}	}
d}nt|�dk�r�|\}	}
}ndSy,t|�}t|�}t|	�}	t|
�}
t|�}Wntk
�r�dSX|dk�r|dk�r|d7}n|d7}d}|j
�}|tk�r,t|}n>yt|�}Wntk
�rNYnX|dk�rj|jd��rjd}|�r�|dk�r�d}
|}nd}
|
|dd|dd}||||	|
|ddd|g
S)Nr�,���-��+r���:��0�.�d�Dili�i�<���r!r!r!r!r!r!r!r!)�split�endswith�lower�	_daynames�rfind�len�find�append�_monthnames�index�isdigit�int�
ValueError�upper�
_timezones�
startswith)r�iZstuff�sZddZmmZyyZtmZtzZthhZtmmZtssZtzoffsetZtzsignrrrr9s�


"














rcCs&t|�}t|t�r|dd�S|SdS)Nr)r�
isinstancer
)r�trrrr�s
cCs<|ddkr"tj|dd�d�Stj|�}||dSdS)Nr�rr!)r!)�timeZmktime�calendarZtimegm)rr5rrrr�s
cCs|jdd�jdd�S)N�\z\\�"z\")�replace)�strrrrr�sc@sxeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dd�Zdd�Zdd�Z
ddd�Zdd�ZdS)�
AddrlistClasscCsZd|_d|_d|_d|_|j|j|_|j|j|j|_|jjdd�|_||_g|_	dS)Nz()<>@,:;."[]rz 	z
rr)
�specials�pos�LWSZCR�FWS�atomendsr;�
phraseends�field�commentlist)�selfrDrrr�__init__�szAddrlistClass.__init__cCs�g}x�|jt|j�kr�|j|j|jdkr^|j|jdkrN|j|j|j�|jd7_q|j|jdkr�|jj|j��qPqWtj|�S)Nz

r�()	r?r'rDr@r)rE�
getcomment�EMPTYSTRING�join)rFZwslistrrr�gotonext�szAddrlistClass.gotonextcCs>g}x4|jt|j�kr8|j�}|r,||7}q|jd�qW|S)Nr)rr)r?r'rD�
getaddressr))rF�resultZadrrr�getaddrlist�s
zAddrlistClass.getaddrlistcCs�g|_|j�|j}|j}|j�}|j�g}|jt|j�kr\|rXtj|j�|dfg}�n\|j|jdkr�||_||_|j�}tj|j�|fg}�n"|j|jdk�rg}t|j�}|jd7_x�|jt|j�k�r|j�|j|ko�|j|jdk�r|jd7_P||j	�}q�Wn�|j|jdk�rx|j
�}|j�rftj|�ddj|j�d	|fg}ntj|�|fg}n@|�r�tj|j�|dfg}n"|j|j|jk�r�|jd7_|j�|jt|j�k�r�|j|jd
k�r�|jd7_|S)Nrz.@rr�;�<z (r�)r)rErLr?�
getphraselistr'rD�SPACErK�getaddrspecrM�getrouteaddrr>)rFZoldposZoldcl�plistZ
returnlistZaddrspecZfieldlenZ	routeaddrrrrrMsL
&$zAddrlistClass.getaddresscCs�|j|jdkrdSd}|jd7_|j�d}x�|jt|j�kr�|rV|j�d}n~|j|jdkrx|jd7_Pn\|j|jdkr�|jd7_d}n8|j|jdkr�|jd7_n|j�}|jd7_P|j�q4W|S)	NrQFrr�>�@Tr)rDr?rLr'�	getdomainrU)rFZexpectrouteZadlistrrrrV?s.zAddrlistClass.getrouteaddrcCs\g}|j�x�|jt|j�kr�d}|j|jdkrj|rL|dj�rL|j�|jd�|jd7_d}nf|j|jdkr�|jdt|j���n>|j|j|j	kr�|r�|d	j�r�|j�Pn|j|j
��|j�}|r|r|j|�qW|jt|j�k�s|j|jdk�rtj|�S|jd�|jd7_|j�|j
�}|�sNtStj|�|S)
NTrrFr:z"%s"rYr!r!)rLr?r'rD�strip�popr)r�getquoterB�getatomrJrKrZ)rFZaslistZpreserve_wsZwsZdomainrrrrU_s:
$

zAddrlistClass.getaddrspeccCs�g}x�|jt|j�kr�|j|j|jkr8|jd7_q|j|jdkrZ|jj|j��q|j|jdkrz|j|j��q|j|jdkr�|jd7_|jd�q|j|jdkr�tS|j|j|j	kr�Pq|j|j
��qWtj|�S)NrrH�[rrY)r?r'rDr@rEr)rI�getdomainliteralrJrBr^rK)rFZsdlistrrrrZ�s"zAddrlistClass.getdomainTcCs�|j|j|krdSdg}d}|jd7_x�|jt|j�kr�|rZ|j|j|j�d}np|j|j|kr||jd7_PnN|r�|j|jdkr�|j|j��q.n(|j|jdkr�d}n|j|j|j�|jd7_q.Wtj|�S)NrFrrHr9T)rDr?r'r)rIrJrK)rFZ	begincharZendcharsZ
allowcommentsZslistrrrr�getdelimited�s(
zAddrlistClass.getdelimitedcCs|jddd�S)Nr:z"
F)ra)rFrrrr]�szAddrlistClass.getquotecCs|jddd�S)NrHz)
T)ra)rFrrrrI�szAddrlistClass.getcommentcCsd|jddd�S)Nz[%s]r_z]
F)ra)rFrrrr`�szAddrlistClass.getdomainliteralNcCshdg}|dkr|j}xH|jt|j�kr\|j|j|kr:Pn|j|j|j�|jd7_qWtj|�S)Nrr)rBr?r'rDr)rJrK)rFrBZatomlistrrrr^�szAddrlistClass.getatomcCs�g}x�|jt|j�kr�|j|j|jkr8|jd7_q|j|jdkrX|j|j��q|j|jdkrz|jj|j��q|j|j|jkr�Pq|j|j	|j��qW|S)Nrr:rH)
r?r'rDrAr)r]rErIrCr^)rFrWrrrrS�szAddrlistClass.getphraselist)T)N)�__name__�
__module__�__qualname__rGrLrOrMrVrUrZrar]rIr`r^rSrrrrr=�s
; &
%
r=c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�AddressListcCs&tj||�|r|j�|_ng|_dS)N)r=rGrO�addresslist)rFrDrrrrG�szAddressList.__init__cCs
t|j�S)N)r'rf)rFrrr�__len__szAddressList.__len__cCsBtd�}|jdd�|_x$|jD]}||jkr |jj|�q W|S)N)rerfr))rF�other�newaddr�xrrr�__add__s
zAddressList.__add__cCs*x$|jD]}||jkr|jj|�qW|S)N)rfr))rFrhrjrrr�__iadd__
s
zAddressList.__iadd__cCs2td�}x$|jD]}||jkr|jj|�qW|S)N)rerfr))rFrhrirjrrr�__sub__s

zAddressList.__sub__cCs*x$|jD]}||jkr|jj|�qW|S)N)rf�remove)rFrhrjrrr�__isub__s
zAddressList.__isub__cCs
|j|S)N)rf)rFr+rrr�__getitem__#szAddressList.__getitem__N)
rbrcrdrGrgrkrlrmrorprrrrre�s	reip���i���i���ip���i����i���iD���i����i��iD���)�__all__r7r8rTrJZ
COMMASPACEr*r%r0rrrrrr=rerrrr�<module>
s6

u	

/PKc��\9T*��base64mime.cpython-36.opt-2.pycnu�[���3


 \�
�@spddddddgZddlmZddlmZmZd	Zd
ZdZdZ	d
d�Z
ddd�Zdefdd�Zdd�Z
e
Ze
ZdS)�body_decode�body_encode�decode�decodestring�
header_encode�
header_length�)�	b64encode)�
b2a_base64�
a2b_base64z
�
��cCs*tt|�d�\}}|d}|r&|d7}|S)N��)�divmod�len)�	bytearrayZgroups_of_3Zleftover�n�r�(/usr/lib64/python3.6/email/base64mime.pyr2s
�
iso-8859-1cCs6|sdSt|t�r|j|�}t|�jd�}d||fS)Nr�asciiz=?%s?b?%s?=)�
isinstance�str�encoderr)Zheader_bytes�charsetZencodedrrrr=s

�LcCs�|s|Sg}|dd}x^tdt|�|�D]J}t||||��jd�}|jt�rj|tkrj|dd�|}|j|�q*Wtj|�S)Nrrrr����)	�rangerr	r�endswith�NL�append�EMPTYSTRING�join)�sZ
maxlinelenZeolZencvecZ
max_unencoded�i�encrrrrLs
cCs.|s
t�St|t�r"t|jd��St|�SdS)Nzraw-unicode-escape)�bytesrrr
r)�stringrrrrfs

N)r)�__all__�base64rZbinasciir	r
ZCRLFr!r#ZMISC_LENrrrrrrrrrr�<module>s"
PKc��\�>��3�3utils.cpython-36.pycnu�[���3

���i�J�@s�dZddddddddd	d
ddd
ddgZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddl
mZ
ddl
mZddl
mZmZmZddlmZdZdZdZdZdZejd�Zejd�ZdZdadd�Zd d!�Zd"d#�Z d$d%�Z!dId'd�Z"d(d)�Z#d*d+�Z$d,Z%dd-�d.d�Z&d/d0�Z'd1d2�Z(d3d4�Z)ejd5ej*ej+B�Z,d6d7�Z-dJd9d�Z.dKd:d�Z/dLd;d	�Z0d<d�Z1dd-�d=d�Z2d>d�Z3d?d�Z4dMd@d�Z5ejdAej6�Z7dBd�Z8dNdEd�Z9dPdGdH�Z:dS)QzMiscellaneous utilities.�collapse_rfc2231_value�
decode_params�decode_rfc2231�encode_rfc2231�
formataddr�
formatdate�format_datetime�getaddresses�
make_msgid�	mktime_tz�	parseaddr�	parsedate�parsedate_tz�parsedate_to_datetime�unquote�N)�quote)�AddressList)r
)rr
�
_parsedate_tz)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]z/etc/python/email.cfgcCstdkrt�atS)z5"Cache implementation for _cached_strict_addr_parsingN)�_cached_strict_addr_parsing�_use_strict_email_parsing_impl�rr�#/usr/lib64/python3.6/email/utils.py�_use_strict_email_parsing7srcCs�ttjjd��}|rdSytt�}Wntk
r8YnBX|�6ddl}|jdd
d�}|j	|�|j
dddd�}WdQRX|r�dSd	S)z]Returns True if strict email parsing is not disabled by
    config file or env variable.
    Z(PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSINGFrN�#)Z
interpolationZcomment_prefixesZemail_addr_parsing)ZfallbackT)r)�bool�os�environ�get�open�_EMAIL_CONFIG_FILE�FileNotFoundError�configparserZConfigParserZ	read_fileZ
getboolean)Zdisabled�filer$�configrrrr?s"
rcCs&y|j�dStk
r dSXdS)z8Return True if s contains surrogate-escaped binary data.FTN)�encode�UnicodeEncodeError)�srrr�_has_surrogates\s
r*cCs|jdd�}|jdd�S)Nzutf-8�surrogateescape�replace)r'�decode)�stringZoriginal_bytesrrr�	_sanitizeisr/�utf-8c
Cs�|\}}|jd�|r�y|jd�Wn8tk
r\t|t�rFt|�}|j|�}d||fSXd}tj|�rpd}tj	d|�}d||||fS|S)a�The inverse of parseaddr(), this takes a 2-tuple of the form
    (realname, email_address) and returns the string value suitable
    for an RFC 2822 From, To or Cc header.

    If the first element of pair is false, then the second element is
    returned unmodified.

    Optional charset if given is the character set that is used to encode
    realname in case realname is not ASCII safe.  Can be an instance of str or
    a Charset-like object which has a header_encode method.  Default is
    'utf-8'.
    �asciiz%s <%s>r�"z\\\g<0>z%s%s%s <%s>)
r'r(�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�nameZaddressZencoded_nameZquotesrrrrus 




ccs`d}d}xDt|�D]8\}}|r2|d|fVd}q|dkr@d}q||fVqW|r\|dfVdS)NrF�\T)�	enumerate)�addr�pos�escape�chrrr�_iter_escaped_chars�srAcCs�d|kr|Sd}d}g}xPt|�D]D\}}|dkr"|dkr@|}q"||krZ|j|||��|d}d}q"W|t|�kr�|j||d��dj|�S)z Strip real names between quotes.r2rN�r)rA�append�len�join)r=�startZopen_pos�resultr>r@rrr�_strip_quoted_realnames�s rHT)�strictcCs�|dkrt�}|s4tjdd�|D��}t|�}|jSdd�|D�}t|�}tj|�}t|�}t|j�}d}x&|D]}t|�}|d|jd�7}qpWt	|�|kr�d
gS|S)z�Return a list of (REALNAME, EMAIL) or ('','') for each fieldvalue.

    When parsing fails for a fieldvalue, a 2-tuple of ('', '') is returned in
    its place.

    If strict is true, use a strict parser which rejects malformed inputs.
    Ncss|]}t|�VqdS)N)r4)�.0�vrrr�	<genexpr>�szgetaddresses.<locals>.<genexpr>cSsg|]}t|��qSr)r4)rJrKrrr�
<listcomp>�sz getaddresses.<locals>.<listcomp>rrB�,r)rr)
r�
COMMASPACErE�_AddressList�addresslist�_pre_parse_validation�_post_parse_validationrH�countrD)ZfieldvaluesrI�all�ar=rG�nrKrrrr�s$


cCsXt|�}d}xBt|�D]6\}}|dkr0|d7}q|dkr|d8}|dkrdSqW|dkS)Nr�(rB�)F)rHrA)r=Zopensr>r@rrr�_check_parenthesis�s
rZcCs,g}x"|D]}t|�sd}|j|�q
W|S)Nz('', ''))rZrC)Zemail_header_fields�accepted_valuesrKrrrrRs
rRcCs0g}x&|D]}d|dkrd}|j|�q
W|S)N�[rBr)rr)rC)Zparsed_email_header_tuplesr[rKrrrrS
s
rSa_
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<atom>.*?)         # non-greedy up to the next ?= is the atom
  \?=                   # literal ?=
  cCsfddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrBr���r)�	timetuple�zonerrr�_format_timetuple_and_zone"srdFcCsR|dkrtj�}|s|r,tjj|tjj�}ntjj|�}|rH|j�}d}t||�S)a�Returns a date string as specified by RFC 2822, e.g.:

    Fri, 09 Nov 2001 01:08:47 -0000

    Optional timeval if given is a floating point time value as accepted by
    gmtime() and localtime(), otherwise the current time is used.

    Optional localtime is a flag that when True, interprets timeval, and
    returns a date relative to the local timezone instead of UTC, properly
    taking daylight savings time into account.

    Optional argument usegmt means that the timezone is written out as
    an ascii string, not numeric one (so "GMT" instead of "+0000"). This
    is needed for HTTP, and is only used when localtime==False.
    NF)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr+scCsV|j�}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}n
|jd�}t||�S)a$Turn a datetime into a date string as specified in RFC 2822.

    If usegmt is True, dt must be an aware datetime with an offset of zero.  In
    this case 'GMT' will be rendered instead of the normal +0000 required by
    RFC2822.  This is to support HTTP headers involving date stamps.
    Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)rb�tzinforfrgrh�
ValueErrorZstrftimerd)rmrl�nowrcrrrrHs

cCs^ttj�d�}tj�}tjd�}|dkr0d}nd|}|dkrHtj�}d|||||f}|S)a{Returns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.  Optional domain if given provides the
    portion of the message id after the '@'.  It defaults to the locally
    defined hostname.
    �d�@Nr�.z<%d.%d.%d%s@%s>)�intrer�getpid�randomZgetrandbits�socketZgetfqdn)ZidstringZdomainrj�pidZrandintZmsgidrrrr	[s

cCsNt|��^}}|dkr(tj|dd��Stj|dd�dtjtj|d��i�S)Nr]rn)�seconds)rrfrg�	timedelta)�dataZdtuple�tzrrrrrs
cCs�|dkrt�}|s,t|�j}|s$dS|dSt|t�r>|d}t|t�sLdSt|g�d}tt|�j�}|szt|�dkr~dS|dS)a
    Parse addr into its constituent realname and email address parts.

    Return a tuple of realname and email address, unless the parse fails, in
    which case return a 2-tuple of ('', '').

    If strict is True, use a strict parser which rejects malformed inputs.
    NrrrB)rr)rr)rr)	rrPrQr3�listr4rRrSrD)r=rIZaddrsrrrrzs 


cCs`t|�dkr\|jd�r<|jd�r<|dd�jdd�jdd�S|jd�r\|jd�r\|dd	�S|S)
zRemove quotes from a string.rBr2z\\r;z\"�<�>���r�)rD�
startswith�endswithr,)r4rrrr�scCs&|jtd�}t|�dkr"dd|fS|S)z#Decode string according to RFC 2231r^N)�split�TICKrD)r)�partsrrrr�s
cCsDtjj|d|pdd�}|dkr*|dkr*|S|dkr6d}d|||fS)z�Encode string according to RFC 2231.

    If neither charset nor language is given, then s is returned as-is.  If
    charset is given but not language, the string is encoded using the empty
    string for language.
    rr1)Zsafe�encodingNz%s'%s'%s)�urllib�parser)r)r9�languagerrrr�sz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Csx|dd�}g}i}|jd�\}}|j||f�x�|r�|jd�\}}|jd�rTd}nd}t|�}tj|�}|r�|jdd�\}}|dk	r�t|�}|j|g�j|||f�q2|j|dt	|�f�q2W|�rtx�|j
�D]�\}}g}d}	|j�x6|D].\}}
}|�rtj
j|
d	d
�}
d}	|j|
�q�Wt	tj|��}|	�r^t|�\}}}|j|||d|ff�q�|j|d|f�q�W|S)zDecode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (param name, string value).
    Nr�*TFr:�numz"%s"zlatin-1)r�)�poprCr�r�rfc2231_continuation�match�grouprt�
setdefaultr�items�sortr�r��EMPTYSTRINGrEr)
ZparamsZ
new_paramsZrfc2231_paramsr:�valueZencodedZmor�Z
continuationsZextendedr)r9r�rrrr�sD

r,�us-asciicCsjt|t�st|�dkr t|�S|\}}}|dkr6|}t|d�}yt|||�Stk
rdt|�SXdS)Nr_zraw-unicode-escape)r3�tuplerDr�bytesr4�LookupError)r��errorsZfallback_charsetr9r��textZrawbytesrrrr�s

rBc	Cs|dkrtjjtjj�j�S|jdk	r.|j�S|j�dd�|f}tj|�}tj	|�}y tj
|jd�}tj||j�}Wn�t
k
r�|tjtj|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�tj|tj|�}n
tj|�}YnX|j|d�S)a�Return local time as an aware datetime object.

    If called without arguments, return current time.  Otherwise *dt*
    argument should be a datetime instance, and it is converted to the
    local time zone according to the system time zone database.  If *dt* is
    naive (that is, dt.tzinfo is None), it is assumed to be in local time.
    In this case, a positive or zero value for *isdst* causes localtime to
    presume initially that summer time (for example, Daylight Saving Time)
    is or is not (respectively) in effect for the specified time.  A
    negative value for *isdst* causes the localtime() function to attempt
    to divine whether summer time is in effect for the specified time.

    NrB)ryr]r)rnr�)rfrprgrhrirnrbreZmktimerkrzZ	tm_gmtoffZtm_zone�AttributeErrorZgmtimeZdaylightZtm_isdstZaltzoneZtznamer,)	rmZisdstZtmryZlocaltmZdeltar|�dstZgmtoffrrrrks$


rk)r0)NFF)F)NN)NN)r,r�r�)Nr�);�__doc__�__all__r�rerervrwrfZurllib.parser�Zemail._parseaddrrrrPr
rr
rZ
email.charsetrrOr�ZUEMPTYSTRINGZCRLFr��compiler5r7r"rrrr*r/rrArHZsupports_strict_parsingrrZrRrS�VERBOSE�
IGNORECASEZecrerdrrr	rrrrr�ASCIIr�rrrkrrrr�<module>s�



!1

	


$
8
PKc��\��3��S�Smessage.cpython-36.opt-2.pycnu�[���3


 \��@s�ddgZddlZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZmZddlm
Zdd	lmZejZd
Zejd�Zdd
�Zddd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZdS)�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�Policy�compat32)�charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]cCs4t|�jd�\}}}|s$|j�dfS|j�|j�fS)N�;)�str�	partition�strip)�param�a�sep�b�r�%/usr/lib64/python3.6/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}tj|d|d|d�}d||fSy|jd�Wn2tk
r�|d7}tj|dd�}d||fSX|s�tj|�r�d	|tj	|�fSd||fSn|SdS)
Nr�*��z%s=%s�asciizutf-8�z%s="%s")
�len�
isinstance�tuplerZencode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer#rrr�_formatparam's	
r%cCs�dt|�}g}x�|dd�dkr�|dd�}|jd�}x<|dkrt|jdd|�|jdd|�drt|jd|d�}q:W|dkr�t|�}|d|�}d|kr�|jd�}|d|�j�j�d||dd�j�}|j|j��||d�}qW|S)Nrrr�"z\"r�=)r
�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
*
,r1cCs4t|t�r&|d|dtj|d�fStj|�SdS)Nrrr)rrr�unquote)r$rrr�
_unquotevalue]s
r3c@s�eZdZefdd�Zdd�Zdcdd	�Zd
d�Zdddd
�Zdd�Z	dd�Z
dd�Zdd�Zdedd�Z
dfdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zdgd0d1�Zd2d3�Zd4d5�Zdhd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%didJdK�Z&djdLdM�Z'dkdPdQ�Z(dldRdS�Z)dmdTdU�Z*dndVdW�Z+dodXdY�Z,dZd[�Z-dpd\d]�Z.dqd^d_�Z/d`da�Z0ddbl1m2Z2dS)rrcCs:||_g|_d|_d|_d|_d|_|_g|_d|_dS)Nz
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr4rrr�__init__xszMessage.__init__cCs|j�S)N)�	as_string)r;rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|j�S)Nr)�	GeneratorF)�mangle_from_�maxheaderlenr4)�unixfrom)�email.generatorr?r4r�flatten�getvalue)r;rBrAr4r?�fp�grrrr=�szMessage.as_stringcCs|j�S)N)�as_bytes)r;rrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|j�S)Nr)�BytesGeneratorF)r@r4)rB)rCrJr4rrDrE)r;rBr4rJrFrGrrrrH�szMessage.as_bytescCst|jt�S)N)rr7�list)r;rrr�is_multipart�szMessage.is_multipartcCs
||_dS)N)r6)r;rBrrr�set_unixfrom�szMessage.set_unixfromcCs|jS)N)r6)r;rrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.y|jj|�Wntk
r@td��YnXdS)Nz=Attach is not valid on a message with a non-multipart payload)r7r,�AttributeError�	TypeError)r;�payloadrrr�attach�s

zMessage.attachcCs�|j�r(|rdS|dkr|jS|j|S|dk	rPt|jt�rPtdt|j���|j}t|jdd��j�}t|t��rt	j
|�r�|jdd�}|s�y|j|j
dd�d�}Wn tk
r�|jdd�}YnXn6|�ry|jd�}Wn tk
�r|jd�}YnX|�s|S|d	k�r tj|�S|d
k�rbtdj|j���\}}x|D]}|jj||��qFW|S|dk�r�t|�}	t�}
ytj|	|
dd�|
j�Stjk
�r�|SXt|t��r�|S|S)NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper
�replacezraw-unicode-escapezquoted-printable�base64��
x-uuencode�uuencode�uue�x-uueT)�quiet)rWrXrYrZ)rLr7rrKrP�typer
�getr+rZ_has_surrogatesr�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr4Z
handle_defectr�uurE�Error)r;r0r^rQ�cteZbpayloadr$r9ZdefectZin_fileZout_filerrr�get_payload�sV"






zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|j|j�}t|d�rT|jdd�|_n||_|dk	rl|j|�dS)Nrr^rrS)�hasattrr7r�Charsetr�output_charsetr^�set_charset)r;rQr
rrr�set_payload/s


zMessage.set_payloadcCs|dkr|jd�d|_dSt|t�s.t|�}||_d|krH|jdd�d|krf|jdd|j�d�n|jd|j��||j�kr�|j|j�|_d|k�r|j	�}y||�Wnjt
k
�r|j}|r�y|jdd	�}Wn tk
r�|j|j
�}YnX|j|�|_|jd|�YnXdS)
Nr
zMIME-Versionz1.0zContent-Typez
text/plain)r
zContent-Transfer-EncodingrrS)�	del_paramr8rrj�
add_headerZget_output_charset�	set_paramZbody_encoder7Zget_body_encodingrPrrark)r;r
rgrQrrrrlCs8


zMessage.set_charsetcCs|jS)N)r8)r;rrr�get_charsetrszMessage.get_charsetcCs
t|j�S)N)rr5)r;rrr�__len__zszMessage.__len__cCs
|j|�S)N)r])r;�namerrr�__getitem__~s	zMessage.__getitem__cCsv|jj|�}|r\|j�}d}x>|jD]4\}}|j�|kr$|d7}||kr$tdj||���q$W|jj|jj||��dS)Nrrz/There may be at most {} {} headers in a message)r4Zheader_max_countr+r5�
ValueError�formatr,�header_store_parse)r;rs�valZ	max_countZlname�found�k�vrrr�__setitem__�szMessage.__setitem__cCsD|j�}g}x,|jD]"\}}|j�|kr|j||f�qW||_dS)N)r+r5r,)r;rs�
newheadersrzr{rrr�__delitem__�szMessage.__delitem__cCs|j�dd�|jD�kS)NcSsg|]\}}|j��qSr)r+)�.0rzr{rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r+r5)r;rsrrr�__contains__�szMessage.__contains__ccsx|jD]\}}|VqWdS)N)r5)r;Zfieldr$rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)NcSsg|]\}}|�qSrr)rrzr{rrrr��sz Message.keys.<locals>.<listcomp>)r5)r;rrr�keys�szMessage.keyscs�fdd��jD�S)Ncsg|]\}}�jj||��qSr)r4�header_fetch_parse)rrzr{)r;rrr��sz"Message.values.<locals>.<listcomp>)r5)r;r)r;r�values�s
zMessage.valuescs�fdd��jD�S)Ncs"g|]\}}|�jj||�f�qSr)r4r�)rrzr{)r;rrr��sz!Message.items.<locals>.<listcomp>)r5)r;r)r;r�items�s
z
Message.itemscCs:|j�}x,|jD]"\}}|j�|kr|jj||�SqW|S)N)r+r5r4r�)r;rs�failobjrzr{rrrr]�s
zMessage.getcCs|jj||f�dS)N)r5r,)r;rsr$rrr�set_raw�szMessage.set_rawcCst|jj��S)N)�iterr5�copy)r;rrr�	raw_items�szMessage.raw_itemscCsLg}|j�}x2|jD](\}}|j�|kr|j|jj||��qW|sH|S|S)N)r+r5r,r4r�)r;rsr�r�rzr{rrr�get_all�s	zMessage.get_allcKstg}xH|j�D]<\}}|dkr2|j|jdd��q|jt|jdd�|��qW|dk	rb|jd|�tj|�||<dS)N�_�-r)r�r,rTr%�insert�	SEMISPACErc)r;�_name�_valueZ_params�partsrzr{rrrroszMessage.add_headercCs^|j�}xPttt|j��|j�D].\}\}}|j�|kr |jj||�|j|<Pq Wt|��dS)N)r+�zip�rangerr5r4rw�KeyError)r;r�r�r0rzr{rrr�replace_header!s$zMessage.replace_headercCsHt�}|jd|�}||kr"|j�St|�dj�}|jd�dkrDdS|S)Nzcontent-typer�/rz
text/plain)�objectr]�get_default_typerr+r))r;�missingr$�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|j�}|jd�dS)Nr�r)r��split)r;r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|j�}|jd�dS)Nr�r)r�r�)r;r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jS)N)r:)r;rrrr�^szMessage.get_default_typecCs
||_dS)N)r:)r;r�rrr�set_default_typegszMessage.set_default_typec	Cs�t�}|j||�}||kr|Sg}xdt|�D]X}y$|jdd�\}}|j�}|j�}Wn tk
rt|j�}d}YnX|j||f�q,Wtj|�}|S)Nr'rr)	r�r]r1r�rrur,rZ
decode_params)	r;r��headerr�r$�params�prsrxrrr�_get_params_preserveps 

zMessage._get_params_preserve�content-typeTcCs8t�}|j||�}||kr|S|r0dd�|D�S|SdS)NcSsg|]\}}|t|�f�qSr)r3)rrzr{rrrr��sz&Message.get_params.<locals>.<listcomp>)r�r�)r;r�r�r2r�r�rrr�
get_params�s
zMessage.get_paramscCsJ||kr|Sx8|j||�D](\}}|j�|j�kr|r>t|�S|SqW|S)N)r�r+r3)r;rr�r�r2rzr{rrrr_�szMessage.get_param�Content-TypercCst|t�r|r|||f}||kr4|j�dkr4d}n
|j|�}|j||d�sv|s^t|||�}q�tj|t|||�g�}nfd}x`|j||d�D]N\}	}
d}|	j�|j�kr�t|||�}nt|	|
|�}|s�|}q�tj||g�}q�W||j|�k�r|�r|j	||�n||=|||<dS)Nzcontent-typez
text/plain)r�r)r�r2)
rrr+r]r_r%r�rcr�r�)r;rr$r��requoter
ZlanguagerTr�Z	old_paramZ	old_valueZappend_paramrrrrp�s2

zMessage.set_paramcCs�||krdSd}xR|j||d�D]@\}}|j�|j�kr |sJt|||�}q tj|t|||�g�}q W||j|�kr�||=|||<dS)Nr)r�r2)r�r+r%r�rcr])r;rr�r�Z	new_ctyper�r{rrrrn�szMessage.del_paramcCs�|jd�dkst�|j�dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<x(|dd�D]\}}|j||||�qjWdS)Nr�rzcontent-typezmime-versionz1.0zMIME-Version)r�r2)r)rur+r�rp)r;r\r�r�r�r�r{rrr�set_typeszMessage.set_typecCsDt�}|jd|d�}||kr*|jd|d�}||kr6|Stj|�j�S)N�filenamezcontent-dispositionrszcontent-type)r�r_r�collapse_rfc2231_valuer)r;r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|jd|�}||kr|Stj|�j�S)N�boundary)r�r_rr��rstrip)r;r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCs t�}|j|d�}||kr$tjd��g}d}xB|D]:\}}|j�dkr^|jdd|f�d}q2|j||f�q2W|s�|jdd|f�g}x�|jD]�\}	}
|	j�dk�rg}x6|D].\}}
|
dkr�|j|�q�|jd||
f�q�Wtj|�}
|j|j	j
|	|
��q�|j|	|
f�q�W||_dS)	Nzcontent-typezNo Content-Type header foundFr�z"%s"Trz%s=%s)r�r�rZHeaderParseErrorr+r,r5r�rcr4rw)r;r�r�r�Z	newparamsZfoundpZpkZpvr}�hr{r�rzrxrrr�set_boundaryCs2


zMessage.set_boundarycCs�t�}|jd|�}||kr|St|t�rr|dp2d}y|djd�}t||�}Wn ttfk
rp|d}YnXy|jd�Wntk
r�|SX|j�S)Nr
rzus-asciirzraw-unicode-escape)	r�r_rrrr
r`rar+)r;r�r�r
ZpcharsetrHrrr�get_content_charsetqs 
zMessage.get_content_charsetcs�fdd�|j�D�S)Ncsg|]}|j���qSr)r�)r�part)r�rrr��sz(Message.get_charsets.<locals>.<listcomp>)�walk)r;r�r)r�r�get_charsets�szMessage.get_charsetscCs*|jd�}|dkrdSt|�dj�}|S)Nzcontent-dispositionr)r]rr+)r;r$�c_drrr�get_content_disposition�s

zMessage.get_content_disposition)r�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)r�TNrF)r�T)r�T)N)N)N)N)3�__name__�
__module__�__qualname__r	r<r>r=rIrHrLrMrNrRrhrmrlrqrrrtr|r~r�r�r�r�r�r]r�r�r�ror�r�r�r�r�r�r�r�r_rprnr�r�r�r�r�r�r�Zemail.iteratorsr�rrrrris`


Z
/


				

!
2

 


.


cs�eZdZd3dd�Zd4�fdd�	Zdd�Zd	d
�Zdd�Zd6dd�Zd7d8d9d:hZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd;d d!�Zd<d"d#�Zd=d$d%�Zdd&�d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS)>�MIMEPartNcCs(|dkrddlm}|}tj||�dS)Nr)�default)Zemail.policyr�rr<)r;r4r�rrrr<�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)N)rAr4)r4Zmax_line_length�superr=)r;rBrAr4)�	__class__rrr=�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8)r4)r=r4Zclone)r;rrrr>�szMIMEPart.__str__cCs |jd�}|dkrdS|jdkS)Nzcontent-dispositionF�
attachment)r]Zcontent_disposition)r;r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|j�rdS|j�jd�\}}|dkrB||kr>|j|�|fVdS|dkrNdS|dkr~x"|j�D]}|j||�EdHq`WdSd|kr�|jd�|fVd}|jd�}|r�x"|j�D]}|d|kr�|}Pq�W|dkr�|j�}|r�|dnd}|dk	�r|j||�EdHdS)Nr��text�	multipart�related�startz
content-idr)r�r�r�r*�
iter_parts�
_find_bodyr_rh)	r;r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_bodyr��html�plaincCsDt|�}d}x2|j||�D]"\}}||kr|}|}|dkrPqW|S)Nr)rr�)r;r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_bodyr�r��alternativec	cs|j�jd�\}}|dks"|dkr&dS|j�j�}|dkr�|dkr�|jd�}|r�d}g}x*|D]"}|jd�|krvd}q^|j|�q^W|r�|EdHdS|jd	�|EdHdSg}xP|D]H}|j�jd�\}}||f|jkr�|j	�r�||kr�|j|�q�|Vq�WdS)
Nr�r�r�r�r�Fz
content-idTr)
r�r�rhr�r_r]r,�pop�_body_typesr�)	r;r�r�r�r�ryZattachmentsr��seenrrr�iter_attachmentss6






zMIMEPart.iter_attachmentsccs|j�dkr|j�EdHdS)Nr�)r�rh)r;rrrr�4szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�S)N)r4r��get_content)r;r��args�kwrrrr�<szMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dS)N)r4r��set_content)r;r�r�r�rrrr�AszMIMEPart.set_contentc
Cs�|j�dkr6|j�}||f}||kr6tdj||���g}g}x>|jD]4\}}|j�jd�rl|j||f�qF|j||f�qFW|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|jd|�dS)Nr�zCannot convert {} to {}zcontent-)r4z
multipart/zContent-Typer�)r�r�rurvr5r+�
startswithr,r\r4r7rp)
r;r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersrsr$r�rrr�_make_multipartFs,


zMIMEPart._make_multipartcCs|jdd|�dS)Nr�r��mixed)r�r�)r�)r;r�rrr�make_relatedaszMIMEPart.make_relatedcCs|jdd|�dS)Nr�r�)r�)r�)r;r�rrr�make_alternativedszMIMEPart.make_alternativecCs|jdf|�dS)Nr�)r�)r;r�rrr�
make_mixedgszMIMEPart.make_mixed)�_dispcOsf|j�dks|j�|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|j|�dS)Nr�Zmake_)r4zcontent-dispositionzContent-Disposition)r�r��getattrr\r4r�rR)r;Z_subtyper�r�r�r�rrr�_add_multipartjszMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r�)r�)r;r�r�rrr�add_relatedtszMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�)r�)r;r�r�rrr�add_alternativewszMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�)r�)r;r�r�rrr�add_attachmentzszMIMEPart.add_attachmentcCsg|_d|_dS)N)r5r7)r;rrr�clear}szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|j�jd�s||f�qS)zcontent-)r+r�)r�nr{rrrr��sz*MIMEPart.clear_content.<locals>.<listcomp>)r5r7)r;rrr�
clear_content�szMIMEPart.clear_content)N)FNN�r�r�r�)r�)r�r�)r�r�)r�r�)r�r�)N)N)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��
__classcell__rr)r�rr��s0

.



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)NzMIME-Versionz1.0)r�r�)r;r�r�)r�rrr��szEmailMessage.set_content)r�r�r�r�r�rr)r�rr�s)NT)�__all__�rererb�iorrZemailrrZemail._policybaserr	r
r8Zemail._encoded_wordsrrjr��compiler!rr%r1r3rr�rrrrr�<module>s4


"NWPKc��\Hsn�� _policybase.cpython-36.opt-2.pycnu�[���3

���i�<�@s�ddlZddlmZddlmZddlmZdddgZGdd	�d	�Zd
d�Z	dd
�Z
Gdd�deejd�Ze
Gdd�de��Z
e
�ZdS)�N)�header)�charset)�_has_surrogates�Policy�Compat32�compat32cs<eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Z�ZS)�_PolicyBasecsLxF|j�D]:\}}t||�r0tt|�j||�q
tdj||jj���q
WdS)Nz*{!r} is an invalid keyword argument for {})	�items�hasattr�superr�__setattr__�	TypeError�format�	__class__�__name__)�self�kw�name�value)r��)/usr/lib64/python3.6/email/_policybase.py�__init__)s
z_PolicyBase.__init__cCs*dd�|jj�D�}dj|jjdj|��S)NcSsg|]\}}dj||��qS)z{}={!r})r)�.0rrrrr�
<listcomp>8sz(_PolicyBase.__repr__.<locals>.<listcomp>z{}({})z, )�__dict__r	rrr�join)r�argsrrr�__repr__7sz_PolicyBase.__repr__cKsz|jj|j�}x$|jj�D]\}}tj|||�qWx@|j�D]4\}}t||�sdtdj||jj	���tj|||�q>W|S)Nz*{!r} is an invalid keyword argument for {})
r�__new__rr	�objectrr
r
rr)rrZ	newpolicy�attrrrrr�clone<s
z_PolicyBase.clonecCs,t||�rd}nd}t|j|jj|���dS)Nz'{!r} object attribute {!r} is read-onlyz!{!r} object has no attribute {!r})r
�AttributeErrorrrr)rrr�msgrrrrNs
z_PolicyBase.__setattr__cCs|jf|j�S)N)r!r)r�otherrrr�__add__Usz_PolicyBase.__add__)	r�
__module__�__qualname__rrr!rr%�
__classcell__rr)rrrs
rcCs,|jdd�d}|jdd�d}|d|S)N�
�r)�rsplit�split)�docZ	added_docrrr�_append_doc^sr.cCs�|jr(|jjd�r(t|jdj|j�|_xf|jj�D]X\}}|jr4|jjd�r4x<dd�|jD�D](}tt||�d�}|r`t||j�|_Pq`Wq4W|S)N�+rcss |]}|j�D]
}|VqqdS)N)�mro)r�base�crrr�	<genexpr>hsz%_extend_docstrings.<locals>.<genexpr>�__doc__)r4�
startswithr.�	__bases__rr	�getattr)�clsrr r2r-rrr�_extend_docstringscs
r9c@s�eZdZdZdZdZdZdZdZdZ	dd�Z
d	d
�Zdd�Ze
jd
d��Ze
jdd��Ze
jdd��Ze
jdd��Ze
jdd��ZdS)rFr)Z8bit�NNTcCs|jr
|�|j||�dS)N)�raise_on_defect�register_defect)r�obj�defectrrr�
handle_defect�szPolicy.handle_defectcCs|jj|�dS)N)Zdefects�append)rr=r>rrrr<�szPolicy.register_defectcCsdS)Nr)rrrrr�header_max_count�szPolicy.header_max_countcCst�dS)N)�NotImplementedError)r�sourcelinesrrr�header_source_parse�szPolicy.header_source_parsecCst�dS)N)rB)rrrrrr�header_store_parse�szPolicy.header_store_parsecCst�dS)N)rB)rrrrrr�header_fetch_parse�s	zPolicy.header_fetch_parsecCst�dS)N)rB)rrrrrr�folds
zPolicy.foldcCst�dS)N)rB)rrrrrr�fold_binaryszPolicy.fold_binary)rr&r'r;�linesep�cte_type�max_line_length�mangle_from_Zmessage_factoryZverify_generated_headersr?r<rA�abc�abstractmethodrDrErFrGrHrrrrrps9

)�	metaclassc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)rTcCs0t|t�s|St|�r(tj|tj|d�S|SdS)N)r�header_name)�
isinstance�strrr�Header�_charset�UNKNOWN8BIT)rrrrrr�_sanitize_header!s

zCompat32._sanitize_headercCs>|djdd�\}}|jd�dj|dd��}||jd�fS)Nr�:r*z 	�z
)r,�lstripr�rstrip)rrCrrrrrrD-szCompat32.header_source_parsecCs||fS)Nr)rrrrrrrE9szCompat32.header_store_parsecCs|j||�S)N)rV)rrrrrrrF?szCompat32.header_fetch_parsecCs|j||dd�S)NT)�sanitize)�_fold)rrrrrrrGFsz
Compat32.foldcCs"|j|||jdkd�}|jdd�S)NZ7bit)r[�ascii�surrogateescape)r\rJ�encode)rrrZfoldedrrrrHPs	zCompat32.fold_binarycCs�g}|jd|�t|t�r\t|�rL|r<tj|tj|d�}qZ|j|�d}q`tj||d�}n|}|dk	r�d}|jdk	r||j}|j|j	|j
|d��|j|j
�dj|�S)Nz%s: )rrP)rPr)rI�
maxlinelenrX)r@rQrRrrrSrTrUrKr_rIr)rrrr[�parts�hr`rrrr\\s&



zCompat32._foldN)rr&r'rLrVrDrErFrGrHr\rrrrrs
)rMZemailrrrTZemail.utilsr�__all__rr.r9�ABCMetarrrrrrr�<module>sL
(fPKc��\V�74�3�3generator.cpython-36.pycnu�[���3

���i�S�@s�dZdddgZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZdd	l
mZd
ZdZejd�Zejd
ej�Zejd�Zejd�ZGdd�d�ZGdd�de�ZdZGdd�de�Zeeejd��ZdeZej Z dS)z:Classes to generate plain text from a message object tree.�	Generator�DecodedGenerator�BytesGenerator�N)�deepcopy)�StringIO�BytesIO)�_has_surrogates)�HeaderWriteError�_�
z
\r\n|\r|\nz^From z\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]s\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]c@s�eZdZdZd'dd�dd�Zdd�Zd(d	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZeZdd�Zdd�Zdd �Zd!d"�Zed)d#d$��Zed%d&��ZdS)*rz�Generates output from a Message object tree.

    This basic generator writes the message to the given file object as plain
    text.
    N)�policycCs6|dkr|dkrdn|j}||_||_||_||_dS)a�Create the generator for message flattening.

        outfp is the output file-like object for writing the message to.  It
        must have a write() method.

        Optional mangle_from_ is a flag that, when True (the default if policy
        is not set), escapes From_ lines in the body of the message by putting
        a `>' in front of them.

        Optional maxheaderlen specifies the longest length for a non-continued
        header.  When a header line is longer (in characters, with tabs
        expanded to 8 spaces) than maxheaderlen, the header will split as
        defined in the Header class.  Set maxheaderlen to zero to disable
        header wrapping.  The default is 78, as recommended (but not required)
        by RFC 2822.

        The policy keyword specifies a policy object that controls a number of
        aspects of the generator's operation.  If no policy is specified,
        the policy associated with the Message object passed to the
        flatten method is used.

        NT)�mangle_from_�_fp�
_mangle_from_�maxheaderlenr)�self�outfpr
rr�r�'/usr/lib64/python3.6/email/generator.py�__init__'szGenerator.__init__cCs|jj|�dS)N)r�write)r�srrrrGszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|j|j�|_d|_|j|j�|_|j}|j}zL||_||_|r�|j	�}|s�dt
jt
j
��}|j||j�|j
|�Wd||_||_XdS)a�Print the message object tree rooted at msg to the output file
        specified when the Generator instance was created.

        unixfrom is a flag that forces the printing of a Unix From_ delimiter
        before the first object in the message tree.  If the original message
        has no From_ delimiter, a `standard' one is crafted.  By default, this
        is False to inhibit the printing of any From_ delimiter.

        Note that for subobjects, no From_ line is printed.

        linesep specifies the characters used to indicate a new line in
        the output.  The default value is determined by the policy specified
        when the Generator instance was created or, if none was specified,
        from the policy associated with the msg.

        N)�linesep)�max_line_length�zFrom nobody )r�clonerr�_NL�_encode�_encoded_NLZ_EMPTY�_encoded_EMPTYZget_unixfrom�timeZctimer�_write)r�msg�unixfromrrZold_gen_policyZold_msg_policyZufromrrr�flattenKs,
zGenerator.flattencCs|j||jd|jd�S)z1Clone this generator with the exact same options.N)r)�	__class__rr)r�fprrrr|szGenerator.clonecCst�S)N)r)rrrr�_new_buffer�szGenerator._new_buffercCs|S)Nr)rrrrrr�szGenerator._encodecCsX|sdStj|�}x*|dd�D]}|j|�|j|j�q W|drT|j|d�dS)N����r)r))�NLCRE�splitrr)r�lines�linerrr�_write_lines�s

zGenerator._write_linescCs�|j}z"d|_|j�|_}|j|�Wd||_|j}|`X|rht|�}|jd|d�|jd|d�t|dd�}|dkr�|j|�n||�|jj|j	��dS)Nzcontent-transfer-encodingrzcontent-typer(�_write_headers)
r�
_munge_cter'�	_dispatchrZreplace_header�getattrr/r�getvalue)rr"ZoldfpZsfpZ	munge_cte�methrrrr!�s"zGenerator._writecCst|j�}|j�}tj||f�jdd�}t|d|d�}|dkrh|jdd�}t|d|d�}|dkrh|j}||�dS)N�-r
Z_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer2�
_writeBody)rr"�main�subZspecificr4Zgenericrrrr1�szGenerator._dispatchcCs�x�|j�D]�\}}|jj||�}|jjr�|jj}|j|jj�sRtd|�d|����|}|j|�rr|dt|��}tj	|�r�td|����|j
|�q
W|j
|j�dS)Nz folded header does not end with z: z folded header contains newline: )�	raw_itemsrZfold�verify_generated_headersr�endswithr	�len�NEWLINE_WITHOUT_FWSP�searchrr)rr"�h�v�foldedr�folded_no_lineseprrrr/�s

zGenerator._write_headerscCs�|j�}|dkrdSt|t�s.tdt|���t|j�r~|jd�}|dk	r~t|�}|d=|j	||�|j�}|d|df|_
|jr�tj
d|�}|j|�dS)Nzstring payload expected: %s�charsetzcontent-transfer-encodingzcontent-typez>From )�get_payload�
isinstance�str�	TypeError�typer�_payloadZ	get_paramrZset_payloadr0r�fcrer=r.)rr"�payloadrHrrr�_handle_text�s"


zGenerator._handle_textcCs�g}|j�}|dkrg}n(t|t�r2|j|�dSt|t�sB|g}x>|D]6}|j�}|j|�}|j|d|jd�|j	|j
��qHW|j�}|s�|jj
|�}|j|�}|j|�|jdk	r�|jr�tjd|j�}	n|j}	|j|	�|j|j�|jd||j�|�r|jj|jd��x4|D],}
|j|jd||j�|jj|
��qW|j|jd|d|j�|jdk	�r�|j�r�tjd|j�}n|j}|j|�dS)NF)r#rz>From z--r)rIrJrKr�listr'rr$r�appendr3Zget_boundaryrr9�_make_boundaryZset_boundary�preamblerrOr=r.r�pop�epilogue)rr"ZmsgtextsZsubparts�partr�g�boundaryZalltextrUZ	body_partrWrrr�_handle_multipart
sJ









zGenerator._handle_multipartcCs0|j}|jdd�|_z|j|�Wd||_XdS)Nr)r)rrr[)rr"�prrr�_handle_multipart_signedGs
z"Generator._handle_multipart_signedcCs�g}x�|j�D]t}|j�}|j|�}|j|d|jd�|j�}|j|j�}|rx|d|jkrx|j	|jj
|dd���q|j	|�qW|jj|jj
|��dS)NF)r#rr(r)r))
rIr'rr$rr3r+rrrSr9rr)rr"ZblocksrXrrY�textr,rrr�_handle_message_delivery_statusRs
z)Generator._handle_message_delivery_statuscCs^|j�}|j|�}|j}t|t�rD|j|jd�d|jd�|j�}n
|j	|�}|j
j|�dS)NrF)r#r)r'rrNrJrRr$rIrr3rrr)rr"rrYrPrrr�_handle_messagegs




zGenerator._handle_messagecCsztjtj�}d	t|d}|dkr(|S|}d}xD|jdtj|�dtj�}|j	|�sZP|dt
|�}|d7}q2W|S)
N�=�z==rz^--z(--)?$�.r(z===============)�randomZ	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINErCrK)�clsr^�tokenrZ�bZcounterZcrerrrrT�s
zGenerator._make_boundarycCstj||�S)N)ri�compile)rlr�flagsrrrrh�szGenerator._compile_re)NN)FN)N)�__name__�
__module__�__qualname__�__doc__rrr$rr'rr.r!r1r/rQr;r[r]r_r`�classmethodrTrhrrrrrs*
1#:csPeZdZdZdd�Zdd�Zdd�Zdd	�Z�fd
d�ZeZ	e
dd
��Z�ZS)ra�Generates a bytes version of a Message object tree.

    Functionally identical to the base Generator except that the output is
    bytes and not string.  When surrogates were used in the input to encode
    bytes, these are decoded back to bytes for output.  If the policy has
    cte_type set to 7bit, then the message is transformed such that the
    non-ASCII bytes are properly content transfer encoded, using the charset
    unknown-8bit.

    The outfp object must accept bytes in its write method.
    cCs|jj|jdd��dS)N�ascii�surrogateescape)rr�encode)rrrrrr�szBytesGenerator.writecCst�S)N)r)rrrrr'�szBytesGenerator._new_buffercCs
|jd�S)Nrv)rx)rrrrrr�szBytesGenerator._encodecCs�x�|j�D]�\}}|jj||�}|jjr�|jjj�}|j|�sRtd|�d|����|}|j|�rr|dt|��}t	j
|�r�td|����|jj|�q
W|j|j
�dS)Nz folded header does not end with z: z folded header contains newline: )r>rZfold_binaryr?rrxr@r	rA�NEWLINE_WITHOUT_FWSP_BYTESrCrrr)rr"rDrErFrrGrrrr/�s


zBytesGenerator._write_headerscs^|jdkrdSt|j�rJ|jjdkrJ|jr<tjd|j�|_|j|j�ntt	|�j
|�dS)NZ7bitz>From )rNrrZcte_typerrOr=r.�superrrQ)rr")r%rrrQ�s
zBytesGenerator._handle_textcCstj|jd�|�S)Nrv)rirorx)rlrrprrrrh�szBytesGenerator._compile_re)
rqrrrsrtrr'rr/rQr;rurh�
__classcell__rr)r%rr�s
zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s(eZdZdZddd�dd�Zdd�ZdS)	rz�Generates a text representation of a message.

    Like the Generator base class, except that non-text parts are substituted
    with a format string representing the part.
    N)rcCs.tj|||||d�|dkr$t|_n||_dS)a�Like Generator.__init__() except that an additional optional
        argument is allowed.

        Walks through all subparts of a message.  If the subpart is of main
        type `text', then it prints the decoded payload of the subpart.

        Otherwise, fmt is a format string that is used instead of the message
        payload.  fmt is expanded with the following keywords (in
        %(keyword)s format):

        type       : Full MIME type of the non-text part
        maintype   : Main MIME type of the non-text part
        subtype    : Sub-MIME type of the non-text part
        filename   : Filename of the non-text part
        description: Description associated with the non-text part
        encoding   : Content transfer encoding of the non-text part

        The default value for fmt is None, meaning

        [Non-text (%(type)s) part of message omitted, filename %(filename)s]
        )rN)rr�_FMTrg)rrr
rZfmtrrrrr�s
zDecodedGenerator.__init__cCs�x�|j�D]v}|j�}|dkr4t|jdd�|d�q
|dkr>q
t|j|j�|j�|j�|jd�|jdd�|jd	d
�d�|d�q
WdS)Nr^F)�decode)�fileZ	multipartz
[no filename]zContent-Descriptionz[no description]zContent-Transfer-Encodingz
[no encoding])rM�maintype�subtype�filenameZdescription�encoding)	�walkr6�printrIrgZget_content_typer7�get_filename�get)rr"rXrrrrr1�s 
zDecodedGenerator._dispatch)NNN)rqrrrsrtrr1rrrrr�sr(z%%0%dd)!rt�__all__rirer rd�copyr�iorrZemail.utilsrZemail.errorsr	r8�NLror*rkrOrBryrrr|rrA�reprrfZ_widthrgrTrrrr�<module>s0



|?;PKc��\��_j�j�message.cpython-36.pycnu�[���3


 \��@s�dZddgZddlZddlZddlZddlmZmZddlm	Z	ddlm
Z
ddlmZm
Z
dd	lmZdd
lmZejZdZejd�Zd
d�Zddd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZdS)z8Basic message object for the email package object model.�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�Policy�compat32)�charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]cCs4t|�jd�\}}}|s$|j�dfS|j�|j�fS)N�;)�str�	partition�strip)�param�a�sep�b�r�%/usr/lib64/python3.6/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}tj|d|d|d�}d||fSy|jd�Wn2tk
r�|d7}tj|dd	�}d||fSX|s�tj|�r�d
|tj	|�fSd||fSn|SdS)a~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.  If value is a
    three tuple (charset, language, value), it will be encoded according
    to RFC2231 rules.  If it contains non-ascii characters it will likewise
    be encoded according to RFC2231 rules, using the utf-8 charset and
    a null language.
    Nr�*��z%s=%s�asciizutf-8�z%s="%s")
�len�
isinstance�tuplerZencode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer#rrr�_formatparam's	
r%cCs�dt|�}g}x�|dd�dkr�|dd�}|jd�}x<|dkrt|jdd|�|jdd|�drt|jd|d�}q:W|dkr�t|�}|d|�}d|kr�|jd�}|d|�j�j�d||dd�j�}|j|j��||d�}qW|S)Nrrr�"z\"r�=)r
�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
*
,r1cCs4t|t�r&|d|dtj|d�fStj|�SdS)Nrrr)rrr�unquote)r$rrr�
_unquotevalue]s
r3c@s�eZdZdZefdd�Zdd�Zddd	d
�Zdd�Zded
d�Z	dd�Z
dd�Zdd�Zdd�Z
dfdd�Zdgdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zdhd1d2�Zd3d4�Zd5d6�Zdid7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&djdKdL�Z'dkdMdN�Z(dldQdR�Z)dmdSdT�Z*dndUdV�Z+dodWdX�Z,dpdYdZ�Z-d[d\�Z.dqd]d^�Z/drd_d`�Z0dadb�Z1ddcl2m3Z3dS)sra�Basic message object.

    A message object is defined as something that has a bunch of RFC 2822
    headers and a payload.  It may optionally have an envelope header
    (a.k.a. Unix-From or From_ header).  If the message is a container (i.e. a
    multipart or a message/rfc822), then the payload is a list of Message
    objects, otherwise it is a string.

    Message objects implement part of the `mapping' interface, which assumes
    there is exactly one occurrence of the header per message.  Some headers
    do in fact appear multiple times (e.g. Received) and for those headers,
    you must use the explicit API to set or get all the headers.  Not all of
    the mapping methods are implemented.
    cCs:||_g|_d|_d|_d|_d|_|_g|_d|_dS)Nz
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr4rrr�__init__xszMessage.__init__cCs|j�S)z9Return the entire formatted message as a string.
        )�	as_string)r;rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|j�S)a�Return the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  For backward compatibility reasons, if maxheaderlen is
        not specified it defaults to 0, so you must override it explicitly
        if you want a different maxheaderlen.  'policy' is passed to the
        Generator instance used to serialize the mesasge; if it is not
        specified the policy associated with the message instance is used.

        If the message object contains binary data that is not encoded
        according to RFC standards, the non-compliant data will be replaced by
        unicode "unknown character" code points.
        r)�	GeneratorNF)�mangle_from_�maxheaderlenr4)�unixfrom)�email.generatorr?r4r�flatten�getvalue)r;rBrAr4r?�fp�grrrr=�szMessage.as_stringcCs|j�S)z?Return the entire formatted message as a bytes object.
        )�as_bytes)r;rrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|j�S)aJReturn the entire formatted message as a bytes object.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  'policy' is passed to the BytesGenerator instance used to
        serialize the message; if not specified the policy associated with
        the message instance is used.
        r)�BytesGeneratorNF)r@r4)rB)rCrJr4rrDrE)r;rBr4rJrFrGrrrrH�szMessage.as_bytescCst|jt�S)z6Return True if the message consists of multiple parts.)rr7�list)r;rrr�is_multipart�szMessage.is_multipartcCs
||_dS)N)r6)r;rBrrr�set_unixfrom�szMessage.set_unixfromcCs|jS)N)r6)r;rrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.y|jj|�Wntk
r@td��YnXdS)z�Add the given payload to the current payload.

        The current payload will always be a list of objects after this method
        is called.  If you want to set the payload to a scalar object, use
        set_payload() instead.
        Nz=Attach is not valid on a message with a non-multipart payload)r7r,�AttributeError�	TypeError)r;�payloadrrr�attach�s

zMessage.attachcCs�|j�r(|rdS|dkr|jS|j|S|dk	rPt|jt�rPtdt|j���|j}t|jdd��j�}t|t��rt	j
|�r�|jdd�}|s�y|j|j
dd�d�}Wn tk
r�|jdd�}YnXn6|�ry|jd�}Wn tk
�r|jd	�}YnX|�s|S|d
k�r tj|�S|dk�rbtdj|j���\}}x|D]}|jj||��qFW|S|dk�r�t|�}	t�}
ytj|	|
dd�|
j�Stjk
�r�|SXt|t��r�|S|S)aZReturn a reference to the payload.

        The payload will either be a list object or a string.  If you mutate
        the list object, you modify the message's payload in place.  Optional
        i returns that index into the payload.

        Optional decode is a flag indicating whether the payload should be
        decoded or not, according to the Content-Transfer-Encoding header
        (default is False).

        When True and the message is not a multipart, the payload will be
        decoded if this header's value is `quoted-printable' or `base64'.  If
        some other encoding is used, or the header is missing, or if the
        payload has bogus data (i.e. bogus base64 or uuencoded data), the
        payload is returned as-is.

        If the message is a multipart and the decode flag is True, then None
        is returned.
        NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper
�replacezraw-unicode-escapezquoted-printable�base64��
x-uuencode�uuencode�uue�x-uueT)�quiet)rWrXrYrZ)rLr7rrKrP�typer
�getr+rZ_has_surrogatesr�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr4Z
handle_defectr�uurE�Error)r;r0r^rQ�cteZbpayloadr$r9ZdefectZin_fileZout_filerrr�get_payload�sV"






zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|j|j�}t|d�rT|jdd�|_n||_|dk	rl|j|�dS)z�Set the payload to the given value.

        Optional charset sets the message's default character set.  See
        set_charset() for details.
        rNr^rrS)�hasattrr7r�Charsetr�output_charsetr^�set_charset)r;rQr
rrr�set_payload/s


zMessage.set_payloadcCs|dkr|jd�d|_dSt|t�s.t|�}||_d|krH|jdd�d|krf|jdd|j�d�n|jd|j��||j�kr�|j|j�|_d|k�r|j	�}y||�Wnjt
k
�r|j}|r�y|jd	d
�}Wn tk
r�|j|j
�}YnX|j|�|_|jd|�YnXdS)a�Set the charset of the payload to a given character set.

        charset can be a Charset instance, a string naming a character set, or
        None.  If it is a string it will be converted to a Charset instance.
        If charset is None, the charset parameter will be removed from the
        Content-Type field.  Anything else will generate a TypeError.

        The message will be assumed to be of type text/* encoded with
        charset.input_charset.  It will be converted to charset.output_charset
        and encoded properly, if needed, when generating the plain text
        representation of the message.  MIME headers (MIME-Version,
        Content-Type, Content-Transfer-Encoding) will be added as needed.
        Nr
zMIME-Versionz1.0zContent-Typez
text/plain)r
zContent-Transfer-EncodingrrS)�	del_paramr8rrj�
add_headerZget_output_charset�	set_paramZbody_encoder7Zget_body_encodingrPrrark)r;r
rgrQrrrrlCs8


zMessage.set_charsetcCs|jS)zKReturn the Charset instance associated with the message's payload.
        )r8)r;rrr�get_charsetrszMessage.get_charsetcCs
t|j�S)z9Return the total number of headers, including duplicates.)rr5)r;rrr�__len__zszMessage.__len__cCs
|j|�S)a-Get a header value.

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, exactly which
        occurrence gets returned is undefined.  Use get_all() to get all
        the values matching a header field name.
        )r])r;�namerrr�__getitem__~s	zMessage.__getitem__cCsv|jj|�}|r\|j�}d}x>|jD]4\}}|j�|kr$|d7}||kr$tdj||���q$W|jj|jj||��dS)z�Set the value of a header.

        Note: this does not overwrite an existing header with the same field
        name.  Use __delitem__() first to delete any existing headers.
        rrz/There may be at most {} {} headers in a messageN)r4Zheader_max_countr+r5�
ValueError�formatr,�header_store_parse)r;rs�valZ	max_countZlname�found�k�vrrr�__setitem__�szMessage.__setitem__cCsD|j�}g}x,|jD]"\}}|j�|kr|j||f�qW||_dS)zwDelete all occurrences of a header, if present.

        Does not raise an exception if the header is missing.
        N)r+r5r,)r;rs�
newheadersrzr{rrr�__delitem__�szMessage.__delitem__cCs|j�dd�|jD�kS)NcSsg|]\}}|j��qSr)r+)�.0rzr{rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r+r5)r;rsrrr�__contains__�szMessage.__contains__ccsx|jD]\}}|VqWdS)N)r5)r;Zfieldr$rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)a.Return a list of all the message's header field names.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSrr)rrzr{rrrr��sz Message.keys.<locals>.<listcomp>)r5)r;rrr�keys�szMessage.keyscs�fdd��jD�S)a)Return a list of all the message's header values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        csg|]\}}�jj||��qSr)r4�header_fetch_parse)rrzr{)r;rrr��sz"Message.values.<locals>.<listcomp>)r5)r;r)r;r�values�s
zMessage.valuescs�fdd��jD�S)a'Get all the message's header fields and values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cs"g|]\}}|�jj||�f�qSr)r4r�)rrzr{)r;rrr��sz!Message.items.<locals>.<listcomp>)r5)r;r)r;r�items�s
z
Message.itemscCs:|j�}x,|jD]"\}}|j�|kr|jj||�SqW|S)z~Get a header value.

        Like __getitem__() but return failobj instead of None when the field
        is missing.
        )r+r5r4r�)r;rs�failobjrzr{rrrr]�s
zMessage.getcCs|jj||f�dS)z�Store name and value in the model without modification.

        This is an "internal" API, intended only for use by a parser.
        N)r5r,)r;rsr$rrr�set_raw�szMessage.set_rawcCst|jj��S)z�Return the (name, value) header pairs without modification.

        This is an "internal" API, intended only for use by a generator.
        )�iterr5�copy)r;rrr�	raw_items�szMessage.raw_itemscCsLg}|j�}x2|jD](\}}|j�|kr|j|jj||��qW|sH|S|S)aQReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original
        message, and may contain duplicates.  Any fields deleted and
        re-inserted are always appended to the header list.

        If no such fields exist, failobj is returned (defaults to None).
        )r+r5r,r4r�)r;rsr�r�rzr{rrr�get_all�s	zMessage.get_allcKstg}xH|j�D]<\}}|dkr2|j|jdd��q|jt|jdd�|��qW|dk	rb|jd|�tj|�||<dS)u�Extended header setting.

        name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.  If a
        parameter value contains non-ASCII characters it can be specified as a
        three-tuple of (charset, language, value), in which case it will be
        encoded according to RFC2231 rules.  Otherwise it will be encoded using
        the utf-8 charset and a language of ''.

        Examples:

        msg.add_header('content-disposition', 'attachment', filename='bud.gif')
        msg.add_header('content-disposition', 'attachment',
                       filename=('utf-8', '', Fußballer.ppt'))
        msg.add_header('content-disposition', 'attachment',
                       filename='Fußballer.ppt'))
        N�_�-r)r�r,rTr%�insert�	SEMISPACErc)r;�_name�_valueZ_params�partsrzr{rrrroszMessage.add_headercCs^|j�}xPttt|j��|j�D].\}\}}|j�|kr |jj||�|j|<Pq Wt|��dS)z�Replace a header.

        Replace the first matching header found in the message, retaining
        header order and case.  If no matching header was found, a KeyError is
        raised.
        N)r+�zip�rangerr5r4rw�KeyError)r;r�r�r0rzr{rrr�replace_header!s$zMessage.replace_headercCsHt�}|jd|�}||kr"|j�St|�dj�}|jd�dkrDdS|S)a0Return the message's content type.

        The returned string is coerced to lower case of the form
        `maintype/subtype'.  If there was no Content-Type header in the
        message, the default type as given by get_default_type() will be
        returned.  Since according to RFC 2045, messages always have a default
        type this will always return a value.

        RFC 2045 defines a message's default type to be text/plain unless it
        appears inside a multipart/digest container, in which case it would be
        message/rfc822.
        zcontent-typer�/rz
text/plain)�objectr]�get_default_typerr+r))r;�missingr$�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|j�}|jd�dS)z�Return the message's main content type.

        This is the `maintype' part of the string returned by
        get_content_type().
        r�r)r��split)r;r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|j�}|jd�dS)z�Returns the message's sub-content type.

        This is the `subtype' part of the string returned by
        get_content_type().
        r�r)r�r�)r;r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jS)aReturn the `default' content type.

        Most messages have a default content type of text/plain, except for
        messages that are subparts of multipart/digest containers.  Such
        subparts have a default content type of message/rfc822.
        )r:)r;rrrr�^szMessage.get_default_typecCs
||_dS)z�Set the `default' content type.

        ctype should be either "text/plain" or "message/rfc822", although this
        is not enforced.  The default content type is not stored in the
        Content-Type header.
        N)r:)r;r�rrr�set_default_typegszMessage.set_default_typec	Cs�t�}|j||�}||kr|Sg}xdt|�D]X}y$|jdd�\}}|j�}|j�}Wn tk
rt|j�}d}YnX|j||f�q,Wtj|�}|S)Nr'rr)	r�r]r1r�rrur,rZ
decode_params)	r;r��headerr�r$�params�prsrxrrr�_get_params_preserveps 

zMessage._get_params_preserve�content-typeTcCs8t�}|j||�}||kr|S|r0dd�|D�S|SdS)amReturn the message's Content-Type parameters, as a list.

        The elements of the returned list are 2-tuples of key/value pairs, as
        split on the `=' sign.  The left hand side of the `=' is the key,
        while the right hand side is the value.  If there is no `=' sign in
        the parameter the value is the empty string.  The value is as
        described in the get_param() method.

        Optional failobj is the object to return if there is no Content-Type
        header.  Optional header is the header to search instead of
        Content-Type.  If unquote is True, the value is unquoted.
        cSsg|]\}}|t|�f�qSr)r3)rrzr{rrrr��sz&Message.get_params.<locals>.<listcomp>N)r�r�)r;r�r�r2r�r�rrr�
get_params�s
zMessage.get_paramscCsJ||kr|Sx8|j||�D](\}}|j�|j�kr|r>t|�S|SqW|S)a�Return the parameter value if found in the Content-Type header.

        Optional failobj is the object to return if there is no Content-Type
        header, or the Content-Type header has no such parameter.  Optional
        header is the header to search instead of Content-Type.

        Parameter keys are always compared case insensitively.  The return
        value can either be a string, or a 3-tuple if the parameter was RFC
        2231 encoded.  When it's a 3-tuple, the elements of the value are of
        the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
        LANGUAGE can be None, in which case you should consider VALUE to be
        encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
        The parameter value (either the returned string, or the VALUE item in
        the 3-tuple) is always unquoted, unless unquote is set to False.

        If your application doesn't care whether the parameter was RFC 2231
        encoded, it can turn the return value into a string as follows:

            rawparam = msg.get_param('foo')
            param = email.utils.collapse_rfc2231_value(rawparam)

        )r�r+r3)r;rr�r�r2rzr{rrrr_�szMessage.get_param�Content-TypercCst|t�r|r|||f}||kr4|j�dkr4d}n
|j|�}|j||d�sv|s^t|||�}q�tj|t|||�g�}nfd}x`|j||d�D]N\}	}
d}|	j�|j�kr�t|||�}nt|	|
|�}|s�|}q�tj||g�}q�W||j|�k�r|�r|j	||�n||=|||<dS)a�Set a parameter in the Content-Type header.

        If the parameter already exists in the header, its value will be
        replaced with the new value.

        If header is Content-Type and has not yet been defined for this
        message, it will be set to "text/plain" and the new parameter and
        value will be appended as per RFC 2045.

        An alternate header can be specified in the header argument, and all
        parameters will be quoted as necessary unless requote is False.

        If charset is specified, the parameter will be encoded according to RFC
        2231.  Optional language specifies the RFC 2231 language, defaulting
        to the empty string.  Both charset and language should be strings.
        zcontent-typez
text/plain)r�r)r�r2N)
rrr+r]r_r%r�rcr�r�)r;rr$r��requoter
ZlanguagerTr�Z	old_paramZ	old_valueZappend_paramrrrrp�s2

zMessage.set_paramcCs�||krdSd}xR|j||d�D]@\}}|j�|j�kr |sJt|||�}q tj|t|||�g�}q W||j|�kr�||=|||<dS)a>Remove the given parameter completely from the Content-Type header.

        The header will be re-written in place without the parameter or its
        value. All values will be quoted as necessary unless requote is
        False.  Optional header specifies an alternative to the Content-Type
        header.
        Nr)r�r2)r�r+r%r�rcr])r;rr�r�Z	new_ctyper�r{rrrrn�szMessage.del_paramcCs�|jd�dkst�|j�dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<x(|dd�D]\}}|j||||�qjWdS)	aKSet the main type and subtype for the Content-Type header.

        type must be a string in the form "maintype/subtype", otherwise a
        ValueError is raised.

        This method replaces the Content-Type header, keeping all the
        parameters in place.  If requote is False, this leaves the existing
        header's quoting as is.  Otherwise, the parameters will be quoted (the
        default).

        An alternative header can be specified in the header argument.  When
        the Content-Type header is set, we'll always also add a MIME-Version
        header.
        r�rzcontent-typezmime-versionz1.0zMIME-VersionN)r�r2)r)rur+r�rp)r;r\r�r�r�r�r{rrr�set_typeszMessage.set_typecCsDt�}|jd|d�}||kr*|jd|d�}||kr6|Stj|�j�S)a@Return the filename associated with the payload if present.

        The filename is extracted from the Content-Disposition header's
        `filename' parameter, and it is unquoted.  If that header is missing
        the `filename' parameter, this method falls back to looking for the
        `name' parameter.
        �filenamezcontent-dispositionrszcontent-type)r�r_r�collapse_rfc2231_valuer)r;r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|jd|�}||kr|Stj|�j�S)z�Return the boundary associated with the payload if present.

        The boundary is extracted from the Content-Type header's `boundary'
        parameter, and it is unquoted.
        �boundary)r�r_rr��rstrip)r;r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCs t�}|j|d�}||kr$tjd��g}d}xB|D]:\}}|j�dkr^|jdd|f�d}q2|j||f�q2W|s�|jdd|f�g}x�|jD]�\}	}
|	j�dk�rg}x6|D].\}}
|
dkr�|j|�q�|jd||
f�q�Wtj|�}
|j|j	j
|	|
��q�|j|	|
f�q�W||_d	S)
a�Set the boundary parameter in Content-Type to 'boundary'.

        This is subtly different than deleting the Content-Type header and
        adding a new one with a new boundary parameter via add_header().  The
        main difference is that using the set_boundary() method preserves the
        order of the Content-Type header in the original message.

        HeaderParseError is raised if the message has no Content-Type header.
        zcontent-typezNo Content-Type header foundFr�z"%s"Trz%s=%sN)r�r�rZHeaderParseErrorr+r,r5r�rcr4rw)r;r�r�r�Z	newparamsZfoundpZpkZpvr}�hr{r�rzrxrrr�set_boundaryCs2


zMessage.set_boundarycCs�t�}|jd|�}||kr|St|t�rr|dp2d}y|djd�}t||�}Wn ttfk
rp|d}YnXy|jd�Wntk
r�|SX|j�S)z�Return the charset parameter of the Content-Type header.

        The returned string is always coerced to lower case.  If there is no
        Content-Type header, or if that header has no charset parameter,
        failobj is returned.
        r
rzus-asciirzraw-unicode-escape)	r�r_rrrr
r`rar+)r;r�r�r
ZpcharsetrHrrr�get_content_charsetqs 
zMessage.get_content_charsetcs�fdd�|j�D�S)a�Return a list containing the charset(s) used in this message.

        The returned list of items describes the Content-Type headers'
        charset parameter for this message and all the subparts in its
        payload.

        Each item will either be a string (the value of the charset parameter
        in the Content-Type header of that part) or the value of the
        'failobj' parameter (defaults to None), if the part does not have a
        main MIME type of "text", or the charset is not defined.

        The list will contain one string for each part of the message, plus
        one for the container message (i.e. self), so that a non-multipart
        message will still return a list of length 1.
        csg|]}|j���qSr)r�)r�part)r�rrr��sz(Message.get_charsets.<locals>.<listcomp>)�walk)r;r�r)r�r�get_charsets�szMessage.get_charsetscCs*|jd�}|dkrdSt|�dj�}|S)z�Return the message's content-disposition if it exists, or None.

        The return values can be either 'inline', 'attachment' or None
        according to the rfc2183.
        zcontent-dispositionNr)r]rr+)r;r$�c_drrr�get_content_disposition�s

zMessage.get_content_disposition)r�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)r�TNrF)r�T)r�T)N)N)N)N)4�__name__�
__module__�__qualname__�__doc__r	r<r>r=rIrHrLrMrNrRrhrmrlrqrrrtr|r~r�r�r�r�r�r]r�r�r�ror�r�r�r�r�r�r�r�r_rprnr�r�r�r�r�r�r�Zemail.iteratorsr�rrrrrisb


Z
/


				

!
2

 


.


cs�eZdZd3dd�Zd4�fdd�	Zdd�Zd	d
�Zdd�Zd6dd�Zd7d8d9d:hZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd;d d!�Zd<d"d#�Zd=d$d%�Zdd&�d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS)>�MIMEPartNcCs(|dkrddlm}|}tj||�dS)Nr)�default)Zemail.policyr�rr<)r;r4r�rrrr<�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)aReturn the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  maxheaderlen is retained for backward compatibility with the
        base Message class, but defaults to None, meaning that the policy value
        for max_line_length controls the header maximum length.  'policy' is
        passed to the Generator instance used to serialize the mesasge; if it
        is not specified the policy associated with the message instance is
        used.
        N)rAr4)r4Zmax_line_length�superr=)r;rBrAr4)�	__class__rrr=�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8)r4)r=r4Zclone)r;rrrr>�szMIMEPart.__str__cCs |jd�}|dkrdS|jdkS)Nzcontent-dispositionF�
attachment)r]Zcontent_disposition)r;r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|j�rdS|j�jd�\}}|dkrB||kr>|j|�|fVdS|dkrNdS|dkr~x"|j�D]}|j||�EdHq`WdSd|kr�|jd�|fVd}|jd�}|r�x"|j�D]}|d|kr�|}Pq�W|dkr�|j�}|r�|dnd}|dk	�r|j||�EdHdS)Nr��text�	multipart�related�startz
content-idr)r�r�r�r*�
iter_parts�
_find_bodyr_rh)	r;r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_bodyr��html�plaincCsDt|�}d}x2|j||�D]"\}}||kr|}|}|dkrPqW|S)aReturn best candidate mime part for display as 'body' of message.

        Do a depth first search, starting with self, looking for the first part
        matching each of the items in preferencelist, and return the part
        corresponding to the first item that has a match, or None if no items
        have a match.  If 'related' is not included in preferencelist, consider
        the root part of any multipart/related encountered as a candidate
        match.  Ignore parts with 'Content-Disposition: attachment'.
        Nr)rr�)r;r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_bodyr�r��alternativec	cs|j�jd�\}}|dks"|dkr&dS|j�j�}|dkr�|dkr�|jd�}|r�d}g}x*|D]"}|jd�|krvd	}q^|j|�q^W|r�|EdHdS|jd
�|EdHdSg}xP|D]H}|j�jd�\}}||f|jkr�|j	�r�||kr�|j|�q�|Vq�WdS)aReturn an iterator over the non-main parts of a multipart.

        Skip the first of each occurrence of text/plain, text/html,
        multipart/related, or multipart/alternative in the multipart (unless
        they have a 'Content-Disposition: attachment' header) and include all
        remaining subparts in the returned iterator.  When applied to a
        multipart/related, return all parts except the root part.  Return an
        empty iterator when applied to a multipart/alternative or a
        non-multipart.
        r�r�r�Nr�r�Fz
content-idTr)
r�r�rhr�r_r]r,�pop�_body_typesr�)	r;r�r�r�r�ryZattachmentsr��seenrrr�iter_attachmentss6






zMIMEPart.iter_attachmentsccs|j�dkr|j�EdHdS)z~Return an iterator over all immediate subparts of a multipart.

        Return an empty iterator for a non-multipart.
        r�N)r�rh)r;rrrr�4szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�S)N)r4r��get_content)r;r��args�kwrrrr�<szMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dS)N)r4r��set_content)r;r�r�r�rrrr�AszMIMEPart.set_contentc
Cs�|j�dkr6|j�}||f}||kr6tdj||���g}g}x>|jD]4\}}|j�jd�rl|j||f�qF|j||f�qFW|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|jd|�dS)Nr�zCannot convert {} to {}zcontent-)r4z
multipart/zContent-Typer�)r�r�rurvr5r+�
startswithr,r\r4r7rp)
r;r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersrsr$r�rrr�_make_multipartFs,


zMIMEPart._make_multipartcCs|jdd|�dS)Nr�r��mixed)r�r�)r�)r;r�rrr�make_relatedaszMIMEPart.make_relatedcCs|jdd|�dS)Nr�r�)r�)r�)r;r�rrr�make_alternativedszMIMEPart.make_alternativecCs|jdf|�dS)Nr�)r�)r;r�rrr�
make_mixedgszMIMEPart.make_mixed)�_dispcOsf|j�dks|j�|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|j|�dS)Nr�Zmake_)r4zcontent-dispositionzContent-Disposition)r�r��getattrr\r4r�rR)r;Z_subtyper�r�r�r�rrr�_add_multipartjszMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r�)r�)r;r�r�rrr�add_relatedtszMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�)r�)r;r�r�rrr�add_alternativewszMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�)r�)r;r�r�rrr�add_attachmentzszMIMEPart.add_attachmentcCsg|_d|_dS)N)r5r7)r;rrr�clear}szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|j�jd�s||f�qS)zcontent-)r+r�)r�nr{rrrr��sz*MIMEPart.clear_content.<locals>.<listcomp>)r5r7)r;rrr�
clear_content�szMIMEPart.clear_content)N)FNN�r�r�r�)r�)r�r�)r�r�)r�r�)r�r�)N)N)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��
__classcell__rr)r�rr��s0

.



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)NzMIME-Versionz1.0)r�r�)r;r�r�)r�rrr��szEmailMessage.set_content)r�r�r�r�r�rr)r�rr�s)NT)r��__all__�rererb�iorrZemailrrZemail._policybaserr	r
r8Zemail._encoded_wordsrrjr��compiler!rr%r1r3rr�rrrrr�<module>s6


"NWPKc��\R���base64mime.cpython-36.pycnu�[���3


 \�
�@stdZddddddgZddlmZdd	lmZmZd
ZdZdZ	d
Z
dd�Zddd�Zdefdd�Z
dd�ZeZeZdS)a�Base64 content transfer encoding per RFCs 2045-2047.

This module handles the content transfer encoding method defined in RFC 2045
to encode arbitrary 8-bit data using the three 8-bit bytes in four 7-bit
characters encoding known as Base64.

It is used in the MIME standards for email to attach images, audio, and text
using some 8-bit character sets to messages.

This module provides an interface to encode and decode both headers and bodies
with Base64 encoding.

RFC 2045 defines a method for including character set information in an
`encoded-word' in a header.  This method is commonly used for 8-bit real names
in To:, From:, Cc:, etc. fields, as well as Subject: lines.

This module does not do the line wrapping or end-of-line character conversion
necessary for proper internationalized headers; it only does dumb encoding and
decoding.  To deal with the various line wrapping issues, use the email.header
module.
�body_decode�body_encode�decode�decodestring�
header_encode�
header_length�)�	b64encode)�
b2a_base64�
a2b_base64z
�
��cCs*tt|�d�\}}|d}|r&|d7}|S)z6Return the length of s when it is encoded with base64.��)�divmod�len)�	bytearrayZgroups_of_3Zleftover�n�r�(/usr/lib64/python3.6/email/base64mime.pyr2s
�
iso-8859-1cCs6|sdSt|t�r|j|�}t|�jd�}d||fS)z�Encode a single header line with Base64 encoding in a given charset.

    charset names the character set to use to encode the header.  It defaults
    to iso-8859-1.  Base64 encoding is defined in RFC 2045.
    r�asciiz=?%s?b?%s?=)�
isinstance�str�encoderr)Zheader_bytes�charsetZencodedrrrr=s

�LcCs�|s|Sg}|dd}x^tdt|�|�D]J}t||||��jd�}|jt�rj|tkrj|dd�|}|j|�q*Wtj|�S)a1Encode a string with base64.

    Each line will be wrapped at, at most, maxlinelen characters (defaults to
    76 characters).

    Each line of encoded text will end with eol, which defaults to "\n".  Set
    this to "\r\n" if you will be using the result of this function directly
    in an email.
    rrrrN����)	�rangerr	r�endswith�NL�append�EMPTYSTRING�join)�sZ
maxlinelenZeolZencvecZ
max_unencoded�i�encrrrrLs
cCs.|s
t�St|t�r"t|jd��St|�SdS)z�Decode a raw base64 string, returning a bytes object.

    This function does not parse a full MIME header value encoded with
    base64 (like =?iso-8859-1?b?bmloISBuaWgh?=) -- please use the high
    level email.header class for that functionality.
    zraw-unicode-escapeN)�bytesrrr
r)�stringrrrrfs

N)r)�__doc__�__all__�base64rZbinasciir	r
ZCRLFr!r#ZMISC_LENrrrrrrrrrr�<module>s$
PK��\^b�ZHHdump.cpython-36.opt-2.pycnu�[���3


 \	�@sdd�ZdS)c
cs|j�}dVd}|j|�}x�|j�D]�\}}}|dkr@dVn*|dkrPdVn|jd�r^q&ndj|�V|jd	d
�}|jdj|��}dd
�|j�D�}	dj|djdd�|	D���}|j|�}
x|
D]}dj|d�Vq�Wq&Wd}|j|�}x"|j�D]\}}}dj|�Vq�WdVdS)NzBEGIN TRANSACTION;z�
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" == 'table'
            ORDER BY "name"
        Zsqlite_sequencezDELETE FROM "sqlite_sequence";Zsqlite_stat1zANALYZE "sqlite_master";Zsqlite_z{0};�"z""zPRAGMA table_info("{0}")cSsg|]}t|d��qS)�)�str)�.0Z
table_info�r�$/usr/lib64/python3.6/sqlite3/dump.py�
<listcomp>3sz_iterdump.<locals>.<listcomp>z2SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";�,css |]}dj|jdd��VqdS)z'||quote("{0}")||'rz""N)�format�replace)r�colrrr�	<genexpr>6sz_iterdump.<locals>.<genexpr>�z�
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" IN ('index', 'trigger', 'view')
        zCOMMIT;)ZcursorZexecuteZfetchall�
startswithr	r
�join)
Z
connectionZcu�qZ
schema_resZ
table_name�typeZsqlZtable_name_ident�resZcolumn_namesZ	query_res�row�namerrr�	_iterdump
s4		

	


rN)rrrrr�<module>
sPK��\�!j�||dump.cpython-36.pycnu�[���3


 \	�@sdd�ZdS)c
cs|j�}dVd}|j|�}x�|j�D]�\}}}|dkr@dVn*|dkrPdVn|jd�r^q&ndj|�V|jd	d
�}|jdj|��}dd
�|j�D�}	dj|djdd�|	D���}|j|�}
x|
D]}dj|d�Vq�Wq&Wd}|j|�}x"|j�D]\}}}dj|�Vq�WdVdS)a/
    Returns an iterator to the dump of the database in an SQL text format.

    Used to produce an SQL dump of the database.  Useful to save an in-memory
    database for later restoration.  This function should not be called
    directly but instead called from the Connection method, iterdump().
    zBEGIN TRANSACTION;z�
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" == 'table'
            ORDER BY "name"
        Zsqlite_sequencezDELETE FROM "sqlite_sequence";Zsqlite_stat1zANALYZE "sqlite_master";Zsqlite_z{0};�"z""zPRAGMA table_info("{0}")cSsg|]}t|d��qS)�)�str)�.0Z
table_info�r�$/usr/lib64/python3.6/sqlite3/dump.py�
<listcomp>3sz_iterdump.<locals>.<listcomp>z2SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";�,css |]}dj|jdd��VqdS)z'||quote("{0}")||'rz""N)�format�replace)r�colrrr�	<genexpr>6sz_iterdump.<locals>.<genexpr>�z�
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" IN ('index', 'trigger', 'view')
        zCOMMIT;N)ZcursorZexecuteZfetchall�
startswithr	r
�join)
Z
connectionZcu�qZ
schema_resZ
table_name�typeZsqlZtable_name_ident�resZcolumn_namesZ	query_res�row�namerrr�	_iterdump
s4		

	


rN)rrrrr�<module>
sPK��\��'��	�	dbapi2.cpython-36.pycnu�[���3


 \
�@s�ddlZddlZddlZddlTdZdZdZejZ	ejZ
ejZdd�Zdd	�Z
d
d�Zedd
�ejd�D��Zedd
�ejd�D��ZeZejjje�dd�Ze�[dS)�N)�*Zqmark�z2.0cCsttj|�dd��S)N�)�Date�time�	localtime)�ticks�r	�&/usr/lib64/python3.6/sqlite3/dbapi2.py�
DateFromTicks)srcCsttj|�dd��S)Nr�)�Timerr)rr	r	r
�
TimeFromTicks,srcCsttj|�dd��S)Nr)�	Timestamprr)rr	r	r
�TimestampFromTicks/srcCsg|]}t|��qSr	)�int)�.0�xr	r	r
�
<listcomp>2sr�.cCsg|]}t|��qSr	)r)rrr	r	r
r3scCsPdd�}dd�}dd�}dd�}ttj|�ttj|�td	|�td
|�dS)NcSs|j�S)N)�	isoformat)�valr	r	r
�
adapt_date9sz4register_adapters_and_converters.<locals>.adapt_datecSs
|jd�S)N� )r)rr	r	r
�adapt_datetime<sz8register_adapters_and_converters.<locals>.adapt_datetimecSstjtt|jd���S)N�-)�datetime�date�mapr�split)rr	r	r
�convert_date?sz6register_adapters_and_converters.<locals>.convert_datecSs�|jd�\}}tt|jd��\}}}|jd�}tt|djd��\}}}	t|�dkrltdj|dj���}
nd}
tj||||||	|
�}|S)	N� r�.r�:�z{:0<6.6}r)rrr�len�format�decoder)rZdatepartZtimepartZyearZmonthZdayZ
timepart_fullZhoursZminutesZsecondsZmicrosecondsr	r	r
�convert_timestampBs
z;register_adapters_and_converters.<locals>.convert_timestamprZ	timestamp)Zregister_adapterrrZregister_converter)rrr r(r	r	r
� register_adapters_and_converters8s
r))rr�collections.abc�collectionsZ_sqlite3Z
paramstyleZthreadsafetyZapilevelrrr
rrrr�tuple�versionr�version_infoZsqlite_versionZsqlite_version_info�
memoryviewZBinary�abc�Sequence�registerZRowr)r	r	r	r
�<module>s&PK��\�!j�||dump.cpython-36.opt-1.pycnu�[���3


 \	�@sdd�ZdS)c
cs|j�}dVd}|j|�}x�|j�D]�\}}}|dkr@dVn*|dkrPdVn|jd�r^q&ndj|�V|jd	d
�}|jdj|��}dd
�|j�D�}	dj|djdd�|	D���}|j|�}
x|
D]}dj|d�Vq�Wq&Wd}|j|�}x"|j�D]\}}}dj|�Vq�WdVdS)a/
    Returns an iterator to the dump of the database in an SQL text format.

    Used to produce an SQL dump of the database.  Useful to save an in-memory
    database for later restoration.  This function should not be called
    directly but instead called from the Connection method, iterdump().
    zBEGIN TRANSACTION;z�
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" == 'table'
            ORDER BY "name"
        Zsqlite_sequencezDELETE FROM "sqlite_sequence";Zsqlite_stat1zANALYZE "sqlite_master";Zsqlite_z{0};�"z""zPRAGMA table_info("{0}")cSsg|]}t|d��qS)�)�str)�.0Z
table_info�r�$/usr/lib64/python3.6/sqlite3/dump.py�
<listcomp>3sz_iterdump.<locals>.<listcomp>z2SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";�,css |]}dj|jdd��VqdS)z'||quote("{0}")||'rz""N)�format�replace)r�colrrr�	<genexpr>6sz_iterdump.<locals>.<genexpr>�z�
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" IN ('index', 'trigger', 'view')
        zCOMMIT;N)ZcursorZexecuteZfetchall�
startswithr	r
�join)
Z
connectionZcu�qZ
schema_resZ
table_name�typeZsqlZtable_name_ident�resZcolumn_namesZ	query_res�row�namerrr�	_iterdump
s4		

	


rN)rrrrr�<module>
sPK��\��'��	�	dbapi2.cpython-36.opt-1.pycnu�[���3


 \
�@s�ddlZddlZddlZddlTdZdZdZejZ	ejZ
ejZdd�Zdd	�Z
d
d�Zedd
�ejd�D��Zedd
�ejd�D��ZeZejjje�dd�Ze�[dS)�N)�*Zqmark�z2.0cCsttj|�dd��S)N�)�Date�time�	localtime)�ticks�r	�&/usr/lib64/python3.6/sqlite3/dbapi2.py�
DateFromTicks)srcCsttj|�dd��S)Nr�)�Timerr)rr	r	r
�
TimeFromTicks,srcCsttj|�dd��S)Nr)�	Timestamprr)rr	r	r
�TimestampFromTicks/srcCsg|]}t|��qSr	)�int)�.0�xr	r	r
�
<listcomp>2sr�.cCsg|]}t|��qSr	)r)rrr	r	r
r3scCsPdd�}dd�}dd�}dd�}ttj|�ttj|�td	|�td
|�dS)NcSs|j�S)N)�	isoformat)�valr	r	r
�
adapt_date9sz4register_adapters_and_converters.<locals>.adapt_datecSs
|jd�S)N� )r)rr	r	r
�adapt_datetime<sz8register_adapters_and_converters.<locals>.adapt_datetimecSstjtt|jd���S)N�-)�datetime�date�mapr�split)rr	r	r
�convert_date?sz6register_adapters_and_converters.<locals>.convert_datecSs�|jd�\}}tt|jd��\}}}|jd�}tt|djd��\}}}	t|�dkrltdj|dj���}
nd}
tj||||||	|
�}|S)	N� r�.r�:�z{:0<6.6}r)rrr�len�format�decoder)rZdatepartZtimepartZyearZmonthZdayZ
timepart_fullZhoursZminutesZsecondsZmicrosecondsr	r	r
�convert_timestampBs
z;register_adapters_and_converters.<locals>.convert_timestamprZ	timestamp)Zregister_adapterrrZregister_converter)rrr r(r	r	r
� register_adapters_and_converters8s
r))rr�collections.abc�collectionsZ_sqlite3Z
paramstyleZthreadsafetyZapilevelrrr
rrrr�tuple�versionr�version_infoZsqlite_versionZsqlite_version_info�
memoryviewZBinary�abc�Sequence�registerZRowr)r	r	r	r
�<module>s&PK��\��'��	�	dbapi2.cpython-36.opt-2.pycnu�[���3


 \
�@s�ddlZddlZddlZddlTdZdZdZejZ	ejZ
ejZdd�Zdd	�Z
d
d�Zedd
�ejd�D��Zedd
�ejd�D��ZeZejjje�dd�Ze�[dS)�N)�*Zqmark�z2.0cCsttj|�dd��S)N�)�Date�time�	localtime)�ticks�r	�&/usr/lib64/python3.6/sqlite3/dbapi2.py�
DateFromTicks)srcCsttj|�dd��S)Nr�)�Timerr)rr	r	r
�
TimeFromTicks,srcCsttj|�dd��S)Nr)�	Timestamprr)rr	r	r
�TimestampFromTicks/srcCsg|]}t|��qSr	)�int)�.0�xr	r	r
�
<listcomp>2sr�.cCsg|]}t|��qSr	)r)rrr	r	r
r3scCsPdd�}dd�}dd�}dd�}ttj|�ttj|�td	|�td
|�dS)NcSs|j�S)N)�	isoformat)�valr	r	r
�
adapt_date9sz4register_adapters_and_converters.<locals>.adapt_datecSs
|jd�S)N� )r)rr	r	r
�adapt_datetime<sz8register_adapters_and_converters.<locals>.adapt_datetimecSstjtt|jd���S)N�-)�datetime�date�mapr�split)rr	r	r
�convert_date?sz6register_adapters_and_converters.<locals>.convert_datecSs�|jd�\}}tt|jd��\}}}|jd�}tt|djd��\}}}	t|�dkrltdj|dj���}
nd}
tj||||||	|
�}|S)	N� r�.r�:�z{:0<6.6}r)rrr�len�format�decoder)rZdatepartZtimepartZyearZmonthZdayZ
timepart_fullZhoursZminutesZsecondsZmicrosecondsr	r	r
�convert_timestampBs
z;register_adapters_and_converters.<locals>.convert_timestamprZ	timestamp)Zregister_adapterrrZregister_converter)rrr r(r	r	r
� register_adapters_and_converters8s
r))rr�collections.abc�collectionsZ_sqlite3Z
paramstyleZthreadsafetyZapilevelrrr
rrrr�tuple�versionr�version_infoZsqlite_versionZsqlite_version_info�
memoryviewZBinary�abc�Sequence�registerZRowr)r	r	r	r
�<module>s&PKg�\l
��~~server.cpython-36.pycnu�[���3

���i���@s�dZdZddddgZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZd	Zd
ZGdd�dej�ZGdd�dej�ZGd
d�de�Zdd�Zdadd�Z dd�Z!Gdd�de�Z"eedddfdd�Z#e$dk�r�ej%�Z&e&j'dddd�e&j'dd dd!d"d#�e&j'd$d%de(d&d'd(�e&j)�Z*e*j+�r~e"Z,neZ,e#e,e*j-e*j.d)�dS)*a@HTTP server classes.

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections,
as of version 0.3.

Notes on CGIHTTPRequestHandler
------------------------------

This class implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
subprocess.Popen() is used as a fallback, with slightly altered semantics.

In all cases, the implementation is intentionally naive -- all
requests are executed synchronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
z0.6�
HTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c@seZdZdZdd�ZdS)r�cCs4tjj|�|jdd�\}}tj|�|_||_dS)z.Override server_bind to store the server name.N�)�socketserver�	TCPServer�server_bind�server_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�#/usr/lib64/python3.6/http/server.pyr�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressrrrrrr�sc
@seZdZdZdejj�dZdeZ	e
ZeZ
dZdd�Zdd	�Zd
d�Zdd
�Zd@dd�ZdAdd�ZdBdd�Zdd�Zdd�Zdd�ZdCdd�Zdd�Zd d!�Zd"d#�ZdDd$d%�Zd&d'�Zd(d)d*d+d,d-d.gZdd/d0d1d2d3d4d5d6d7d8d9d:g
Z d;d<�Z!d=Z"e#j$j%Z&d>d?�e'j(j)�D�Z*dS)Era�HTTP request handler base class.

    The following explanation of HTTP serves to guide you through the
    code as well as to expose any misunderstandings I may have about
    HTTP (so you don't need to read the code to figure out I'm wrong
    :-).

    HTTP (HyperText Transfer Protocol) is an extensible protocol on
    top of a reliable stream transport (e.g. TCP/IP).  The protocol
    recognizes three parts to a request:

    1. One line identifying the request type and path
    2. An optional set of RFC-822-style headers
    3. An optional data part

    The headers and data are separated by a blank line.

    The first line of the request has the form

    <command> <path> <version>

    where <command> is a (case-sensitive) keyword such as GET or POST,
    <path> is a string containing path information for the request,
    and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
    <path> is encoded using the URL encoding scheme (using %xx to signify
    the ASCII character with hex code xx).

    The specification specifies that lines are separated by CRLF but
    for compatibility with the widest range of clients recommends
    servers also handle LF.  Similarly, whitespace in the request line
    is treated sensibly (allowing multiple spaces between components
    and allowing trailing whitespace).

    Similarly, for output, lines ought to be separated by CRLF pairs
    but most clients grok LF characters just fine.

    If the first line of the request has the form

    <command> <path>

    (i.e. <version> is left out) then this is assumed to be an HTTP
    0.9 request; this form has no optional headers and data part and
    the reply consists of just the data.

    The reply form of the HTTP 1.x protocol again has three parts:

    1. One line giving the response code
    2. An optional set of RFC-822-style headers
    3. The data

    Again, the headers and data are separated by a blank line.

    The response code line has the form

    <version> <responsecode> <responsestring>

    where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
    <responsecode> is a 3-digit response code indicating success or
    failure of the request, and <responsestring> is an optional
    human-readable string explaining what the response code means.

    This server parses the request and the headers, and then calls a
    function specific to the request type (<command>).  Specifically,
    a request SPAM will be handled by a method do_SPAM().  If no
    such method exists the server sends an error response to the
    client.  If it exists, it is called with no arguments:

    do_SPAM()

    Note that the request name is case sensitive (i.e. SPAM and spam
    are different requests).

    The various request details are stored in instance variables:

    - client_address is the client IP address in the form (host,
    port);

    - command, path and version are the broken-down request line;

    - headers is an instance of email.message.Message (or a derived
    class) containing the header information;

    - rfile is a file object open for reading positioned at the
    start of the optional input data part;

    - wfile is a file object open for writing.

    IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

    The first thing to be written must be the response line.  Then
    follow 0 or more header lines, then a blank line, and then the
    actual data (if any).  The meaning of the header lines depends on
    the command executed by the server; in most cases, when data is
    returned, there should be at least one header line of the form

    Content-type: <type>/<subtype>

    where <type> and <subtype> should be registered MIME types,
    e.g. "text/html" or "text/plain".

    zPython/rz	BaseHTTP/zHTTP/0.9cCs�d|_|j|_}d|_t|jd�}|jd�}||_|j�}t	|�dk�r|\}}}yZ|dd�dkrjt
�|jdd	�d	}|jd
�}t	|�dkr�t
�t|d�t|d	�f}Wn*t
tfk
r�|j
tjd
|�dSX|dkr�|jdkr�d|_|dk�rr|j
tjd|�dSn^t	|�dk�rR|\}}d|_|dk�rr|j
tjd|�dSn |�s\dS|j
tjd|�dS||||_|_|_|jjd��r�d|jjd�|_ytjj|j|jd�|_Wnrtjjk
�r�}z|j
tjdt|��dSd}~Xn:tjjk
�r4}z|j
tjdt|��dSd}~XnX|jjdd�}	|	j�dk�rZd|_n |	j�dk�rz|jdk�rzd|_|jjdd�}
|
j�dk�r�|jdk�r�|jdk�r�|j ��s�dSdS) a'Parse a request (internal).

        The request should be stored in self.raw_requestline; the results
        are in self.command, self.path, self.request_version and
        self.headers.

        Return True for success, False for failure; on failure, an
        error is sent back.

        NTz
iso-8859-1z
��zHTTP/�/r�.rrzBad request version (%r)FzHTTP/1.1zInvalid HTTP version (%s)ZGETzBad HTTP/0.9 request type (%r)zBad request syntax (%r)z//)Z_classz
Line too longzToo many headers�
Connection��closez
keep-aliveZExpectz100-continue)rr)rr)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�
startswith�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr&�wordsrr.Zbase_version_numberZversion_number�errZconntypeZexpectrrr�
parse_requests�












z$BaseHTTPRequestHandler.parse_requestcCs|jtj�|j�dS)a7Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        T)�send_response_onlyrZCONTINUE�end_headers)rrrrr8nsz(BaseHTTPRequestHandler.handle_expect_100cCs�y�|jjd�|_t|j�dkr@d|_d|_d|_|jtj	�dS|jsPd|_
dS|j�s\dSd|j}t||�s�|jtj
d|j�dSt||�}|�|jj�Wn4tjk
r�}z|jd|�d|_
dSd}~XnXdS)	z�Handle a single HTTP request.

        You normally don't need to override this method; see the class
        __doc__ string for information on how to handle specific HTTP
        commands such as GET and POST.

        iirNTZdo_zUnsupported method (%r)zRequest timed out: %r)r3�readliner$r(r&r!rr,rZREQUEST_URI_TOO_LONGr"r<�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushr
Ztimeout�	log_error)rZmname�method�errr�handle_one_request�s4


z)BaseHTTPRequestHandler.handle_one_requestcCs&d|_|j�x|js |j�qWdS)z&Handle multiple requests if necessary.TN)r"rH)rrrr�handle�szBaseHTTPRequestHandler.handleNcCs
y|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|jd||�|j||�|jdd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d	�}|jd
d�}|jd|j
�|jd
tt|���|j�|jdko�|�r|jj|�dS)akSend and log an error reply.

        Arguments are
        * code:    an HTTP error code
                   3 digits
        * message: a simple optional 1 line reason phrase.
                   *( HTAB / SP / VCHAR / %x80-FF )
                   defaults to short entry matching the response code
        * explain: a detailed message defaults to the long entry
                   matching the response code.

        This sends an error response (so it must be called before any
        output has been generated), logs the error, and finally sends
        a piece of HTML explaining the error to the user.

        �???Nzcode %d, message %srr��F)�quote)�code�message�explainzUTF-8�replacezContent-TypezContent-LengthZHEAD)rJrJ)�	responses�KeyErrorrE�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENTZNOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer#r(r>rrC�write)rrMrNrOZshortmsgZlongmsgZbodyZcontentrrrr,�s4
z!BaseHTTPRequestHandler.send_errorcCs:|j|�|j||�|jd|j��|jd|j��dS)z�Add the response header to the headers buffer and log the
        response code.

        Also send two standard headers with the server software
        version and the current date.

        ZServerZDateN)�log_requestr=rT�version_string�date_time_string)rrMrNrrrrS�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|jjd|j||fjdd��dS)	zSend the response header only.zHTTP/0.9Nrr�_headers_bufferz
%s %d %s
zlatin-1�strict)r!rQr@r^�appendr-rX)rrMrNrrrr=�s


z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|jjd||fjdd��|j�dkrh|j�dkrVd|_n|j�d	krhd
|_dS)z)Send a MIME header to the headers buffer.zHTTP/0.9r^z%s: %s
zlatin-1r_Z
connectionrTz
keep-aliveFN)r!r@r^r`rXr7r")r�keyword�valuerrrrT�s

z"BaseHTTPRequestHandler.send_headercCs"|jdkr|jjd�|j�dS)z,Send the blank line ending the MIME headers.zHTTP/0.9s
N)r!r^r`�
flush_headers)rrrrr>s
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|jjdj|j��g|_dS)Nr^�)r@rCrZ�joinr^)rrrrrcs
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|jd|jt|�t|��dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)�
isinstancerrb�log_messager&r#)rrM�sizerrrr[s
z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS)z�Log an error.

        This is called when a request cannot be fulfilled.  By
        default it passes the message on to log_message().

        Arguments are the same as for log_message().

        XXX This should go to the separate error log.

        N)rh)r�format�argsrrrrE!sz BaseHTTPRequestHandler.log_errorcGs&tjjd|j�|j�||f�dS)a�Log an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        z%s - - [%s] %s
N)�sys�stderrrZ�address_string�log_date_time_string)rrjrkrrrrh/sz"BaseHTTPRequestHandler.log_messagecCs|jd|jS)z*Return the server software version string.� )�server_version�sys_version)rrrrr\Esz%BaseHTTPRequestHandler.version_stringcCs |dkrtj�}tjj|dd�S)z@Return the current date and time formatted for a message header.NT)Zusegmt)�time�emailZutilsZ
formatdate)rZ	timestamprrrr]Isz'BaseHTTPRequestHandler.date_time_stringc	CsBtj�}tj|�\	}}}}}}}}	}
d||j|||||f}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)rsZ	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrroOs
z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)zReturn the client address.r)�client_address)rrrrrn]sz%BaseHTTPRequestHandler.address_stringzHTTP/1.0cCsi|]}|j|jf|�qSr)�phraseZdescription)�.0�vrrr�
<dictcomp>lsz!BaseHTTPRequestHandler.<dictcomp>)NN)N)N)rfrf)N)+rrr�__doc__rlr9r'rr�__version__rq�DEFAULT_ERROR_MESSAGErU�DEFAULT_ERROR_CONTENT_TYPErYr r<r8rHrIr,rSr=rTr>rcr[rErhr\r]roZweekdaynamerurnr-r1r2ZHTTPMessager4r�__members__�valuesrQrrrrr�s>fg%
5



	c@s|eZdZdZdeZdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Ze
jsZe
j�e
jj�Zejddddd��dS)raWSimple HTTP request handler with GET and HEAD commands.

    This serves files from the current directory and any of its
    subdirectories.  The MIME type for files is determined by
    calling the .guess_type() method.

    The GET and HEAD requests are identical except that the HEAD
    request omits the actual contents of the file.

    zSimpleHTTP/c
Cs.|j�}|r*z|j||j�Wd|j�XdS)zServe a GET request.N)�	send_head�copyfilerCr)r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|j�}|r|j�dS)zServe a HEAD request.N)r�r)rr�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADc	Csx|j|j�}d}tjj|�r�tjj|j�}|jjd�s�|jt	j
�|d|d|dd|d|df}tjj|�}|jd|�|j
�dSx6dD]$}tjj||�}tjj|�r�|}Pq�W|j|�S|j|�}yt|d�}Wn$tk
�r|jt	jd�dSXyZ|jt	j�|jd
|�tj|j��}|jdt|d��|jd|j|j��|j
�|S|j��YnXdS)a{Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.

        Nrrrrr�ZLocation�
index.html�	index.htm�rbzFile not foundzContent-typezContent-Length�z
Last-Modified)r�r�)�translate_pathr.�os�isdir�urllib�parseZurlsplit�endswithrSrZMOVED_PERMANENTLYZ
urlunsplitrTr>re�exists�list_directory�
guess_type�open�OSErrorr,�	NOT_FOUND�OK�fstat�filenor#r]�st_mtimer)	rr.r��partsZ	new_partsZnew_url�indexZctypeZfsrrrr��sF


z"SimpleHTTPRequestHandler.send_headc
Cs�ytj|�}Wn"tk
r0|jtjd�dSX|jdd�d�g}ytjj	|j
dd�}Wn tk
r|tjj	|�}YnXtj
|dd	�}tj�}d
|}|jd�|jd�|jd
|�|jd|�|jd|�|jd�x~|D]v}tj
j||�}|}	}
tj
j|��r"|d}	|d}
tj
j|��r8|d}	|jdtjj|
dd�tj
|	dd	�f�q�W|jd�dj|�j|d�}tj�}|j|�|jd�|jtj�|jdd|�|jdtt|���|j�|S)z�Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        zNo permission to list directoryNcSs|j�S)N)r7)�arrr�<lambda>�sz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass)�errorsF)rLzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperzContent-typeztext/html; charset=%szContent-Length) r��listdirr�r,rr��sortr�r��unquoter.�UnicodeDecodeErrorrVrWrl�getfilesystemencodingr`rer��islinkrLrX�io�BytesIOrZ�seekrSr�rTr#r(r>)
rr.�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr��s\







z'SimpleHTTPRequestHandler.list_directorycCs�|jdd�d}|jdd�d}|j�jd�}ytjj|dd�}Wn tk
rbtjj|�}YnXtj|�}|jd�}t	d|�}t
j�}x8|D]0}t
jj
|�s�|t
jt
jfkr�q�t
jj||�}q�W|r�|d7}|S)	z�Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        �?rr�#rr�)r�N)r'r%r�r�r�r�r��	posixpath�normpath�filterr��getcwdr.�dirname�curdir�pardirre)rr.Ztrailing_slashr:Zwordrrrr��s$	



z'SimpleHTTPRequestHandler.translate_pathcCstj||�dS)a�Copy all data between two file objects.

        The SOURCE argument is a file object open for reading
        (or anything with a read() method) and the DESTINATION
        argument is a file object open for writing (or
        anything with a write() method).

        The only reason for overriding this would be to change
        the block size or perhaps to replace newlines by CRLF
        -- note however that this the default server uses this
        to copy binary data as well.

        N)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�sz!SimpleHTTPRequestHandler.copyfilecCsLtj|�\}}||jkr"|j|S|j�}||jkr>|j|S|jdSdS)a�Guess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.

        rN)r��splitext�extensions_mapr7)rr.�baseZextrrrr�)s



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)rz.pyz.cz.hN)rrrrr�rqr�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��updaterrrrrrs"	1:
c	Cs�|jd�\}}}tjj|�}|jd�}g}x<|dd�D],}|dkrN|j�q8|r8|dkr8|j|�q8W|r�|j�}|r�|dkr�|j�d}q�|dkr�d}nd}|r�dj||f�}ddj|�|f}dj|�}|S)	a�
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a collapsed path.

    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.

    Returns: The reconstituted URL, which will always start with a '/'.

    Raises: IndexError if too many '..' occur within the path.

    r�rNrz..rr���)�	partitionr�r�r�r'�popr`re)	r.�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_pathNs.


r�cCsptrtSyddl}Wntk
r(dSXy|jd�daWn.tk
rjdtdd�|j�D��aYnXtS)	z$Internal routine to get nobody's uidrNr�nobodyrcss|]}|dVqdS)rNr)r|rvrrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>r�)r��pwd�ImportError�getpwnamrR�maxZgetpwall)r�rrr�
nobody_uid�s r�cCstj|tj�S)zTest for executable file.)r��access�X_OK)r.rrr�
executable�sr�c@sVeZdZdZeed�ZdZdd�Zdd�Z	dd	�Z
d
dgZdd
�Zdd�Z
dd�ZdS)rz�Complete HTTP server with GET, HEAD and POST commands.

    GET and HEAD also support running CGI scripts.

    The POST command is *only* implemented for CGI scripts.

    �forkrcCs$|j�r|j�n|jtjd�dS)zRServe a POST request.

        This is only implemented for CGI scripts.

        zCan only POST to CGI scriptsN)�is_cgi�run_cgir,rrA)rrrr�do_POST�s

zCGIHTTPRequestHandler.do_POSTcCs|j�r|j�Stj|�SdS)z-Version of send_head that support CGI scriptsN)r�r�rr�)rrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|jdd�}|d|�||dd�}}||jkrL||f|_dSdS)a3Test whether self.path corresponds to a CGI script.

        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.

        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.

        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).

        rrNTF)r�r.�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr��s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�S)z1Test whether argument path is an executable file.)r�)rr.rrr�
is_executable�sz#CGIHTTPRequestHandler.is_executablecCstjj|�\}}|j�dkS)z.Test whether argument path is a Python script.�.py�.pyw)r�r�)r�r.r�r7)rr.r�r�rrr�	is_python�szCGIHTTPRequestHandler.is_pythonc)Cs�|j\}}|d|}|jdt|�d�}x`|dkr�|d|�}||dd�}|j|�}tjj|�r�||}}|jdt|�d�}q,Pq,W|jd�\}}}	|jd�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|j|�}tjj|��s|j	t
jd|�dStjj|��s2|j	t
j
d|�dS|j|�}
|j�sL|
�rn|j|��sn|j	t
j
d	|�dStjtj�}|j�|d
<|jj|d<d|d
<|j|d<t|jj�|d<|j|d<tjj|�}||d<|j|�|d<||d<|	�r�|	|d<|jd|d<|jj d�}|�r�|j!�}t|�dk�r�ddl"}ddl#}|d|d<|dj$�dk�r�y"|dj%d�}|j&|�j'd�}Wn|j(t)fk
�r�Yn&X|j!d�}t|�dk�r�|d|d<|jj d�dk�r�|jj*�|d<n|jd|d<|jj d�}|�r||d <|jj d!�}|�r"||d"<g}xN|jj+d#�D]>}|dd�d$k�rZ|j,|j-��n||d%d�j!d&�}�q4Wd&j.|�|d'<|jj d(�}|�r�||d)<t/d|jj0d*g��}d+j.|�}|�r�||d,<xd=D]}|j1|d��q�W|j2t
j3d.�|j4�|	j5d/d0�}|j�r.|
g}d1|k�r*|j,|�t6�}|j7j8�tj9�}|dk�r�tj:|d�\}}x0t;j;|j<gggd�d�r�|j<j=d��s^P�q^W|�r�|j>d2|�dSy\ytj?|�Wnt@k
�r�YnXtjA|j<jB�d�tjA|j7jB�d�tjC|||�Wn(|jjD|jE|j�tjFd3�YnX�n�ddlG} |g}!|j|��r�tHjI}"|"j$�jJd4��rv|"dd>�|"d?d�}"|"d7g|!}!d1|	k�r�|!j,|	�|jKd8| jL|!��ytM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d9�}$|jj$�d:k�r|#dk�r|j<j=|#�}%nd}%x4t;j;|j<jRgggd�d�rN|j<jRjSd��sP�qW|$jT|%�\}&}'|j7jU|&�|'�r||j>d;|'�|$jVjW�|$jXjW�|$jY}(|(�r�|j>d2|(�n
|jKd<�dS)@zExecute a CGI script.rrrNr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationrZ	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE�REMOTE_HOSTzScript output follows�+rp�=zCGI script exit status %#x�zw.exerr�z-uzcommand: %s)�stdin�stdoutrm�envZpostz%szCGI script exited OK)r�r�r�r�r�r�������)Zr�r�r(r�r�r.r�r�r�r,rr��isfileZ	FORBIDDENr��	have_forkr�r��deepcopy�environr\Zserverrr-r#rrr�r�r�rzr5r6r'�base64�binasciir7rXZdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersr`�striprer�Zget_all�
setdefaultrSr�rcrPr�rCrDr��waitpid�selectr3�readrE�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessrlr�r�rhZlist2cmdliner*�	TypeErrorr)�Popen�PIPEZ_sockZrecvZcommunicaterZrmrr��
returncode))r�dir�restr.�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyr�Zuqrestr�rrZlengthr�r��lineZua�coZ
cookie_str�kZ
decoded_queryrkr��pid�stsrZcmdlineZinterp�nbytes�p�datar�rmZstatusrrrr��s4

























zCGIHTTPRequestHandler.run_cgiN)rrrrr@r�r�Zrbufsizer�r�r�r�r�r�r�rrrrr�s
zHTTP/1.0i@rc	Cs�||f}||_|||��b}|jj�}d}t|j|d|dd��y|j�Wn&tk
rttd�tjd�YnXWdQRXdS)zmTest the HTTP request handler class.

    This runs an HTTP server on port 8000 (or the port argument).

    z>Serving HTTP on {host} port {port} (http://{host}:{port}/) ...rr)rrz&
Keyboard interrupt received, exiting.N)	r-r
Zgetsockname�printrjZ
serve_forever�KeyboardInterruptrl�exit)	�HandlerClassZServerClassZprotocolr�bindrZhttpdZsaZ
serve_messagerrr�test�s
r%�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�default�metavarr)rZstorer�z&Specify alternate port [default: 8000])r(r*�type�nargsr))r#rr$)/rr��__all__Zemail.utilsrtrVZhttp.clientr1r�r�r�r�r
r�r
r	rlrsZurllib.parser�r��argparserr�r�r
rZStreamRequestHandlerrrr�r�r�r�rr%r�ArgumentParser�parser�add_argumentr*�
parse_argsrkZcgiZ
handler_classrr$rrrr�<module> sj3g]0
PKg�\m$�w�>�>cookies.cpython-36.opt-1.pycnu�[���3


 \�S�
@s|dZddlZddlZdddgZdjZdjZdjZd	d
�ZGdd�de	�Z
ejejdZ
e
d
Zdd�eed��eeee��D�Zejed�ded�di�ejdeje
��jZdd�Zejd�Zejd�Zdd�Zddddd d!d"gZdd#d$d%d&d'd(d)d*d+d,d-d.g
Zdeefd/d0�ZGd1d2�d2e �Z!d3Z"e"d4Z#ejd5e"d6e#d7ej$ej%B�Z&Gd8d�de �Z'Gd9d�de'�Z(dS):a.

Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

The Basics
----------

Importing is easy...

   >>> from http import cookies

Most of the time you start by creating a cookie.

   >>> C = cookies.SimpleCookie()

Once you've created your Cookie, you can add values just as if it were
a dictionary.

   >>> C = cookies.SimpleCookie()
   >>> C["fig"] = "newton"
   >>> C["sugar"] = "wafer"
   >>> C.output()
   'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'

Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header.  This is the
default behavior.  You can change the header and printed
attributes by using the .output() function

   >>> C = cookies.SimpleCookie()
   >>> C["rocky"] = "road"
   >>> C["rocky"]["path"] = "/cookie"
   >>> print(C.output(header="Cookie:"))
   Cookie: rocky=road; Path=/cookie
   >>> print(C.output(attrs=[], header="Cookie:"))
   Cookie: rocky=road

The load() method of a Cookie extracts cookies from a string.  In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.

   >>> C = cookies.SimpleCookie()
   >>> C.load("chips=ahoy; vienna=finger")
   >>> C.output()
   'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'

The load() method is darn-tootin smart about identifying cookies
within a string.  Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.

   >>> C = cookies.SimpleCookie()
   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C = cookies.SimpleCookie()
   >>> C["oreo"] = "doublestuff"
   >>> C["oreo"]["path"] = "/"
   >>> print(C)
   Set-Cookie: oreo=doublestuff; Path=/

Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C = cookies.SimpleCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'

The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.

   >>> C = cookies.SimpleCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   '7'
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number=7\r\nSet-Cookie: string=seven'

Finis.
�N�CookieError�
BaseCookie�SimpleCookie�z; � cCs$ddl}d|}|j|tdd�dS)NrzvThe .%s setter is deprecated. The attribute will be read-only in future releases. Please use the set() method instead.�)�
stacklevel)�warnings�warn�DeprecationWarning)�setterr	�msg�r�$/usr/lib64/python3.6/http/cookies.py�_warn_deprecated_setter�src@seZdZdS)rN)�__name__�
__module__�__qualname__rrrrr�sz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}d||�qS)z\%03or)�.0�nrrr�
<dictcomp>�sr��"z\"�\z\\z[%s]+cCs*|dkst|�r|Sd|jt�dSdS)z�Quote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    Nr)�
_is_legal_key�	translate�_Translator)�strrrr�_quote�srz\\[0-3][0-7][0-7]z[\\].cCsT|dkst|�dkr|S|ddks0|ddkr4|S|dd�}d}t|�}g}x�d|kod|kn�rJtj||�}tj||�}|r�|r�|j||d��Pd	}}|r�|jd�}|r�|jd�}|o�|s�||k�r
|j|||��|j||d�|d}qR|j|||��|jtt||d|d�d���|d}qRWt|�S)
N�rr������r#r#)	�len�
_OctalPatt�search�
_QuotePatt�append�start�chr�int�	_nulljoin)r�ir�resZo_matchZq_match�j�krrr�_unquote�s6


$r1ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r3r2)ZfutureZweekdaynameZ	monthnamer2r3ZnowZyearZmonthZdayZhhZmmZssZwd�y�zrrr�_getdate�s
r6c	@seZdZdZdddddddd	d
�ZddhZd
d�Zedd��Zej	dd��Zedd��Z
e
j	dd��Z
edd��Zej	dd��Zdd�Zd4dd�Z
dd�ZejZdd �Zd!d"�Zd#d$�Zefd%d&�Zd'd(�Zd)d*�Zd5d,d-�ZeZd.d/�Zd6d0d1�Zd7d2d3�ZdS)8�Morsela�A class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.  This is most useful when Python
    objects are pickled for network transit.
    �expiresZPath�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersion)r8�path�commentZdomainzmax-age�secure�httponly�versionr<r=cCs4d|_|_|_x|jD]}tj||d�qWdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyrrr�__init__&szMorsel.__init__cCs|jS)N)r?)rErrrrF.sz
Morsel.keycCstd�||_dS)NrF)rr?)rErFrrrrF2scCs|jS)N)r@)rErrr�value7szMorsel.valuecCstd�||_dS)NrH)rr@)rErHrrrrH;scCs|jS)N)rA)rErrr�coded_value@szMorsel.coded_valuecCstd�||_dS)NrI)rrA)rErIrrrrIDscCs2|j�}||jkr td|f��tj|||�dS)NzInvalid attribute %r)�lowerrBrrCrD)rE�K�VrrrrDIs
zMorsel.__setitem__NcCs.|j�}||jkr td|f��tj|||�S)NzInvalid attribute %r)rJrBrrC�
setdefault)rErF�valrrrrMOs
zMorsel.setdefaultcCs>t|t�stStj||�o<|j|jko<|j|jko<|j|jkS)N)�
isinstancer7�NotImplementedrC�__eq__r@r?rA)rE�morselrrrrQUs
z
Morsel.__eq__cCs$t�}tj||�|jj|j�|S)N)r7rC�update�__dict__)rErRrrr�copy_szMorsel.copycCsVi}x@t|�j�D]0\}}|j�}||jkr:td|f��|||<qWtj||�dS)NzInvalid attribute %r)rC�itemsrJrBrrS)rE�values�datarFrNrrrrSes
z
Morsel.updatecCs|j�|jkS)N)rJrB)rErKrrr�
isReservedKeynszMorsel.isReservedKeycCsh|tkr ddl}|jdtdd�|j�|jkr<td|f��t|�sRtd|f��||_||_	||_
dS)NrzSLegalChars parameter is deprecated, ignored and will be removed in future versions.r)rz Attempt to set a reserved key %rzIllegal key %r)�_LegalCharsr	r
rrJrBrrr?r@rA)rErFrNZ	coded_valZ
LegalCharsr	rrr�setqsz
Morsel.setcCs|j|j|jd�S)N)rFrHrI)r?r@rA)rErrr�__getstate__�szMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrFrHrI)r?r@rA)rE�staterrr�__setstate__�s

zMorsel.__setstate__�Set-Cookie:cCsd||j|�fS)Nz%s %s)�OutputString)rE�attrs�headerrrr�output�sz
Morsel.outputcCsd|jj|j�fS)Nz<%s: %s>)�	__class__rr`)rErrr�__repr__�szMorsel.__repr__cCsd|j|�jdd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rz\")r`�replace)rErarrr�	js_output�szMorsel.js_outputcCs(g}|j}|d|j|jf�|dkr,|j}t|j��}x�|D]�\}}|dkrPq>||krZq>|dkr�t|t�r�|d|j|t|�f�q>|dkr�t|t�r�|d|j||f�q>|dkr�t|t	�r�|d|j|t
|�f�q>||jk�r|�r|t	|j|��q>|d|j||f�q>Wt|�S)Nz%s=%srr8zmax-agez%s=%dr;)
r(rFrIrB�sortedrVrOr+r6rr�_flags�_semispacejoin)rEra�resultr(rVrFrHrrrr`�s,zMorsel.OutputString)N)Nr_)N)N)rrr�__doc__rBrirG�propertyrFrrHrIrDrMrQ�object�__ne__rUrSrYrZr[r\r^rc�__str__rergr`rrrrr7s@
	


r7z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@sneZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zddd�Z	e	Z
dd�Zddd�Zdd�Z
efdd�ZdS)rz'A container class for a set of Morsels.cCs||fS)a
real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        r)rErNrrr�value_decode�szBaseCookie.value_decodecCst|�}||fS)z�real_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        )r)rErN�strvalrrr�value_encode�szBaseCookie.value_encodeNcCs|r|j|�dS)N)�load)rE�inputrrrrG�szBaseCookie.__init__cCs.|j|t��}|j|||�tj|||�dS)z+Private method for setting a cookie's valueN)�getr7r[rCrD)rErFZ
real_valuerI�MrrrZ__set�szBaseCookie.__setcCs:t|t�rtj|||�n|j|�\}}|j|||�dS)zDictionary style assignment.N)rOr7rCrDrs�_BaseCookie__set)rErFrH�rval�cvalrrrrDs
zBaseCookie.__setitem__�Set-Cookie:�
cCs>g}t|j��}x"|D]\}}|j|j||��qW|j|�S)z"Return a string suitable for HTTP.)rhrVr(rc�join)rErarb�seprkrVrFrHrrrrc
s
zBaseCookie.outputcCsNg}t|j��}x(|D] \}}|jd|t|j�f�qWd|jjt|�fS)Nz%s=%sz<%s: %s>)rhrVr(�reprrHrdr�
_spacejoin)rE�lrVrFrHrrrres
zBaseCookie.__repr__cCs:g}t|j��}x |D]\}}|j|j|��qWt|�S)z(Return a string suitable for JavaScript.)rhrVr(rgr,)rErarkrVrFrHrrrrgs
zBaseCookie.js_outputcCs8t|t�r|j|�nx|j�D]\}}|||<q WdS)z�Load cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        N)rOr�_BaseCookie__parse_stringrV)rEZrawdatarFrHrrrrt&s

zBaseCookie.loadcCspd}t|�}g}d}d}d}�xd|ko2|kn�r|j||�}	|	sLP|	jd�|	jd�}
}|	jd�}|
ddkr�|s~q |j||
dd�|f�q |
j�tjkr�|s�dS|dkr�|
j�tjkr�|j||
df�q�dSn|j||
t	|�f�q |dk	�r|j||
|j
|�f�d}q dSq Wd}xF|D]>\}
}
}|
|k�rH|||
<n|\}}|j|
||�||
}�q*WdS)	NrFr rrFrN�$T)r$�match�group�endr(rJr7rBrir1rqrx)rErZpattr-rZparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�rFrHrw�tpryrzrrrZ__parse_string4sF



zBaseCookie.__parse_string)N)Nr{r|)N)rrrrlrqrsrGrxrDrcrprergrt�_CookiePatternr�rrrrr�s		
	

c@s eZdZdZdd�Zdd�ZdS)rz�
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    cCst|�|fS)N)r1)rErNrrrrqxszSimpleCookie.value_decodecCst|�}|t|�fS)N)rr)rErNrrrrrrs{szSimpleCookie.value_encodeN)rrrrlrqrsrrrrrqs))rl�re�string�__all__r}r,rjr�r�	ExceptionrZ
ascii_lettersZdigitsrZZ_UnescapedCharsr[�range�map�ordrrS�compile�escape�	fullmatchrrr%r'r1Z_weekdaynameZ
_monthnamer6rCr7Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrrrrr�<module>sF
	

2J
PKg�\���0�0�client.cpython-36.opt-1.pycnu�[���3

���i*��@srdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZdddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZe�jejj�dd�ejjj�D�ZdZdZd Zejd!�jZejd"�jZ ejd#�Z!ejd$�Z"d%d&d'hZ#dCd)d*�Z$Gd+d,�d,ej%j&�Z'd-d.�Z(e'fd/d0�Z)Gd1d�dej*�Z+Gd2d�d�Z,yddl-Z-Wne.k
�rlYnXGd3d4�d4e,�Z/ej0d4�Gd5d�de1�Z2Gd6d�de2�Z3Gd7d�de2�Z4Gd8d�de2�Z5Gd9d	�d	e2�Z6Gd:d
�d
e2�Z7Gd;d�de2�Z8Gd<d
�d
e2�Z9Gd=d�de9�Z:Gd>d�de9�Z;Gd?d�de9�Z<Gd@d�de2�Z=GdAd�de2�Z>GdBd�de?e=�Z@e2ZAdS)Da�
HTTP/1.1 client library

<intro stuff goes here>
<other stuff, too>

HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:

    (null)
      |
      | HTTPConnection()
      v
    Idle
      |
      | putrequest()
      v
    Request-started
      |
      | ( putheader() )*  endheaders()
      v
    Request-sent
      |\_____________________________
      |                              | getresponse() raises
      | response = getresponse()     | ConnectionError
      v                              v
    Unread-response                Idle
    [Response-headers-read]
      |\____________________
      |                     |
      | response.read()     | putrequest()
      v                     v
    Idle                  Req-started-unread-response
                     ______/|
                   /        |
   response.read() |        | ( putheader() )*  endheaders()
                   v        v
       Request-started    Req-sent-unread-response
                            |
                            | response.read()
                            v
                          Request-sent

This diagram presents the following rules:
  -- a second request may not be started until {response-headers-read}
  -- a response [object] cannot be retrieved until {request-sent}
  -- there is no differentiation between an unread response body and a
     partially read response body

Note: this enforcement is applied by the HTTPConnection class. The
      HTTPResponse class does not enforce this state machine, which
      implies sophisticated clients may accelerate the request/response
      pipeline. Caution should be taken, though: accelerating the states
      beyond the above pattern may imply knowledge of the server's
      connection-close behavior for certain requests. For example, it
      is impossible to tell whether the server will close the connection
      UNTIL the response headers have been read; this means that further
      requests cannot be placed into the pipeline until it is known that
      the server will NOT be closing the connection.

Logical State                  __state            __response
-------------                  -------            ----------
Idle                           _CS_IDLE           None
Request-started                _CS_REQ_STARTED    None
Request-sent                   _CS_REQ_SENT       None
Unread-response                _CS_IDLE           <response_class>
Req-started-unread-response    _CS_REQ_STARTED    <response_class>
Req-sent-unread-response       _CS_REQ_SENT       <response_class>
�N)�urlsplit�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}|j|�qS�)�phrase)�.0�vrr�#/usr/lib64/python3.6/http/client.py�
<dictcomp>ksrii�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUT�datacCsfy
|jd�Stk
r`}z:t|j|j|j|jd|j�||j|j�|f�d�WYdd}~XnXdS)z<Call data.encode("latin-1") but show a better error message.zlatin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.N)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s
r'c@seZdZdd�ZdS)�HTTPMessagecCsn|j�d}t|�}g}d}xL|j�D]@}|d|�j�|krDd}n|dd�j�sXd}|r&|j|�q&W|S)a�Find all header lines matching a given header name.

        Look through the list of headers and find all lines matching a given
        header name (and their continuation lines).  A list of the lines is
        returned, without interpretation.  If the header does not occur, an
        empty list is returned.  If the header occurs multiple times, all
        occurrences are returned.  Case is not important in the header name.

        �:rN�)�lower�len�keys�isspace�append)�selfr%�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r3rrrrr(�sr(cCs\g}xR|jtd�}t|�tkr(td��|j|�t|�tkrJtdt��|dkrPqW|S)z�Reads potential header lines into a list from a file pointer.

    Length of line is limited by _MAXLINE, and number of
    headers is limited by _MAXHEADERS.
    r*zheader linezgot more than %d headers�
�
�)r7r8r9)�readline�_MAXLINEr,rr/�_MAXHEADERSr)�fp�headersr2rrr�
_read_headers�s
r?cCs,t|�}dj|�jd�}tjj|d�j|�S)aGParses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.

    r9z
iso-8859-1)�_class)r?�join�decode�email�parserZParserZparsestr)r=r@r>Zhstringrrr�
parse_headers�s
rEcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdCd(d)�ZdEd*d+�ZdG�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdHd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)IrrNcCsR|jd�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)�makefiler=�
debuglevel�_methodr>�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r0�sockrH�method�urlrrr�__init__�szHTTPResponse.__init__cCst|jjtd�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��y|j
dd�\}}}WnFtk
r�y|j
dd�\}}d}Wntk
r�d}YnXYnX|jd	�s�|j
�t|��y$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr*z
iso-8859-1zstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr=r:r;r,rrH�print�reprr�split�
ValueError�
startswith�_close_connr�int)r0r2rLrMrNrrr�_read_statuss2

zHTTPResponse._read_statuscCs�|jdk	rdSx<|j�\}}}|tkr(Pt|j�}|jdkrFtd|�~qW||_|_|j	�|_
|dkrrd|_n|jd�r�d|_nt
|��t|j�|_|_|jdkr�x&|jD]}td|d	|jj|��q�W|jjd
�}|r�|j�dkr�d|_d|_nd
|_|j�|_d|_|jjd�}|jjd
�}|�rx|j�rxyt|�|_Wntk
�rbd|_YnX|jdk�r~d|_nd|_|tk�s�|tk�s�d|k�o�dkn�s�|jdk�r�d|_|j�r�|j�r�|jdk�r�d|_dS)Nrzheaders:�HTTP/1.0�HTTP/0.9�
zHTTP/1.�zheader:r)ztransfer-encodingrOTFzcontent-lengthr���HEAD)rbrc)r>raZCONTINUEr?r=rHrZ�coderM�striprNrLr^rrErJ�getr+rOrP�_check_closerRrQr`r]Z
NO_CONTENTZNOT_MODIFIEDrI)r0rLrMrNZskipped_headers�hdrZtr_encrQrrr�begin9s\









zHTTPResponse.begincCs�|jjd�}|jdkr:|jjd�}|r6d|j�kr6dSdS|jjd�rJdS|r^d|j�kr^dS|jjd�}|r~d|j�kr~dSdS)NZ
connectionre�closeTFz
keep-alivezproxy-connection)r>rjrLr+)r0ZconnZpconnrrrrk�s
zHTTPResponse._check_closecCs|j}d|_|j�dS)N)r=rn)r0r=rrrr_�szHTTPResponse._close_connc
s$zt�j�Wd|jr|j�XdS)N)�superrnr=r_)r0)�	__class__rrrn�szHTTPResponse.closecst�j�|jr|jj�dS)N)ro�flushr=)r0)rprrrq�s
zHTTPResponse.flushcCsdS)zAlways returns TrueTr)r0rrr�readable�szHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)r=)r0rrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|j�dS|dk	rRt|�}|j|�}t|�d|�j�S|jr`|j�S|j	dkrv|jj
�}n6y|j|j	�}Wntk
r�|j��YnXd|_	|j�|SdS)Nr9rgr)
r=rIr_�	bytearray�readinto�
memoryview�tobytesrO�_readall_chunkedrQ�read�
_safe_readr
)r0�amt�br1�srrrry�s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|j�dS|jr4|j|�S|jdk	r^t|�|jkr^t|�d|j�}|jj|�}|r~|r~|j�n&|jdk	r�|j|8_|js�|j�|S)z^Read up to len(b) bytes into bytearray b and return the number
        of bytes read.
        Nrrg)	r=rIr_rO�_readinto_chunkedrQr,rvru)r0r|r1rrrru�s$






zHTTPResponse.readintocCsp|jjtd�}t|�tkr$td��|jd�}|dkrB|d|�}y
t|d�Stk
rj|j��YnXdS)Nr*z
chunk size�;r�)	r=r:r;r,r�findr`r]r_)r0r2�irrr�_read_next_chunk_size
s

z"HTTPResponse._read_next_chunk_sizecCs>x8|jjtd�}t|�tkr&td��|s,P|dkrPqWdS)Nr*ztrailer line�
r8r9)r�r8r9)r=r:r;r,r)r0r2rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|jd�y|j�}Wntk
rDtd��YnX|dkrb|j�|j�d}||_|S)NrWr9r)rPrzr�r]r
r�r_)r0rPrrr�_get_chunk_left(s
zHTTPResponse._get_chunk_leftcCsdg}y8x,|j�}|dkrP|j|j|��d|_qWdj|�Stk
r^tdj|���YnXdS)Nrr9)r�r/rzrPrAr
)r0�valuerPrrrrx@s

zHTTPResponse._readall_chunkedcCs�d}t|�}yvxp|j�}|dkr$|St|�|krL|j|�}|||_||S|d|�}|j|�}||d�}||7}d|_qWWn(tk
r�tt|d|����YnXdS)Nr)rvr�r,�_safe_readintorPr
�bytes)r0r|�total_bytes�mvbrPr1�temp_mvbrrrr~Ns$


zHTTPResponse._readinto_chunkedcCsXg}xH|dkrL|jjt|t��}|s4tdj|�|��|j|�|t|�8}qWdj|�S)aVRead the number of bytes requested, compensating for partial reads.

        Normally, we have a blocking socket, but a read() can be interrupted
        by a signal (resulting in a partial read).

        Note that we cannot distinguish between EOF and an interrupt when zero
        bytes have been read. IncompleteRead() will be raised in this
        situation.

        This function should be used when <amt> bytes "should" be present for
        reading. If the bytes are truly not available (due to EOF), then the
        IncompleteRead exception can be used to detect the problem.
        rr9)r=ry�min�	MAXAMOUNTr
rAr/r,)r0r{r}�chunkrrrrzfs

zHTTPResponse._safe_readcCs�d}t|�}xt|t|�kr�tt|�kr@|dt�}|jj|�}n|jj|�}|sjtt|d|��t|���||d�}||7}qW|S)z2Same as _safe_read, but for reading into a buffer.rN)rvr,r�r=rur
r�)r0r|r�r�r�r1rrrr�}szHTTPResponse._safe_readintor*cCs�|jdks|jdkrdS|jr(|j|�S|jdk	rJ|dksD||jkrJ|j}y|jj|�}Wn*tk
r�|dkrt�|jjd�}YnX|r�|r�|j�n|jdk	r�|jt|�8_|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        Nrgr9rr�ii@)	r=rIrO�_read1_chunkedrQ�read1r]r_r,)r0r1�resultrrrr��s"



zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|j|�S|jj|�S)Nrgr9)r=rIrO�
_peek_chunked�peek)r0r1rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t�j|�S|jdk	rL|dksF||jkrL|j}|jj|�}|rl|rl|j�n|jdk	r�|jt|�8_|S)Nrgr9r)r=rIrOror:rQr_r,)r0�limitr�)rprrr:�s


zHTTPResponse.readlinecCsf|j�}|dks|dkrdSd|ko.|kns8|}|jj|�}|jt|�8_|sbtd��|S)Nrr9)r�r=r�rPr,r
)r0r1rPryrrrr��szHTTPResponse._read1_chunkedcCsBy|j�}Wntk
r dSX|dkr.dS|jj|�d|�S)Nr9)r�r
r=r�)r0r1rPrrrr��szHTTPResponse._peek_chunkedcCs
|jj�S)N)r=�fileno)r0rrrr��szHTTPResponse.filenocCsH|jdkrt��|jj|�p|}t|t�s6t|d�r:|Sdj|�SdS)axReturns the value of the header matching *name*.

        If there are multiple matching headers, the values are
        combined into a single string separated by commas and spaces.

        If no matching header is found, returns *default* or None if
        the *default* is not specified.

        If the headers are unknown, raises http.client.ResponseNotReady.

        N�__iter__z, )r>rZget_all�
isinstancerY�hasattrrA)r0r%�defaultr>rrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|jj��S)z&Return list of (header, value) tuples.N)r>r�list�items)r0rrr�
getheaders�s
zHTTPResponse.getheaderscCs|S)Nr)r0rrrr��szHTTPResponse.__iter__cCs|jS)ajReturns an instance of the class mimetools.Message containing
        meta-information associated with the URL.

        When the method is HTTP, these headers are those returned by
        the server at the head of the retrieved HTML page (including
        Content-Length and Content-Type).

        When the method is FTP, a Content-Length header will be
        present if (as is now usual) the server passed back a file
        length in response to the FTP retrieval request. A
        Content-Type header will be present if the MIME type can be
        guessed.

        When the method is local-file, returned headers will include
        a Date representing the file's last-modified time, a
        Content-Length giving file size, and a Content-Type
        containing a guess at the file's type. See also the
        description of the mimetools module.

        )r>)r0rrr�info�szHTTPResponse.infocCs|jS)aZReturn the real URL of the page.

        In some cases, the HTTP server redirects a client to another
        URL. The urlopen() function handles this transparently, but in
        some cases the caller needs to know which URL the client was
        redirected to. The geturl() method can be used to get at this
        redirected URL.

        )rU)r0rrr�geturls
zHTTPResponse.geturlcCs|jS)zuReturn the HTTP status code that was sent with the response,
        or None if the URL is not an HTTP URL.

        )rM)r0rrr�getcodeszHTTPResponse.getcode)rNN)N���)r�r�)r�r�)r�)N)"r4r5r6rVrarmrkr_rnrqrrrsryrur�r�r�rxr~rzr�r�r�r:r�r�r�r�r�r�r�r�r��
__classcell__rr)rprr�s<	
!K

 "

	

c@s�eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	fd
d�Zd0dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd1dd �Zd2d!d"�Zd#d$�Zd%d&�Zd3dd'�d(d)�Zd	ifdd'�d*d+�Zd,d-�Z d.d/�Z!d	S)4rrezHTTP/1.1r*rcCst|tj�S)zFTest whether a file-like object is a text or a binary stream.
        )r��io�
TextIOBase)�streamrrr�
_is_textIO0szHTTPConnection._is_textIOcCsd|dkr|j�tkrdSdSt|d�r*dSyt|�}|jStk
rLYnXt|t�r`t|�SdS)aGet the content-length based on the body.

        If the body is None, we set Content-Length: 0 for methods that expect
        a body (RFC 7230, Section 3.3.2). We also set the Content-Length for
        any method if the body is a str or bytes-like object and not a file.
        Nrry)	�upper�_METHODS_EXPECTING_BODYr�rv�nbytes�	TypeErrorr�rYr,)�bodyrTZmvrrr�_get_content_length6s

z"HTTPConnection._get_content_lengthNcCs\||_||_d|_g|_d|_t|_d|_d|_d|_	i|_
|j||�\|_|_
tj|_dS)N)�timeout�source_addressrS�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterI�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�socketZcreate_connection�_create_connection)r0r�r�r�r�rrrrVVszHTTPConnection.__init__cCs<|jrtd��|j||�\|_|_|r.||_n
|jj�dS)aDSet up host and port for HTTP CONNECT tunnelling.

        In a connection that uses HTTP CONNECT tunneling, the host passed to the
        constructor is used as a proxy server that relays all communication to
        the endpoint passed to `set_tunnel`. This done by sending an HTTP
        CONNECT request to the proxy server when the connection is established.

        This method must be called before the HTML connection has been
        established.

        The headers argument should be a mapping of extra HTTP headers to send
        with the CONNECT request.
        z.Can't set up tunnel for established connectionN)rS�RuntimeErrorr�r�r�r��clear)r0r�r�r>rrr�
set_tunneliszHTTPConnection.set_tunnelcCs�|dkr�|jd�}|jd�}||kr�yt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd	�}||fS)
Nr)�]r*rXznonnumeric port: '%s'r�[r�r�)�rfindr`r]�default_portr)r0r�r�r��jrrrr��s

zHTTPConnection._get_hostportcCs
||_dS)N)rH)r0�levelrrr�set_debuglevel�szHTTPConnection.set_debuglevelcCsd|j|jf}|jd�}|j|�x6|jj�D](\}}d||f}|jd�}|j|�q0W|jd�|j|j|jd�}|j	�\}}	}
|	t
jjkr�|j
�td|	|
j�f��xP|jjtd�}t|�tkr�td	��|s�P|dkr�P|jdkr�td
|j��q�WdS)NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
zlatin-1�
)rTzTunnel connection failed: %d %sr*zheader liner8r9rzheader:)r�r8r9)r�r�r�sendr�r��response_classrSrIra�http�
HTTPStatusZOKrn�OSErrorrir=r:r;r,rrHrZrB)r0Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserLrh�messager2rrr�_tunnel�s2





zHTTPConnection._tunnelcCsB|j|j|jf|j|j�|_|jjtjtj	d�|j
r>|j�dS)z3Connect to the host and port specified in __init__.r*N)r�r�r�r�r�rSZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�)r0rrr�connect�s
zHTTPConnection.connectcCsBt|_z|j}|r d|_|j�Wd|j}|r<d|_|j�XdS)z(Close the connection to the HTTP server.N)r�r�rSrnr�)r0rSr�rrrrn�szHTTPConnection.closecCs|jdkr |jr|j�nt��|jdkr8tdt|��d}t|d�r�|jdkrXtd�|j|�}|rx|jdkrxtd�x.|j	|�}|s�P|r�|j
d�}|jj|�qzWdSy|jj|�WnNtk
�r
t
|tj�r�x*|D]}|jj|�q�Wntd	t|���YnXdS)
z�Send `data' to the server.
        ``data`` can be a string object, a bytes object, an array object, a
        file-like object that supports a .read() method, or an iterable object.
        Nrzsend:i ryzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1z9data should be a bytes-like object or an iterable, got %r)rS�	auto_openr�rrHrZr[r�r�ryrZsendallr�r��collections�Iterable�type)r0r�	blocksizer�	datablock�drrrr��s:








zHTTPConnection.sendcCs|jj|�dS)zuAdd a line of output to the current request buffer.

        Assumes that the line does *not* end with \r\n.
        N)r�r/)r0r}rrr�_output�szHTTPConnection._outputccsdd}|jdkrtd�|j|�}|r6|jdkr6td�x(|j|�}|sHP|rV|jd�}|Vq8WdS)Ni rzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1)rHrZr�ryr)r0rrr�rr�rrr�_read_readable�s



zHTTPConnection._read_readableFcCs$|jjd
�dj|j�}|jdd�=|j|�|dk	�r t|d�rN|j|�}nZyt|�WnFtk
r�yt|�}Wn$tk
r�tdt	|���YnXYnX|f}xZ|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d	�d
�jd�|d}|j|�q�W|�r |jdk�r |jd�dS)z�Send the currently buffered request and clear the buffer.

        Appends an extra \r\n to the buffer.
        A message_body may be specified, to be appended to the request.
        r9s
NryzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredre�Xz
r�s0

)r9r9)r��extendrAr�r�r�rvr��iterr�rHrZ�	_http_vsnr,r)r0�message_body�encode_chunkedrJZchunksr�rrr�_send_outputs4




zHTTPConnection._send_outputc

Cs�|jr|jj�rd|_|jtkr(t|_n
t|j��|j|�||_|sJd}tj	|�}|rrt
d|�d|j��d���d|||jf}|j
|jd��|jdk�r�|�s�d	}|jd
�r�t|�\}}}}}|�ry|jd�}	Wntk
r�|jd�}	YnX|jd|	�n�|j�r|j}
|j}n|j}
|j}y|
jd�}Wn tk
�rV|
jd�}YnX|
jd
�dk�rtd|d}||jk�r�|jd|�n|jd�}|jdd||f�|�s�|jdd�ndS)a`Send a request to the server.

        `method' specifies an HTTP request method, e.g. 'GET'.
        `url' specifies the object being requested, e.g. '/index.html'.
        `skip_host' if True does not add automatically a 'Host:' header
        `skip_accept_encoding' if True does not add automatically an
           'Accept-Encoding:' header
        N�/z&URL can't contain control characters. z (found at least �)z%s %s %sr�rerXr�ZidnaZHostr)r�[�]z%s:%szAccept-EncodingZidentity)r�rsr�r��_CS_REQ_STARTEDr
�_validate_methodrI�!_contains_disallowed_url_pchar_re�searchr�group�
_http_vsn_strr�rr�r^rr�	putheaderr�r�r�r�r�r�rB)
r0rTrU�	skip_host�skip_accept_encoding�match�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequestAsV






zHTTPConnection.putrequestcCs,tj|�}|r(td|�d|j��d���dS)z&Validate a method name for putrequest.z)method can't contain control characters. z (found at least r�N)�$_contains_disallowed_method_pchar_rer�r]r�)r0rTr�rrrr��s
zHTTPConnection._validate_methodcGs�|jtkrt��t|d�r$|jd�}t|�s:td|f��t|�}xht|�D]\\}}t|d�rn|jd�||<nt	|t
�r�t|�jd�||<t||�rLtd||f��qLWdj
|�}|d|}|j|�dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        rr�zInvalid header name %rzlatin-1zInvalid header value %rs
	s: N)r�r�rr�r�_is_legal_header_namer]r��	enumerater�r`rY�_is_illegal_header_valuerAr�)r0r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader)r�cCs*|jtkrt|_nt��|j||d�dS)z�Indicate that the last header line has been sent to the server.

        This method sends the request to the server.  The optional message_body
        argument can be used to pass a message body associated with the
        request.
        )r�N)r�r��_CS_REQ_SENTrr�)r0r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|j|||||�dS)z&Send a complete request to the server.N)�
_send_request)r0rTrUr�r>r�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|j||�}|dkr�|dk	r�|jdkr�td|�d
}|jdd�q�|jdt|��nd
}x |j�D]\}	}
|j|	|
�q�Wt|t�r�t	|d�}|j
||d�dS)Ncss|]}|j�VqdS)N)r+)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r*r�zaccept-encodingr�zcontent-lengthztransfer-encodingFrzUnable to determine size of %rTzTransfer-EncodingrOzContent-Lengthr�)r�)�	frozensetr�r�rHrZr�rYr�r�r'r�)r0rTrUr�r>r�Zheader_namesZskipsZcontent_lengthrlr�rrrr��s0	


zHTTPConnection._send_requestcCs�|jr|jj�rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}yLy|j	�Wnt
k
r�|j��YnXt|_|j
r�|j�n||_|S|j��YnXdS)a)Get the response from the server.

        If the HTTPConnection is in the correct state, returns an
        instance of HTTPResponse or of whatever object is returned by
        the response_class variable.

        If a request has not been sent or if a previous response has
        not be handled, ResponseNotReady is raised.  If the HTTP
        response indicates that the connection should be closed, then
        it will be closed before the response is returned.  When the
        connection is closed, the underlying socket is closed.
        Nr)rT)r�rsr�r�rrHr�rSrIrm�ConnectionErrorrnr�rR)r0r�rrr�getresponse)s,


zHTTPConnection.getresponse)NN)NF)FF)N)"r4r5r6r�r�rr��	HTTP_PORTr�r�rH�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrVr�r�r�r�r�rnr�r�r�r�r�r�r�r�r�r�r�rrrrr&s< 
	'
6
	
.csFeZdZdZeZdddejdfddd��fdd�Z�fdd�Z	�Z
S)�HTTPSConnectionz(This class allows communication via SSL.N)�context�check_hostnamecs�tt|�j||||�|dk	s.|dk	s.|dk	rDddl}	|	jdtd�||_||_|dkrptj	�}|j
dk	rpd|_
|jtjk}
|dkr�|j
}|r�|
r�td��|s�|r�|j||�|j
dk	r�d|_
||_||_dS)NrzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rWTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rorrV�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr]Zload_cert_chain�_context�_check_hostname)r0r�r�rr	r�r�rrrZwill_verify)rprrrVts0


zHTTPSConnection.__init__cs�t�j�|jr|j}n|j}|jj|j|d�|_|jjr�|jr�yt	j
|jj�|�Wn.tk
r�|jj
tj�|jj��YnXdS)z(Connect to a host on a given (SSL) port.)�server_hostnameN)ror�r�r�rZwrap_socketrSrrr
Zmatch_hostnameZgetpeercert�	ExceptionZshutdownr�Z	SHUT_RDWRrn)r0r
)rprrr��s



zHTTPSConnection.connect)r4r5r6�__doc__�
HTTPS_PORTr�r�rrVr�r�rr)rprrmsrc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dS)N)�argsrL)r0rLrrrrV�szUnknownProtocol.__init__N)r4r5r6rVrrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r	N)r4r5r6rrrrr	�sc@s&eZdZddd�Zdd�Zdd�ZdS)	r
NcCs|f|_||_||_dS)N)r�partial�expected)r0rrrrrrV�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedrXz%s(%i bytes read%s))rrpr4r,r)r0�errr�__repr__�s

zIncompleteRead.__repr__cCst|�S)N)r[)r0rrr�__str__�szIncompleteRead.__str__)N)r4r5r6rVrrrrrrr
�s
c@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r
N)r4r5r6rrrrr
�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dS)N)r[rr2)r0r2rrrrV�szBadStatusLine.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcCstj|dt|f�dS)Nz&got more than %d bytes when reading %s)rrVr;)r0Z	line_typerrrrV�szLineTooLong.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcOs"tj|d�tj|f|�|�dS)NrX)rrV�ConnectionResetError)r0�pos�kwrrrrV�szRemoteDisconnected.__init__N)r4r5r6rVrrrrr�s)r)BrZemail.parserrCZ
email.messager�r��os�rer�r�Zurllib.parser�__all__r�rrKr�r�r��globals�updater��__members__r�rr�r;r<�compile�	fullmatchr�r�r�r�r�r�r'r�ZMessager(r?rE�BufferedIOBaserrr
�ImportErrorrr/rrrrrrr	r
rr
rrrrrrrrrrr�<module>Es�



9F=
PKg�\l
��~~server.cpython-36.opt-1.pycnu�[���3

���i���@s�dZdZddddgZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZd	Zd
ZGdd�dej�ZGdd�dej�ZGd
d�de�Zdd�Zdadd�Z dd�Z!Gdd�de�Z"eedddfdd�Z#e$dk�r�ej%�Z&e&j'dddd�e&j'dd dd!d"d#�e&j'd$d%de(d&d'd(�e&j)�Z*e*j+�r~e"Z,neZ,e#e,e*j-e*j.d)�dS)*a@HTTP server classes.

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections,
as of version 0.3.

Notes on CGIHTTPRequestHandler
------------------------------

This class implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
subprocess.Popen() is used as a fallback, with slightly altered semantics.

In all cases, the implementation is intentionally naive -- all
requests are executed synchronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
z0.6�
HTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c@seZdZdZdd�ZdS)r�cCs4tjj|�|jdd�\}}tj|�|_||_dS)z.Override server_bind to store the server name.N�)�socketserver�	TCPServer�server_bind�server_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�#/usr/lib64/python3.6/http/server.pyr�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressrrrrrr�sc
@seZdZdZdejj�dZdeZ	e
ZeZ
dZdd�Zdd	�Zd
d�Zdd
�Zd@dd�ZdAdd�ZdBdd�Zdd�Zdd�Zdd�ZdCdd�Zdd�Zd d!�Zd"d#�ZdDd$d%�Zd&d'�Zd(d)d*d+d,d-d.gZdd/d0d1d2d3d4d5d6d7d8d9d:g
Z d;d<�Z!d=Z"e#j$j%Z&d>d?�e'j(j)�D�Z*dS)Era�HTTP request handler base class.

    The following explanation of HTTP serves to guide you through the
    code as well as to expose any misunderstandings I may have about
    HTTP (so you don't need to read the code to figure out I'm wrong
    :-).

    HTTP (HyperText Transfer Protocol) is an extensible protocol on
    top of a reliable stream transport (e.g. TCP/IP).  The protocol
    recognizes three parts to a request:

    1. One line identifying the request type and path
    2. An optional set of RFC-822-style headers
    3. An optional data part

    The headers and data are separated by a blank line.

    The first line of the request has the form

    <command> <path> <version>

    where <command> is a (case-sensitive) keyword such as GET or POST,
    <path> is a string containing path information for the request,
    and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
    <path> is encoded using the URL encoding scheme (using %xx to signify
    the ASCII character with hex code xx).

    The specification specifies that lines are separated by CRLF but
    for compatibility with the widest range of clients recommends
    servers also handle LF.  Similarly, whitespace in the request line
    is treated sensibly (allowing multiple spaces between components
    and allowing trailing whitespace).

    Similarly, for output, lines ought to be separated by CRLF pairs
    but most clients grok LF characters just fine.

    If the first line of the request has the form

    <command> <path>

    (i.e. <version> is left out) then this is assumed to be an HTTP
    0.9 request; this form has no optional headers and data part and
    the reply consists of just the data.

    The reply form of the HTTP 1.x protocol again has three parts:

    1. One line giving the response code
    2. An optional set of RFC-822-style headers
    3. The data

    Again, the headers and data are separated by a blank line.

    The response code line has the form

    <version> <responsecode> <responsestring>

    where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
    <responsecode> is a 3-digit response code indicating success or
    failure of the request, and <responsestring> is an optional
    human-readable string explaining what the response code means.

    This server parses the request and the headers, and then calls a
    function specific to the request type (<command>).  Specifically,
    a request SPAM will be handled by a method do_SPAM().  If no
    such method exists the server sends an error response to the
    client.  If it exists, it is called with no arguments:

    do_SPAM()

    Note that the request name is case sensitive (i.e. SPAM and spam
    are different requests).

    The various request details are stored in instance variables:

    - client_address is the client IP address in the form (host,
    port);

    - command, path and version are the broken-down request line;

    - headers is an instance of email.message.Message (or a derived
    class) containing the header information;

    - rfile is a file object open for reading positioned at the
    start of the optional input data part;

    - wfile is a file object open for writing.

    IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

    The first thing to be written must be the response line.  Then
    follow 0 or more header lines, then a blank line, and then the
    actual data (if any).  The meaning of the header lines depends on
    the command executed by the server; in most cases, when data is
    returned, there should be at least one header line of the form

    Content-type: <type>/<subtype>

    where <type> and <subtype> should be registered MIME types,
    e.g. "text/html" or "text/plain".

    zPython/rz	BaseHTTP/zHTTP/0.9cCs�d|_|j|_}d|_t|jd�}|jd�}||_|j�}t	|�dk�r|\}}}yZ|dd�dkrjt
�|jdd	�d	}|jd
�}t	|�dkr�t
�t|d�t|d	�f}Wn*t
tfk
r�|j
tjd
|�dSX|dkr�|jdkr�d|_|dk�rr|j
tjd|�dSn^t	|�dk�rR|\}}d|_|dk�rr|j
tjd|�dSn |�s\dS|j
tjd|�dS||||_|_|_|jjd��r�d|jjd�|_ytjj|j|jd�|_Wnrtjjk
�r�}z|j
tjdt|��dSd}~Xn:tjjk
�r4}z|j
tjdt|��dSd}~XnX|jjdd�}	|	j�dk�rZd|_n |	j�dk�rz|jdk�rzd|_|jjdd�}
|
j�dk�r�|jdk�r�|jdk�r�|j ��s�dSdS) a'Parse a request (internal).

        The request should be stored in self.raw_requestline; the results
        are in self.command, self.path, self.request_version and
        self.headers.

        Return True for success, False for failure; on failure, an
        error is sent back.

        NTz
iso-8859-1z
��zHTTP/�/r�.rrzBad request version (%r)FzHTTP/1.1zInvalid HTTP version (%s)ZGETzBad HTTP/0.9 request type (%r)zBad request syntax (%r)z//)Z_classz
Line too longzToo many headers�
Connection��closez
keep-aliveZExpectz100-continue)rr)rr)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�
startswith�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr&�wordsrr.Zbase_version_numberZversion_number�errZconntypeZexpectrrr�
parse_requests�












z$BaseHTTPRequestHandler.parse_requestcCs|jtj�|j�dS)a7Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        T)�send_response_onlyrZCONTINUE�end_headers)rrrrr8nsz(BaseHTTPRequestHandler.handle_expect_100cCs�y�|jjd�|_t|j�dkr@d|_d|_d|_|jtj	�dS|jsPd|_
dS|j�s\dSd|j}t||�s�|jtj
d|j�dSt||�}|�|jj�Wn4tjk
r�}z|jd|�d|_
dSd}~XnXdS)	z�Handle a single HTTP request.

        You normally don't need to override this method; see the class
        __doc__ string for information on how to handle specific HTTP
        commands such as GET and POST.

        iirNTZdo_zUnsupported method (%r)zRequest timed out: %r)r3�readliner$r(r&r!rr,rZREQUEST_URI_TOO_LONGr"r<�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushr
Ztimeout�	log_error)rZmname�method�errr�handle_one_request�s4


z)BaseHTTPRequestHandler.handle_one_requestcCs&d|_|j�x|js |j�qWdS)z&Handle multiple requests if necessary.TN)r"rH)rrrr�handle�szBaseHTTPRequestHandler.handleNcCs
y|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|jd||�|j||�|jdd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d	�}|jd
d�}|jd|j
�|jd
tt|���|j�|jdko�|�r|jj|�dS)akSend and log an error reply.

        Arguments are
        * code:    an HTTP error code
                   3 digits
        * message: a simple optional 1 line reason phrase.
                   *( HTAB / SP / VCHAR / %x80-FF )
                   defaults to short entry matching the response code
        * explain: a detailed message defaults to the long entry
                   matching the response code.

        This sends an error response (so it must be called before any
        output has been generated), logs the error, and finally sends
        a piece of HTML explaining the error to the user.

        �???Nzcode %d, message %srr��F)�quote)�code�message�explainzUTF-8�replacezContent-TypezContent-LengthZHEAD)rJrJ)�	responses�KeyErrorrE�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENTZNOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer#r(r>rrC�write)rrMrNrOZshortmsgZlongmsgZbodyZcontentrrrr,�s4
z!BaseHTTPRequestHandler.send_errorcCs:|j|�|j||�|jd|j��|jd|j��dS)z�Add the response header to the headers buffer and log the
        response code.

        Also send two standard headers with the server software
        version and the current date.

        ZServerZDateN)�log_requestr=rT�version_string�date_time_string)rrMrNrrrrS�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|jjd|j||fjdd��dS)	zSend the response header only.zHTTP/0.9Nrr�_headers_bufferz
%s %d %s
zlatin-1�strict)r!rQr@r^�appendr-rX)rrMrNrrrr=�s


z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|jjd||fjdd��|j�dkrh|j�dkrVd|_n|j�d	krhd
|_dS)z)Send a MIME header to the headers buffer.zHTTP/0.9r^z%s: %s
zlatin-1r_Z
connectionrTz
keep-aliveFN)r!r@r^r`rXr7r")r�keyword�valuerrrrT�s

z"BaseHTTPRequestHandler.send_headercCs"|jdkr|jjd�|j�dS)z,Send the blank line ending the MIME headers.zHTTP/0.9s
N)r!r^r`�
flush_headers)rrrrr>s
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|jjdj|j��g|_dS)Nr^�)r@rCrZ�joinr^)rrrrrcs
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|jd|jt|�t|��dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)�
isinstancerrb�log_messager&r#)rrM�sizerrrr[s
z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS)z�Log an error.

        This is called when a request cannot be fulfilled.  By
        default it passes the message on to log_message().

        Arguments are the same as for log_message().

        XXX This should go to the separate error log.

        N)rh)r�format�argsrrrrE!sz BaseHTTPRequestHandler.log_errorcGs&tjjd|j�|j�||f�dS)a�Log an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        z%s - - [%s] %s
N)�sys�stderrrZ�address_string�log_date_time_string)rrjrkrrrrh/sz"BaseHTTPRequestHandler.log_messagecCs|jd|jS)z*Return the server software version string.� )�server_version�sys_version)rrrrr\Esz%BaseHTTPRequestHandler.version_stringcCs |dkrtj�}tjj|dd�S)z@Return the current date and time formatted for a message header.NT)Zusegmt)�time�emailZutilsZ
formatdate)rZ	timestamprrrr]Isz'BaseHTTPRequestHandler.date_time_stringc	CsBtj�}tj|�\	}}}}}}}}	}
d||j|||||f}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)rsZ	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrroOs
z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)zReturn the client address.r)�client_address)rrrrrn]sz%BaseHTTPRequestHandler.address_stringzHTTP/1.0cCsi|]}|j|jf|�qSr)�phraseZdescription)�.0�vrrr�
<dictcomp>lsz!BaseHTTPRequestHandler.<dictcomp>)NN)N)N)rfrf)N)+rrr�__doc__rlr9r'rr�__version__rq�DEFAULT_ERROR_MESSAGErU�DEFAULT_ERROR_CONTENT_TYPErYr r<r8rHrIr,rSr=rTr>rcr[rErhr\r]roZweekdaynamerurnr-r1r2ZHTTPMessager4r�__members__�valuesrQrrrrr�s>fg%
5



	c@s|eZdZdZdeZdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Ze
jsZe
j�e
jj�Zejddddd��dS)raWSimple HTTP request handler with GET and HEAD commands.

    This serves files from the current directory and any of its
    subdirectories.  The MIME type for files is determined by
    calling the .guess_type() method.

    The GET and HEAD requests are identical except that the HEAD
    request omits the actual contents of the file.

    zSimpleHTTP/c
Cs.|j�}|r*z|j||j�Wd|j�XdS)zServe a GET request.N)�	send_head�copyfilerCr)r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|j�}|r|j�dS)zServe a HEAD request.N)r�r)rr�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADc	Csx|j|j�}d}tjj|�r�tjj|j�}|jjd�s�|jt	j
�|d|d|dd|d|df}tjj|�}|jd|�|j
�dSx6dD]$}tjj||�}tjj|�r�|}Pq�W|j|�S|j|�}yt|d�}Wn$tk
�r|jt	jd�dSXyZ|jt	j�|jd
|�tj|j��}|jdt|d��|jd|j|j��|j
�|S|j��YnXdS)a{Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.

        Nrrrrr�ZLocation�
index.html�	index.htm�rbzFile not foundzContent-typezContent-Length�z
Last-Modified)r�r�)�translate_pathr.�os�isdir�urllib�parseZurlsplit�endswithrSrZMOVED_PERMANENTLYZ
urlunsplitrTr>re�exists�list_directory�
guess_type�open�OSErrorr,�	NOT_FOUND�OK�fstat�filenor#r]�st_mtimer)	rr.r��partsZ	new_partsZnew_url�indexZctypeZfsrrrr��sF


z"SimpleHTTPRequestHandler.send_headc
Cs�ytj|�}Wn"tk
r0|jtjd�dSX|jdd�d�g}ytjj	|j
dd�}Wn tk
r|tjj	|�}YnXtj
|dd	�}tj�}d
|}|jd�|jd�|jd
|�|jd|�|jd|�|jd�x~|D]v}tj
j||�}|}	}
tj
j|��r"|d}	|d}
tj
j|��r8|d}	|jdtjj|
dd�tj
|	dd	�f�q�W|jd�dj|�j|d�}tj�}|j|�|jd�|jtj�|jdd|�|jdtt|���|j�|S)z�Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        zNo permission to list directoryNcSs|j�S)N)r7)�arrr�<lambda>�sz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass)�errorsF)rLzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperzContent-typeztext/html; charset=%szContent-Length) r��listdirr�r,rr��sortr�r��unquoter.�UnicodeDecodeErrorrVrWrl�getfilesystemencodingr`rer��islinkrLrX�io�BytesIOrZ�seekrSr�rTr#r(r>)
rr.�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr��s\







z'SimpleHTTPRequestHandler.list_directorycCs�|jdd�d}|jdd�d}|j�jd�}ytjj|dd�}Wn tk
rbtjj|�}YnXtj|�}|jd�}t	d|�}t
j�}x8|D]0}t
jj
|�s�|t
jt
jfkr�q�t
jj||�}q�W|r�|d7}|S)	z�Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        �?rr�#rr�)r�N)r'r%r�r�r�r�r��	posixpath�normpath�filterr��getcwdr.�dirname�curdir�pardirre)rr.Ztrailing_slashr:Zwordrrrr��s$	



z'SimpleHTTPRequestHandler.translate_pathcCstj||�dS)a�Copy all data between two file objects.

        The SOURCE argument is a file object open for reading
        (or anything with a read() method) and the DESTINATION
        argument is a file object open for writing (or
        anything with a write() method).

        The only reason for overriding this would be to change
        the block size or perhaps to replace newlines by CRLF
        -- note however that this the default server uses this
        to copy binary data as well.

        N)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�sz!SimpleHTTPRequestHandler.copyfilecCsLtj|�\}}||jkr"|j|S|j�}||jkr>|j|S|jdSdS)a�Guess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.

        rN)r��splitext�extensions_mapr7)rr.�baseZextrrrr�)s



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)rz.pyz.cz.hN)rrrrr�rqr�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��updaterrrrrrs"	1:
c	Cs�|jd�\}}}tjj|�}|jd�}g}x<|dd�D],}|dkrN|j�q8|r8|dkr8|j|�q8W|r�|j�}|r�|dkr�|j�d}q�|dkr�d}nd}|r�dj||f�}ddj|�|f}dj|�}|S)	a�
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a collapsed path.

    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.

    Returns: The reconstituted URL, which will always start with a '/'.

    Raises: IndexError if too many '..' occur within the path.

    r�rNrz..rr���)�	partitionr�r�r�r'�popr`re)	r.�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_pathNs.


r�cCsptrtSyddl}Wntk
r(dSXy|jd�daWn.tk
rjdtdd�|j�D��aYnXtS)	z$Internal routine to get nobody's uidrNr�nobodyrcss|]}|dVqdS)rNr)r|rvrrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>r�)r��pwd�ImportError�getpwnamrR�maxZgetpwall)r�rrr�
nobody_uid�s r�cCstj|tj�S)zTest for executable file.)r��access�X_OK)r.rrr�
executable�sr�c@sVeZdZdZeed�ZdZdd�Zdd�Z	dd	�Z
d
dgZdd
�Zdd�Z
dd�ZdS)rz�Complete HTTP server with GET, HEAD and POST commands.

    GET and HEAD also support running CGI scripts.

    The POST command is *only* implemented for CGI scripts.

    �forkrcCs$|j�r|j�n|jtjd�dS)zRServe a POST request.

        This is only implemented for CGI scripts.

        zCan only POST to CGI scriptsN)�is_cgi�run_cgir,rrA)rrrr�do_POST�s

zCGIHTTPRequestHandler.do_POSTcCs|j�r|j�Stj|�SdS)z-Version of send_head that support CGI scriptsN)r�r�rr�)rrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|jdd�}|d|�||dd�}}||jkrL||f|_dSdS)a3Test whether self.path corresponds to a CGI script.

        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.

        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.

        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).

        rrNTF)r�r.�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr��s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�S)z1Test whether argument path is an executable file.)r�)rr.rrr�
is_executable�sz#CGIHTTPRequestHandler.is_executablecCstjj|�\}}|j�dkS)z.Test whether argument path is a Python script.�.py�.pyw)r�r�)r�r.r�r7)rr.r�r�rrr�	is_python�szCGIHTTPRequestHandler.is_pythonc)Cs�|j\}}|d|}|jdt|�d�}x`|dkr�|d|�}||dd�}|j|�}tjj|�r�||}}|jdt|�d�}q,Pq,W|jd�\}}}	|jd�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|j|�}tjj|��s|j	t
jd|�dStjj|��s2|j	t
j
d|�dS|j|�}
|j�sL|
�rn|j|��sn|j	t
j
d	|�dStjtj�}|j�|d
<|jj|d<d|d
<|j|d<t|jj�|d<|j|d<tjj|�}||d<|j|�|d<||d<|	�r�|	|d<|jd|d<|jj d�}|�r�|j!�}t|�dk�r�ddl"}ddl#}|d|d<|dj$�dk�r�y"|dj%d�}|j&|�j'd�}Wn|j(t)fk
�r�Yn&X|j!d�}t|�dk�r�|d|d<|jj d�dk�r�|jj*�|d<n|jd|d<|jj d�}|�r||d <|jj d!�}|�r"||d"<g}xN|jj+d#�D]>}|dd�d$k�rZ|j,|j-��n||d%d�j!d&�}�q4Wd&j.|�|d'<|jj d(�}|�r�||d)<t/d|jj0d*g��}d+j.|�}|�r�||d,<xd=D]}|j1|d��q�W|j2t
j3d.�|j4�|	j5d/d0�}|j�r.|
g}d1|k�r*|j,|�t6�}|j7j8�tj9�}|dk�r�tj:|d�\}}x0t;j;|j<gggd�d�r�|j<j=d��s^P�q^W|�r�|j>d2|�dSy\ytj?|�Wnt@k
�r�YnXtjA|j<jB�d�tjA|j7jB�d�tjC|||�Wn(|jjD|jE|j�tjFd3�YnX�n�ddlG} |g}!|j|��r�tHjI}"|"j$�jJd4��rv|"dd>�|"d?d�}"|"d7g|!}!d1|	k�r�|!j,|	�|jKd8| jL|!��ytM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d9�}$|jj$�d:k�r|#dk�r|j<j=|#�}%nd}%x4t;j;|j<jRgggd�d�rN|j<jRjSd��sP�qW|$jT|%�\}&}'|j7jU|&�|'�r||j>d;|'�|$jVjW�|$jXjW�|$jY}(|(�r�|j>d2|(�n
|jKd<�dS)@zExecute a CGI script.rrrNr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationrZ	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE�REMOTE_HOSTzScript output follows�+rp�=zCGI script exit status %#x�zw.exerr�z-uzcommand: %s)�stdin�stdoutrm�envZpostz%szCGI script exited OK)r�r�r�r�r�r�������)Zr�r�r(r�r�r.r�r�r�r,rr��isfileZ	FORBIDDENr��	have_forkr�r��deepcopy�environr\Zserverrr-r#rrr�r�r�rzr5r6r'�base64�binasciir7rXZdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersr`�striprer�Zget_all�
setdefaultrSr�rcrPr�rCrDr��waitpid�selectr3�readrE�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessrlr�r�rhZlist2cmdliner*�	TypeErrorr)�Popen�PIPEZ_sockZrecvZcommunicaterZrmrr��
returncode))r�dir�restr.�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyr�Zuqrestr�rrZlengthr�r��lineZua�coZ
cookie_str�kZ
decoded_queryrkr��pid�stsrZcmdlineZinterp�nbytes�p�datar�rmZstatusrrrr��s4

























zCGIHTTPRequestHandler.run_cgiN)rrrrr@r�r�Zrbufsizer�r�r�r�r�r�r�rrrrr�s
zHTTP/1.0i@rc	Cs�||f}||_|||��b}|jj�}d}t|j|d|dd��y|j�Wn&tk
rttd�tjd�YnXWdQRXdS)zmTest the HTTP request handler class.

    This runs an HTTP server on port 8000 (or the port argument).

    z>Serving HTTP on {host} port {port} (http://{host}:{port}/) ...rr)rrz&
Keyboard interrupt received, exiting.N)	r-r
Zgetsockname�printrjZ
serve_forever�KeyboardInterruptrl�exit)	�HandlerClassZServerClassZprotocolr�bindrZhttpdZsaZ
serve_messagerrr�test�s
r%�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�default�metavarr)rZstorer�z&Specify alternate port [default: 8000])r(r*�type�nargsr))r#rr$)/rr��__all__Zemail.utilsrtrVZhttp.clientr1r�r�r�r�r
r�r
r	rlrsZurllib.parser�r��argparserr�r�r
rZStreamRequestHandlerrrr�r�r�r�rr%r�ArgumentParser�parser�add_argumentr*�
parse_argsrkZcgiZ
handler_classrr$rrrr�<module> sj3g]0
PKg�\��yi??cookies.cpython-36.pycnu�[���3


 \�S�
@s|dZddlZddlZdddgZdjZdjZdjZd	d
�ZGdd�de	�Z
ejejdZ
e
d
Zdd�eed��eeee��D�Zejed�ded�di�ejdeje
��jZdd�Zejd�Zejd�Zdd�Zddddd d!d"gZdd#d$d%d&d'd(d)d*d+d,d-d.g
Zdeefd/d0�ZGd1d2�d2e �Z!d3Z"e"d4Z#ejd5e"d6e#d7ej$ej%B�Z&Gd8d�de �Z'Gd9d�de'�Z(dS):a.

Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

The Basics
----------

Importing is easy...

   >>> from http import cookies

Most of the time you start by creating a cookie.

   >>> C = cookies.SimpleCookie()

Once you've created your Cookie, you can add values just as if it were
a dictionary.

   >>> C = cookies.SimpleCookie()
   >>> C["fig"] = "newton"
   >>> C["sugar"] = "wafer"
   >>> C.output()
   'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'

Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header.  This is the
default behavior.  You can change the header and printed
attributes by using the .output() function

   >>> C = cookies.SimpleCookie()
   >>> C["rocky"] = "road"
   >>> C["rocky"]["path"] = "/cookie"
   >>> print(C.output(header="Cookie:"))
   Cookie: rocky=road; Path=/cookie
   >>> print(C.output(attrs=[], header="Cookie:"))
   Cookie: rocky=road

The load() method of a Cookie extracts cookies from a string.  In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.

   >>> C = cookies.SimpleCookie()
   >>> C.load("chips=ahoy; vienna=finger")
   >>> C.output()
   'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'

The load() method is darn-tootin smart about identifying cookies
within a string.  Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.

   >>> C = cookies.SimpleCookie()
   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C = cookies.SimpleCookie()
   >>> C["oreo"] = "doublestuff"
   >>> C["oreo"]["path"] = "/"
   >>> print(C)
   Set-Cookie: oreo=doublestuff; Path=/

Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C = cookies.SimpleCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'

The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.

   >>> C = cookies.SimpleCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   '7'
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number=7\r\nSet-Cookie: string=seven'

Finis.
�N�CookieError�
BaseCookie�SimpleCookie�z; � cCs$ddl}d|}|j|tdd�dS)NrzvThe .%s setter is deprecated. The attribute will be read-only in future releases. Please use the set() method instead.�)�
stacklevel)�warnings�warn�DeprecationWarning)�setterr	�msg�r�$/usr/lib64/python3.6/http/cookies.py�_warn_deprecated_setter�src@seZdZdS)rN)�__name__�
__module__�__qualname__rrrrr�sz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}d||�qS)z\%03or)�.0�nrrr�
<dictcomp>�sr��"z\"�\z\\z[%s]+cCs*|dkst|�r|Sd|jt�dSdS)z�Quote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    Nr)�
_is_legal_key�	translate�_Translator)�strrrr�_quote�srz\\[0-3][0-7][0-7]z[\\].cCsT|dkst|�dkr|S|ddks0|ddkr4|S|dd�}d}t|�}g}x�d|kod|kn�rJtj||�}tj||�}|r�|r�|j||d��Pd	}}|r�|jd�}|r�|jd�}|o�|s�||k�r
|j|||��|j||d�|d}qR|j|||��|jtt||d|d�d���|d}qRWt|�S)
N�rr������r#r#)	�len�
_OctalPatt�search�
_QuotePatt�append�start�chr�int�	_nulljoin)r�ir�resZo_matchZq_match�j�krrr�_unquote�s6


$r1ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r3r2)ZfutureZweekdaynameZ	monthnamer2r3ZnowZyearZmonthZdayZhhZmmZssZwd�y�zrrr�_getdate�s
r6c	@seZdZdZdddddddd	d
�ZddhZd
d�Zedd��Zej	dd��Zedd��Z
e
j	dd��Z
edd��Zej	dd��Zdd�Zd4dd�Z
dd�ZejZdd �Zd!d"�Zd#d$�Zefd%d&�Zd'd(�Zd)d*�Zd5d,d-�ZeZd.d/�Zd6d0d1�Zd7d2d3�ZdS)8�Morsela�A class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.  This is most useful when Python
    objects are pickled for network transit.
    �expiresZPath�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersion)r8�path�commentZdomainzmax-age�secure�httponly�versionr<r=cCs4d|_|_|_x|jD]}tj||d�qWdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyrrr�__init__&szMorsel.__init__cCs|jS)N)r?)rErrrrF.sz
Morsel.keycCstd�||_dS)NrF)rr?)rErFrrrrF2scCs|jS)N)r@)rErrr�value7szMorsel.valuecCstd�||_dS)NrH)rr@)rErHrrrrH;scCs|jS)N)rA)rErrr�coded_value@szMorsel.coded_valuecCstd�||_dS)NrI)rrA)rErIrrrrIDscCs2|j�}||jkr td|f��tj|||�dS)NzInvalid attribute %r)�lowerrBrrCrD)rE�K�VrrrrDIs
zMorsel.__setitem__NcCs.|j�}||jkr td|f��tj|||�S)NzInvalid attribute %r)rJrBrrC�
setdefault)rErF�valrrrrMOs
zMorsel.setdefaultcCs>t|t�stStj||�o<|j|jko<|j|jko<|j|jkS)N)�
isinstancer7�NotImplementedrC�__eq__r@r?rA)rE�morselrrrrQUs
z
Morsel.__eq__cCs$t�}tj||�|jj|j�|S)N)r7rC�update�__dict__)rErRrrr�copy_szMorsel.copycCsVi}x@t|�j�D]0\}}|j�}||jkr:td|f��|||<qWtj||�dS)NzInvalid attribute %r)rC�itemsrJrBrrS)rE�values�datarFrNrrrrSes
z
Morsel.updatecCs|j�|jkS)N)rJrB)rErKrrr�
isReservedKeynszMorsel.isReservedKeycCsh|tkr ddl}|jdtdd�|j�|jkr<td|f��t|�sRtd|f��||_||_	||_
dS)NrzSLegalChars parameter is deprecated, ignored and will be removed in future versions.r)rz Attempt to set a reserved key %rzIllegal key %r)�_LegalCharsr	r
rrJrBrrr?r@rA)rErFrNZ	coded_valZ
LegalCharsr	rrr�setqsz
Morsel.setcCs|j|j|jd�S)N)rFrHrI)r?r@rA)rErrr�__getstate__�szMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrFrHrI)r?r@rA)rE�staterrr�__setstate__�s

zMorsel.__setstate__�Set-Cookie:cCsd||j|�fS)Nz%s %s)�OutputString)rE�attrs�headerrrr�output�sz
Morsel.outputcCsd|jj|j�fS)Nz<%s: %s>)�	__class__rr`)rErrr�__repr__�szMorsel.__repr__cCsd|j|�jdd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rz\")r`�replace)rErarrr�	js_output�szMorsel.js_outputcCs(g}|j}|d|j|jf�|dkr,|j}t|j��}x�|D]�\}}|dkrPq>||krZq>|dkr�t|t�r�|d|j|t|�f�q>|dkr�t|t�r�|d|j||f�q>|dkr�t|t	�r�|d|j|t
|�f�q>||jk�r|�r|t	|j|��q>|d|j||f�q>Wt|�S)Nz%s=%srr8zmax-agez%s=%dr;)
r(rFrIrB�sortedrVrOr+r6rr�_flags�_semispacejoin)rEra�resultr(rVrFrHrrrr`�s,zMorsel.OutputString)N)Nr_)N)N)rrr�__doc__rBrirG�propertyrFrrHrIrDrMrQ�object�__ne__rUrSrYrZr[r\r^rc�__str__rergr`rrrrr7s@
	


r7z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@sneZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zddd�Z	e	Z
dd�Zddd�Zdd�Z
efdd�ZdS)rz'A container class for a set of Morsels.cCs||fS)a
real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        r)rErNrrr�value_decode�szBaseCookie.value_decodecCst|�}||fS)z�real_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        )r)rErN�strvalrrr�value_encode�szBaseCookie.value_encodeNcCs|r|j|�dS)N)�load)rE�inputrrrrG�szBaseCookie.__init__cCs.|j|t��}|j|||�tj|||�dS)z+Private method for setting a cookie's valueN)�getr7r[rCrD)rErFZ
real_valuerI�MrrrZ__set�szBaseCookie.__setcCs:t|t�rtj|||�n|j|�\}}|j|||�dS)zDictionary style assignment.N)rOr7rCrDrs�_BaseCookie__set)rErFrH�rval�cvalrrrrDs
zBaseCookie.__setitem__�Set-Cookie:�
cCs>g}t|j��}x"|D]\}}|j|j||��qW|j|�S)z"Return a string suitable for HTTP.)rhrVr(rc�join)rErarb�seprkrVrFrHrrrrc
s
zBaseCookie.outputcCsNg}t|j��}x(|D] \}}|jd|t|j�f�qWd|jjt|�fS)Nz%s=%sz<%s: %s>)rhrVr(�reprrHrdr�
_spacejoin)rE�lrVrFrHrrrres
zBaseCookie.__repr__cCs:g}t|j��}x |D]\}}|j|j|��qWt|�S)z(Return a string suitable for JavaScript.)rhrVr(rgr,)rErarkrVrFrHrrrrgs
zBaseCookie.js_outputcCs8t|t�r|j|�nx|j�D]\}}|||<q WdS)z�Load cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        N)rOr�_BaseCookie__parse_stringrV)rEZrawdatarFrHrrrrt&s

zBaseCookie.loadcCs�d}t|�}g}d}d}d}�xd|ko2|kn�r|j||�}	|	sLP|	jd�|	jd�}
}|	jd�}|
ddkr�|s~q |j||
dd�|f�q |
j�tjkr�|s�dS|dkr�|
j�tjkr�|j||
df�q�dSn|j||
t	|�f�q |dk	�r|j||
|j
|�f�d}q dSq Wd}xb|D]Z\}
}
}|
|k�rV|dk	�sLt�|||
<n,|
|k�sdt�|\}}|j|
||�||
}�q*WdS)	NrFr rrFrN�$T)
r$�match�group�endr(rJr7rBrir1rq�AssertionErrorrx)rErZpattr-rZparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�rFrHrw�tpryrzrrrZ__parse_string4sJ



zBaseCookie.__parse_string)N)Nr{r|)N)rrrrlrqrsrGrxrDrcrprergrt�_CookiePatternr�rrrrr�s		
	

c@s eZdZdZdd�Zdd�ZdS)rz�
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    cCst|�|fS)N)r1)rErNrrrrqxszSimpleCookie.value_decodecCst|�}|t|�fS)N)rr)rErNrrrrrrs{szSimpleCookie.value_encodeN)rrrrlrqrsrrrrrqs))rl�re�string�__all__r}r,rjr�r�	ExceptionrZ
ascii_lettersZdigitsrZZ_UnescapedCharsr[�range�map�ordrrS�compile�escape�	fullmatchrrr%r'r1Z_weekdaynameZ
_monthnamer6rCr7Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrrrrr�<module>sF
	

2J
PKg�\�-�fdfdclient.cpython-36.opt-2.pycnu�[���3

���i*��@snddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddddddd	d
ddd
dddddddgZdZdZ
dZdZdZdZe�jejj�dd�ejjj�D�ZdZdZdZejd �jZejd!�jZejd"�Z ejd#�Z!d$d%d&hZ"dBd(d)�Z#Gd*d+�d+ej$j%�Z&d,d-�Z'e&fd.d/�Z(Gd0d�dej)�Z*Gd1d�d�Z+yddl,Z,Wne-k
�rhYnXGd2d3�d3e+�Z.ej/d3�Gd4d�de0�Z1Gd5d�de1�Z2Gd6d�de1�Z3Gd7d�de1�Z4Gd8d�de1�Z5Gd9d	�d	e1�Z6Gd:d
�d
e1�Z7Gd;d�de1�Z8Gd<d
�d
e8�Z9Gd=d�de8�Z:Gd>d�de8�Z;Gd?d�de1�Z<Gd@d�de1�Z=GdAd�de>e<�Z?e1Z@dS)C�N)�urlsplit�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}|j|�qS�)�phrase)�.0�vrr�#/usr/lib64/python3.6/http/client.py�
<dictcomp>ksrii�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUT�datacCsfy
|jd�Stk
r`}z:t|j|j|j|jd|j�||j|j�|f�d�WYdd}~XnXdS)Nzlatin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s
r'c@seZdZdd�ZdS)�HTTPMessagecCsn|j�d}t|�}g}d}xL|j�D]@}|d|�j�|krDd}n|dd�j�sXd}|r&|j|�q&W|S)N�:r�)�lower�len�keys�isspace�append)�selfr%�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r3rrrrr(�sr(cCs\g}xR|jtd�}t|�tkr(td��|j|�t|�tkrJtdt��|dkrPqW|S)Nr*zheader linezgot more than %d headers�
�
�)r7r8r9)�readline�_MAXLINEr,rr/�_MAXHEADERSr)�fp�headersr2rrr�
_read_headers�s
r?cCs,t|�}dj|�jd�}tjj|d�j|�S)Nr9z
iso-8859-1)�_class)r?�join�decode�email�parserZParserZparsestr)r=r@r>Zhstringrrr�
parse_headers�s
rEcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdCd(d)�ZdEd*d+�ZdG�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdHd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)IrrNcCsR|jd�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)�makefiler=�
debuglevel�_methodr>�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r0�sockrH�method�urlrrr�__init__�szHTTPResponse.__init__cCst|jjtd�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��y|j
dd�\}}}WnFtk
r�y|j
dd�\}}d}Wntk
r�d}YnXYnX|jd	�s�|j
�t|��y$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr*z
iso-8859-1zstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr=r:r;r,rrH�print�reprr�split�
ValueError�
startswith�_close_connr�int)r0r2rLrMrNrrr�_read_statuss2

zHTTPResponse._read_statuscCs�|jdk	rdSx<|j�\}}}|tkr(Pt|j�}|jdkrFtd|�~qW||_|_|j	�|_
|dkrrd|_n|jd�r�d|_nt
|��t|j�|_|_|jdkr�x&|jD]}td|d	|jj|��q�W|jjd
�}|r�|j�dkr�d|_d|_nd
|_|j�|_d|_|jjd�}|jjd
�}|�rx|j�rxyt|�|_Wntk
�rbd|_YnX|jdk�r~d|_nd|_|tk�s�|tk�s�d|k�o�dkn�s�|jdk�r�d|_|j�r�|j�r�|jdk�r�d|_dS)Nrzheaders:�HTTP/1.0�HTTP/0.9�
zHTTP/1.�zheader:r)ztransfer-encodingrOTFzcontent-lengthr���HEAD)rbrc)r>raZCONTINUEr?r=rHrZ�coderM�striprNrLr^rrErJ�getr+rOrP�_check_closerRrQr`r]Z
NO_CONTENTZNOT_MODIFIEDrI)r0rLrMrNZskipped_headers�hdrZtr_encrQrrr�begin9s\









zHTTPResponse.begincCs�|jjd�}|jdkr:|jjd�}|r6d|j�kr6dSdS|jjd�rJdS|r^d|j�kr^dS|jjd�}|r~d|j�kr~dSdS)NZ
connectionre�closeTFz
keep-alivezproxy-connection)r>rjrLr+)r0ZconnZpconnrrrrk�s
zHTTPResponse._check_closecCs|j}d|_|j�dS)N)r=rn)r0r=rrrr_�szHTTPResponse._close_connc
s$zt�j�Wd|jr|j�XdS)N)�superrnr=r_)r0)�	__class__rrrn�szHTTPResponse.closecst�j�|jr|jj�dS)N)ro�flushr=)r0)rprrrq�s
zHTTPResponse.flushcCsdS)NTr)r0rrr�readable�szHTTPResponse.readablecCs
|jdkS)N)r=)r0rrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|j�dS|dk	rRt|�}|j|�}t|�d|�j�S|jr`|j�S|j	dkrv|jj
�}n6y|j|j	�}Wntk
r�|j��YnXd|_	|j�|SdS)Nr9rgr)
r=rIr_�	bytearray�readinto�
memoryview�tobytesrO�_readall_chunkedrQ�read�
_safe_readr
)r0�amt�br1�srrrry�s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|j�dS|jr4|j|�S|jdk	r^t|�|jkr^t|�d|j�}|jj|�}|r~|r~|j�n&|jdk	r�|j|8_|js�|j�|S)Nrrg)	r=rIr_rO�_readinto_chunkedrQr,rvru)r0r|r1rrrru�s$






zHTTPResponse.readintocCsp|jjtd�}t|�tkr$td��|jd�}|dkrB|d|�}y
t|d�Stk
rj|j��YnXdS)Nr*z
chunk size�;r�)	r=r:r;r,r�findr`r]r_)r0r2�irrr�_read_next_chunk_size
s

z"HTTPResponse._read_next_chunk_sizecCs>x8|jjtd�}t|�tkr&td��|s,P|dkrPqWdS)Nr*ztrailer line�
r8r9)r�r8r9)r=r:r;r,r)r0r2rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|jd�y|j�}Wntk
rDtd��YnX|dkrb|j�|j�d}||_|S)NrWr9r)rPrzr�r]r
r�r_)r0rPrrr�_get_chunk_left(s
zHTTPResponse._get_chunk_leftcCsdg}y8x,|j�}|dkrP|j|j|��d|_qWdj|�Stk
r^tdj|���YnXdS)Nrr9)r�r/rzrPrAr
)r0�valuerPrrrrx@s

zHTTPResponse._readall_chunkedcCs�d}t|�}yvxp|j�}|dkr$|St|�|krL|j|�}|||_||S|d|�}|j|�}||d�}||7}d|_qWWn(tk
r�tt|d|����YnXdS)Nr)rvr�r,�_safe_readintorPr
�bytes)r0r|�total_bytes�mvbrPr1�temp_mvbrrrr~Ns$


zHTTPResponse._readinto_chunkedcCsXg}xH|dkrL|jjt|t��}|s4tdj|�|��|j|�|t|�8}qWdj|�S)Nrr9)r=ry�min�	MAXAMOUNTr
rAr/r,)r0r{r}�chunkrrrrzfs

zHTTPResponse._safe_readcCs�d}t|�}xt|t|�kr�tt|�kr@|dt�}|jj|�}n|jj|�}|sjtt|d|��t|���||d�}||7}qW|S)Nr)rvr,r�r=rur
r�)r0r|r�r�r�r1rrrr�}szHTTPResponse._safe_readintor*cCs�|jdks|jdkrdS|jr(|j|�S|jdk	rJ|dksD||jkrJ|j}y|jj|�}Wn*tk
r�|dkrt�|jjd�}YnX|r�|r�|j�n|jdk	r�|jt|�8_|S)Nrgr9rr�ii@)	r=rIrO�_read1_chunkedrQ�read1r]r_r,)r0r1�resultrrrr��s"



zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|j|�S|jj|�S)Nrgr9)r=rIrO�
_peek_chunked�peek)r0r1rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t�j|�S|jdk	rL|dksF||jkrL|j}|jj|�}|rl|rl|j�n|jdk	r�|jt|�8_|S)Nrgr9r)r=rIrOror:rQr_r,)r0�limitr�)rprrr:�s


zHTTPResponse.readlinecCsf|j�}|dks|dkrdSd|ko.|kns8|}|jj|�}|jt|�8_|sbtd��|S)Nrr9)r�r=r�rPr,r
)r0r1rPryrrrr��szHTTPResponse._read1_chunkedcCsBy|j�}Wntk
r dSX|dkr.dS|jj|�d|�S)Nr9)r�r
r=r�)r0r1rPrrrr��szHTTPResponse._peek_chunkedcCs
|jj�S)N)r=�fileno)r0rrrr��szHTTPResponse.filenocCsH|jdkrt��|jj|�p|}t|t�s6t|d�r:|Sdj|�SdS)N�__iter__z, )r>rZget_all�
isinstancerY�hasattrrA)r0r%�defaultr>rrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|jj��S)N)r>r�list�items)r0rrr�
getheaders�s
zHTTPResponse.getheaderscCs|S)Nr)r0rrrr��szHTTPResponse.__iter__cCs|jS)N)r>)r0rrr�info�szHTTPResponse.infocCs|jS)N)rU)r0rrr�geturls
zHTTPResponse.geturlcCs|jS)N)rM)r0rrr�getcodeszHTTPResponse.getcode)rNN)N���)r�r�)r�r�)r�)N)"r4r5r6rVrarmrkr_rnrqrrrsryrur�r�r�rxr~rzr�r�r�r:r�r�r�r�r�r�r�r�r��
__classcell__rr)rprr�s<	
!K

 "

	

c@s�eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	fd
d�Zd0dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd1dd �Zd2d!d"�Zd#d$�Zd%d&�Zd3dd'�d(d)�Zd	ifdd'�d*d+�Zd,d-�Z d.d/�Z!d	S)4rrezHTTP/1.1r*rcCst|tj�S)N)r��io�
TextIOBase)�streamrrr�
_is_textIO0szHTTPConnection._is_textIOcCsd|dkr|j�tkrdSdSt|d�r*dSyt|�}|jStk
rLYnXt|t�r`t|�SdS)Nrry)	�upper�_METHODS_EXPECTING_BODYr�rv�nbytes�	TypeErrorr�rYr,)�bodyrTZmvrrr�_get_content_length6s

z"HTTPConnection._get_content_lengthNcCs\||_||_d|_g|_d|_t|_d|_d|_d|_	i|_
|j||�\|_|_
tj|_dS)N)�timeout�source_addressrS�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterI�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�socketZcreate_connection�_create_connection)r0r�r�r�r�rrrrVVszHTTPConnection.__init__cCs<|jrtd��|j||�\|_|_|r.||_n
|jj�dS)Nz.Can't set up tunnel for established connection)rS�RuntimeErrorr�r�r�r��clear)r0r�r�r>rrr�
set_tunneliszHTTPConnection.set_tunnelcCs�|dkr�|jd�}|jd�}||kr�yt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd	�}||fS)
Nr)�]r*rXznonnumeric port: '%s'r�[r�r�)�rfindr`r]�default_portr)r0r�r�r��jrrrr��s

zHTTPConnection._get_hostportcCs
||_dS)N)rH)r0�levelrrr�set_debuglevel�szHTTPConnection.set_debuglevelcCsd|j|jf}|jd�}|j|�x6|jj�D](\}}d||f}|jd�}|j|�q0W|jd�|j|j|jd�}|j	�\}}	}
|	t
jjkr�|j
�td|	|
j�f��xP|jjtd�}t|�tkr�td	��|s�P|dkr�P|jdkr�td
|j��q�WdS)NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
zlatin-1�
)rTzTunnel connection failed: %d %sr*zheader liner8r9rzheader:)r�r8r9)r�r�r�sendr�r��response_classrSrIra�http�
HTTPStatusZOKrn�OSErrorrir=r:r;r,rrHrZrB)r0Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserLrh�messager2rrr�_tunnel�s2





zHTTPConnection._tunnelcCsB|j|j|jf|j|j�|_|jjtjtj	d�|j
r>|j�dS)Nr*)r�r�r�r�r�rSZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�)r0rrr�connect�s
zHTTPConnection.connectcCsBt|_z|j}|r d|_|j�Wd|j}|r<d|_|j�XdS)N)r�r�rSrnr�)r0rSr�rrrrn�szHTTPConnection.closecCs|jdkr |jr|j�nt��|jdkr8tdt|��d}t|d�r�|jdkrXtd�|j|�}|rx|jdkrxtd�x.|j	|�}|s�P|r�|j
d�}|jj|�qzWdSy|jj|�WnNtk
�r
t
|tj�r�x*|D]}|jj|�q�Wntdt|���YnXdS)	Nrzsend:i ryzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1z9data should be a bytes-like object or an iterable, got %r)rS�	auto_openr�rrHrZr[r�r�ryrZsendallr�r��collections�Iterable�type)r0r�	blocksizer�	datablock�drrrr��s:








zHTTPConnection.sendcCs|jj|�dS)N)r�r/)r0r}rrr�_output�szHTTPConnection._outputccsdd}|jdkrtd�|j|�}|r6|jdkr6td�x(|j|�}|sHP|rV|jd�}|Vq8WdS)Ni rzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1)rHrZr�ryr)r0rrr�rr�rrr�_read_readable�s



zHTTPConnection._read_readableFcCs$|jjd�dj|j�}|jdd�=|j|�|dk	�r t|d�rN|j|�}nZyt|�WnFtk
r�yt|�}Wn$tk
r�tdt	|���YnXYnX|f}xZ|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d�d	�jd
�|d}|j|�q�W|�r |jdk�r |jd�dS)
Nr9s
ryzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredre�Xz
r�s0

)r9r9)r��extendrAr�r�r�rvr��iterr�rHrZ�	_http_vsnr,r)r0�message_body�encode_chunkedrJZchunksr�rrr�_send_outputs4




zHTTPConnection._send_outputc

Cs�|jr|jj�rd|_|jtkr(t|_n
t|j��|j|�||_|sJd}tj	|�}|rrt
d|�d|j��d���d|||jf}|j
|jd��|jdk�r�|�s�d}|jd	�r�t|�\}}}}}|�ry|jd�}	Wntk
r�|jd
�}	YnX|jd|	�n�|j�r|j}
|j}n|j}
|j}y|
jd�}Wn tk
�rV|
jd
�}YnX|
jd�d
k�rtd|d}||jk�r�|jd|�n|jd�}|jdd||f�|�s�|jdd�ndS)N�/z&URL can't contain control characters. z (found at least �)z%s %s %sr�rerXr�ZidnaZHostr)r�[�]z%s:%szAccept-EncodingZidentity)r�rsr�r��_CS_REQ_STARTEDr
�_validate_methodrI�!_contains_disallowed_url_pchar_re�searchr�group�
_http_vsn_strr�rr�r^rr�	putheaderr�r�r�r�r�r�rB)
r0rTrU�	skip_host�skip_accept_encoding�match�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequestAsV






zHTTPConnection.putrequestcCs,tj|�}|r(td|�d|j��d���dS)Nz)method can't contain control characters. z (found at least r�)�$_contains_disallowed_method_pchar_rer�r]r�)r0rTr�rrrr��s
zHTTPConnection._validate_methodcGs�|jtkrt��t|d�r$|jd�}t|�s:td|f��t|�}xht|�D]\\}}t|d�rn|jd�||<nt	|t
�r�t|�jd�||<t||�rLtd||f��qLWdj
|�}|d|}|j|�dS)Nrr�zInvalid header name %rzlatin-1zInvalid header value %rs
	s: )r�r�rr�r�_is_legal_header_namer]r��	enumerater�r`rY�_is_illegal_header_valuerAr�)r0r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader)r�cCs*|jtkrt|_nt��|j||d�dS)N)r�)r�r��_CS_REQ_SENTrr�)r0r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|j|||||�dS)N)�
_send_request)r0rTrUr�r>r�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|j||�}|dkr�|dk	r�|jdkr�td|�d
}|jdd�q�|jdt|��nd
}x |j�D]\}	}
|j|	|
�q�Wt|t�r�t	|d�}|j
||d�dS)Ncss|]}|j�VqdS)N)r+)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r*r�zaccept-encodingr�zcontent-lengthztransfer-encodingFrzUnable to determine size of %rTzTransfer-EncodingrOzContent-Lengthr�)r�)�	frozensetr�r�rHrZr�rYr�r�r'r�)r0rTrUr�r>r�Zheader_namesZskipsZcontent_lengthrlr�rrrr��s0	


zHTTPConnection._send_requestcCs�|jr|jj�rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}yLy|j	�Wnt
k
r�|j��YnXt|_|j
r�|j�n||_|S|j��YnXdS)Nr)rT)r�rsr�r�rrHr�rSrIrm�ConnectionErrorrnr�rR)r0r�rrr�getresponse)s,


zHTTPConnection.getresponse)NN)NF)FF)N)"r4r5r6r�r�rr��	HTTP_PORTr�r�rH�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrVr�r�r�r�r�rnr�r�r�r�r�r�r�r�r�r�r�rrrrr&s< 
	'
6
	
.csBeZdZeZdddejdfddd��fdd�Z�fdd�Z�Z	S)�HTTPSConnectionN)�context�check_hostnamecs�tt|�j||||�|dk	s.|dk	s.|dk	rDddl}	|	jdtd�||_||_|dkrptj	�}|j
dk	rpd|_
|jtjk}
|dkr�|j
}|r�|
r�td��|s�|r�|j||�|j
dk	r�d|_
||_||_dS)NrzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rWTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rorrV�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr]Zload_cert_chain�_context�_check_hostname)r0r�r�rr	r�r�rrrZwill_verify)rprrrVts0


zHTTPSConnection.__init__cs�t�j�|jr|j}n|j}|jj|j|d�|_|jjr�|jr�yt	j
|jj�|�Wn.tk
r�|jj
tj�|jj��YnXdS)N)�server_hostname)ror�r�r�rZwrap_socketrSrrr
Zmatch_hostnameZgetpeercert�	ExceptionZshutdownr�Z	SHUT_RDWRrn)r0r
)rprrr��s



zHTTPSConnection.connect)
r4r5r6�
HTTPS_PORTr�r�rrVr�r�rr)rprrmsrc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dS)N)�argsrL)r0rLrrrrV�szUnknownProtocol.__init__N)r4r5r6rVrrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r	N)r4r5r6rrrrr	�sc@s&eZdZddd�Zdd�Zdd�ZdS)	r
NcCs|f|_||_||_dS)N)r�partial�expected)r0rrrrrrV�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedrXz%s(%i bytes read%s))rrpr4r,r)r0�errr�__repr__�s

zIncompleteRead.__repr__cCst|�S)N)r[)r0rrr�__str__�szIncompleteRead.__str__)N)r4r5r6rVrrrrrrr
�s
c@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r
N)r4r5r6rrrrr
�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dS)N)r[rr2)r0r2rrrrV�szBadStatusLine.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcCstj|dt|f�dS)Nz&got more than %d bytes when reading %s)rrVr;)r0Z	line_typerrrrV�szLineTooLong.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcOs"tj|d�tj|f|�|�dS)NrX)rrV�ConnectionResetError)r0�pos�kwrrrrV�szRemoteDisconnected.__init__N)r4r5r6rVrrrrr�s)r)AZemail.parserrCZ
email.messager�r��os�rer�r�Zurllib.parser�__all__r�rrKr�r�r��globals�updater��__members__r�rr�r;r<�compile�	fullmatchr�r�r�r�r�r�r'r�ZMessager(r?rE�BufferedIOBaserrr
�ImportErrorrr/rrrrrrr	r
rr
rrrrrrrrrrr�<module>Gs�



9F=
PKg�\�>��?�?�cookiejar.cpython-36.opt-1.pycnu�[���3

���ir+�@s*dZddddddddgZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZyd	d
l	Z
Wnek
rpd	d
lZ
YnXd	d
l
Zd	dlmZdZd
ad
d�Zeejj�ZdZdd�ZdZdd�ZdddddddgZddddd d!d"d#d$d%d&d'gZgZxeD]Zej ej!��q�Wdud(d)�Z"dvd*d+�Z#d
d
d
d
d,�Z$ej%d-ej&�Z'd.d/�Z(d0d1�Z)ej%d2ej&�Z*ej%d3ej+ej&B�Z,ej%d4ej-ej&B�Z.d5d6�Z/ej%d7ej-ej&B�Z0d8d9�Z1d:d;�Z2ej%d<�Z3ej%d=�Z4ej%d>�Z5ej%d?�Z6d@dA�Z7ej%dB�Z8dCdD�Z9dEdF�Z:dGdH�Z;ej%dIej&�Z<dJdK�Z=dLdM�Z>dNdO�Z?dPdQ�Z@ej%dRej&�ZAdSdT�ZBdUdV�ZCdWdX�ZDdYdZ�ZEd[ZFej%d\�ZGd]d^�ZHd_d`�ZIdadb�ZJdcdd�ZKGded�d�ZLGdfd�d�ZMGdgd�deM�ZNdhdi�ZOdjdk�ZPGdldm�dm�ZQGdnd�d�ZRGdod�deS�ZTGdpd�deR�ZUdqdr�ZVGdsd�deU�ZWGdtd�deU�ZXd
S)wa�HTTP cookie handling for web clients.

This module has (now fairly distant) origins in Gisle Aas' Perl module
HTTP::Cookies, from the libwww-perl library.

Docstrings, comments and debug strings in this code refer to the
attributes of the HTTP cookie system as cookie-attributes, to distinguish
them clearly from Python attributes.

Class diagram (note that BSDDBCookieJar and the MSIE* classes are not
distributed with the Python standard library, but are available from
http://wwwsearch.sf.net/):

                        CookieJar____
                        /     \      \
            FileCookieJar      \      \
             /    |   \         \      \
 MozillaCookieJar | LWPCookieJar \      \
                  |               |      \
                  |   ---MSIEBase |       \
                  |  /      |     |        \
                  | /   MSIEDBCookieJar BSDDBCookieJar
                  |/
               MSIECookieJar

�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|jd�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�&/usr/lib64/python3.6/http/cookiejar.py�_debug.s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|j�}|jd|�|j�}|jd|dd�dS)Nr	zhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)rrr�f�msgrrr�_warn_unhandled_exception<s
ri�cCs�|dd�\}}}}}}|tkr�d|ko2dknr�d|koJdknr�d|kobdknr�d|kozdknr�d|ko�dknr�t|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmKs
8Hr,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtjj�}ntjj|�}d|j|j|j|j|j|jfS)aHReturn a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
    representing Universal Time (UTC, aka GMT).  An example of this format is:

    1994-11-24 08:49:37Z

    Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second)�t�dtrrr�	time2isozYs
r5cCsR|dkrtjj�}ntjj|�}dt|j�|jt|jd|j|j	|j
|jfS)z�Return a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like this:

    Wed, DD-Mon-YYYY HH:MM:SS GMT

    Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2)r3r4rrr�
time2netscapelsr8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTtj|�}|rfdt|jd��}|jd�rR|dt|jd��}|jd�dkrf|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s

rFc
Cs�t|�}|tjkrdSytj|j��d}WnXtk
r�yt|�}Wntk
r\dSXd|kopdknr||}ndSYnX|dkr�d}|dkr�d}|dkr�d}t|�}t|�}t|�}t|�}|dk�r0tjtj��d}|d}	|}
|||	}|	|
}	t	|	�dk�r0|	dk�r(|d}n|d}t
|||||||f�}|dk	�r�|dk�r^d}|j�}t|�}|dk�r|dS||}|S)Nrr r	i��d�2r9)
rAr-ZMAXYEAR�MONTHS_LOWER�index�lower�
ValueError�timeZ	localtime�absr,�upperrF)
r0�mon�yr�hrr*r+rCZimonZcur_yrrEZtmpr3rDrrr�	_str2time�sV







rSzV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
       \s*
    (?:\(\w+\))?       # ASCII representation of timezone in parens.
       \s*$cCs�tj|�}|rl|j�}tj|dj��d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|j	�}t
jd|d�}dgd	\}}}}}}	}
tj|�}|dk	r�|j�\}}}}}}	}
ndSt
||||||	|
�S)
a�Returns time in seconds since epoch of time represented by a string.

    Return value is an integer.

    None is returned if the format of str is unrecognized, the time is outside
    the representable range, or the timezone string is not recognized.  If the
    string contains no timezone, UTC is assumed.

    The timezone in the string may be numerical (like "-0800" or "+0100") or a
    string timezone (like "UTC", "GMT", "BST" or "EST").  Currently, only the
    timezone strings equivalent to UTC (zero offset) are known to the function.

    The function loosely parses the following formats:

    Wed, 09 Feb 1994 22:23:32 GMT       -- HTTP format
    Tuesday, 08-Feb-94 14:15:29 GMT     -- old rfc850 HTTP format
    Tuesday, 08-Feb-1994 14:15:29 GMT   -- broken rfc850 HTTP format
    09 Feb 1994 22:23:32 GMT            -- HTTP format (no weekday)
    08-Feb-94 14:15:29 GMT              -- rfc850 format (no weekday)
    08-Feb-1994 14:15:29 GMT            -- broken rfc850 format (no weekday)

    The parser ignores leading and trailing whitespace.  The time may be
    absent.

    If the year is given with only 2 digits, the function will select the
    century that makes the year closest to the current date.

    rrr	r;���N�)�STRICT_DATE_REr@�groupsrIrJrKrA�floatr,�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_RErS)�textrE�grPr&r0rQrRr*r+rCrrr�	http2time�s
"
raa�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   ([-+]?\d\d?:?(:?\d\d)?
    |Z|z)?               # timezone  (Z is "zero meridian", i.e. GMT)
      \s*$c
Csd|j�}dgd\}}}}}}}tj|�}|dk	rL|j�\}}}}}}}}	ndSt|||||||�S)av
    As for http2time, but parses the ISO 8601 formats:

    1994-02-03 14:15:29 -0100    -- ISO 8601 format
    1994-02-03 14:15:29          -- zone is optional
    1994-02-03                   -- only date
    1994-02-03T14:15:29          -- Use T as separator
    19940203T141529Z             -- ISO 8601 compact format
    19940203                     -- only date

    NrW)r[�ISO_DATE_REr@rYrS)
r_r0rPrQrRr*r+rCrE�_rrr�iso2time's

rdcCs*|jd�\}}|jd|�|j|d�S)z)Return unmatched part of re.Match object.r	N)�span�string)�match�start�endrrr�	unmatchedHsrjz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Csg}�x|D]�}|}g}x�|r�tj|�}|r�t|�}|jd�}tj|�}|rlt|�}|jd�}tjd|�}n.tj|�}|r�t|�}|jd�}|j�}nd}|j	||f�q|j
�jd�r�|j
�dd�}|r�|j	|�g}qtj
dd|�\}}	|}qW|r|j	|�qW|S)amParse header values into a list of lists containing key,value pairs.

    The function knows how to deal with ",", ";" and "=" as well as quoted
    values after "=".  A list of space separated tokens are parsed as if they
    were separated by ";".

    If the header_values passed as argument contains multiple values, then they
    are treated as if they were a single value separated by comma ",".

    This means that this function is useful for parsing header fields that
    follow this syntax (BNF as from the HTTP/1.1 specification, but we relax
    the requirement for tokens).

      headers           = #header
      header            = (token | parameter) *( [";"] (token | parameter))

      token             = 1*<any CHAR except CTLs or separators>
      separators        = "(" | ")" | "<" | ">" | "@"
                        | "," | ";" | ":" | "\" | <">
                        | "/" | "[" | "]" | "?" | "="
                        | "{" | "}" | SP | HT

      quoted-string     = ( <"> *(qdtext | quoted-pair ) <"> )
      qdtext            = <any TEXT except <">>
      quoted-pair       = "\" CHAR

      parameter         = attribute "=" value
      attribute         = token
      value             = token | quoted-string

    Each header is represented by a list of key/value pairs.  The value for a
    simple token (not part of a parameter) is None.  Syntactically incorrect
    headers will not necessarily be parsed as you would want.

    This is easier to describe with some examples:

    >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz'])
    [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]]
    >>> split_header_words(['text/html; charset="iso-8859-1"'])
    [[('text/html', None), ('charset', 'iso-8859-1')]]
    >>> split_header_words([r'Basic realm="\"foo\bar\""'])
    [[('Basic', None), ('realm', '"foobar"')]]

    rz\1N�,z^[=\s;]*rV)�HEADER_TOKEN_REr@rjrB�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr]�HEADER_VALUE_RE�rstrip�appendr[�
startswith�re�subn)
Z
header_values�resultr_Z	orig_text�pairsrE�name�valueZnon_junkZ
nr_junk_charsrrr�split_header_wordsQs>.







ryz([\"\\])cCs�g}xt|D]l}g}xN|D]F\}}|dk	rTtjd|�sHtjd|�}d|}d||f}|j|�qW|r
|jdj|��q
Wdj|�S)a�Do the inverse (almost) of the conversion done by split_header_words.

    Takes a list of lists of (key, value) pairs and produces a single header
    value.  Attribute values are quoted if needed.

    >>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]])
    'text/plain; charset="iso-8859-1"'
    >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]])
    'text/plain, charset="iso-8859-1"'

    Nz^\w+$z\\\1z"%s"z%s=%sz; z, )rsr@�HEADER_JOIN_ESCAPE_REr]rq�join)Zlists�headersrv�attr�k�vrrr�join_header_words�s
r�cCs0|jd�r|dd�}|jd�r,|dd�}|S)N�"r���)rr�endswith)r_rrr�strip_quotes�s


r�cCsd}g}x�|D]�}g}d}x�t|jd	��D]�\}}|j�}|jd
�\}}	}
|j�}|sd|dkr*Pnq*|	rp|
j�nd}
|dkr�|j�}||kr�|}|dkr�|
dk	r�t|
�}
d
}n|dkr�|
dk	r�tt|
��}
|j||
f�q*W|r|�s�|jd�|j|�qW|S)a5Ad-hoc parser for Netscape protocol cookie-attributes.

    The old Netscape cookie format for Set-Cookie can for instance contain
    an unquoted "," in the expires field, so we have to use this ad-hoc
    parser instead of split_header_words.

    XXX This may not make the best possible effort to parse all the crap
    that Netscape Cookie headers contain.  Ronald Tschalar's HTTPClient
    parser is probably better, so could do worse than following that if
    this ever gives any trouble.

    Currently, this is also used for parsing RFC 2109 cookies.

    �expires�domain�path�secure�version�port�max-ageF�;�=r	NT�0)r�r�r�r�r�r�r�)r�r�)�	enumerate�split�strip�	partitionrKr�rarq)Z
ns_headersZknown_attrsruZ	ns_headerrv�version_setZiiZparam�key�sep�val�lcrrr�parse_ns_headers�s@

r�z\.\d+$cCs:tj|�rdS|dkrdS|ddks2|ddkr6dSdS)z*Return True if text is a host domain name.FrVr	�.rTr�)�IPV4_REr@)r_rrr�is_HDNs
r�cCsl|j�}|j�}||krdSt|�s(dS|j|�}|dksB|dkrFdS|jd�sTdSt|dd��shdSdS)a�Return True if domain A domain-matches domain B, according to RFC 2965.

    A and B may be host domain names or IP addresses.

    RFC 2965, section 1:

    Host names can be specified either as an IP address or a HDN string.
    Sometimes we compare one host name with another.  (Such comparisons SHALL
    be case-insensitive.)  Host A's name domain-matches host B's if

         *  their host name strings string-compare equal; or

         * A is a HDN string and has the form NB, where N is a non-empty
            name string, B has the form .B', and B' is a HDN string.  (So,
            x.y.com domain-matches .Y.com but not Y.com.)

    Note that domain-match is not a commutative operation: a.b.c.com
    domain-matches .c.com, but not the reverse.

    TFrr	r�Nr�)rKr��rfindrr)�A�B�irrr�domain_matchs

r�cCstj|�rdSdS)zdReturn True if text is a sort-of-like a host domain name.

    For accepting/blocking domains.

    FT)r�r@)r_rrr�liberal_is_HDNBs
r�cCsb|j�}|j�}t|�ot|�s0||kr,dSdS|jd�}|rL|j|�rLdS|r^||kr^dSdS)z\For blocking/accepting domains.

    A and B may be host domain names or IP addresses.

    TFr�)rKr�rrr�)r�r��initial_dotrrr�user_domain_matchLs
r�z:\d+$cCsB|j�}tjj|�d}|dkr,|jdd�}tjd|d�}|j�S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    rrVZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer]rK)�request�url�hostrrr�request_hostasr�cCs6t|�}}|jd�dkr.tj|�r.|d}||fS)zzReturn a tuple (request-host, effective request-host name).

    As defined by RFC 2965, except both are lowercased.

    r�rz.localr�)r��findr�r@)r��erhn�req_hostrrr�eff_request_hostqsr�cCs4|j�}tjj|�}t|j�}|jd�s0d|}|S)z6Path component of request-URI, as defined by RFC 2965.�/)r�r�r�Zurlsplit�escape_pathr�rr)r�r��partsr�rrr�request_path|s

r�cCs^|j}|jd�}|dkrV||dd�}yt|�WqZtk
rRtd|�dSXnt}|S)N�:r	rznonnumeric port: '%s')r�r�rArLr�DEFAULT_HTTP_PORT)r�r�r�r�rrr�request_port�s

r�z%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|jd�j�S)Nz%%%sr)rBrO)rgrrr�uppercase_escaped_char�sr�cCstjj|t�}tjt|�}|S)zEEscape any invalid characters in HTTP URL, and uppercase all escapes.)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr]r�)r�rrrr��s
r�cCsP|jd�}|dkrL||dd�}|jd�}t|�rL|dksD|dkrLd|S|S)aBReturn reach of host h, as defined by RFC 2965, section 1.

    The reach R of a host name H is defined as follows:

       *  If

          -  H is the host domain name of a host; and,

          -  H has the form A.B; and

          -  A has no embedded (that is, interior) dots; and

          -  B has at least one embedded dot, or B is the string "local".
             then the reach of H is .B.

       *  Otherwise, the reach of H is H.

    >>> reach("www.acme.com")
    '.acme.com'
    >>> reach("acme.com")
    'acme.com'
    >>> reach("acme.local")
    '.local'

    r�r	rNZlocal)r�r�)�hr��brrr�reach�s

r�cCs$t|�}t|t|j��sdSdSdS)z�

    RFC 2965, section 3.3.6:

        An unverifiable transaction is to a third-party host if its request-
        host U does not domain-match the reach R of the request-host O in the
        origin transaction.

    TFN)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
r�c@sNeZdZdZddd�Zdd�Zddd	�Zd
d�Zddd
�Zdd�Z	dd�Z
dS)ra�HTTP Cookie.

    This class represents both Netscape and RFC 2965 cookies.

    This is deliberately a very simple class.  It just holds attributes.  It's
    possible to construct Cookie instances that don't comply with the cookie
    standards.  CookieJar.make_cookies is the factory function for Cookie
    objects -- it deals with cookie parsing, supplying defaults, and
    normalising to the representation used in this class.  CookiePolicy is
    responsible for checking them to see whether they should be accepted from
    and returned to the server.

    Note that the port may be present in the headers, but unspecified ("Port"
    rather than"Port=80", for example); if this is the case, port is None.

    FcCs�|dk	rt|�}|dk	r$tt|��}|dkr<|dkr<td��||_||_||_||_||_|j�|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_tj|�|_dS)NTz-if port is None, port_specified must be false)rArZrLr�rwrxr��port_specifiedrKr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�rwrxr�r�r�r�r�r�r�r�r�r�r�r��restr�rrr�__init__�s.

zCookie.__init__cCs
||jkS)N)r�)r�rwrrr�has_nonstandard_attrszCookie.has_nonstandard_attrNcCs|jj||�S)N)r��get)r�rw�defaultrrr�get_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dS)N)r�)r�rwrxrrr�set_nonstandard_attrszCookie.set_nonstandard_attrcCs,|dkrtj�}|jdk	r(|j|kr(dSdS)NTF)rMr�)r��nowrrr�
is_expireds
zCookie.is_expiredcCsX|jdkrd}n
d|j}|j||j}|jdk	rFd|j|jf}n|j}d||fS)NrVr�z%s=%sz<Cookie %s for %s>)r�r�r�rxrw)r��p�limitZ	namevaluerrr�__str__%s


zCookie.__str__cCspg}x,dD]$}t||�}|jd|t|�f�q
W|jdt|j��|jdt|j��d|jjdj|�fS)Nr�rwrxr�r�r�r�r�r�r�r�r�r�r�r�z%s=%szrest=%sz
rfc2109=%sz%s(%s)z, )r�rwrxr�r�r�r�r�r�r�r�r�r�r�r�)�getattrrq�reprr�r��	__class__�__name__r{)r�rrwr}rrr�__repr__/s
zCookie.__repr__)F)N)N)r��
__module__�__qualname__�__doc__r�r�r�r�r�r�r�rrrrr�s
 


c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)ra Defines which cookies get accepted from and returned to server.

    May also modify cookies, though this is probably a bad idea.

    The subclass DefaultCookiePolicy defines the standard rules for Netscape
    and RFC 2965 cookies -- override that if you want a customized policy.

    cCs
t��dS)z�Return true if (and only if) cookie should be accepted from server.

        Currently, pre-expired cookies never get this far -- the CookieJar
        class deletes such cookies itself.

        N)�NotImplementedError)r��cookier�rrr�set_okGszCookiePolicy.set_okcCs
t��dS)zAReturn true if (and only if) cookie should be returned to server.N)r�)r�r�r�rrr�	return_okPszCookiePolicy.return_okcCsdS)zMReturn false if cookies should not be returned, given cookie domain.
        Tr)r�r�r�rrr�domain_return_okTszCookiePolicy.domain_return_okcCsdS)zKReturn false if cookies should not be returned, given cookie path.
        Tr)r�r�r�rrr�path_return_okYszCookiePolicy.path_return_okN)r�r�r�r�r�r�r�r�rrrrr>s
	c@s�eZdZdZdZdZdZdZeeBZdddddddddeddfd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�ZdS)7rzBImplements the standard rules for accepting and returning cookies.rrrTr	NTFc

Csp||_||_||_||_||_||_|	|_|
|_||_||_	|dk	rPt
|�|_nf|_|dk	rft
|�}||_dS)zAConstructor arguments should be passed as keyword arguments only.N)
�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�tuple�_blocked_domains�_allowed_domains)
r��blocked_domains�allowed_domainsr�r�r�r�r�r�r�r�r�r�rrrr�is 
zDefaultCookiePolicy.__init__cCs|jS)z4Return the sequence of blocked domains (as a tuple).)r�)r�rrrr��sz#DefaultCookiePolicy.blocked_domainscCst|�|_dS)z$Set the sequence of blocked domains.N)r�r�)r�r�rrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs"x|jD]}t||�rdSqWdS)NTF)r�r�)r�r�Zblocked_domainrrr�
is_blocked�s
zDefaultCookiePolicy.is_blockedcCs|jS)z=Return None, or the sequence of allowed domains (as a tuple).)r�)r�rrrr��sz#DefaultCookiePolicy.allowed_domainscCs|dk	rt|�}||_dS)z-Set the sequence of allowed domains, or None.N)r�r�)r�r�rrr�set_allowed_domains�sz'DefaultCookiePolicy.set_allowed_domainscCs0|jdkrdSx|jD]}t||�rdSqWdS)NFT)r�r�)r�r�Zallowed_domainrrr�is_not_allowed�s

z"DefaultCookiePolicy.is_not_allowedcCsBtd|j|j�x,dD]$}d|}t||�}|||�sd	SqWd
S)z�
        If you override .set_ok(), be sure to call this method.  If it returns
        false, so should your subclass (assuming your subclass wants to be more
        strict about which cookies to accept).

        z - checking cookie %s=%sr��
verifiabilityrwr�r�r�Zset_ok_FT)r�r�rwr�r�r�)rrwrxr�)r�r�r��n�fn_name�fnrrrr��s


zDefaultCookiePolicy.set_okcCs^|jdkrtd|j|j�dS|jdkr<|jr<td�dS|jdkrZ|jrZtd�dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	z$   RFC 2965 cookies are switched offz$   Netscape cookies are switched offT)r�rrwrxr�r�)r�r�r�rrr�set_ok_version�s
z"DefaultCookiePolicy.set_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS)Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT)�unverifiabler�r�r�rr�)r�r�r�rrr�set_ok_verifiability�sz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|jjd�r,td|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�r�rwrrr)r�r�r�rrr�set_ok_name�s
zDefaultCookiePolicy.set_ok_namecCsL|jrHt|�}|jdks(|jdkrH|jrH|j|j�rHtd|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�r�rrr�r)r�r�r��req_pathrrr�set_ok_path�s

zDefaultCookiePolicy.set_ok_pathc
Cs�|j|j�rtd|j�dS|j|j�r8td|j�dS|j�r�t|�\}}|j}|jr�|jd�dkr�|jd�}|jdd|�}|dkr�||dd�}||d|�}	|	j	�d$kr�t
|�dkr�td|�dS|jd��r�|dd�}
n|}
|
jd�dk}|�r|dk�rtd|�dS|j
dk�rb|j|��rb|jd��rbd|j|��rbtd ||�dS|j
dk�s||j|j@�r�t||��s�td!||�dS|j
dk�s�|j|j@�r�|dt
|��}|jd�dk�r�tj|��r�td"||�dSd#S)%Nz"   domain %s is in user block-listFz&   domain %s is not in user allow-listr�rr	r�co�ac�com�edu�org�net�gov�milrA�aero�biz�cat�coop�info�jobs�mobi�museumrw�pro�travel�euz&   country-code second level domain %sz.localz/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rrrrrrrrrAr	r
rrr
rrrrwrrr)r�r�rr�r�r�r��countr�rK�lenrrr�r�r�r��DomainRFC2965Matchr��DomainStrictNoDotsr�r@)
r�r�r�r�r�r�r��jZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr�
set_ok_domain�sf

z!DefaultCookiePolicy.set_ok_domaincCs�|jr�t|�}|dkrd}nt|�}x\|jjd�D]:}yt|�Wntk
r`td|�dSX||kr2Pq2Wtd||j�dSdS)N�80rkz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)r�r��strr�r�rArLr)r�r�r��req_portr�rrr�set_ok_port%s"

zDefaultCookiePolicy.set_ok_portcCsBtd|j|j�x,dD]$}d|}t||�}|||�sd	SqWd
S)z�
        If you override .return_ok(), be sure to call this method.  If it
        returns false, so should your subclass (assuming your subclass wants to
        be more strict about which cookies to return).

        z - checking cookie %s=%sr�r�r�r�r�r�Z
return_ok_FT)r�r�r�r�r�r�)rrwrxr�)r�r�r�r�r�r�rrrr�:s	


zDefaultCookiePolicy.return_okcCs@|jdkr|jrtd�dS|jdkr<|jr<td�dSdS)Nr	z$   RFC 2965 cookies are switched offFz$   Netscape cookies are switched offT)r�r�rr�)r�r�r�rrr�return_ok_versionLsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS)Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT)r�r�r�r�rr�)r�r�r�rrr�return_ok_verifiabilityUsz+DefaultCookiePolicy.return_ok_verifiabilitycCs |jr|jdkrtd�dSdS)NZhttpsz(   secure cookie with non-secure requestFT)r��typer)r�r�r�rrr�return_ok_secureasz$DefaultCookiePolicy.return_ok_securecCs|j|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowr)r�r�r�rrr�return_ok_expiresgsz%DefaultCookiePolicy.return_ok_expirescCsP|jrLt|�}|dkrd}x0|jjd�D]}||kr(Pq(Wtd||j�dSdS)Nrrkz0   request port %s does not match cookie port %sFT)r�r�r�r)r�r�r�rr�rrr�return_ok_portms
z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r,|jd�r,d|}n|}|jdkrb|j|j@rb|jrb||krbtd�dS|jdkr�t||�r�td||�dS|jdkr�d|j	|�r�td||�dSdS)Nr�r	zQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sz;   request-host %s does not match Netscape cookie domain %sT)
r�r�rrr�r��DomainStrictNonDomainr�rr�r�)r�r�r�r�r�r��	dotdomainrrr�return_ok_domain{s&

z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|jd�sd|}|jd�s0d|}|rJ|jd�rJd|}n|}|j|�p`|j|�sfdS|j|�r~td|�dS|j|�r�td|�dSdS)Nr�Fz"   domain %s is in user block-listz&   domain %s is not in user allow-listT)r�rrr�r�rr�)r�r�r�r�r�r&rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCs0td|�t|�}|j|�s,td||�dSdS)Nz- checking cookie path=%sz  %s does not path-match %sFT)rr�rr)r�r�r�r�rrrr��s

z"DefaultCookiePolicy.path_return_ok) r�r�r�r�rr%rZ
DomainLiberalZDomainStrictr�r�r�r�r�r�r�r�r�r�r�rrrr�rrr!r#r$r'r�r�rrrrr_sL	;	cCst|j��}t|j|�S)N)�sorted�keys�mapr�)Zadictr)rrr�vals_sorted_by_key�sr+ccsZt|�}xL|D]D}d}y
|jWntk
r4YnXd}t|�EdH|s|VqWdS)zBIterates over nested mapping, depth-first, in sorted order by key.FTN)r+�items�AttributeError�
deepvalues)�mapping�values�objrrrr.�s

r.c@seZdZdS)�AbsentN)r�r�r�rrrrr2�sr2c@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ejdej�Zd3d	d
�Z
dd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd4d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z d1d2�Z!dS)5rz�Collection of HTTP cookies.

    You may not need to know about this class: try
    urllib.request.build_opener(HTTPCookieProcessor).open(url).
    z\Wz([\"\\])z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|dkrt�}||_tj�|_i|_dS)N)r�_policy�
_threading�RLock�
_cookies_lock�_cookies)r��policyrrrr��s

zCookieJar.__init__cCs
||_dS)N)r3)r�r8rrr�
set_policy�szCookieJar.set_policycCs�g}|jj||�sgStd|�|j|}xd|j�D]X}|jj||�sHq4||}x:|j�D].}|jj||�svtd�qZtd�|j|�qZWq4W|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r3r�rr7r)r�r0r�rq)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s 

zCookieJar._cookies_for_domaincCs.g}x$|jj�D]}|j|j||��qW|S)z2Return a list of cookies to be returned to server.)r7r)�extendr;)r�r�r:r�rrr�_cookies_for_request�szCookieJar._cookies_for_requestc	CsF|jdd�dd�d}g}�x$|D�]}|j}|sLd}|dkrL|jd|�|jdk	r~|jj|j�r~|dkr~|jjd	|j�}n|j}|jdkr�|j|j�n|jd
|j|f�|dkr"|j	r�|jd|j
�|jjd��r|j}|j
o�|jd��r|d
d�}|jd|�|jdk	r"d}|j�r4|d|j}|j|�q"W|S)z�Return a list of cookie-attributes to be returned to server.

        like ['foo="bar"; $Path="/"', ...]

        The $Version attribute is also added when appropriate (currently only
        once per request).

        cSs
t|j�S)N)rr�)�arrr�<lambda>sz)CookieJar._cookie_attrs.<locals>.<lambda>T)r��reverseFr	z$Version=%sNz\\\1z%s=%sz
$Path="%s"r�rz$Domain="%s"z$Portz="%s")�sortr�rqrx�non_word_rer@�quote_rer]rwr�r�r�rrr�r�r�)	r�r:r��attrsr�r�rxr�r�rrr�
_cookie_attrss>



zCookieJar._cookie_attrsc
Cs�td�|jj�z�ttj��|j_|_|j|�}|j|�}|r^|j	d�s^|j
ddj|��|jjr�|jj
r�|j	d�r�x$|D]}|jdkr�|j
dd�Pq�WWd|jj�X|j�dS)z�Add correct Cookie: header to request (urllib.request.Request object).

        The Cookie2 header is also added unless policy.hide_cookie2 is true.

        �add_cookie_headerrz; ZCookie2rz$Version="1"N)rr6�acquirerArMr3r"r=rEZ
has_headerZadd_unredirected_headerr{r�r�r��release�clear_expired_cookies)r�r�r:rDr�rrrrF?s$






zCookieJar.add_cookie_headercCs�g}d}d}�x||D�]r}|d\}}d}d}	i}
i}�x4|d
d�D�]"\}}
|j�}||ksh||krl|}||kr�|
dkr�d}
||
kr�qF|dkr�|
dkr�td�d}	P|
j�}
|dkr�|r�qF|
dkr�td�qF|dk�rd}yt|
�}
Wn$tk
�rtd�d}	PYnXd}|j|
}
||k�s2||k�rb|
dk�rX|dk�rXtd|�d}	P|
|
|<qF|
||<qFW|	�rvq|j|||
|f�qW|S)aReturn list of tuples containing normalised cookie information.

        attrs_set is the list of lists of key,value pairs extracted from
        the Set-Cookie or Set-Cookie2 headers.

        Tuples are name, value, standard, rest, where name and value are the
        cookie name and value, standard is a dictionary containing the standard
        cookie-attributes (discard, secure, version, expires or max-age,
        domain, path and port) and rest is a dictionary containing the rest of
        the cookie-attributes.

        r�r�r�r��max-ager�r�r�r��
commenturlr	FrNTz%   missing value for domain attributezM   missing or invalid value for expires attribute: treating as session cookiez?   missing or invalid (non-numeric) value for max-age attributez!   missing value for %s attribute)r�r�)r�r�rJr�r�r�r�rK)r�r�rK)rKrrArLr"rq)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsrwrxZmax_age_setZ
bad_cookie�standardr�r~rr�rrr�_normalized_cookie_tuples`sl






z#CookieJar._normalized_cookie_tuplesc!Cs$|\}}}}|jdt�}|jdt�}|jdt�}	|jdt�}
|jdd�}|dk	rryt|�}Wntk
rpdSX|jdd�}|jdd�}
|jd	d�}|jd
d�}|tk	r�|dkr�d}t|�}nXd}t|�}|jd
�}|dk�r|dkr�|d|�}n|d|d�}t|�dk�rd
}|tk	}d}|�r8t|j	d��}|tk�rTt
|�\}}|}n|j	d��shd|}d}|	tk	�r�|	dk�r�t|�}	nd}tj
dd|	�}	nd}	|
tk�r�d}
d}
nH|
|jk�r�y|j|||�Wntk
�r�YnXtd|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rKrVTr�rr	r�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s'r�)r�r2rArLr�r�r�r�boolrrr�r�rsr]r"�clear�KeyErrorrr)r��tupr�rwrxrPr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�_cookie_from_cookie_tuple�s�








z#CookieJar._cookie_from_cookie_tuplecCs:|j|�}g}x&|D]}|j||�}|r|j|�qW|S)N)rQrVrq)r�rLr�rMr:rUr�rrr�_cookies_from_attrs_sets

z!CookieJar._cookies_from_attrs_setcCsLt|jdd�}|dkr |jj}x&|D]}|jdkr&d|_|r&d|_q&WdS)Nr�rTr	)r�r3r�r�r�)r�r:Z
rfc2109_as_nsr�rrr�_process_rfc2109_cookies&s


z"CookieJar._process_rfc2109_cookiesc
Cs6|j�}|jdg�}|jdg�}|jj}|jj}|r<|s`|rH|s`|rT|s`|rd|rdgSy|jt|�|�}Wntk
r�t�g}YnX|o�|�r2y|jt	|�|�}	Wntk
r�t�g}	YnX|j
|	�|�r"i}
x |D]}d|
|j|j|j
f<q�W|
fdd�}t||	�}	|	�r2|j|	�|S)zAReturn sequence of Cookie objects extracted from response object.zSet-Cookie2z
Set-CookieNcSs|j|j|jf}||kS)N)r�r�rw)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965^sz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)r
Zget_allr3r�r�rWry�	Exceptionrr�rXr�r�rw�filterr<)
r��responser�r|Zrfc2965_hdrsZns_hdrsr�r�r:Z
ns_cookiesrYr�rZrrr�make_cookies2sB






zCookieJar.make_cookiesc
CsN|jj�z2ttj��|j_|_|jj||�r:|j|�Wd|jj�XdS)z-Set a cookie if policy says it's OK to do so.N)	r6rGrArMr3r"r��
set_cookierH)r�r�r�rrr�set_cookie_if_okhs
zCookieJar.set_cookie_if_okc
Csl|j}|jj�zJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<Wd|jj�XdS)z?Set a cookie, without checking whether or not it should be set.N)r7r6rGr�r�rwrH)r�r��cZc2Zc3rrrr_us






zCookieJar.set_cookiec
Cs|td|j��|jj�zRttj��|j_|_x6|j||�D]&}|jj	||�r>td|�|j
|�q>WWd|jj�XdS)zAExtract cookies from response, where allowable given the request.zextract_cookies: %sz setting cookie: %sN)rr
r6rGrArMr3r"r^r�r_rH)r�r]r�r�rrr�extract_cookies�s

zCookieJar.extract_cookiescCst|dk	r2|dks|dkr td��|j|||=n>|dk	rX|dkrJtd��|j||=n|dk	rj|j|=ni|_dS)a�Clear some cookies.

        Invoking this method without arguments will clear all cookies.  If
        given a single argument, only cookies belonging to that domain will be
        removed.  If given two arguments, cookies belonging to the specified
        path within that domain are removed.  If given three arguments, then
        the cookie with the specified name, path and domain is removed.

        Raises KeyError if no matching cookie exists.

        Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLr7)r�r�r�rwrrrrS�s
zCookieJar.clearcCsH|jj�z,x&|D]}|jr|j|j|j|j�qWWd|jj�XdS)z�Discard all session cookies.

        Note that the .save() method won't save session cookies anyway, unless
        you ask otherwise by passing a true ignore_discard argument.

        N)r6rGr�rSr�r�rwrH)r�r�rrr�clear_session_cookies�s

zCookieJar.clear_session_cookiescCsT|jj�z8tj�}x*|D]"}|j|�r|j|j|j|j�qWWd|jj�XdS)a�Discard all expired cookies.

        You probably don't need to call this method: expired cookies are never
        sent back to the server (provided you're using DefaultCookiePolicy),
        this method is called by CookieJar itself every so often, and the
        .save() method won't save expired cookies anyway (unless you ask
        otherwise by passing a true ignore_expires argument).

        N)	r6rGrMr�rSr�r�rwrH)r�r�r�rrrrI�s



zCookieJar.clear_expired_cookiescCs
t|j�S)N)r.r7)r�rrr�__iter__�szCookieJar.__iter__cCsd}x|D]}|d}q
W|S)z#Return number of contained cookies.r	rr)r�r�r�rrr�__len__�s
zCookieJar.__len__cCs6g}x|D]}|jt|��q
Wd|jjdj|�fS)Nz<%s[%s]>z, )rqr�r�r�r{)r��rr�rrrr��s
zCookieJar.__repr__cCs6g}x|D]}|jt|��q
Wd|jjdj|�fS)Nz<%s[%s]>z, )rqrr�r�r{)r�rfr�rrrr��s
zCookieJar.__str__)N)NNN)"r�r�r�r�rs�compilerBrCZstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�r9r;r=rErFrQrVrWrXr^r`r_rbrSrcrIrdrer�r�rrrrr�s8





;!a\	6


c@seZdZdS)rN)r�r�r�rrrrr�sc@s8eZdZdZddd�Zd
dd�Zddd	�Zdd
d�ZdS)rz6CookieJar that can be loaded from and saved to a file.NFc	CsJtj||�|dk	r6y|dWntd��YnX||_t|�|_dS)z}
        Cookies are NOT loaded from the named file until either the .load() or
        .revert() method is called.

        NrVzfilename must be string-like)rr�rL�filenamerR�	delayload)r�rjrkr8rrrr��szFileCookieJar.__init__cCs
t��dS)zSave cookies to a file.N)r�)r�rj�ignore_discard�ignore_expiresrrr�save�szFileCookieJar.savecCsJ|dkr"|jdk	r|j}ntt��t|��}|j||||�WdQRXdS)zLoad cookies from a file.N)rjrL�MISSING_FILENAME_TEXT�open�_really_load)r�rjrlrmrrrr�load�s

zFileCookieJar.loadcCs�|dkr"|jdk	r|j}ntt��|jj�zFtj|j�}i|_y|j|||�Wnt	k
rn||_�YnXWd|jj
�XdS)z�Clear all cookies and reload cookies from a saved file.

        Raises LoadError (or OSError) if reversion is not successful; the
        object's state will not be altered if this happens.

        N)rjrLror6rGr��deepcopyr7rr�OSErrorrH)r�rjrlrmZ	old_staterrr�reverts

zFileCookieJar.revert)NFN)NFF)NFF)NFF)r�r�r�r�r�rnrrrurrrrr�s


	cCs$|j|jfd|jfd|jfg}|jdk	r8|jd|jf�|jrH|jd�|jrX|jd�|jrh|jd�|j	rx|jd�|j
r�|jd	tt|j
��f�|j
r�|jd�|jr�|jd|jf�|jr�|jd|jf�t|jj��}x$|D]}|j|t|j|�f�q�W|jd
t|j�f�t|g�S)z�Return string representation of Cookie in the LWP cookie file format.

    Actually, the format is extended a bit -- see module docstring.

    r�r�Nr��	path_spec�	port_spec�
domain_dotr�r�r�r�rKr�)rvN)rwN)rxN)r�N)r�N)rwrxr�r�r�rqr�r�r�r�r�r5rZr�r�r�r(r�r)rr�r�)r�r�r)r~rrr�lwp_cookie_strs6







ryc@s,eZdZdZddd�Zddd�Zd	d
�ZdS)
ra[
    The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
    "Set-Cookie3" is the format used by the libwww-perl library, not known
    to be compatible with any browser, but which is easy to read and
    doesn't lose information about RFC 2965 cookies.

    Additional methods

    as_lwp_str(ignore_discard=True, ignore_expired=True)

    TcCs\tj�}g}x>|D]6}|r$|jr$q|r6|j|�r6q|jdt|��qWdj|dg�S)z�Return cookies as a string of "\n"-separated "Set-Cookie3" headers.

        ignore_discard and ignore_expires: see docstring for FileCookieJar.save

        zSet-Cookie3: %s�
rV)rMr�r�rqryr{)r�rlrmr�rfr�rrr�
as_lwp_strGs
zLWPCookieJar.as_lwp_strNFcCsX|dkr"|jdk	r|j}ntt��t|d��"}|jd�|j|j||��WdQRXdS)N�wz#LWP-Cookies-2.0
)rjrLrorp�writer{)r�rjrlrmrrrrrnWs

zLWPCookieJar.savecCsL|j�}|jj|�s$d|}t|��tj�}d}d}	d}
�yʐx�|j�}|dkrRP|j|�s^q@|t|�d�j�}�x�t|g�D�]x}|d\}
}i}i}x|	D]}d||<q�Wx�|dd�D]t\}}|dk	r�|j	�}nd}||
k�s�||	k�r�|}||	k�r|dk�rd}|||<q�||
k�r*|||<q�|||<q�W|j
}|d�}|d�}|dk	�r^t|�}|dk�rld}|d�}|jd�}t|d�|
||d	�|d�|||d�|d
�|d�|d�|||d
�|d�|�}|�r�|j
�r�q�|�r�|j|��r�q�|j|�q�Wq@WWnBtk
�r�Yn,tk
�rFt�td||f��YnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:rwrvrxr�r�r�r�r�r�r�r�rKrVr	FrTr�z&invalid Set-Cookie3 format file %r: %r)rwrvrxr�r�)r�r�r�r�r�r�rK)�readlinerir@rrMrrrr�ryrKr�rdrr�r�r_rtr[r)r�rrjrlrm�magicrr��headerrNrO�line�datarwrxrPr�r~rr�r�r�r�r�r�rarrrrqcs�











zLWPCookieJar._really_load)TT)NFF)r�r�r�r�r{rnrqrrrrr:s

c@s0eZdZdZejd�ZdZdd�Zd
dd	�Z	dS)ra�

    WARNING: you may want to backup your browser's cookies file if you use
    this class to save cookies.  I *think* it works, but there have been
    bugs in the past!

    This class differs from CookieJar only in the format it uses to save and
    load cookies to and from a file.  This class uses the Mozilla/Netscape
    `cookies.txt' format.  lynx uses this file format, too.

    Don't expect cookies saved while the browser is running to be noticed by
    the browser (in fact, Mozilla on unix will overwrite your saved cookies if
    you change them on disk while it's running; on Windows, you probably can't
    save at all while the browser is running).

    Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
    Netscape cookies on saving.

    In particular, the cookie version and port number information is lost,
    together with information about whether or not Path, Port and Discard were
    specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
    domain as set in the HTTP header started with a dot (yes, I'm aware some
    domains in Netscape files start with a dot and some don't -- trust me, you
    really don't want to know any more about this).

    Note that though Mozilla and Netscape use the same format, they use
    slightly different headers.  The class saves cookies using the Netscape
    header by default (Mozilla can cope with that).

    z#( Netscape)? HTTP Cookie Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCsntj�}|j�}|jj|�s(td|���y�x�|j�}|dkr@P|jd�rV|dd�}|j�jd�s.|j�dkrrq.|jd�\}}	}
}}}
}|dk}|	dk}	|
dkr�|}
d}|jd	�}d
}|dkr�d}d}t	d|
|dd
||	||
d
|||ddi�}|�r|j
�rq.|�r|j|��rq.|j|�q.WWnBt
k
�r>�Yn,tk
�rht�td
||f��YnXdS)Nz4%r does not look like a Netscape format cookies filerVrzr�#r��	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %rr�)r�r�)rMr~rir@rr�r�rrr�rr�r�r_rtr[r)r�rrjrlrmr�rr�r�r�r�r�r�rwrxr�r�rarrrrq�s`

zMozillaCookieJar._really_loadNFcCs|dkr"|jdk	r|j}ntt��t|d���}|j|j�tj�}x�|D]�}|rZ|jrZqH|rl|j|�rlqH|j	rxd}nd}|j
jd�r�d}nd}|jdk	r�t
|j�}	nd}	|jdkr�d}
|j}n|j}
|j}|jdj|j
||j||	|
|g�d�qHWWdQRXdS)Nr|r�ZFALSEr�rVr�rz)rjrLrorpr}r�rMr�r�r�r�rrr�rrxrwr{r�)r�rjrlrmrr�r�r�r�r�rwrxrrrrns<



zMozillaCookieJar.save)NFF)
r�r�r�r�rsrgrir�rqrnrrrrr�s

A)N)N)Yr��__all__r�r-rsrMZurllib.parser�Zurllib.requestZ	threadingr4�ImportErrorZdummy_threadingZhttp.clientZhttpZcalendarr
rrrrZclientZ	HTTP_PORTr�rorr%r,r6r7rIr(rqrKr5r8r>rgrhr?rFrSrX�Ir\�Xr^rarbrdrjrlrmrornryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr+r.r2rrtrrryrrrrrr�<module>s�



88!



U
D'


#b!\:xPKg�\�w3��O�Oserver.cpython-36.opt-2.pycnu�[���3

���i���@s�dZddddgZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZdZd	ZGd
d�dej�ZGdd�dej�ZGdd�de�Zd
d�Zdadd�Zdd�Z Gdd�de�Z!eedddfdd�Z"e#dk�r�ej$�Z%e%j&dddd�e%j&dddd d!d"�e%j&d#d$de'd%d&d'�e%j(�Z)e)j*�rze!Z+neZ+e"e+e)j,e)j-d(�dS))z0.6�
HTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c@seZdZdZdd�ZdS)r�cCs4tjj|�|jdd�\}}tj|�|_||_dS)N�)�socketserver�	TCPServer�server_bind�server_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�#/usr/lib64/python3.6/http/server.pyr�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressrrrrrr�sc
@seZdZdejj�dZdeZe	Z
eZdZ
dd�Zdd�Zd	d
�Zdd�Zd?dd�Zd@dd�ZdAdd�Zdd�Zdd�Zdd�ZdBdd�Zdd�Zdd �Zd!d"�ZdCd#d$�Zd%d&�Zd'd(d)d*d+d,d-gZd
d.d/d0d1d2d3d4d5d6d7d8d9g
Zd:d;�Z d<Z!e"j#j$Z%d=d>�e&j'j(�D�Z)d
S)DrzPython/rz	BaseHTTP/zHTTP/0.9cCs�d|_|j|_}d|_t|jd�}|jd�}||_|j�}t	|�dk�r|\}}}yZ|dd�dkrjt
�|jdd�d}|jd	�}t	|�d
kr�t
�t|d�t|d�f}Wn*t
tfk
r�|j
tjd|�d
SX|dkr�|jdkr�d
|_|dk�rr|j
tjd|�d
Sn^t	|�d
k�rR|\}}d|_|dk�rr|j
tjd|�d
Sn |�s\d
S|j
tjd|�d
S||||_|_|_|jjd��r�d|jjd�|_ytjj|j|jd�|_Wnrtjjk
�r�}z|j
tjdt|��d
Sd}~Xn:tjjk
�r4}z|j
tjdt|��d
Sd}~XnX|jjdd�}	|	j�dk�rZd|_n |	j�dk�rz|jdk�rzd
|_|jjdd�}
|
j�dk�r�|jdk�r�|jdk�r�|j ��s�d
SdS)NTz
iso-8859-1z
��zHTTP/�/r�.rrzBad request version (%r)FzHTTP/1.1zInvalid HTTP version (%s)ZGETzBad HTTP/0.9 request type (%r)zBad request syntax (%r)z//)Z_classz
Line too longzToo many headers�
Connection��closez
keep-aliveZExpectz100-continue)rr)rr)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�
startswith�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr&�wordsrr.Zbase_version_numberZversion_number�errZconntypeZexpectrrr�
parse_requests�












z$BaseHTTPRequestHandler.parse_requestcCs|jtj�|j�dS)NT)�send_response_onlyrZCONTINUE�end_headers)rrrrr8nsz(BaseHTTPRequestHandler.handle_expect_100cCs�y�|jjd�|_t|j�dkr@d|_d|_d|_|jtj	�dS|jsPd|_
dS|j�s\dSd|j}t||�s�|jtj
d|j�dSt||�}|�|jj�Wn4tjk
r�}z|jd|�d|_
dSd}~XnXdS)NiirTZdo_zUnsupported method (%r)zRequest timed out: %r)r3�readliner$r(r&r!rr,rZREQUEST_URI_TOO_LONGr"r<�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushr
Ztimeout�	log_error)rZmname�method�errr�handle_one_request�s4


z)BaseHTTPRequestHandler.handle_one_requestcCs&d|_|j�x|js |j�qWdS)NT)r"rH)rrrr�handle�szBaseHTTPRequestHandler.handleNcCs
y|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|jd||�|j||�|jdd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d�}|jd	d
�}|jd|j
�|jdtt|���|j�|jd
ko�|�r|jj|�dS)N�???zcode %d, message %srr��F)�quote)�code�message�explainzUTF-8�replacezContent-TypezContent-LengthZHEAD)rJrJ)�	responses�KeyErrorrE�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENTZNOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer#r(r>rrC�write)rrMrNrOZshortmsgZlongmsgZbodyZcontentrrrr,�s4
z!BaseHTTPRequestHandler.send_errorcCs:|j|�|j||�|jd|j��|jd|j��dS)NZServerZDate)�log_requestr=rT�version_string�date_time_string)rrMrNrrrrS�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|jjd|j||fjdd��dS)NzHTTP/0.9rr�_headers_bufferz
%s %d %s
zlatin-1�strict)r!rQr@r^�appendr-rX)rrMrNrrrr=�s


z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|jjd||fjdd��|j�dkrh|j�dkrVd|_n|j�d	krhd
|_dS)NzHTTP/0.9r^z%s: %s
zlatin-1r_Z
connectionrTz
keep-aliveF)r!r@r^r`rXr7r")r�keyword�valuerrrrT�s

z"BaseHTTPRequestHandler.send_headercCs"|jdkr|jjd�|j�dS)NzHTTP/0.9s
)r!r^r`�
flush_headers)rrrrr>s
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|jjdj|j��g|_dS)Nr^�)r@rCrZ�joinr^)rrrrrcs
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|jd|jt|�t|��dS)Nz
"%s" %s %s)�
isinstancerrb�log_messager&r#)rrM�sizerrrr[s
z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS)N)rh)r�format�argsrrrrE!sz BaseHTTPRequestHandler.log_errorcGs&tjjd|j�|j�||f�dS)Nz%s - - [%s] %s
)�sys�stderrrZ�address_string�log_date_time_string)rrjrkrrrrh/sz"BaseHTTPRequestHandler.log_messagecCs|jd|jS)N� )�server_version�sys_version)rrrrr\Esz%BaseHTTPRequestHandler.version_stringcCs |dkrtj�}tjj|dd�S)NT)Zusegmt)�time�emailZutilsZ
formatdate)rZ	timestamprrrr]Isz'BaseHTTPRequestHandler.date_time_stringc	CsBtj�}tj|�\	}}}}}}}}	}
d||j|||||f}|S)Nz%02d/%3s/%04d %02d:%02d:%02d)rsZ	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrroOs
z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)Nr)�client_address)rrrrrn]sz%BaseHTTPRequestHandler.address_stringzHTTP/1.0cCsi|]}|j|jf|�qSr)�phraseZdescription)�.0�vrrr�
<dictcomp>lsz!BaseHTTPRequestHandler.<dictcomp>)NN)N)N)rfrf)N)*rrrrlr9r'rr�__version__rq�DEFAULT_ERROR_MESSAGErU�DEFAULT_ERROR_CONTENT_TYPErYr r<r8rHrIr,rSr=rTr>rcr[rErhr\r]roZweekdaynamerurnr-r1r2ZHTTPMessager4r�__members__�valuesrQrrrrr�s<ig%
5



	c@sxeZdZdeZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zej
sVej�ejj�Zejddddd��dS)rzSimpleHTTP/c
Cs.|j�}|r*z|j||j�Wd|j�XdS)N)�	send_head�copyfilerCr)r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|j�}|r|j�dS)N)r�r)rr�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADc	Csx|j|j�}d}tjj|�r�tjj|j�}|jjd�s�|jt	j
�|d|d|dd|d|df}tjj|�}|jd|�|j
�dSx6dD]$}tjj||�}tjj|�r�|}Pq�W|j|�S|j|�}yt|d
�}Wn$tk
�r|jt	jd�dSXyZ|jt	j�|jd|�tj|j��}|jd
t|d��|jd|j|j��|j
�|S|j��YnXdS)Nrrrrr�ZLocation�
index.html�	index.htm�rbzFile not foundzContent-typezContent-Length�z
Last-Modified)r�r�)�translate_pathr.�os�isdir�urllib�parseZurlsplit�endswithrSrZMOVED_PERMANENTLYZ
urlunsplitrTr>re�exists�list_directory�
guess_type�open�OSErrorr,�	NOT_FOUND�OK�fstat�filenor#r]�st_mtimer)	rr.r��partsZ	new_partsZnew_url�indexZctypeZfsrrrr��sF


z"SimpleHTTPRequestHandler.send_headc
Cs�ytj|�}Wn"tk
r0|jtjd�dSX|jdd�d�g}ytjj	|j
dd�}Wn tk
r|tjj	|�}YnXtj
|dd�}tj�}d	|}|jd
�|jd�|jd|�|jd
|�|jd|�|jd�x~|D]v}tj
j||�}|}	}
tj
j|��r"|d}	|d}
tj
j|��r8|d}	|jdtjj|
dd�tj
|	dd�f�q�W|jd�dj|�j|d�}tj�}|j|�|jd�|jtj�|jdd|�|jdtt|���|j�|S)NzNo permission to list directorycSs|j�S)N)r7)�arrr�<lambda>�sz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass)�errorsF)rLzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperzContent-typeztext/html; charset=%szContent-Length) r��listdirr�r,rr��sortr�r��unquoter.�UnicodeDecodeErrorrVrWrl�getfilesystemencodingr`rer��islinkrLrX�io�BytesIOrZ�seekrSr�rTr#r(r>)
rr.�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr��s\







z'SimpleHTTPRequestHandler.list_directorycCs�|jdd�d}|jdd�d}|j�jd�}ytjj|dd�}Wn tk
rbtjj|�}YnXtj|�}|jd�}t	d|�}t
j�}x8|D]0}t
jj
|�s�|t
jt
jfkr�q�t
jj||�}q�W|r�|d7}|S)N�?rr�#rr�)r�)r'r%r�r�r�r�r��	posixpath�normpath�filterr��getcwdr.�dirname�curdir�pardirre)rr.Ztrailing_slashr:Zwordrrrr��s$	



z'SimpleHTTPRequestHandler.translate_pathcCstj||�dS)N)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�sz!SimpleHTTPRequestHandler.copyfilecCsLtj|�\}}||jkr"|j|S|j�}||jkr>|j|S|jdSdS)Nr)r��splitext�extensions_mapr7)rr.�baseZextrrrr�)s



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)rz.pyz.cz.hN)rrrrrqr�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��updaterrrrrrs 
	1:
c	Cs�|jd�\}}}tjj|�}|jd�}g}x<|dd�D],}|dkrN|j�q8|r8|dkr8|j|�q8W|r�|j�}|r�|dkr�|j�d}q�|dkr�d}nd}|r�dj||f�}ddj|�|f}dj|�}|S)Nr�rrz..rr���)�	partitionr�r�r�r'�popr`re)	r.�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_pathNs.


r�cCsptrtSyddl}Wntk
r(dSXy|jd�daWn.tk
rjdtdd�|j�D��aYnXtS)Nrr�nobodyrcss|]}|dVqdS)rNr)r|rvrrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>r�)r��pwd�ImportError�getpwnamrR�maxZgetpwall)r�rrr�
nobody_uid�s r�cCstj|tj�S)N)r��access�X_OK)r.rrr�
executable�sr�c@sReZdZeed�ZdZdd�Zdd�Zdd�Z	d	d
gZ
dd�Zd
d�Zdd�Z
dS)r�forkrcCs$|j�r|j�n|jtjd�dS)NzCan only POST to CGI scripts)�is_cgi�run_cgir,rrA)rrrr�do_POST�s

zCGIHTTPRequestHandler.do_POSTcCs|j�r|j�Stj|�SdS)N)r�r�rr�)rrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|jdd�}|d|�||dd�}}||jkrL||f|_dSdS)NrrTF)r�r.�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr��s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�S)N)r�)rr.rrr�
is_executable�sz#CGIHTTPRequestHandler.is_executablecCstjj|�\}}|j�dkS)N�.py�.pyw)r�r�)r�r.r�r7)rr.r�r�rrr�	is_python�szCGIHTTPRequestHandler.is_pythonc)Cs�|j\}}|d|}|jdt|�d�}x`|dkr�|d|�}||dd�}|j|�}tjj|�r�||}}|jdt|�d�}q,Pq,W|jd�\}}}	|jd�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|j|�}tjj|��s|j	t
jd|�dStjj|��s2|j	t
j
d|�dS|j|�}
|j�sL|
�rn|j|��sn|j	t
j
d|�dStjtj�}|j�|d	<|jj|d
<d|d<|j|d
<t|jj�|d<|j|d<tjj|�}||d<|j|�|d<||d<|	�r�|	|d<|jd|d<|jj d�}|�r�|j!�}t|�dk�r�ddl"}ddl#}|d|d<|dj$�dk�r�y"|dj%d�}|j&|�j'd�}Wn|j(t)fk
�r�Yn&X|j!d�}t|�dk�r�|d|d<|jj d�dk�r�|jj*�|d<n|jd|d<|jj d�}|�r||d<|jj d �}|�r"||d!<g}xN|jj+d"�D]>}|dd�d#k�rZ|j,|j-��n||d$d�j!d%�}�q4Wd%j.|�|d&<|jj d'�}|�r�||d(<t/d|jj0d)g��}d*j.|�}|�r�||d+<xd<D]}|j1|d��q�W|j2t
j3d-�|j4�|	j5d.d/�}|j�r.|
g}d0|k�r*|j,|�t6�}|j7j8�tj9�}|dk�r�tj:|d�\}}x0t;j;|j<gggd�d�r�|j<j=d��s^P�q^W|�r�|j>d1|�dSy\ytj?|�Wnt@k
�r�YnXtjA|j<jB�d�tjA|j7jB�d�tjC|||�Wn(|jjD|jE|j�tjFd2�YnX�n�ddlG} |g}!|j|��r�tHjI}"|"j$�jJd3��rv|"dd=�|"d>d�}"|"d6g|!}!d0|	k�r�|!j,|	�|jKd7| jL|!��ytM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d8�}$|jj$�d9k�r|#dk�r|j<j=|#�}%nd}%x4t;j;|j<jRgggd�d�rN|j<jRjSd��sP�qW|$jT|%�\}&}'|j7jU|&�|'�r||j>d:|'�|$jVjW�|$jXjW�|$jY}(|(�r�|j>d1|(�n
|jKd;�dS)?Nrrrr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationrZ	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE�REMOTE_HOSTzScript output follows�+rp�=zCGI script exit status %#x�zw.exerr�z-uzcommand: %s)�stdin�stdoutrm�envZpostz%szCGI script exited OK)r�r�r�r�r�r�������)Zr�r�r(r�r�r.r�r�r�r,rr��isfileZ	FORBIDDENr��	have_forkr�r��deepcopy�environr\Zserverrr-r#rrr�r�r�rzr5r6r'�base64�binasciir7rXZdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersr`�striprer�Zget_all�
setdefaultrSr�rcrPr�rCrDr��waitpid�selectr3�readrE�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessrlr�r�rhZlist2cmdliner*�	TypeErrorr)�Popen�PIPEZ_sockZrecvZcommunicaterZrmrr��
returncode))r�dir�restr.�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyr�Zuqrestr�rrZlengthr�r��lineZua�coZ
cookie_str�kZ
decoded_queryrkr��pid�stsrZcmdlineZinterp�nbytes�p�datar�rmZstatusrrrr��s4

























zCGIHTTPRequestHandler.run_cgiN)rrrr@r�r�Zrbufsizer�r�r�r�r�r�r�rrrrr�s
zHTTP/1.0i@rc	Cs�||f}||_|||��b}|jj�}d}t|j|d|dd��y|j�Wn&tk
rttd�tjd�YnXWdQRXdS)Nz>Serving HTTP on {host} port {port} (http://{host}:{port}/) ...rr)rrz&
Keyboard interrupt received, exiting.)	r-r
Zgetsockname�printrjZ
serve_forever�KeyboardInterruptrl�exit)	�HandlerClassZServerClassZprotocolr�bindrZhttpdZsaZ
serve_messagerrr�test�s
r$�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�default�metavarr(rZstorer�z&Specify alternate port [default: 8000])r'r)�type�nargsr()r"rr#).r�__all__Zemail.utilsrtrVZhttp.clientr1r�r�r�r�r	r�r
r	rlrsZurllib.parser�r��argparserr�r�r
rZStreamRequestHandlerrrr�r�r�r�rr$r�ArgumentParser�parser�add_argumentr*�
parse_argsrkZcgiZ
handler_classrr#rrrr�<module>Sshg]0
PKg�\�ǫ�a-a-cookies.cpython-36.opt-2.pycnu�[���3


 \�S�
@sxddlZddlZdddgZdjZdjZdjZdd	�ZGd
d�de�Z	ej
ejdZedZ
d
d�eed��eeee
��D�Zejed�ded�di�ejdeje��jZdd�Zejd�Zejd�Zdd�Zdddddd d!gZdd"d#d$d%d&d'd(d)d*d+d,d-g
Zdeefd.d/�ZGd0d1�d1e�Z d2Z!e!d3Z"ejd4e!d5e"d6ej#ej$B�Z%Gd7d�de�Z&Gd8d�de&�Z'dS)9�N�CookieError�
BaseCookie�SimpleCookie�z; � cCs$ddl}d|}|j|tdd�dS)NrzvThe .%s setter is deprecated. The attribute will be read-only in future releases. Please use the set() method instead.�)�
stacklevel)�warnings�warn�DeprecationWarning)�setterr	�msg�r�$/usr/lib64/python3.6/http/cookies.py�_warn_deprecated_setter�src@seZdZdS)rN)�__name__�
__module__�__qualname__rrrrr�sz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}d||�qS)z\%03or)�.0�nrrr�
<dictcomp>�sr��"z\"�\z\\z[%s]+cCs*|dkst|�r|Sd|jt�dSdS)Nr)�
_is_legal_key�	translate�_Translator)�strrrr�_quote�srz\\[0-3][0-7][0-7]z[\\].cCsT|dkst|�dkr|S|ddks0|ddkr4|S|dd�}d}t|�}g}x�d|kod|kn�rJtj||�}tj||�}|r�|r�|j||d��Pd	}}|r�|jd�}|r�|jd�}|o�|s�||k�r
|j|||��|j||d�|d}qR|j|||��|jtt||d|d�d���|d}qRWt|�S)
N�rr������r#r#)	�len�
_OctalPatt�search�
_QuotePatt�append�start�chr�int�	_nulljoin)r�ir�resZo_matchZq_match�j�krrr�_unquote�s6


$r1ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r3r2)ZfutureZweekdaynameZ	monthnamer2r3ZnowZyearZmonthZdayZhhZmmZssZwd�y�zrrr�_getdate�s
r6c	@s�eZdZddddddddd	�Zd
dhZdd
�Zedd��Zejdd��Zedd��Z	e	jdd��Z	edd��Z
e
jdd��Z
dd�Zd3dd�Zdd�Z
ejZdd�Zd d!�Zd"d#�Zefd$d%�Zd&d'�Zd(d)�Zd4d+d,�ZeZd-d.�Zd5d/d0�Zd6d1d2�ZdS)7�Morsel�expiresZPath�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersion)r8�path�commentZdomainzmax-age�secure�httponly�versionr<r=cCs4d|_|_|_x|jD]}tj||d�qWdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyrrr�__init__&szMorsel.__init__cCs|jS)N)r?)rErrrrF.sz
Morsel.keycCstd�||_dS)NrF)rr?)rErFrrrrF2scCs|jS)N)r@)rErrr�value7szMorsel.valuecCstd�||_dS)NrH)rr@)rErHrrrrH;scCs|jS)N)rA)rErrr�coded_value@szMorsel.coded_valuecCstd�||_dS)NrI)rrA)rErIrrrrIDscCs2|j�}||jkr td|f��tj|||�dS)NzInvalid attribute %r)�lowerrBrrCrD)rE�K�VrrrrDIs
zMorsel.__setitem__NcCs.|j�}||jkr td|f��tj|||�S)NzInvalid attribute %r)rJrBrrC�
setdefault)rErF�valrrrrMOs
zMorsel.setdefaultcCs>t|t�stStj||�o<|j|jko<|j|jko<|j|jkS)N)�
isinstancer7�NotImplementedrC�__eq__r@r?rA)rE�morselrrrrQUs
z
Morsel.__eq__cCs$t�}tj||�|jj|j�|S)N)r7rC�update�__dict__)rErRrrr�copy_szMorsel.copycCsVi}x@t|�j�D]0\}}|j�}||jkr:td|f��|||<qWtj||�dS)NzInvalid attribute %r)rC�itemsrJrBrrS)rE�values�datarFrNrrrrSes
z
Morsel.updatecCs|j�|jkS)N)rJrB)rErKrrr�
isReservedKeynszMorsel.isReservedKeycCsh|tkr ddl}|jdtdd�|j�|jkr<td|f��t|�sRtd|f��||_||_	||_
dS)NrzSLegalChars parameter is deprecated, ignored and will be removed in future versions.r)rz Attempt to set a reserved key %rzIllegal key %r)�_LegalCharsr	r
rrJrBrrr?r@rA)rErFrNZ	coded_valZ
LegalCharsr	rrr�setqsz
Morsel.setcCs|j|j|jd�S)N)rFrHrI)r?r@rA)rErrr�__getstate__�szMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrFrHrI)r?r@rA)rE�staterrr�__setstate__�s

zMorsel.__setstate__�Set-Cookie:cCsd||j|�fS)Nz%s %s)�OutputString)rE�attrs�headerrrr�output�sz
Morsel.outputcCsd|jj|j�fS)Nz<%s: %s>)�	__class__rr`)rErrr�__repr__�szMorsel.__repr__cCsd|j|�jdd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rz\")r`�replace)rErarrr�	js_output�szMorsel.js_outputcCs(g}|j}|d|j|jf�|dkr,|j}t|j��}x�|D]�\}}|dkrPq>||krZq>|dkr�t|t�r�|d|j|t|�f�q>|dkr�t|t�r�|d|j||f�q>|dkr�t|t	�r�|d|j|t
|�f�q>||jk�r|�r|t	|j|��q>|d|j||f�q>Wt|�S)Nz%s=%srr8zmax-agez%s=%dr;)
r(rFrIrB�sortedrVrOr+r6rr�_flags�_semispacejoin)rEra�resultr(rVrFrHrrrr`�s,zMorsel.OutputString)N)Nr_)N)N)rrrrBrirG�propertyrFrrHrIrDrMrQ�object�__ne__rUrSrYrZr[r\r^rc�__str__rergr`rrrrr7s>
	


r7z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@sjeZdZdd�Zdd�Zddd�Zdd	�Zd
d�Zddd�ZeZ	dd�Z
ddd�Zdd�Ze
fdd�ZdS)rcCs||fS)Nr)rErNrrr�value_decode�szBaseCookie.value_decodecCst|�}||fS)N)r)rErN�strvalrrr�value_encode�szBaseCookie.value_encodeNcCs|r|j|�dS)N)�load)rE�inputrrrrG�szBaseCookie.__init__cCs.|j|t��}|j|||�tj|||�dS)N)�getr7r[rCrD)rErFZ
real_valuerI�MrrrZ__set�szBaseCookie.__setcCs:t|t�rtj|||�n|j|�\}}|j|||�dS)N)rOr7rCrDrr�_BaseCookie__set)rErFrH�rval�cvalrrrrDs
zBaseCookie.__setitem__�Set-Cookie:�
cCs>g}t|j��}x"|D]\}}|j|j||��qW|j|�S)N)rhrVr(rc�join)rErarb�seprkrVrFrHrrrrc
s
zBaseCookie.outputcCsNg}t|j��}x(|D] \}}|jd|t|j�f�qWd|jjt|�fS)Nz%s=%sz<%s: %s>)rhrVr(�reprrHrdr�
_spacejoin)rE�lrVrFrHrrrres
zBaseCookie.__repr__cCs:g}t|j��}x |D]\}}|j|j|��qWt|�S)N)rhrVr(rgr,)rErarkrVrFrHrrrrgs
zBaseCookie.js_outputcCs8t|t�r|j|�nx|j�D]\}}|||<q WdS)N)rOr�_BaseCookie__parse_stringrV)rEZrawdatarFrHrrrrs&s

zBaseCookie.loadcCspd}t|�}g}d}d}d}�xd|ko2|kn�r|j||�}	|	sLP|	jd�|	jd�}
}|	jd�}|
ddkr�|s~q |j||
dd�|f�q |
j�tjkr�|s�dS|dkr�|
j�tjkr�|j||
df�q�dSn|j||
t	|�f�q |dk	�r|j||
|j
|�f�d}q dSq Wd}xF|D]>\}
}
}|
|k�rH|||
<n|\}}|j|
||�||
}�q*WdS)	NrFr rrFrN�$T)r$�match�group�endr(rJr7rBrir1rprw)rErZpattr-rZparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�rFrHrv�tprxryrrrZ__parse_string4sF



zBaseCookie.__parse_string)N)Nrzr{)N)rrrrprrrGrwrDrcrorergrs�_CookiePatternr�rrrrr�s		
	

c@seZdZdd�Zdd�ZdS)rcCst|�|fS)N)r1)rErNrrrrpxszSimpleCookie.value_decodecCst|�}|t|�fS)N)rr)rErNrqrrrrr{szSimpleCookie.value_encodeN)rrrrprrrrrrrqs)(�re�string�__all__r|r,rjrr�	ExceptionrZ
ascii_lettersZdigitsrZZ_UnescapedCharsr[�range�map�ordrrS�compile�escape�	fullmatchrrr%r'r1Z_weekdaynameZ
_monthnamer6rCr7Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrrrrr�<module>�sD
	

2J
PKg�\t�]�	�	�cookiejar.cpython-36.opt-2.pycnu�[���3

���ir+�@s&ddddddddgZdd	lZdd	lZdd	lZdd	lZdd	lZdd	lZydd	lZ	Wne
k
rldd	lZ	YnXdd	lZ
dd
lmZdZd	add
�Zee
jj�ZdZdd�ZdZdd�ZdddddddgZdddddd d!d"d#d$d%d&gZgZxeD]Zejej ��q�Wdtd'd(�Z!dud)d*�Z"d	d	d	d	d+�Z#ej$d,ej%�Z&d-d.�Z'd/d0�Z(ej$d1ej%�Z)ej$d2ej*ej%B�Z+ej$d3ej,ej%B�Z-d4d5�Z.ej$d6ej,ej%B�Z/d7d8�Z0d9d:�Z1ej$d;�Z2ej$d<�Z3ej$d=�Z4ej$d>�Z5d?d@�Z6ej$dA�Z7dBdC�Z8dDdE�Z9dFdG�Z:ej$dHej%�Z;dIdJ�Z<dKdL�Z=dMdN�Z>dOdP�Z?ej$dQej%�Z@dRdS�ZAdTdU�ZBdVdW�ZCdXdY�ZDdZZEej$d[�ZFd\d]�ZGd^d_�ZHd`da�ZIdbdc�ZJGddd�d�ZKGded�d�ZLGdfd�deL�ZMdgdh�ZNdidj�ZOGdkdl�dl�ZPGdmd�d�ZQGdnd�deR�ZSGdod�deQ�ZTdpdq�ZUGdrd�deT�ZVGdsd�deT�ZWd	S)v�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|jd�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�&/usr/lib64/python3.6/http/cookiejar.py�_debug.s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|j�}|jd|�|j�}|jd|dd�dS)Nr	zhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)rrr�f�msgrrr�_warn_unhandled_exception<s
ri�cCs�|dd�\}}}}}}|tkr�d|ko2dknr�d|koJdknr�d|kobdknr�d|kozdknr�d|ko�dknr�t|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmKs
8Hr,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtjj�}ntjj|�}d|j|j|j|j|j|jfS)Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second)�t�dtrrr�	time2isozYs
r5cCsR|dkrtjj�}ntjj|�}dt|j�|jt|jd|j|j	|j
|jfS)Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2)r3r4rrr�
time2netscapelsr8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTtj|�}|rfdt|jd��}|jd�rR|dt|jd��}|jd�dkrf|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s

rFc
Cs�t|�}|tjkrdSytj|j��d}WnXtk
r�yt|�}Wntk
r\dSXd|kopdknr||}ndSYnX|dkr�d}|dkr�d}|dkr�d}t|�}t|�}t|�}t|�}|dk�r0tjtj��d}|d}	|}
|||	}|	|
}	t	|	�dk�r0|	dk�r(|d}n|d}t
|||||||f�}|dk	�r�|dk�r^d}|j�}t|�}|dk�r|dS||}|S)Nrr r	i��d�2r9)
rAr-ZMAXYEAR�MONTHS_LOWER�index�lower�
ValueError�timeZ	localtime�absr,�upperrF)
r0�mon�yr�hrr*r+rCZimonZcur_yrrEZtmpr3rDrrr�	_str2time�sV







rSzV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
       \s*
    (?:\(\w+\))?       # ASCII representation of timezone in parens.
       \s*$cCs�tj|�}|rl|j�}tj|dj��d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|j	�}t
jd|d�}dgd\}}}}}}	}
tj|�}|dk	r�|j�\}}}}}}	}
ndSt
||||||	|
�S)	Nrrr	r;����)�STRICT_DATE_REr@�groupsrIrJrKrA�floatr,�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_RErS)�textrE�grPr&r0rQrRr*r+rCrrr�	http2time�s
"
raa�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   ([-+]?\d\d?:?(:?\d\d)?
    |Z|z)?               # timezone  (Z is "zero meridian", i.e. GMT)
      \s*$c
Csd|j�}dgd\}}}}}}}tj|�}|dk	rL|j�\}}}}}}}}	ndSt|||||||�S)NrW)r[�ISO_DATE_REr@rYrS)
r_r0rPrQrRr*r+rCrE�_rrr�iso2time's

rdcCs*|jd�\}}|jd|�|j|d�S)Nr	)�span�string)�match�start�endrrr�	unmatchedHsrjz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Csg}�x|D]�}|}g}x�|r�tj|�}|r�t|�}|jd�}tj|�}|rlt|�}|jd�}tjd|�}n.tj|�}|r�t|�}|jd�}|j�}nd}|j	||f�q|j
�jd�r�|j
�dd�}|r�|j	|�g}qtj
dd|�\}}	|}qW|r|j	|�qW|S)Nrz\1�,z^[=\s;]*rV)�HEADER_TOKEN_REr@rjrB�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr]�HEADER_VALUE_RE�rstrip�appendr[�
startswith�re�subn)
Z
header_values�resultr_Z	orig_text�pairsrE�name�valueZnon_junkZ
nr_junk_charsrrr�split_header_wordsQs>.







ryz([\"\\])cCs�g}xt|D]l}g}xN|D]F\}}|dk	rTtjd|�sHtjd|�}d|}d||f}|j|�qW|r
|jdj|��q
Wdj|�S)Nz^\w+$z\\\1z"%s"z%s=%sz; z, )rsr@�HEADER_JOIN_ESCAPE_REr]rq�join)Zlists�headersrv�attr�k�vrrr�join_header_words�s
r�cCs0|jd�r|dd�}|jd�r,|dd�}|S)N�"r���)rr�endswith)r_rrr�strip_quotes�s


r�cCsd}g}x�|D]�}g}d}x�t|jd	��D]�\}}|j�}|jd
�\}}	}
|j�}|sd|dkr*Pnq*|	rp|
j�nd}
|dkr�|j�}||kr�|}|dkr�|
dk	r�t|
�}
d}n|dkr�|
dk	r�tt|
��}
|j||
f�q*W|r|�s�|jd�|j|�qW|S)N�expires�domain�path�secure�version�port�max-ageF�;�=r	T�0)r�r�r�r�r�r�r�)r�r�)�	enumerate�split�strip�	partitionrKr�rarq)Z
ns_headersZknown_attrsruZ	ns_headerrv�version_setZiiZparam�key�sep�val�lcrrr�parse_ns_headers�s@

r�z\.\d+$cCs:tj|�rdS|dkrdS|ddks2|ddkr6dSdS)NFrVr	�.rTr�)�IPV4_REr@)r_rrr�is_HDNs
r�cCsl|j�}|j�}||krdSt|�s(dS|j|�}|dksB|dkrFdS|jd�sTdSt|dd��shdSdS)NTFrr	r�r�)rKr��rfindrr)�A�B�irrr�domain_matchs

r�cCstj|�rdSdS)NFT)r�r@)r_rrr�liberal_is_HDNBs
r�cCsb|j�}|j�}t|�ot|�s0||kr,dSdS|jd�}|rL|j|�rLdS|r^||kr^dSdS)NTFr�)rKr�rrr�)r�r��initial_dotrrr�user_domain_matchLs
r�z:\d+$cCsB|j�}tjj|�d}|dkr,|jdd�}tjd|d�}|j�S)NrrVZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer]rK)�request�url�hostrrr�request_hostasr�cCs6t|�}}|jd�dkr.tj|�r.|d}||fS)Nr�rz.localr�)r��findr�r@)r��erhn�req_hostrrr�eff_request_hostqsr�cCs4|j�}tjj|�}t|j�}|jd�s0d|}|S)N�/)r�r�r�Zurlsplit�escape_pathr�rr)r�r��partsr�rrr�request_path|s

r�cCs^|j}|jd�}|dkrV||dd�}yt|�WqZtk
rRtd|�dSXnt}|S)N�:r	rznonnumeric port: '%s')r�r�rArLr�DEFAULT_HTTP_PORT)r�r�r�r�rrr�request_port�s

r�z%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|jd�j�S)Nz%%%sr)rBrO)rgrrr�uppercase_escaped_char�sr�cCstjj|t�}tjt|�}|S)N)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr]r�)r�rrrr��s
r�cCsP|jd�}|dkrL||dd�}|jd�}t|�rL|dksD|dkrLd|S|S)Nr�r	rZlocal)r�r�)�hr��brrr�reach�s

r�cCs$t|�}t|t|j��sdSdSdS)NTF)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
r�c@sJeZdZddd�Zdd�Zddd�Zd	d
�Zddd�Zd
d�Zdd�Z	dS)rFcCs�|dk	rt|�}|dk	r$tt|��}|dkr<|dkr<td��||_||_||_||_||_|j�|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_tj|�|_dS)NTz-if port is None, port_specified must be false)rArZrLr�rwrxr��port_specifiedrKr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�rwrxr�r�r�r�r�r�r�r�r�r�r�r��restr�rrr�__init__�s.

zCookie.__init__cCs
||jkS)N)r�)r�rwrrr�has_nonstandard_attrszCookie.has_nonstandard_attrNcCs|jj||�S)N)r��get)r�rw�defaultrrr�get_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dS)N)r�)r�rwrxrrr�set_nonstandard_attrszCookie.set_nonstandard_attrcCs,|dkrtj�}|jdk	r(|j|kr(dSdS)NTF)rMr�)r��nowrrr�
is_expireds
zCookie.is_expiredcCsX|jdkrd}n
d|j}|j||j}|jdk	rFd|j|jf}n|j}d||fS)NrVr�z%s=%sz<Cookie %s for %s>)r�r�r�rxrw)r��p�limitZ	namevaluerrr�__str__%s


zCookie.__str__cCspg}x,dD]$}t||�}|jd|t|�f�q
W|jdt|j��|jdt|j��d|jjdj|�fS)Nr�rwrxr�r�r�r�r�r�r�r�r�r�r�r�z%s=%szrest=%sz
rfc2109=%sz%s(%s)z, )r�rwrxr�r�r�r�r�r�r�r�r�r�r�r�)�getattrrq�reprr�r��	__class__�__name__r{)r�rrwr}rrr�__repr__/s
zCookie.__repr__)F)N)N)
r��
__module__�__qualname__r�r�r�r�r�r�r�rrrrr�s
 


c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCs
t��dS)N)�NotImplementedError)r��cookier�rrr�set_okGszCookiePolicy.set_okcCs
t��dS)N)r�)r�r�r�rrr�	return_okPszCookiePolicy.return_okcCsdS)NTr)r�r�r�rrr�domain_return_okTszCookiePolicy.domain_return_okcCsdS)NTr)r�r�r�rrr�path_return_okYszCookiePolicy.path_return_okN)r�r�r�r�r�r�r�rrrrr>s		c@s�eZdZdZdZdZdZeeBZdddddddddeddfdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdS)6rrrrTr	NTFc

Csp||_||_||_||_||_||_|	|_|
|_||_||_	|dk	rPt
|�|_nf|_|dk	rft
|�}||_dS)N)
�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�tuple�_blocked_domains�_allowed_domains)
r��blocked_domains�allowed_domainsr�r�r�r�r�r�r�r�r�r�rrrr�is 
zDefaultCookiePolicy.__init__cCs|jS)N)r�)r�rrrr��sz#DefaultCookiePolicy.blocked_domainscCst|�|_dS)N)r�r�)r�r�rrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs"x|jD]}t||�rdSqWdS)NTF)r�r�)r�r�Zblocked_domainrrr�
is_blocked�s
zDefaultCookiePolicy.is_blockedcCs|jS)N)r�)r�rrrr��sz#DefaultCookiePolicy.allowed_domainscCs|dk	rt|�}||_dS)N)r�r�)r�r�rrr�set_allowed_domains�sz'DefaultCookiePolicy.set_allowed_domainscCs0|jdkrdSx|jD]}t||�rdSqWdS)NFT)r�r�)r�r�Zallowed_domainrrr�is_not_allowed�s

z"DefaultCookiePolicy.is_not_allowedcCsBtd|j|j�x,dD]$}d|}t||�}|||�sd	SqWd
S)Nz - checking cookie %s=%sr��
verifiabilityrwr�r�r�Zset_ok_FT)r�r�rwr�r�r�)rrwrxr�)r�r�r��n�fn_name�fnrrrr��s


zDefaultCookiePolicy.set_okcCs^|jdkrtd|j|j�dS|jdkr<|jr<td�dS|jdkrZ|jrZtd�dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	z$   RFC 2965 cookies are switched offz$   Netscape cookies are switched offT)r�rrwrxr�r�)r�r�r�rrr�set_ok_version�s
z"DefaultCookiePolicy.set_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS)Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT)�unverifiabler�r�r�rr�)r�r�r�rrr�set_ok_verifiability�sz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|jjd�r,td|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�r�rwrrr)r�r�r�rrr�set_ok_name�s
zDefaultCookiePolicy.set_ok_namecCsL|jrHt|�}|jdks(|jdkrH|jrH|j|j�rHtd|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�r�rrr�r)r�r�r��req_pathrrr�set_ok_path�s

zDefaultCookiePolicy.set_ok_pathc
Cs�|j|j�rtd|j�dS|j|j�r8td|j�dS|j�r�t|�\}}|j}|jr�|jd�dkr�|jd�}|jdd|�}|dkr�||dd�}||d|�}	|	j	�d$kr�t
|�dkr�td|�dS|jd��r�|dd�}
n|}
|
jd�dk}|�r|dk�rtd|�dS|j
dk�rb|j|��rb|jd��rbd|j|��rbtd ||�dS|j
dk�s||j|j@�r�t||��s�td!||�dS|j
dk�s�|j|j@�r�|dt
|��}|jd�dk�r�tj|��r�td"||�dSd#S)%Nz"   domain %s is in user block-listFz&   domain %s is not in user allow-listr�rr	r�co�ac�com�edu�org�net�gov�milrA�aero�biz�cat�coop�info�jobs�mobi�museumrw�pro�travel�euz&   country-code second level domain %sz.localz/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rrrrrrrrrArr	r
rrr
rrrwrrr)r�r�rr�r�r�r��countr�rK�lenrrr�r�r�r��DomainRFC2965Matchr��DomainStrictNoDotsr�r@)
r�r�r�r�r�r�r��jZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr�
set_ok_domain�sf

z!DefaultCookiePolicy.set_ok_domaincCs�|jr�t|�}|dkrd}nt|�}x\|jjd�D]:}yt|�Wntk
r`td|�dSX||kr2Pq2Wtd||j�dSdS)N�80rkz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)r�r��strr�r�rArLr)r�r�r��req_portr�rrr�set_ok_port%s"

zDefaultCookiePolicy.set_ok_portcCsBtd|j|j�x,dD]$}d|}t||�}|||�sd	SqWd
S)Nz - checking cookie %s=%sr�r�r�r�r�r�Z
return_ok_FT)r�r�r�r�r�r�)rrwrxr�)r�r�r�r�r�r�rrrr�:s	


zDefaultCookiePolicy.return_okcCs@|jdkr|jrtd�dS|jdkr<|jr<td�dSdS)Nr	z$   RFC 2965 cookies are switched offFz$   Netscape cookies are switched offT)r�r�rr�)r�r�r�rrr�return_ok_versionLsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS)Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT)r�r�r�r�rr�)r�r�r�rrr�return_ok_verifiabilityUsz+DefaultCookiePolicy.return_ok_verifiabilitycCs |jr|jdkrtd�dSdS)NZhttpsz(   secure cookie with non-secure requestFT)r��typer)r�r�r�rrr�return_ok_secureasz$DefaultCookiePolicy.return_ok_securecCs|j|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowr)r�r�r�rrr�return_ok_expiresgsz%DefaultCookiePolicy.return_ok_expirescCsP|jrLt|�}|dkrd}x0|jjd�D]}||kr(Pq(Wtd||j�dSdS)Nrrkz0   request port %s does not match cookie port %sFT)r�r�r�r)r�r�r�rr�rrr�return_ok_portms
z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r,|jd�r,d|}n|}|jdkrb|j|j@rb|jrb||krbtd�dS|jdkr�t||�r�td||�dS|jdkr�d|j	|�r�td||�dSdS)Nr�r	zQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sz;   request-host %s does not match Netscape cookie domain %sT)
r�r�rrr�r��DomainStrictNonDomainr�rr�r�)r�r�r�r�r�r��	dotdomainrrr�return_ok_domain{s&

z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|jd�sd|}|jd�s0d|}|rJ|jd�rJd|}n|}|j|�p`|j|�sfdS|j|�r~td|�dS|j|�r�td|�dSdS)Nr�Fz"   domain %s is in user block-listz&   domain %s is not in user allow-listT)r�rrr�r�rr�)r�r�r�r�r�r%rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCs0td|�t|�}|j|�s,td||�dSdS)Nz- checking cookie path=%sz  %s does not path-match %sFT)rr�rr)r�r�r�r�rrrr��s

z"DefaultCookiePolicy.path_return_ok)r�r�r�rr$rZ
DomainLiberalZDomainStrictr�r�r�r�r�r�r�r�r�r�r�r�rrr�rrr r"r#r&r�r�rrrrr_sJ	;	cCst|j��}t|j|�S)N)�sorted�keys�mapr�)Zadictr(rrr�vals_sorted_by_key�sr*ccsZt|�}xL|D]D}d}y
|jWntk
r4YnXd}t|�EdH|s|VqWdS)NFT)r*�items�AttributeError�
deepvalues)�mapping�values�objrrrr-�s

r-c@seZdZdS)�AbsentN)r�r�r�rrrrr1�sr1c@s�eZdZejd�Zejd�Zejd�Zejd�Zejd�Z	ejdej
�Zd2dd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd3d$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dS)4rz\Wz([\"\\])z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|dkrt�}||_tj�|_i|_dS)N)r�_policy�
_threading�RLock�
_cookies_lock�_cookies)r��policyrrrr��s

zCookieJar.__init__cCs
||_dS)N)r2)r�r7rrr�
set_policy�szCookieJar.set_policycCs�g}|jj||�sgStd|�|j|}xd|j�D]X}|jj||�sHq4||}x:|j�D].}|jj||�svtd�qZtd�|j|�qZWq4W|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r2r�rr6r(r�r/r�rq)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s 

zCookieJar._cookies_for_domaincCs.g}x$|jj�D]}|j|j||��qW|S)N)r6r(�extendr:)r�r�r9r�rrr�_cookies_for_request�szCookieJar._cookies_for_requestc	CsF|jdd�dd�d}g}�x$|D�]}|j}|sLd}|dkrL|jd|�|jdk	r~|jj|j�r~|dkr~|jjd|j�}n|j}|jdkr�|j|j�n|jd	|j|f�|dkr"|j	r�|jd
|j
�|jjd��r|j}|j
o�|jd��r|dd�}|jd
|�|jdk	r"d}|j�r4|d|j}|j|�q"W|S)NcSs
t|j�S)N)rr�)�arrr�<lambda>sz)CookieJar._cookie_attrs.<locals>.<lambda>T)r��reverseFr	z$Version=%sz\\\1z%s=%sz
$Path="%s"r�rz$Domain="%s"z$Portz="%s")�sortr�rqrx�non_word_rer@�quote_rer]rwr�r�r�rrr�r�r�)	r�r9r��attrsr�r�rxr�r�rrr�
_cookie_attrss>



zCookieJar._cookie_attrsc
Cs�td�|jj�z�ttj��|j_|_|j|�}|j|�}|r^|j	d�s^|j
ddj|��|jjr�|jj
r�|j	d�r�x$|D]}|jdkr�|j
dd�Pq�WWd|jj�X|j�dS)N�add_cookie_headerrz; ZCookie2rz$Version="1")rr5�acquirerArMr2r!r<rDZ
has_headerZadd_unredirected_headerr{r�r�r��release�clear_expired_cookies)r�r�r9rCr�rrrrE?s$






zCookieJar.add_cookie_headercCs�g}d}d}�x||D�]r}|d\}}d}d}	i}
i}�x4|d
d�D�]"\}}
|j�}||ksh||krl|}||kr�|
dkr�d}
||
kr�qF|dkr�|
dkr�td�d}	P|
j�}
|dkr�|r�qF|
dkr�td�qF|dk�rd}yt|
�}
Wn$tk
�rtd�d}	PYnXd}|j|
}
||k�s2||k�rb|
dk�rX|dk�rXtd|�d}	P|
|
|<qF|
||<qFW|	�rvq|j|||
|f�qW|S)Nr�r�r�r��max-ager�r�r�r��
commenturlr	FrTz%   missing value for domain attributezM   missing or invalid value for expires attribute: treating as session cookiez?   missing or invalid (non-numeric) value for max-age attributez!   missing value for %s attribute)r�r�)r�r�rIr�r�r�r�rJ)r�r�rJ)rKrrArLr!rq)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsrwrxZmax_age_setZ
bad_cookie�standardr�r~rr�rrr�_normalized_cookie_tuples`sl






z#CookieJar._normalized_cookie_tuplesc!Cs$|\}}}}|jdt�}|jdt�}|jdt�}	|jdt�}
|jdd�}|dk	rryt|�}Wntk
rpdSX|jdd�}|jdd�}
|jd	d�}|jd
d�}|tk	r�|dkr�d}t|�}nXd}t|�}|jd
�}|dk�r|dkr�|d|�}n|d|d�}t|�dk�rd
}|tk	}d}|�r8t|j	d��}|tk�rTt
|�\}}|}n|j	d��shd|}d}|	tk	�r�|	dk�r�t|�}	nd}tj
dd|	�}	nd}	|
tk�r�d}
d}
nH|
|jk�r�y|j|||�Wntk
�r�YnXtd|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rJrVTr�rr	r�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s'r�)r�r1rArLr�r�r�r�boolrrr�r�rsr]r!�clear�KeyErrorrr)r��tupr�rwrxrOr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�_cookie_from_cookie_tuple�s�








z#CookieJar._cookie_from_cookie_tuplecCs:|j|�}g}x&|D]}|j||�}|r|j|�qW|S)N)rPrUrq)r�rKr�rLr9rTr�rrr�_cookies_from_attrs_sets

z!CookieJar._cookies_from_attrs_setcCsLt|jdd�}|dkr |jj}x&|D]}|jdkr&d|_|r&d|_q&WdS)Nr�rTr	)r�r2r�r�r�)r�r9Z
rfc2109_as_nsr�rrr�_process_rfc2109_cookies&s


z"CookieJar._process_rfc2109_cookiesc
Cs6|j�}|jdg�}|jdg�}|jj}|jj}|r<|s`|rH|s`|rT|s`|rd|rdgSy|jt|�|�}Wntk
r�t�g}YnX|o�|�r2y|jt	|�|�}	Wntk
r�t�g}	YnX|j
|	�|�r"i}
x |D]}d|
|j|j|j
f<q�W|
fdd�}t||	�}	|	�r2|j|	�|S)NzSet-Cookie2z
Set-CookiecSs|j|j|jf}||kS)N)r�r�rw)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965^sz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)rZget_allr2r�r�rVry�	Exceptionrr�rWr�r�rw�filterr;)
r��responser�r|Zrfc2965_hdrsZns_hdrsr�r�r9Z
ns_cookiesrXr�rYrrr�make_cookies2sB






zCookieJar.make_cookiesc
CsN|jj�z2ttj��|j_|_|jj||�r:|j|�Wd|jj�XdS)N)	r5rFrArMr2r!r��
set_cookierG)r�r�r�rrr�set_cookie_if_okhs
zCookieJar.set_cookie_if_okc
Csl|j}|jj�zJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<Wd|jj�XdS)N)r6r5rFr�r�rwrG)r�r��cZc2Zc3rrrr^us






zCookieJar.set_cookiec
Cs|td|j��|jj�zRttj��|j_|_x6|j||�D]&}|jj	||�r>td|�|j
|�q>WWd|jj�XdS)Nzextract_cookies: %sz setting cookie: %s)rrr5rFrArMr2r!r]r�r^rG)r�r\r�r�rrr�extract_cookies�s

zCookieJar.extract_cookiescCst|dk	r2|dks|dkr td��|j|||=n>|dk	rX|dkrJtd��|j||=n|dk	rj|j|=ni|_dS)Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLr6)r�r�r�rwrrrrR�s
zCookieJar.clearcCsH|jj�z,x&|D]}|jr|j|j|j|j�qWWd|jj�XdS)N)r5rFr�rRr�r�rwrG)r�r�rrr�clear_session_cookies�s

zCookieJar.clear_session_cookiescCsT|jj�z8tj�}x*|D]"}|j|�r|j|j|j|j�qWWd|jj�XdS)N)	r5rFrMr�rRr�r�rwrG)r�r�r�rrrrH�s



zCookieJar.clear_expired_cookiescCs
t|j�S)N)r-r6)r�rrr�__iter__�szCookieJar.__iter__cCsd}x|D]}|d}q
W|S)Nr	rr)r�r�r�rrr�__len__�s
zCookieJar.__len__cCs6g}x|D]}|jt|��q
Wd|jjdj|�fS)Nz<%s[%s]>z, )rqr�r�r�r{)r��rr�rrrr��s
zCookieJar.__repr__cCs6g}x|D]}|jt|��q
Wd|jjdj|�fS)Nz<%s[%s]>z, )rqrr�r�r{)r�rer�rrrr��s
zCookieJar.__str__)N)NNN)!r�r�r�rs�compilerArBZstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�r8r:r<rDrErPrUrVrWr]r_r^rarRrbrHrcrdr�r�rrrrr�s6





;!a\	6


c@seZdZdS)rN)r�r�r�rrrrr�sc@s4eZdZddd�Zddd�Zd
dd�Zdd	d
�ZdS)rNFc	CsJtj||�|dk	r6y|dWntd��YnX||_t|�|_dS)NrVzfilename must be string-like)rr�rL�filenamerQ�	delayload)r�rirjr7rrrr��szFileCookieJar.__init__cCs
t��dS)N)r�)r�ri�ignore_discard�ignore_expiresrrr�save�szFileCookieJar.savecCsJ|dkr"|jdk	r|j}ntt��t|��}|j||||�WdQRXdS)N)rirL�MISSING_FILENAME_TEXT�open�_really_load)r�rirkrlrrrr�load�s

zFileCookieJar.loadcCs�|dkr"|jdk	r|j}ntt��|jj�zFtj|j�}i|_y|j|||�Wnt	k
rn||_�YnXWd|jj
�XdS)N)rirLrnr5rFr��deepcopyr6rq�OSErrorrG)r�rirkrlZ	old_staterrr�reverts

zFileCookieJar.revert)NFN)NFF)NFF)NFF)r�r�r�r�rmrqrtrrrrr�s



	cCs$|j|jfd|jfd|jfg}|jdk	r8|jd|jf�|jrH|jd
�|jrX|jd�|jrh|jd�|j	rx|jd�|j
r�|jdtt|j
��f�|j
r�|jd�|jr�|jd
|jf�|jr�|jd|jf�t|jj��}x$|D]}|j|t|j|�f�q�W|jdt|j�f�t|g�S)Nr�r�r��	path_spec�	port_spec�
domain_dotr�r�r�r�rJr�)ruN)rvN)rwN)r�N)r�N)rwrxr�r�r�rqr�r�r�r�r�r5rZr�r�r�r'r�r(rr�r�)r�r�r(r~rrr�lwp_cookie_strs6







rxc@s(eZdZd
dd�Zddd�Zdd	�ZdS)rTcCs\tj�}g}x>|D]6}|r$|jr$q|r6|j|�r6q|jdt|��qWdj|dg�S)NzSet-Cookie3: %s�
rV)rMr�r�rqrxr{)r�rkrlr�rer�rrr�
as_lwp_strGs
zLWPCookieJar.as_lwp_strNFcCsX|dkr"|jdk	r|j}ntt��t|d��"}|jd�|j|j||��WdQRXdS)N�wz#LWP-Cookies-2.0
)rirLrnro�writerz)r�rirkrlrrrrrmWs

zLWPCookieJar.savecCsL|j�}|jj|�s$d|}t|��tj�}d}d}	d}
�yʐx�|j�}|dkrRP|j|�s^q@|t|�d�j�}�x�t|g�D�]x}|d\}
}i}i}x|	D]}d||<q�Wx�|dd�D]t\}}|dk	r�|j	�}nd}||
k�s�||	k�r�|}||	k�r|dk�rd}|||<q�||
k�r*|||<q�|||<q�W|j
}|d�}|d�}|dk	�r^t|�}|dk�rld}|d�}|jd�}t|d�|
||d	�|d�|||d�|d
�|d�|d�|||d
�|d�|�}|�r�|j
�r�q�|�r�|j|��r�q�|j|�q�Wq@WWnBtk
�r�Yn,tk
�rFt�td||f��YnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:rvrurwr�r�r�r�r�r�r�r�rJrVr	FrTr�z&invalid Set-Cookie3 format file %r: %r)rvrurwr�r�)r�r�r�r�r�r�rJ)�readlinerhr@rrMrrrr�ryrKr�rdrr�r�r^rsrZr)r�rrirkrl�magicrr��headerrMrN�line�datarwrxrOr�r~rr�r�r�r�r�r�r`rrrrpcs�











zLWPCookieJar._really_load)TT)NFF)r�r�r�rzrmrprrrrr:s

c@s,eZdZejd�ZdZdd�Zd	dd�ZdS)
rz#( Netscape)? HTTP Cookie Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCsntj�}|j�}|jj|�s(td|���y�x�|j�}|dkr@P|jd�rV|dd�}|j�jd�s.|j�dkrrq.|jd�\}}	}
}}}
}|dk}|	dk}	|
dkr�|}
d}|jd	�}d
}|dkr�d}d}t	d|
|dd
||	||
d
|||ddi�}|�r|j
�rq.|�r|j|��rq.|j|�q.WWnBt
k
�r>�Yn,tk
�rht�td
||f��YnXdS)Nz4%r does not look like a Netscape format cookies filerVryr�#r��	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %rr�)r�r�)rMr}rhr@rr�r�rrr�rr�r�r^rsrZr)r�rrirkrlr�r~r�r�r�r�r�r�rwrxr�r�r`rrrrp�s`

zMozillaCookieJar._really_loadNFcCs|dkr"|jdk	r|j}ntt��t|d���}|j|j�tj�}x�|D]�}|rZ|jrZqH|rl|j|�rlqH|j	rxd}nd}|j
jd�r�d}nd}|jdk	r�t
|j�}	nd}	|jdkr�d}
|j}n|j}
|j}|jdj|j
||j||	|
|g�d�qHWWdQRXdS)Nr{r�ZFALSEr�rVr�ry)rirLrnror|rrMr�r�r�r�rrr�rrxrwr{r�)r�rirkrlrr�r�r�r�r�rwrxrrrrms<



zMozillaCookieJar.save)NFF)	r�r�r�rsrfrhrrprmrrrrr�s
A)N)N)X�__all__r�r-rsrMZurllib.parser�Zurllib.requestZ	threadingr3�ImportErrorZdummy_threadingZhttp.clientZhttpZcalendarr
rrrrZclientZ	HTTP_PORTr�rnrr%r,r6r7rIr(rqrKr5r8r>rfrgr?rFrSrX�Ir\�Xr^rarbrdrjrlrmrornryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr*r-r1rrsrrrxrrrrrr�<module>s�



88!



U
D'


#b!\:xPKg�\;mj�����cookiejar.cpython-36.pycnu�[���3

���ir+�@s*dZddddddddgZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZd	d
lZyd	d
l	Z
Wnek
rpd	d
lZ
YnXd	d
l
Zd	dlmZdZd
ad
d�Zeejj�ZdZdd�ZdZdd�ZdddddddgZddddd d!d"d#d$d%d&d'gZgZxeD]Zej ej!��q�Wdud(d)�Z"dvd*d+�Z#d
d
d
d
d,�Z$ej%d-ej&�Z'd.d/�Z(d0d1�Z)ej%d2ej&�Z*ej%d3ej+ej&B�Z,ej%d4ej-ej&B�Z.d5d6�Z/ej%d7ej-ej&B�Z0d8d9�Z1d:d;�Z2ej%d<�Z3ej%d=�Z4ej%d>�Z5ej%d?�Z6d@dA�Z7ej%dB�Z8dCdD�Z9dEdF�Z:dGdH�Z;ej%dIej&�Z<dJdK�Z=dLdM�Z>dNdO�Z?dPdQ�Z@ej%dRej&�ZAdSdT�ZBdUdV�ZCdWdX�ZDdYdZ�ZEd[ZFej%d\�ZGd]d^�ZHd_d`�ZIdadb�ZJdcdd�ZKGded�d�ZLGdfd�d�ZMGdgd�deM�ZNdhdi�ZOdjdk�ZPGdldm�dm�ZQGdnd�d�ZRGdod�deS�ZTGdpd�deR�ZUdqdr�ZVGdsd�deU�ZWGdtd�deU�ZXd
S)wa�HTTP cookie handling for web clients.

This module has (now fairly distant) origins in Gisle Aas' Perl module
HTTP::Cookies, from the libwww-perl library.

Docstrings, comments and debug strings in this code refer to the
attributes of the HTTP cookie system as cookie-attributes, to distinguish
them clearly from Python attributes.

Class diagram (note that BSDDBCookieJar and the MSIE* classes are not
distributed with the Python standard library, but are available from
http://wwwsearch.sf.net/):

                        CookieJar____
                        /     \      \
            FileCookieJar      \      \
             /    |   \         \      \
 MozillaCookieJar | LWPCookieJar \      \
                  |               |      \
                  |   ---MSIEBase |       \
                  |  /      |     |        \
                  | /   MSIEDBCookieJar BSDDBCookieJar
                  |/
               MSIECookieJar

�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|jd�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�&/usr/lib64/python3.6/http/cookiejar.py�_debug.s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|j�}|jd|�|j�}|jd|dd�dS)Nr	zhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)rrr�f�msgrrr�_warn_unhandled_exception<s
ri�cCs�|dd�\}}}}}}|tkr�d|ko2dknr�d|koJdknr�d|kobdknr�d|kozdknr�d|ko�dknr�t|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmKs
8Hr,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtjj�}ntjj|�}d|j|j|j|j|j|jfS)aHReturn a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
    representing Universal Time (UTC, aka GMT).  An example of this format is:

    1994-11-24 08:49:37Z

    Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second)�t�dtrrr�	time2isozYs
r5cCsR|dkrtjj�}ntjj|�}dt|j�|jt|jd|j|j	|j
|jfS)z�Return a string representing time in seconds since epoch, t.

    If the function is called without an argument, it will use the current
    time.

    The format of the returned string is like this:

    Wed, DD-Mon-YYYY HH:MM:SS GMT

    Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2)r3r4rrr�
time2netscapelsr8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTtj|�}|rfdt|jd��}|jd�rR|dt|jd��}|jd�dkrf|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s

rFc
Cs�t|�}|tjkrdSytj|j��d}WnXtk
r�yt|�}Wntk
r\dSXd|kopdknr||}ndSYnX|dkr�d}|dkr�d}|dkr�d}t|�}t|�}t|�}t|�}|dk�r0tjtj��d}|d}	|}
|||	}|	|
}	t	|	�dk�r0|	dk�r(|d}n|d}t
|||||||f�}|dk	�r�|dk�r^d}|j�}t|�}|dk�r|dS||}|S)Nrr r	i��d�2r9)
rAr-ZMAXYEAR�MONTHS_LOWER�index�lower�
ValueError�timeZ	localtime�absr,�upperrF)
r0�mon�yr�hrr*r+rCZimonZcur_yrrEZtmpr3rDrrr�	_str2time�sV







rSzV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
       \s*
    (?:\(\w+\))?       # ASCII representation of timezone in parens.
       \s*$cCs�tj|�}|rl|j�}tj|dj��d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|j	�}t
jd|d�}dgd	\}}}}}}	}
tj|�}|dk	r�|j�\}}}}}}	}
ndSt
||||||	|
�S)
a�Returns time in seconds since epoch of time represented by a string.

    Return value is an integer.

    None is returned if the format of str is unrecognized, the time is outside
    the representable range, or the timezone string is not recognized.  If the
    string contains no timezone, UTC is assumed.

    The timezone in the string may be numerical (like "-0800" or "+0100") or a
    string timezone (like "UTC", "GMT", "BST" or "EST").  Currently, only the
    timezone strings equivalent to UTC (zero offset) are known to the function.

    The function loosely parses the following formats:

    Wed, 09 Feb 1994 22:23:32 GMT       -- HTTP format
    Tuesday, 08-Feb-94 14:15:29 GMT     -- old rfc850 HTTP format
    Tuesday, 08-Feb-1994 14:15:29 GMT   -- broken rfc850 HTTP format
    09 Feb 1994 22:23:32 GMT            -- HTTP format (no weekday)
    08-Feb-94 14:15:29 GMT              -- rfc850 format (no weekday)
    08-Feb-1994 14:15:29 GMT            -- broken rfc850 format (no weekday)

    The parser ignores leading and trailing whitespace.  The time may be
    absent.

    If the year is given with only 2 digits, the function will select the
    century that makes the year closest to the current date.

    rrr	r;���N�)�STRICT_DATE_REr@�groupsrIrJrKrA�floatr,�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_RErS)�textrE�grPr&r0rQrRr*r+rCrrr�	http2time�s
"
raa�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   ([-+]?\d\d?:?(:?\d\d)?
    |Z|z)?               # timezone  (Z is "zero meridian", i.e. GMT)
      \s*$c
Csd|j�}dgd\}}}}}}}tj|�}|dk	rL|j�\}}}}}}}}	ndSt|||||||�S)av
    As for http2time, but parses the ISO 8601 formats:

    1994-02-03 14:15:29 -0100    -- ISO 8601 format
    1994-02-03 14:15:29          -- zone is optional
    1994-02-03                   -- only date
    1994-02-03T14:15:29          -- Use T as separator
    19940203T141529Z             -- ISO 8601 compact format
    19940203                     -- only date

    NrW)r[�ISO_DATE_REr@rYrS)
r_r0rPrQrRr*r+rCrE�_rrr�iso2time's

rdcCs*|jd�\}}|jd|�|j|d�S)z)Return unmatched part of re.Match object.r	N)�span�string)�match�start�endrrr�	unmatchedHsrjz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Cs<t|t�st�g}�x |D�]}|}g}x�|�r$tj|�}|r�t|�}|jd�}tj|�}|r�t|�}|jd�}tj	d|�}n.t
j|�}|r�t|�}|jd�}|j�}nd}|j||f�q,|j
�jd�r�|j
�dd�}|r�|j|�g}q,tjdd|�\}}	|	dk�std|||f��|}q,W|r|j|�qW|S)	amParse header values into a list of lists containing key,value pairs.

    The function knows how to deal with ",", ";" and "=" as well as quoted
    values after "=".  A list of space separated tokens are parsed as if they
    were separated by ";".

    If the header_values passed as argument contains multiple values, then they
    are treated as if they were a single value separated by comma ",".

    This means that this function is useful for parsing header fields that
    follow this syntax (BNF as from the HTTP/1.1 specification, but we relax
    the requirement for tokens).

      headers           = #header
      header            = (token | parameter) *( [";"] (token | parameter))

      token             = 1*<any CHAR except CTLs or separators>
      separators        = "(" | ")" | "<" | ">" | "@"
                        | "," | ";" | ":" | "\" | <">
                        | "/" | "[" | "]" | "?" | "="
                        | "{" | "}" | SP | HT

      quoted-string     = ( <"> *(qdtext | quoted-pair ) <"> )
      qdtext            = <any TEXT except <">>
      quoted-pair       = "\" CHAR

      parameter         = attribute "=" value
      attribute         = token
      value             = token | quoted-string

    Each header is represented by a list of key/value pairs.  The value for a
    simple token (not part of a parameter) is None.  Syntactically incorrect
    headers will not necessarily be parsed as you would want.

    This is easier to describe with some examples:

    >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz'])
    [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]]
    >>> split_header_words(['text/html; charset="iso-8859-1"'])
    [[('text/html', None), ('charset', 'iso-8859-1')]]
    >>> split_header_words([r'Basic realm="\"foo\bar\""'])
    [[('Basic', None), ('realm', '"foobar"')]]

    rz\1N�,z^[=\s;]*rVr	z&split_header_words bug: '%s', '%s', %s)�
isinstance�str�AssertionError�HEADER_TOKEN_REr@rjrB�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr]�HEADER_VALUE_RE�rstrip�appendr[�
startswith�re�subn)
Z
header_values�resultr_Z	orig_text�pairsrE�name�valueZnon_junkZ
nr_junk_charsrrr�split_header_wordsQsF-







r|z([\"\\])cCs�g}xt|D]l}g}xN|D]F\}}|dk	rTtjd|�sHtjd|�}d|}d||f}|j|�qW|r
|jdj|��q
Wdj|�S)a�Do the inverse (almost) of the conversion done by split_header_words.

    Takes a list of lists of (key, value) pairs and produces a single header
    value.  Attribute values are quoted if needed.

    >>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]])
    'text/plain; charset="iso-8859-1"'
    >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]])
    'text/plain, charset="iso-8859-1"'

    Nz^\w+$z\\\1z"%s"z%s=%sz; z, )rvr@�HEADER_JOIN_ESCAPE_REr]rt�join)Zlists�headersry�attr�k�vrrr�join_header_words�s
r�cCs0|jd�r|dd�}|jd�r,|dd�}|S)N�"r���)ru�endswith)r_rrr�strip_quotes�s


r�cCsd}g}x�|D]�}g}d}x�t|jd	��D]�\}}|j�}|jd
�\}}	}
|j�}|sd|dkr*Pnq*|	rp|
j�nd}
|dkr�|j�}||kr�|}|dkr�|
dk	r�t|
�}
d
}n|dkr�|
dk	r�tt|
��}
|j||
f�q*W|r|�s�|jd�|j|�qW|S)a5Ad-hoc parser for Netscape protocol cookie-attributes.

    The old Netscape cookie format for Set-Cookie can for instance contain
    an unquoted "," in the expires field, so we have to use this ad-hoc
    parser instead of split_header_words.

    XXX This may not make the best possible effort to parse all the crap
    that Netscape Cookie headers contain.  Ronald Tschalar's HTTPClient
    parser is probably better, so could do worse than following that if
    this ever gives any trouble.

    Currently, this is also used for parsing RFC 2109 cookies.

    �expires�domain�path�secure�version�port�max-ageF�;�=r	NT�0)r�r�r�r�r�r�r�)r�r�)�	enumerate�split�strip�	partitionrKr�rart)Z
ns_headersZknown_attrsrxZ	ns_headerry�version_setZiiZparam�key�sep�val�lcrrr�parse_ns_headers�s@

r�z\.\d+$cCs:tj|�rdS|dkrdS|ddks2|ddkr6dSdS)z*Return True if text is a host domain name.FrVr	�.rTr�)�IPV4_REr@)r_rrr�is_HDNs
r�cCsl|j�}|j�}||krdSt|�s(dS|j|�}|dksB|dkrFdS|jd�sTdSt|dd��shdSdS)a�Return True if domain A domain-matches domain B, according to RFC 2965.

    A and B may be host domain names or IP addresses.

    RFC 2965, section 1:

    Host names can be specified either as an IP address or a HDN string.
    Sometimes we compare one host name with another.  (Such comparisons SHALL
    be case-insensitive.)  Host A's name domain-matches host B's if

         *  their host name strings string-compare equal; or

         * A is a HDN string and has the form NB, where N is a non-empty
            name string, B has the form .B', and B' is a HDN string.  (So,
            x.y.com domain-matches .Y.com but not Y.com.)

    Note that domain-match is not a commutative operation: a.b.c.com
    domain-matches .c.com, but not the reverse.

    TFrr	r�Nr�)rKr��rfindru)�A�B�irrr�domain_matchs

r�cCstj|�rdSdS)zdReturn True if text is a sort-of-like a host domain name.

    For accepting/blocking domains.

    FT)r�r@)r_rrr�liberal_is_HDNBs
r�cCsb|j�}|j�}t|�ot|�s0||kr,dSdS|jd�}|rL|j|�rLdS|r^||kr^dSdS)z\For blocking/accepting domains.

    A and B may be host domain names or IP addresses.

    TFr�)rKr�rur�)r�r��initial_dotrrr�user_domain_matchLs
r�z:\d+$cCsB|j�}tjj|�d}|dkr,|jdd�}tjd|d�}|j�S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    rrVZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer]rK)�request�url�hostrrr�request_hostasr�cCs6t|�}}|jd�dkr.tj|�r.|d}||fS)zzReturn a tuple (request-host, effective request-host name).

    As defined by RFC 2965, except both are lowercased.

    r�rz.localr�)r��findr�r@)r��erhn�req_hostrrr�eff_request_hostqsr�cCs4|j�}tjj|�}t|j�}|jd�s0d|}|S)z6Path component of request-URI, as defined by RFC 2965.�/)r�r�r�Zurlsplit�escape_pathr�ru)r�r��partsr�rrr�request_path|s

r�cCs^|j}|jd�}|dkrV||dd�}yt|�WqZtk
rRtd|�dSXnt}|S)N�:r	rznonnumeric port: '%s')r�r�rArLr�DEFAULT_HTTP_PORT)r�r�r�r�rrr�request_port�s

r�z%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|jd�j�S)Nz%%%sr)rBrO)rgrrr�uppercase_escaped_char�sr�cCstjj|t�}tjt|�}|S)zEEscape any invalid characters in HTTP URL, and uppercase all escapes.)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr]r�)r�rrrr��s
r�cCsP|jd�}|dkrL||dd�}|jd�}t|�rL|dksD|dkrLd|S|S)aBReturn reach of host h, as defined by RFC 2965, section 1.

    The reach R of a host name H is defined as follows:

       *  If

          -  H is the host domain name of a host; and,

          -  H has the form A.B; and

          -  A has no embedded (that is, interior) dots; and

          -  B has at least one embedded dot, or B is the string "local".
             then the reach of H is .B.

       *  Otherwise, the reach of H is H.

    >>> reach("www.acme.com")
    '.acme.com'
    >>> reach("acme.com")
    'acme.com'
    >>> reach("acme.local")
    '.local'

    r�r	rNZlocal)r�r�)�hr��brrr�reach�s

r�cCs$t|�}t|t|j��sdSdSdS)z�

    RFC 2965, section 3.3.6:

        An unverifiable transaction is to a third-party host if its request-
        host U does not domain-match the reach R of the request-host O in the
        origin transaction.

    TFN)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
r�c@sNeZdZdZddd�Zdd�Zddd	�Zd
d�Zddd
�Zdd�Z	dd�Z
dS)ra�HTTP Cookie.

    This class represents both Netscape and RFC 2965 cookies.

    This is deliberately a very simple class.  It just holds attributes.  It's
    possible to construct Cookie instances that don't comply with the cookie
    standards.  CookieJar.make_cookies is the factory function for Cookie
    objects -- it deals with cookie parsing, supplying defaults, and
    normalising to the representation used in this class.  CookiePolicy is
    responsible for checking them to see whether they should be accepted from
    and returned to the server.

    Note that the port may be present in the headers, but unspecified ("Port"
    rather than"Port=80", for example); if this is the case, port is None.

    FcCs�|dk	rt|�}|dk	r$tt|��}|dkr<|dkr<td��||_||_||_||_||_|j�|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_tj|�|_dS)NTz-if port is None, port_specified must be false)rArZrLr�rzr{r��port_specifiedrKr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�rzr{r�r�r�r�r�r�r�r�r�r�r�r��restr�rrr�__init__�s.

zCookie.__init__cCs
||jkS)N)r�)r�rzrrr�has_nonstandard_attrszCookie.has_nonstandard_attrNcCs|jj||�S)N)r��get)r�rz�defaultrrr�get_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dS)N)r�)r�rzr{rrr�set_nonstandard_attrszCookie.set_nonstandard_attrcCs,|dkrtj�}|jdk	r(|j|kr(dSdS)NTF)rMr�)r��nowrrr�
is_expireds
zCookie.is_expiredcCsX|jdkrd}n
d|j}|j||j}|jdk	rFd|j|jf}n|j}d||fS)NrVr�z%s=%sz<Cookie %s for %s>)r�r�r�r{rz)r��p�limitZ	namevaluerrr�__str__%s


zCookie.__str__cCspg}x,dD]$}t||�}|jd|t|�f�q
W|jdt|j��|jdt|j��d|jjdj|�fS)Nr�rzr{r�r�r�r�r�r�r�r�r�r�r�r�z%s=%szrest=%sz
rfc2109=%sz%s(%s)z, )r�rzr{r�r�r�r�r�r�r�r�r�r�r�r�)�getattrrt�reprr�r��	__class__�__name__r~)r�rrzr�rrr�__repr__/s
zCookie.__repr__)F)N)N)r��
__module__�__qualname__�__doc__r�r�r�r�r�r�r�rrrrr�s
 


c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)ra Defines which cookies get accepted from and returned to server.

    May also modify cookies, though this is probably a bad idea.

    The subclass DefaultCookiePolicy defines the standard rules for Netscape
    and RFC 2965 cookies -- override that if you want a customized policy.

    cCs
t��dS)z�Return true if (and only if) cookie should be accepted from server.

        Currently, pre-expired cookies never get this far -- the CookieJar
        class deletes such cookies itself.

        N)�NotImplementedError)r��cookier�rrr�set_okGszCookiePolicy.set_okcCs
t��dS)zAReturn true if (and only if) cookie should be returned to server.N)r�)r�r�r�rrr�	return_okPszCookiePolicy.return_okcCsdS)zMReturn false if cookies should not be returned, given cookie domain.
        Tr)r�r�r�rrr�domain_return_okTszCookiePolicy.domain_return_okcCsdS)zKReturn false if cookies should not be returned, given cookie path.
        Tr)r�r�r�rrr�path_return_okYszCookiePolicy.path_return_okN)r�r�r�r�r�r�r�r�rrrrr>s
	c@s�eZdZdZdZdZdZdZeeBZdddddddddeddfd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�ZdS)7rzBImplements the standard rules for accepting and returning cookies.rrrTr	NTFc

Csp||_||_||_||_||_||_|	|_|
|_||_||_	|dk	rPt
|�|_nf|_|dk	rft
|�}||_dS)zAConstructor arguments should be passed as keyword arguments only.N)
�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�tuple�_blocked_domains�_allowed_domains)
r��blocked_domains�allowed_domainsr�r�r�r�r�r�r�r�r�r�rrrr�is 
zDefaultCookiePolicy.__init__cCs|jS)z4Return the sequence of blocked domains (as a tuple).)r�)r�rrrr��sz#DefaultCookiePolicy.blocked_domainscCst|�|_dS)z$Set the sequence of blocked domains.N)r�r�)r�r�rrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs"x|jD]}t||�rdSqWdS)NTF)r�r�)r�r�Zblocked_domainrrr�
is_blocked�s
zDefaultCookiePolicy.is_blockedcCs|jS)z=Return None, or the sequence of allowed domains (as a tuple).)r�)r�rrrr��sz#DefaultCookiePolicy.allowed_domainscCs|dk	rt|�}||_dS)z-Set the sequence of allowed domains, or None.N)r�r�)r�r�rrr�set_allowed_domains�sz'DefaultCookiePolicy.set_allowed_domainscCs0|jdkrdSx|jD]}t||�rdSqWdS)NFT)r�r�)r�r�Zallowed_domainrrr�is_not_allowed�s

z"DefaultCookiePolicy.is_not_allowedcCsPtd|j|j�|jdk	st�x,dD]$}d	|}t||�}|||�s$d
Sq$WdS)
z�
        If you override .set_ok(), be sure to call this method.  If it returns
        false, so should your subclass (assuming your subclass wants to be more
        strict about which cookies to accept).

        z - checking cookie %s=%sNr��
verifiabilityrzr�r�r�Zset_ok_FT)r�r�rzr�r�r�)rrzr{rnr�)r�r�r��n�fn_name�fnrrrr��s


zDefaultCookiePolicy.set_okcCs^|jdkrtd|j|j�dS|jdkr<|jr<td�dS|jdkrZ|jrZtd�dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	z$   RFC 2965 cookies are switched offz$   Netscape cookies are switched offT)r�rrzr{r�r�)r�r�r�rrr�set_ok_version�s
z"DefaultCookiePolicy.set_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS)Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT)�unverifiabler�r�r�rr�)r�r�r�rrr�set_ok_verifiability�sz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|jjd�r,td|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�r�rzrur)r�r�r�rrr�set_ok_name�s
zDefaultCookiePolicy.set_ok_namecCsL|jrHt|�}|jdks(|jdkrH|jrH|j|j�rHtd|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�r�rur�r)r�r�r��req_pathrrr�set_ok_path�s

zDefaultCookiePolicy.set_ok_pathc
Cs�|j|j�rtd|j�dS|j|j�r8td|j�dS|j�r�t|�\}}|j}|jr�|jd�dkr�|jd�}|jdd|�}|dkr�||dd�}||d|�}	|	j	�d$kr�t
|�dkr�td|�dS|jd��r�|dd�}
n|}
|
jd�dk}|�r|dk�rtd|�dS|j
dk�rb|j|��rb|jd��rbd|j|��rbtd ||�dS|j
dk�s||j|j@�r�t||��s�td!||�dS|j
dk�s�|j|j@�r�|dt
|��}|jd�dk�r�tj|��r�td"||�dSd#S)%Nz"   domain %s is in user block-listFz&   domain %s is not in user allow-listr�rr	r�co�ac�com�edu�org�net�gov�milrA�aero�biz�cat�coop�info�jobs�mobi�museumrz�pro�travel�euz&   country-code second level domain %sz.localz/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rrrrrr	r
rrArr
rrrrrrrzrrr)r�r�rr�r�r�r��countr�rK�lenrur�r�r�r��DomainRFC2965Matchr��DomainStrictNoDotsr�r@)
r�r�r�r�r�r�r��jZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr�
set_ok_domain�sf

z!DefaultCookiePolicy.set_ok_domaincCs�|jr�t|�}|dkrd}nt|�}x\|jjd�D]:}yt|�Wntk
r`td|�dSX||kr2Pq2Wtd||j�dSdS)N�80rkz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)r�r�rmr�r�rArLr)r�r�r��req_portr�rrr�set_ok_port%s"

zDefaultCookiePolicy.set_ok_portcCsBtd|j|j�x,dD]$}d|}t||�}|||�sd	SqWd
S)z�
        If you override .return_ok(), be sure to call this method.  If it
        returns false, so should your subclass (assuming your subclass wants to
        be more strict about which cookies to return).

        z - checking cookie %s=%sr�r�r�r�r�r�Z
return_ok_FT)r�r�r�r�r�r�)rrzr{r�)r�r�r�r�r�r�rrrr�:s	


zDefaultCookiePolicy.return_okcCs@|jdkr|jrtd�dS|jdkr<|jr<td�dSdS)Nr	z$   RFC 2965 cookies are switched offFz$   Netscape cookies are switched offT)r�r�rr�)r�r�r�rrr�return_ok_versionLsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdS)Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT)r�r�r�r�rr�)r�r�r�rrr�return_ok_verifiabilityUsz+DefaultCookiePolicy.return_ok_verifiabilitycCs |jr|jdkrtd�dSdS)NZhttpsz(   secure cookie with non-secure requestFT)r��typer)r�r�r�rrr�return_ok_secureasz$DefaultCookiePolicy.return_ok_securecCs|j|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowr)r�r�r�rrr�return_ok_expiresgsz%DefaultCookiePolicy.return_ok_expirescCsP|jrLt|�}|dkrd}x0|jjd�D]}||kr(Pq(Wtd||j�dSdS)Nrrkz0   request port %s does not match cookie port %sFT)r�r�r�r)r�r�r�rr�rrr�return_ok_portms
z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r,|jd�r,d|}n|}|jdkrb|j|j@rb|jrb||krbtd�dS|jdkr�t||�r�td||�dS|jdkr�d|j	|�r�td||�dSdS)Nr�r	zQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sz;   request-host %s does not match Netscape cookie domain %sT)
r�r�rur�r��DomainStrictNonDomainr�rr�r�)r�r�r�r�r�r��	dotdomainrrr�return_ok_domain{s&

z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|jd�sd|}|jd�s0d|}|rJ|jd�rJd|}n|}|j|�p`|j|�sfdS|j|�r~td|�dS|j|�r�td|�dSdS)Nr�Fz"   domain %s is in user block-listz&   domain %s is not in user allow-listT)r�rur�r�rr�)r�r�r�r�r�r(rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCs0td|�t|�}|j|�s,td||�dSdS)Nz- checking cookie path=%sz  %s does not path-match %sFT)rr�ru)r�r�r�rrrrr��s

z"DefaultCookiePolicy.path_return_ok) r�r�r�r�rr'rZ
DomainLiberalZDomainStrictr�r�r�r�r�r�r�r�r�r�rrrrr�r r!r#r%r&r)r�r�rrrrr_sL	;	cCst|j��}t|j|�S)N)�sorted�keys�mapr�)Zadictr+rrr�vals_sorted_by_key�sr-ccsZt|�}xL|D]D}d}y
|jWntk
r4YnXd}t|�EdH|s|VqWdS)zBIterates over nested mapping, depth-first, in sorted order by key.FTN)r-�items�AttributeError�
deepvalues)�mapping�values�objrrrr0�s

r0c@seZdZdS)�AbsentN)r�r�r�rrrrr4�sr4c@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ejdej�Zd3d	d
�Z
dd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd4d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z d1d2�Z!dS)5rz�Collection of HTTP cookies.

    You may not need to know about this class: try
    urllib.request.build_opener(HTTPCookieProcessor).open(url).
    z\Wz([\"\\])z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|dkrt�}||_tj�|_i|_dS)N)r�_policy�
_threading�RLock�
_cookies_lock�_cookies)r��policyrrrr��s

zCookieJar.__init__cCs
||_dS)N)r5)r�r:rrr�
set_policy�szCookieJar.set_policycCs�g}|jj||�sgStd|�|j|}xd|j�D]X}|jj||�sHq4||}x:|j�D].}|jj||�svtd�qZtd�|j|�qZWq4W|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r5r�rr9r+r�r2r�rt)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s 

zCookieJar._cookies_for_domaincCs.g}x$|jj�D]}|j|j||��qW|S)z2Return a list of cookies to be returned to server.)r9r+�extendr=)r�r�r<r�rrr�_cookies_for_request�szCookieJar._cookies_for_requestc	CsF|jdd�dd�d}g}�x$|D�]}|j}|sLd}|dkrL|jd|�|jdk	r~|jj|j�r~|dkr~|jjd	|j�}n|j}|jdkr�|j|j�n|jd
|j|f�|dkr"|j	r�|jd|j
�|jjd��r|j}|j
o�|jd��r|d
d�}|jd|�|jdk	r"d}|j�r4|d|j}|j|�q"W|S)z�Return a list of cookie-attributes to be returned to server.

        like ['foo="bar"; $Path="/"', ...]

        The $Version attribute is also added when appropriate (currently only
        once per request).

        cSs
t|j�S)N)rr�)�arrr�<lambda>sz)CookieJar._cookie_attrs.<locals>.<lambda>T)r��reverseFr	z$Version=%sNz\\\1z%s=%sz
$Path="%s"r�rz$Domain="%s"z$Portz="%s")�sortr�rtr{�non_word_rer@�quote_rer]rzr�r�r�rur�r�r�)	r�r<r��attrsr�r�r{r�r�rrr�
_cookie_attrss>



zCookieJar._cookie_attrsc
Cs�td�|jj�z�ttj��|j_|_|j|�}|j|�}|r^|j	d�s^|j
ddj|��|jjr�|jj
r�|j	d�r�x$|D]}|jdkr�|j
dd�Pq�WWd|jj�X|j�dS)z�Add correct Cookie: header to request (urllib.request.Request object).

        The Cookie2 header is also added unless policy.hide_cookie2 is true.

        �add_cookie_headerrz; ZCookie2rz$Version="1"N)rr8�acquirerArMr5r$r?rGZ
has_headerZadd_unredirected_headerr~r�r�r��release�clear_expired_cookies)r�r�r<rFr�rrrrH?s$






zCookieJar.add_cookie_headercCs�g}d}d}�x||D�]r}|d\}}d}d}	i}
i}�x4|d
d�D�]"\}}
|j�}||ksh||krl|}||kr�|
dkr�d}
||
kr�qF|dkr�|
dkr�td�d}	P|
j�}
|dkr�|r�qF|
dkr�td�qF|dk�rd}yt|
�}
Wn$tk
�rtd�d}	PYnXd}|j|
}
||k�s2||k�rb|
dk�rX|dk�rXtd|�d}	P|
|
|<qF|
||<qFW|	�rvq|j|||
|f�qW|S)aReturn list of tuples containing normalised cookie information.

        attrs_set is the list of lists of key,value pairs extracted from
        the Set-Cookie or Set-Cookie2 headers.

        Tuples are name, value, standard, rest, where name and value are the
        cookie name and value, standard is a dictionary containing the standard
        cookie-attributes (discard, secure, version, expires or max-age,
        domain, path and port) and rest is a dictionary containing the rest of
        the cookie-attributes.

        r�r�r�r��max-ager�r�r�r��
commenturlr	FrNTz%   missing value for domain attributezM   missing or invalid value for expires attribute: treating as session cookiez?   missing or invalid (non-numeric) value for max-age attributez!   missing value for %s attribute)r�r�)r�r�rLr�r�r�r�rM)r�r�rM)rKrrArLr$rt)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsrzr{Zmax_age_setZ
bad_cookie�standardr�r�r�r�rrr�_normalized_cookie_tuples`sl






z#CookieJar._normalized_cookie_tuplesc!Cs$|\}}}}|jdt�}|jdt�}|jdt�}	|jdt�}
|jdd�}|dk	rryt|�}Wntk
rpdSX|jdd�}|jdd�}
|jd	d�}|jd
d�}|tk	r�|dkr�d}t|�}nXd}t|�}|jd
�}|dk�r|dkr�|d|�}n|d|d�}t|�dk�rd
}|tk	}d}|�r8t|j	d��}|tk�rTt
|�\}}|}n|j	d��shd|}d}|	tk	�r�|	dk�r�t|�}	nd}tj
dd|	�}	nd}	|
tk�r�d}
d}
nH|
|jk�r�y|j|||�Wntk
�r�YnXtd|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rMrVTr�rr	r�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s'r�)r�r4rArLr�r�r�r�boolrur�r�rvr]r$�clear�KeyErrorrr)r��tupr�rzr{rRr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�_cookie_from_cookie_tuple�s�








z#CookieJar._cookie_from_cookie_tuplecCs:|j|�}g}x&|D]}|j||�}|r|j|�qW|S)N)rSrXrt)r�rNr�rOr<rWr�rrr�_cookies_from_attrs_sets

z!CookieJar._cookies_from_attrs_setcCsLt|jdd�}|dkr |jj}x&|D]}|jdkr&d|_|r&d|_q&WdS)Nr�rTr	)r�r5r�r�r�)r�r<Z
rfc2109_as_nsr�rrr�_process_rfc2109_cookies&s


z"CookieJar._process_rfc2109_cookiesc
Cs6|j�}|jdg�}|jdg�}|jj}|jj}|r<|s`|rH|s`|rT|s`|rd|rdgSy|jt|�|�}Wntk
r�t�g}YnX|o�|�r2y|jt	|�|�}	Wntk
r�t�g}	YnX|j
|	�|�r"i}
x |D]}d|
|j|j|j
f<q�W|
fdd�}t||	�}	|	�r2|j|	�|S)zAReturn sequence of Cookie objects extracted from response object.zSet-Cookie2z
Set-CookieNcSs|j|j|jf}||kS)N)r�r�rz)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965^sz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)rZget_allr5r�r�rYr|�	Exceptionrr�rZr�r�rz�filterr>)
r��responser�rZrfc2965_hdrsZns_hdrsr�r�r<Z
ns_cookiesr[r�r\rrr�make_cookies2sB






zCookieJar.make_cookiesc
CsN|jj�z2ttj��|j_|_|jj||�r:|j|�Wd|jj�XdS)z-Set a cookie if policy says it's OK to do so.N)	r8rIrArMr5r$r��
set_cookierJ)r�r�r�rrr�set_cookie_if_okhs
zCookieJar.set_cookie_if_okc
Csl|j}|jj�zJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<Wd|jj�XdS)z?Set a cookie, without checking whether or not it should be set.N)r9r8rIr�r�rzrJ)r�r��cZc2Zc3rrrraus






zCookieJar.set_cookiec
Cs|td|j��|jj�zRttj��|j_|_x6|j||�D]&}|jj	||�r>td|�|j
|�q>WWd|jj�XdS)zAExtract cookies from response, where allowable given the request.zextract_cookies: %sz setting cookie: %sN)rrr8rIrArMr5r$r`r�rarJ)r�r_r�r�rrr�extract_cookies�s

zCookieJar.extract_cookiescCst|dk	r2|dks|dkr td��|j|||=n>|dk	rX|dkrJtd��|j||=n|dk	rj|j|=ni|_dS)a�Clear some cookies.

        Invoking this method without arguments will clear all cookies.  If
        given a single argument, only cookies belonging to that domain will be
        removed.  If given two arguments, cookies belonging to the specified
        path within that domain are removed.  If given three arguments, then
        the cookie with the specified name, path and domain is removed.

        Raises KeyError if no matching cookie exists.

        Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLr9)r�r�r�rzrrrrU�s
zCookieJar.clearcCsH|jj�z,x&|D]}|jr|j|j|j|j�qWWd|jj�XdS)z�Discard all session cookies.

        Note that the .save() method won't save session cookies anyway, unless
        you ask otherwise by passing a true ignore_discard argument.

        N)r8rIr�rUr�r�rzrJ)r�r�rrr�clear_session_cookies�s

zCookieJar.clear_session_cookiescCsT|jj�z8tj�}x*|D]"}|j|�r|j|j|j|j�qWWd|jj�XdS)a�Discard all expired cookies.

        You probably don't need to call this method: expired cookies are never
        sent back to the server (provided you're using DefaultCookiePolicy),
        this method is called by CookieJar itself every so often, and the
        .save() method won't save expired cookies anyway (unless you ask
        otherwise by passing a true ignore_expires argument).

        N)	r8rIrMr�rUr�r�rzrJ)r�r�r�rrrrK�s



zCookieJar.clear_expired_cookiescCs
t|j�S)N)r0r9)r�rrr�__iter__�szCookieJar.__iter__cCsd}x|D]}|d}q
W|S)z#Return number of contained cookies.r	rr)r�r�r�rrr�__len__�s
zCookieJar.__len__cCs6g}x|D]}|jt|��q
Wd|jjdj|�fS)Nz<%s[%s]>z, )rtr�r�r�r~)r��rr�rrrr��s
zCookieJar.__repr__cCs6g}x|D]}|jt|��q
Wd|jjdj|�fS)Nz<%s[%s]>z, )rtrmr�r�r~)r�rhr�rrrr��s
zCookieJar.__str__)N)NNN)"r�r�r�r�rv�compilerDrEZstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�r;r=r?rGrHrSrXrYrZr`rbrardrUrerKrfrgr�r�rrrrr�s8





;!a\	6


c@seZdZdS)rN)r�r�r�rrrrr�sc@s8eZdZdZddd�Zd
dd�Zddd	�Zdd
d�ZdS)rz6CookieJar that can be loaded from and saved to a file.NFc	CsJtj||�|dk	r6y|dWntd��YnX||_t|�|_dS)z}
        Cookies are NOT loaded from the named file until either the .load() or
        .revert() method is called.

        NrVzfilename must be string-like)rr�rL�filenamerT�	delayload)r�rlrmr:rrrr��szFileCookieJar.__init__cCs
t��dS)zSave cookies to a file.N)r�)r�rl�ignore_discard�ignore_expiresrrr�save�szFileCookieJar.savecCsJ|dkr"|jdk	r|j}ntt��t|��}|j||||�WdQRXdS)zLoad cookies from a file.N)rlrL�MISSING_FILENAME_TEXT�open�_really_load)r�rlrnrorrrr�load�s

zFileCookieJar.loadcCs�|dkr"|jdk	r|j}ntt��|jj�zFtj|j�}i|_y|j|||�Wnt	k
rn||_�YnXWd|jj
�XdS)z�Clear all cookies and reload cookies from a saved file.

        Raises LoadError (or OSError) if reversion is not successful; the
        object's state will not be altered if this happens.

        N)rlrLrqr8rIr��deepcopyr9rt�OSErrorrJ)r�rlrnroZ	old_staterrr�reverts

zFileCookieJar.revert)NFN)NFF)NFF)NFF)r�r�r�r�r�rprtrwrrrrr�s


	cCs$|j|jfd|jfd|jfg}|jdk	r8|jd|jf�|jrH|jd�|jrX|jd�|jrh|jd�|j	rx|jd�|j
r�|jd	tt|j
��f�|j
r�|jd�|jr�|jd|jf�|jr�|jd|jf�t|jj��}x$|D]}|j|t|j|�f�q�W|jd
t|j�f�t|g�S)z�Return string representation of Cookie in the LWP cookie file format.

    Actually, the format is extended a bit -- see module docstring.

    r�r�Nr��	path_spec�	port_spec�
domain_dotr�r�r�r�rMr�)rxN)ryN)rzN)r�N)r�N)rzr{r�r�r�rtr�r�r�r�r�r5rZr�r�r�r*r�r+rmr�r�)r�r�r+r�rrr�lwp_cookie_strs6







r{c@s,eZdZdZddd�Zddd�Zd	d
�ZdS)
ra[
    The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
    "Set-Cookie3" is the format used by the libwww-perl library, not known
    to be compatible with any browser, but which is easy to read and
    doesn't lose information about RFC 2965 cookies.

    Additional methods

    as_lwp_str(ignore_discard=True, ignore_expired=True)

    TcCs\tj�}g}x>|D]6}|r$|jr$q|r6|j|�r6q|jdt|��qWdj|dg�S)z�Return cookies as a string of "\n"-separated "Set-Cookie3" headers.

        ignore_discard and ignore_expires: see docstring for FileCookieJar.save

        zSet-Cookie3: %s�
rV)rMr�r�rtr{r~)r�rnror�rhr�rrr�
as_lwp_strGs
zLWPCookieJar.as_lwp_strNFcCsX|dkr"|jdk	r|j}ntt��t|d��"}|jd�|j|j||��WdQRXdS)N�wz#LWP-Cookies-2.0
)rlrLrqrr�writer})r�rlrnrorrrrrpWs

zLWPCookieJar.savecCsL|j�}|jj|�s$d|}t|��tj�}d}d}	d}
�yʐx�|j�}|dkrRP|j|�s^q@|t|�d�j�}�x�t|g�D�]x}|d\}
}i}i}x|	D]}d||<q�Wx�|dd�D]t\}}|dk	r�|j	�}nd}||
k�s�||	k�r�|}||	k�r|dk�rd}|||<q�||
k�r*|||<q�|||<q�W|j
}|d�}|d�}|dk	�r^t|�}|dk�rld}|d�}|jd�}t|d�|
||d	�|d�|||d�|d
�|d�|d�|||d
�|d�|�}|�r�|j
�r�q�|�r�|j|��r�q�|j|�q�Wq@WWnBtk
�r�Yn,tk
�rFt�td||f��YnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:ryrxrzr�r�r�r�r�r�r�r�rMrVr	FrTr�z&invalid Set-Cookie3 format file %r: %r)ryrxrzr�r�)r�r�r�r�r�r�rM)�readlinerkr@rrMrurr�r|rKr�rdrr�r�rarvr]r)r�rrlrnro�magicrr��headerrPrQ�line�datarzr{rRr�r�r�r�r�r�r�r�r�rcrrrrscs�











zLWPCookieJar._really_load)TT)NFF)r�r�r�r�r}rprsrrrrr:s

c@s0eZdZdZejd�ZdZdd�Zd
dd	�Z	dS)ra�

    WARNING: you may want to backup your browser's cookies file if you use
    this class to save cookies.  I *think* it works, but there have been
    bugs in the past!

    This class differs from CookieJar only in the format it uses to save and
    load cookies to and from a file.  This class uses the Mozilla/Netscape
    `cookies.txt' format.  lynx uses this file format, too.

    Don't expect cookies saved while the browser is running to be noticed by
    the browser (in fact, Mozilla on unix will overwrite your saved cookies if
    you change them on disk while it's running; on Windows, you probably can't
    save at all while the browser is running).

    Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
    Netscape cookies on saving.

    In particular, the cookie version and port number information is lost,
    together with information about whether or not Path, Port and Discard were
    specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
    domain as set in the HTTP header started with a dot (yes, I'm aware some
    domains in Netscape files start with a dot and some don't -- trust me, you
    really don't want to know any more about this).

    Note that though Mozilla and Netscape use the same format, they use
    slightly different headers.  The class saves cookies using the Netscape
    header by default (Mozilla can cope with that).

    z#( Netscape)? HTTP Cookie Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCs|tj�}|j�}|jj|�s(td|���y
�x|j�}|dkrBP|jd�rX|dd�}|j�jd�s0|j�dkrtq0|jd�\}}	}
}}}
}|dk}|	dk}	|
dkr�|}
d}|jd	�}|	|ks�t	�d
}|dkr�d}d}t
d|
|dd
||	||
d
|||ddi�}|�r|j�rq0|�r$|j|��r$q0|j
|�q0WWnBtk
�rL�Yn,tk
�rvt�td
||f��YnXdS)Nz4%r does not look like a Netscape format cookies filerVr|r�#r�	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %rr�)r�r)rMr�rkr@rr�r�rur�rnrr�r�rarvr]r)r�rrlrnror�r�r�r�r�r�r�r�rzr{r�r�rcrrrrs�sb

zMozillaCookieJar._really_loadNFcCs|dkr"|jdk	r|j}ntt��t|d���}|j|j�tj�}x�|D]�}|rZ|jrZqH|rl|j|�rlqH|j	rxd}nd}|j
jd�r�d}nd}|jdk	r�t
|j�}	nd}	|jdkr�d}
|j}n|j}
|j}|jdj|j
||j||	|
|g�d�qHWWdQRXdS)Nr~r�ZFALSEr�rVr�r|)rlrLrqrrrr�rMr�r�r�r�rur�rmr{rzr~r�)r�rlrnrorr�r�r�r�r�rzr{rrrrps<



zMozillaCookieJar.save)NFF)
r�r�r�r�rvrirkr�rsrprrrrr�s

A)N)N)Yr��__all__r�r-rvrMZurllib.parser�Zurllib.requestZ	threadingr6�ImportErrorZdummy_threadingZhttp.clientZhttpZcalendarr
rrrrmZclientZ	HTTP_PORTr�rqrr%r,r6r7rIr(rtrKr5r8r>rirjr?rFrSrX�Ir\�Xr^rarbrdrjrorprrrqr|r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr-r0r4rrvrrr{rrrrrr�<module>s�



88!



U
D'


#b!\:xPKg�\:v~����client.cpython-36.pycnu�[���3

���i*��@srdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZdddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZe�jejj�dd�ejjj�D�ZdZdZd Zejd!�jZejd"�jZ ejd#�Z!ejd$�Z"d%d&d'hZ#dCd)d*�Z$Gd+d,�d,ej%j&�Z'd-d.�Z(e'fd/d0�Z)Gd1d�dej*�Z+Gd2d�d�Z,yddl-Z-Wne.k
�rlYnXGd3d4�d4e,�Z/ej0d4�Gd5d�de1�Z2Gd6d�de2�Z3Gd7d�de2�Z4Gd8d�de2�Z5Gd9d	�d	e2�Z6Gd:d
�d
e2�Z7Gd;d�de2�Z8Gd<d
�d
e2�Z9Gd=d�de9�Z:Gd>d�de9�Z;Gd?d�de9�Z<Gd@d�de2�Z=GdAd�de2�Z>GdBd�de?e=�Z@e2ZAdS)Da�
HTTP/1.1 client library

<intro stuff goes here>
<other stuff, too>

HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:

    (null)
      |
      | HTTPConnection()
      v
    Idle
      |
      | putrequest()
      v
    Request-started
      |
      | ( putheader() )*  endheaders()
      v
    Request-sent
      |\_____________________________
      |                              | getresponse() raises
      | response = getresponse()     | ConnectionError
      v                              v
    Unread-response                Idle
    [Response-headers-read]
      |\____________________
      |                     |
      | response.read()     | putrequest()
      v                     v
    Idle                  Req-started-unread-response
                     ______/|
                   /        |
   response.read() |        | ( putheader() )*  endheaders()
                   v        v
       Request-started    Req-sent-unread-response
                            |
                            | response.read()
                            v
                          Request-sent

This diagram presents the following rules:
  -- a second request may not be started until {response-headers-read}
  -- a response [object] cannot be retrieved until {request-sent}
  -- there is no differentiation between an unread response body and a
     partially read response body

Note: this enforcement is applied by the HTTPConnection class. The
      HTTPResponse class does not enforce this state machine, which
      implies sophisticated clients may accelerate the request/response
      pipeline. Caution should be taken, though: accelerating the states
      beyond the above pattern may imply knowledge of the server's
      connection-close behavior for certain requests. For example, it
      is impossible to tell whether the server will close the connection
      UNTIL the response headers have been read; this means that further
      requests cannot be placed into the pipeline until it is known that
      the server will NOT be closing the connection.

Logical State                  __state            __response
-------------                  -------            ----------
Idle                           _CS_IDLE           None
Request-started                _CS_REQ_STARTED    None
Request-sent                   _CS_REQ_SENT       None
Unread-response                _CS_IDLE           <response_class>
Req-started-unread-response    _CS_REQ_STARTED    <response_class>
Req-sent-unread-response       _CS_REQ_SENT       <response_class>
�N)�urlsplit�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}|j|�qS�)�phrase)�.0�vrr�#/usr/lib64/python3.6/http/client.py�
<dictcomp>ksrii�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUT�datacCsfy
|jd�Stk
r`}z:t|j|j|j|jd|j�||j|j�|f�d�WYdd}~XnXdS)z<Call data.encode("latin-1") but show a better error message.zlatin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.N)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s
r'c@seZdZdd�ZdS)�HTTPMessagecCsn|j�d}t|�}g}d}xL|j�D]@}|d|�j�|krDd}n|dd�j�sXd}|r&|j|�q&W|S)a�Find all header lines matching a given header name.

        Look through the list of headers and find all lines matching a given
        header name (and their continuation lines).  A list of the lines is
        returned, without interpretation.  If the header does not occur, an
        empty list is returned.  If the header occurs multiple times, all
        occurrences are returned.  Case is not important in the header name.

        �:rN�)�lower�len�keys�isspace�append)�selfr%�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r3rrrrr(�sr(cCs\g}xR|jtd�}t|�tkr(td��|j|�t|�tkrJtdt��|dkrPqW|S)z�Reads potential header lines into a list from a file pointer.

    Length of line is limited by _MAXLINE, and number of
    headers is limited by _MAXHEADERS.
    r*zheader linezgot more than %d headers�
�
�)r7r8r9)�readline�_MAXLINEr,rr/�_MAXHEADERSr)�fp�headersr2rrr�
_read_headers�s
r?cCs,t|�}dj|�jd�}tjj|d�j|�S)aGParses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.

    r9z
iso-8859-1)�_class)r?�join�decode�email�parserZParserZparsestr)r=r@r>Zhstringrrr�
parse_headers�s
rEcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdCd(d)�ZdEd*d+�ZdG�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdHd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)IrrNcCsR|jd�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)�makefiler=�
debuglevel�_methodr>�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r0�sockrH�method�urlrrr�__init__�szHTTPResponse.__init__cCst|jjtd�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��y|j
dd�\}}}WnFtk
r�y|j
dd�\}}d}Wntk
r�d}YnXYnX|jd	�s�|j
�t|��y$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr*z
iso-8859-1zstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr=r:r;r,rrH�print�reprr�split�
ValueError�
startswith�_close_connr�int)r0r2rLrMrNrrr�_read_statuss2

zHTTPResponse._read_statuscCs�|jdk	rdSx<|j�\}}}|tkr(Pt|j�}|jdkrFtd|�~qW||_|_|j	�|_
|dkrrd|_n|jd�r�d|_nt
|��t|j�|_|_|jdkr�x&|jD]}td|d	|jj|��q�W|jjd
�}|r�|j�dkr�d|_d|_nd
|_|j�|_d|_|jjd�}|jjd
�}|�rx|j�rxyt|�|_Wntk
�rbd|_YnX|jdk�r~d|_nd|_|tk�s�|tk�s�d|k�o�dkn�s�|jdk�r�d|_|j�r�|j�r�|jdk�r�d|_dS)Nrzheaders:�HTTP/1.0�HTTP/0.9�
zHTTP/1.�zheader:r)ztransfer-encodingrOTFzcontent-lengthr���HEAD)rbrc)r>raZCONTINUEr?r=rHrZ�coderM�striprNrLr^rrErJ�getr+rOrP�_check_closerRrQr`r]Z
NO_CONTENTZNOT_MODIFIEDrI)r0rLrMrNZskipped_headers�hdrZtr_encrQrrr�begin9s\









zHTTPResponse.begincCs�|jjd�}|jdkr:|jjd�}|r6d|j�kr6dSdS|jjd�rJdS|r^d|j�kr^dS|jjd�}|r~d|j�kr~dSdS)NZ
connectionre�closeTFz
keep-alivezproxy-connection)r>rjrLr+)r0ZconnZpconnrrrrk�s
zHTTPResponse._check_closecCs|j}d|_|j�dS)N)r=rn)r0r=rrrr_�szHTTPResponse._close_connc
s$zt�j�Wd|jr|j�XdS)N)�superrnr=r_)r0)�	__class__rrrn�szHTTPResponse.closecst�j�|jr|jj�dS)N)ro�flushr=)r0)rprrrq�s
zHTTPResponse.flushcCsdS)zAlways returns TrueTr)r0rrr�readable�szHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)r=)r0rrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|j�dS|dk	rRt|�}|j|�}t|�d|�j�S|jr`|j�S|j	dkrv|jj
�}n6y|j|j	�}Wntk
r�|j��YnXd|_	|j�|SdS)Nr9rgr)
r=rIr_�	bytearray�readinto�
memoryview�tobytesrO�_readall_chunkedrQ�read�
_safe_readr
)r0�amt�br1�srrrry�s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|j�dS|jr4|j|�S|jdk	r^t|�|jkr^t|�d|j�}|jj|�}|r~|r~|j�n&|jdk	r�|j|8_|js�|j�|S)z^Read up to len(b) bytes into bytearray b and return the number
        of bytes read.
        Nrrg)	r=rIr_rO�_readinto_chunkedrQr,rvru)r0r|r1rrrru�s$






zHTTPResponse.readintocCsp|jjtd�}t|�tkr$td��|jd�}|dkrB|d|�}y
t|d�Stk
rj|j��YnXdS)Nr*z
chunk size�;r�)	r=r:r;r,r�findr`r]r_)r0r2�irrr�_read_next_chunk_size
s

z"HTTPResponse._read_next_chunk_sizecCs>x8|jjtd�}t|�tkr&td��|s,P|dkrPqWdS)Nr*ztrailer line�
r8r9)r�r8r9)r=r:r;r,r)r0r2rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|jd�y|j�}Wntk
rDtd��YnX|dkrb|j�|j�d}||_|S)NrWr9r)rPrzr�r]r
r�r_)r0rPrrr�_get_chunk_left(s
zHTTPResponse._get_chunk_leftcCsr|jtkst�g}y8x,|j�}|dkr(P|j|j|��d|_qWdj|�Stk
rltdj|���YnXdS)Nrr9)	rOrK�AssertionErrorr�r/rzrPrAr
)r0�valuerPrrrrx@s

zHTTPResponse._readall_chunkedcCs�|jtkst�d}t|�}yvxp|j�}|dkr2|St|�|krZ|j|�}|||_||S|d|�}|j|�}||d�}||7}d|_qWWn(tk
r�tt	|d|����YnXdS)Nr)
rOrKr�rvr�r,�_safe_readintorPr
�bytes)r0r|�total_bytes�mvbrPr1�temp_mvbrrrr~Ns&


zHTTPResponse._readinto_chunkedcCsXg}xH|dkrL|jjt|t��}|s4tdj|�|��|j|�|t|�8}qWdj|�S)aVRead the number of bytes requested, compensating for partial reads.

        Normally, we have a blocking socket, but a read() can be interrupted
        by a signal (resulting in a partial read).

        Note that we cannot distinguish between EOF and an interrupt when zero
        bytes have been read. IncompleteRead() will be raised in this
        situation.

        This function should be used when <amt> bytes "should" be present for
        reading. If the bytes are truly not available (due to EOF), then the
        IncompleteRead exception can be used to detect the problem.
        rr9)r=ry�min�	MAXAMOUNTr
rAr/r,)r0r{r}�chunkrrrrzfs

zHTTPResponse._safe_readcCs�d}t|�}xt|t|�kr�tt|�kr@|dt�}|jj|�}n|jj|�}|sjtt|d|��t|���||d�}||7}qW|S)z2Same as _safe_read, but for reading into a buffer.rN)rvr,r�r=rur
r�)r0r|r�r�r�r1rrrr�}szHTTPResponse._safe_readintor*cCs�|jdks|jdkrdS|jr(|j|�S|jdk	rJ|dksD||jkrJ|j}y|jj|�}Wn*tk
r�|dkrt�|jjd�}YnX|r�|r�|j�n|jdk	r�|jt|�8_|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        Nrgr9rr�ii@)	r=rIrO�_read1_chunkedrQ�read1r]r_r,)r0r1�resultrrrr��s"



zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|j|�S|jj|�S)Nrgr9)r=rIrO�
_peek_chunked�peek)r0r1rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t�j|�S|jdk	rL|dksF||jkrL|j}|jj|�}|rl|rl|j�n|jdk	r�|jt|�8_|S)Nrgr9r)r=rIrOror:rQr_r,)r0�limitr�)rprrr:�s


zHTTPResponse.readlinecCsf|j�}|dks|dkrdSd|ko.|kns8|}|jj|�}|jt|�8_|sbtd��|S)Nrr9)r�r=r�rPr,r
)r0r1rPryrrrr��szHTTPResponse._read1_chunkedcCsBy|j�}Wntk
r dSX|dkr.dS|jj|�d|�S)Nr9)r�r
r=r�)r0r1rPrrrr��szHTTPResponse._peek_chunkedcCs
|jj�S)N)r=�fileno)r0rrrr��szHTTPResponse.filenocCsH|jdkrt��|jj|�p|}t|t�s6t|d�r:|Sdj|�SdS)axReturns the value of the header matching *name*.

        If there are multiple matching headers, the values are
        combined into a single string separated by commas and spaces.

        If no matching header is found, returns *default* or None if
        the *default* is not specified.

        If the headers are unknown, raises http.client.ResponseNotReady.

        N�__iter__z, )r>rZget_all�
isinstancerY�hasattrrA)r0r%�defaultr>rrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|jj��S)z&Return list of (header, value) tuples.N)r>r�list�items)r0rrr�
getheaders�s
zHTTPResponse.getheaderscCs|S)Nr)r0rrrr��szHTTPResponse.__iter__cCs|jS)ajReturns an instance of the class mimetools.Message containing
        meta-information associated with the URL.

        When the method is HTTP, these headers are those returned by
        the server at the head of the retrieved HTML page (including
        Content-Length and Content-Type).

        When the method is FTP, a Content-Length header will be
        present if (as is now usual) the server passed back a file
        length in response to the FTP retrieval request. A
        Content-Type header will be present if the MIME type can be
        guessed.

        When the method is local-file, returned headers will include
        a Date representing the file's last-modified time, a
        Content-Length giving file size, and a Content-Type
        containing a guess at the file's type. See also the
        description of the mimetools module.

        )r>)r0rrr�info�szHTTPResponse.infocCs|jS)aZReturn the real URL of the page.

        In some cases, the HTTP server redirects a client to another
        URL. The urlopen() function handles this transparently, but in
        some cases the caller needs to know which URL the client was
        redirected to. The geturl() method can be used to get at this
        redirected URL.

        )rU)r0rrr�geturls
zHTTPResponse.geturlcCs|jS)zuReturn the HTTP status code that was sent with the response,
        or None if the URL is not an HTTP URL.

        )rM)r0rrr�getcodeszHTTPResponse.getcode)rNN)N���)r�r�)r�r�)r�)N)"r4r5r6rVrarmrkr_rnrqrrrsryrur�r�r�rxr~rzr�r�r�r:r�r�r�r�r�r�r�r�r��
__classcell__rr)rprr�s<	
!K

 "

	

c@s�eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	fd
d�Zd0dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd1dd �Zd2d!d"�Zd#d$�Zd%d&�Zd3dd'�d(d)�Zd	ifdd'�d*d+�Zd,d-�Z d.d/�Z!d	S)4rrezHTTP/1.1r*rcCst|tj�S)zFTest whether a file-like object is a text or a binary stream.
        )r��io�
TextIOBase)�streamrrr�
_is_textIO0szHTTPConnection._is_textIOcCsd|dkr|j�tkrdSdSt|d�r*dSyt|�}|jStk
rLYnXt|t�r`t|�SdS)aGet the content-length based on the body.

        If the body is None, we set Content-Length: 0 for methods that expect
        a body (RFC 7230, Section 3.3.2). We also set the Content-Length for
        any method if the body is a str or bytes-like object and not a file.
        Nrry)	�upper�_METHODS_EXPECTING_BODYr�rv�nbytes�	TypeErrorr�rYr,)�bodyrTZmvrrr�_get_content_length6s

z"HTTPConnection._get_content_lengthNcCs\||_||_d|_g|_d|_t|_d|_d|_d|_	i|_
|j||�\|_|_
tj|_dS)N)�timeout�source_addressrS�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterI�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�socketZcreate_connection�_create_connection)r0r�r�r�r�rrrrVVszHTTPConnection.__init__cCs<|jrtd��|j||�\|_|_|r.||_n
|jj�dS)aDSet up host and port for HTTP CONNECT tunnelling.

        In a connection that uses HTTP CONNECT tunneling, the host passed to the
        constructor is used as a proxy server that relays all communication to
        the endpoint passed to `set_tunnel`. This done by sending an HTTP
        CONNECT request to the proxy server when the connection is established.

        This method must be called before the HTML connection has been
        established.

        The headers argument should be a mapping of extra HTTP headers to send
        with the CONNECT request.
        z.Can't set up tunnel for established connectionN)rS�RuntimeErrorr�r�r�r��clear)r0r�r�r>rrr�
set_tunneliszHTTPConnection.set_tunnelcCs�|dkr�|jd�}|jd�}||kr�yt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd	�}||fS)
Nr)�]r*rXznonnumeric port: '%s'r�[r�r�)�rfindr`r]�default_portr)r0r�r�r��jrrrr��s

zHTTPConnection._get_hostportcCs
||_dS)N)rH)r0�levelrrr�set_debuglevel�szHTTPConnection.set_debuglevelcCsd|j|jf}|jd�}|j|�x6|jj�D](\}}d||f}|jd�}|j|�q0W|jd�|j|j|jd�}|j	�\}}	}
|	t
jjkr�|j
�td|	|
j�f��xP|jjtd�}t|�tkr�td	��|s�P|dkr�P|jdkr�td
|j��q�WdS)NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
zlatin-1�
)rTzTunnel connection failed: %d %sr*zheader liner8r9rzheader:)r�r8r9)r�r�r�sendr�r��response_classrSrIra�http�
HTTPStatusZOKrn�OSErrorrir=r:r;r,rrHrZrB)r0Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserLrh�messager2rrr�_tunnel�s2





zHTTPConnection._tunnelcCsB|j|j|jf|j|j�|_|jjtjtj	d�|j
r>|j�dS)z3Connect to the host and port specified in __init__.r*N)r�r�r�r�r�rSZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�)r0rrr�connect�s
zHTTPConnection.connectcCsBt|_z|j}|r d|_|j�Wd|j}|r<d|_|j�XdS)z(Close the connection to the HTTP server.N)r�r�rSrnr�)r0rSr�rrrrn�szHTTPConnection.closecCs|jdkr |jr|j�nt��|jdkr8tdt|��d}t|d�r�|jdkrXtd�|j|�}|rx|jdkrxtd�x.|j	|�}|s�P|r�|j
d�}|jj|�qzWdSy|jj|�WnNtk
�r
t
|tj�r�x*|D]}|jj|�q�Wntd	t|���YnXdS)
z�Send `data' to the server.
        ``data`` can be a string object, a bytes object, an array object, a
        file-like object that supports a .read() method, or an iterable object.
        Nrzsend:i ryzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1z9data should be a bytes-like object or an iterable, got %r)rS�	auto_openr�rrHrZr[r�r�ryrZsendallr�r��collections�Iterable�type)r0r�	blocksizer�	datablock�drrrr��s:








zHTTPConnection.sendcCs|jj|�dS)zuAdd a line of output to the current request buffer.

        Assumes that the line does *not* end with \r\n.
        N)r�r/)r0r}rrr�_output�szHTTPConnection._outputccsdd}|jdkrtd�|j|�}|r6|jdkr6td�x(|j|�}|sHP|rV|jd�}|Vq8WdS)Ni rzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1)rHrZr�ryr)r0rrr�rr�rrr�_read_readable�s



zHTTPConnection._read_readableFcCs$|jjd
�dj|j�}|jdd�=|j|�|dk	�r t|d�rN|j|�}nZyt|�WnFtk
r�yt|�}Wn$tk
r�tdt	|���YnXYnX|f}xZ|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d	�d
�jd�|d}|j|�q�W|�r |jdk�r |jd�dS)z�Send the currently buffered request and clear the buffer.

        Appends an extra \r\n to the buffer.
        A message_body may be specified, to be appended to the request.
        r9s
NryzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredre�Xz
r�s0

)r9r9)r��extendrAr�r�r�rvr��iterr�rHrZ�	_http_vsnr,r)r0�message_body�encode_chunkedrJZchunksr�rrr�_send_outputs4




zHTTPConnection._send_outputc

Cs�|jr|jj�rd|_|jtkr(t|_n
t|j��|j|�||_|sJd}tj	|�}|rrt
d|�d|j��d���d|||jf}|j
|jd��|jdk�r�|�s�d	}|jd
�r�t|�\}}}}}|�ry|jd�}	Wntk
r�|jd�}	YnX|jd|	�n�|j�r|j}
|j}n|j}
|j}y|
jd�}Wn tk
�rV|
jd�}YnX|
jd
�dk�rtd|d}||jk�r�|jd|�n|jd�}|jdd||f�|�s�|jdd�ndS)a`Send a request to the server.

        `method' specifies an HTTP request method, e.g. 'GET'.
        `url' specifies the object being requested, e.g. '/index.html'.
        `skip_host' if True does not add automatically a 'Host:' header
        `skip_accept_encoding' if True does not add automatically an
           'Accept-Encoding:' header
        N�/z&URL can't contain control characters. z (found at least �)z%s %s %sr�rerXr�ZidnaZHostr)r�[�]z%s:%szAccept-EncodingZidentity)r�rsr�r��_CS_REQ_STARTEDr
�_validate_methodrI�!_contains_disallowed_url_pchar_re�searchr�group�
_http_vsn_strr�rr�r^rr�	putheaderr�r�r�r�r�r�rB)
r0rTrU�	skip_host�skip_accept_encoding�match�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequestAsV






zHTTPConnection.putrequestcCs,tj|�}|r(td|�d|j��d���dS)z&Validate a method name for putrequest.z)method can't contain control characters. z (found at least r�N)�$_contains_disallowed_method_pchar_rer�r]r�)r0rTr�rrrr��s
zHTTPConnection._validate_methodcGs�|jtkrt��t|d�r$|jd�}t|�s:td|f��t|�}xht|�D]\\}}t|d�rn|jd�||<nt	|t
�r�t|�jd�||<t||�rLtd||f��qLWdj
|�}|d|}|j|�dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        rr�zInvalid header name %rzlatin-1zInvalid header value %rs
	s: N)r�r�rr�r�_is_legal_header_namer]r��	enumerater�r`rY�_is_illegal_header_valuerAr�)r0r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader)r�cCs*|jtkrt|_nt��|j||d�dS)z�Indicate that the last header line has been sent to the server.

        This method sends the request to the server.  The optional message_body
        argument can be used to pass a message body associated with the
        request.
        )r�N)r�r��_CS_REQ_SENTrr�)r0r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|j|||||�dS)z&Send a complete request to the server.N)�
_send_request)r0rTrUr�r>r�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|j||�}|dkr�|dk	r�|jdkr�td|�d
}|jdd�q�|jdt|��nd
}x |j�D]\}	}
|j|	|
�q�Wt|t�r�t	|d�}|j
||d�dS)Ncss|]}|j�VqdS)N)r+)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r*r�zaccept-encodingr�zcontent-lengthztransfer-encodingFrzUnable to determine size of %rTzTransfer-EncodingrOzContent-Lengthr�)r�)�	frozensetr�r�rHrZr�rYr�r�r'r�)r0rTrUr�r>r�Zheader_namesZskipsZcontent_lengthrlr�rrrr��s0	


zHTTPConnection._send_requestcCs�|jr|jj�rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}yZy|j	�Wnt
k
r�|j��YnX|jt
ks�t�t|_|jr�|j�n||_|S|j��YnXdS)a)Get the response from the server.

        If the HTTPConnection is in the correct state, returns an
        instance of HTTPResponse or of whatever object is returned by
        the response_class variable.

        If a request has not been sent or if a previous response has
        not be handled, ResponseNotReady is raised.  If the HTTP
        response indicates that the connection should be closed, then
        it will be closed before the response is returned.  When the
        connection is closed, the underlying socket is closed.
        Nr)rT)r�rsr�r�rrHr�rSrIrm�ConnectionErrorrnrRrKr�r�)r0r�rrr�getresponse)s.


zHTTPConnection.getresponse)NN)NF)FF)N)"r4r5r6r�r�rr��	HTTP_PORTr�r�rH�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrVr�r�r�r�r�rnr�r�r�r�r�r�r�r�r�r�r�rrrrr&s< 
	'
6
	
.csFeZdZdZeZdddejdfddd��fdd�Z�fdd�Z	�Z
S)�HTTPSConnectionz(This class allows communication via SSL.N)�context�check_hostnamecs�tt|�j||||�|dk	s.|dk	s.|dk	rDddl}	|	jdtd�||_||_|dkrptj	�}|j
dk	rpd|_
|jtjk}
|dkr�|j
}|r�|
r�td��|s�|r�|j||�|j
dk	r�d|_
||_||_dS)NrzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rWTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rorrV�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr]Zload_cert_chain�_context�_check_hostname)r0r�r�r	r
r�r�rrrZwill_verify)rprrrVts0


zHTTPSConnection.__init__cs�t�j�|jr|j}n|j}|jj|j|d�|_|jjr�|jr�yt	j
|jj�|�Wn.tk
r�|jj
tj�|jj��YnXdS)z(Connect to a host on a given (SSL) port.)�server_hostnameN)ror�r�r�rZwrap_socketrSrr
rZmatch_hostnameZgetpeercert�	ExceptionZshutdownr�Z	SHUT_RDWRrn)r0r)rprrr��s



zHTTPSConnection.connect)r4r5r6�__doc__�
HTTPS_PORTr�r�rrVr�r�rr)rprrmsrc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dS)N)�argsrL)r0rLrrrrV�szUnknownProtocol.__init__N)r4r5r6rVrrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r	N)r4r5r6rrrrr	�sc@s&eZdZddd�Zdd�Zdd�ZdS)	r
NcCs|f|_||_||_dS)N)r�partial�expected)r0rrrrrrV�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedrXz%s(%i bytes read%s))rrpr4r,r)r0�errr�__repr__�s

zIncompleteRead.__repr__cCst|�S)N)r[)r0rrr�__str__�szIncompleteRead.__str__)N)r4r5r6rVrrrrrrr
�s
c@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r
N)r4r5r6rrrrr
�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dS)N)r[rr2)r0r2rrrrV�szBadStatusLine.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcCstj|dt|f�dS)Nz&got more than %d bytes when reading %s)rrVr;)r0Z	line_typerrrrV�szLineTooLong.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcOs"tj|d�tj|f|�|�dS)NrX)rrV�ConnectionResetError)r0�pos�kwrrrrV�szRemoteDisconnected.__init__N)r4r5r6rVrrrrr�s)r)BrZemail.parserrCZ
email.messager�r��os�rer�r�Zurllib.parser�__all__rrrKr�r�r��globals�updater��__members__r�rr�r;r<�compile�	fullmatchr�r�r�r�r�r�r'r�ZMessager(r?rE�BufferedIOBaserrr�ImportErrorrr/rrrrrrr	r
rr
rrrrrrrrrrr�<module>Es�



9F=
PK*�\D��@�*�*simpledialog.cpython-38.pycnu�[���U

e5d�-�@s�dZddlTddlmZmZGdd�d�ZGdd�de�Zdd	�ZGd
d�de�ZGdd
�d
e�Z	dd�Z
Gdd�de�Zdd�ZGdd�de�Z
dd�Zedkr�dd�Ze�dS)a&This modules handles dialog boxes.

It contains the following public symbols:

SimpleDialog -- A simple but flexible modal dialog box

Dialog -- a base class for dialogs

askinteger -- get an integer from the user

askfloat -- get a float from the user

askstring -- get a string from the user
�)�*)�
messagebox�_get_default_rootc@sLeZdZdgddddfdd�Zddd�Zd	d
�Zdd�Zd
d�Zdd�ZdS)�SimpleDialog�NcCs|rt||d�|_n
t|�|_|r:|j�|�|j�|�t|j�t|j|dd�|_|jjdtd�t	|j�|_
|j
��||_||_||_
|j�d|j�tt|��D]L}||}	t|j
|	||fdd�d	�}
||kr�|
jtd
d�|
jttdd�q�|j�d
|j�|�|�dS)N)�class_i�)�textZaspect�)�expand�fill�<Return>cSs
|�|�S�N)�done��self�num�r�,/usr/lib64/python3.8/tkinter/simpledialog.py�<lambda>8�z'SimpleDialog.__init__.<locals>.<lambda>�r�command�)ZreliefZborderwidth)�siderr
�WM_DELETE_WINDOW)�Toplevel�root�titleZiconname�
_setup_dialogZMessage�message�packZBOTH�Frame�framer�cancel�default�bind�return_event�range�len�ButtonZconfigZRIDGE�LEFT�protocol�wm_delete_window�_set_transient)r�masterr�buttonsr$r#rrr�s�brrr�__init__ s2


�zSimpleDialog.__init__��?�333333�?c
Cs|j}|��|�|�|��|��rJ|��}|��}|��}|��}n|�	�}|�
�}d}}|��}	|��}
|||	|}|||
|}||	|�	�kr�|�	�|	}n|dkr�d}||
|�
�kr�|�
�|
}n|dkr�d}|�
d||f�|��dS)Nr�+%d+%d)r�withdraw�	transient�update_idletasksZwinfo_ismappedZwinfo_widthZwinfo_height�winfo_rootx�winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheight�geometry�	deiconify)
rr.ZrelxZrelyZwidgetZm_widthZm_heightZm_xZm_yZw_widthZw_height�x�yrrrr-?s4

zSimpleDialog._set_transientcCs.|j��|j��|j��|j��|jSr
)r�wait_visibility�grab_set�mainloop�destroyr�rrrr�go\s




zSimpleDialog.gocCs&|jdkr|j��n|�|j�dSr
)r$r�bellr�rZeventrrrr&cs
zSimpleDialog.return_eventcCs&|jdkr|j��n|�|j�dSr
)r#rrErrCrrrr,is
zSimpleDialog.wm_delete_windowcCs||_|j��dSr
)rr�quitrrrrroszSimpleDialog.done)r3r4)	�__name__�
__module__�__qualname__r2r-rDr&r,rrrrrrs�

rc@sVeZdZdZddd�Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	dd�Z
dd�ZdS)�DialogzZClass to open dialogs.

    This class is intended as a base class for custom dialogs
    NcCs�|}|std�}t�||�|��|dk	r>|��r>|�|�|rL|�|�t|�||_d|_	t
|�}|�|�|_|j
ddd�|��|js�||_|�d|j�|dk	r�|�d|��d|��df�|��|j��|��|��|�|�dS)z�Initialize a dialog.

        Arguments:

            parent -- a parent window (the application window)

            title -- the dialog title
        zcreate dialog windowN�)�padx�padyrr5�2)rrr2r6Zwinfo_viewabler7rr�parent�resultr!�body�
initial_focusr �	buttonboxr+r#r;r9r:r<�	focus_setr?r@Zwait_window)rrPrr.rRrrrr2{s8	


�
zDialog.__init__cCsd|_t�|�dS)zDestroy the windowN)rSrrBrCrrrrB�szDialog.destroycCsdS)z�create dialog body.

        return widget that should have initial focus.
        This method should be overridden, and is called
        by the __init__ method.
        Nr)rr.rrrrR�szDialog.bodycCsvt|�}t|dd|jtd�}|jtddd�t|dd|jd�}|jtddd�|�d|j�|�d	|j�|��d
S)z[add standard button box.

        override if you do not want the standard buttons
        ZOK�
)r�widthrr$rL)rrMrN�Cancel)rrWrrz<Escape>N)r!r)�okZACTIVEr r*r#r%)rZbox�wrrrrT�szDialog.buttonboxcCsB|��s|j��dS|��|��z|��W5|��XdSr
)�validaterSrUr6r8r#�applyrFrrrrY�s
z	Dialog.okcCs |jdk	r|j��|��dSr
)rPrUrBrFrrrr#�s

z
Dialog.cancelcCsdS)z�validate the data

        This method is called automatically to validate the data before the
        dialog is destroyed. By default, it always validates OK.
        r	rrCrrrr[�szDialog.validatecCsdS)z�process the data

        This method is called automatically to process the data, *after*
        the dialog is destroyed. By default, it does nothing.
        NrrCrrrr\�szDialog.apply)N)N)N)rHrIrJ�__doc__r2rBrRrTrYr#r[r\rrrrrKts
7	


	rKcCs:|jdkr |j�dd|dd�n|jdkr6|�dd�dS)	NZaquaz!::tk::unsupported::MacWindowStyleZstyleZ
moveableModalrZx11z-typeZdialog)Z_windowingsystemZtkZcallZ
wm_attributes)rZrrrrs

�
rc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�_QueryDialogNcCs*||_||_||_||_t�|||�dSr
)�prompt�minvalue�maxvalue�initialvaluerKr2)rrr_rbr`rarPrrrr2s
z_QueryDialog.__init__cCsd|_t�|�dSr
)�entryrKrBrCrrrrBsz_QueryDialog.destroycCsrt||jtd�}|jddtd�t|dd�|_|jjddttd�|jdk	rl|j�	d|j�|j�
dt�|jS)N)rZjustifyrrL)�rowrMZstickyrc)�namer	)ZLabelr_r*Zgrid�WZEntryrc�Erb�insertZselect_rangeZEND)rr.rZrrrrR s
z_QueryDialog.bodycCs�z|��}Wn,tk
r8tjd|jd|d�YdSX|jdk	rh||jkrhtjdd|j|d�dS|jdk	r�||jkr�tjdd|j|d�dS||_d	S)
Nz
Illegal valuez
Please try again)rPrz	Too smallz2The allowed minimum value is %s. Please try again.z	Too largez2The allowed maximum value is %s. Please try again.r	)�	getresult�
ValueErrorr�showwarning�errormessager`rarQ)rrQrrrr[.s:�����z_QueryDialog.validate)NNNN)rHrIrJr2rBrRr[rrrrr^
s�

r^c@seZdZdZdd�ZdS)�
_QueryIntegerzNot an integer.cCs|�|j���Sr
)Zgetintrc�getrCrrrriSsz_QueryInteger.getresultN�rHrIrJrlrirrrrrmPsrmcKst||f|�}|jS)z�get an integer from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is an integer
    )rmrQ�rr_�kw�drrr�
askintegerWsrsc@seZdZdZdd�ZdS)�_QueryFloatzNot a floating point value.cCs|�|j���Sr
)Z	getdoublercrnrCrrrriisz_QueryFloat.getresultNrorrrrrtfsrtcKst||f|�}|jS)z�get a float from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is a float
    )rtrQrprrr�askfloatmsruc@s$eZdZdd�Zdd�Zdd�ZdS)�_QueryStringcOs6d|kr|d|_|d=nd|_tj|f|�|�dS)N�show)�_QueryString__showr^r2)r�argsrqrrrr2}s

z_QueryString.__init__cCs(t�||�}|jdk	r$|j|jd�|S)N)rw)r^rRrxZ	configure)rr.rcrrrrR�s
z_QueryString.bodycCs
|j��Sr
)rcrnrCrrrri�sz_QueryString.getresultN)rHrIrJr2rRrirrrrrv|srvcKst||f|�}|jS)z�get a string from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is a string
    )rvrQrprrr�	askstring�srz�__main__cCsLt�}|fdd�}t|d|d�}|��t|d|jd�}|��|��dS)NcSs^t|ddddgdddd�}t|���ttd	d
dd��ttd	d
ddd��ttd	d��dS)Nz�This is a test dialog.  Would this have been an actual dialog, the buttons below would have been glowing in soft pink light.
Do you believe this?ZYesZNorXr�zTest Dialog)rr/r$r#rZSpamz	Egg count�)rbzEgg weight
(in tons)r	�d)r`raz	Egg label)r�printrDrsrurz)rrrrrr�doit�s�

�ztest.<locals>.doitZTestrZQuit)ZTkr)r rGrA)rr��t�qrrr�test�sr�N)r]ZtkinterrrrrrKrr^rmrsrtrurvrzrHr�rrrr�<module>s V
CPK*�\ҧ����dialog.cpython-38.pycnu�[���U

e5d��@srddlTddlmZdZGdd�de�Zdd�Zedkrned	d
ddeeii�Z	ed	d
d
de	j
eii�Ze	��d	S)�)�*)�	_cnfmergeZ	questheadc@s"eZdZdifdd�Zdd�ZdS)�DialogNc
Ks�t||f�}d|_t�|||�|j�|jjd|j|d|d|d|df|d���|_zt�	|�Wnt
k
r~YnXdS)NZ
__dialog__Z	tk_dialog�title�text�bitmap�default�strings)rZ
widgetName�Widget�_setupZtkZgetintZcallZ_w�num�destroyZTclError)�selfZmasterZcnf�kw�r�&/usr/lib64/python3.8/tkinter/dialog.py�__init__
s&���zDialog.__init__cCsdS)Nr)rrrrr
�zDialog.destroy)�__name__�
__module__�__qualname__rr
rrrrr	s
rcCs$tdddtddd��}t|j�dS)Nz
File ModifiedzzFile "Python.h" has been modified since the last time it was saved. Do you want to save it before exiting the application.r)z	Save FilezDiscard ChangeszReturn to Editor)rrrrr	)r�DIALOG_ICON�printr)�drrr�_tests�r�__main__NrZTestZcommandZQuit)
Ztkinterrrr
rrrZButtonZPack�t�quit�qZmainlooprrrr�<module>s$��PK*�\b
p�nnttk.cpython-38.opt-2.pycnu�[���U

e5d���@s�dZdZdddddddd	d
ddd
dddddddddddddgZddlZddlmZmZmZmZejdkrldnd Z	d!d"�Z
dWd#d$�ZdXd%d&�Zd'd(�Z
dYd)d*�ZdZd+d,�Zd[d.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d�Zd\d?d�ZGd@d�de�ZGdAdB�dBej�ZGdCd�de�ZGdDd�de�ZGdEd�deej�ZGdFd�de�Z GdGd�de�Z!GdHd�de�Z"GdId�de�Z#e#Z$GdJd
�d
e�Z%GdKd�de�Z&GdLd�deej'�Z(e(Z'GdMd�de�Z)GdNd�de�Z*GdOd�deej+�Z+GdPd�deej,�Z,GdQd�de�Z-GdRd�de�Z.GdSd�de�Z/GdTd�deej0ej1�Z2GdUd�de!�Z3GdVd�de%�Z4dS)]z0.3.1z!Guilherme Polo <ggpolo@gmail.com>�Button�Checkbutton�Combobox�Entry�Frame�Label�
Labelframe�
LabelFrame�
Menubutton�Notebook�Panedwindow�PanedWindow�Progressbar�Radiobutton�Scale�	Scrollbar�	Separator�Sizegrip�Spinbox�Style�Treeview�LabeledScale�
OptionMenu�
tclobjs_to_py�setup_master�N)�_flatten�_join�
_stringify�
_splitdictg!@TFcCsBtr>ddl}|j�d�}|r,|j�d|�|j�d�d|_dS)NrZTILE_LIBRARYz(global auto_path; lappend auto_path {%s}zpackage require tileT)�
_REQUIRE_TILE�os�environ�get�tk�eval�_tile_loaded)�masterr Ztilelib�r'�#/usr/lib64/python3.8/tkinter/ttk.py�
_load_tile"s��r)cCs(|rt|�}nt|ttf�r$t|�}|S�N)r�
isinstance�list�tupler)�value�scriptr'r'r(�_format_optvalue1s

r0cCsPg}|��D]:\}}|r ||kr|�d|�|dk	r|�t||��qt|�S�N�-%s)�items�appendr0r)Zoptdictr/�ignore�opts�optr.r'r'r(�_format_optdict;sr8cCsXg}|D]J�^}}t|�dkr,|dp(d}n
d�|�}|�|�|dk	r|�|�q|S)N�r�� )�len�joinr4)r3Zopt_val�state�valr'r'r(�_mapdict_valuesKs

r@cCs:g}|��D]$\}}|�d|tt|�|�f�qt|�Sr1)r3�extendr0r@r)Zmapdictr/r6r7r.r'r'r(�_format_mapdict`s

�rBcOs�d}d}|dkr�|dkrB|d}tt|dd���}d||f}n2|dd�\}}	tt|dd���}
d||	|
f}t||�}n,|d	kr�|d}t|�dkr�t|d|�f}|r�d
|}d�|�}||fS)Nr')�imageZvsapirCrr9z%s %s�z%s %s %s�fromz{%s}r;)rr@r8r<r0r=)�etyper/�args�kw�specr6ZinameZ	imagespec�
class_nameZpart_idZstatemapr'r'r(�_format_elemcreateqs&
rKrDc
Cs�g}|D]�}|\}}|pi}d�t|dd��}dd|||rDd|ndf}d|kr�|�|d�||7}t|d||�\}	}|�|	�||8}|�d	d|�q|�|�qd
�|�|fS)Nr;T)�childrenz%s%s%sz %sr:rLz -children {z%s}�
)r=r8r4�_format_layoutlist)
�layout�indentZindent_sizer/Zlayout_elem�elemr6Zfopts�headZ	newscriptr'r'r(rN�s"
�
rNcCsXg}|��D�]>\}}|�d�rFd�t|dd��}|�d||f�|�d�rvd�t|dd��}|�d||f�d|kr�|ds�d}nt|d�\}}|�d	||f�|�d
�r|d
}|d}d}|t|�kr�t||d
�s�|d7}q�|d|�}	|t|�k�r||�r||ni}
t	|df|	�|
�\}}|�d||||f�qd�|�S)N�	configurer;Tzttk::style configure %s %s;�mapzttk::style map %s %s;rO�nullzttk::style layout %s {
%s
}zelement createrr9r3z%ttk::style element create %s %s %s %srM)
r3r"r=r8r4rBrNr<�hasattrrK)�settingsr/�namer6�s�_ZeoptsrFZargcZelemargsZelemkwrIr'r'r(�_script_from_settings�s:



$�
r[cCs�t|t�r|Sg}t|�}t||�D]j\}}t|d�rDt|���}n(t|t�rX|��}nt|ttf�sl|f}t|d�r~t|�}|�||f��q$|S)N�typename)	r+�str�iter�ziprV�splitr-r,r4)Zstuple�result�itr>r?r'r'r(�_list_from_statespec�s




rccCs�|�|�}g}d}|t|�kr�||}i}|�||f�|d7}|t|�kr|||d�\}}|�d�slq|dd�}|d7}|dkr�t||�}|||<q@q|S)Nrr9rD�-rL)�	splitlistr<r4�
startswith�_list_from_layouttuple)r#Zltuple�resZindxrXr6r7r?r'r'r(rgs$


rgcGs4t|�}|j||�}t|�dr&|St||td�S)NrD)�conv)r8�callr<r�
_tclobj_to_py)r#�optionsrGrhr'r'r(�_val_or_dict!s
rmc	Cs2t|�}zt|�}Wnttfk
r,YnX|Sr*)r]�int�
ValueError�	TypeError)r.r'r'r(�_convert_stringval1srqcCs(t|t�r$d|krt|�}nt|�}|S)N�.)r+r]�floatrn)�xr'r'r(�
_to_number;s


rucCs\|rFt|d�rFt|t�sFt|ddd�dkr6t|�}qXttt|��}nt|d�rXt|�}|S)N�__len__rr\Z	StateSpec)rVr+r]�getattrrcr,rTrq)r?r'r'r(rkCs

rkcCs"|��D]\}}t|�||<q|Sr*)r3rk)Zadictr7r?r'r'r(rPscCs|dkrt��}|Sr*)�tkinterZ_get_default_root)r&r'r'r(rXsc@s~eZdZdZddd�Zddd�Zddd�Zdd	d
�Zddd�Zd
d�Z	dd�Z
dd�Zd dd�Zdd�Z
dd�Zd!dd�ZdS)"rz
ttk::styleNcCs0t|�}t|dd�st|�||_|jj|_dS)Nr%F)rrwr)r&r#)�selfr&r'r'r(�__init__is
zStyle.__init__cKs4|dk	rd||<t|j||jd|�}|s,|r0|SdS)NrS)rmr#�_name�ry�styleZ	query_optrHrar'r'r(rSts
zStyle.configurecsj|dk	r0�j��jd|d|�}t�j�|��S�jj�jd|ft|���}�fdd�t�j|���D�S)NrTr2cs"i|]\}}|t�j�|���qSr')rcr#re)�.0�k�v�ryr'r(�
<dictcomp>�s�zStyle.map.<locals>.<dictcomp>)r#rjr{rcrerBrr3r|r'r�r(rT�s
�z	Style.mapcCs.|rd�|�nd}|j�|jd|d|||�S)Nr;r:�lookupr2)r=r#rjr{)ryr}�optionr>�defaultr'r'r(r��s
�zStyle.lookupcCs>d}|rt|�d}n|dk	r"d}t|j|j�|jd||��S)NrrUrO)rNrgr#rjr{)ryr}Z
layoutspecZlspecr'r'r(rO�s �zStyle.layoutcOs8t|df|�|�\}}|jj|jdd|||f|��dS)NF�element�create)rKr#rjr{)ry�elementnamerFrGrHrIr6r'r'r(�element_create�s��zStyle.element_createc	Cs(tdd�|j�|j�|jdd��D��S)Ncss|]}|�d�VqdS�rdN��lstrip)r~�nr'r'r(�	<genexpr>�sz&Style.element_names.<locals>.<genexpr>r��names�r-r#rerjr{r�r'r'r(�
element_names�s�zStyle.element_namesc
Cs*tdd�|j�|j�|jdd|��D��S)Ncss|]}|�d�VqdSr�r�)r~�or'r'r(r��sz(Style.element_options.<locals>.<genexpr>r�rlr�)ryr�r'r'r(�element_options�s�zStyle.element_optionsc
CsN|rt|�nd}|r2|j�|jdd|d|d|�n|j�|jdd|d|�dS)Nr:�themer�z-parentz	-settings�r[r#rjr{)ry�	themename�parentrWr/r'r'r(�theme_create�s��zStyle.theme_createcCs"t|�}|j�|jdd||�dS)Nr�rWr�)ryr�rWr/r'r'r(�theme_settings�szStyle.theme_settingscCs|j�|j�|jdd��S)Nr�r�)r#rerjr{r�r'r'r(�theme_names�szStyle.theme_namescCs&|dkr|j�d�S|j�d|�dS)Nzreturn $ttk::currentThemez
ttk::setTheme)r#r$rj)ryr�r'r'r(�	theme_use�szStyle.theme_use)N)N)N)NN)N)NN)N)�__name__�
__module__�__qualname__r{rzrSrTr�rOr�r�r�r�r�r�r�r'r'r'r(rds




+
c@s2eZdZd
dd�Zdd�Zddd�Zddd	�ZdS)
�WidgetNcCs4t|�}t|dd�st|�tjj||||d�dS)Nr%F)rH)rrwr)rxr�rz)ryr&Z
widgetnamerHr'r'r(rzszWidget.__init__cCs|j�|jd||�S�N�identify�r#rj�_w�ryrt�yr'r'r(r�+szWidget.identifyc	Os6|j�|j�|jdd�|���}|r2|r2|||�S|S)N�instater;)r#�
getbooleanrjr�r=)ry�	statespec�callbackrGrHZretr'r'r(r�3s�
zWidget.instatecCs0|dk	rd�|�}|j�t|j�|jd|���S)Nr;r>)r=r#rer]rjr�)ryr�r'r'r(r>Bs
zWidget.state)N)N)N)r�r�r�rzr�r�r>r'r'r'r(r�
s

r�c@seZdZddd�Zdd�ZdS)rNcKst�||d|�dS)Nzttk::button�r�rz�ryr&rHr'r'r(rzSszButton.__init__cCs|j�|jd�S�N�invoker�r�r'r'r(r�bsz
Button.invoke)N�r�r�r�rzr�r'r'r'r(rOs
c@seZdZddd�Zdd�ZdS)rNcKst�||d|�dS)Nzttk::checkbuttonr�r�r'r'r(rzjszCheckbutton.__init__cCs|j�|jd�Sr�r�r�r'r'r(r�yszCheckbutton.invoke)Nr�r'r'r'r(rgs
c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)rNcKst�|||pd|�dS)Nz
ttk::entryr�)ryr&ZwidgetrHr'r'r(rz�szEntry.__init__cCs|�|j�|jd|��S)N�bbox�Z_getintsr#rjr�)ry�indexr'r'r(r��sz
Entry.bboxcCs|j�|jd||�Sr�r�r�r'r'r(r��szEntry.identifycCs|j�|j�|jd��S)N�validate�r#r�rjr�r�r'r'r(r��szEntry.validate)NN)r�r�r�rzr�r�r�r'r'r'r(r�s
c@s(eZdZddd�Zd	dd�Zdd�ZdS)
rNcKstj||df|�dS)Nz
ttk::combobox�rrzr�r'r'r(rz�szCombobox.__init__cCs2|dkr |j�|j�|jd��S|j�|jd|�S)N�current�r#Zgetintrjr�)ryZnewindexr'r'r(r��szCombobox.currentcCs|j�|jd|�dS�N�setr��ryr.r'r'r(r��szCombobox.set)N)N)r�r�r�rzr�r�r'r'r'r(r�s


c@seZdZddd�ZdS)rNcKst�||d|�dS)Nz
ttk::framer�r�r'r'r(rz�szFrame.__init__)N�r�r�r�rzr'r'r'r(r�sc@seZdZddd�ZdS)rNcKst�||d|�dS)Nz
ttk::labelr�r�r'r'r(rz�s
zLabel.__init__)Nr�r'r'r'r(r�sc@seZdZddd�ZdS)rNcKst�||d|�dS)Nzttk::labelframer�r�r'r'r(rz�szLabelframe.__init__)Nr�r'r'r'r(r�sc@seZdZddd�ZdS)r	NcKst�||d|�dS)Nzttk::menubuttonr�r�r'r'r(rzszMenubutton.__init__)Nr�r'r'r'r(r	
sc@sjeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
ddd�Zdd�Zdd�Z
dS)r
NcKst�||d|�dS)Nz
ttk::notebookr�r�r'r'r(rz"szNotebook.__init__cKs |jj|jd|ft|���dS�N�add�r#rjr�r8)ry�childrHr'r'r(r�BszNotebook.addcCs|j�|jd|�dS)N�forgetr��ry�tab_idr'r'r(r�JszNotebook.forgetcCs|j�|jd|�dS)N�hider�r�r'r'r(r�Psz
Notebook.hidecCs|j�|jd||�Sr�r�r�r'r'r(r�YszNotebook.identifycCs|j�|j�|jd|��S�Nr�r�r�r'r'r(r�_szNotebook.indexcKs"|jj|jd||ft|���dS�N�insertr��ry�posr�rHr'r'r(r�eszNotebook.insertcCs|j�|jd|�S)N�selectr�r�r'r'r(r�nszNotebook.selectcKs$|dk	rd||<t|j||jd|�S)N�tab�rmr#r�)ryr�r�rHr'r'r(r�xszNotebook.tabcCs|j�|j�|jd�pd�S)N�tabsr'�r#rerjr�r�r'r'r(r��sz
Notebook.tabscCs|j�d|j�dS)Nzttk::notebook::enableTraversalr�r�r'r'r(�enable_traversal�szNotebook.enable_traversal)N)N)N)r�r�r�rzr�r�r�r�r�r�r�r�r�r�r'r'r'r(r
s
 		


c@s:eZdZd
dd�ZejjZdd�Zddd�Zddd	�Z	dS)
rNcKst�||d|�dS)Nzttk::panedwindowr�r�r'r'r(rz�szPanedwindow.__init__cKs"|jj|jd||ft|���dSr�r�r�r'r'r(r��szPanedwindow.insertcKs$|dk	rd||<t|j||jd|�S)N�paner�)ryr�r�rHr'r'r(r��szPanedwindow.panecCs|j�|j�|jd||��S)N�sashposr�)ryr�Znewposr'r'r(r��szPanedwindow.sashpos)N)N)N)
r�r�r�rzrxrr�r�r�r�r'r'r'r(r�s

	
c@s2eZdZd
dd�Zddd�Zddd�Zdd	�ZdS)
r
NcKst�||d|�dS)Nzttk::progressbarr�r�r'r'r(rz�szProgressbar.__init__cCs|j�|jd|�dS)N�startr�)ryZintervalr'r'r(r��szProgressbar.startcCs|j�|jd|�dS)N�stepr�)ryZamountr'r'r(r��szProgressbar.stepcCs|j�|jd�dS)N�stopr�r�r'r'r(r�szProgressbar.stop)N)N)N)r�r�r�rzr�r�r�r'r'r'r(r
�s


c@seZdZddd�Zdd�ZdS)rNcKst�||d|�dS)Nzttk::radiobuttonr�r�r'r'r(rzszRadiobutton.__init__cCs|j�|jd�Sr�r�r�r'r'r(r�szRadiobutton.invoke)Nr�r'r'r'r(rs
c@s*eZdZddd�Zd	dd�Zd
dd�ZdS)rNcKst�||d|�dS)Nz
ttk::scaler�r�r'r'r(rz'szScale.__init__cKsTtj||f|�}t|td�tf�s,|�|�td|kd|kd|kg�rP|�d�|S)NrE�from_�to�<<RangeChanged>>)r�rSr+�typer]�update�anyZevent_generate)ryZcnfrHZretvalr'r'r(rS5s

zScale.configurecCs|j�|jd||�S)Nr"r�r�r'r'r(r"Bsz	Scale.get)N)N)NN)r�r�r�rzrSr"r'r'r'r(r#s


c@seZdZddd�ZdS)rNcKst�||d|�dS)Nzttk::scrollbarr�r�r'r'r(rzNszScrollbar.__init__)Nr�r'r'r'r(rKsc@seZdZddd�ZdS)rNcKst�||d|�dS)Nzttk::separatorr�r�r'r'r(rz`szSeparator.__init__)Nr�r'r'r'r(r\sc@seZdZddd�ZdS)rNcKst�||d|�dS)Nz
ttk::sizegripr�r�r'r'r(rzrszSizegrip.__init__)Nr�r'r'r'r(rnsc@seZdZddd�Zdd�ZdS)rNcKstj||df|�dS)Nzttk::spinboxr�r�r'r'r(rz�szSpinbox.__init__cCs|j�|jd|�dSr�r�r�r'r'r(r��szSpinbox.set)N)r�r�r�rzr�r'r'r'r(r|s
c@s0eZdZdDdd�ZdEdd�ZdFdd�Zdd	�ZdGd
d�Zdd
�Zdd�Z	dd�Z
dHdd�ZdIdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�ZdJd"d#�ZdKd$d%�Zd&d'�ZeZd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z dLd<d=�Z!dMd>d?�Z"dNd@dA�Z#dOdBdC�Z$dS)PrNcKst�||d|�dS)Nz
ttk::treeviewr�r�r'r'r(rz�szTreeview.__init__cCs|�|j�|jd||��pdS)Nr�r:r�)ry�item�columnr'r'r(r��sz
Treeview.bboxcCs"|j�|j�|jd|pd�pd�S)NrLr:r'r��ryr�r'r'r(�get_children�s�zTreeview.get_childrencGs|j�|jd||�dS)NrLr�)ryr�Znewchildrenr'r'r(�set_children�szTreeview.set_childrencKs$|dk	rd||<t|j||jd|�S)Nr�r�)ryr�r�rHr'r'r(r��szTreeview.columncGs|j�|jd|�dS)N�deleter��ryr3r'r'r(r��szTreeview.deletecGs|j�|jd|�dS)N�detachr�r�r'r'r(r��szTreeview.detachcCs|j�|j�|jd|��S)N�existsr�r�r'r'r(r��szTreeview.existscCs|j�|jd|�S)N�focusr�r�r'r'r(r��szTreeview.focuscKsP|�d�}|r,t|t�s,|j�||j�|d<|dk	r<d||<t|j||jd|�S)N�command�heading)	r"r+r]r&�registerZ_substitutermr#r�)ryr�r�rH�cmdr'r'r(r��s
zTreeview.headingcCs|j�|jd|||�Sr�r�)ryZ	componentrtr�r'r'r(r�szTreeview.identifycCs|�dd|�S)N�rowr�r�)ryr�r'r'r(�identify_rowszTreeview.identify_rowcCs|�d|d�S)Nr�rr�)ryrtr'r'r(�identify_column"szTreeview.identify_columncCs|�d||�S)NZregionr�r�r'r'r(�identify_region)s	zTreeview.identify_regioncCs|�d||�S)Nr�r�r�r'r'r(�identify_element5szTreeview.identify_elementcCs|j�|j�|jd|��Sr�r�r�r'r'r(r�<szTreeview.indexcKsNt|�}|dk	r0|jj|jd||d|f|��}n|jj|jd||f|��}|S)Nr�z-id)r8r#rjr�)ryr�r�ZiidrHr6rhr'r'r(r�Bs
��zTreeview.insertcKs$|dk	rd||<t|j||jd|�S)Nr�r�)ryr�r�rHr'r'r(r�Ysz
Treeview.itemcCs|j�|jd|||�dS)N�mover�)ryr�r�r�r'r'r(r�esz
Treeview.movecCs|j�|jd|�S)N�nextr�r�r'r'r(r�qsz
Treeview.nextcCs|j�|jd|�S)Nr�r�r�r'r'r(r�wszTreeview.parentcCs|j�|jd|�S)N�prevr�r�r'r'r(r�}sz
Treeview.prevcCs|j�|jd|�dS)N�seer�r�r'r'r(r��szTreeview.seecCs|j�|j�|jd��S)N�	selectionr�r�r'r'r(r��szTreeview.selectioncCs>t|�dkr&t|dttf�r&|d}|j�|jd||�dS)Nr9rr�)r<r+r-r,r#rjr�)ryZselopr3r'r'r(�
_selection�szTreeview._selectioncGs|�d|�dSr��r�r�r'r'r(�
selection_set�szTreeview.selection_setcGs|�d|�dSr�r�r�r'r'r(�
selection_add�szTreeview.selection_addcGs|�d|�dS)N�remover�r�r'r'r(�selection_remove�szTreeview.selection_removecGs|�d|�dS)NZtoggler�r�r'r'r(�selection_toggle�szTreeview.selection_togglecCs@|j�|jd|||�}|dkr8|dkr8t|j|dtd�S|SdS)Nr�F)Z	cut_minusri)r#rjr�rrk)ryr�r�r.rhr'r'r(r��s�zTreeview.setcCs |j|jdd|f||dd�dS)N�tag�bindr)r�)Z_bindr�)ry�tagnameZsequencer�r'r'r(�tag_bind�szTreeview.tag_bindcKs&|dk	rd||<t|j||jdd|�S)Nr�rSr�)ryr�r�rHr'r'r(�
tag_configure�s
�zTreeview.tag_configurec	CsF|dkr$|j�|j�|jdd|��S|j�|j�|jdd||��SdS)Nr�Zhas)r#rerjr�r�)ryr�r�r'r'r(�tag_has�s��zTreeview.tag_has)N)N)N)N)N)N)N)N)NN)NN)N)N)%r�r�r�rzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zreattachr�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r'r'r(r�sD



	
	

 

		



csHeZdZd
dd�Z�fdd�Zdd	�Zed
d��Zejdd��Z�Z	S)rNr�
c	Ks|�dd�dk|_tj||f|�|p.t�|�|_|j�|�||_t	|�|_
t||j||d�|_|j�
d|j�|jr|dnd}|dkr�dnd}|jj|dd�t	|�}|j|d�|��|j
j|dkr�d	nd
d�|j�d|j�|_|�
d
|j�|�
d|j�dS)NZcompound�top)�variabler�r�r�Zbottomrt)�sideZfill)rr�rY)Zanchor�wz<Configure>z<Map>)�pop�
_label_toprrzrxZIntVar�	_variabler��_last_validr�labelr�scaler��_adjustZpack�lowerZplaceZtrace_variable�_LabeledScale__tracecb)	ryr&rr�r�rHZ
scale_sideZ
label_sideZdummyr'r'r(rz�s$
zLabeledScale.__init__csHz|j�d|j�Wntk
r(YnX|`t���d|_d|_dS)Nr)rZ
trace_vdeleter�AttributeError�super�destroyrr	r���	__class__r'r(rs
zLabeledScale.destroycs��fdd�}t�jd�}t�jd�}||kr:||}}�j��}||krX|ksfn�j�_dS|�_|�jd<��|�dS)NcsZ����j��\}}�jr2�j���j��}n�j���j��}�jj||d�dS)N�rtr�)Zupdate_idletasksr	ZcoordsrZwinfo_yrZwinfo_reqheightZplace_configurerr�r'r(�adjust_labelsz*LabeledScale._adjust.<locals>.adjust_labelrEr��text)rur	rr"rr.rZ
after_idle)ryrGrr�r�Znewvalr'r�r(r
s


zLabeledScale._adjustcCs
|j��Sr*)rr"r�r'r'r(r.4szLabeledScale.valuecCs|j�|�dSr*)rr�)ryr?r'r'r(r.9s)NNrr�)
r�r�r�rzrr
�propertyr.�setter�
__classcell__r'r'rr(r�s
&

cs8eZdZd
dd�Zdd�Zddd�Z�fdd	�Z�ZS)rNcOs�||�dd�|�dd�d�}tj||f|�tj|dd�|d<||_|�dd�|_|rpt�dtt	|�
�����|j|f|��dS)	Nr}�	direction)Ztextvariabler}rF)Ztearoff�menur�zunknown option -%s)rr	rzrxZMenur�	_callbackZTclErrorr�r^�keys�set_menu)ryr&rr��values�kwargsrHr'r'r(rzCs
��zOptionMenu.__init__cCs&|dkr|�t�||��St�||�S)Nr)Znametowidgetr	�__getitem__r�r'r'r(r`szOptionMenu.__getitem__cGsR|d}|�dd�|D]$}|j|t�|j||j�|jd�q|rN|j�|�dS)Nrr�end)rr�r)r�Zadd_radiobuttonrxZ_setitrrr�)ryr�rrr?r'r'r(rgs�zOptionMenu.set_menucs,z|`Wntk
rYnXt���dSr*)rr
rrr�rr'r(rus
zOptionMenu.destroy)N)N)r�r�r�rzrrrrr'r'rr(r?s

)F)FN)F)F)rrD)N)5�__version__�
__author__�__all__rxrrrrZ	TkVersionrr)r0r8r@rBrKrNr[rcrgrmrqrurkrr�objectrr�rrrrrrrrr	r
rrr
rrrrrrZXViewZYViewrrrr'r'r'r(�<module>s��	




%
1*


*B*"8*(J`PK*�\[_��S
S
messagebox.cpython-38.opt-2.pycnu�[���U

e5d}�@sHddlmZdZdZdZdZdZdZdZd	Z	d
Z
dZdZd
Z
dZdZdZdZdZGdd�de�Zd5dd�Zd6dd�Zd7dd�Zd8dd�Zd9dd�Zd:dd �Zd;d!d"�Zd<d#d$�Zd=d%d&�Zed'k�rDeded(d)��eded(d*��eded(d+��eded(d,��ed-ed(d.��ed/ed(d0��ed1ed(d2��ed3ed(d4��dS)>�)�Dialog�error�infoZquestionZwarningZabortretryignore�okZokcancelZretrycancelZyesnoZyesnocancel�abortZretry�ignoreZcancelZyesZnoc@seZdZdZdS)�MessageZ
tk_messageBoxN)�__name__�
__module__�__qualname__Zcommand�rr�*/usr/lib64/python3.8/tkinter/messagebox.pyr9srNcKsl|rd|kr||d<|r(d|kr(||d<|r4||d<|r@||d<tf|���}t|t�rd|r`tStSt|�S)NZicon�type�title�message)rZshow�
isinstance�bool�YES�NO�str)rrZ_iconZ_type�options�resrrr
�_showCs
rcKst||ttf|�S�N)r�INFO�OK�rrrrrr
�showinfoRsrcKst||ttf|�Sr)r�WARNINGrrrrr
�showwarningWsrcKst||ttf|�Sr)r�ERRORrrrrr
�	showerror\sr!cKst||ttf|�Sr)r�QUESTION�YESNOrrrr
�askquestionasr$cKst||ttf|�}|tkSr)rr"�OKCANCELr�rrr�srrr
�askokcancelfsr(cKst||ttf|�}|tkSr)rr"r#rr&rrr
�askyesnolsr)cKs.t||ttf|�}t|�}|tkr&dS|tkSr)rr"�YESNOCANCELr�CANCELrr&rrr
�askyesnocancelrs
r,cKst||ttf|�}|tkSr)rr�RETRYCANCEL�RETRYr&rrr
�askretrycancel|sr/�__main__ZSpamzEgg InformationzEgg Warningz	Egg Alertz	Question?ZproceedzProceed?zyes/nozGot it?z
yes/no/cancelzWant it?z	try againz
Try again?)NNNN)NN)NN)NN)NN)NN)NN)NN)NN)Ztkinter.commondialogrr rr"rZABORTRETRYIGNORErr%r-r#r*ZABORTr.ZIGNOREr+rrrrrrr!r$r(r)r,r/r	�printrrrr
�<module>sH










	
PK+�\��00filedialog.cpython-38.opt-1.pycnu�[���U

e5d�8�@sdZddlTddlmZddlmZddlmZddlZddlZiZ	Gdd�d�Z
Gd	d
�d
e
�ZGdd�de
�ZGd
d�dej�Z
Gdd�de
�ZGdd�de
�ZGdd�dej�Zdd�Zdd�Zdd�Zd(dd�Zd)dd�Zd*d!d"�Zd#d$�Zd%d&�Zed'k�re�dS)+aUFile selection dialog classes.

Classes:

- FileDialog
- LoadFileDialog
- SaveFileDialog

This module also presents tk common file dialogues, it provides interfaces
to the native file dialogues available in Tk 4.2 and newer, and the
directory dialogue available in Tk 8.3 and newer.
These interfaces were written by Fredrik Lundh, May 1997.
�)�*)�Dialog)�commondialog)�
_setup_dialogNc@s�eZdZdZdZd$dd�Zejdddfdd	�Zd%d
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd&dd�Zdd�Zdd�Zd'dd�Zd d!�Zd"d#�ZdS)(�
FileDialoga�Standard file selection dialog -- no checks on selected file.

    Usage:

        d = FileDialog(master)
        fname = d.go(dir_or_file, pattern, default, key)
        if fname is None: ...canceled...
        else: ...open file...

    All arguments to go() are optional.

    The 'key' argument specifies a key in the global dictionary
    'dialogstates', which keeps track of the values for the directory
    and pattern arguments, overriding the values passed in (it does
    not keep track of the default argument!).  If no key is specified,
    the dialog keeps no memory of previous state.  Note that memory is
    kept even when the dialog is canceled.  (All this emulates the
    behavior of the Macintosh file selection dialogs.)

    zFile Selection DialogNcCs�|dkr|j}||_d|_t|�|_|j�|�|j�|�t|j�t|j�|_|jj	t
td�t|j�|_
|j
j	t
td�|j
�d|j�t|j�|_|jj	ttd�|j�d|j�t|j�|_|jj	ttd�t|j�|_|jj	ttd�t|jd|jdfd�|_|jj	tttd�|j��}|j�|dd�|dd��|j�d	|j�|j�d
|j�|jj|jdfd�t|j�|_ |j j	t!td�t|jd|j dfd�|_"|j"j	t!ttd�|j j|j"dfd�|j"��}|j"�|dd�|dd��|j"�d	|j#�|j"�d
|j$�t%|jd
|j&d�|_'|j'j	t!d�t%|jd|jd�|_(|j(j	t!td�t%|jd|j)d�|_*|j*j	td�|j�+d|j)�|j�d|j)�|j�d|j)�dS)N)�side�fillz<Return>)�expandrr�set)ZexportselectionZyscrollcommand)rr	r�z<ButtonRelease-1>z<Double-ButtonRelease-1>Zyview)�commandZOK)�textr)rZFilter)rr	�CancelZWM_DELETE_WINDOWz<Alt-w>z<Alt-W>),�title�master�	directoryZToplevel�topZiconnamerZFrameZbotframeZpackZBOTTOM�XZEntry�	selectionZbind�ok_event�filterZTOP�filter_commandZmidframeZYESZBOTHZ	ScrollbarZfilesbarZRIGHT�YZListbox�filesZbindtags�files_select_event�files_double_eventZconfigZdirsbarZLEFT�dirs�dirs_select_event�dirs_double_eventZButton�
ok_commandZ	ok_buttonZ
filter_button�cancel_commandZ
cancel_buttonZprotocol)�selfrrZbtags�r"�*/usr/lib64/python3.8/tkinter/filedialog.py�__init__4st

�
 �
 ���zFileDialog.__init__r�cCs�|r|tkrt|\|_}n2tj�|�}tj�|�r<||_ntj�|�\|_}|�|j|�|�|�|�	�|j
��|j�
�|j��d|_|j��|r�|��\}}|jr�tj�|j�}||ft|<|j��|jS�N)�dialogstatesr�os�path�
expanduser�isdir�split�
set_filter�
set_selectionrrZ	focus_setrZwait_visibilityZgrab_set�howrZmainloop�
get_filter�dirnameZdestroy)r!Zdir_or_file�pattern�default�keyrr"r"r#�gots*





z
FileDialog.gocCs||_|j��dSr&)r/r�quit)r!r/r"r"r#r6�szFileDialog.quitcCs|��dSr&)r�r!�eventr"r"r#r�szFileDialog.dirs_double_eventcCs@|��\}}|j�d�}tj�tj�|j|��}|�||�dS�NZactive)	r0r�getr(r)�normpath�joinrr-)r!r8�dir�patZsubdirr"r"r#r�szFileDialog.dirs_select_eventcCs|��dSr&�rr7r"r"r#r�szFileDialog.files_double_eventcCs|j�d�}|�|�dSr9)rr:r.)r!r8�filer"r"r#r�szFileDialog.files_select_eventcCs|��dSr&r?r7r"r"r#r�szFileDialog.ok_eventcCs|�|���dSr&)r6�
get_selection�r!r"r"r#r�szFileDialog.ok_commandcCs&|��\}}zt�|�}Wn tk
r:|j��YdSX||_|�||�|��tj	g}g}|D]@}tj
�||�}tj
�|�r�|�
|�qft�||�rf|�
|�qf|j�dt�|D]}|j�t|�q�|j�dt�|D]}|j�t|�q�tj
�|���\}	}
|
tjk�rd}
|�|
�dS)Nrr%)r0r(�listdir�OSErrorr�bellrr-�sort�pardirr)r<r+�append�fnmatchr�delete�END�insertrr,rA�curdirr.)r!r8r=r>�namesZsubdirsZ
matchingfiles�name�fullname�head�tailr"r"r#r�s6
zFileDialog.filter_commandcCsN|j��}tj�|�}|dd�tjks4tj�|�rBtj�|d�}tj�|�S)N���r)	rr:r(r)r*�sepr+r<r,)r!rr"r"r#r0�s

zFileDialog.get_filtercCs|j��}tj�|�}|Sr&)rr:r(r)r*�r!r@r"r"r#rA�s
zFileDialog.get_selectioncCs|��dSr&)r6r7r"r"r#r �szFileDialog.cancel_commandcCs�tj�|�sPzt��}Wntk
r0d}YnX|rPtj�||�}tj�|�}|j�dt	�|j�
t	tj�|pttj|pzd��dS)Nrr)r(r)�isabs�getcwdrDr<r;rrJrKrLrM)r!r=r>�pwdr"r"r#r-�s
zFileDialog.set_filtercCs,|j�dt�|j�ttj�|j|��dS)Nr)rrJrKrLr(r)r<rrUr"r"r#r.�szFileDialog.set_selection)N)N)N)N)�__name__�
__module__�__qualname__�__doc__rr$r(rMr5r6rrrrrrrr0rAr r-r.r"r"r"r#rs"
@


rc@seZdZdZdZdd�ZdS)�LoadFileDialogz8File selection dialog which checks that the file exists.zLoad File Selection DialogcCs.|��}tj�|�s |j��n
|�|�dSr&)rAr(r)�isfilerrEr6rUr"r"r#r�szLoadFileDialog.ok_commandN�rYrZr[r\rrr"r"r"r#r]�sr]c@seZdZdZdZdd�ZdS)�SaveFileDialogz@File selection dialog which checks that the file may be created.zSave File Selection DialogcCs�|��}tj�|�rZtj�|�r.|j��dSt|jdd|fdddd�}|j	dkr�dSn*tj�
|�\}}tj�|�s�|j��dS|�|�dS)Nz Overwrite Existing File QuestionzOverwrite existing file %r?Z	questheadr)ZYesr)rr
Zbitmapr3Zstringsr)rAr(r)�existsr+rrErrZnumr,r6)r!r@�drQrRr"r"r#r�s&
�

zSaveFileDialog.ok_commandNr_r"r"r"r#r`�sr`c@seZdZdd�Zdd�ZdS)�_DialogcCs2zt|jd�|jd<Wntk
r,YnXdS)N�	filetypes)�tuple�options�KeyErrorrBr"r"r#�_fixoptions,sz_Dialog._fixoptionscCsR|rHz
|j}Wntk
r"YnXtj�|�\}}||jd<||jd<||_|S)N�
initialdirZinitialfile)�string�AttributeErrorr(r)r,rf�filename�r!�widget�resultr)r@r"r"r#�
_fixresult3s


z_Dialog._fixresultN)rYrZr[rhrpr"r"r"r#rc*srcc@seZdZdZdZdd�ZdS)�Open�Ask for a filename to openZtk_getOpenFilecCsxt|t�rBtdd�|D��}|r>tj�|d�\}}||jd<|S|j��sjd|jkrj|�||j�	|��St
�|||�S)NcSsg|]}t|d|��qS)rj)�getattr)�.0�rr"r"r#�
<listcomp>Nsz#Open._fixresult.<locals>.<listcomp>rri�multiple)�
isinstancerer(r)r,rfZtkZwantobjectsrpZ	splitlistrcrmr"r"r#rpKs

zOpen._fixresultN�rYrZr[r\rrpr"r"r"r#rqFsrqc@seZdZdZdZdS)�SaveAs�Ask for a filename to save asZtk_getSaveFileN)rYrZr[r\rr"r"r"r#rzZsrzc@seZdZdZdZdd�ZdS)�	DirectoryzAsk for a directoryZtk_chooseDirectorycCs8|r.z
|j}Wntk
r"YnX||jd<||_|S)Nri)rjrkrfr)r!rnror"r"r#rpfs

zDirectory._fixresultNryr"r"r"r#r|asr|cKstf|���S)rr�rq�show�rfr"r"r#�askopenfilenamewsr�cKstf|���S)r{)rzr~rr"r"r#�asksaveasfilename}sr�cKsd|d<tf|���S)ztAsk for multiple filenames to open

    Returns a list of filenames or empty list if
    cancel button selected
    rrwr}rr"r"r#�askopenfilenames�sr�rucKs tf|���}|rt||�SdS)z8Ask for a filename to open, and returned the opened fileN)rqr~�open��moderfrlr"r"r#�askopenfile�s
r�cKs4tf|�}|r0g}|D]}|�t||��q|}|S)z�Ask for multiple filenames and return the open file
    objects

    returns a list of open file objects or an empty list if
    cancel selected
    )r�rHr�)r�rfrZofilesrlr"r"r#�askopenfiles�s
r��wcKs tf|���}|rt||�SdS)z;Ask for a filename to save as, and returned the opened fileN)rzr~r�r�r"r"r#�
asksaveasfile�s
r�cKstf|���S)z-Ask for a directory, and return the file name)r|r~rr"r"r#�askdirectory�sr�c
	Cs�t�}|��t|�}|jdd�}t|�}|jdd�}t||�d}ddl}z&ddl}|�|j	d�|�
|j�}Wntt
fk
r�YnXtdgd�}zt|d	�}|��Wn$td
�t|��d�YnXtd|�|��t�}	td
|	�|��dS)zSimple test program.�test)r4zutf-8rNr%)z	all filesr)rdruzCould not open File: rr�Zsaveas)ZTkZwithdrawr]r5r`�print�sys�locale�	setlocale�LC_ALL�nl_langinfo�CODESET�ImportErrorrkr�r��close�exc_info�encoder�)
�root�fdZloadfileZsavefile�encr�r�Zopenfilename�fpZsaveasfilenamer"r"r#r��s2

r��__main__)ru)ru)r�)r\ZtkinterZtkinter.dialogrrZtkinter.simpledialogrr(rIr'rr]r`rcrqrzr|r�r�r�r�r�r�r�r�rYr"r"r"r#�<module>s2I9
	

	,
PK+�\寉�CC!colorchooser.cpython-38.opt-2.pycnu�[���U

e5dA
�@s>ddlmZGdd�de�Zd	dd�Zedkr:ede��dS)
�)�Dialogc@s eZdZdZdd�Zdd�ZdS)�ChooserZtk_chooseColorcCs@z&|jd}t|t�r$d||jd<Wntk
r:YnXdS)N�initialcolorz
#%02x%02x%02x)�options�
isinstance�tuple�KeyError)�self�color�r�,/usr/lib64/python3.8/tkinter/colorchooser.py�_fixoptions!s

zChooser._fixoptionscCs>|rt|�sdS|�|�\}}}|d|d|dft|�fS)N)NN�)�strZ	winfo_rgb)r	Zwidget�result�r�g�brrr�
_fixresult.szChooser._fixresultN)�__name__�
__module__�__qualname__Zcommandr
rrrrrrs
rNcKs"|r|��}||d<tf|���S)Nr)�copyrZshow)r
rrrr�askcolorBsr�__main__r
)N)Ztkinter.commondialogrrrr�printrrrr�<module>s3
PK+�\��z`,,dnd.cpython-38.opt-1.pycnu�[���U

e5d�,�@sXdZddlZdd�ZGdd�d�ZGdd�d�ZGd	d
�d
�Zdd�Zed
krTe�dS)aFDrag-and-drop support for Tkinter.

This is very preliminary.  I currently only support dnd *within* one
application, between different windows (or within the same window).

I am trying to make this as generic as possible -- not dependent on
the use of a particular widget or icon type, etc.  I also hope that
this will work with Pmw.

To enable an object to be dragged, you must create an event binding
for it that starts the drag-and-drop process. Typically, you should
bind <ButtonPress> to a callback function that you write. The function
should call Tkdnd.dnd_start(source, event), where 'source' is the
object to be dragged, and 'event' is the event that invoked the call
(the argument to your callback function).  Even though this is a class
instantiation, the returned instance should not be stored -- it will
be kept alive automatically for the duration of the drag-and-drop.

When a drag-and-drop is already in process for the Tk interpreter, the
call is *ignored*; this normally averts starting multiple simultaneous
dnd processes, e.g. because different button callbacks all
dnd_start().

The object is *not* necessarily a widget -- it can be any
application-specific object that is meaningful to potential
drag-and-drop targets.

Potential drag-and-drop targets are discovered as follows.  Whenever
the mouse moves, and at the start and end of a drag-and-drop move, the
Tk widget directly under the mouse is inspected.  This is the target
widget (not to be confused with the target object, yet to be
determined).  If there is no target widget, there is no dnd target
object.  If there is a target widget, and it has an attribute
dnd_accept, this should be a function (or any callable object).  The
function is called as dnd_accept(source, event), where 'source' is the
object being dragged (the object passed to dnd_start() above), and
'event' is the most recent event object (generally a <Motion> event;
it can also be <ButtonPress> or <ButtonRelease>).  If the dnd_accept()
function returns something other than None, this is the new dnd target
object.  If dnd_accept() returns None, or if the target widget has no
dnd_accept attribute, the target widget's parent is considered as the
target widget, and the search for a target object is repeated from
there.  If necessary, the search is repeated all the way up to the
root widget.  If none of the target widgets can produce a target
object, there is no target object (the target object is None).

The target object thus produced, if any, is called the new target
object.  It is compared with the old target object (or None, if there
was no old target widget).  There are several cases ('source' is the
source object, and 'event' is the most recent event object):

- Both the old and new target objects are None.  Nothing happens.

- The old and new target objects are the same object.  Its method
dnd_motion(source, event) is called.

- The old target object was None, and the new target object is not
None.  The new target object's method dnd_enter(source, event) is
called.

- The new target object is None, and the old target object is not
None.  The old target object's method dnd_leave(source, event) is
called.

- The old and new target objects differ and neither is None.  The old
target object's method dnd_leave(source, event), and then the new
target object's method dnd_enter(source, event) is called.

Once this is done, the new target object replaces the old one, and the
Tk mainloop proceeds.  The return value of the methods mentioned above
is ignored; if they raise an exception, the normal exception handling
mechanisms take over.

The drag-and-drop processes can end in two ways: a final target object
is selected, or no final target object is selected.  When a final
target object is selected, it will always have been notified of the
potential drop by a call to its dnd_enter() method, as described
above, and possibly one or more calls to its dnd_motion() method; its
dnd_leave() method has not been called since the last call to
dnd_enter().  The target is notified of the drop by a call to its
method dnd_commit(source, event).

If no final target object is selected, and there was an old target
object, its dnd_leave(source, event) method is called to complete the
dnd sequence.

Finally, the source object is notified that the drag-and-drop process
is over, by a call to source.dnd_end(target, event), specifying either
the selected target object, or None if no target object was selected.
The source object can use this to implement the commit action; this is
sometimes simpler than to do it in the target's dnd_commit().  The
target's dnd_commit() method could then simply be aliased to
dnd_leave().

At any time during a dnd sequence, the application can cancel the
sequence by calling the cancel() method on the object returned by
dnd_start().  This will call dnd_leave() if a target is currently
active; it will never call dnd_commit().

�NcCst||�}|jr|SdSdS�N)�
DndHandler�root)�source�event�h�r�#/usr/lib64/python3.8/tkinter/dnd.py�	dnd_startls
r
c@sDeZdZdZdd�Zdd�Zdd�Zdd	�Zdd
d�Zdd
d�Z	dS)rNcCs�|jdkrdS|j��}z|jWdStk
rD||_||_YnX||_d|_|j|_}|j|_	}d||f|_
|dp�d|_|�|j
|j
�|�d|j�d|d<dS)N�z<B%d-ButtonRelease-%d>�cursor��<Motion>Zhand2)Znum�widgetZ_root�_DndHandler__dnd�AttributeErrorrr�targetZinitial_button�initial_widget�release_pattern�save_cursor�bind�
on_release�	on_motion)�selfrrrZbuttonrrrr	�__init__zs$

zDndHandler.__init__cCs2|j}d|_|r.z|`Wntk
r,YnXdSr)rrr�rrrrr	�__del__�szDndHandler.__del__c	Cs�|j|j}}|j�||�}|j}d}|rbz
|j}Wntk
rHYnX|||�}|rZqb|j}q&|j}||kr�|r�|�	||�n,|r�d|_|�
||�|r�|�||�||_dSr)�x_root�y_rootrZwinfo_containingr�
dnd_acceptrZmasterr�
dnd_motion�	dnd_leave�	dnd_enter)	rr�x�yZ
target_widgetr�
new_target�attrZ
old_targetrrr	r�s.

zDndHandler.on_motioncCs|�|d�dS)N���finish�rrrrr	r�szDndHandler.on_releasecCs|�|d�dS)Nrr(r*rrr	�cancel�szDndHandler.cancelrc
Cs�|j}|j}|j}|j}zf|`|j�|j�|j�d�|j|d<d|_|_|_|_|r||rp|�	||�n|�
||�W5|�||�XdS)Nrr)rrrr�dnd_endrZunbindrr�
dnd_commitr!)rrZcommitrrrrrrr	r)�s
zDndHandler.finish)N)r)
�__name__�
__module__�__qualname__rrrrrr+r)rrrr	rvs	
rc@sNeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�IconcCs||_d|_|_|_dSr)�name�canvas�label�id)rr2rrr	r�sz
Icon.__init__�
cCs�||jkr |j�|j||�dS|jr.|��|s6dStj||jddd�}|j|||dd�}||_||_||_|�	d|j
�dS)N�Zraised)�textZborderwidthZreliefZnw)ZwindowZanchorz
<ButtonPress>)r3�coordsr5�detach�tkinterZLabelr2Z
create_windowr4r�press)rr3r#r$r4r5rrr	�attach�s 

�zIcon.attachcCsB|j}|sdS|j}|j}d|_|_|_|�|�|��dSr)r3r5r4�deleteZdestroy)rr3r5r4rrr	r:�s
zIcon.detachcCs4t||�r0|j|_|j|_|j�|j�\|_|_	dSr)
r
r#�x_offr$�y_offr3r9r5�x_orig�y_origr*rrr	r<�s
z
Icon.presscCs(|�|j|�\}}|j�|j||�dSr)�wherer3r9r5)rrr#r$rrr	�move�sz	Icon.movecCs|j�|j|j|j�dSr)r3r9r5rArB)rrrr	�putback�szIcon.putbackcCs8|��}|��}|j|}|j|}||j||jfSr)Zwinfo_rootxZwinfo_rootyrrr?r@)rr3rZx_orgZy_orgr#r$rrr	rC�s


z
Icon.wherecCsdSrr)rrrrrr	r,szIcon.dnd_endN)r6r6)r.r/r0rr=r:r<rDrErCr,rrrr	r1�s


r1c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestercCs>t�|�|_tj|jddd�|_|jjddd�|j|j_dS)N�d)�widthZheightZbothr')Zfill�expand)r;ZToplevel�topZCanvasr3�packrrrrr	rszTester.__init__cCs|Srr�rrrrrr	rszTester.dnd_acceptcCsp|j��|�|j|�\}}|j�|j�\}}}}||||}	}
|j�||||	||
�|_|�||�dSr)r3�	focus_setrC�bboxr5Zcreate_rectangle�dndidr )rrrr#r$�x1�y1�x2�y2ZdxZdyrrr	r"s
zTester.dnd_enterc	CsF|�|j|�\}}|j�|j�\}}}}|j�|j||||�dSr)rCr3rNrOrD)	rrrr#r$rPrQrRrSrrr	r szTester.dnd_motioncCs"|j��|j�|j�d|_dSr)rJrMr3r>rOrLrrr	r!$s
zTester.dnd_leavecCs2|�||�|�|j|�\}}|�|j||�dSr)r!rCr3r=)rrrr#r$rrr	r-)szTester.dnd_commitN)	r.r/r0rrr"r r!r-rrrr	rFsrFcCs�t��}|�d�tj|jdd���t|�}|j�d�t|�}|j�d�t|�}|j�d�td�}td�}td	�}|�	|j
�|�	|j
�|�	|j
�|��dS)
Nz+1+1ZQuit)Zcommandr8z+1+60z+120+60z+240+60ZICON1ZICON2ZICON3)r;ZTkZgeometryZButton�quitrKrFrJr1r=r3Zmainloop)r�t1�t2Zt3Zi1Zi2Zi3rrr	�test/s 
rW�__main__)�__doc__r;r
rr1rFrWr.rrrr	�<module>sf
Y=#PK+�\M��font.cpython-38.opt-1.pycnu�[���U

e5d@�@szdZddlZddlZdZdZdZdZdd�ZGd	d
�d
�Zd dd�Z	d!d
d�Z
edk�rve��Z
edded�Zee���ee�d��ee�d��ee���ee�d��ee�d��ee
��ee�d�e�d��eeje
d��edd�Zee�d�ejde
d��eje
ded�Ze��eje
de
jd�Ze��eedd���Zejed�ejed�e��dS)"z0.9�NZnormalZroman�boldZitaliccCst|dd�S)zFGiven the name of a tk named font, returns a Font representation.
    T)�name�exists)�Font�r�r�$/usr/lib64/python3.8/tkinter/font.py�
nametofontsr	c@s�eZdZdZe�d�Zdd�Zdd�Zdd�Z	d#dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd$dd�Zdd�Zdd�ZeZd%dd �Zd!d"�Zd	S)&ra�Represents a named font.

    Constructor options are:

    font -- font specifier (name, system font, or (family, size, style)-tuple)
    name -- name to use for this font configuration (defaults to a unique name)
    exists -- does a named font by this name already exist?
       Creates a new named font if False, points to the existing font if True.
       Raises _tkinter.TclError if the assertion is false.

       the following are ignored if font is specified:

    family -- font 'family', e.g. Courier, Times, Helvetica
    size -- font size in points
    weight -- font thickness: NORMAL, BOLD
    slant -- font slant: ROMAN, ITALIC
    underline -- font underlining: false (0), true (1)
    overstrike -- font strikeout: false (0), true (1)

    �cCs:g}|��D]$\}}|�d|�|�t|��qt|�S�N�-)�items�append�str�tuple)�self�kw�options�k�vrrr�_set1s
z	Font._setcCs$g}|D]}|�d|�qt|�Sr)rr)r�argsrrrrr�_get8sz	Font._getcCs:i}tdt|�d�D] }||d|||dd�<q|S)Nr�r
)�range�len)rrr�irrr�_mkdict>szFont._mkdictNFcKs�|st�d�}t|d|�}|r4|�|�dd|��}n
|�|�}|sTdtt|j��}||_	|r�d|_
|j	|�|�dd��kr�tj�d|j	f��|r�|jdd|j	f|��n|jdd	|j	f|��d
|_
||_
|j|_|j|_dS)Nzuse font�tk�font�actualF�namesz$named font %s does not already exist�	configureZcreateT)�tkinter�_get_default_root�getattr�	splitlist�callrr�next�counterr�delete_fontZ_tkinterZTclError�_tk�_split�_call)r�rootrrrrrrrr�__init__Ds,


�z
Font.__init__cCs|jS�Nr�rrrr�__str__cszFont.__str__cCs&t|t�stS|j|jko$|j|jkSr0)�
isinstancer�NotImplementedrr+)r�otherrrr�__eq__fs
zFont.__eq__cCs
|�|�Sr0)�cget)r�keyrrr�__getitem__kszFont.__getitem__cCs|jf||i�dSr0)r")rr8�valuerrr�__setitem__nszFont.__setitem__cCs4z|jr|�dd|j�Wntk
r.YnXdS)Nr�delete)r*r-r�	Exceptionr1rrr�__del__qs
zFont.__del__cCst|jf|���S)z*Return a distinct copy of the current font)rr+r r1rrr�copyxsz	Font.copycCs^d}|rd|f}|r8|d|f}|jdd|jf|��S|�|�|jdd|jf|����SdS)zReturn actual font attributesr�
-displayofrrr N)r-rrr,)r�option�	displayofrrrrr |s�zFont.actualcCs|�dd|jd|�S)zGet font attributer�configr)r-r)rrArrrr7�sz	Font.cgetc	KsB|r"|jdd|jf|�|���n|�|�|�dd|j���SdS)zModify font attributesrrCN)r-rrrr,)rrrrrrC�s��zFont.configcCs2|f}|rd||f}|j�|jdd|jf|���S)zReturn text widthr@r�measure)r+�getintr-r)r�textrBrrrrrD�s
zFont.measurecOs�d}|�dd�}|rd|f}|rL||�|�}|j�|jdd|jf|���S|�|jdd|jf|���}i}tdt|�d�D](}|j�||d	�|||d	d�<q||SdS)
z}Return font metrics.

        For best performance, create a dummy widget
        using this font before calling this method.rrBNr@r�metricsrrr
)	�poprr+rEr-rr,rr)rrrrrB�resrrrrrG�s�&zFont.metrics)NNNF)NN)N)�__name__�
__module__�__qualname__�__doc__�	itertools�countr)rrrr/r2r6r9r;r>r?r r7rCr"rDrGrrrrrs$


	
rcCs6|st�d�}d}|rd|f}|j�|jjd|���S)zGet font families (as a tuple)zuse font.families()rr@r�families)rrP�r#r$rr&r')r.rBrrrrrP�s
rPcCs$|st�d�}|j�|j�dd��S)z'Get names of defined fonts (as a tuple)zuse font.names()rr!rQ)r.rrrr!�s
r!�__main__�times�)�family�size�weightrUrWZhelloZ	linespace)rB)ZCourier�r)rzHello, world)rFrzQuit!)rFZcommandr)rW)NN)N)�__version__rNr#ZNORMALZROMANZBOLDZITALICr	rrPr!rJZTkr.�f�printr rCr7rDrGZLabel�wZpackZButtonZdestroyr?ZfbZmainlooprrrr�<module>sB






PK+�\M��font.cpython-38.pycnu�[���U

e5d@�@szdZddlZddlZdZdZdZdZdd�ZGd	d
�d
�Zd dd�Z	d!d
d�Z
edk�rve��Z
edded�Zee���ee�d��ee�d��ee���ee�d��ee�d��ee
��ee�d�e�d��eeje
d��edd�Zee�d�ejde
d��eje
ded�Ze��eje
de
jd�Ze��eedd���Zejed�ejed�e��dS)"z0.9�NZnormalZroman�boldZitaliccCst|dd�S)zFGiven the name of a tk named font, returns a Font representation.
    T)�name�exists)�Font�r�r�$/usr/lib64/python3.8/tkinter/font.py�
nametofontsr	c@s�eZdZdZe�d�Zdd�Zdd�Zdd�Z	d#dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd$dd�Zdd�Zdd�ZeZd%dd �Zd!d"�Zd	S)&ra�Represents a named font.

    Constructor options are:

    font -- font specifier (name, system font, or (family, size, style)-tuple)
    name -- name to use for this font configuration (defaults to a unique name)
    exists -- does a named font by this name already exist?
       Creates a new named font if False, points to the existing font if True.
       Raises _tkinter.TclError if the assertion is false.

       the following are ignored if font is specified:

    family -- font 'family', e.g. Courier, Times, Helvetica
    size -- font size in points
    weight -- font thickness: NORMAL, BOLD
    slant -- font slant: ROMAN, ITALIC
    underline -- font underlining: false (0), true (1)
    overstrike -- font strikeout: false (0), true (1)

    �cCs:g}|��D]$\}}|�d|�|�t|��qt|�S�N�-)�items�append�str�tuple)�self�kw�options�k�vrrr�_set1s
z	Font._setcCs$g}|D]}|�d|�qt|�Sr)rr)r�argsrrrrr�_get8sz	Font._getcCs:i}tdt|�d�D] }||d|||dd�<q|S)Nr�r
)�range�len)rrr�irrr�_mkdict>szFont._mkdictNFcKs�|st�d�}t|d|�}|r4|�|�dd|��}n
|�|�}|sTdtt|j��}||_	|r�d|_
|j	|�|�dd��kr�tj�d|j	f��|r�|jdd|j	f|��n|jdd	|j	f|��d
|_
||_
|j|_|j|_dS)Nzuse font�tk�font�actualF�namesz$named font %s does not already exist�	configureZcreateT)�tkinter�_get_default_root�getattr�	splitlist�callrr�next�counterr�delete_fontZ_tkinterZTclError�_tk�_split�_call)r�rootrrrrrrrr�__init__Ds,


�z
Font.__init__cCs|jS�Nr�rrrr�__str__cszFont.__str__cCs&t|t�stS|j|jko$|j|jkSr0)�
isinstancer�NotImplementedrr+)r�otherrrr�__eq__fs
zFont.__eq__cCs
|�|�Sr0)�cget)r�keyrrr�__getitem__kszFont.__getitem__cCs|jf||i�dSr0)r")rr8�valuerrr�__setitem__nszFont.__setitem__cCs4z|jr|�dd|j�Wntk
r.YnXdS)Nr�delete)r*r-r�	Exceptionr1rrr�__del__qs
zFont.__del__cCst|jf|���S)z*Return a distinct copy of the current font)rr+r r1rrr�copyxsz	Font.copycCs^d}|rd|f}|r8|d|f}|jdd|jf|��S|�|�|jdd|jf|����SdS)zReturn actual font attributesr�
-displayofrrr N)r-rrr,)r�option�	displayofrrrrr |s�zFont.actualcCs|�dd|jd|�S)zGet font attributer�configr)r-r)rrArrrr7�sz	Font.cgetc	KsB|r"|jdd|jf|�|���n|�|�|�dd|j���SdS)zModify font attributesrrCN)r-rrrr,)rrrrrrC�s��zFont.configcCs2|f}|rd||f}|j�|jdd|jf|���S)zReturn text widthr@r�measure)r+�getintr-r)r�textrBrrrrrD�s
zFont.measurecOs�d}|�dd�}|rd|f}|rL||�|�}|j�|jdd|jf|���S|�|jdd|jf|���}i}tdt|�d�D](}|j�||d	�|||d	d�<q||SdS)
z}Return font metrics.

        For best performance, create a dummy widget
        using this font before calling this method.rrBNr@r�metricsrrr
)	�poprr+rEr-rr,rr)rrrrrB�resrrrrrG�s�&zFont.metrics)NNNF)NN)N)�__name__�
__module__�__qualname__�__doc__�	itertools�countr)rrrr/r2r6r9r;r>r?r r7rCr"rDrGrrrrrs$


	
rcCs6|st�d�}d}|rd|f}|j�|jjd|���S)zGet font families (as a tuple)zuse font.families()rr@r�families)rrP�r#r$rr&r')r.rBrrrrrP�s
rPcCs$|st�d�}|j�|j�dd��S)z'Get names of defined fonts (as a tuple)zuse font.names()rr!rQ)r.rrrr!�s
r!�__main__�times�)�family�size�weightrUrWZhelloZ	linespace)rB)ZCourier�r)rzHello, world)rFrzQuit!)rFZcommandr)rW)NN)N)�__version__rNr#ZNORMALZROMANZBOLDZITALICr	rrPr!rJZTkr.�f�printr rCr7rDrGZLabel�wZpackZButtonZdestroyr?ZfbZmainlooprrrr�<module>sB






PK+�\v��ZZcommondialog.cpython-38.pycnu�[���U

e5d��@sddlTGdd�d�ZdS)�)�*c@s2eZdZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�DialogNcKs|s|�d�}||_||_dS)N�parent)�get�master�options)�selfrr�r	�,/usr/lib64/python3.8/tkinter/commondialog.py�__init__s
zDialog.__init__cCsdS�Nr	)rr	r	r
�_fixoptionsszDialog._fixoptionscCs|Srr	)rZwidget�resultr	r	r
�
_fixresultszDialog._fixresultcKs||��D]\}}||j|<q|��t|j�}z,|jj|jf|�	|j���}|�
||�}W5z|��WnYnXX|Sr)�itemsrr
ZFramerZdestroyZtkZcall�commandZ_optionsr)rr�k�v�w�sr	r	r
�shows
zDialog.show)N)�__name__�
__module__�__qualname__rrr
rrr	r	r	r
rs

rN)Ztkinterrr	r	r	r
�<module>sPK+�\��00filedialog.cpython-38.pycnu�[���U

e5d�8�@sdZddlTddlmZddlmZddlmZddlZddlZiZ	Gdd�d�Z
Gd	d
�d
e
�ZGdd�de
�ZGd
d�dej�Z
Gdd�de
�ZGdd�de
�ZGdd�dej�Zdd�Zdd�Zdd�Zd(dd�Zd)dd�Zd*d!d"�Zd#d$�Zd%d&�Zed'k�re�dS)+aUFile selection dialog classes.

Classes:

- FileDialog
- LoadFileDialog
- SaveFileDialog

This module also presents tk common file dialogues, it provides interfaces
to the native file dialogues available in Tk 4.2 and newer, and the
directory dialogue available in Tk 8.3 and newer.
These interfaces were written by Fredrik Lundh, May 1997.
�)�*)�Dialog)�commondialog)�
_setup_dialogNc@s�eZdZdZdZd$dd�Zejdddfdd	�Zd%d
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd&dd�Zdd�Zdd�Zd'dd�Zd d!�Zd"d#�ZdS)(�
FileDialoga�Standard file selection dialog -- no checks on selected file.

    Usage:

        d = FileDialog(master)
        fname = d.go(dir_or_file, pattern, default, key)
        if fname is None: ...canceled...
        else: ...open file...

    All arguments to go() are optional.

    The 'key' argument specifies a key in the global dictionary
    'dialogstates', which keeps track of the values for the directory
    and pattern arguments, overriding the values passed in (it does
    not keep track of the default argument!).  If no key is specified,
    the dialog keeps no memory of previous state.  Note that memory is
    kept even when the dialog is canceled.  (All this emulates the
    behavior of the Macintosh file selection dialogs.)

    zFile Selection DialogNcCs�|dkr|j}||_d|_t|�|_|j�|�|j�|�t|j�t|j�|_|jj	t
td�t|j�|_
|j
j	t
td�|j
�d|j�t|j�|_|jj	ttd�|j�d|j�t|j�|_|jj	ttd�t|j�|_|jj	ttd�t|jd|jdfd�|_|jj	tttd�|j��}|j�|dd�|dd��|j�d	|j�|j�d
|j�|jj|jdfd�t|j�|_ |j j	t!td�t|jd|j dfd�|_"|j"j	t!ttd�|j j|j"dfd�|j"��}|j"�|dd�|dd��|j"�d	|j#�|j"�d
|j$�t%|jd
|j&d�|_'|j'j	t!d�t%|jd|jd�|_(|j(j	t!td�t%|jd|j)d�|_*|j*j	td�|j�+d|j)�|j�d|j)�|j�d|j)�dS)N)�side�fillz<Return>)�expandrr�set)ZexportselectionZyscrollcommand)rr	r�z<ButtonRelease-1>z<Double-ButtonRelease-1>Zyview)�commandZOK)�textr)rZFilter)rr	�CancelZWM_DELETE_WINDOWz<Alt-w>z<Alt-W>),�title�master�	directoryZToplevel�topZiconnamerZFrameZbotframeZpackZBOTTOM�XZEntry�	selectionZbind�ok_event�filterZTOP�filter_commandZmidframeZYESZBOTHZ	ScrollbarZfilesbarZRIGHT�YZListbox�filesZbindtags�files_select_event�files_double_eventZconfigZdirsbarZLEFT�dirs�dirs_select_event�dirs_double_eventZButton�
ok_commandZ	ok_buttonZ
filter_button�cancel_commandZ
cancel_buttonZprotocol)�selfrrZbtags�r"�*/usr/lib64/python3.8/tkinter/filedialog.py�__init__4st

�
 �
 ���zFileDialog.__init__r�cCs�|r|tkrt|\|_}n2tj�|�}tj�|�r<||_ntj�|�\|_}|�|j|�|�|�|�	�|j
��|j�
�|j��d|_|j��|r�|��\}}|jr�tj�|j�}||ft|<|j��|jS�N)�dialogstatesr�os�path�
expanduser�isdir�split�
set_filter�
set_selectionrrZ	focus_setrZwait_visibilityZgrab_set�howrZmainloop�
get_filter�dirnameZdestroy)r!Zdir_or_file�pattern�default�keyrr"r"r#�gots*





z
FileDialog.gocCs||_|j��dSr&)r/r�quit)r!r/r"r"r#r6�szFileDialog.quitcCs|��dSr&)r�r!�eventr"r"r#r�szFileDialog.dirs_double_eventcCs@|��\}}|j�d�}tj�tj�|j|��}|�||�dS�NZactive)	r0r�getr(r)�normpath�joinrr-)r!r8�dir�patZsubdirr"r"r#r�szFileDialog.dirs_select_eventcCs|��dSr&�rr7r"r"r#r�szFileDialog.files_double_eventcCs|j�d�}|�|�dSr9)rr:r.)r!r8�filer"r"r#r�szFileDialog.files_select_eventcCs|��dSr&r?r7r"r"r#r�szFileDialog.ok_eventcCs|�|���dSr&)r6�
get_selection�r!r"r"r#r�szFileDialog.ok_commandcCs&|��\}}zt�|�}Wn tk
r:|j��YdSX||_|�||�|��tj	g}g}|D]@}tj
�||�}tj
�|�r�|�
|�qft�||�rf|�
|�qf|j�dt�|D]}|j�t|�q�|j�dt�|D]}|j�t|�q�tj
�|���\}	}
|
tjk�rd}
|�|
�dS)Nrr%)r0r(�listdir�OSErrorr�bellrr-�sort�pardirr)r<r+�append�fnmatchr�delete�END�insertrr,rA�curdirr.)r!r8r=r>�namesZsubdirsZ
matchingfiles�name�fullname�head�tailr"r"r#r�s6
zFileDialog.filter_commandcCsN|j��}tj�|�}|dd�tjks4tj�|�rBtj�|d�}tj�|�S)N���r)	rr:r(r)r*�sepr+r<r,)r!rr"r"r#r0�s

zFileDialog.get_filtercCs|j��}tj�|�}|Sr&)rr:r(r)r*�r!r@r"r"r#rA�s
zFileDialog.get_selectioncCs|��dSr&)r6r7r"r"r#r �szFileDialog.cancel_commandcCs�tj�|�sPzt��}Wntk
r0d}YnX|rPtj�||�}tj�|�}|j�dt	�|j�
t	tj�|pttj|pzd��dS)Nrr)r(r)�isabs�getcwdrDr<r;rrJrKrLrM)r!r=r>�pwdr"r"r#r-�s
zFileDialog.set_filtercCs,|j�dt�|j�ttj�|j|��dS)Nr)rrJrKrLr(r)r<rrUr"r"r#r.�szFileDialog.set_selection)N)N)N)N)�__name__�
__module__�__qualname__�__doc__rr$r(rMr5r6rrrrrrrr0rAr r-r.r"r"r"r#rs"
@


rc@seZdZdZdZdd�ZdS)�LoadFileDialogz8File selection dialog which checks that the file exists.zLoad File Selection DialogcCs.|��}tj�|�s |j��n
|�|�dSr&)rAr(r)�isfilerrEr6rUr"r"r#r�szLoadFileDialog.ok_commandN�rYrZr[r\rrr"r"r"r#r]�sr]c@seZdZdZdZdd�ZdS)�SaveFileDialogz@File selection dialog which checks that the file may be created.zSave File Selection DialogcCs�|��}tj�|�rZtj�|�r.|j��dSt|jdd|fdddd�}|j	dkr�dSn*tj�
|�\}}tj�|�s�|j��dS|�|�dS)Nz Overwrite Existing File QuestionzOverwrite existing file %r?Z	questheadr)ZYesr)rr
Zbitmapr3Zstringsr)rAr(r)�existsr+rrErrZnumr,r6)r!r@�drQrRr"r"r#r�s&
�

zSaveFileDialog.ok_commandNr_r"r"r"r#r`�sr`c@seZdZdd�Zdd�ZdS)�_DialogcCs2zt|jd�|jd<Wntk
r,YnXdS)N�	filetypes)�tuple�options�KeyErrorrBr"r"r#�_fixoptions,sz_Dialog._fixoptionscCsR|rHz
|j}Wntk
r"YnXtj�|�\}}||jd<||jd<||_|S)N�
initialdirZinitialfile)�string�AttributeErrorr(r)r,rf�filename�r!�widget�resultr)r@r"r"r#�
_fixresult3s


z_Dialog._fixresultN)rYrZr[rhrpr"r"r"r#rc*srcc@seZdZdZdZdd�ZdS)�Open�Ask for a filename to openZtk_getOpenFilecCsxt|t�rBtdd�|D��}|r>tj�|d�\}}||jd<|S|j��sjd|jkrj|�||j�	|��St
�|||�S)NcSsg|]}t|d|��qS)rj)�getattr)�.0�rr"r"r#�
<listcomp>Nsz#Open._fixresult.<locals>.<listcomp>rri�multiple)�
isinstancerer(r)r,rfZtkZwantobjectsrpZ	splitlistrcrmr"r"r#rpKs

zOpen._fixresultN�rYrZr[r\rrpr"r"r"r#rqFsrqc@seZdZdZdZdS)�SaveAs�Ask for a filename to save asZtk_getSaveFileN)rYrZr[r\rr"r"r"r#rzZsrzc@seZdZdZdZdd�ZdS)�	DirectoryzAsk for a directoryZtk_chooseDirectorycCs8|r.z
|j}Wntk
r"YnX||jd<||_|S)Nri)rjrkrfr)r!rnror"r"r#rpfs

zDirectory._fixresultNryr"r"r"r#r|asr|cKstf|���S)rr�rq�show�rfr"r"r#�askopenfilenamewsr�cKstf|���S)r{)rzr~rr"r"r#�asksaveasfilename}sr�cKsd|d<tf|���S)ztAsk for multiple filenames to open

    Returns a list of filenames or empty list if
    cancel button selected
    rrwr}rr"r"r#�askopenfilenames�sr�rucKs tf|���}|rt||�SdS)z8Ask for a filename to open, and returned the opened fileN)rqr~�open��moderfrlr"r"r#�askopenfile�s
r�cKs4tf|�}|r0g}|D]}|�t||��q|}|S)z�Ask for multiple filenames and return the open file
    objects

    returns a list of open file objects or an empty list if
    cancel selected
    )r�rHr�)r�rfrZofilesrlr"r"r#�askopenfiles�s
r��wcKs tf|���}|rt||�SdS)z;Ask for a filename to save as, and returned the opened fileN)rzr~r�r�r"r"r#�
asksaveasfile�s
r�cKstf|���S)z-Ask for a directory, and return the file name)r|r~rr"r"r#�askdirectory�sr�c
	Cs�t�}|��t|�}|jdd�}t|�}|jdd�}t||�d}ddl}z&ddl}|�|j	d�|�
|j�}Wntt
fk
r�YnXtdgd�}zt|d	�}|��Wn$td
�t|��d�YnXtd|�|��t�}	td
|	�|��dS)zSimple test program.�test)r4zutf-8rNr%)z	all filesr)rdruzCould not open File: rr�Zsaveas)ZTkZwithdrawr]r5r`�print�sys�locale�	setlocale�LC_ALL�nl_langinfo�CODESET�ImportErrorrkr�r��close�exc_info�encoder�)
�root�fdZloadfileZsavefile�encr�r�Zopenfilename�fpZsaveasfilenamer"r"r#r��s2

r��__main__)ru)ru)r�)r\ZtkinterZtkinter.dialogrrZtkinter.simpledialogrr(rIr'rr]r`rcrqrzr|r�r�r�r�r�r�r�r�rYr"r"r"r#�<module>s2I9
	

	,
PK+�\ҧ����dialog.cpython-38.opt-1.pycnu�[���U

e5d��@srddlTddlmZdZGdd�de�Zdd�Zedkrned	d
ddeeii�Z	ed	d
d
de	j
eii�Ze	��d	S)�)�*)�	_cnfmergeZ	questheadc@s"eZdZdifdd�Zdd�ZdS)�DialogNc
Ks�t||f�}d|_t�|||�|j�|jjd|j|d|d|d|df|d���|_zt�	|�Wnt
k
r~YnXdS)NZ
__dialog__Z	tk_dialog�title�text�bitmap�default�strings)rZ
widgetName�Widget�_setupZtkZgetintZcallZ_w�num�destroyZTclError)�selfZmasterZcnf�kw�r�&/usr/lib64/python3.8/tkinter/dialog.py�__init__
s&���zDialog.__init__cCsdS)Nr)rrrrr
�zDialog.destroy)�__name__�
__module__�__qualname__rr
rrrrr	s
rcCs$tdddtddd��}t|j�dS)Nz
File ModifiedzzFile "Python.h" has been modified since the last time it was saved. Do you want to save it before exiting the application.r)z	Save FilezDiscard ChangeszReturn to Editor)rrrrr	)r�DIALOG_ICON�printr)�drrr�_tests�r�__main__NrZTestZcommandZQuit)
Ztkinterrrr
rrrZButtonZPack�t�quit�qZmainlooprrrr�<module>s$��PK+�\�(1616tix.cpython-38.pycnu�[���U

e5d-,�@sLddlZddlZddlTddlmZddlZdZdZdZdZdZd	Z	d
Z
dZdZd
Z
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZGdd �d �Z Gd!d"�d"ej!e �Z!Gd#d$�d$�Z"ej#j$e"fej#_$Gd%d&�d&ej#�Z%Gd'd(�d(e%�Z&Gd)d*�d*�Z'Gd+d,�d,e%�Z(Gd-d.�d.e%�Z)Gd/d0�d0e%�Z*Gd1d2�d2e%�Z+Gd3d4�d4e%�Z,Gd5d6�d6e%�Z-Gd7d8�d8e%�Z.Gd9d:�d:e%�Z/Gd;d<�d<e%�Z0Gd=d>�d>e%�Z1Gd?d@�d@e%�Z2GdAdB�dBe%�Z3GdCdD�dDe%�Z4GdEdF�dFe%e5e6�Z7GdGdH�dHe%�Z8GdIdJ�dJe%�Z9GdKdL�dLe%�Z:GdMdN�dNe%�Z;GdOdP�dPe%�Z<GdQdR�dRe%�Z=GdSdT�dTe%�Z>GdUdV�dVe%�Z?GdWdX�dXe%�Z@GdYdZ�dZe%�ZAGd[d\�d\e%�ZBGd]d^�d^e%�ZCGd_d`�d`e%�ZDGdadb�dbe%�ZEGdcdd�dde%�ZFGdedf�dfe%�ZGGdgdh�dhe%�ZHGdidj�dje%�ZIGdkdl�dle%�ZJGdmdn�dne%�ZKGdodp�dpe%e5e6�ZLGdqdr�dre%�ZMGdsdt�dte%�ZNGdudv�dveOe&�ZPGdwdx�dxeQe&�ZRGdydz�dzeSe&�ZTGd{d|�d|eUe&�ZVGd}d~�d~eWe&�ZXGdd��d�eYe&�ZZGd�d��d�e[e&�Z\Gd�d��d�e]e&�Z^Gd�d��d�e_e&�Z`Gd�d��d�eae&�ZbGd�d��d�eDe&�ZcGd�d��d�e7e&�ZdGd�d��d�eCe&�ZeGd�d��d�eLe&�ZfGd�d��d�e*e&�ZgGd�d��d�e,e&�ZhGd�d��d�e.e&�ZiGd�d��d�e/e&�ZjGd�d��d�e2e&�ZkGd�d��d�e*e&�ZlGd�d��d�eKe&�ZmGd�d��d�e>e&�ZnGd�d��d�e@e&�Zod�d��Zpd�d��ZqGd�d��d�e%�ZrGd�d��d�e%e5e6�ZsGd�d��d�es�ZtdS)��N)�*)�	_cnfmerge�window�textZstatusZ	immediate�imageZ	imagetextZballoon�autoZ	acrosstop�asciiZcell�columnZ
decreasingZ
increasingZinteger�main�max�real�rowzs-regionzx-regionzy-region����� c@sVeZdZdZdd�Zdd�Zddd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
ddd�ZdS)�
tixCommanda�The tix commands provide access to miscellaneous  elements
    of  Tix's  internal state and the Tix application context.
    Most of the information manipulated by these  commands pertains
    to  the  application  as a whole, or to a screen or
    display, rather than to a particular window.

    This is a mixin class, assumed to be mixed to Tkinter.Tk
    that supports the self.tk.call method.
    cCs|j�dd|�S)a�Tix maintains a list of directories under which
        the  tix_getimage  and tix_getbitmap commands will
        search for image files. The standard bitmap  directory
        is $TIX_LIBRARY/bitmaps. The addbitmapdir command
        adds directory into this list. By  using  this
        command, the  image  files  of an applications can
        also be located using the tix_getimage or tix_getbitmap
        command.
        �tixZaddbitmapdir��tk�call)�selfZ	directory�r�#/usr/lib64/python3.8/tkinter/tix.py�tix_addbitmapdirRs
ztixCommand.tix_addbitmapdircCs|j�dd|�S)z�Returns  the  current  value  of the configuration
        option given by option. Option may be  any  of  the
        options described in the CONFIGURATION OPTIONS section.
        r�cgetr�r�optionrrr�tix_cget^sztixCommand.tix_cgetNcKsd|rt||f�}n|rt|�}|dkr2|�dd�St|t�rN|�ddd|�S|j�d|�|��S)a�Query or modify the configuration options of the Tix application
        context. If no option is specified, returns a dictionary all of the
        available options.  If option is specified with no value, then the
        command returns a list describing the one named option (this list
        will be identical to the corresponding sublist of the value
        returned if no option is specified).  If one or more option-value
        pairs are specified, then the command modifies the given option(s)
        to have the given value(s); in this case the command returns an
        empty string. Option may be any of the configuration options.
        Nr�	configure�-)rr )r�
_getconfigure�
isinstance�strZ_getconfigure1rr�_options�r�cnf�kwrrr�
tix_configurees
ztixCommand.tix_configurecCs*|dk	r|j�dd|�S|j�dd�SdS)a�Returns the file selection dialog that may be shared among
        different calls from this application.  This command will create a
        file selection dialog widget when it is called the first time. This
        dialog will be returned by all subsequent calls to tix_filedialog.
        An optional dlgclass parameter can be passed to specified what type
        of file selection dialog widget is desired. Possible options are
        tix FileSelectDialog or tixExFileSelectDialog.
        NrZ
filedialogr)rZdlgclassrrr�tix_filedialog{s	ztixCommand.tix_filedialogcCs|j�dd|�S)a�Locates a bitmap file of the name name.xpm or name in one of the
        bitmap directories (see the tix_addbitmapdir command above).  By
        using tix_getbitmap, you can avoid hard coding the pathnames of the
        bitmap files in your application. When successful, it returns the
        complete pathname of the bitmap file, prefixed with the character
        '@'.  The returned value can be used to configure the -bitmap
        option of the TK and Tix widgets.
        rZ	getbitmapr�r�namerrr�
tix_getbitmap�s	ztixCommand.tix_getbitmapcCs|j�dd|�S)a�Locates an image file of the name name.xpm, name.xbm or name.ppm
        in one of the bitmap directories (see the addbitmapdir command
        above). If more than one file with the same name (but different
        extensions) exist, then the image type is chosen according to the
        depth of the X display: xbm images are chosen on monochrome
        displays and color images are chosen on color displays. By using
        tix_ getimage, you can avoid hard coding the pathnames of the
        image files in your application. When successful, this command
        returns the name of the newly created image, which can be used to
        configure the -image option of the Tk and Tix widgets.
        rZgetimagerr+rrr�tix_getimage�sztixCommand.tix_getimagecCs|j�ddd|�S)a@Gets  the options  maintained  by  the  Tix
        scheme mechanism. Available options include:

            active_bg       active_fg      bg
            bold_font       dark1_bg       dark1_fg
            dark2_bg        dark2_fg       disabled_fg
            fg              fixed_font     font
            inactive_bg     inactive_fg    input1_bg
            input2_bg       italic_font    light1_bg
            light1_fg       light2_bg      light2_fg
            menu_font       output1_bg     output2_bg
            select_bg       select_fg      selector
            rr�getrr+rrr�tix_option_get�sztixCommand.tix_option_getcCs2|dk	r|j�dd|||�S|j�dd||�SdS)a�Resets the scheme and fontset of the Tix application to
        newScheme and newFontSet, respectively.  This affects only those
        widgets created after this call. Therefore, it is best to call the
        resetoptions command before the creation of any widgets in a Tix
        application.

        The optional parameter newScmPrio can be given to reset the
        priority level of the Tk options set by the Tix schemes.

        Because of the way Tk handles the X option database, after Tix has
        been has imported and inited, it is not possible to reset the color
        schemes and font sets using the tix config command.  Instead, the
        tix_resetoptions command must be used.
        NrZresetoptionsr)rZ	newSchemeZ
newFontSetZ
newScmPriorrr�tix_resetoptions�sztixCommand.tix_resetoptions)N)N)N)�__name__�
__module__�__qualname__�__doc__rrr)r*r-r.r0r1rrrrrGs


rc@s"eZdZdZddd�Zdd�ZdS)	�Tkz{Toplevel widget of Tix which represents mostly the main window
    of an application. It has an associated Tcl interpreter.N�TixcCsbtj�||||�tj�d�}|j�d�|dk	rR|j�d|�|j�d|�|j�d�dS)NZTIX_LIBRARYz<global auto_path; lappend auto_path [file dir [info nameof]]z(global auto_path; lappend auto_path {%s}z,global tcl_pkgPath; lappend tcl_pkgPath {%s}zpackage require Tix)�tkinterr6�__init__�os�environr/r�eval)rZ
screenNameZbaseNameZ	classNameZtixlibrrrr9�szTk.__init__cCs|�dd�tj�|�dS)NZWM_DELETE_WINDOW�)Zprotocolr8r6�destroy�rrrrr>�sz
Tk.destroy)NNr7�r2r3r4r5r9r>rrrrr6�s
r6c@sTeZdZdZifdd�ZeZdd�Zdd�Zdd	�Zddd�Z	ddd�Z
dd�Zd
S)�Formz�The Tix Form geometry manager

    Widgets can be arranged by specifying attachments to other widgets.
    See Tix documentation for complete detailscKs"|jjd|jf|�||���dS)N�tixForm�rr�_wr%r&rrr�config�szForm.configcCst�|||i�dS�N)rA�form�r�key�valuerrr�__setitem__�szForm.__setitem__cCs|j�dd|j�S)NrB�check�rrrDr?rrrrL�sz
Form.checkcCs|j�dd|j�dS)NrB�forgetrMr?rrrrN�szForm.forgetrcCs`|sJ|sJ|j�dd|j�}|j�|�}d}|D]}||j�|�f}q.|S|j�dd|j||�S)NrB�gridr)rrrD�	splitlistZgetint)rZxsizeZysize�x�y�zrrrrO�sz	Form.gridNcCs>|s|j�dd|j�S|ddkr*d|}|j�dd|j|�S)NrB�inforr!rMrrrrrT�s
z	Form.infocs(�fdd��j��j�dd�j��D�S)Ncsg|]}��|��qSr)�
_nametowidget��.0rQr?rr�
<listcomp>szForm.slaves.<locals>.<listcomp>rB�slaves�rrPrrDr?rr?rrYs
���zForm.slaves)rr)N)r2r3r4r5rErGrKrLrNrOrTrYrrrrrA�s


rAc@sreZdZdZdddiifdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zidfdd�Zdd�Z
dS)�	TixWidgetaQA TixWidget class is used to package all (or most) Tix widgets.

    Widget initialization is extended in two ways:
       1) It is possible to give a list of options which must be part of
       the creation command (so called Tix 'static' options). These cannot be
       given as a 'config' command later.
       2) It is possible to give the name of an existing TK widget. These are
       child widgets created automatically by a Tix mega-widget. The Tk call
       to create these widgets is therefore bypassed in TixWidget.__init__

    Both options are for use by subclasses only.
    Nc	Cs�|rt||f�}nt|�}d}|r.|�d�ndg}t|���D]&\}}||kr@|d||f}||=q@||_t�|||�|r�|jj||j	f|��|r�t�
||�i|_dS)Nr�optionsr!)r�append�list�items�
widgetName�Widget�_setuprrrDrE�subwidget_list)	r�masterr`Zstatic_optionsr'r(Zextra�k�vrrrr9s$zTixWidget.__init__cCs ||jkr|j|St|��dSrF)rc�AttributeErrorr+rrr�__getattr__Gs

zTixWidget.__getattr__cCs|j�d|j|�dS)z1Set a variable without calling its action routineZtixSetSilentNrM)rrJrrr�
set_silentLszTixWidget.set_silentcCsD|�|�}|s$td|d|j��|t|j�dd�}|�|�S)zSReturn the named subwidget (which must have been created by
        the sub-class).z
Subwidget z not child of �N)�_subwidget_name�TclError�_name�lenrDrU)rr,�nrrr�	subwidgetPs

zTixWidget.subwidgetcCsZ|��}|sgSg}|D]<}|t|j�dd�}z|�|�|��WqYqXq|S)zReturn all subwidgets.rjN)�_subwidget_namesrnrDr]rU)r�namesZretlistr,rrr�subwidgets_allZszTixWidget.subwidgets_allcCs0z|j�|jd|�WStk
r*YdSXdS)z7Get a subwidget name (returns a String, not a Widget !)rpN)rrrDrlr+rrrrkiszTixWidget._subwidget_namecCs<z |j�|jdd�}|j�|�WStk
r6YdSXdS)z"Return the name of all subwidgets.Z
subwidgetsz-allN)rrrDrPrl)rrQrrrrqps
zTixWidget._subwidget_namescCs\|dkrdSt|t�st|�}t|t�s0t|�}|��}|D]}|j�|dd||�q<dS)z8Set configuration options for all subwidgets (and self).r=Nr r!)r#r$�reprrqrr)rrrJrrr,rrr�
config_allxs

zTixWidget.config_allcKst|s|}|r|rt||f�}n|r&|}d}|��D]*\}}t|�rL|�|�}|d||f}q2|j�dd|f|�S)Nrr!r�create)rr_�callable�	_registerrr)rZimgtyper'rdr(r\rerfrrr�image_create�s
zTixWidget.image_createcCs.z|j�dd|�Wntk
r(YnXdS)Nr�delete)rrrl)rZimgnamerrr�image_delete�szTixWidget.image_delete)r2r3r4r5r9rhrirprsrkrqruryr{rrrrr[
s�
-
r[c@s"eZdZdZddd�Zdd�ZdS)	�TixSubWidgetz�Subwidget class.

    This is used to mirror child widgets automatically created
    by Tix/Tk as part of a mega-widget in Python (which is not informed
    of this)rjc
Cs�|rD|�|�}z$|t|j�dd�}|�d�}Wng}YnX|s`t�||ddd|i�n�|}tt|�d�D]V}d�|d|d��}	z|�|	�}
|
}Wqtt	k
r�t
|||ddd�}YqtXqt|r�|d}t�||ddd|i�||_dS)Nrj�.r,r)�destroy_physically�check_intermediate���)rkrnrD�splitr[r9�range�joinrU�KeyErrorr|r~)rrdr,r~r�pathZplist�parent�iro�wrrrr9�s0



�zTixSubWidget.__init__cCsjt|j���D]}|��q|j|jjkr6|jj|j=|j|jjkrP|jj|j=|jrf|j�	d|j
�dS)Nr>)r^�children�valuesr>rmrdrcr~rrrD�r�crrrr>�s
zTixSubWidget.destroyN)rjrjr@rrrrr|�s
�
 r|c@sVeZdZdZifdd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zifdd�Z	dd�Z
dS)�DisplayStylezRDisplayStyle - handle configuration options shared by
    (multiple) Display ItemsN)rdcKs\|s2d|kr|d}nd|kr(|d}n
t�d�}|j|_|jjd|f|�||���|_dS)NZ	refwindowzcreate display styleZtixDisplayStyle)r8Z_get_default_rootrrr%�	stylename)r�itemtyper'rdr(rrrr9�s



�zDisplayStyle.__init__cCs|jSrF)r�r?rrr�__str__�szDisplayStyle.__str__cCsH|r|rt||f�}n|r|}d}|��D]\}}|d||f}q*|S)Nrr!)rr_)rr'r(Zoptsrerfrrrr%�szDisplayStyle._optionscCs|j�|jd�dS�Nrz�rrr�r?rrrrz�szDisplayStyle.deletecCs|j�|jdd||�dS)Nr �-%sr�rHrrrrK�szDisplayStyle.__setitem__cKs|j|jdf|�||���S)Nr )r"r�r%r&rrrrE�s�
�zDisplayStyle.configcCs|j�|jdd|�S)Nrr�r�)rrIrrr�__getitem__�szDisplayStyle.__getitem__)r2r3r4r5r9r�r%rzrKrEr�rrrrr��s
r�c@s2eZdZdZdifdd�Zifdd�Zdd�ZdS)	�BalloonzBalloon help widget.

    Subwidget       Class
    ---------       -----
    label           Label
    message         MessageNcKsNdddddg}t�||d|||�t|ddd	�|jd<t|d
dd	�|jd
<dS)Nr\ZinstallcolormapZinitwaitZ	statusbarZcursorZ
tixBalloon�labelr�r~�message�r[r9�_dummyLabelrc�rrdr'r(Zstaticrrrr9	s���zBalloon.__init__cKs&|jj|jd|jf|�||���dS)zkBind balloon widget to another.
        One balloon widget may be bound to several widgets at the same time�bindNrC)r�widgetr'r(rrr�bind_widgetszBalloon.bind_widgetcCs|j�|jd|j�dS�NZunbindrM�rr�rrr�
unbind_widgetszBalloon.unbind_widget)r2r3r4r5r9r�r�rrrrr�s
r�c@s2eZdZdZdifdd�Zifdd�Zdd�ZdS)	�	ButtonBoxzgButtonBox - A container for pushbuttons.
    Subwidgets are the buttons added with the add method.
    NcKst�||dddg||�dS)NZtixButtonBox�orientationr\�r[r9�rrdr'r(rrrr9s

�zButtonBox.__init__cKs4|jj|jd|f|�||���}t||�|j|<|S)z$Add a button with given name to box.�add�rrrDr%�_dummyButtonrc)rr,r'r(Zbtnrrrr�#s z
ButtonBox.addcCs ||jkr|j�|jd|�dS�N�invoke�rcrrrDr+rrrr�*s
zButtonBox.invoke�r2r3r4r5r9r�r�rrrrr�sr�c@s>eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�ZdS)
�ComboBoxa�ComboBox - an Entry field with a dropdown menu. The user can select a
    choice by either typing in the entry subwidget or selecting from the
    listbox subwidget.

    Subwidget       Class
    ---------       -----
    entry       Entry
    arrow       Button
    slistbox    ScrolledListBox
    tick        Button
    cross       Button : present if created with the fancy optionNc	Ks�t�||dddddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d	�|jd	<z$t|d
�|jd
<t|d�|jd<Wntk
r�YnXdS)NZtixComboBoxZeditableZdropdown�fancyr\r��entry�arrow�slistbox�tick�cross)r[r9r�rc�_dummyEntryr��_dummyScrolledListBox�	TypeErrorr�rrrr9<s 

��
zComboBox.__init__cCs|j�|jd|�dS)NZ
addhistoryrM�rr$rrr�add_historyNszComboBox.add_historycCs|j�|jd|�dS)NZ
appendhistoryrMr�rrr�append_historyQszComboBox.append_historycCs|j�|jd||�dS�N�insertrM)r�indexr$rrrr�TszComboBox.insertcCs|j�|jd|�dS)N�pickrM�rr�rrrr�Wsz
ComboBox.pick)	r2r3r4r5r9r�r�r�r�rrrrr�.s
r�c@s>eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�ZdS)
�Controla�Control - An entry field with value change arrows.  The user can
    adjust the value by pressing the two arrow buttons or by entering
    the value directly into the entry. The new value will be checked
    against the user-defined upper and lower limits.

    Subwidget       Class
    ---------       -----
    incr       Button
    decr       Button
    entry       Entry
    label       LabelNcKsZt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixControlr\�incr�decrr�r�)r[r9r�rcr�r�r�rrrr9hs
zControl.__init__cCs|j�|jd�dS)Nr�rMr?rrr�	decrementoszControl.decrementcCs|j�|jd�dS)Nr�rMr?rrr�	incrementrszControl.incrementcCs|j�|jd�dSr�rMr?rrrr�uszControl.invokecCs|j�|jd�dS)N�updaterMr?rrrr�xszControl.update)	r2r3r4r5r9r�r�r�r�rrrrr�Zs
r�c@s$eZdZdZifdd�Zdd�ZdS)�DirListaRDirList - displays a list view of a directory, its previous
    directories and its sub-directories. The user can choose one of
    the directories displayed in the list or change to another directory.

    Subwidget       Class
    ---------       -----
    hlist       HList
    hsb              Scrollbar
    vsb              ScrollbarcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixDirListr\�hlist�vsb�hsb�r[r9�_dummyHListrc�_dummyScrollbarr�rrrr9�szDirList.__init__cCs|j�|jd|�dS�N�chdirrM�r�dirrrrr��sz
DirList.chdirN�r2r3r4r5r9r�rrrrr�{sr�c@s$eZdZdZifdd�Zdd�ZdS)�DirTreea�DirTree - Directory Listing in a hierarchical view.
    Displays a tree view of a directory, its previous directories and its
    sub-directories. The user can choose one of the directories displayed
    in the list or change to another directory.

    Subwidget       Class
    ---------       -----
    hlist           HList
    hsb             Scrollbar
    vsb             ScrollbarcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixDirTreer\r�r�r�r�r�rrrr9�szDirTree.__init__cCs|j�|jd|�dSr�rMr�rrrr��sz
DirTree.chdirNr�rrrrr��sr�c@seZdZdZifdd�ZdS)�DirSelectBoxa�DirSelectBox - Motif style file select box.
    It is generally used for
    the user to choose a file. FileSelectBox stores the files mostly
    recently selected into a ComboBox widget so that they can be quickly
    selected again.

    Subwidget       Class
    ---------       -----
    selection       ComboBox
    filter          ComboBox
    dirlist         ScrolledListBox
    filelist        ScrolledListBoxcKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixDirSelectBoxr\�dirlist�dircbx)r[r9�
_dummyDirListrc�_dummyFileComboBoxr�rrrr9�szDirSelectBox.__init__N�r2r3r4r5r9rrrrr��s
r�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�ExFileSelectBoxa�ExFileSelectBox - MS Windows style file select box.
    It provides a convenient method for the user to select files.

    Subwidget       Class
    ---------       -----
    cancel       Button
    ok              Button
    hidden       Checkbutton
    types       ComboBox
    dir              ComboBox
    file       ComboBox
    dirlist       ScrolledListBox
    filelist       ScrolledListBoxcKs�t�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d	�|jd	<t|d
�|jd
<dS)NZtixExFileSelectBoxr\�cancel�ok�hidden�typesr�r��file�filelist)r[r9r�rc�_dummyCheckbutton�_dummyComboBoxr�r�r�rrrr9�szExFileSelectBox.__init__cCs|j�|jd�dS�N�filterrMr?rrrr��szExFileSelectBox.filtercCs|j�|jd�dSr�rMr?rrrr��szExFileSelectBox.invokeN)r2r3r4r5r9r�r�rrrrr��sr�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�DirSelectDialoga#The DirSelectDialog widget presents the directories in the file
    system in a dialog window. The user can use this dialog window to
    navigate through the file system to select the desired directory.

    Subwidgets       Class
    ----------       -----
    dirbox       DirSelectDialogcKs*t�||ddg||�t|d�|jd<dS)NZtixDirSelectDialogr\Zdirbox)r[r9�_dummyDirSelectBoxrcr�rrrr9�s
�zDirSelectDialog.__init__cCs|j�|jd�dS�N�popuprMr?rrrr��szDirSelectDialog.popupcCs|j�|jd�dS�N�popdownrMr?rrrr��szDirSelectDialog.popdownN�r2r3r4r5r9r�r�rrrrr��s	r�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�ExFileSelectDialogz�ExFileSelectDialog - MS Windows style file select dialog.
    It provides a convenient method for the user to select files.

    Subwidgets       Class
    ----------       -----
    fsbox       ExFileSelectBoxcKs*t�||ddg||�t|d�|jd<dS)NZtixExFileSelectDialogr\�fsbox)r[r9�_dummyExFileSelectBoxrcr�rrrr9�s
�zExFileSelectDialog.__init__cCs|j�|jd�dSr�rMr?rrrr�szExFileSelectDialog.popupcCs|j�|jd�dSr�rMr?rrrr�szExFileSelectDialog.popdownNr�rrrrr��sr�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�
FileSelectBoxa�ExFileSelectBox - Motif style file select box.
    It is generally used for
    the user to choose a file. FileSelectBox stores the files mostly
    recently selected into a ComboBox widget so that they can be quickly
    selected again.

    Subwidget       Class
    ---------       -----
    selection       ComboBox
    filter          ComboBox
    dirlist         ScrolledListBox
    filelist        ScrolledListBoxcKsZt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixFileSelectBoxr\r�r�r��	selection)r[r9r�rcr�r�rrrr9s
zFileSelectBox.__init__cCs|j�|jd�dSr�rMr?rrr�apply_filterszFileSelectBox.apply_filtercCs|j�|jd�dSr�rMr?rrrr�szFileSelectBox.invokeN)r2r3r4r5r9r�r�rrrrr�s
r�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�FileSelectDialogz�FileSelectDialog - Motif style file select dialog.

    Subwidgets       Class
    ----------       -----
    btns       StdButtonBox
    fsbox       FileSelectBoxcKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixFileSelectDialogr\Zbtnsr�)r[r9�_dummyStdButtonBoxrc�_dummyFileSelectBoxr�rrrr9,s
�zFileSelectDialog.__init__cCs|j�|jd�dSr�rMr?rrrr�2szFileSelectDialog.popupcCs|j�|jd�dSr�rMr?rrrr�5szFileSelectDialog.popdownNr�rrrrr�#sr�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�	FileEntrya_FileEntry - Entry field with button that invokes a FileSelectDialog.
    The user can type in the filename manually. Alternatively, the user can
    press the button widget that sits next to the entry, which will bring
    up a file selection dialog.

    Subwidgets       Class
    ----------       -----
    button       Button
    entry       EntrycKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZtixFileEntryZ
dialogtyper\Zbuttonr�)r[r9r�rcr�r�rrrr9Ds
�zFileEntry.__init__cCs|j�|jd�dSr�rMr?rrrr�JszFileEntry.invokecCsdSrFrr?rrr�file_dialogMszFileEntry.file_dialogN)r2r3r4r5r9r�r�rrrrr�8sr�c@s�eZdZdZdifdd�Zifdd�Zdifdd�Zd	d
�Zdd�Zdldd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zifd d!�Zifd"d#�Zd$d%�Zd&d'�ZeZd(d)�Zd*d+�Zd,d-�Zifd.d/�Zifd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!dmd>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,ifdTdU�Z-ifdVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1ifd^d_�Z2d`da�Z3dbdc�Z4ifddde�Z5dfdg�Z6dndhdi�Z7djdk�Z8dS)o�HListaHList - Hierarchy display  widget can be used to display any data
    that have a hierarchical structure, for example, file system directory
    trees. The list entries are indented and connected by branch lines
    according to their places in the hierarchy.

    Subwidgets - NoneNcKst�||dddg||�dS)NZtixHList�columnsr\r�r�rrrr9Ys

�zHList.__init__cKs |jj|jd|f|�||���S�Nr�rC�rr�r'r(rrrr�]sz	HList.addcKs(|sd}|jj|jd|f|�||���S)Nr=ZaddchildrC)rr�r'r(rrr�	add_child`s�
�zHList.add_childcCs|j�|jdd|�dS�N�anchor�setrM�rr�rrr�
anchor_setfszHList.anchor_setcCs|j�|jdd�dS�Nr��clearrMr?rrr�anchor_cleariszHList.anchor_clearrcCs6|s|j�|jdd||�S|j�|jdd|d|�SdS)Nr	�widthz-charrM)r�colr�charsrrr�column_widthls�zHList.column_widthcCs|j�|jdd�dS)Nrz�allrMr?rrr�
delete_allsszHList.delete_allcCs|j�|jdd|�dS)Nrzr�rMr�rrr�delete_entryvszHList.delete_entrycCs|j�|jdd|�dS)NrzZ
offspringsrMr�rrr�delete_offspringsyszHList.delete_offspringscCs|j�|jdd|�dS)NrzZsiblingsrMr�rrr�delete_siblings|szHList.delete_siblingscCs|j�|jdd|�dS�N�dragsiter�rMr�rrr�dragsite_setszHList.dragsite_setcCs|j�|jdd�dS�NrrrMr?rrr�dragsite_clear�szHList.dragsite_clearcCs|j�|jdd|�dS�N�dropsiter�rMr�rrr�dropsite_set�szHList.dropsite_setcCs|j�|jdd�dS�NrrrMr?rrr�dropsite_clear�szHList.dropsite_clearcKs&|jj|jdd|f|�||���dS)N�headerrvrC�rrr'r(rrr�
header_create�szHList.header_createcKs@|dkr|�|jdd|�S|jj|jdd|f|�||���dS)Nrr �r"rDrrr%rrrr�header_configure�s

�zHList.header_configurecCs|j�|jdd||�S)NrrrM)rr�optrrr�header_cget�szHList.header_cgetcCs|j�|j�|jdd|��S)NrZexist)rZ
getbooleanrrD�rrrrr�
header_exists�szHList.header_existscCs|j�|jdd|�dS)NrrzrMrrrr�
header_delete�szHList.header_deletecCs|j�|jdd|�S)Nr�sizerMrrrr�header_size�szHList.header_sizecCs|j�|jdd|�dS)N�hider�rMr�rrr�
hide_entry�szHList.hide_entrycKs&|jj|jdd|f|�||���dS)N�	indicatorrvrCr�rrr�indicator_create�s�
�zHList.indicator_createcKs@|dkr|�|jdd|�S|jj|jdd|f|�||���dS)Nr#r rr�rrr�indicator_configure�s��
�zHList.indicator_configurecCs|j�|jdd||�S)Nr#rrM�rr�rrrr�indicator_cget�szHList.indicator_cgetcCs|j�|jdd|�S)Nr#�existsrMr�rrr�indicator_exists�szHList.indicator_existscCs|j�|jdd|�dS)Nr#rzrMr�rrr�indicator_delete�szHList.indicator_deletecCs|j�|jdd|�S)Nr#rrMr�rrr�indicator_size�szHList.indicator_sizecCs|j�|jdd�S�NrTr�rMr?rrr�info_anchor�szHList.info_anchorcCs|�|j�|jdd|��pdS�NrTZbbox)�_getintsrrrDr�rrr�	info_bbox�s
��zHList.info_bboxcCs |j�|jdd|�}|j�|�S)NrTr��rrrDrP)rr�r�rrr�
info_children�szHList.info_childrencCs|j�|jdd|�S)NrT�datarMr�rrr�	info_data�szHList.info_datacCs|j�|jdd�S)NrTrrMr?rrr�
info_dragsite�szHList.info_dragsitecCs|j�|jdd�S)NrTrrMr?rrr�
info_dropsite�szHList.info_dropsitecCs|j�|jdd|�S)NrTr(rMr�rrr�info_exists�szHList.info_existscCs|j�|jdd|�S)NrTr�rMr�rrr�info_hidden�szHList.info_hiddencCs|j�|jdd|�S)NrT�nextrMr�rrr�	info_next�szHList.info_nextcCs|j�|jdd|�S)NrTr�rMr�rrr�info_parent�szHList.info_parentcCs|j�|jdd|�S)NrT�prevrMr�rrr�	info_prev�szHList.info_prevcCs|j�|jdd�}|j�|�S�NrTr�r1r�rrr�info_selection�szHList.info_selectioncCs|j�|jdd|||�S)N�itemrrM)rr�rrrrr�	item_cget�szHList.item_cgetcKsD|dkr|�|jdd||�S|jj|jdd||f|�||���dS)Nr@r r�rr�rr'r(rrr�item_configure�s

�zHList.item_configurecKs(|jj|jdd||f|�||���dS)Nr@rvrCrBrrr�item_create�s�
�zHList.item_createcCs|j�|jdd||�S)Nr@r(rM�rr�rrrr�item_exists�szHList.item_existscCs|j�|jdd||�dS)Nr@rzrMrErrr�item_delete�szHList.item_deletecCs|j�|jd||�S)N�	entrycgetrMr&rrrrH�szHList.entrycgetcKs<|dkr|�|jd|�S|jj|jd|f|�||���dS�N�entryconfigurerr�rrrrJ�s

�zHList.entryconfigurecCs|j�|jd|�S�N�nearestrM)rrRrrrrLsz
HList.nearestcCs|j�|jd|�dS�N�seerMr�rrrrNsz	HList.seecKs$|jj|jddf|�||���dS�Nr�rrCr&rrr�selection_clearszHList.selection_clearcCs|j�|jdd|�S�Nr�ZincludesrMr�rrr�selection_includes
szHList.selection_includescCs|j�|jdd||�dS�Nr�r�rM�r�firstZlastrrr�
selection_set
szHList.selection_setcCs|j�|jdd|�S)N�showr�rMr�rrr�
show_entryszHList.show_entry)rNN)N)N)9r2r3r4r5r9r�r�r�rrrrr	r
r
rrrrrrrZheader_existrr r"r$r%r'r)r*r+r-r0r2r4r5r6r7r8r:r;r=r?rArCrDrFrGrHrJrLrNrPrRrVrXrrrrr�Qsl


r�c@seZdZdZdifdd�ZdS)�	InputOnlyz?InputOnly - Invisible widget. Unix only.

    Subwidgets - NoneNcKst�||dd||�dS)NZtixInputOnlyr�r�rrrr9szInputOnly.__init__r�rrrrrYsrYc@seZdZdZdifdd�ZdS)�
LabelEntryaLabelEntry - Entry field with label. Packages an entry widget
    and a label into one mega widget. It can be used to simplify the creation
    of ``entry-form'' type of interface.

    Subwidgets       Class
    ----------       -----
    label       Label
    entry       EntryNcKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZ
tixLabelEntry�	labelsider\r�r�)r[r9r�rcr�r�rrrr9%s
�zLabelEntry.__init__r�rrrrrZs	rZc@seZdZdZdifdd�ZdS)�
LabelFrameaeLabelFrame - Labelled Frame container. Packages a frame widget
    and a label into one mega widget. To create widgets inside a
    LabelFrame widget, one creates the new widgets relative to the
    frame subwidget and manage them inside the frame subwidget.

    Subwidgets       Class
    ----------       -----
    label       Label
    frame       FrameNcKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZ
tixLabelFramer[r\r��frame)r[r9r�rc�_dummyFramer�rrrr96s
�zLabelFrame.__init__r�rrrrr\+s
r\c@s@eZdZdZifdd�Zifdd�Zdd�Zdd	�Zd
d�ZdS)
�ListNoteBookaA ListNoteBook widget is very similar to the TixNoteBook widget:
    it can be used to display many windows in a limited space using a
    notebook metaphor. The notebook is divided into a stack of pages
    (windows). At one time only one of these pages can be shown.
    The user can navigate through these pages by
    choosing the name of the desired page in the hlist subwidget.cKsNt�||ddg||�t|ddd�|jd<t|d�|jd<t|d�|jd<dS)NZtixListNoteBookr\Zpanerr�r�Zshlist)r[r9�_dummyPanedWindowrcr��_dummyScrolledHListr�rrrr9Es�zListNoteBook.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr��rrrDr%r|rc�rr,r'r(rrrr�Ms zListNoteBook.addcCs
|�|�SrF�rpr+rrr�pageRszListNoteBook.pagecCs:|j�|j�|jd��}g}|D]}|�|�|��q |S�N�pages�rrPrrDr]rp�rrrZretrQrrrrgUs
zListNoteBook.pagescCs|j�|jd|�dS�N�raiserMr+rrr�
raise_page]szListNoteBook.raise_pageN)	r2r3r4r5r9r�rergrlrrrrr_=sr_c@seZdZdZdifdd�ZdS)�MeterzuThe Meter widget can be used to show the progress of a background
    job which may take a long time to execute.
    NcKst�||ddg||�dS)NZtixMeterr\r�r�rrrr9es

�zMeter.__init__r�rrrrrm`srmc@sReZdZdZdifdd�Zifdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�NoteBookz�NoteBook - Multi-page container widget (tabbed notebook metaphor).

    Subwidgets       Class
    ----------       -----
    nbframe       NoteBookFrame
    <pages>       page widgets added dynamically with the add methodNcKs.t�||ddg||�t|ddd�|jd<dS)NZtixNoteBookr\Znbframerr�)r[r9r|rcr�rrrr9qs�zNoteBook.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr�rbrcrrrr�vs zNoteBook.addcCs,|j�|jd|�|j|��|j|=dSr��rrrDrcr>r+rrrrz{szNoteBook.deletecCs
|�|�SrFrdr+rrrre�sz
NoteBook.pagecCs:|j�|j�|jd��}g}|D]}|�|�|��q |Srfrhrirrrrg�s
zNoteBook.pagescCs|j�|jd|�dSrjrMr+rrrrl�szNoteBook.raise_pagecCs|j�|jd�S)N�raisedrMr?rrrrp�szNoteBook.raised)r2r3r4r5r9r�rzrergrlrprrrrrnisrnc@seZdZdS)�
NoteBookFrameN)r2r3r4rrrrrq�srqc@sLeZdZdZifdd�Zifdd�Zifdd�Zdd	�Zd
d�Zdd
�Z	dS)�
OptionMenuz�OptionMenu - creates a menu button of options.

    Subwidget       Class
    ---------       -----
    menubutton      Menubutton
    menu            MenucKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZ
tixOptionMenur\�
menubutton�menu�r[r9�_dummyMenubuttonrc�
_dummyMenur�rrrr9�szOptionMenu.__init__cKs&|jj|jdd|f|�||���dS)Nr��commandrCrcrrr�add_command�szOptionMenu.add_commandcKs&|jj|jdd|f|�||���dS)Nr�Z	separatorrCrcrrr�
add_separator�szOptionMenu.add_separatorcCs|j�|jd|�dSr�rMr+rrrrz�szOptionMenu.deletecCs|j�|jd|�dS)N�disablerMr+rrrr{�szOptionMenu.disablecCs|j�|jd|�dS)N�enablerMr+rrrr|�szOptionMenu.enableN)
r2r3r4r5r9ryrzrzr{r|rrrrrr�srrc@sTeZdZdZifdd�Zifdd�Zdd�Zdd	�Zd
d�Zifdd
�Z	dd�Z
dS)�PanedWindowa�PanedWindow - Multi-pane container widget
    allows the user to interactively manipulate the sizes of several
    panes. The panes can be arranged either vertically or horizontally.The
    user changes the sizes of the panes by dragging the resize handle
    between two panes.

    Subwidgets       Class
    ----------       -----
    <panes>       g/p widgets added dynamically with the add method.cKst�||dddg||�dS)NZtixPanedWindowr�r\r�r�rrrr9�szPanedWindow.__init__cKs>|jj|jd|f|�||���t||dd�|j|<|j|S)Nr�r)rrbrcrrrr��s
 �zPanedWindow.addcCs,|j�|jd|�|j|��|j|=dSr�ror+rrrrz�szPanedWindow.deletecCs|j�|jd|�dS)NrNrMr+rrrrN�szPanedWindow.forgetcCs|j�|jd||�S)N�panecgetrMr&rrrr~�szPanedWindow.panecgetcKs<|dkr|�|jd|�S|jj|jd|f|�||���dS)N�
paneconfigurerr�rrrr�szPanedWindow.paneconfigurecs*�j��j��jd��}�fdd�|D�S)N�panescsg|]}��|��qSrrdrVr?rrrX�sz%PanedWindow.panes.<locals>.<listcomp>rZ)rrrrr?rr��szPanedWindow.panesN)r2r3r4r5r9r�rzrNr~rr�rrrrr}�s
r}c@s4eZdZdZifdd�Zdd�Zdd�Zdd	�Zd
S)�	PopupMenuaPopupMenu widget can be used as a replacement of the tk_popup command.
    The advantage of the Tix PopupMenu widget is it requires less application
    code to manipulate.


    Subwidgets       Class
    ----------       -----
    menubutton       Menubutton
    menu       MenucKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixPopupMenur\rsrtrur�rrrr9�szPopupMenu.__init__cCs|j�|jd|j�dS)Nr�rMr�rrrr��szPopupMenu.bind_widgetcCs|j�|jd|j�dSr�rMr�rrrr��szPopupMenu.unbind_widgetcCs|j�|jd|j||�dS)NZpostrM)rr�rQrRrrr�post_widget�szPopupMenu.post_widgetN)r2r3r4r5r9r�r�r�rrrrr��s
r�c@s<eZdZdZifdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ResizeHandlez;Internal widget to draw resize handles on Scrolled widgets.c	Ks.ddddddddd	g	}t�||d
|||�dS)Nr\rxZcursorfgZcursorbgZ
handlesizeZ	hintcolorZ	hintwidthrQrRZtixResizeHandler�)rrdr'r(�flagsrrrr9�s�
�zResizeHandle.__init__cCs|j�|jd|j�dS)NZattachwidgetrMr�rrr�
attach_widgetszResizeHandle.attach_widgetcCs|j�|jd|j�dS)NZdetachwidgetrMr�rrr�
detach_widgetszResizeHandle.detach_widgetcCs|j�|jd|j�dS)Nr!rMr�rrrr!szResizeHandle.hidecCs|j�|jd|j�dS)NrWrMr�rrrrW	szResizeHandle.showN)	r2r3r4r5r9r�r�r!rWrrrrr��s
r�c@seZdZdZifdd�ZdS)�
ScrolledHListz0ScrolledHList - HList with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledHListr\r�r�r�r�r�rrrr9s�zScrolledHList.__init__Nr�rrrrr�sr�c@seZdZdZifdd�ZdS)�ScrolledListBoxz4ScrolledListBox - Listbox with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledListBoxr\�listboxr�r�)r[r9�
_dummyListboxrcr�r�rrrr9szScrolledListBox.__init__Nr�rrrrr�sr�c@seZdZdZifdd�ZdS)�ScrolledTextz.ScrolledText - Text with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledTextr\rr�r�)r[r9�
_dummyTextrcr�r�rrrr9%szScrolledText.__init__Nr�rrrrr�!sr�c@seZdZdZifdd�ZdS)�
ScrolledTListz0ScrolledTList - TList with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledTListr\Ztlistr�r�)r[r9�_dummyTListrcr�r�rrrr9/s�zScrolledTList.__init__Nr�rrrrr�+sr�c@seZdZdZifdd�ZdS)�ScrolledWindowz2ScrolledWindow - Window with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledWindowr\rr�r�)r[r9r^rcr�r�rrrr9:szScrolledWindow.__init__Nr�rrrrr�6sr�c@s0eZdZdZifdd�Zifdd�Zdd�ZdS)	�Selectz�Select - Container of button subwidgets. It can be used to provide
    radio-box or check-box style of selection options for the user.

    Subwidgets are buttons added dynamically using the add method.c
Ks2t�||ddddddg||�t|d�|jd<dS)NZ	tixSelectZ	allowzero�radior�r[r\r�r�r�rrrr9Gs
��zSelect.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr�r�rcrrrr�Ns z
Select.addcCs|j�|jd|�dSr�rMr+rrrr�Ssz
Select.invokeNr�rrrrr�@sr�c@seZdZdZdifdd�ZdS)�Shellz'Toplevel window.

    Subwidgets - NoneNcKst�||dddg||�dS)NZtixShellr\�titler�r�rrrr9[szShell.__init__r�rrrrr�Vsr�c@s6eZdZdZdifdd�Zdd�Zdd�Zd	d
�ZdS)�DialogShellz�Toplevel window, with popup popdown and center methods.
    It tells the window manager that it is a dialog window and should be
    treated specially. The exact treatment depends on the treatment of
    the window manager.

    Subwidgets - NoneNcKs&t�||ddddddddg||�dS)	NZtixDialogShellr\r�ZmappedZ	minheightZminwidthr�Z	transientr�r�rrrr9gs��zDialogShell.__init__cCs|j�|jd�dSr�rMr?rrrr�nszDialogShell.popdowncCs|j�|jd�dSr�rMr?rrrr�qszDialogShell.popupcCs|j�|jd�dS)N�centerrMr?rrrr�tszDialogShell.center)r2r3r4r5r9r�r�r�rrrrr�^s
r�c@s&eZdZdZdifdd�Zdd�ZdS)�StdButtonBoxz@StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) NcKs\t�||dddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixStdButtonBoxr�r\r��applyr��help)r[r9r�rcr�rrrr9zs
�zStdButtonBox.__init__cCs ||jkr|j�|jd|�dSr�r�r+rrrr��s
zStdButtonBox.invoke)r2r3r4r5r9r�rrrrr�wsr�c@s�eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�Zd3d
d�Z	dd�Z
dd�Zdd�Zdd�Z
ifdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zifd-d.�Zd/d0�Zd4d1d2�ZdS)5�TLista�TList - Hierarchy display widget which can be
    used to display data in a tabular format. The list entries of a TList
    widget are similar to the entries in the Tk listbox widget. The main
    differences are (1) the TList widget can display the list entries in a
    two dimensional format and (2) you can use graphical images as well as
    multiple colors and fonts for the list entries.

    Subwidgets - NoneNcKst�||ddg||�dS)NZtixTListr\r�r�rrrr9�szTList.__init__cCs|j�|jdd|�dS)N�activer�rMr�rrr�
active_set�szTList.active_setcCs|j�|jdd�dS)Nr�rrMr?rrr�active_clear�szTList.active_clearcCs|j�|jdd|�dSr�rMr�rrrr��szTList.anchor_setcCs|j�|jdd�dSr�rMr?rrrr�szTList.anchor_clearcCs|j�|jd||�dSr�rM�r�from_�torrrrz�szTList.deletecCs|j�|jdd|�dSrrMr�rrrr
�szTList.dragsite_setcCs|j�|jdd�dSrrMr?rrrr�szTList.dragsite_clearcCs|j�|jdd|�dSrrMr�rrrr�szTList.dropsite_setcCs|j�|jdd�dSrrMr?rrrr�szTList.dropsite_clearcKs$|jj|jd|f|�||���dSr�rC)rr�r'r(rrrr��szTList.insertcCs|j�|jdd�S)NrTr�rMr?rrr�info_active�szTList.info_activecCs|j�|jdd�Sr,rMr?rrrr-�szTList.info_anchorcCs|j�|jdd|�S)NrTZdownrMr�rrr�	info_down�szTList.info_downcCs|j�|jdd|�S)NrT�leftrMr�rrr�	info_left�szTList.info_leftcCs|j�|jdd|�S)NrT�rightrMr�rrr�
info_right�szTList.info_rightcCs|j�|jdd�}|j�|�Sr>r1r�rrrr?�szTList.info_selectioncCs|j�|jdd�S)NrTrrMr?rrr�	info_size�szTList.info_sizecCs|j�|jdd|�S)NrTZuprMr�rrr�info_up�sz
TList.info_upcCs|j�|jd||�SrKrM�rrQrRrrrrL�sz
TList.nearestcCs|j�|jd|�dSrMrMr�rrrrN�sz	TList.seecKs$|jj|jddf|�||���dSrOrCr&rrrrP�szTList.selection_clearcCs|j�|jdd|�SrQrMr�rrrrR�szTList.selection_includescCs|j�|jdd||�dSrSrMrTrrrrV�szTList.selection_set)N)N)r2r3r4r5r9r�r�r�rrzr
rrrr�r�r-r�r�r�r?r�r�rLrNrPrRrVrrrrr��s2	
r�c@sHeZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	dS)�Treez�Tree - The tixTree widget can be used to display hierarchical
    data in a tree form. The user can adjust
    the view of the tree by opening or closing parts of the tree.NcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixTreer\r�r�r�r�r�rrrr9�s
�z
Tree.__init__cCs|j�|jd�dS�aThis command calls the setmode method for all the entries in this
     Tree widget: if an entry has no child entries, its mode is set to
     none. Otherwise, if the entry has any hidden child entries, its mode is
     set to open; otherwise its mode is set to close.�autosetmodeNrMr?rrrr��szTree.autosetmodecCs|j�|jd|�dS�z8Close the entry given by entryPath if its mode is close.�closeNrM�r�	entrypathrrrr��sz
Tree.closecCs|j�|jd|�S�z9Returns the current mode of the entry given by entryPath.�getmoderMr�rrrr��szTree.getmodecCs|j�|jd|�dS�z6Open the entry given by entryPath if its mode is open.�openNrMr�rrrr��sz	Tree.open�nonecCs|j�|jd||�dS)a�This command is used to indicate whether the entry given by
     entryPath has children entries and whether the children are visible. mode
     must be one of open, close or none. If mode is set to open, a (+)
     indicator is drawn next the entry. If mode is set to close, a (-)
     indicator is drawn next the entry. If mode is set to none, no
     indicators will be drawn for this entry. The default mode is none. The
     open mode indicates the entry has hidden children and this entry can be
     opened by the user. The close mode indicates that all the children of the
     entry are now visible and the entry can be closed by the user.�setmodeNrM�rr��moderrrr��s
zTree.setmode)r�)
r2r3r4r5r9r�r�r�r�r�rrrrr��sr�c@sZeZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	dd�Z
ddd�ZdS)�	CheckListz�The CheckList widget
    displays a list of items to be selected by the user. CheckList acts
    similarly to the Tk checkbutton or radiobutton widgets, except it is
    capable of handling many more items than checkbuttons or radiobuttons.
    NcKsLt�||dddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixCheckListr\r�r�r�r�r�r�rrrr9s
�zCheckList.__init__cCs|j�|jd�dSr�rMr?rrrr�szCheckList.autosetmodecCs|j�|jd|�dSr�rMr�rrrr�szCheckList.closecCs|j�|jd|�Sr�rMr�rrrr� szCheckList.getmodecCs|j�|jd|�dSr�rMr�rrrr�$szCheckList.open�oncCs|j�|j�|jd|��S)z�Returns a list of items whose status matches status. If status is
     not specified, the list of items in the "on" status will be returned.
     Mode can be on, off, default�getselectionrZ)rr�rrrr�(szCheckList.getselectioncCs|j�|jd|�S)z(Returns the current status of entryPath.�	getstatusrMr�rrrr�.szCheckList.getstatuscCs|j�|jd||�dS)z~Sets the status of entryPath to be status. A bitmap will be
     displayed next to the entry its status is on, off or default.�	setstatusNrMr�rrrr�2szCheckList.setstatus)r�)r�)r2r3r4r5r9r�r�r�r�r�r�r�rrrrr�s
r�c@seZdZddd�ZdS)r�rjcCst�||||�dSrF�r|r9�rrdr,r~rrrr9>sz_dummyButton.__init__N)rj�r2r3r4r9rrrrr�=sr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Bsz_dummyCheckbutton.__init__N)rjr�rrrrr�Asr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Fsz_dummyEntry.__init__N)rjr�rrrrr�Esr�c@seZdZddd�ZdS)r^rjcCst�||||�dSrFr�r�rrrr9Jsz_dummyFrame.__init__N)rjr�rrrrr^Isr^c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Nsz_dummyLabel.__init__N)rjr�rrrrr�Msr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Rsz_dummyListbox.__init__N)rjr�rrrrr�Qsr�c@seZdZddd�ZdS)rwrjcCst�||||�dSrFr�r�rrrr9Vsz_dummyMenu.__init__N)rjr�rrrrrwUsrwc@seZdZddd�ZdS)rvrjcCst�||||�dSrFr�r�rrrr9Zsz_dummyMenubutton.__init__N)rjr�rrrrrvYsrvc@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9^sz_dummyScrollbar.__init__N)rjr�rrrrr�]sr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9bsz_dummyText.__init__N)rjr�rrrrr�asr�c@seZdZddd�ZdS)r�rjcCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�)r|r9r�rcr�r�rrrr9fsz_dummyScrolledListBox.__init__N)rjr�rrrrr�esr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9msz_dummyHList.__init__N)rjr�rrrrr�lsr�c@seZdZddd�ZdS)rarjcCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dS�Nr�r�r��r|r9r�rcr�r�rrrr9qsz_dummyScrolledHList.__init__N)rjr�rrrrrapsrac@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9xsz_dummyTList.__init__N)rjr�rrrrr�wsr�c@seZdZddd�ZdS)r�rjcCs�t�|||d|g�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<z$t|d�|jd<t|d�|jd<Wntk
r�YnXdS)Nr�r�r�r�r�r�r�)r|r9r�rcr�r�r�r�r�rrrr9|s�
z_dummyComboBox.__init__N)rjr�rrrrr�{sr�c@seZdZddd�ZdS)r�rjcCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dSr�r�r�rrrr9�sz_dummyDirList.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCs4t�||||�t|d�|jd<t|d�|jd<dS)Nr�r�)r|r9r�rcr�r�rrrr9�sz_dummyDirSelectBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCs�t�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)	Nr�r�r�r�r�r�r�r�)r|r9r�rcr�r�r�r�rrrr9�sz_dummyExFileSelectBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCsTt�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�r�)r|r9r�rcr�r�rrrr9�s
z_dummyFileSelectBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCs$t�||||�t|d�|jd<dS)Nr�)r|r9r�rcr�rrrr9�sz_dummyFileComboBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCsTt�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�r�)r|r9r�rcr�rrrr9�s
z_dummyStdButtonBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)�_dummyNoteBookFramercCst�||||�dSrFr�r�rrrr9�sz_dummyNoteBookFrame.__init__N)rr�rrrrr��sr�c@seZdZddd�ZdS)r`rjcCst�||||�dSrFr�r�rrrr9�sz_dummyPanedWindow.__init__N)rjr�rrrrr`�sr`cCs|j�d|j�S)zzReturns the qualified path name for the widget. Normally used to set
    default options for subwidgets. See tixwidgets.pyZ
tixOptionNamerM)r�rrr�
OptionName�sr�cCs:d}|��D](}|d|d|d||d}q|S)Nr=z{{z} {z - z}} )�keys)�dict�s�typerrr�FileTypeList�s&r�c@seZdZdZdS)�CObjViewaBThis file implements the Canvas Object View widget. This is a base
    class of IconView. It implements automatic placement/adjustment of the
    scrollbars according to the canvas objects inside the canvas subwidget.
    The scrollbars are adjusted so that the canvas is just large enough
    to see all the objects.
    N)r2r3r4r5rrrrr��sr�c@s�eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zd)dd�Zd*d
d�Z	dd�Z
dd�Zdd�Zd+dd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd,d!d"�Zd#d$�Zd%d&�Zd'd(�ZdS)-�Grida}The Tix Grid command creates a new window  and makes it into a
    tixGrid widget. Additional options, may be specified on the command
    line or in the option database to configure aspects such as its cursor
    and relief.

    A Grid widget displays its contents in a two dimensional grid of cells.
    Each cell may contain one Tix display item, which may be in text,
    graphics or other formats. See the DisplayStyle class for more information
    about Tix display items. Individual cells, or groups of cells, can be
    formatted with a wide range of attributes, such as its color, relief and
    border.

    Subwidgets - NoneNcKs"g}||_t�||d|||�dS)NZtixGrid�r'r[r9r�rrrr9�sz
Grid.__init__cCs|j�|dd�dS)zRemoves the selection anchor.r�rNrr?rrrrszGrid.anchor_clearcCs|�|j�|dd��S)z3Get the (x,y) coordinate of the current anchor cellr�r/�r/rrr?rrr�
anchor_getszGrid.anchor_getcCs|j�|dd||�dS)z/Set the selection anchor to the cell at (x, y).r�r�Nrr�rrrr�szGrid.anchor_setcCs4|dkr|j�|dd|�n|j�|dd||�dS)zdDelete rows between from_ and to inclusive.
        If to is not provided,  delete only row at from_Nrzr
rr�rrr�
delete_rowszGrid.delete_rowcCs4|dkr|j�|dd|�n|j�|dd||�dS)zjDelete columns between from_ and to inclusive.
        If to is not provided,  delete only column at from_Nrzr	rr�rrr�
delete_columnszGrid.delete_columncCs|j�|dd�dS)zUIf any cell is being edited, de-highlight the cell  and  applies
        the changes.�editr�Nrr?rrr�
edit_applyszGrid.edit_applycCs|j�|dd||�dS)zmHighlights  the  cell  at  (x, y) for editing, if the -editnotify
        command returns True for this cell.r�r�Nrr�rrr�edit_set!sz
Grid.edit_setcCs,|r|ddkrd|}|j�|d|||�S)z&Get the option value for cell at (x,y)rr!rHr)rrQrRrrrrrH&szGrid.entrycgetcKs|�d||f||�SrI)Z
_configure)rrQrRr'r(rrrrJ,szGrid.entryconfigurec	Cs|�|j�|dd||��S)z+Return True if display item exists at (x,y)rTr()Z_getbooleanrrr�rrrr72szGrid.info_existscCs|j�|dd||�Sr.rr�rrrr06szGrid.info_bboxcCs|j�|dd|||�dS)z�Moves the range of columns from position FROM through TO by
        the distance indicated by OFFSET. For example, move_column(2, 4, 1)
        moves the columns 2,3,4 to columns 3,4,5.�mover	Nr�rr�r��offsetrrr�move_column:szGrid.move_columncCs|j�|dd|||�dS)z�Moves the range of rows from position FROM through TO by
        the distance indicated by OFFSET.
        For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.r�r
Nrr�rrr�move_row@sz
Grid.move_rowcCs|�|j�|d||��S)z8Return coordinate of cell nearest pixel coordinate (x,y)rLr�r�rrrrLFszGrid.nearestcKs>|�|j|�}|dk	r"d|f|}|jj|d||f|��dS)Nz	-itemtyper�)r%r'rr)rrQrRr�r(�argsrrrr�PszGrid.setcKs*|j�|jj|jdd|f|�i|����S)a�Queries or sets the size of the column given by
        INDEX.  INDEX may be any non-negative
        integer that gives the position of a given column.
        INDEX can also be the string "default"; in this case, this command
        queries or sets the default size of all columns.
        When no option-value pair is given, this command returns a tuple
        containing the current size setting of the given column.  When
        option-value pairs are given, the corresponding options of the
        size setting of the given column are changed. Options may be one
        of the following:
              pad0 pixels
                     Specifies the paddings to the left of a column.
              pad1 pixels
                     Specifies the paddings to the right of a column.
              size val
                     Specifies the width of a column.  Val may be:
                     "auto" -- the width of the column is set to the
                     width of the widest cell in the column;
                     a valid Tk screen distance unit;
                     or a real number following by the word chars
                     (e.g. 3.4chars) that sets the width of the column to the
                     given number of characters.rr	)rrPrrDr%�rr�r(rrr�size_columnVs
�zGrid.size_columncKs(|j�|jj|dd|f|�i|����S)a�Queries or sets the size of the row given by
        INDEX. INDEX may be any non-negative
        integer that gives the position of a given row .
        INDEX can also be the string "default"; in this case, this command
        queries or sets the default size of all rows.
        When no option-value pair is given, this command returns a list con-
        taining the current size setting of the given row . When option-value
        pairs are given, the corresponding options of the size setting of the
        given row are changed. Options may be one of the following:
              pad0 pixels
                     Specifies the paddings to the top of a row.
              pad1 pixels
                     Specifies the paddings to the bottom of a row.
              size val
                     Specifies the height of a row.  Val may be:
                     "auto" -- the height of the row is set to the
                     height of the highest cell in the row;
                     a valid Tk screen distance unit;
                     or a real number following by the word chars
                     (e.g. 3.4chars) that sets the height of the row to the
                     given number of characters.rr
)rrPrr%r�rrr�size_rowps�
�z
Grid.size_rowcCs|j�|jd||�dS)z7Clears the cell at (x, y) by removing its display item.�unsetNrMr�rrrr��sz
Grid.unset)N)N)N)N)r2r3r4r5r9rr�r�r�r�r�r�rHrJr7r0r�r�rLr�r�r�r�rrrrr��s(	




r�c@seZdZdZdifdd�ZdS)�ScrolledGridzScrolled Grid widgetsNcKs"g}||_t�||d|||�dS)NZtixScrolledGridr�r�rrrr9�szScrolledGrid.__init__r�rrrrr��sr�)ur:r8rZ_tkinterZWINDOWZTEXTZSTATUSZ	IMMEDIATEZIMAGEZ	IMAGETEXTZBALLOONZAUTOZ	ACROSSTOP�ASCIIZCELLZCOLUMNZ
DECREASINGZ
INCREASINGZINTEGERZMAIN�MAXZREALZROWZS_REGIONZX_REGIONZY_REGIONZ
TCL_DONT_WAITZTCL_WINDOW_EVENTSZTCL_FILE_EVENTSZTCL_TIMER_EVENTSZTCL_IDLE_EVENTSZTCL_ALL_EVENTSrr6rAra�	__bases__r[r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZXViewZYViewr�rYrZr\r_rmrnrqrrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZButtonr�ZCheckbuttonr�ZEntryr�ZFramer^ZLabelr�ZListboxr�ZMenurwZ
MenubuttonrvZ	Scrollbarr�ZTextr�r�r�rar�r�r�r�r�r�r�r�r�r`r�r�r�r�r�rrrr�<module>s�-
8/,!"C#	()


S.6

*PK+�\v��ZZ!commondialog.cpython-38.opt-1.pycnu�[���U

e5d��@sddlTGdd�d�ZdS)�)�*c@s2eZdZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�DialogNcKs|s|�d�}||_||_dS)N�parent)�get�master�options)�selfrr�r	�,/usr/lib64/python3.8/tkinter/commondialog.py�__init__s
zDialog.__init__cCsdS�Nr	)rr	r	r
�_fixoptionsszDialog._fixoptionscCs|Srr	)rZwidget�resultr	r	r
�
_fixresultszDialog._fixresultcKs||��D]\}}||j|<q|��t|j�}z,|jj|jf|�	|j���}|�
||�}W5z|��WnYnXX|Sr)�itemsrr
ZFramerZdestroyZtkZcall�commandZ_optionsr)rr�k�v�w�sr	r	r
�shows
zDialog.show)N)�__name__�
__module__�__qualname__rrr
rrr	r	r	r
rs

rN)Ztkinterrr	r	r	r
�<module>sPK+�\�T—|�|�ttk.cpython-38.opt-1.pycnu�[���U

e5d���@s�dZdZdZddddddd	d
ddd
ddddddddddddddgZddlZddlmZmZmZmZej	dkrpd nd!Z
d"d#�ZdXd$d%�ZdYd&d'�Z
d(d)�ZdZd*d+�Zd[d,d-�Zd\d/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d�Zd]d@d�ZGdAd�de�ZGdBdC�dCej�ZGdDd�de�ZGdEd�de�ZGdFd�deej �Z GdGd�de �Z!GdHd�de�Z"GdId�de�Z#GdJd	�d	e�Z$e$Z%GdKd�de�Z&GdLd�de�Z'GdMd
�d
eej(�Z)e)Z(GdNd�de�Z*GdOd�de�Z+GdPd�deej,�Z,GdQd�deej-�Z-GdRd�de�Z.GdSd�de�Z/GdTd�de �Z0GdUd�deej1ej2�Z3GdVd�de"�Z4GdWd�de&�Z5dS)^a�Ttk wrapper.

This module provides classes to allow using Tk themed widget set.

Ttk is based on a revised and enhanced version of
TIP #48 (http://tip.tcl.tk/48) specified style engine.

Its basic idea is to separate, to the extent possible, the code
implementing a widget's behavior from the code implementing its
appearance. Widget class bindings are primarily responsible for
maintaining the widget state and invoking callbacks, all aspects
of the widgets appearance lies at Themes.
z0.3.1z!Guilherme Polo <ggpolo@gmail.com>�Button�Checkbutton�Combobox�Entry�Frame�Label�
Labelframe�
LabelFrame�
Menubutton�Notebook�Panedwindow�PanedWindow�Progressbar�Radiobutton�Scale�	Scrollbar�	Separator�Sizegrip�Spinbox�Style�Treeview�LabeledScale�
OptionMenu�
tclobjs_to_py�setup_master�N)�_flatten�_join�
_stringify�
_splitdictg!@TFcCsBtr>ddl}|j�d�}|r,|j�d|�|j�d�d|_dS)NrZTILE_LIBRARYz(global auto_path; lappend auto_path {%s}zpackage require tileT)�
_REQUIRE_TILE�os�environ�get�tk�eval�_tile_loaded)�masterr Ztilelib�r'�#/usr/lib64/python3.8/tkinter/ttk.py�
_load_tile"s��r)cCs(|rt|�}nt|ttf�r$t|�}|S)zInternal function.)r�
isinstance�list�tupler)�value�scriptr'r'r(�_format_optvalue1s

r/cCsPg}|��D]:\}}|r ||kr|�d|�|dk	r|�t||��qt|�S)z�Formats optdict to a tuple to pass it to tk.call.

    E.g. (script=False):
      {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns:
      ('-foreground', 'blue', '-padding', '1 2 3 4')�-%sN)�items�appendr/r)Zoptdictr.�ignore�opts�optr-r'r'r(�_format_optdict;sr6cCsXg}|D]J�^}}t|�dkr,|dp(d}n
d�|�}|�|�|dk	r|�|�q|S)N�r�� )�len�joinr2)r1Zopt_val�state�valr'r'r(�_mapdict_valuesKs

r>cCs:g}|��D]$\}}|�d|tt|�|�f�qt|�S)z�Formats mapdict to pass it to tk.call.

    E.g. (script=False):
      {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]}

      returns:

      ('-expand', '{active selected} grey focus {1, 2, 3, 4}')r0)r1�extendr/r>r)Zmapdictr.r4r5r-r'r'r(�_format_mapdict`s

�r@cOs�d}d}|dkr�|dkrB|d}tt|dd���}d||f}n2|dd�\}}	tt|dd���}
d	||	|
f}t||�}n,|d
kr�|d}t|�dkr�t|d|�f}|r�d|}d�|�}||fS)
zAFormats args and kw according to the given element factory etype.Nr')�imageZvsapirArr7z%s %s�z%s %s %s�fromz{%s}r9)rr>r6r:r/r;)�etyper.�args�kw�specr4ZinameZ	imagespec�
class_nameZpart_idZstatemapr'r'r(�_format_elemcreateqs&
rIrBc
Cs�g}|D]�}|\}}|pi}d�t|dd��}dd|||rDd|ndf}d|kr�|�|d�||7}t|d||�\}	}|�|	�||8}|�d	d|�q|�|�qd
�|�|fS)a$Formats a layout list so we can pass the result to ttk::style
    layout and ttk::style settings. Note that the layout doesn't have to
    be a list necessarily.

    E.g.:
      [("Menubutton.background", None),
       ("Menubutton.button", {"children":
           [("Menubutton.focus", {"children":
               [("Menubutton.padding", {"children":
                [("Menubutton.label", {"side": "left", "expand": 1})]
               })]
           })]
       }),
       ("Menubutton.indicator", {"side": "right"})
      ]

      returns:

      Menubutton.background
      Menubutton.button -children {
        Menubutton.focus -children {
          Menubutton.padding -children {
            Menubutton.label -side left -expand 1
          }
        }
      }
      Menubutton.indicator -side rightr9T)�childrenz%s%s%sz %sr8rJz -children {z%s}�
)r;r6r2�_format_layoutlist)
�layout�indentZindent_sizer.Zlayout_elem�elemr4Zfopts�headZ	newscriptr'r'r(rL�s"
�
rLcCsXg}|��D�]>\}}|�d�rFd�t|dd��}|�d||f�|�d�rvd�t|dd��}|�d||f�d|kr�|ds�d}nt|d�\}}|�d	||f�|�d
�r|d
}|d}d}|t|�kr�t||d
�s�|d7}q�|d|�}	|t|�k�r||�r||ni}
t	|df|	�|
�\}}|�d||||f�qd�|�S)z�Returns an appropriate script, based on settings, according to
    theme_settings definition to be used by theme_settings and
    theme_create.�	configurer9Tzttk::style configure %s %s;�mapzttk::style map %s %s;rM�nullzttk::style layout %s {
%s
}zelement createrr7r1z%ttk::style element create %s %s %s %srK)
r1r"r;r6r2r@rLr:�hasattrrI)�settingsr.�namer4�s�_ZeoptsrDZargcZelemargsZelemkwrGr'r'r(�_script_from_settings�s:



$�
rYcCs�t|t�r|Sg}t|�}t||�D]j\}}t|d�rDt|���}n(t|t�rX|��}nt|ttf�sl|f}t|d�r~t|�}|�||f��q$|S)ztConstruct a list from the given statespec tuple according to the
    accepted statespec accepted by _format_mapdict.�typename)	r*�str�iter�ziprT�splitr,r+r2)Zstuple�result�itr<r=r'r'r(�_list_from_statespec�s




racCs�|�|�}g}d}|t|�kr�||}i}|�||f�|d7}|t|�kr|||d�\}}|�d�slq|dd�}|d7}|dkr�t||�}|||<q@q|S)zpConstruct a list from the tuple returned by ttk::layout, this is
    somewhat the reverse of _format_layoutlist.rr7rB�-NrJ)�	splitlistr:r2�
startswith�_list_from_layouttuple)r#Zltuple�resZindxrVr4r5r=r'r'r(res$


recGs4t|�}|j||�}t|�dr&|St||td�S)ahFormat options then call Tk command with args and options and return
    the appropriate result.

    If no option is specified, a dict is returned. If an option is
    specified with the None value, the value for that option is returned.
    Otherwise, the function just sets the passed options and the caller
    shouldn't be expecting a return value anyway.rB)�conv)r6�callr:r�
_tclobj_to_py)r#�optionsrErfr'r'r(�_val_or_dict!s
rkc	Cs2t|�}zt|�}Wnttfk
r,YnX|S)zAConverts a value to, hopefully, a more appropriate Python object.)r[�int�
ValueError�	TypeError)r-r'r'r(�_convert_stringval1srocCs(t|t�r$d|krt|�}nt|�}|S)N�.)r*r[�floatrl)�xr'r'r(�
_to_number;s


rscCs\|rFt|d�rFt|t�sFt|ddd�dkr6t|�}qXttt|��}nt|d�rXt|�}|S)z8Return value converted from Tcl object to Python object.�__len__rrZNZ	StateSpec)rTr*r[�getattrrar+rRro)r=r'r'r(riCs

ricCs"|��D]\}}t|�||<q|S)zOReturns adict with its values converted from Tcl objects to Python
    objects.)r1ri)Zadictr5r=r'r'r(rPscCs|dkrt��}|S)aIf master is not None, itself is returned. If master is None,
    the default master is returned if there is one, otherwise a new
    master is created and returned.

    If it is not allowed to use the default root and master is None,
    RuntimeError is raised.N)�tkinterZ_get_default_root)r&r'r'r(rXsc@s�eZdZdZdZddd�Zddd�Zddd	�Zdd
d�Zd dd
�Z	dd�Z
dd�Zdd�Zd!dd�Z
dd�Zdd�Zd"dd�ZdS)#rzManipulate style database.z
ttk::styleNcCs0t|�}t|dd�st|�||_|jj|_dS)Nr%F)rrur)r&r#)�selfr&r'r'r(�__init__is
zStyle.__init__cKs4|dk	rd||<t|j||jd|�}|s,|r0|SdS)z�Query or sets the default value of the specified option(s) in
        style.

        Each key in kw is an option and each value is either a string or
        a sequence identifying the value for that option.NrQ)rkr#�_name�rw�styleZ	query_optrFr_r'r'r(rQts
zStyle.configurecsj|dk	r0�j��jd|d|�}t�j�|��S�jj�jd|ft|���}�fdd�t�j|���D�S)aSQuery or sets dynamic values of the specified option(s) in
        style.

        Each key in kw is an option and each value should be a list or a
        tuple (usually) containing statespecs grouped in tuples, or list,
        or something else of your preference. A statespec is compound of
        one or more states and then a value.NrRr0cs"i|]\}}|t�j�|���qSr')rar#rc)�.0�k�v�rwr'r(�
<dictcomp>�s�zStyle.map.<locals>.<dictcomp>)r#rhryrarcr@rr1rzr'rr(rR�s
�z	Style.mapcCs.|rd�|�nd}|j�|jd|d|||�S)aReturns the value specified for option in style.

        If state is specified it is expected to be a sequence of one
        or more states. If the default argument is set, it is used as
        a fallback value in case no specification for option is found.r9r8�lookupr0)r;r#rhry)rwr{�optionr<�defaultr'r'r(r��s
�zStyle.lookupcCs>d}|rt|�d}n|dk	r"d}t|j|j�|jd||��S)a�Define the widget layout for given style. If layoutspec is
        omitted, return the layout specification for given style.

        layoutspec is expected to be a list or an object different than
        None that evaluates to False if you want to "turn off" that style.
        If it is a list (or tuple, or something else), each item should be
        a tuple where the first item is the layout name and the second item
        should have the format described below:

        LAYOUTS

            A layout can contain the value None, if takes no options, or
            a dict of options specifying how to arrange the element.
            The layout mechanism uses a simplified version of the pack
            geometry manager: given an initial cavity, each element is
            allocated a parcel. Valid options/values are:

                side: whichside
                    Specifies which side of the cavity to place the
                    element; one of top, right, bottom or left. If
                    omitted, the element occupies the entire cavity.

                sticky: nswe
                    Specifies where the element is placed inside its
                    allocated parcel.

                children: [sublayout... ]
                    Specifies a list of elements to place inside the
                    element. Each element is a tuple (or other sequence)
                    where the first item is the layout name, and the other
                    is a LAYOUT.NrrSrM)rLrer#rhry)rwr{Z
layoutspecZlspecr'r'r(rM�s �zStyle.layoutcOs8t|df|�|�\}}|jj|jdd|||f|��dS)z9Create a new element in the current theme of given etype.F�element�createN)rIr#rhry)rw�elementnamerDrErFrGr4r'r'r(�element_create�s��zStyle.element_createc	Cs(tdd�|j�|j�|jdd��D��S)z:Returns the list of elements defined in the current theme.css|]}|�d�VqdS�rbN��lstrip)r|�nr'r'r(�	<genexpr>�sz&Style.element_names.<locals>.<genexpr>r��names�r,r#rcrhryrr'r'r(�
element_names�s�zStyle.element_namesc
Cs*tdd�|j�|j�|jdd|��D��S)z)Return the list of elementname's options.css|]}|�d�VqdSr�r�)r|�or'r'r(r��sz(Style.element_options.<locals>.<genexpr>r�rjr�)rwr�r'r'r(�element_options�s�zStyle.element_optionsc
CsN|rt|�nd}|r2|j�|jdd|d|d|�n|j�|jdd|d|�dS)a.Creates a new theme.

        It is an error if themename already exists. If parent is
        specified, the new theme will inherit styles, elements and
        layouts from the specified parent theme. If settings are present,
        they are expected to have the same syntax used for theme_settings.r8�themer�z-parentz	-settingsN�rYr#rhry)rw�	themename�parentrUr.r'r'r(�theme_create�s��zStyle.theme_createcCs"t|�}|j�|jdd||�dS)a�Temporarily sets the current theme to themename, apply specified
        settings and then restore the previous theme.

        Each key in settings is a style and each value may contain the
        keys 'configure', 'map', 'layout' and 'element create' and they
        are expected to have the same format as specified by the methods
        configure, map, layout and element_create respectively.r�rUNr�)rwr�rUr.r'r'r(�theme_settings�szStyle.theme_settingscCs|j�|j�|jdd��S)z#Returns a list of all known themes.r�r�)r#rcrhryrr'r'r(�theme_names�szStyle.theme_namescCs&|dkr|j�d�S|j�d|�dS)z�If themename is None, returns the theme in use, otherwise, set
        the current theme to themename, refreshes all widgets and emits
        a <<ThemeChanged>> event.Nzreturn $ttk::currentThemez
ttk::setTheme)r#r$rh)rwr�r'r'r(�	theme_use�szStyle.theme_use)N)N)N)NN)N)NN)N)�__name__�
__module__�__qualname__�__doc__ryrxrQrRr�rMr�r�r�r�r�r�r�r'r'r'r(rds




+
c@s6eZdZdZddd�Zdd�Zddd�Zd
d	d
�ZdS)�Widgetz!Base class for Tk themed widgets.NcCs4t|�}t|dd�st|�tjj||||d�dS)a�Constructs a Ttk Widget with the parent master.

        STANDARD OPTIONS

            class, cursor, takefocus, style

        SCROLLABLE WIDGET OPTIONS

            xscrollcommand, yscrollcommand

        LABEL WIDGET OPTIONS

            text, textvariable, underline, image, compound, width

        WIDGET STATES

            active, disabled, focus, pressed, selected, background,
            readonly, alternate, invalid
        r%F)rFN)rrur)rvr�rx)rwr&Z
widgetnamerFr'r'r(rxszWidget.__init__cCs|j�|jd||�S)z�Returns the name of the element at position x, y, or the empty
        string if the point does not lie within any element.

        x and y are pixel coordinates relative to the widget.�identify�r#rh�_w�rwrr�yr'r'r(r�+szWidget.identifyc	Os6|j�|j�|jdd�|���}|r2|r2|||�S|S)a1Test the widget's state.

        If callback is not specified, returns True if the widget state
        matches statespec and False otherwise. If callback is specified,
        then it will be invoked with *args, **kw if the widget state
        matches statespec. statespec is expected to be a sequence.�instater9)r#�
getbooleanrhr�r;)rw�	statespec�callbackrErFZretr'r'r(r�3s�
zWidget.instatecCs0|dk	rd�|�}|j�t|j�|jd|���S)aModify or inquire widget state.

        Widget state is returned if statespec is None, otherwise it is
        set according to the statespec flags and then a new state spec
        is returned indicating which flags were changed. statespec is
        expected to be a sequence.Nr9r<)r;r#rcr[rhr�)rwr�r'r'r(r<Bs
zWidget.state)N)N)N)r�r�r�r�rxr�r�r<r'r'r'r(r�
s


r�c@s"eZdZdZddd�Zdd�ZdS)rzcTtk Button widget, displays a textual label and/or image, and
    evaluates a command when pressed.NcKst�||d|�dS)aConstruct a Ttk Button widget with the parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            command, default, width
        zttk::buttonN�r�rx�rwr&rFr'r'r(rxSszButton.__init__cCs|j�|jd�S)z/Invokes the command associated with the button.�invoker�rr'r'r(r�bsz
Button.invoke)N�r�r�r�r�rxr�r'r'r'r(rOs
c@s"eZdZdZddd�Zdd�ZdS)rz;Ttk Checkbutton widget which is either in on- or off-state.NcKst�||d|�dS)a'Construct a Ttk Checkbutton widget with the parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            command, offvalue, onvalue, variable
        zttk::checkbuttonNr�r�r'r'r(rxjszCheckbutton.__init__cCs|j�|jd�S)aWToggles between the selected and deselected states and
        invokes the associated command. If the widget is currently
        selected, sets the option variable to the offvalue option
        and deselects the widget; otherwise, sets the option variable
        to the option onvalue.

        Returns the result of the associated command.r�r�rr'r'r(r�yszCheckbutton.invoke)Nr�r'r'r'r(rgs
c@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)rzeTtk Entry widget displays a one-line text string and allows that
    string to be edited by the user.NcKst�|||pd|�dS)a�Constructs a Ttk Entry widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, xscrollcommand

        WIDGET-SPECIFIC OPTIONS

            exportselection, invalidcommand, justify, show, state,
            textvariable, validate, validatecommand, width

        VALIDATION MODES

            none, key, focus, focusin, focusout, all
        z
ttk::entryNr�)rwr&ZwidgetrFr'r'r(rx�szEntry.__init__cCs|�|j�|jd|��S)zqReturn a tuple of (x, y, width, height) which describes the
        bounding box of the character given by index.�bbox�Z_getintsr#rhr�)rw�indexr'r'r(r��sz
Entry.bboxcCs|j�|jd||�S)zxReturns the name of the element at position x, y, or the
        empty string if the coordinates are outside the window.r�r�r�r'r'r(r��szEntry.identifycCs|j�|j�|jd��S)z�Force revalidation, independent of the conditions specified
        by the validate option. Returns False if validation fails, True
        if it succeeds. Sets or clears the invalid state accordingly.�validate�r#r�rhr�rr'r'r(r��szEntry.validate)NN)r�r�r�r�rxr�r�r�r'r'r'r(r�s

c@s,eZdZdZd	dd�Zd
dd�Zdd�ZdS)rzMTtk Combobox widget combines a text field with a pop-down list of
    values.NcKstj||df|�dS)aConstruct a Ttk Combobox widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            exportselection, justify, height, postcommand, state,
            textvariable, values, width
        z
ttk::comboboxN�rrxr�r'r'r(rx�szCombobox.__init__cCs2|dkr |j�|j�|jd��S|j�|jd|�S)aIf newindex is supplied, sets the combobox value to the
        element at position newindex in the list of values. Otherwise,
        returns the index of the current value in the list of values
        or -1 if the current value does not appear in the list.N�current�r#Zgetintrhr�)rwZnewindexr'r'r(r��szCombobox.currentcCs|j�|jd|�dS)z(Sets the value of the combobox to value.�setNr��rwr-r'r'r(r��szCombobox.set)N)N)r�r�r�r�rxr�r�r'r'r'r(r�s


c@seZdZdZddd�ZdS)rzJTtk Frame widget is a container, used to group other widgets
    together.NcKst�||d|�dS)z�Construct a Ttk Frame with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            borderwidth, relief, padding, width, height
        z
ttk::frameNr�r�r'r'r(rx�szFrame.__init__)N�r�r�r�r�rxr'r'r'r(r�sc@seZdZdZddd�ZdS)rz7Ttk Label widget displays a textual label and/or image.NcKst�||d|�dS)aGConstruct a Ttk Label with parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, style, takefocus, text,
            textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            anchor, background, font, foreground, justify, padding,
            relief, text, wraplength
        z
ttk::labelNr�r�r'r'r(rx�s
zLabel.__init__)Nr�r'r'r'r(r�sc@seZdZdZddd�ZdS)rz�Ttk Labelframe widget is a container used to group other widgets
    together. It has an optional label, which may be a plain text string
    or another widget.NcKst�||d|�dS)z�Construct a Ttk Labelframe with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS
            labelanchor, text, underline, padding, labelwidget, width,
            height
        zttk::labelframeNr�r�r'r'r(rx�szLabelframe.__init__)Nr�r'r'r'r(r�sc@seZdZdZddd�ZdS)r	zbTtk Menubutton widget displays a textual label and/or image, and
    displays a menu when pressed.NcKst�||d|�dS)aConstruct a Ttk Menubutton with parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            direction, menu
        zttk::menubuttonNr�r�r'r'r(rxszMenubutton.__init__)Nr�r'r'r'r(r	
sc@sneZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ddd�Zddd�Zdd�Z
dd�ZdS)r
z�Ttk Notebook widget manages a collection of windows and displays
    a single one at a time. Each child window is associated with a tab,
    which the user may select to change the currently-displayed window.NcKst�||d|�dS)a\Construct a Ttk Notebook with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            height, padding, width

        TAB OPTIONS

            state, sticky, padding, text, image, compound, underline

        TAB IDENTIFIERS (tab_id)

            The tab_id argument found in several methods may take any of
            the following forms:

                * An integer between zero and the number of tabs
                * The name of a child window
                * A positional specification of the form "@x,y", which
                  defines the tab
                * The string "current", which identifies the
                  currently-selected tab
                * The string "end", which returns the number of tabs (only
                  valid for method index)
        z
ttk::notebookNr�r�r'r'r(rx"szNotebook.__init__cKs |jj|jd|ft|���dS)z�Adds a new tab to the notebook.

        If window is currently managed by the notebook but hidden, it is
        restored to its previous position.�addN�r#rhr�r6)rw�childrFr'r'r(r�BszNotebook.addcCs|j�|jd|�dS)zXRemoves the tab specified by tab_id, unmaps and unmanages the
        associated window.�forgetNr��rw�tab_idr'r'r(r�JszNotebook.forgetcCs|j�|jd|�dS)z�Hides the tab specified by tab_id.

        The tab will not be displayed, but the associated window remains
        managed by the notebook and its configuration remembered. Hidden
        tabs may be restored with the add command.�hideNr�r�r'r'r(r�Psz
Notebook.hidecCs|j�|jd||�S)zZReturns the name of the tab element at position x, y, or the
        empty string if none.r�r�r�r'r'r(r�YszNotebook.identifycCs|j�|j�|jd|��S)z|Returns the numeric index of the tab specified by tab_id, or
        the total number of tabs if tab_id is the string "end".r�r�r�r'r'r(r�_szNotebook.indexcKs"|jj|jd||ft|���dS)z�Inserts a pane at the specified position.

        pos is either the string end, an integer index, or the name of
        a managed child. If child is already managed by the notebook,
        moves it to the specified position.�insertNr��rw�posr�rFr'r'r(r�eszNotebook.insertcCs|j�|jd|�S)z�Selects the specified tab.

        The associated child window will be displayed, and the
        previously-selected window (if different) is unmapped. If tab_id
        is omitted, returns the widget name of the currently selected
        pane.�selectr�r�r'r'r(r�nszNotebook.selectcKs$|dk	rd||<t|j||jd|�S)z�Query or modify the options of the specific tab_id.

        If kw is not given, returns a dict of the tab option values. If option
        is specified, returns the value of that option. Otherwise, sets the
        options to the corresponding values.N�tab�rkr#r�)rwr�r�rFr'r'r(r�xszNotebook.tabcCs|j�|j�|jd�pd�S)z2Returns a list of windows managed by the notebook.�tabsr'�r#rcrhr�rr'r'r(r��sz
Notebook.tabscCs|j�d|j�dS)a�Enable keyboard traversal for a toplevel window containing
        this notebook.

        This will extend the bindings for the toplevel window containing
        this notebook as follows:

            Control-Tab: selects the tab following the currently selected
                         one

            Shift-Control-Tab: selects the tab preceding the currently
                               selected one

            Alt-K: where K is the mnemonic (underlined) character of any
                   tab, will select that tab.

        Multiple notebooks in a single toplevel may be enabled for
        traversal, including nested notebooks. However, notebook traversal
        only works properly if all panes are direct children of the
        notebook.zttk::notebook::enableTraversalNr�rr'r'r(�enable_traversal�szNotebook.enable_traversal)N)N)N)r�r�r�r�rxr�r�r�r�r�r�r�r�r�r�r'r'r'r(r
s
 		


c@s>eZdZdZddd�ZejjZdd�Zddd�Z	d
d	d
�Z
dS)rzfTtk Panedwindow widget displays a number of subwindows, stacked
    either vertically or horizontally.NcKst�||d|�dS)z�Construct a Ttk Panedwindow with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            orient, width, height

        PANE OPTIONS

            weight
        zttk::panedwindowNr�r�r'r'r(rx�szPanedwindow.__init__cKs"|jj|jd||ft|���dS)z�Inserts a pane at the specified positions.

        pos is either the string end, and integer index, or the name
        of a child. If child is already managed by the paned window,
        moves it to the specified position.r�Nr�r�r'r'r(r��szPanedwindow.insertcKs$|dk	rd||<t|j||jd|�S)aQQuery or modify the options of the specified pane.

        pane is either an integer index or the name of a managed subwindow.
        If kw is not given, returns a dict of the pane option values. If
        option is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values.N�paner�)rwr�r�rFr'r'r(r��szPanedwindow.panecCs|j�|j�|jd||��S)aLIf newpos is specified, sets the position of sash number index.

        May adjust the positions of adjacent sashes to ensure that
        positions are monotonically increasing. Sash positions are further
        constrained to be between 0 and the total size of the widget.

        Returns the new position of sash number index.�sashposr�)rwr�Znewposr'r'r(r��szPanedwindow.sashpos)N)N)N)r�r�r�r�rxrvrr�r�r�r�r'r'r'r(r�s
	
c@s6eZdZdZddd�Zddd�Zd
dd�Zd	d
�ZdS)r
a6Ttk Progressbar widget shows the status of a long-running
    operation. They can operate in two modes: determinate mode shows the
    amount completed relative to the total amount of work to be done, and
    indeterminate mode provides an animated display to let the user know
    that something is happening.NcKst�||d|�dS)z�Construct a Ttk Progressbar with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            orient, length, mode, maximum, value, variable, phase
        zttk::progressbarNr�r�r'r'r(rx�szProgressbar.__init__cCs|j�|jd|�dS)z�Begin autoincrement mode: schedules a recurring timer event
        that calls method step every interval milliseconds.

        interval defaults to 50 milliseconds (20 steps/second) if omitted.�startNr�)rwZintervalr'r'r(r��szProgressbar.startcCs|j�|jd|�dS)zRIncrements the value option by amount.

        amount defaults to 1.0 if omitted.�stepNr�)rwZamountr'r'r(r��szProgressbar.stepcCs|j�|jd�dS)zVStop autoincrement mode: cancels any recurring timer event
        initiated by start.�stopNr�rr'r'r(r�szProgressbar.stop)N)N)N)r�r�r�r�rxr�r�r�r'r'r'r(r
�s



c@s"eZdZdZddd�Zdd�ZdS)rzeTtk Radiobutton widgets are used in groups to show or change a
    set of mutually-exclusive options.NcKst�||d|�dS)aConstruct a Ttk Radiobutton with parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            command, value, variable
        zttk::radiobuttonNr�r�r'r'r(rxszRadiobutton.__init__cCs|j�|jd�S)z�Sets the option variable to the option value, selects the
        widget, and invokes the associated command.

        Returns the result of the command, or an empty string if
        no command is specified.r�r�rr'r'r(r�szRadiobutton.invoke)Nr�r'r'r'r(rs
c@s.eZdZdZd	dd�Zd
dd�Zddd�ZdS)rzTtk Scale widget is typically used to control the numeric value of
    a linked variable that varies uniformly over some range.NcKst�||d|�dS)z�Construct a Ttk Scale with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            command, from, length, orient, to, value, variable
        z
ttk::scaleNr�r�r'r'r(rx'szScale.__init__cKsTtj||f|�}t|td�tf�s,|�|�td|kd|kd|kg�rP|�d�|S)z�Modify or query scale options.

        Setting a value for any of the "from", "from_" or "to" options
        generates a <<RangeChanged>> event.NrC�from_�to�<<RangeChanged>>)r�rQr*�typer[�update�anyZevent_generate)rwZcnfrFZretvalr'r'r(rQ5s

zScale.configurecCs|j�|jd||�S)z�Get the current value of the value option, or the value
        corresponding to the coordinates x, y if they are specified.

        x and y are pixel coordinates relative to the scale widget
        origin.r"r�r�r'r'r(r"Bsz	Scale.get)N)N)NN)r�r�r�r�rxrQr"r'r'r'r(r#s


c@seZdZdZddd�ZdS)rz;Ttk Scrollbar controls the viewport of a scrollable widget.NcKst�||d|�dS)z�Construct a Ttk Scrollbar with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            command, orient
        zttk::scrollbarNr�r�r'r'r(rxNszScrollbar.__init__)Nr�r'r'r'r(rKsc@seZdZdZddd�ZdS)rzITtk Separator widget displays a horizontal or vertical separator
    bar.NcKst�||d|�dS)z�Construct a Ttk Separator with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            orient
        zttk::separatorNr�r�r'r'r(rx`szSeparator.__init__)Nr�r'r'r'r(r\sc@seZdZdZddd�ZdS)rzlTtk Sizegrip allows the user to resize the containing toplevel
    window by pressing and dragging the grip.NcKst�||d|�dS)z�Construct a Ttk Sizegrip with parent master.

        STANDARD OPTIONS

            class, cursor, state, style, takefocus
        z
ttk::sizegripNr�r�r'r'r(rxrszSizegrip.__init__)Nr�r'r'r'r(rnsc@s"eZdZdZddd�Zdd�ZdS)rz�Ttk Spinbox is an Entry with increment and decrement arrows

    It is commonly used for number entry or to select from a list of
    string values.
    NcKstj||df|�dS)a/Construct a Ttk Spinbox widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, validate,
            validatecommand, xscrollcommand, invalidcommand

        WIDGET-SPECIFIC OPTIONS

            to, from_, increment, values, wrap, format, command
        zttk::spinboxNr�r�r'r'r(rx�szSpinbox.__init__cCs|j�|jd|�dS)z'Sets the value of the Spinbox to value.r�Nr�r�r'r'r(r��szSpinbox.set)N)r�r�r�r�rxr�r'r'r'r(r|s
c@s4eZdZdZdEdd�ZdFdd�ZdGdd�Zd	d
�ZdHdd�Zd
d�Z	dd�Z
dd�ZdIdd�ZdJdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�ZdKd#d$�ZdLd%d&�Zd'd(�ZeZd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!dMd=d>�Z"dNd?d@�Z#dOdAdB�Z$dPdCdD�Z%dS)Qrz�Ttk Treeview widget displays a hierarchical collection of items.

    Each item has a textual label, an optional image, and an optional list
    of data values. The data values are displayed in successive columns
    after the tree label.NcKst�||d|�dS)a�Construct a Ttk Treeview with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, xscrollcommand,
            yscrollcommand

        WIDGET-SPECIFIC OPTIONS

            columns, displaycolumns, height, padding, selectmode, show

        ITEM OPTIONS

            text, image, values, open, tags

        TAG OPTIONS

            foreground, background, font, image
        z
ttk::treeviewNr�r�r'r'r(rx�szTreeview.__init__cCs|�|j�|jd||��pdS)aTReturns the bounding box (relative to the treeview widget's
        window) of the specified item in the form x y width height.

        If column is specified, returns the bounding box of that cell.
        If the item is not visible (i.e., if it is a descendant of a
        closed item or is scrolled offscreen), returns an empty string.r�r8r�)rw�item�columnr'r'r(r��sz
Treeview.bboxcCs"|j�|j�|jd|pd�pd�S)zhReturns a tuple of children belonging to item.

        If item is not specified, returns root children.rJr8r'r��rwr�r'r'r(�get_children�s�zTreeview.get_childrencGs|j�|jd||�dS)z�Replaces item's child with newchildren.

        Children present in item that are not present in newchildren
        are detached from tree. No items in newchildren may be an
        ancestor of item.rJNr�)rwr�Znewchildrenr'r'r(�set_children�szTreeview.set_childrencKs$|dk	rd||<t|j||jd|�S)a
Query or modify the options for the specified column.

        If kw is not given, returns a dict of the column option values. If
        option is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values.Nr�r�)rwr�r�rFr'r'r(r��szTreeview.columncGs|j�|jd|�dS)z_Delete all specified items and all their descendants. The root
        item may not be deleted.�deleteNr��rwr1r'r'r(r��szTreeview.deletecGs|j�|jd|�dS)z�Unlinks all of the specified items from the tree.

        The items and all of their descendants are still present, and may
        be reinserted at another point in the tree, but will not be
        displayed. The root item may not be detached.�detachNr�r�r'r'r(r��szTreeview.detachcCs|j�|j�|jd|��S)zSReturns True if the specified item is present in the tree,
        False otherwise.�existsr�r�r'r'r(r��szTreeview.existscCs|j�|jd|�S)z}If item is specified, sets the focus item to item. Otherwise,
        returns the current focus item, or '' if there is none.�focusr�r�r'r'r(r��szTreeview.focuscKsP|�d�}|r,t|t�s,|j�||j�|d<|dk	r<d||<t|j||jd|�S)a_Query or modify the heading options for the specified column.

        If kw is not given, returns a dict of the heading option values. If
        option is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values.

        Valid options/values are:
            text: text
                The text to display in the column heading
            image: image_name
                Specifies an image to display to the right of the column
                heading
            anchor: anchor
                Specifies how the heading text should be aligned. One of
                the standard Tk anchor values
            command: callback
                A callback to be invoked when the heading label is
                pressed.

        To configure the tree column heading, call this with column = "#0" �commandN�heading)	r"r*r[r&�registerZ_substituterkr#r�)rwr�r�rF�cmdr'r'r(r��s
zTreeview.headingcCs|j�|jd|||�S)z�Returns a description of the specified component under the
        point given by x and y, or the empty string if no such component
        is present at that position.r�r�)rwZ	componentrrr�r'r'r(r�szTreeview.identifycCs|�dd|�S)z.Returns the item ID of the item at position y.�rowr�r�)rwr�r'r'r(�identify_rowszTreeview.identify_rowcCs|�d|d�S)zaReturns the data column identifier of the cell at position x.

        The tree column has ID #0.r�rr�)rwrrr'r'r(�identify_column"szTreeview.identify_columncCs|�d||�S)z�Returns one of:

        heading: Tree heading area.
        separator: Space between two columns headings;
        tree: The tree area.
        cell: A data cell.

        * Availability: Tk 8.6Zregionr�r�r'r'r(�identify_region)s	zTreeview.identify_regioncCs|�d||�S)zEReturns the element at position x, y.

        * Availability: Tk 8.6r�r�r�r'r'r(�identify_element5szTreeview.identify_elementcCs|j�|j�|jd|��S)zOReturns the integer index of item within its parent's list
        of children.r�r�r�r'r'r(r�<szTreeview.indexcKsNt|�}|dk	r0|jj|jd||d|f|��}n|jj|jd||f|��}|S)a�Creates a new item and return the item identifier of the newly
        created item.

        parent is the item ID of the parent item, or the empty string
        to create a new top-level item. index is an integer, or the value
        end, specifying where in the list of parent's children to insert
        the new item. If index is less than or equal to zero, the new node
        is inserted at the beginning, if index is greater than or equal to
        the current number of children, it is inserted at the end. If iid
        is specified, it is used as the item identifier, iid must not
        already exist in the tree. Otherwise, a new unique identifier
        is generated.Nr�z-id)r6r#rhr�)rwr�r�ZiidrFr4rfr'r'r(r�Bs
��zTreeview.insertcKs$|dk	rd||<t|j||jd|�S)a-Query or modify the options for the specified item.

        If no options are given, a dict with options/values for the item
        is returned. If option is specified then the value for that option
        is returned. Otherwise, sets the options to the corresponding
        values as given by kw.Nr�r�)rwr�r�rFr'r'r(r�Ysz
Treeview.itemcCs|j�|jd|||�dS)aRMoves item to position index in parent's list of children.

        It is illegal to move an item under one of its descendants. If
        index is less than or equal to zero, item is moved to the
        beginning, if greater than or equal to the number of children,
        it is moved to the end. If item was detached it is reattached.�moveNr�)rwr�r�r�r'r'r(r�esz
Treeview.movecCs|j�|jd|�S)zeReturns the identifier of item's next sibling, or '' if item
        is the last child of its parent.�nextr�r�r'r'r(r�qsz
Treeview.nextcCs|j�|jd|�S)zaReturns the ID of the parent of item, or '' if item is at the
        top level of the hierarchy.r�r�r�r'r'r(r�wszTreeview.parentcCs|j�|jd|�S)zjReturns the identifier of item's previous sibling, or '' if
        item is the first child of its parent.�prevr�r�r'r'r(r�}sz
Treeview.prevcCs|j�|jd|�dS)z�Ensure that item is visible.

        Sets all of item's ancestors open option to True, and scrolls
        the widget if necessary so that item is within the visible
        portion of the tree.�seeNr�r�r'r'r(r��szTreeview.seecCs|j�|j�|jd��S)z$Returns the tuple of selected items.�	selectionr�rr'r'r(r��szTreeview.selectioncCs>t|�dkr&t|dttf�r&|d}|j�|jd||�dS)Nr7rr�)r:r*r,r+r#rhr�)rwZselopr1r'r'r(�
_selection�szTreeview._selectioncGs|�d|�dS)z.The specified items becomes the new selection.r�N�r�r�r'r'r(�
selection_set�szTreeview.selection_setcGs|�d|�dS)z0Add all of the specified items to the selection.r�Nr�r�r'r'r(�
selection_add�szTreeview.selection_addcGs|�d|�dS)z5Remove all of the specified items from the selection.�removeNr�r�r'r'r(�selection_remove�szTreeview.selection_removecGs|�d|�dS)z2Toggle the selection state of each specified item.ZtoggleNr�r�r'r'r(�selection_toggle�szTreeview.selection_togglecCs@|j�|jd|||�}|dkr8|dkr8t|j|dtd�S|SdS)a;Query or set the value of given item.

        With one argument, return a dictionary of column/value pairs
        for the specified item. With two arguments, return the current
        value of the specified column. With three arguments, set the
        value of given column in given item to the specified value.r�NF)Z	cut_minusrg)r#rhr�rri)rwr�r�r-rfr'r'r(r��s�zTreeview.setcCs |j|jdd|f||dd�dS)z�Bind a callback for the given event sequence to the tag tagname.
        When an event is delivered to an item, the callbacks for each
        of the item's tags option are called.�tag�bindr)r�N)Z_bindr�)rw�tagnameZsequencer�r'r'r(�tag_bind�szTreeview.tag_bindcKs&|dk	rd||<t|j||jdd|�S)aBQuery or modify the options for the specified tagname.

        If kw is not given, returns a dict of the option settings for tagname.
        If option is specified, returns the value for that option for the
        specified tagname. Otherwise, sets the options to the corresponding
        values for the given tagname.Nr�rQr�)rwr�r�rFr'r'r(�
tag_configure�s
�zTreeview.tag_configurec	CsF|dkr$|j�|j�|jdd|��S|j�|j�|jdd||��SdS)z�If item is specified, returns 1 or 0 depending on whether the
        specified item has the given tagname. Otherwise, returns a list of
        all items which have the specified tag.

        * Availability: Tk 8.6Nr�Zhas)r#rcrhr�r�)rwr�r�r'r'r(�tag_has�s��zTreeview.tag_has)N)N)N)N)N)N)N)N)NN)NN)N)N)&r�r�r�r�rxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zreattachr�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r'r'r(r�sF



	
	

 

		



csLeZdZdZddd�Z�fdd�Zd	d
�Zedd��Zej	d
d��Z�Z
S)rz�A Ttk Scale widget with a Ttk Label widget indicating its
    current value.

    The Ttk Scale can be accessed through instance.scale, and Ttk Label
    can be accessed through instance.labelNr�
c	Ks|�dd�dk|_tj||f|�|p.t�|�|_|j�|�||_t	|�|_
t||j||d�|_|j�
d|j�|jr|dnd}|dkr�dnd}|jj|dd�t	|�}|j|d�|��|j
j|dkr�d	nd
d�|j�d|j�|_|�
d
|j�|�
d|j�dS)a�Construct a horizontal LabeledScale with parent master, a
        variable to be associated with the Ttk Scale widget and its range.
        If variable is not specified, a tkinter.IntVar is created.

        WIDGET-SPECIFIC OPTIONS

            compound: 'top' or 'bottom'
                Specifies how to display the label relative to the scale.
                Defaults to 'top'.
        Zcompound�top)�variabler�r�r�Zbottomrr)�sideZfill)r�r�rW)Zanchor�wz<Configure>z<Map>N)�pop�
_label_toprrxrvZIntVar�	_variabler��_last_validr�labelr�scaler��_adjustZpack�lowerZplaceZtrace_variable�_LabeledScale__tracecb)	rwr&r�r�r�rFZ
scale_sideZ
label_sideZdummyr'r'r(rx�s$
zLabeledScale.__init__csHz|j�d|j�Wntk
r(YnX|`t���d|_d|_dS)z9Destroy this widget and possibly its associated variable.r�N)r�Z
trace_vdeleter�AttributeError�super�destroyrrr��	__class__r'r(rs
zLabeledScale.destroycs��fdd�}t�jd�}t�jd�}||kr:||}}�j��}||krX|ksfn�j�_dS|�_|�jd<��|�dS)z1Adjust the label position according to the scale.csZ����j��\}}�jr2�j���j��}n�j���j��}�jj||d�dS)N�rrr�)Zupdate_idletasksrZcoordsr�Zwinfo_yrZwinfo_reqheightZplace_configurerrr'r(�adjust_labelsz*LabeledScale._adjust.<locals>.adjust_labelrCr�N�text)rsrr�r"rr-rZ
after_idle)rwrErr�r�Znewvalr'rr(rs


zLabeledScale._adjustcCs
|j��S)zReturn current scale value.)r�r"rr'r'r(r-4szLabeledScale.valuecCs|j�|�dS)zSet new scale value.N)r�r�)rwr=r'r'r(r-9s)NNrr�)r�r�r�r�rxrr�propertyr-�setter�
__classcell__r'r'r	r(r�s
&

cs<eZdZdZddd�Zdd�Zddd�Z�fd	d
�Z�ZS)
rzmThemed OptionMenu, based after tkinter's OptionMenu, which allows
    the user to select a value from a menu.NcOs�||�dd�|�dd�d�}tj||f|�tj|dd�|d<||_|�dd�|_|rpt�d	tt	|�
�����|j|f|��dS)
a9Construct a themed OptionMenu widget with master as the parent,
        the resource textvariable set to variable, the initially selected
        value specified by the default parameter, the menu values given by
        *values and additional keywords.

        WIDGET-SPECIFIC OPTIONS

            style: stylename
                Menubutton style.
            direction: 'above', 'below', 'left', 'right', or 'flush'
                Menubutton direction.
            command: callback
                A callback that will be invoked after selecting an item.
        r{N�	direction)Ztextvariabler{rF)Ztearoff�menur�zunknown option -%s)r�r	rxrvZMenur��	_callbackZTclErrorr�r\�keys�set_menu)rwr&r�r��values�kwargsrFr'r'r(rxCs
��zOptionMenu.__init__cCs&|dkr|�t�||��St�||�S)Nr)Znametowidgetr	�__getitem__r�r'r'r(r`szOptionMenu.__getitem__cGsR|d}|�dd�|D]$}|j|t�|j||j�|jd�q|rN|j�|�dS)zUBuild a new menu of radiobuttons with *values and optionally
        a default value.rr�end)rr�r�N)r�Zadd_radiobuttonrvZ_setitr�rr�)rwr�rrr=r'r'r(rgs�zOptionMenu.set_menucs,z|`Wntk
rYnXt���dS)z0Destroy this widget and its associated variable.N)r�rrrrr	r'r(rus
zOptionMenu.destroy)N)N)	r�r�r�r�rxrrrrr'r'r	r(r?s


)F)FN)F)F)rrB)N)6r��__version__�
__author__�__all__rvrrrrZ	TkVersionrr)r/r6r>r@rIrLrYrarerkrorsrirr�objectrr�rrrrrrrrr	r
rrr
rrrrrrZXViewZYViewrrrr'r'r'r(�<module>s��	




%
1*


*B*"8*(J`PK+�\�(1616tix.cpython-38.opt-1.pycnu�[���U

e5d-,�@sLddlZddlZddlTddlmZddlZdZdZdZdZdZd	Z	d
Z
dZdZd
Z
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZGdd �d �Z Gd!d"�d"ej!e �Z!Gd#d$�d$�Z"ej#j$e"fej#_$Gd%d&�d&ej#�Z%Gd'd(�d(e%�Z&Gd)d*�d*�Z'Gd+d,�d,e%�Z(Gd-d.�d.e%�Z)Gd/d0�d0e%�Z*Gd1d2�d2e%�Z+Gd3d4�d4e%�Z,Gd5d6�d6e%�Z-Gd7d8�d8e%�Z.Gd9d:�d:e%�Z/Gd;d<�d<e%�Z0Gd=d>�d>e%�Z1Gd?d@�d@e%�Z2GdAdB�dBe%�Z3GdCdD�dDe%�Z4GdEdF�dFe%e5e6�Z7GdGdH�dHe%�Z8GdIdJ�dJe%�Z9GdKdL�dLe%�Z:GdMdN�dNe%�Z;GdOdP�dPe%�Z<GdQdR�dRe%�Z=GdSdT�dTe%�Z>GdUdV�dVe%�Z?GdWdX�dXe%�Z@GdYdZ�dZe%�ZAGd[d\�d\e%�ZBGd]d^�d^e%�ZCGd_d`�d`e%�ZDGdadb�dbe%�ZEGdcdd�dde%�ZFGdedf�dfe%�ZGGdgdh�dhe%�ZHGdidj�dje%�ZIGdkdl�dle%�ZJGdmdn�dne%�ZKGdodp�dpe%e5e6�ZLGdqdr�dre%�ZMGdsdt�dte%�ZNGdudv�dveOe&�ZPGdwdx�dxeQe&�ZRGdydz�dzeSe&�ZTGd{d|�d|eUe&�ZVGd}d~�d~eWe&�ZXGdd��d�eYe&�ZZGd�d��d�e[e&�Z\Gd�d��d�e]e&�Z^Gd�d��d�e_e&�Z`Gd�d��d�eae&�ZbGd�d��d�eDe&�ZcGd�d��d�e7e&�ZdGd�d��d�eCe&�ZeGd�d��d�eLe&�ZfGd�d��d�e*e&�ZgGd�d��d�e,e&�ZhGd�d��d�e.e&�ZiGd�d��d�e/e&�ZjGd�d��d�e2e&�ZkGd�d��d�e*e&�ZlGd�d��d�eKe&�ZmGd�d��d�e>e&�ZnGd�d��d�e@e&�Zod�d��Zpd�d��ZqGd�d��d�e%�ZrGd�d��d�e%e5e6�ZsGd�d��d�es�ZtdS)��N)�*)�	_cnfmerge�window�textZstatusZ	immediate�imageZ	imagetextZballoon�autoZ	acrosstop�asciiZcell�columnZ
decreasingZ
increasingZinteger�main�max�real�rowzs-regionzx-regionzy-region����� c@sVeZdZdZdd�Zdd�Zddd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
ddd�ZdS)�
tixCommanda�The tix commands provide access to miscellaneous  elements
    of  Tix's  internal state and the Tix application context.
    Most of the information manipulated by these  commands pertains
    to  the  application  as a whole, or to a screen or
    display, rather than to a particular window.

    This is a mixin class, assumed to be mixed to Tkinter.Tk
    that supports the self.tk.call method.
    cCs|j�dd|�S)a�Tix maintains a list of directories under which
        the  tix_getimage  and tix_getbitmap commands will
        search for image files. The standard bitmap  directory
        is $TIX_LIBRARY/bitmaps. The addbitmapdir command
        adds directory into this list. By  using  this
        command, the  image  files  of an applications can
        also be located using the tix_getimage or tix_getbitmap
        command.
        �tixZaddbitmapdir��tk�call)�selfZ	directory�r�#/usr/lib64/python3.8/tkinter/tix.py�tix_addbitmapdirRs
ztixCommand.tix_addbitmapdircCs|j�dd|�S)z�Returns  the  current  value  of the configuration
        option given by option. Option may be  any  of  the
        options described in the CONFIGURATION OPTIONS section.
        r�cgetr�r�optionrrr�tix_cget^sztixCommand.tix_cgetNcKsd|rt||f�}n|rt|�}|dkr2|�dd�St|t�rN|�ddd|�S|j�d|�|��S)a�Query or modify the configuration options of the Tix application
        context. If no option is specified, returns a dictionary all of the
        available options.  If option is specified with no value, then the
        command returns a list describing the one named option (this list
        will be identical to the corresponding sublist of the value
        returned if no option is specified).  If one or more option-value
        pairs are specified, then the command modifies the given option(s)
        to have the given value(s); in this case the command returns an
        empty string. Option may be any of the configuration options.
        Nr�	configure�-)rr )r�
_getconfigure�
isinstance�strZ_getconfigure1rr�_options�r�cnf�kwrrr�
tix_configurees
ztixCommand.tix_configurecCs*|dk	r|j�dd|�S|j�dd�SdS)a�Returns the file selection dialog that may be shared among
        different calls from this application.  This command will create a
        file selection dialog widget when it is called the first time. This
        dialog will be returned by all subsequent calls to tix_filedialog.
        An optional dlgclass parameter can be passed to specified what type
        of file selection dialog widget is desired. Possible options are
        tix FileSelectDialog or tixExFileSelectDialog.
        NrZ
filedialogr)rZdlgclassrrr�tix_filedialog{s	ztixCommand.tix_filedialogcCs|j�dd|�S)a�Locates a bitmap file of the name name.xpm or name in one of the
        bitmap directories (see the tix_addbitmapdir command above).  By
        using tix_getbitmap, you can avoid hard coding the pathnames of the
        bitmap files in your application. When successful, it returns the
        complete pathname of the bitmap file, prefixed with the character
        '@'.  The returned value can be used to configure the -bitmap
        option of the TK and Tix widgets.
        rZ	getbitmapr�r�namerrr�
tix_getbitmap�s	ztixCommand.tix_getbitmapcCs|j�dd|�S)a�Locates an image file of the name name.xpm, name.xbm or name.ppm
        in one of the bitmap directories (see the addbitmapdir command
        above). If more than one file with the same name (but different
        extensions) exist, then the image type is chosen according to the
        depth of the X display: xbm images are chosen on monochrome
        displays and color images are chosen on color displays. By using
        tix_ getimage, you can avoid hard coding the pathnames of the
        image files in your application. When successful, this command
        returns the name of the newly created image, which can be used to
        configure the -image option of the Tk and Tix widgets.
        rZgetimagerr+rrr�tix_getimage�sztixCommand.tix_getimagecCs|j�ddd|�S)a@Gets  the options  maintained  by  the  Tix
        scheme mechanism. Available options include:

            active_bg       active_fg      bg
            bold_font       dark1_bg       dark1_fg
            dark2_bg        dark2_fg       disabled_fg
            fg              fixed_font     font
            inactive_bg     inactive_fg    input1_bg
            input2_bg       italic_font    light1_bg
            light1_fg       light2_bg      light2_fg
            menu_font       output1_bg     output2_bg
            select_bg       select_fg      selector
            rr�getrr+rrr�tix_option_get�sztixCommand.tix_option_getcCs2|dk	r|j�dd|||�S|j�dd||�SdS)a�Resets the scheme and fontset of the Tix application to
        newScheme and newFontSet, respectively.  This affects only those
        widgets created after this call. Therefore, it is best to call the
        resetoptions command before the creation of any widgets in a Tix
        application.

        The optional parameter newScmPrio can be given to reset the
        priority level of the Tk options set by the Tix schemes.

        Because of the way Tk handles the X option database, after Tix has
        been has imported and inited, it is not possible to reset the color
        schemes and font sets using the tix config command.  Instead, the
        tix_resetoptions command must be used.
        NrZresetoptionsr)rZ	newSchemeZ
newFontSetZ
newScmPriorrr�tix_resetoptions�sztixCommand.tix_resetoptions)N)N)N)�__name__�
__module__�__qualname__�__doc__rrr)r*r-r.r0r1rrrrrGs


rc@s"eZdZdZddd�Zdd�ZdS)	�Tkz{Toplevel widget of Tix which represents mostly the main window
    of an application. It has an associated Tcl interpreter.N�TixcCsbtj�||||�tj�d�}|j�d�|dk	rR|j�d|�|j�d|�|j�d�dS)NZTIX_LIBRARYz<global auto_path; lappend auto_path [file dir [info nameof]]z(global auto_path; lappend auto_path {%s}z,global tcl_pkgPath; lappend tcl_pkgPath {%s}zpackage require Tix)�tkinterr6�__init__�os�environr/r�eval)rZ
screenNameZbaseNameZ	classNameZtixlibrrrr9�szTk.__init__cCs|�dd�tj�|�dS)NZWM_DELETE_WINDOW�)Zprotocolr8r6�destroy�rrrrr>�sz
Tk.destroy)NNr7�r2r3r4r5r9r>rrrrr6�s
r6c@sTeZdZdZifdd�ZeZdd�Zdd�Zdd	�Zddd�Z	ddd�Z
dd�Zd
S)�Formz�The Tix Form geometry manager

    Widgets can be arranged by specifying attachments to other widgets.
    See Tix documentation for complete detailscKs"|jjd|jf|�||���dS)N�tixForm�rr�_wr%r&rrr�config�szForm.configcCst�|||i�dS�N)rA�form�r�key�valuerrr�__setitem__�szForm.__setitem__cCs|j�dd|j�S)NrB�check�rrrDr?rrrrL�sz
Form.checkcCs|j�dd|j�dS)NrB�forgetrMr?rrrrN�szForm.forgetrcCs`|sJ|sJ|j�dd|j�}|j�|�}d}|D]}||j�|�f}q.|S|j�dd|j||�S)NrB�gridr)rrrD�	splitlistZgetint)rZxsizeZysize�x�y�zrrrrO�sz	Form.gridNcCs>|s|j�dd|j�S|ddkr*d|}|j�dd|j|�S)NrB�inforr!rMrrrrrT�s
z	Form.infocs(�fdd��j��j�dd�j��D�S)Ncsg|]}��|��qSr)�
_nametowidget��.0rQr?rr�
<listcomp>szForm.slaves.<locals>.<listcomp>rB�slaves�rrPrrDr?rr?rrYs
���zForm.slaves)rr)N)r2r3r4r5rErGrKrLrNrOrTrYrrrrrA�s


rAc@sreZdZdZdddiifdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zidfdd�Zdd�Z
dS)�	TixWidgetaQA TixWidget class is used to package all (or most) Tix widgets.

    Widget initialization is extended in two ways:
       1) It is possible to give a list of options which must be part of
       the creation command (so called Tix 'static' options). These cannot be
       given as a 'config' command later.
       2) It is possible to give the name of an existing TK widget. These are
       child widgets created automatically by a Tix mega-widget. The Tk call
       to create these widgets is therefore bypassed in TixWidget.__init__

    Both options are for use by subclasses only.
    Nc	Cs�|rt||f�}nt|�}d}|r.|�d�ndg}t|���D]&\}}||kr@|d||f}||=q@||_t�|||�|r�|jj||j	f|��|r�t�
||�i|_dS)Nr�optionsr!)r�append�list�items�
widgetName�Widget�_setuprrrDrE�subwidget_list)	r�masterr`Zstatic_optionsr'r(Zextra�k�vrrrr9s$zTixWidget.__init__cCs ||jkr|j|St|��dSrF)rc�AttributeErrorr+rrr�__getattr__Gs

zTixWidget.__getattr__cCs|j�d|j|�dS)z1Set a variable without calling its action routineZtixSetSilentNrM)rrJrrr�
set_silentLszTixWidget.set_silentcCsD|�|�}|s$td|d|j��|t|j�dd�}|�|�S)zSReturn the named subwidget (which must have been created by
        the sub-class).z
Subwidget z not child of �N)�_subwidget_name�TclError�_name�lenrDrU)rr,�nrrr�	subwidgetPs

zTixWidget.subwidgetcCsZ|��}|sgSg}|D]<}|t|j�dd�}z|�|�|��WqYqXq|S)zReturn all subwidgets.rjN)�_subwidget_namesrnrDr]rU)r�namesZretlistr,rrr�subwidgets_allZszTixWidget.subwidgets_allcCs0z|j�|jd|�WStk
r*YdSXdS)z7Get a subwidget name (returns a String, not a Widget !)rpN)rrrDrlr+rrrrkiszTixWidget._subwidget_namecCs<z |j�|jdd�}|j�|�WStk
r6YdSXdS)z"Return the name of all subwidgets.Z
subwidgetsz-allN)rrrDrPrl)rrQrrrrqps
zTixWidget._subwidget_namescCs\|dkrdSt|t�st|�}t|t�s0t|�}|��}|D]}|j�|dd||�q<dS)z8Set configuration options for all subwidgets (and self).r=Nr r!)r#r$�reprrqrr)rrrJrrr,rrr�
config_allxs

zTixWidget.config_allcKst|s|}|r|rt||f�}n|r&|}d}|��D]*\}}t|�rL|�|�}|d||f}q2|j�dd|f|�S)Nrr!r�create)rr_�callable�	_registerrr)rZimgtyper'rdr(r\rerfrrr�image_create�s
zTixWidget.image_createcCs.z|j�dd|�Wntk
r(YnXdS)Nr�delete)rrrl)rZimgnamerrr�image_delete�szTixWidget.image_delete)r2r3r4r5r9rhrirprsrkrqruryr{rrrrr[
s�
-
r[c@s"eZdZdZddd�Zdd�ZdS)	�TixSubWidgetz�Subwidget class.

    This is used to mirror child widgets automatically created
    by Tix/Tk as part of a mega-widget in Python (which is not informed
    of this)rjc
Cs�|rD|�|�}z$|t|j�dd�}|�d�}Wng}YnX|s`t�||ddd|i�n�|}tt|�d�D]V}d�|d|d��}	z|�|	�}
|
}Wqtt	k
r�t
|||ddd�}YqtXqt|r�|d}t�||ddd|i�||_dS)Nrj�.r,r)�destroy_physically�check_intermediate���)rkrnrD�splitr[r9�range�joinrU�KeyErrorr|r~)rrdr,r~r�pathZplist�parent�iro�wrrrr9�s0



�zTixSubWidget.__init__cCsjt|j���D]}|��q|j|jjkr6|jj|j=|j|jjkrP|jj|j=|jrf|j�	d|j
�dS)Nr>)r^�children�valuesr>rmrdrcr~rrrD�r�crrrr>�s
zTixSubWidget.destroyN)rjrjr@rrrrr|�s
�
 r|c@sVeZdZdZifdd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zifdd�Z	dd�Z
dS)�DisplayStylezRDisplayStyle - handle configuration options shared by
    (multiple) Display ItemsN)rdcKs\|s2d|kr|d}nd|kr(|d}n
t�d�}|j|_|jjd|f|�||���|_dS)NZ	refwindowzcreate display styleZtixDisplayStyle)r8Z_get_default_rootrrr%�	stylename)r�itemtyper'rdr(rrrr9�s



�zDisplayStyle.__init__cCs|jSrF)r�r?rrr�__str__�szDisplayStyle.__str__cCsH|r|rt||f�}n|r|}d}|��D]\}}|d||f}q*|S)Nrr!)rr_)rr'r(Zoptsrerfrrrr%�szDisplayStyle._optionscCs|j�|jd�dS�Nrz�rrr�r?rrrrz�szDisplayStyle.deletecCs|j�|jdd||�dS)Nr �-%sr�rHrrrrK�szDisplayStyle.__setitem__cKs|j|jdf|�||���S)Nr )r"r�r%r&rrrrE�s�
�zDisplayStyle.configcCs|j�|jdd|�S)Nrr�r�)rrIrrr�__getitem__�szDisplayStyle.__getitem__)r2r3r4r5r9r�r%rzrKrEr�rrrrr��s
r�c@s2eZdZdZdifdd�Zifdd�Zdd�ZdS)	�BalloonzBalloon help widget.

    Subwidget       Class
    ---------       -----
    label           Label
    message         MessageNcKsNdddddg}t�||d|||�t|ddd	�|jd<t|d
dd	�|jd
<dS)Nr\ZinstallcolormapZinitwaitZ	statusbarZcursorZ
tixBalloon�labelr�r~�message�r[r9�_dummyLabelrc�rrdr'r(Zstaticrrrr9	s���zBalloon.__init__cKs&|jj|jd|jf|�||���dS)zkBind balloon widget to another.
        One balloon widget may be bound to several widgets at the same time�bindNrC)r�widgetr'r(rrr�bind_widgetszBalloon.bind_widgetcCs|j�|jd|j�dS�NZunbindrM�rr�rrr�
unbind_widgetszBalloon.unbind_widget)r2r3r4r5r9r�r�rrrrr�s
r�c@s2eZdZdZdifdd�Zifdd�Zdd�ZdS)	�	ButtonBoxzgButtonBox - A container for pushbuttons.
    Subwidgets are the buttons added with the add method.
    NcKst�||dddg||�dS)NZtixButtonBox�orientationr\�r[r9�rrdr'r(rrrr9s

�zButtonBox.__init__cKs4|jj|jd|f|�||���}t||�|j|<|S)z$Add a button with given name to box.�add�rrrDr%�_dummyButtonrc)rr,r'r(Zbtnrrrr�#s z
ButtonBox.addcCs ||jkr|j�|jd|�dS�N�invoke�rcrrrDr+rrrr�*s
zButtonBox.invoke�r2r3r4r5r9r�r�rrrrr�sr�c@s>eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�ZdS)
�ComboBoxa�ComboBox - an Entry field with a dropdown menu. The user can select a
    choice by either typing in the entry subwidget or selecting from the
    listbox subwidget.

    Subwidget       Class
    ---------       -----
    entry       Entry
    arrow       Button
    slistbox    ScrolledListBox
    tick        Button
    cross       Button : present if created with the fancy optionNc	Ks�t�||dddddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d	�|jd	<z$t|d
�|jd
<t|d�|jd<Wntk
r�YnXdS)NZtixComboBoxZeditableZdropdown�fancyr\r��entry�arrow�slistbox�tick�cross)r[r9r�rc�_dummyEntryr��_dummyScrolledListBox�	TypeErrorr�rrrr9<s 

��
zComboBox.__init__cCs|j�|jd|�dS)NZ
addhistoryrM�rr$rrr�add_historyNszComboBox.add_historycCs|j�|jd|�dS)NZ
appendhistoryrMr�rrr�append_historyQszComboBox.append_historycCs|j�|jd||�dS�N�insertrM)r�indexr$rrrr�TszComboBox.insertcCs|j�|jd|�dS)N�pickrM�rr�rrrr�Wsz
ComboBox.pick)	r2r3r4r5r9r�r�r�r�rrrrr�.s
r�c@s>eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�ZdS)
�Controla�Control - An entry field with value change arrows.  The user can
    adjust the value by pressing the two arrow buttons or by entering
    the value directly into the entry. The new value will be checked
    against the user-defined upper and lower limits.

    Subwidget       Class
    ---------       -----
    incr       Button
    decr       Button
    entry       Entry
    label       LabelNcKsZt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixControlr\�incr�decrr�r�)r[r9r�rcr�r�r�rrrr9hs
zControl.__init__cCs|j�|jd�dS)Nr�rMr?rrr�	decrementoszControl.decrementcCs|j�|jd�dS)Nr�rMr?rrr�	incrementrszControl.incrementcCs|j�|jd�dSr�rMr?rrrr�uszControl.invokecCs|j�|jd�dS)N�updaterMr?rrrr�xszControl.update)	r2r3r4r5r9r�r�r�r�rrrrr�Zs
r�c@s$eZdZdZifdd�Zdd�ZdS)�DirListaRDirList - displays a list view of a directory, its previous
    directories and its sub-directories. The user can choose one of
    the directories displayed in the list or change to another directory.

    Subwidget       Class
    ---------       -----
    hlist       HList
    hsb              Scrollbar
    vsb              ScrollbarcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixDirListr\�hlist�vsb�hsb�r[r9�_dummyHListrc�_dummyScrollbarr�rrrr9�szDirList.__init__cCs|j�|jd|�dS�N�chdirrM�r�dirrrrr��sz
DirList.chdirN�r2r3r4r5r9r�rrrrr�{sr�c@s$eZdZdZifdd�Zdd�ZdS)�DirTreea�DirTree - Directory Listing in a hierarchical view.
    Displays a tree view of a directory, its previous directories and its
    sub-directories. The user can choose one of the directories displayed
    in the list or change to another directory.

    Subwidget       Class
    ---------       -----
    hlist           HList
    hsb             Scrollbar
    vsb             ScrollbarcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixDirTreer\r�r�r�r�r�rrrr9�szDirTree.__init__cCs|j�|jd|�dSr�rMr�rrrr��sz
DirTree.chdirNr�rrrrr��sr�c@seZdZdZifdd�ZdS)�DirSelectBoxa�DirSelectBox - Motif style file select box.
    It is generally used for
    the user to choose a file. FileSelectBox stores the files mostly
    recently selected into a ComboBox widget so that they can be quickly
    selected again.

    Subwidget       Class
    ---------       -----
    selection       ComboBox
    filter          ComboBox
    dirlist         ScrolledListBox
    filelist        ScrolledListBoxcKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixDirSelectBoxr\�dirlist�dircbx)r[r9�
_dummyDirListrc�_dummyFileComboBoxr�rrrr9�szDirSelectBox.__init__N�r2r3r4r5r9rrrrr��s
r�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�ExFileSelectBoxa�ExFileSelectBox - MS Windows style file select box.
    It provides a convenient method for the user to select files.

    Subwidget       Class
    ---------       -----
    cancel       Button
    ok              Button
    hidden       Checkbutton
    types       ComboBox
    dir              ComboBox
    file       ComboBox
    dirlist       ScrolledListBox
    filelist       ScrolledListBoxcKs�t�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d	�|jd	<t|d
�|jd
<dS)NZtixExFileSelectBoxr\�cancel�ok�hidden�typesr�r��file�filelist)r[r9r�rc�_dummyCheckbutton�_dummyComboBoxr�r�r�rrrr9�szExFileSelectBox.__init__cCs|j�|jd�dS�N�filterrMr?rrrr��szExFileSelectBox.filtercCs|j�|jd�dSr�rMr?rrrr��szExFileSelectBox.invokeN)r2r3r4r5r9r�r�rrrrr��sr�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�DirSelectDialoga#The DirSelectDialog widget presents the directories in the file
    system in a dialog window. The user can use this dialog window to
    navigate through the file system to select the desired directory.

    Subwidgets       Class
    ----------       -----
    dirbox       DirSelectDialogcKs*t�||ddg||�t|d�|jd<dS)NZtixDirSelectDialogr\Zdirbox)r[r9�_dummyDirSelectBoxrcr�rrrr9�s
�zDirSelectDialog.__init__cCs|j�|jd�dS�N�popuprMr?rrrr��szDirSelectDialog.popupcCs|j�|jd�dS�N�popdownrMr?rrrr��szDirSelectDialog.popdownN�r2r3r4r5r9r�r�rrrrr��s	r�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�ExFileSelectDialogz�ExFileSelectDialog - MS Windows style file select dialog.
    It provides a convenient method for the user to select files.

    Subwidgets       Class
    ----------       -----
    fsbox       ExFileSelectBoxcKs*t�||ddg||�t|d�|jd<dS)NZtixExFileSelectDialogr\�fsbox)r[r9�_dummyExFileSelectBoxrcr�rrrr9�s
�zExFileSelectDialog.__init__cCs|j�|jd�dSr�rMr?rrrr�szExFileSelectDialog.popupcCs|j�|jd�dSr�rMr?rrrr�szExFileSelectDialog.popdownNr�rrrrr��sr�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�
FileSelectBoxa�ExFileSelectBox - Motif style file select box.
    It is generally used for
    the user to choose a file. FileSelectBox stores the files mostly
    recently selected into a ComboBox widget so that they can be quickly
    selected again.

    Subwidget       Class
    ---------       -----
    selection       ComboBox
    filter          ComboBox
    dirlist         ScrolledListBox
    filelist        ScrolledListBoxcKsZt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixFileSelectBoxr\r�r�r��	selection)r[r9r�rcr�r�rrrr9s
zFileSelectBox.__init__cCs|j�|jd�dSr�rMr?rrr�apply_filterszFileSelectBox.apply_filtercCs|j�|jd�dSr�rMr?rrrr�szFileSelectBox.invokeN)r2r3r4r5r9r�r�rrrrr�s
r�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�FileSelectDialogz�FileSelectDialog - Motif style file select dialog.

    Subwidgets       Class
    ----------       -----
    btns       StdButtonBox
    fsbox       FileSelectBoxcKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixFileSelectDialogr\Zbtnsr�)r[r9�_dummyStdButtonBoxrc�_dummyFileSelectBoxr�rrrr9,s
�zFileSelectDialog.__init__cCs|j�|jd�dSr�rMr?rrrr�2szFileSelectDialog.popupcCs|j�|jd�dSr�rMr?rrrr�5szFileSelectDialog.popdownNr�rrrrr�#sr�c@s,eZdZdZifdd�Zdd�Zdd�ZdS)	�	FileEntrya_FileEntry - Entry field with button that invokes a FileSelectDialog.
    The user can type in the filename manually. Alternatively, the user can
    press the button widget that sits next to the entry, which will bring
    up a file selection dialog.

    Subwidgets       Class
    ----------       -----
    button       Button
    entry       EntrycKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZtixFileEntryZ
dialogtyper\Zbuttonr�)r[r9r�rcr�r�rrrr9Ds
�zFileEntry.__init__cCs|j�|jd�dSr�rMr?rrrr�JszFileEntry.invokecCsdSrFrr?rrr�file_dialogMszFileEntry.file_dialogN)r2r3r4r5r9r�r�rrrrr�8sr�c@s�eZdZdZdifdd�Zifdd�Zdifdd�Zd	d
�Zdd�Zdldd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zifd d!�Zifd"d#�Zd$d%�Zd&d'�ZeZd(d)�Zd*d+�Zd,d-�Zifd.d/�Zifd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!dmd>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,ifdTdU�Z-ifdVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1ifd^d_�Z2d`da�Z3dbdc�Z4ifddde�Z5dfdg�Z6dndhdi�Z7djdk�Z8dS)o�HListaHList - Hierarchy display  widget can be used to display any data
    that have a hierarchical structure, for example, file system directory
    trees. The list entries are indented and connected by branch lines
    according to their places in the hierarchy.

    Subwidgets - NoneNcKst�||dddg||�dS)NZtixHList�columnsr\r�r�rrrr9Ys

�zHList.__init__cKs |jj|jd|f|�||���S�Nr�rC�rr�r'r(rrrr�]sz	HList.addcKs(|sd}|jj|jd|f|�||���S)Nr=ZaddchildrC)rr�r'r(rrr�	add_child`s�
�zHList.add_childcCs|j�|jdd|�dS�N�anchor�setrM�rr�rrr�
anchor_setfszHList.anchor_setcCs|j�|jdd�dS�Nr��clearrMr?rrr�anchor_cleariszHList.anchor_clearrcCs6|s|j�|jdd||�S|j�|jdd|d|�SdS)Nr	�widthz-charrM)r�colr�charsrrr�column_widthls�zHList.column_widthcCs|j�|jdd�dS)Nrz�allrMr?rrr�
delete_allsszHList.delete_allcCs|j�|jdd|�dS)Nrzr�rMr�rrr�delete_entryvszHList.delete_entrycCs|j�|jdd|�dS)NrzZ
offspringsrMr�rrr�delete_offspringsyszHList.delete_offspringscCs|j�|jdd|�dS)NrzZsiblingsrMr�rrr�delete_siblings|szHList.delete_siblingscCs|j�|jdd|�dS�N�dragsiter�rMr�rrr�dragsite_setszHList.dragsite_setcCs|j�|jdd�dS�NrrrMr?rrr�dragsite_clear�szHList.dragsite_clearcCs|j�|jdd|�dS�N�dropsiter�rMr�rrr�dropsite_set�szHList.dropsite_setcCs|j�|jdd�dS�NrrrMr?rrr�dropsite_clear�szHList.dropsite_clearcKs&|jj|jdd|f|�||���dS)N�headerrvrC�rrr'r(rrr�
header_create�szHList.header_createcKs@|dkr|�|jdd|�S|jj|jdd|f|�||���dS)Nrr �r"rDrrr%rrrr�header_configure�s

�zHList.header_configurecCs|j�|jdd||�S)NrrrM)rr�optrrr�header_cget�szHList.header_cgetcCs|j�|j�|jdd|��S)NrZexist)rZ
getbooleanrrD�rrrrr�
header_exists�szHList.header_existscCs|j�|jdd|�dS)NrrzrMrrrr�
header_delete�szHList.header_deletecCs|j�|jdd|�S)Nr�sizerMrrrr�header_size�szHList.header_sizecCs|j�|jdd|�dS)N�hider�rMr�rrr�
hide_entry�szHList.hide_entrycKs&|jj|jdd|f|�||���dS)N�	indicatorrvrCr�rrr�indicator_create�s�
�zHList.indicator_createcKs@|dkr|�|jdd|�S|jj|jdd|f|�||���dS)Nr#r rr�rrr�indicator_configure�s��
�zHList.indicator_configurecCs|j�|jdd||�S)Nr#rrM�rr�rrrr�indicator_cget�szHList.indicator_cgetcCs|j�|jdd|�S)Nr#�existsrMr�rrr�indicator_exists�szHList.indicator_existscCs|j�|jdd|�dS)Nr#rzrMr�rrr�indicator_delete�szHList.indicator_deletecCs|j�|jdd|�S)Nr#rrMr�rrr�indicator_size�szHList.indicator_sizecCs|j�|jdd�S�NrTr�rMr?rrr�info_anchor�szHList.info_anchorcCs|�|j�|jdd|��pdS�NrTZbbox)�_getintsrrrDr�rrr�	info_bbox�s
��zHList.info_bboxcCs |j�|jdd|�}|j�|�S)NrTr��rrrDrP)rr�r�rrr�
info_children�szHList.info_childrencCs|j�|jdd|�S)NrT�datarMr�rrr�	info_data�szHList.info_datacCs|j�|jdd�S)NrTrrMr?rrr�
info_dragsite�szHList.info_dragsitecCs|j�|jdd�S)NrTrrMr?rrr�
info_dropsite�szHList.info_dropsitecCs|j�|jdd|�S)NrTr(rMr�rrr�info_exists�szHList.info_existscCs|j�|jdd|�S)NrTr�rMr�rrr�info_hidden�szHList.info_hiddencCs|j�|jdd|�S)NrT�nextrMr�rrr�	info_next�szHList.info_nextcCs|j�|jdd|�S)NrTr�rMr�rrr�info_parent�szHList.info_parentcCs|j�|jdd|�S)NrT�prevrMr�rrr�	info_prev�szHList.info_prevcCs|j�|jdd�}|j�|�S�NrTr�r1r�rrr�info_selection�szHList.info_selectioncCs|j�|jdd|||�S)N�itemrrM)rr�rrrrr�	item_cget�szHList.item_cgetcKsD|dkr|�|jdd||�S|jj|jdd||f|�||���dS)Nr@r r�rr�rr'r(rrr�item_configure�s

�zHList.item_configurecKs(|jj|jdd||f|�||���dS)Nr@rvrCrBrrr�item_create�s�
�zHList.item_createcCs|j�|jdd||�S)Nr@r(rM�rr�rrrr�item_exists�szHList.item_existscCs|j�|jdd||�dS)Nr@rzrMrErrr�item_delete�szHList.item_deletecCs|j�|jd||�S)N�	entrycgetrMr&rrrrH�szHList.entrycgetcKs<|dkr|�|jd|�S|jj|jd|f|�||���dS�N�entryconfigurerr�rrrrJ�s

�zHList.entryconfigurecCs|j�|jd|�S�N�nearestrM)rrRrrrrLsz
HList.nearestcCs|j�|jd|�dS�N�seerMr�rrrrNsz	HList.seecKs$|jj|jddf|�||���dS�Nr�rrCr&rrr�selection_clearszHList.selection_clearcCs|j�|jdd|�S�Nr�ZincludesrMr�rrr�selection_includes
szHList.selection_includescCs|j�|jdd||�dS�Nr�r�rM�r�firstZlastrrr�
selection_set
szHList.selection_setcCs|j�|jdd|�S)N�showr�rMr�rrr�
show_entryszHList.show_entry)rNN)N)N)9r2r3r4r5r9r�r�r�rrrrr	r
r
rrrrrrrZheader_existrr r"r$r%r'r)r*r+r-r0r2r4r5r6r7r8r:r;r=r?rArCrDrFrGrHrJrLrNrPrRrVrXrrrrr�Qsl


r�c@seZdZdZdifdd�ZdS)�	InputOnlyz?InputOnly - Invisible widget. Unix only.

    Subwidgets - NoneNcKst�||dd||�dS)NZtixInputOnlyr�r�rrrr9szInputOnly.__init__r�rrrrrYsrYc@seZdZdZdifdd�ZdS)�
LabelEntryaLabelEntry - Entry field with label. Packages an entry widget
    and a label into one mega widget. It can be used to simplify the creation
    of ``entry-form'' type of interface.

    Subwidgets       Class
    ----------       -----
    label       Label
    entry       EntryNcKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZ
tixLabelEntry�	labelsider\r�r�)r[r9r�rcr�r�rrrr9%s
�zLabelEntry.__init__r�rrrrrZs	rZc@seZdZdZdifdd�ZdS)�
LabelFrameaeLabelFrame - Labelled Frame container. Packages a frame widget
    and a label into one mega widget. To create widgets inside a
    LabelFrame widget, one creates the new widgets relative to the
    frame subwidget and manage them inside the frame subwidget.

    Subwidgets       Class
    ----------       -----
    label       Label
    frame       FrameNcKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZ
tixLabelFramer[r\r��frame)r[r9r�rc�_dummyFramer�rrrr96s
�zLabelFrame.__init__r�rrrrr\+s
r\c@s@eZdZdZifdd�Zifdd�Zdd�Zdd	�Zd
d�ZdS)
�ListNoteBookaA ListNoteBook widget is very similar to the TixNoteBook widget:
    it can be used to display many windows in a limited space using a
    notebook metaphor. The notebook is divided into a stack of pages
    (windows). At one time only one of these pages can be shown.
    The user can navigate through these pages by
    choosing the name of the desired page in the hlist subwidget.cKsNt�||ddg||�t|ddd�|jd<t|d�|jd<t|d�|jd<dS)NZtixListNoteBookr\Zpanerr�r�Zshlist)r[r9�_dummyPanedWindowrcr��_dummyScrolledHListr�rrrr9Es�zListNoteBook.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr��rrrDr%r|rc�rr,r'r(rrrr�Ms zListNoteBook.addcCs
|�|�SrF�rpr+rrr�pageRszListNoteBook.pagecCs:|j�|j�|jd��}g}|D]}|�|�|��q |S�N�pages�rrPrrDr]rp�rrrZretrQrrrrgUs
zListNoteBook.pagescCs|j�|jd|�dS�N�raiserMr+rrr�
raise_page]szListNoteBook.raise_pageN)	r2r3r4r5r9r�rergrlrrrrr_=sr_c@seZdZdZdifdd�ZdS)�MeterzuThe Meter widget can be used to show the progress of a background
    job which may take a long time to execute.
    NcKst�||ddg||�dS)NZtixMeterr\r�r�rrrr9es

�zMeter.__init__r�rrrrrm`srmc@sReZdZdZdifdd�Zifdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�NoteBookz�NoteBook - Multi-page container widget (tabbed notebook metaphor).

    Subwidgets       Class
    ----------       -----
    nbframe       NoteBookFrame
    <pages>       page widgets added dynamically with the add methodNcKs.t�||ddg||�t|ddd�|jd<dS)NZtixNoteBookr\Znbframerr�)r[r9r|rcr�rrrr9qs�zNoteBook.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr�rbrcrrrr�vs zNoteBook.addcCs,|j�|jd|�|j|��|j|=dSr��rrrDrcr>r+rrrrz{szNoteBook.deletecCs
|�|�SrFrdr+rrrre�sz
NoteBook.pagecCs:|j�|j�|jd��}g}|D]}|�|�|��q |Srfrhrirrrrg�s
zNoteBook.pagescCs|j�|jd|�dSrjrMr+rrrrl�szNoteBook.raise_pagecCs|j�|jd�S)N�raisedrMr?rrrrp�szNoteBook.raised)r2r3r4r5r9r�rzrergrlrprrrrrnisrnc@seZdZdS)�
NoteBookFrameN)r2r3r4rrrrrq�srqc@sLeZdZdZifdd�Zifdd�Zifdd�Zdd	�Zd
d�Zdd
�Z	dS)�
OptionMenuz�OptionMenu - creates a menu button of options.

    Subwidget       Class
    ---------       -----
    menubutton      Menubutton
    menu            MenucKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZ
tixOptionMenur\�
menubutton�menu�r[r9�_dummyMenubuttonrc�
_dummyMenur�rrrr9�szOptionMenu.__init__cKs&|jj|jdd|f|�||���dS)Nr��commandrCrcrrr�add_command�szOptionMenu.add_commandcKs&|jj|jdd|f|�||���dS)Nr�Z	separatorrCrcrrr�
add_separator�szOptionMenu.add_separatorcCs|j�|jd|�dSr�rMr+rrrrz�szOptionMenu.deletecCs|j�|jd|�dS)N�disablerMr+rrrr{�szOptionMenu.disablecCs|j�|jd|�dS)N�enablerMr+rrrr|�szOptionMenu.enableN)
r2r3r4r5r9ryrzrzr{r|rrrrrr�srrc@sTeZdZdZifdd�Zifdd�Zdd�Zdd	�Zd
d�Zifdd
�Z	dd�Z
dS)�PanedWindowa�PanedWindow - Multi-pane container widget
    allows the user to interactively manipulate the sizes of several
    panes. The panes can be arranged either vertically or horizontally.The
    user changes the sizes of the panes by dragging the resize handle
    between two panes.

    Subwidgets       Class
    ----------       -----
    <panes>       g/p widgets added dynamically with the add method.cKst�||dddg||�dS)NZtixPanedWindowr�r\r�r�rrrr9�szPanedWindow.__init__cKs>|jj|jd|f|�||���t||dd�|j|<|j|S)Nr�r)rrbrcrrrr��s
 �zPanedWindow.addcCs,|j�|jd|�|j|��|j|=dSr�ror+rrrrz�szPanedWindow.deletecCs|j�|jd|�dS)NrNrMr+rrrrN�szPanedWindow.forgetcCs|j�|jd||�S)N�panecgetrMr&rrrr~�szPanedWindow.panecgetcKs<|dkr|�|jd|�S|jj|jd|f|�||���dS)N�
paneconfigurerr�rrrr�szPanedWindow.paneconfigurecs*�j��j��jd��}�fdd�|D�S)N�panescsg|]}��|��qSrrdrVr?rrrX�sz%PanedWindow.panes.<locals>.<listcomp>rZ)rrrrr?rr��szPanedWindow.panesN)r2r3r4r5r9r�rzrNr~rr�rrrrr}�s
r}c@s4eZdZdZifdd�Zdd�Zdd�Zdd	�Zd
S)�	PopupMenuaPopupMenu widget can be used as a replacement of the tk_popup command.
    The advantage of the Tix PopupMenu widget is it requires less application
    code to manipulate.


    Subwidgets       Class
    ----------       -----
    menubutton       Menubutton
    menu       MenucKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixPopupMenur\rsrtrur�rrrr9�szPopupMenu.__init__cCs|j�|jd|j�dS)Nr�rMr�rrrr��szPopupMenu.bind_widgetcCs|j�|jd|j�dSr�rMr�rrrr��szPopupMenu.unbind_widgetcCs|j�|jd|j||�dS)NZpostrM)rr�rQrRrrr�post_widget�szPopupMenu.post_widgetN)r2r3r4r5r9r�r�r�rrrrr��s
r�c@s<eZdZdZifdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ResizeHandlez;Internal widget to draw resize handles on Scrolled widgets.c	Ks.ddddddddd	g	}t�||d
|||�dS)Nr\rxZcursorfgZcursorbgZ
handlesizeZ	hintcolorZ	hintwidthrQrRZtixResizeHandler�)rrdr'r(�flagsrrrr9�s�
�zResizeHandle.__init__cCs|j�|jd|j�dS)NZattachwidgetrMr�rrr�
attach_widgetszResizeHandle.attach_widgetcCs|j�|jd|j�dS)NZdetachwidgetrMr�rrr�
detach_widgetszResizeHandle.detach_widgetcCs|j�|jd|j�dS)Nr!rMr�rrrr!szResizeHandle.hidecCs|j�|jd|j�dS)NrWrMr�rrrrW	szResizeHandle.showN)	r2r3r4r5r9r�r�r!rWrrrrr��s
r�c@seZdZdZifdd�ZdS)�
ScrolledHListz0ScrolledHList - HList with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledHListr\r�r�r�r�r�rrrr9s�zScrolledHList.__init__Nr�rrrrr�sr�c@seZdZdZifdd�ZdS)�ScrolledListBoxz4ScrolledListBox - Listbox with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledListBoxr\�listboxr�r�)r[r9�
_dummyListboxrcr�r�rrrr9szScrolledListBox.__init__Nr�rrrrr�sr�c@seZdZdZifdd�ZdS)�ScrolledTextz.ScrolledText - Text with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledTextr\rr�r�)r[r9�
_dummyTextrcr�r�rrrr9%szScrolledText.__init__Nr�rrrrr�!sr�c@seZdZdZifdd�ZdS)�
ScrolledTListz0ScrolledTList - TList with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledTListr\Ztlistr�r�)r[r9�_dummyTListrcr�r�rrrr9/s�zScrolledTList.__init__Nr�rrrrr�+sr�c@seZdZdZifdd�ZdS)�ScrolledWindowz2ScrolledWindow - Window with automatic scrollbars.cKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledWindowr\rr�r�)r[r9r^rcr�r�rrrr9:szScrolledWindow.__init__Nr�rrrrr�6sr�c@s0eZdZdZifdd�Zifdd�Zdd�ZdS)	�Selectz�Select - Container of button subwidgets. It can be used to provide
    radio-box or check-box style of selection options for the user.

    Subwidgets are buttons added dynamically using the add method.c
Ks2t�||ddddddg||�t|d�|jd<dS)NZ	tixSelectZ	allowzero�radior�r[r\r�r�r�rrrr9Gs
��zSelect.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr�r�rcrrrr�Ns z
Select.addcCs|j�|jd|�dSr�rMr+rrrr�Ssz
Select.invokeNr�rrrrr�@sr�c@seZdZdZdifdd�ZdS)�Shellz'Toplevel window.

    Subwidgets - NoneNcKst�||dddg||�dS)NZtixShellr\�titler�r�rrrr9[szShell.__init__r�rrrrr�Vsr�c@s6eZdZdZdifdd�Zdd�Zdd�Zd	d
�ZdS)�DialogShellz�Toplevel window, with popup popdown and center methods.
    It tells the window manager that it is a dialog window and should be
    treated specially. The exact treatment depends on the treatment of
    the window manager.

    Subwidgets - NoneNcKs&t�||ddddddddg||�dS)	NZtixDialogShellr\r�ZmappedZ	minheightZminwidthr�Z	transientr�r�rrrr9gs��zDialogShell.__init__cCs|j�|jd�dSr�rMr?rrrr�nszDialogShell.popdowncCs|j�|jd�dSr�rMr?rrrr�qszDialogShell.popupcCs|j�|jd�dS)N�centerrMr?rrrr�tszDialogShell.center)r2r3r4r5r9r�r�r�rrrrr�^s
r�c@s&eZdZdZdifdd�Zdd�ZdS)�StdButtonBoxz@StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) NcKs\t�||dddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixStdButtonBoxr�r\r��applyr��help)r[r9r�rcr�rrrr9zs
�zStdButtonBox.__init__cCs ||jkr|j�|jd|�dSr�r�r+rrrr��s
zStdButtonBox.invoke)r2r3r4r5r9r�rrrrr�wsr�c@s�eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�Zd3d
d�Z	dd�Z
dd�Zdd�Zdd�Z
ifdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zifd-d.�Zd/d0�Zd4d1d2�ZdS)5�TLista�TList - Hierarchy display widget which can be
    used to display data in a tabular format. The list entries of a TList
    widget are similar to the entries in the Tk listbox widget. The main
    differences are (1) the TList widget can display the list entries in a
    two dimensional format and (2) you can use graphical images as well as
    multiple colors and fonts for the list entries.

    Subwidgets - NoneNcKst�||ddg||�dS)NZtixTListr\r�r�rrrr9�szTList.__init__cCs|j�|jdd|�dS)N�activer�rMr�rrr�
active_set�szTList.active_setcCs|j�|jdd�dS)Nr�rrMr?rrr�active_clear�szTList.active_clearcCs|j�|jdd|�dSr�rMr�rrrr��szTList.anchor_setcCs|j�|jdd�dSr�rMr?rrrr�szTList.anchor_clearcCs|j�|jd||�dSr�rM�r�from_�torrrrz�szTList.deletecCs|j�|jdd|�dSrrMr�rrrr
�szTList.dragsite_setcCs|j�|jdd�dSrrMr?rrrr�szTList.dragsite_clearcCs|j�|jdd|�dSrrMr�rrrr�szTList.dropsite_setcCs|j�|jdd�dSrrMr?rrrr�szTList.dropsite_clearcKs$|jj|jd|f|�||���dSr�rC)rr�r'r(rrrr��szTList.insertcCs|j�|jdd�S)NrTr�rMr?rrr�info_active�szTList.info_activecCs|j�|jdd�Sr,rMr?rrrr-�szTList.info_anchorcCs|j�|jdd|�S)NrTZdownrMr�rrr�	info_down�szTList.info_downcCs|j�|jdd|�S)NrT�leftrMr�rrr�	info_left�szTList.info_leftcCs|j�|jdd|�S)NrT�rightrMr�rrr�
info_right�szTList.info_rightcCs|j�|jdd�}|j�|�Sr>r1r�rrrr?�szTList.info_selectioncCs|j�|jdd�S)NrTrrMr?rrr�	info_size�szTList.info_sizecCs|j�|jdd|�S)NrTZuprMr�rrr�info_up�sz
TList.info_upcCs|j�|jd||�SrKrM�rrQrRrrrrL�sz
TList.nearestcCs|j�|jd|�dSrMrMr�rrrrN�sz	TList.seecKs$|jj|jddf|�||���dSrOrCr&rrrrP�szTList.selection_clearcCs|j�|jdd|�SrQrMr�rrrrR�szTList.selection_includescCs|j�|jdd||�dSrSrMrTrrrrV�szTList.selection_set)N)N)r2r3r4r5r9r�r�r�rrzr
rrrr�r�r-r�r�r�r?r�r�rLrNrPrRrVrrrrr��s2	
r�c@sHeZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	dS)�Treez�Tree - The tixTree widget can be used to display hierarchical
    data in a tree form. The user can adjust
    the view of the tree by opening or closing parts of the tree.NcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixTreer\r�r�r�r�r�rrrr9�s
�z
Tree.__init__cCs|j�|jd�dS�aThis command calls the setmode method for all the entries in this
     Tree widget: if an entry has no child entries, its mode is set to
     none. Otherwise, if the entry has any hidden child entries, its mode is
     set to open; otherwise its mode is set to close.�autosetmodeNrMr?rrrr��szTree.autosetmodecCs|j�|jd|�dS�z8Close the entry given by entryPath if its mode is close.�closeNrM�r�	entrypathrrrr��sz
Tree.closecCs|j�|jd|�S�z9Returns the current mode of the entry given by entryPath.�getmoderMr�rrrr��szTree.getmodecCs|j�|jd|�dS�z6Open the entry given by entryPath if its mode is open.�openNrMr�rrrr��sz	Tree.open�nonecCs|j�|jd||�dS)a�This command is used to indicate whether the entry given by
     entryPath has children entries and whether the children are visible. mode
     must be one of open, close or none. If mode is set to open, a (+)
     indicator is drawn next the entry. If mode is set to close, a (-)
     indicator is drawn next the entry. If mode is set to none, no
     indicators will be drawn for this entry. The default mode is none. The
     open mode indicates the entry has hidden children and this entry can be
     opened by the user. The close mode indicates that all the children of the
     entry are now visible and the entry can be closed by the user.�setmodeNrM�rr��moderrrr��s
zTree.setmode)r�)
r2r3r4r5r9r�r�r�r�r�rrrrr��sr�c@sZeZdZdZdifdd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	dd�Z
ddd�ZdS)�	CheckListz�The CheckList widget
    displays a list of items to be selected by the user. CheckList acts
    similarly to the Tk checkbutton or radiobutton widgets, except it is
    capable of handling many more items than checkbuttons or radiobuttons.
    NcKsLt�||dddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixCheckListr\r�r�r�r�r�r�rrrr9s
�zCheckList.__init__cCs|j�|jd�dSr�rMr?rrrr�szCheckList.autosetmodecCs|j�|jd|�dSr�rMr�rrrr�szCheckList.closecCs|j�|jd|�Sr�rMr�rrrr� szCheckList.getmodecCs|j�|jd|�dSr�rMr�rrrr�$szCheckList.open�oncCs|j�|j�|jd|��S)z�Returns a list of items whose status matches status. If status is
     not specified, the list of items in the "on" status will be returned.
     Mode can be on, off, default�getselectionrZ)rr�rrrr�(szCheckList.getselectioncCs|j�|jd|�S)z(Returns the current status of entryPath.�	getstatusrMr�rrrr�.szCheckList.getstatuscCs|j�|jd||�dS)z~Sets the status of entryPath to be status. A bitmap will be
     displayed next to the entry its status is on, off or default.�	setstatusNrMr�rrrr�2szCheckList.setstatus)r�)r�)r2r3r4r5r9r�r�r�r�r�r�r�rrrrr�s
r�c@seZdZddd�ZdS)r�rjcCst�||||�dSrF�r|r9�rrdr,r~rrrr9>sz_dummyButton.__init__N)rj�r2r3r4r9rrrrr�=sr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Bsz_dummyCheckbutton.__init__N)rjr�rrrrr�Asr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Fsz_dummyEntry.__init__N)rjr�rrrrr�Esr�c@seZdZddd�ZdS)r^rjcCst�||||�dSrFr�r�rrrr9Jsz_dummyFrame.__init__N)rjr�rrrrr^Isr^c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Nsz_dummyLabel.__init__N)rjr�rrrrr�Msr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9Rsz_dummyListbox.__init__N)rjr�rrrrr�Qsr�c@seZdZddd�ZdS)rwrjcCst�||||�dSrFr�r�rrrr9Vsz_dummyMenu.__init__N)rjr�rrrrrwUsrwc@seZdZddd�ZdS)rvrjcCst�||||�dSrFr�r�rrrr9Zsz_dummyMenubutton.__init__N)rjr�rrrrrvYsrvc@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9^sz_dummyScrollbar.__init__N)rjr�rrrrr�]sr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9bsz_dummyText.__init__N)rjr�rrrrr�asr�c@seZdZddd�ZdS)r�rjcCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�)r|r9r�rcr�r�rrrr9fsz_dummyScrolledListBox.__init__N)rjr�rrrrr�esr�c@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9msz_dummyHList.__init__N)rjr�rrrrr�lsr�c@seZdZddd�ZdS)rarjcCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dS�Nr�r�r��r|r9r�rcr�r�rrrr9qsz_dummyScrolledHList.__init__N)rjr�rrrrrapsrac@seZdZddd�ZdS)r�rjcCst�||||�dSrFr�r�rrrr9xsz_dummyTList.__init__N)rjr�rrrrr�wsr�c@seZdZddd�ZdS)r�rjcCs�t�|||d|g�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<z$t|d�|jd<t|d�|jd<Wntk
r�YnXdS)Nr�r�r�r�r�r�r�)r|r9r�rcr�r�r�r�r�rrrr9|s�
z_dummyComboBox.__init__N)rjr�rrrrr�{sr�c@seZdZddd�ZdS)r�rjcCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dSr�r�r�rrrr9�sz_dummyDirList.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCs4t�||||�t|d�|jd<t|d�|jd<dS)Nr�r�)r|r9r�rcr�r�rrrr9�sz_dummyDirSelectBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCs�t�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)	Nr�r�r�r�r�r�r�r�)r|r9r�rcr�r�r�r�rrrr9�sz_dummyExFileSelectBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCsTt�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�r�)r|r9r�rcr�r�rrrr9�s
z_dummyFileSelectBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCs$t�||||�t|d�|jd<dS)Nr�)r|r9r�rcr�rrrr9�sz_dummyFileComboBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)r�rjcCsTt�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�r�)r|r9r�rcr�rrrr9�s
z_dummyStdButtonBox.__init__N)rjr�rrrrr��sr�c@seZdZddd�ZdS)�_dummyNoteBookFramercCst�||||�dSrFr�r�rrrr9�sz_dummyNoteBookFrame.__init__N)rr�rrrrr��sr�c@seZdZddd�ZdS)r`rjcCst�||||�dSrFr�r�rrrr9�sz_dummyPanedWindow.__init__N)rjr�rrrrr`�sr`cCs|j�d|j�S)zzReturns the qualified path name for the widget. Normally used to set
    default options for subwidgets. See tixwidgets.pyZ
tixOptionNamerM)r�rrr�
OptionName�sr�cCs:d}|��D](}|d|d|d||d}q|S)Nr=z{{z} {z - z}} )�keys)�dict�s�typerrr�FileTypeList�s&r�c@seZdZdZdS)�CObjViewaBThis file implements the Canvas Object View widget. This is a base
    class of IconView. It implements automatic placement/adjustment of the
    scrollbars according to the canvas objects inside the canvas subwidget.
    The scrollbars are adjusted so that the canvas is just large enough
    to see all the objects.
    N)r2r3r4r5rrrrr��sr�c@s�eZdZdZdifdd�Zdd�Zdd�Zd	d
�Zd)dd�Zd*d
d�Z	dd�Z
dd�Zdd�Zd+dd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd,d!d"�Zd#d$�Zd%d&�Zd'd(�ZdS)-�Grida}The Tix Grid command creates a new window  and makes it into a
    tixGrid widget. Additional options, may be specified on the command
    line or in the option database to configure aspects such as its cursor
    and relief.

    A Grid widget displays its contents in a two dimensional grid of cells.
    Each cell may contain one Tix display item, which may be in text,
    graphics or other formats. See the DisplayStyle class for more information
    about Tix display items. Individual cells, or groups of cells, can be
    formatted with a wide range of attributes, such as its color, relief and
    border.

    Subwidgets - NoneNcKs"g}||_t�||d|||�dS)NZtixGrid�r'r[r9r�rrrr9�sz
Grid.__init__cCs|j�|dd�dS)zRemoves the selection anchor.r�rNrr?rrrrszGrid.anchor_clearcCs|�|j�|dd��S)z3Get the (x,y) coordinate of the current anchor cellr�r/�r/rrr?rrr�
anchor_getszGrid.anchor_getcCs|j�|dd||�dS)z/Set the selection anchor to the cell at (x, y).r�r�Nrr�rrrr�szGrid.anchor_setcCs4|dkr|j�|dd|�n|j�|dd||�dS)zdDelete rows between from_ and to inclusive.
        If to is not provided,  delete only row at from_Nrzr
rr�rrr�
delete_rowszGrid.delete_rowcCs4|dkr|j�|dd|�n|j�|dd||�dS)zjDelete columns between from_ and to inclusive.
        If to is not provided,  delete only column at from_Nrzr	rr�rrr�
delete_columnszGrid.delete_columncCs|j�|dd�dS)zUIf any cell is being edited, de-highlight the cell  and  applies
        the changes.�editr�Nrr?rrr�
edit_applyszGrid.edit_applycCs|j�|dd||�dS)zmHighlights  the  cell  at  (x, y) for editing, if the -editnotify
        command returns True for this cell.r�r�Nrr�rrr�edit_set!sz
Grid.edit_setcCs,|r|ddkrd|}|j�|d|||�S)z&Get the option value for cell at (x,y)rr!rHr)rrQrRrrrrrH&szGrid.entrycgetcKs|�d||f||�SrI)Z
_configure)rrQrRr'r(rrrrJ,szGrid.entryconfigurec	Cs|�|j�|dd||��S)z+Return True if display item exists at (x,y)rTr()Z_getbooleanrrr�rrrr72szGrid.info_existscCs|j�|dd||�Sr.rr�rrrr06szGrid.info_bboxcCs|j�|dd|||�dS)z�Moves the range of columns from position FROM through TO by
        the distance indicated by OFFSET. For example, move_column(2, 4, 1)
        moves the columns 2,3,4 to columns 3,4,5.�mover	Nr�rr�r��offsetrrr�move_column:szGrid.move_columncCs|j�|dd|||�dS)z�Moves the range of rows from position FROM through TO by
        the distance indicated by OFFSET.
        For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.r�r
Nrr�rrr�move_row@sz
Grid.move_rowcCs|�|j�|d||��S)z8Return coordinate of cell nearest pixel coordinate (x,y)rLr�r�rrrrLFszGrid.nearestcKs>|�|j|�}|dk	r"d|f|}|jj|d||f|��dS)Nz	-itemtyper�)r%r'rr)rrQrRr�r(�argsrrrr�PszGrid.setcKs*|j�|jj|jdd|f|�i|����S)a�Queries or sets the size of the column given by
        INDEX.  INDEX may be any non-negative
        integer that gives the position of a given column.
        INDEX can also be the string "default"; in this case, this command
        queries or sets the default size of all columns.
        When no option-value pair is given, this command returns a tuple
        containing the current size setting of the given column.  When
        option-value pairs are given, the corresponding options of the
        size setting of the given column are changed. Options may be one
        of the following:
              pad0 pixels
                     Specifies the paddings to the left of a column.
              pad1 pixels
                     Specifies the paddings to the right of a column.
              size val
                     Specifies the width of a column.  Val may be:
                     "auto" -- the width of the column is set to the
                     width of the widest cell in the column;
                     a valid Tk screen distance unit;
                     or a real number following by the word chars
                     (e.g. 3.4chars) that sets the width of the column to the
                     given number of characters.rr	)rrPrrDr%�rr�r(rrr�size_columnVs
�zGrid.size_columncKs(|j�|jj|dd|f|�i|����S)a�Queries or sets the size of the row given by
        INDEX. INDEX may be any non-negative
        integer that gives the position of a given row .
        INDEX can also be the string "default"; in this case, this command
        queries or sets the default size of all rows.
        When no option-value pair is given, this command returns a list con-
        taining the current size setting of the given row . When option-value
        pairs are given, the corresponding options of the size setting of the
        given row are changed. Options may be one of the following:
              pad0 pixels
                     Specifies the paddings to the top of a row.
              pad1 pixels
                     Specifies the paddings to the bottom of a row.
              size val
                     Specifies the height of a row.  Val may be:
                     "auto" -- the height of the row is set to the
                     height of the highest cell in the row;
                     a valid Tk screen distance unit;
                     or a real number following by the word chars
                     (e.g. 3.4chars) that sets the height of the row to the
                     given number of characters.rr
)rrPrr%r�rrr�size_rowps�
�z
Grid.size_rowcCs|j�|jd||�dS)z7Clears the cell at (x, y) by removing its display item.�unsetNrMr�rrrr��sz
Grid.unset)N)N)N)N)r2r3r4r5r9rr�r�r�r�r�r�rHrJr7r0r�r�rLr�r�r�r�rrrrr��s(	




r�c@seZdZdZdifdd�ZdS)�ScrolledGridzScrolled Grid widgetsNcKs"g}||_t�||d|||�dS)NZtixScrolledGridr�r�rrrr9�szScrolledGrid.__init__r�rrrrr��sr�)ur:r8rZ_tkinterZWINDOWZTEXTZSTATUSZ	IMMEDIATEZIMAGEZ	IMAGETEXTZBALLOONZAUTOZ	ACROSSTOP�ASCIIZCELLZCOLUMNZ
DECREASINGZ
INCREASINGZINTEGERZMAIN�MAXZREALZROWZS_REGIONZX_REGIONZY_REGIONZ
TCL_DONT_WAITZTCL_WINDOW_EVENTSZTCL_FILE_EVENTSZTCL_TIMER_EVENTSZTCL_IDLE_EVENTSZTCL_ALL_EVENTSrr6rAra�	__bases__r[r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZXViewZYViewr�rYrZr\r_rmrnrqrrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZButtonr�ZCheckbuttonr�ZEntryr�ZFramer^ZLabelr�ZListboxr�ZMenurwZ
MenubuttonrvZ	Scrollbarr�ZTextr�r�r�rar�r�r�r�r�r�r�r�r�r`r�r�r�r�r�rrrr�<module>s�-
8/,!"C#	()


S.6

*PK+�\�#�N��colorchooser.cpython-38.pycnu�[���U

e5dA
�@s>ddlmZGdd�de�Zd	dd�Zedkr:ede��dS)
�)�Dialogc@s$eZdZdZdZdd�Zdd�ZdS)�Choosera�Create a dialog for the tk_chooseColor command.

    Args:
        master: The master widget for this dialog.  If not provided,
            defaults to options['parent'] (if defined).
        options: Dictionary of options for the tk_chooseColor call.
            initialcolor: Specifies the selected color when the
                dialog is first displayed.  This can be a tk color
                string or a 3-tuple of ints in the range (0, 255)
                for an RGB triplet.
            parent: The parent window of the color dialog.  The
                color dialog is displayed on top of this.
            title: A string for the title of the dialog box.
    Ztk_chooseColorcCs@z&|jd}t|t�r$d||jd<Wntk
r:YnXdS)zvEnsure initialcolor is a tk color string.

        Convert initialcolor from a RGB triplet to a color string.
        �initialcolorz
#%02x%02x%02xN)�options�
isinstance�tuple�KeyError)�self�color�r�,/usr/lib64/python3.8/tkinter/colorchooser.py�_fixoptions!s

zChooser._fixoptionscCs>|rt|�sdS|�|�\}}}|d|d|dft|�fS)z�Adjust result returned from call to tk_chooseColor.

        Return both an RGB tuple of ints in the range (0, 255) and the
        tk color string in the form #rrggbb.
        )NN�)�strZ	winfo_rgb)r	Zwidget�result�r�g�brrr�
_fixresult.szChooser._fixresultN)�__name__�
__module__�__qualname__�__doc__Zcommandr
rrrrrrs
rNcKs"|r|��}||d<tf|���S)z�Display dialog window for selection of a color.

    Convenience wrapper for the Chooser class.  Displays the color
    chooser dialog with color as the initial value.
    r)�copyrZshow)r
rrrr�askcolorBsr�__main__r
)N)Ztkinter.commondialogrrrr�printrrrr�<module>s3
PK+�\s����!scrolledtext.cpython-38.opt-1.pycnu�[���U

e5d�@sldZdgZddlmZmZmZmZmZmZddl	m
Z
mZmZm
Z
Gdd�de�Zdd�Zedkrhe�d	S)
aA ScrolledText widget feels like a text widget but also has a
vertical scroll bar on its right.  (Later, options may be added to
add a horizontal bar as well, to make the bars disappear
automatically when not needed, to move them to the other side of the
window, etc.)

Configuration options are passed to the Text widget.
A Frame widget is inserted between the master and the text, to hold
the Scrollbar widget.
Most methods calls are inherited from the Text widget; Pack, Grid and
Place methods are redirected to the Frame widget however.
�ScrolledText�)�Frame�Text�	Scrollbar�Pack�Grid�Place)�RIGHT�LEFT�Y�BOTHc@seZdZddd�Zdd�ZdS)rNcKs�t|�|_t|j�|_|jjttd�|�d|jji�t	j
||jf|�|jttdd�|j
|jd<tt	���}tt���tt���Btt���B}|�|�}|D]4}|ddkr�|dkr�|d	kr�t||t|j|��q�dS)
N)�side�fillZyscrollcommandT)r
r�expandZcommandr�_ZconfigZ	configure)r�framerZvbar�packr	r�update�setr�__init__r
rZyview�vars�keysrrr�
difference�setattr�getattr)�selfZmaster�kwZ
text_meths�methods�m�r�,/usr/lib64/python3.8/tkinter/scrolledtext.pyrs
$
zScrolledText.__init__cCs
t|j�S)N)�strr)rrrr �__str__)szScrolledText.__str__)N)�__name__�
__module__�__qualname__rr"rrrr rs
cCsHddlm}tddd�}|�|t�|jttdd�|��|�	�dS)Nr)�ENDZwhite�
)ZbgZheightT)rr
r)
�tkinter.constantsr&r�insert�__doc__rrr
Z	focus_setZmainloop)r&Zstextrrr �example-sr+�__main__N)r*�__all__Ztkinterrrrrrrr(r	r
rrrr+r#rrrr �<module>s
 
PK+�\ҧ����dialog.cpython-38.opt-2.pycnu�[���U

e5d��@srddlTddlmZdZGdd�de�Zdd�Zedkrned	d
ddeeii�Z	ed	d
d
de	j
eii�Ze	��d	S)�)�*)�	_cnfmergeZ	questheadc@s"eZdZdifdd�Zdd�ZdS)�DialogNc
Ks�t||f�}d|_t�|||�|j�|jjd|j|d|d|d|df|d���|_zt�	|�Wnt
k
r~YnXdS)NZ
__dialog__Z	tk_dialog�title�text�bitmap�default�strings)rZ
widgetName�Widget�_setupZtkZgetintZcallZ_w�num�destroyZTclError)�selfZmasterZcnf�kw�r�&/usr/lib64/python3.8/tkinter/dialog.py�__init__
s&���zDialog.__init__cCsdS)Nr)rrrrr
�zDialog.destroy)�__name__�
__module__�__qualname__rr
rrrrr	s
rcCs$tdddtddd��}t|j�dS)Nz
File ModifiedzzFile "Python.h" has been modified since the last time it was saved. Do you want to save it before exiting the application.r)z	Save FilezDiscard ChangeszReturn to Editor)rrrrr	)r�DIALOG_ICON�printr)�drrr�_tests�r�__main__NrZTestZcommandZQuit)
Ztkinterrrr
rrrZButtonZPack�t�quit�qZmainlooprrrr�<module>s$��PK+�\v��ZZ!commondialog.cpython-38.opt-2.pycnu�[���U

e5d��@sddlTGdd�d�ZdS)�)�*c@s2eZdZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�DialogNcKs|s|�d�}||_||_dS)N�parent)�get�master�options)�selfrr�r	�,/usr/lib64/python3.8/tkinter/commondialog.py�__init__s
zDialog.__init__cCsdS�Nr	)rr	r	r
�_fixoptionsszDialog._fixoptionscCs|Srr	)rZwidget�resultr	r	r
�
_fixresultszDialog._fixresultcKs||��D]\}}||j|<q|��t|j�}z,|jj|jf|�	|j���}|�
||�}W5z|��WnYnXX|Sr)�itemsrr
ZFramerZdestroyZtkZcall�commandZ_optionsr)rr�k�v�w�sr	r	r
�shows
zDialog.show)N)�__name__�
__module__�__qualname__rrr
rrr	r	r	r
rs

rN)Ztkinterrr	r	r	r
�<module>sPK+�\V�Fifont.cpython-38.opt-2.pycnu�[���U

e5d@�@szdZddlZddlZdZdZdZdZdd�ZGd	d
�d
�Zd dd�Z	d!d
d�Z
edk�rve��Z
edded�Zee���ee�d��ee�d��ee���ee�d��ee�d��ee
��ee�d�e�d��eeje
d��edd�Zee�d�ejde
d��eje
ded�Ze��eje
de
jd�Ze��eedd���Zejed�ejed�e��dS)"z0.9�NZnormalZroman�boldZitaliccCst|dd�S)NT)�name�exists)�Font�r�r�$/usr/lib64/python3.8/tkinter/font.py�
nametofontsr	c@s�eZdZe�d�Zdd�Zdd�Zdd�Zd"d
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd#dd�Zdd�Zdd�ZeZd$dd�Zd d!�ZdS)%r�cCs:g}|��D]$\}}|�d|�|�t|��qt|�S�N�-)�items�append�str�tuple)�self�kw�options�k�vrrr�_set1s
z	Font._setcCs$g}|D]}|�d|�qt|�Sr)rr)r�argsrrrrr�_get8sz	Font._getcCs:i}tdt|�d�D] }||d|||dd�<q|S)Nr�r
)�range�len)rrr�irrr�_mkdict>szFont._mkdictNFcKs�|st�d�}t|d|�}|r4|�|�dd|��}n
|�|�}|sTdtt|j��}||_	|r�d|_
|j	|�|�dd��kr�tj�d|j	f��|r�|jdd|j	f|��n|jdd	|j	f|��d
|_
||_
|j|_|j|_dS)Nzuse font�tk�font�actualF�namesz$named font %s does not already exist�	configureZcreateT)�tkinter�_get_default_root�getattr�	splitlist�callrr�next�counterr�delete_fontZ_tkinterZTclError�_tk�_split�_call)r�rootrrrrrrrr�__init__Ds,


�z
Font.__init__cCs|jS�Nr�rrrr�__str__cszFont.__str__cCs&t|t�stS|j|jko$|j|jkSr0)�
isinstancer�NotImplementedrr+)r�otherrrr�__eq__fs
zFont.__eq__cCs
|�|�Sr0)�cget)r�keyrrr�__getitem__kszFont.__getitem__cCs|jf||i�dSr0)r")rr8�valuerrr�__setitem__nszFont.__setitem__cCs4z|jr|�dd|j�Wntk
r.YnXdS)Nr�delete)r*r-r�	Exceptionr1rrr�__del__qs
zFont.__del__cCst|jf|���Sr0)rr+r r1rrr�copyxsz	Font.copycCs^d}|rd|f}|r8|d|f}|jdd|jf|��S|�|�|jdd|jf|����SdS)Nr�
-displayofrrr )r-rrr,)r�option�	displayofrrrrr |s�zFont.actualcCs|�dd|jd|�S)Nr�configr)r-r)rrArrrr7�sz	Font.cgetc	KsB|r"|jdd|jf|�|���n|�|�|�dd|j���SdS)NrrC)r-rrrr,)rrrrrrC�s��zFont.configcCs2|f}|rd||f}|j�|jdd|jf|���S)Nr@r�measure)r+�getintr-r)r�textrBrrrrrD�s
zFont.measurecOs�d}|�dd�}|rd|f}|rL||�|�}|j�|jdd|jf|���S|�|jdd|jf|���}i}tdt|�d�D](}|j�||d�|||dd�<q||SdS)	NrrBr@r�metricsrrr
)	�poprr+rEr-rr,rr)rrrrrB�resrrrrrG�s�&zFont.metrics)NNNF)NN)N)�__name__�
__module__�__qualname__�	itertools�countr)rrrr/r2r6r9r;r>r?r r7rCr"rDrGrrrrrs"


	
rcCs6|st�d�}d}|rd|f}|j�|jjd|���S)Nzuse font.families()rr@r�families)rrO�r#r$rr&r')r.rBrrrrrO�s
rOcCs$|st�d�}|j�|j�dd��S)Nzuse font.names()rr!rP)r.rrrr!�s
r!�__main__�times�)�family�size�weightrTrVZhelloZ	linespace)rB)ZCourier�r)rzHello, world)rFrzQuit!)rFZcommandr)rV)NN)N)�__version__rMr#ZNORMALZROMANZBOLDZITALICr	rrOr!rJZTkr.�f�printr rCr7rDrGZLabel�wZpackZButtonZdestroyr?ZfbZmainlooprrrr�<module>sB






PK+�\�T—|�|�ttk.cpython-38.pycnu�[���U

e5d���@s�dZdZdZddddddd	d
ddd
ddddddddddddddgZddlZddlmZmZmZmZej	dkrpd nd!Z
d"d#�ZdXd$d%�ZdYd&d'�Z
d(d)�ZdZd*d+�Zd[d,d-�Zd\d/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d�Zd]d@d�ZGdAd�de�ZGdBdC�dCej�ZGdDd�de�ZGdEd�de�ZGdFd�deej �Z GdGd�de �Z!GdHd�de�Z"GdId�de�Z#GdJd	�d	e�Z$e$Z%GdKd�de�Z&GdLd�de�Z'GdMd
�d
eej(�Z)e)Z(GdNd�de�Z*GdOd�de�Z+GdPd�deej,�Z,GdQd�deej-�Z-GdRd�de�Z.GdSd�de�Z/GdTd�de �Z0GdUd�deej1ej2�Z3GdVd�de"�Z4GdWd�de&�Z5dS)^a�Ttk wrapper.

This module provides classes to allow using Tk themed widget set.

Ttk is based on a revised and enhanced version of
TIP #48 (http://tip.tcl.tk/48) specified style engine.

Its basic idea is to separate, to the extent possible, the code
implementing a widget's behavior from the code implementing its
appearance. Widget class bindings are primarily responsible for
maintaining the widget state and invoking callbacks, all aspects
of the widgets appearance lies at Themes.
z0.3.1z!Guilherme Polo <ggpolo@gmail.com>�Button�Checkbutton�Combobox�Entry�Frame�Label�
Labelframe�
LabelFrame�
Menubutton�Notebook�Panedwindow�PanedWindow�Progressbar�Radiobutton�Scale�	Scrollbar�	Separator�Sizegrip�Spinbox�Style�Treeview�LabeledScale�
OptionMenu�
tclobjs_to_py�setup_master�N)�_flatten�_join�
_stringify�
_splitdictg!@TFcCsBtr>ddl}|j�d�}|r,|j�d|�|j�d�d|_dS)NrZTILE_LIBRARYz(global auto_path; lappend auto_path {%s}zpackage require tileT)�
_REQUIRE_TILE�os�environ�get�tk�eval�_tile_loaded)�masterr Ztilelib�r'�#/usr/lib64/python3.8/tkinter/ttk.py�
_load_tile"s��r)cCs(|rt|�}nt|ttf�r$t|�}|S)zInternal function.)r�
isinstance�list�tupler)�value�scriptr'r'r(�_format_optvalue1s

r/cCsPg}|��D]:\}}|r ||kr|�d|�|dk	r|�t||��qt|�S)z�Formats optdict to a tuple to pass it to tk.call.

    E.g. (script=False):
      {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns:
      ('-foreground', 'blue', '-padding', '1 2 3 4')�-%sN)�items�appendr/r)Zoptdictr.�ignore�opts�optr-r'r'r(�_format_optdict;sr6cCsXg}|D]J�^}}t|�dkr,|dp(d}n
d�|�}|�|�|dk	r|�|�q|S)N�r�� )�len�joinr2)r1Zopt_val�state�valr'r'r(�_mapdict_valuesKs

r>cCs:g}|��D]$\}}|�d|tt|�|�f�qt|�S)z�Formats mapdict to pass it to tk.call.

    E.g. (script=False):
      {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]}

      returns:

      ('-expand', '{active selected} grey focus {1, 2, 3, 4}')r0)r1�extendr/r>r)Zmapdictr.r4r5r-r'r'r(�_format_mapdict`s

�r@cOs�d}d}|dkr�|dkrB|d}tt|dd���}d||f}n2|dd�\}}	tt|dd���}
d	||	|
f}t||�}n,|d
kr�|d}t|�dkr�t|d|�f}|r�d|}d�|�}||fS)
zAFormats args and kw according to the given element factory etype.Nr')�imageZvsapirArr7z%s %s�z%s %s %s�fromz{%s}r9)rr>r6r:r/r;)�etyper.�args�kw�specr4ZinameZ	imagespec�
class_nameZpart_idZstatemapr'r'r(�_format_elemcreateqs&
rIrBc
Cs�g}|D]�}|\}}|pi}d�t|dd��}dd|||rDd|ndf}d|kr�|�|d�||7}t|d||�\}	}|�|	�||8}|�d	d|�q|�|�qd
�|�|fS)a$Formats a layout list so we can pass the result to ttk::style
    layout and ttk::style settings. Note that the layout doesn't have to
    be a list necessarily.

    E.g.:
      [("Menubutton.background", None),
       ("Menubutton.button", {"children":
           [("Menubutton.focus", {"children":
               [("Menubutton.padding", {"children":
                [("Menubutton.label", {"side": "left", "expand": 1})]
               })]
           })]
       }),
       ("Menubutton.indicator", {"side": "right"})
      ]

      returns:

      Menubutton.background
      Menubutton.button -children {
        Menubutton.focus -children {
          Menubutton.padding -children {
            Menubutton.label -side left -expand 1
          }
        }
      }
      Menubutton.indicator -side rightr9T)�childrenz%s%s%sz %sr8rJz -children {z%s}�
)r;r6r2�_format_layoutlist)
�layout�indentZindent_sizer.Zlayout_elem�elemr4Zfopts�headZ	newscriptr'r'r(rL�s"
�
rLcCsXg}|��D�]>\}}|�d�rFd�t|dd��}|�d||f�|�d�rvd�t|dd��}|�d||f�d|kr�|ds�d}nt|d�\}}|�d	||f�|�d
�r|d
}|d}d}|t|�kr�t||d
�s�|d7}q�|d|�}	|t|�k�r||�r||ni}
t	|df|	�|
�\}}|�d||||f�qd�|�S)z�Returns an appropriate script, based on settings, according to
    theme_settings definition to be used by theme_settings and
    theme_create.�	configurer9Tzttk::style configure %s %s;�mapzttk::style map %s %s;rM�nullzttk::style layout %s {
%s
}zelement createrr7r1z%ttk::style element create %s %s %s %srK)
r1r"r;r6r2r@rLr:�hasattrrI)�settingsr.�namer4�s�_ZeoptsrDZargcZelemargsZelemkwrGr'r'r(�_script_from_settings�s:



$�
rYcCs�t|t�r|Sg}t|�}t||�D]j\}}t|d�rDt|���}n(t|t�rX|��}nt|ttf�sl|f}t|d�r~t|�}|�||f��q$|S)ztConstruct a list from the given statespec tuple according to the
    accepted statespec accepted by _format_mapdict.�typename)	r*�str�iter�ziprT�splitr,r+r2)Zstuple�result�itr<r=r'r'r(�_list_from_statespec�s




racCs�|�|�}g}d}|t|�kr�||}i}|�||f�|d7}|t|�kr|||d�\}}|�d�slq|dd�}|d7}|dkr�t||�}|||<q@q|S)zpConstruct a list from the tuple returned by ttk::layout, this is
    somewhat the reverse of _format_layoutlist.rr7rB�-NrJ)�	splitlistr:r2�
startswith�_list_from_layouttuple)r#Zltuple�resZindxrVr4r5r=r'r'r(res$


recGs4t|�}|j||�}t|�dr&|St||td�S)ahFormat options then call Tk command with args and options and return
    the appropriate result.

    If no option is specified, a dict is returned. If an option is
    specified with the None value, the value for that option is returned.
    Otherwise, the function just sets the passed options and the caller
    shouldn't be expecting a return value anyway.rB)�conv)r6�callr:r�
_tclobj_to_py)r#�optionsrErfr'r'r(�_val_or_dict!s
rkc	Cs2t|�}zt|�}Wnttfk
r,YnX|S)zAConverts a value to, hopefully, a more appropriate Python object.)r[�int�
ValueError�	TypeError)r-r'r'r(�_convert_stringval1srocCs(t|t�r$d|krt|�}nt|�}|S)N�.)r*r[�floatrl)�xr'r'r(�
_to_number;s


rscCs\|rFt|d�rFt|t�sFt|ddd�dkr6t|�}qXttt|��}nt|d�rXt|�}|S)z8Return value converted from Tcl object to Python object.�__len__rrZNZ	StateSpec)rTr*r[�getattrrar+rRro)r=r'r'r(riCs

ricCs"|��D]\}}t|�||<q|S)zOReturns adict with its values converted from Tcl objects to Python
    objects.)r1ri)Zadictr5r=r'r'r(rPscCs|dkrt��}|S)aIf master is not None, itself is returned. If master is None,
    the default master is returned if there is one, otherwise a new
    master is created and returned.

    If it is not allowed to use the default root and master is None,
    RuntimeError is raised.N)�tkinterZ_get_default_root)r&r'r'r(rXsc@s�eZdZdZdZddd�Zddd�Zddd	�Zdd
d�Zd dd
�Z	dd�Z
dd�Zdd�Zd!dd�Z
dd�Zdd�Zd"dd�ZdS)#rzManipulate style database.z
ttk::styleNcCs0t|�}t|dd�st|�||_|jj|_dS)Nr%F)rrur)r&r#)�selfr&r'r'r(�__init__is
zStyle.__init__cKs4|dk	rd||<t|j||jd|�}|s,|r0|SdS)z�Query or sets the default value of the specified option(s) in
        style.

        Each key in kw is an option and each value is either a string or
        a sequence identifying the value for that option.NrQ)rkr#�_name�rw�styleZ	query_optrFr_r'r'r(rQts
zStyle.configurecsj|dk	r0�j��jd|d|�}t�j�|��S�jj�jd|ft|���}�fdd�t�j|���D�S)aSQuery or sets dynamic values of the specified option(s) in
        style.

        Each key in kw is an option and each value should be a list or a
        tuple (usually) containing statespecs grouped in tuples, or list,
        or something else of your preference. A statespec is compound of
        one or more states and then a value.NrRr0cs"i|]\}}|t�j�|���qSr')rar#rc)�.0�k�v�rwr'r(�
<dictcomp>�s�zStyle.map.<locals>.<dictcomp>)r#rhryrarcr@rr1rzr'rr(rR�s
�z	Style.mapcCs.|rd�|�nd}|j�|jd|d|||�S)aReturns the value specified for option in style.

        If state is specified it is expected to be a sequence of one
        or more states. If the default argument is set, it is used as
        a fallback value in case no specification for option is found.r9r8�lookupr0)r;r#rhry)rwr{�optionr<�defaultr'r'r(r��s
�zStyle.lookupcCs>d}|rt|�d}n|dk	r"d}t|j|j�|jd||��S)a�Define the widget layout for given style. If layoutspec is
        omitted, return the layout specification for given style.

        layoutspec is expected to be a list or an object different than
        None that evaluates to False if you want to "turn off" that style.
        If it is a list (or tuple, or something else), each item should be
        a tuple where the first item is the layout name and the second item
        should have the format described below:

        LAYOUTS

            A layout can contain the value None, if takes no options, or
            a dict of options specifying how to arrange the element.
            The layout mechanism uses a simplified version of the pack
            geometry manager: given an initial cavity, each element is
            allocated a parcel. Valid options/values are:

                side: whichside
                    Specifies which side of the cavity to place the
                    element; one of top, right, bottom or left. If
                    omitted, the element occupies the entire cavity.

                sticky: nswe
                    Specifies where the element is placed inside its
                    allocated parcel.

                children: [sublayout... ]
                    Specifies a list of elements to place inside the
                    element. Each element is a tuple (or other sequence)
                    where the first item is the layout name, and the other
                    is a LAYOUT.NrrSrM)rLrer#rhry)rwr{Z
layoutspecZlspecr'r'r(rM�s �zStyle.layoutcOs8t|df|�|�\}}|jj|jdd|||f|��dS)z9Create a new element in the current theme of given etype.F�element�createN)rIr#rhry)rw�elementnamerDrErFrGr4r'r'r(�element_create�s��zStyle.element_createc	Cs(tdd�|j�|j�|jdd��D��S)z:Returns the list of elements defined in the current theme.css|]}|�d�VqdS�rbN��lstrip)r|�nr'r'r(�	<genexpr>�sz&Style.element_names.<locals>.<genexpr>r��names�r,r#rcrhryrr'r'r(�
element_names�s�zStyle.element_namesc
Cs*tdd�|j�|j�|jdd|��D��S)z)Return the list of elementname's options.css|]}|�d�VqdSr�r�)r|�or'r'r(r��sz(Style.element_options.<locals>.<genexpr>r�rjr�)rwr�r'r'r(�element_options�s�zStyle.element_optionsc
CsN|rt|�nd}|r2|j�|jdd|d|d|�n|j�|jdd|d|�dS)a.Creates a new theme.

        It is an error if themename already exists. If parent is
        specified, the new theme will inherit styles, elements and
        layouts from the specified parent theme. If settings are present,
        they are expected to have the same syntax used for theme_settings.r8�themer�z-parentz	-settingsN�rYr#rhry)rw�	themename�parentrUr.r'r'r(�theme_create�s��zStyle.theme_createcCs"t|�}|j�|jdd||�dS)a�Temporarily sets the current theme to themename, apply specified
        settings and then restore the previous theme.

        Each key in settings is a style and each value may contain the
        keys 'configure', 'map', 'layout' and 'element create' and they
        are expected to have the same format as specified by the methods
        configure, map, layout and element_create respectively.r�rUNr�)rwr�rUr.r'r'r(�theme_settings�szStyle.theme_settingscCs|j�|j�|jdd��S)z#Returns a list of all known themes.r�r�)r#rcrhryrr'r'r(�theme_names�szStyle.theme_namescCs&|dkr|j�d�S|j�d|�dS)z�If themename is None, returns the theme in use, otherwise, set
        the current theme to themename, refreshes all widgets and emits
        a <<ThemeChanged>> event.Nzreturn $ttk::currentThemez
ttk::setTheme)r#r$rh)rwr�r'r'r(�	theme_use�szStyle.theme_use)N)N)N)NN)N)NN)N)�__name__�
__module__�__qualname__�__doc__ryrxrQrRr�rMr�r�r�r�r�r�r�r'r'r'r(rds




+
c@s6eZdZdZddd�Zdd�Zddd�Zd
d	d
�ZdS)�Widgetz!Base class for Tk themed widgets.NcCs4t|�}t|dd�st|�tjj||||d�dS)a�Constructs a Ttk Widget with the parent master.

        STANDARD OPTIONS

            class, cursor, takefocus, style

        SCROLLABLE WIDGET OPTIONS

            xscrollcommand, yscrollcommand

        LABEL WIDGET OPTIONS

            text, textvariable, underline, image, compound, width

        WIDGET STATES

            active, disabled, focus, pressed, selected, background,
            readonly, alternate, invalid
        r%F)rFN)rrur)rvr�rx)rwr&Z
widgetnamerFr'r'r(rxszWidget.__init__cCs|j�|jd||�S)z�Returns the name of the element at position x, y, or the empty
        string if the point does not lie within any element.

        x and y are pixel coordinates relative to the widget.�identify�r#rh�_w�rwrr�yr'r'r(r�+szWidget.identifyc	Os6|j�|j�|jdd�|���}|r2|r2|||�S|S)a1Test the widget's state.

        If callback is not specified, returns True if the widget state
        matches statespec and False otherwise. If callback is specified,
        then it will be invoked with *args, **kw if the widget state
        matches statespec. statespec is expected to be a sequence.�instater9)r#�
getbooleanrhr�r;)rw�	statespec�callbackrErFZretr'r'r(r�3s�
zWidget.instatecCs0|dk	rd�|�}|j�t|j�|jd|���S)aModify or inquire widget state.

        Widget state is returned if statespec is None, otherwise it is
        set according to the statespec flags and then a new state spec
        is returned indicating which flags were changed. statespec is
        expected to be a sequence.Nr9r<)r;r#rcr[rhr�)rwr�r'r'r(r<Bs
zWidget.state)N)N)N)r�r�r�r�rxr�r�r<r'r'r'r(r�
s


r�c@s"eZdZdZddd�Zdd�ZdS)rzcTtk Button widget, displays a textual label and/or image, and
    evaluates a command when pressed.NcKst�||d|�dS)aConstruct a Ttk Button widget with the parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            command, default, width
        zttk::buttonN�r�rx�rwr&rFr'r'r(rxSszButton.__init__cCs|j�|jd�S)z/Invokes the command associated with the button.�invoker�rr'r'r(r�bsz
Button.invoke)N�r�r�r�r�rxr�r'r'r'r(rOs
c@s"eZdZdZddd�Zdd�ZdS)rz;Ttk Checkbutton widget which is either in on- or off-state.NcKst�||d|�dS)a'Construct a Ttk Checkbutton widget with the parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            command, offvalue, onvalue, variable
        zttk::checkbuttonNr�r�r'r'r(rxjszCheckbutton.__init__cCs|j�|jd�S)aWToggles between the selected and deselected states and
        invokes the associated command. If the widget is currently
        selected, sets the option variable to the offvalue option
        and deselects the widget; otherwise, sets the option variable
        to the option onvalue.

        Returns the result of the associated command.r�r�rr'r'r(r�yszCheckbutton.invoke)Nr�r'r'r'r(rgs
c@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)rzeTtk Entry widget displays a one-line text string and allows that
    string to be edited by the user.NcKst�|||pd|�dS)a�Constructs a Ttk Entry widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, xscrollcommand

        WIDGET-SPECIFIC OPTIONS

            exportselection, invalidcommand, justify, show, state,
            textvariable, validate, validatecommand, width

        VALIDATION MODES

            none, key, focus, focusin, focusout, all
        z
ttk::entryNr�)rwr&ZwidgetrFr'r'r(rx�szEntry.__init__cCs|�|j�|jd|��S)zqReturn a tuple of (x, y, width, height) which describes the
        bounding box of the character given by index.�bbox�Z_getintsr#rhr�)rw�indexr'r'r(r��sz
Entry.bboxcCs|j�|jd||�S)zxReturns the name of the element at position x, y, or the
        empty string if the coordinates are outside the window.r�r�r�r'r'r(r��szEntry.identifycCs|j�|j�|jd��S)z�Force revalidation, independent of the conditions specified
        by the validate option. Returns False if validation fails, True
        if it succeeds. Sets or clears the invalid state accordingly.�validate�r#r�rhr�rr'r'r(r��szEntry.validate)NN)r�r�r�r�rxr�r�r�r'r'r'r(r�s

c@s,eZdZdZd	dd�Zd
dd�Zdd�ZdS)rzMTtk Combobox widget combines a text field with a pop-down list of
    values.NcKstj||df|�dS)aConstruct a Ttk Combobox widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            exportselection, justify, height, postcommand, state,
            textvariable, values, width
        z
ttk::comboboxN�rrxr�r'r'r(rx�szCombobox.__init__cCs2|dkr |j�|j�|jd��S|j�|jd|�S)aIf newindex is supplied, sets the combobox value to the
        element at position newindex in the list of values. Otherwise,
        returns the index of the current value in the list of values
        or -1 if the current value does not appear in the list.N�current�r#Zgetintrhr�)rwZnewindexr'r'r(r��szCombobox.currentcCs|j�|jd|�dS)z(Sets the value of the combobox to value.�setNr��rwr-r'r'r(r��szCombobox.set)N)N)r�r�r�r�rxr�r�r'r'r'r(r�s


c@seZdZdZddd�ZdS)rzJTtk Frame widget is a container, used to group other widgets
    together.NcKst�||d|�dS)z�Construct a Ttk Frame with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            borderwidth, relief, padding, width, height
        z
ttk::frameNr�r�r'r'r(rx�szFrame.__init__)N�r�r�r�r�rxr'r'r'r(r�sc@seZdZdZddd�ZdS)rz7Ttk Label widget displays a textual label and/or image.NcKst�||d|�dS)aGConstruct a Ttk Label with parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, style, takefocus, text,
            textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            anchor, background, font, foreground, justify, padding,
            relief, text, wraplength
        z
ttk::labelNr�r�r'r'r(rx�s
zLabel.__init__)Nr�r'r'r'r(r�sc@seZdZdZddd�ZdS)rz�Ttk Labelframe widget is a container used to group other widgets
    together. It has an optional label, which may be a plain text string
    or another widget.NcKst�||d|�dS)z�Construct a Ttk Labelframe with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS
            labelanchor, text, underline, padding, labelwidget, width,
            height
        zttk::labelframeNr�r�r'r'r(rx�szLabelframe.__init__)Nr�r'r'r'r(r�sc@seZdZdZddd�ZdS)r	zbTtk Menubutton widget displays a textual label and/or image, and
    displays a menu when pressed.NcKst�||d|�dS)aConstruct a Ttk Menubutton with parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            direction, menu
        zttk::menubuttonNr�r�r'r'r(rxszMenubutton.__init__)Nr�r'r'r'r(r	
sc@sneZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ddd�Zddd�Zdd�Z
dd�ZdS)r
z�Ttk Notebook widget manages a collection of windows and displays
    a single one at a time. Each child window is associated with a tab,
    which the user may select to change the currently-displayed window.NcKst�||d|�dS)a\Construct a Ttk Notebook with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            height, padding, width

        TAB OPTIONS

            state, sticky, padding, text, image, compound, underline

        TAB IDENTIFIERS (tab_id)

            The tab_id argument found in several methods may take any of
            the following forms:

                * An integer between zero and the number of tabs
                * The name of a child window
                * A positional specification of the form "@x,y", which
                  defines the tab
                * The string "current", which identifies the
                  currently-selected tab
                * The string "end", which returns the number of tabs (only
                  valid for method index)
        z
ttk::notebookNr�r�r'r'r(rx"szNotebook.__init__cKs |jj|jd|ft|���dS)z�Adds a new tab to the notebook.

        If window is currently managed by the notebook but hidden, it is
        restored to its previous position.�addN�r#rhr�r6)rw�childrFr'r'r(r�BszNotebook.addcCs|j�|jd|�dS)zXRemoves the tab specified by tab_id, unmaps and unmanages the
        associated window.�forgetNr��rw�tab_idr'r'r(r�JszNotebook.forgetcCs|j�|jd|�dS)z�Hides the tab specified by tab_id.

        The tab will not be displayed, but the associated window remains
        managed by the notebook and its configuration remembered. Hidden
        tabs may be restored with the add command.�hideNr�r�r'r'r(r�Psz
Notebook.hidecCs|j�|jd||�S)zZReturns the name of the tab element at position x, y, or the
        empty string if none.r�r�r�r'r'r(r�YszNotebook.identifycCs|j�|j�|jd|��S)z|Returns the numeric index of the tab specified by tab_id, or
        the total number of tabs if tab_id is the string "end".r�r�r�r'r'r(r�_szNotebook.indexcKs"|jj|jd||ft|���dS)z�Inserts a pane at the specified position.

        pos is either the string end, an integer index, or the name of
        a managed child. If child is already managed by the notebook,
        moves it to the specified position.�insertNr��rw�posr�rFr'r'r(r�eszNotebook.insertcCs|j�|jd|�S)z�Selects the specified tab.

        The associated child window will be displayed, and the
        previously-selected window (if different) is unmapped. If tab_id
        is omitted, returns the widget name of the currently selected
        pane.�selectr�r�r'r'r(r�nszNotebook.selectcKs$|dk	rd||<t|j||jd|�S)z�Query or modify the options of the specific tab_id.

        If kw is not given, returns a dict of the tab option values. If option
        is specified, returns the value of that option. Otherwise, sets the
        options to the corresponding values.N�tab�rkr#r�)rwr�r�rFr'r'r(r�xszNotebook.tabcCs|j�|j�|jd�pd�S)z2Returns a list of windows managed by the notebook.�tabsr'�r#rcrhr�rr'r'r(r��sz
Notebook.tabscCs|j�d|j�dS)a�Enable keyboard traversal for a toplevel window containing
        this notebook.

        This will extend the bindings for the toplevel window containing
        this notebook as follows:

            Control-Tab: selects the tab following the currently selected
                         one

            Shift-Control-Tab: selects the tab preceding the currently
                               selected one

            Alt-K: where K is the mnemonic (underlined) character of any
                   tab, will select that tab.

        Multiple notebooks in a single toplevel may be enabled for
        traversal, including nested notebooks. However, notebook traversal
        only works properly if all panes are direct children of the
        notebook.zttk::notebook::enableTraversalNr�rr'r'r(�enable_traversal�szNotebook.enable_traversal)N)N)N)r�r�r�r�rxr�r�r�r�r�r�r�r�r�r�r'r'r'r(r
s
 		


c@s>eZdZdZddd�ZejjZdd�Zddd�Z	d
d	d
�Z
dS)rzfTtk Panedwindow widget displays a number of subwindows, stacked
    either vertically or horizontally.NcKst�||d|�dS)z�Construct a Ttk Panedwindow with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            orient, width, height

        PANE OPTIONS

            weight
        zttk::panedwindowNr�r�r'r'r(rx�szPanedwindow.__init__cKs"|jj|jd||ft|���dS)z�Inserts a pane at the specified positions.

        pos is either the string end, and integer index, or the name
        of a child. If child is already managed by the paned window,
        moves it to the specified position.r�Nr�r�r'r'r(r��szPanedwindow.insertcKs$|dk	rd||<t|j||jd|�S)aQQuery or modify the options of the specified pane.

        pane is either an integer index or the name of a managed subwindow.
        If kw is not given, returns a dict of the pane option values. If
        option is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values.N�paner�)rwr�r�rFr'r'r(r��szPanedwindow.panecCs|j�|j�|jd||��S)aLIf newpos is specified, sets the position of sash number index.

        May adjust the positions of adjacent sashes to ensure that
        positions are monotonically increasing. Sash positions are further
        constrained to be between 0 and the total size of the widget.

        Returns the new position of sash number index.�sashposr�)rwr�Znewposr'r'r(r��szPanedwindow.sashpos)N)N)N)r�r�r�r�rxrvrr�r�r�r�r'r'r'r(r�s
	
c@s6eZdZdZddd�Zddd�Zd
dd�Zd	d
�ZdS)r
a6Ttk Progressbar widget shows the status of a long-running
    operation. They can operate in two modes: determinate mode shows the
    amount completed relative to the total amount of work to be done, and
    indeterminate mode provides an animated display to let the user know
    that something is happening.NcKst�||d|�dS)z�Construct a Ttk Progressbar with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            orient, length, mode, maximum, value, variable, phase
        zttk::progressbarNr�r�r'r'r(rx�szProgressbar.__init__cCs|j�|jd|�dS)z�Begin autoincrement mode: schedules a recurring timer event
        that calls method step every interval milliseconds.

        interval defaults to 50 milliseconds (20 steps/second) if omitted.�startNr�)rwZintervalr'r'r(r��szProgressbar.startcCs|j�|jd|�dS)zRIncrements the value option by amount.

        amount defaults to 1.0 if omitted.�stepNr�)rwZamountr'r'r(r��szProgressbar.stepcCs|j�|jd�dS)zVStop autoincrement mode: cancels any recurring timer event
        initiated by start.�stopNr�rr'r'r(r�szProgressbar.stop)N)N)N)r�r�r�r�rxr�r�r�r'r'r'r(r
�s



c@s"eZdZdZddd�Zdd�ZdS)rzeTtk Radiobutton widgets are used in groups to show or change a
    set of mutually-exclusive options.NcKst�||d|�dS)aConstruct a Ttk Radiobutton with parent master.

        STANDARD OPTIONS

            class, compound, cursor, image, state, style, takefocus,
            text, textvariable, underline, width

        WIDGET-SPECIFIC OPTIONS

            command, value, variable
        zttk::radiobuttonNr�r�r'r'r(rxszRadiobutton.__init__cCs|j�|jd�S)z�Sets the option variable to the option value, selects the
        widget, and invokes the associated command.

        Returns the result of the command, or an empty string if
        no command is specified.r�r�rr'r'r(r�szRadiobutton.invoke)Nr�r'r'r'r(rs
c@s.eZdZdZd	dd�Zd
dd�Zddd�ZdS)rzTtk Scale widget is typically used to control the numeric value of
    a linked variable that varies uniformly over some range.NcKst�||d|�dS)z�Construct a Ttk Scale with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            command, from, length, orient, to, value, variable
        z
ttk::scaleNr�r�r'r'r(rx'szScale.__init__cKsTtj||f|�}t|td�tf�s,|�|�td|kd|kd|kg�rP|�d�|S)z�Modify or query scale options.

        Setting a value for any of the "from", "from_" or "to" options
        generates a <<RangeChanged>> event.NrC�from_�to�<<RangeChanged>>)r�rQr*�typer[�update�anyZevent_generate)rwZcnfrFZretvalr'r'r(rQ5s

zScale.configurecCs|j�|jd||�S)z�Get the current value of the value option, or the value
        corresponding to the coordinates x, y if they are specified.

        x and y are pixel coordinates relative to the scale widget
        origin.r"r�r�r'r'r(r"Bsz	Scale.get)N)N)NN)r�r�r�r�rxrQr"r'r'r'r(r#s


c@seZdZdZddd�ZdS)rz;Ttk Scrollbar controls the viewport of a scrollable widget.NcKst�||d|�dS)z�Construct a Ttk Scrollbar with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            command, orient
        zttk::scrollbarNr�r�r'r'r(rxNszScrollbar.__init__)Nr�r'r'r'r(rKsc@seZdZdZddd�ZdS)rzITtk Separator widget displays a horizontal or vertical separator
    bar.NcKst�||d|�dS)z�Construct a Ttk Separator with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            orient
        zttk::separatorNr�r�r'r'r(rx`szSeparator.__init__)Nr�r'r'r'r(r\sc@seZdZdZddd�ZdS)rzlTtk Sizegrip allows the user to resize the containing toplevel
    window by pressing and dragging the grip.NcKst�||d|�dS)z�Construct a Ttk Sizegrip with parent master.

        STANDARD OPTIONS

            class, cursor, state, style, takefocus
        z
ttk::sizegripNr�r�r'r'r(rxrszSizegrip.__init__)Nr�r'r'r'r(rnsc@s"eZdZdZddd�Zdd�ZdS)rz�Ttk Spinbox is an Entry with increment and decrement arrows

    It is commonly used for number entry or to select from a list of
    string values.
    NcKstj||df|�dS)a/Construct a Ttk Spinbox widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, validate,
            validatecommand, xscrollcommand, invalidcommand

        WIDGET-SPECIFIC OPTIONS

            to, from_, increment, values, wrap, format, command
        zttk::spinboxNr�r�r'r'r(rx�szSpinbox.__init__cCs|j�|jd|�dS)z'Sets the value of the Spinbox to value.r�Nr�r�r'r'r(r��szSpinbox.set)N)r�r�r�r�rxr�r'r'r'r(r|s
c@s4eZdZdZdEdd�ZdFdd�ZdGdd�Zd	d
�ZdHdd�Zd
d�Z	dd�Z
dd�ZdIdd�ZdJdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�ZdKd#d$�ZdLd%d&�Zd'd(�ZeZd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!dMd=d>�Z"dNd?d@�Z#dOdAdB�Z$dPdCdD�Z%dS)Qrz�Ttk Treeview widget displays a hierarchical collection of items.

    Each item has a textual label, an optional image, and an optional list
    of data values. The data values are displayed in successive columns
    after the tree label.NcKst�||d|�dS)a�Construct a Ttk Treeview with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, xscrollcommand,
            yscrollcommand

        WIDGET-SPECIFIC OPTIONS

            columns, displaycolumns, height, padding, selectmode, show

        ITEM OPTIONS

            text, image, values, open, tags

        TAG OPTIONS

            foreground, background, font, image
        z
ttk::treeviewNr�r�r'r'r(rx�szTreeview.__init__cCs|�|j�|jd||��pdS)aTReturns the bounding box (relative to the treeview widget's
        window) of the specified item in the form x y width height.

        If column is specified, returns the bounding box of that cell.
        If the item is not visible (i.e., if it is a descendant of a
        closed item or is scrolled offscreen), returns an empty string.r�r8r�)rw�item�columnr'r'r(r��sz
Treeview.bboxcCs"|j�|j�|jd|pd�pd�S)zhReturns a tuple of children belonging to item.

        If item is not specified, returns root children.rJr8r'r��rwr�r'r'r(�get_children�s�zTreeview.get_childrencGs|j�|jd||�dS)z�Replaces item's child with newchildren.

        Children present in item that are not present in newchildren
        are detached from tree. No items in newchildren may be an
        ancestor of item.rJNr�)rwr�Znewchildrenr'r'r(�set_children�szTreeview.set_childrencKs$|dk	rd||<t|j||jd|�S)a
Query or modify the options for the specified column.

        If kw is not given, returns a dict of the column option values. If
        option is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values.Nr�r�)rwr�r�rFr'r'r(r��szTreeview.columncGs|j�|jd|�dS)z_Delete all specified items and all their descendants. The root
        item may not be deleted.�deleteNr��rwr1r'r'r(r��szTreeview.deletecGs|j�|jd|�dS)z�Unlinks all of the specified items from the tree.

        The items and all of their descendants are still present, and may
        be reinserted at another point in the tree, but will not be
        displayed. The root item may not be detached.�detachNr�r�r'r'r(r��szTreeview.detachcCs|j�|j�|jd|��S)zSReturns True if the specified item is present in the tree,
        False otherwise.�existsr�r�r'r'r(r��szTreeview.existscCs|j�|jd|�S)z}If item is specified, sets the focus item to item. Otherwise,
        returns the current focus item, or '' if there is none.�focusr�r�r'r'r(r��szTreeview.focuscKsP|�d�}|r,t|t�s,|j�||j�|d<|dk	r<d||<t|j||jd|�S)a_Query or modify the heading options for the specified column.

        If kw is not given, returns a dict of the heading option values. If
        option is specified then the value for that option is returned.
        Otherwise, sets the options to the corresponding values.

        Valid options/values are:
            text: text
                The text to display in the column heading
            image: image_name
                Specifies an image to display to the right of the column
                heading
            anchor: anchor
                Specifies how the heading text should be aligned. One of
                the standard Tk anchor values
            command: callback
                A callback to be invoked when the heading label is
                pressed.

        To configure the tree column heading, call this with column = "#0" �commandN�heading)	r"r*r[r&�registerZ_substituterkr#r�)rwr�r�rF�cmdr'r'r(r��s
zTreeview.headingcCs|j�|jd|||�S)z�Returns a description of the specified component under the
        point given by x and y, or the empty string if no such component
        is present at that position.r�r�)rwZ	componentrrr�r'r'r(r�szTreeview.identifycCs|�dd|�S)z.Returns the item ID of the item at position y.�rowr�r�)rwr�r'r'r(�identify_rowszTreeview.identify_rowcCs|�d|d�S)zaReturns the data column identifier of the cell at position x.

        The tree column has ID #0.r�rr�)rwrrr'r'r(�identify_column"szTreeview.identify_columncCs|�d||�S)z�Returns one of:

        heading: Tree heading area.
        separator: Space between two columns headings;
        tree: The tree area.
        cell: A data cell.

        * Availability: Tk 8.6Zregionr�r�r'r'r(�identify_region)s	zTreeview.identify_regioncCs|�d||�S)zEReturns the element at position x, y.

        * Availability: Tk 8.6r�r�r�r'r'r(�identify_element5szTreeview.identify_elementcCs|j�|j�|jd|��S)zOReturns the integer index of item within its parent's list
        of children.r�r�r�r'r'r(r�<szTreeview.indexcKsNt|�}|dk	r0|jj|jd||d|f|��}n|jj|jd||f|��}|S)a�Creates a new item and return the item identifier of the newly
        created item.

        parent is the item ID of the parent item, or the empty string
        to create a new top-level item. index is an integer, or the value
        end, specifying where in the list of parent's children to insert
        the new item. If index is less than or equal to zero, the new node
        is inserted at the beginning, if index is greater than or equal to
        the current number of children, it is inserted at the end. If iid
        is specified, it is used as the item identifier, iid must not
        already exist in the tree. Otherwise, a new unique identifier
        is generated.Nr�z-id)r6r#rhr�)rwr�r�ZiidrFr4rfr'r'r(r�Bs
��zTreeview.insertcKs$|dk	rd||<t|j||jd|�S)a-Query or modify the options for the specified item.

        If no options are given, a dict with options/values for the item
        is returned. If option is specified then the value for that option
        is returned. Otherwise, sets the options to the corresponding
        values as given by kw.Nr�r�)rwr�r�rFr'r'r(r�Ysz
Treeview.itemcCs|j�|jd|||�dS)aRMoves item to position index in parent's list of children.

        It is illegal to move an item under one of its descendants. If
        index is less than or equal to zero, item is moved to the
        beginning, if greater than or equal to the number of children,
        it is moved to the end. If item was detached it is reattached.�moveNr�)rwr�r�r�r'r'r(r�esz
Treeview.movecCs|j�|jd|�S)zeReturns the identifier of item's next sibling, or '' if item
        is the last child of its parent.�nextr�r�r'r'r(r�qsz
Treeview.nextcCs|j�|jd|�S)zaReturns the ID of the parent of item, or '' if item is at the
        top level of the hierarchy.r�r�r�r'r'r(r�wszTreeview.parentcCs|j�|jd|�S)zjReturns the identifier of item's previous sibling, or '' if
        item is the first child of its parent.�prevr�r�r'r'r(r�}sz
Treeview.prevcCs|j�|jd|�dS)z�Ensure that item is visible.

        Sets all of item's ancestors open option to True, and scrolls
        the widget if necessary so that item is within the visible
        portion of the tree.�seeNr�r�r'r'r(r��szTreeview.seecCs|j�|j�|jd��S)z$Returns the tuple of selected items.�	selectionr�rr'r'r(r��szTreeview.selectioncCs>t|�dkr&t|dttf�r&|d}|j�|jd||�dS)Nr7rr�)r:r*r,r+r#rhr�)rwZselopr1r'r'r(�
_selection�szTreeview._selectioncGs|�d|�dS)z.The specified items becomes the new selection.r�N�r�r�r'r'r(�
selection_set�szTreeview.selection_setcGs|�d|�dS)z0Add all of the specified items to the selection.r�Nr�r�r'r'r(�
selection_add�szTreeview.selection_addcGs|�d|�dS)z5Remove all of the specified items from the selection.�removeNr�r�r'r'r(�selection_remove�szTreeview.selection_removecGs|�d|�dS)z2Toggle the selection state of each specified item.ZtoggleNr�r�r'r'r(�selection_toggle�szTreeview.selection_togglecCs@|j�|jd|||�}|dkr8|dkr8t|j|dtd�S|SdS)a;Query or set the value of given item.

        With one argument, return a dictionary of column/value pairs
        for the specified item. With two arguments, return the current
        value of the specified column. With three arguments, set the
        value of given column in given item to the specified value.r�NF)Z	cut_minusrg)r#rhr�rri)rwr�r�r-rfr'r'r(r��s�zTreeview.setcCs |j|jdd|f||dd�dS)z�Bind a callback for the given event sequence to the tag tagname.
        When an event is delivered to an item, the callbacks for each
        of the item's tags option are called.�tag�bindr)r�N)Z_bindr�)rw�tagnameZsequencer�r'r'r(�tag_bind�szTreeview.tag_bindcKs&|dk	rd||<t|j||jdd|�S)aBQuery or modify the options for the specified tagname.

        If kw is not given, returns a dict of the option settings for tagname.
        If option is specified, returns the value for that option for the
        specified tagname. Otherwise, sets the options to the corresponding
        values for the given tagname.Nr�rQr�)rwr�r�rFr'r'r(�
tag_configure�s
�zTreeview.tag_configurec	CsF|dkr$|j�|j�|jdd|��S|j�|j�|jdd||��SdS)z�If item is specified, returns 1 or 0 depending on whether the
        specified item has the given tagname. Otherwise, returns a list of
        all items which have the specified tag.

        * Availability: Tk 8.6Nr�Zhas)r#rcrhr�r�)rwr�r�r'r'r(�tag_has�s��zTreeview.tag_has)N)N)N)N)N)N)N)N)NN)NN)N)N)&r�r�r�r�rxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zreattachr�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r'r'r(r�sF



	
	

 

		



csLeZdZdZddd�Z�fdd�Zd	d
�Zedd��Zej	d
d��Z�Z
S)rz�A Ttk Scale widget with a Ttk Label widget indicating its
    current value.

    The Ttk Scale can be accessed through instance.scale, and Ttk Label
    can be accessed through instance.labelNr�
c	Ks|�dd�dk|_tj||f|�|p.t�|�|_|j�|�||_t	|�|_
t||j||d�|_|j�
d|j�|jr|dnd}|dkr�dnd}|jj|dd�t	|�}|j|d�|��|j
j|dkr�d	nd
d�|j�d|j�|_|�
d
|j�|�
d|j�dS)a�Construct a horizontal LabeledScale with parent master, a
        variable to be associated with the Ttk Scale widget and its range.
        If variable is not specified, a tkinter.IntVar is created.

        WIDGET-SPECIFIC OPTIONS

            compound: 'top' or 'bottom'
                Specifies how to display the label relative to the scale.
                Defaults to 'top'.
        Zcompound�top)�variabler�r�r�Zbottomrr)�sideZfill)r�r�rW)Zanchor�wz<Configure>z<Map>N)�pop�
_label_toprrxrvZIntVar�	_variabler��_last_validr�labelr�scaler��_adjustZpack�lowerZplaceZtrace_variable�_LabeledScale__tracecb)	rwr&r�r�r�rFZ
scale_sideZ
label_sideZdummyr'r'r(rx�s$
zLabeledScale.__init__csHz|j�d|j�Wntk
r(YnX|`t���d|_d|_dS)z9Destroy this widget and possibly its associated variable.r�N)r�Z
trace_vdeleter�AttributeError�super�destroyrrr��	__class__r'r(rs
zLabeledScale.destroycs��fdd�}t�jd�}t�jd�}||kr:||}}�j��}||krX|ksfn�j�_dS|�_|�jd<��|�dS)z1Adjust the label position according to the scale.csZ����j��\}}�jr2�j���j��}n�j���j��}�jj||d�dS)N�rrr�)Zupdate_idletasksrZcoordsr�Zwinfo_yrZwinfo_reqheightZplace_configurerrr'r(�adjust_labelsz*LabeledScale._adjust.<locals>.adjust_labelrCr�N�text)rsrr�r"rr-rZ
after_idle)rwrErr�r�Znewvalr'rr(rs


zLabeledScale._adjustcCs
|j��S)zReturn current scale value.)r�r"rr'r'r(r-4szLabeledScale.valuecCs|j�|�dS)zSet new scale value.N)r�r�)rwr=r'r'r(r-9s)NNrr�)r�r�r�r�rxrr�propertyr-�setter�
__classcell__r'r'r	r(r�s
&

cs<eZdZdZddd�Zdd�Zddd�Z�fd	d
�Z�ZS)
rzmThemed OptionMenu, based after tkinter's OptionMenu, which allows
    the user to select a value from a menu.NcOs�||�dd�|�dd�d�}tj||f|�tj|dd�|d<||_|�dd�|_|rpt�d	tt	|�
�����|j|f|��dS)
a9Construct a themed OptionMenu widget with master as the parent,
        the resource textvariable set to variable, the initially selected
        value specified by the default parameter, the menu values given by
        *values and additional keywords.

        WIDGET-SPECIFIC OPTIONS

            style: stylename
                Menubutton style.
            direction: 'above', 'below', 'left', 'right', or 'flush'
                Menubutton direction.
            command: callback
                A callback that will be invoked after selecting an item.
        r{N�	direction)Ztextvariabler{rF)Ztearoff�menur�zunknown option -%s)r�r	rxrvZMenur��	_callbackZTclErrorr�r\�keys�set_menu)rwr&r�r��values�kwargsrFr'r'r(rxCs
��zOptionMenu.__init__cCs&|dkr|�t�||��St�||�S)Nr)Znametowidgetr	�__getitem__r�r'r'r(r`szOptionMenu.__getitem__cGsR|d}|�dd�|D]$}|j|t�|j||j�|jd�q|rN|j�|�dS)zUBuild a new menu of radiobuttons with *values and optionally
        a default value.rr�end)rr�r�N)r�Zadd_radiobuttonrvZ_setitr�rr�)rwr�rrr=r'r'r(rgs�zOptionMenu.set_menucs,z|`Wntk
rYnXt���dS)z0Destroy this widget and its associated variable.N)r�rrrrr	r'r(rus
zOptionMenu.destroy)N)N)	r�r�r�r�rxrrrrr'r'r	r(r?s


)F)FN)F)F)rrB)N)6r��__version__�
__author__�__all__rvrrrrZ	TkVersionrr)r/r6r>r@rIrLrYrarerkrorsrirr�objectrr�rrrrrrrrr	r
rrr
rrrrrrZXViewZYViewrrrr'r'r'r(�<module>s��	




%
1*


*B*"8*(J`PK+�\���i�(�(filedialog.cpython-38.opt-2.pycnu�[���U

e5d�8�@sddlTddlmZddlmZddlmZddlZddlZiZGdd�d�Z	Gdd	�d	e	�Z
Gd
d�de	�ZGdd
�d
ej�ZGdd�de�Z
Gdd�de�ZGdd�dej�Zdd�Zdd�Zdd�Zd'dd�Zd(dd�Zd)d d!�Zd"d#�Zd$d%�Zed&k�re�dS)*�)�*)�Dialog)�commondialog)�
_setup_dialogNc@s�eZdZdZd#dd�Zejdddfdd�Zd$d	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zd%dd�Zdd�Zdd�Zd&dd�Zdd �Zd!d"�ZdS)'�
FileDialogzFile Selection DialogNcCs�|dkr|j}||_d|_t|�|_|j�|�|j�|�t|j�t|j�|_|jj	t
td�t|j�|_
|j
j	t
td�|j
�d|j�t|j�|_|jj	ttd�|j�d|j�t|j�|_|jj	ttd�t|j�|_|jj	ttd�t|jd|jdfd�|_|jj	tttd�|j��}|j�|dd�|dd��|j�d	|j�|j�d
|j�|jj|jdfd�t|j�|_ |j j	t!td�t|jd|j dfd�|_"|j"j	t!ttd�|j j|j"dfd�|j"��}|j"�|dd�|dd��|j"�d	|j#�|j"�d
|j$�t%|jd
|j&d�|_'|j'j	t!d�t%|jd|jd�|_(|j(j	t!td�t%|jd|j)d�|_*|j*j	td�|j�+d|j)�|j�d|j)�|j�d|j)�dS)N)�side�fillz<Return>)�expandrr�set)ZexportselectionZyscrollcommand)rr	r�z<ButtonRelease-1>z<Double-ButtonRelease-1>Zyview)�commandZOK)�textr)rZFilter)rr	�CancelZWM_DELETE_WINDOWz<Alt-w>z<Alt-W>),�title�master�	directoryZToplevel�topZiconnamerZFrameZbotframeZpackZBOTTOM�XZEntry�	selectionZbind�ok_event�filterZTOP�filter_commandZmidframeZYESZBOTHZ	ScrollbarZfilesbarZRIGHT�YZListbox�filesZbindtags�files_select_event�files_double_eventZconfigZdirsbarZLEFT�dirs�dirs_select_event�dirs_double_eventZButton�
ok_commandZ	ok_buttonZ
filter_button�cancel_commandZ
cancel_buttonZprotocol)�selfrrZbtags�r"�*/usr/lib64/python3.8/tkinter/filedialog.py�__init__4st

�
 �
 ���zFileDialog.__init__r�cCs�|r|tkrt|\|_}n2tj�|�}tj�|�r<||_ntj�|�\|_}|�|j|�|�|�|�	�|j
��|j�
�|j��d|_|j��|r�|��\}}|jr�tj�|j�}||ft|<|j��|jS�N)�dialogstatesr�os�path�
expanduser�isdir�split�
set_filter�
set_selectionrrZ	focus_setrZwait_visibilityZgrab_set�howrZmainloop�
get_filter�dirnameZdestroy)r!Zdir_or_file�pattern�default�keyrr"r"r#�gots*





z
FileDialog.gocCs||_|j��dSr&)r/r�quit)r!r/r"r"r#r6�szFileDialog.quitcCs|��dSr&)r�r!�eventr"r"r#r�szFileDialog.dirs_double_eventcCs@|��\}}|j�d�}tj�tj�|j|��}|�||�dS�NZactive)	r0r�getr(r)�normpath�joinrr-)r!r8�dir�patZsubdirr"r"r#r�szFileDialog.dirs_select_eventcCs|��dSr&�rr7r"r"r#r�szFileDialog.files_double_eventcCs|j�d�}|�|�dSr9)rr:r.)r!r8�filer"r"r#r�szFileDialog.files_select_eventcCs|��dSr&r?r7r"r"r#r�szFileDialog.ok_eventcCs|�|���dSr&)r6�
get_selection�r!r"r"r#r�szFileDialog.ok_commandcCs&|��\}}zt�|�}Wn tk
r:|j��YdSX||_|�||�|��tj	g}g}|D]@}tj
�||�}tj
�|�r�|�
|�qft�||�rf|�
|�qf|j�dt�|D]}|j�t|�q�|j�dt�|D]}|j�t|�q�tj
�|���\}	}
|
tjk�rd}
|�|
�dS)Nrr%)r0r(�listdir�OSErrorr�bellrr-�sort�pardirr)r<r+�append�fnmatchr�delete�END�insertrr,rA�curdirr.)r!r8r=r>�namesZsubdirsZ
matchingfiles�name�fullname�head�tailr"r"r#r�s6
zFileDialog.filter_commandcCsN|j��}tj�|�}|dd�tjks4tj�|�rBtj�|d�}tj�|�S)N���r)	rr:r(r)r*�sepr+r<r,)r!rr"r"r#r0�s

zFileDialog.get_filtercCs|j��}tj�|�}|Sr&)rr:r(r)r*�r!r@r"r"r#rA�s
zFileDialog.get_selectioncCs|��dSr&)r6r7r"r"r#r �szFileDialog.cancel_commandcCs�tj�|�sPzt��}Wntk
r0d}YnX|rPtj�||�}tj�|�}|j�dt	�|j�
t	tj�|pttj|pzd��dS)Nrr)r(r)�isabs�getcwdrDr<r;rrJrKrLrM)r!r=r>�pwdr"r"r#r-�s
zFileDialog.set_filtercCs,|j�dt�|j�ttj�|j|��dS)Nr)rrJrKrLr(r)r<rrUr"r"r#r.�szFileDialog.set_selection)N)N)N)N)�__name__�
__module__�__qualname__rr$r(rMr5r6rrrrrrrr0rAr r-r.r"r"r"r#rs 
@


rc@seZdZdZdd�ZdS)�LoadFileDialogzLoad File Selection DialogcCs.|��}tj�|�s |j��n
|�|�dSr&)rAr(r)�isfilerrEr6rUr"r"r#r�szLoadFileDialog.ok_commandN�rYrZr[rrr"r"r"r#r\�sr\c@seZdZdZdd�ZdS)�SaveFileDialogzSave File Selection DialogcCs�|��}tj�|�rZtj�|�r.|j��dSt|jdd|fdddd�}|j	dkr�dSn*tj�
|�\}}tj�|�s�|j��dS|�|�dS)Nz Overwrite Existing File QuestionzOverwrite existing file %r?Z	questheadr)ZYesr)rr
Zbitmapr3Zstringsr)rAr(r)�existsr+rrErrZnumr,r6)r!r@�drQrRr"r"r#r�s&
�

zSaveFileDialog.ok_commandNr^r"r"r"r#r_�sr_c@seZdZdd�Zdd�ZdS)�_DialogcCs2zt|jd�|jd<Wntk
r,YnXdS)N�	filetypes)�tuple�options�KeyErrorrBr"r"r#�_fixoptions,sz_Dialog._fixoptionscCsR|rHz
|j}Wntk
r"YnXtj�|�\}}||jd<||jd<||_|S)N�
initialdirZinitialfile)�string�AttributeErrorr(r)r,re�filename�r!�widget�resultr)r@r"r"r#�
_fixresult3s


z_Dialog._fixresultN)rYrZr[rgror"r"r"r#rb*srbc@seZdZdZdd�ZdS)�OpenZtk_getOpenFilecCsxt|t�rBtdd�|D��}|r>tj�|d�\}}||jd<|S|j��sjd|jkrj|�||j�	|��St
�|||�S)NcSsg|]}t|d|��qS)ri)�getattr)�.0�rr"r"r#�
<listcomp>Nsz#Open._fixresult.<locals>.<listcomp>rrh�multiple)�
isinstancerdr(r)r,reZtkZwantobjectsroZ	splitlistrbrlr"r"r#roKs

zOpen._fixresultN�rYrZr[rror"r"r"r#rpFsrpc@seZdZdZdS)�SaveAsZtk_getSaveFileN)rYrZr[rr"r"r"r#rxZsrxc@seZdZdZdd�ZdS)�	DirectoryZtk_chooseDirectorycCs8|r.z
|j}Wntk
r"YnX||jd<||_|S)Nrh)rirjrer)r!rmrnr"r"r#rofs

zDirectory._fixresultNrwr"r"r"r#ryasrycKstf|���Sr&�rp�show�rer"r"r#�askopenfilenamewsr}cKstf|���Sr&)rxr{r|r"r"r#�asksaveasfilename}sr~cKsd|d<tf|���S)Nrrurzr|r"r"r#�askopenfilenames�srrscKs tf|���}|rt||�SdSr&)rpr{�open��modererkr"r"r#�askopenfile�s
r�cKs4tf|�}|r0g}|D]}|�t||��q|}|Sr&)rrHr�)r�rerZofilesrkr"r"r#�askopenfiles�s
r��wcKs tf|���}|rt||�SdSr&)rxr{r�r�r"r"r#�
asksaveasfile�s
r�cKstf|���Sr&)ryr{r|r"r"r#�askdirectory�sr�c
	Cs�t�}|��t|�}|jdd�}t|�}|jdd�}t||�d}ddl}z&ddl}|�|j	d�|�
|j�}Wntt
fk
r�YnXtdgd�}zt|d�}|��Wn$td	�t|��d
�YnXtd|�|��t�}	td|	�|��dS)
N�test)r4zutf-8rr%)z	all filesr)rcrszCould not open File: rr�Zsaveas)ZTkZwithdrawr\r5r_�print�sys�locale�	setlocale�LC_ALL�nl_langinfo�CODESET�ImportErrorrjr}r��close�exc_info�encoder~)
�root�fdZloadfileZsavefile�encr�r�Zopenfilename�fpZsaveasfilenamer"r"r#r��s2

r��__main__)rs)rs)r�)ZtkinterZtkinter.dialogrrZtkinter.simpledialogrr(rIr'rr\r_rbrprxryr}r~rr�r�r�r�r�rYr"r"r"r#�<module>s0I9
	

	,
PK+�\�#�N��!colorchooser.cpython-38.opt-1.pycnu�[���U

e5dA
�@s>ddlmZGdd�de�Zd	dd�Zedkr:ede��dS)
�)�Dialogc@s$eZdZdZdZdd�Zdd�ZdS)�Choosera�Create a dialog for the tk_chooseColor command.

    Args:
        master: The master widget for this dialog.  If not provided,
            defaults to options['parent'] (if defined).
        options: Dictionary of options for the tk_chooseColor call.
            initialcolor: Specifies the selected color when the
                dialog is first displayed.  This can be a tk color
                string or a 3-tuple of ints in the range (0, 255)
                for an RGB triplet.
            parent: The parent window of the color dialog.  The
                color dialog is displayed on top of this.
            title: A string for the title of the dialog box.
    Ztk_chooseColorcCs@z&|jd}t|t�r$d||jd<Wntk
r:YnXdS)zvEnsure initialcolor is a tk color string.

        Convert initialcolor from a RGB triplet to a color string.
        �initialcolorz
#%02x%02x%02xN)�options�
isinstance�tuple�KeyError)�self�color�r�,/usr/lib64/python3.8/tkinter/colorchooser.py�_fixoptions!s

zChooser._fixoptionscCs>|rt|�sdS|�|�\}}}|d|d|dft|�fS)z�Adjust result returned from call to tk_chooseColor.

        Return both an RGB tuple of ints in the range (0, 255) and the
        tk color string in the form #rrggbb.
        )NN�)�strZ	winfo_rgb)r	Zwidget�result�r�g�brrr�
_fixresult.szChooser._fixresultN)�__name__�
__module__�__qualname__�__doc__Zcommandr
rrrrrrs
rNcKs"|r|��}||d<tf|���S)z�Display dialog window for selection of a color.

    Convenience wrapper for the Chooser class.  Displays the color
    chooser dialog with color as the initial value.
    r)�copyrZshow)r
rrrr�askcolorBsr�__main__r
)N)Ztkinter.commondialogrrrr�printrrrr�<module>s3
PK+�\wbh^��dnd.cpython-38.opt-2.pycnu�[���U

e5d�,�@sTddlZdd�ZGdd�d�ZGdd�d�ZGdd	�d	�Zd
d�ZedkrPe�dS)
�NcCst||�}|jr|SdSdS�N)�
DndHandler�root)�source�event�h�r�#/usr/lib64/python3.8/tkinter/dnd.py�	dnd_startls
r
c@sDeZdZdZdd�Zdd�Zdd�Zdd	�Zdd
d�Zdd
d�Z	dS)rNcCs�|jdkrdS|j��}z|jWdStk
rD||_||_YnX||_d|_|j|_}|j|_	}d||f|_
|dp�d|_|�|j
|j
�|�d|j�d|d<dS)N�z<B%d-ButtonRelease-%d>�cursor��<Motion>Zhand2)Znum�widgetZ_root�_DndHandler__dnd�AttributeErrorrr�targetZinitial_button�initial_widget�release_pattern�save_cursor�bind�
on_release�	on_motion)�selfrrrZbuttonrrrr	�__init__zs$

zDndHandler.__init__cCs2|j}d|_|r.z|`Wntk
r,YnXdSr)rrr�rrrrr	�__del__�szDndHandler.__del__c	Cs�|j|j}}|j�||�}|j}d}|rbz
|j}Wntk
rHYnX|||�}|rZqb|j}q&|j}||kr�|r�|�	||�n,|r�d|_|�
||�|r�|�||�||_dSr)�x_root�y_rootrZwinfo_containingr�
dnd_acceptrZmasterr�
dnd_motion�	dnd_leave�	dnd_enter)	rr�x�yZ
target_widgetr�
new_target�attrZ
old_targetrrr	r�s.

zDndHandler.on_motioncCs|�|d�dS)N���finish�rrrrr	r�szDndHandler.on_releasecCs|�|d�dS)Nrr(r*rrr	�cancel�szDndHandler.cancelrc
Cs�|j}|j}|j}|j}zf|`|j�|j�|j�d�|j|d<d|_|_|_|_|r||rp|�	||�n|�
||�W5|�||�XdS)Nrr)rrrr�dnd_endrZunbindrr�
dnd_commitr!)rrZcommitrrrrrrr	r)�s
zDndHandler.finish)N)r)
�__name__�
__module__�__qualname__rrrrrr+r)rrrr	rvs	
rc@sNeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�IconcCs||_d|_|_|_dSr)�name�canvas�label�id)rr2rrr	r�sz
Icon.__init__�
cCs�||jkr |j�|j||�dS|jr.|��|s6dStj||jddd�}|j|||dd�}||_||_||_|�	d|j
�dS)N�Zraised)�textZborderwidthZreliefZnw)ZwindowZanchorz
<ButtonPress>)r3�coordsr5�detach�tkinterZLabelr2Z
create_windowr4r�press)rr3r#r$r4r5rrr	�attach�s 

�zIcon.attachcCsB|j}|sdS|j}|j}d|_|_|_|�|�|��dSr)r3r5r4�deleteZdestroy)rr3r5r4rrr	r:�s
zIcon.detachcCs4t||�r0|j|_|j|_|j�|j�\|_|_	dSr)
r
r#�x_offr$�y_offr3r9r5�x_orig�y_origr*rrr	r<�s
z
Icon.presscCs(|�|j|�\}}|j�|j||�dSr)�wherer3r9r5)rrr#r$rrr	�move�sz	Icon.movecCs|j�|j|j|j�dSr)r3r9r5rArB)rrrr	�putback�szIcon.putbackcCs8|��}|��}|j|}|j|}||j||jfSr)Zwinfo_rootxZwinfo_rootyrrr?r@)rr3rZx_orgZy_orgr#r$rrr	rC�s


z
Icon.wherecCsdSrr)rrrrrr	r,szIcon.dnd_endN)r6r6)r.r/r0rr=r:r<rDrErCr,rrrr	r1�s


r1c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestercCs>t�|�|_tj|jddd�|_|jjddd�|j|j_dS)N�d)�widthZheightZbothr')Zfill�expand)r;ZToplevel�topZCanvasr3�packrrrrr	rszTester.__init__cCs|Srr�rrrrrr	rszTester.dnd_acceptcCsp|j��|�|j|�\}}|j�|j�\}}}}||||}	}
|j�||||	||
�|_|�||�dSr)r3�	focus_setrC�bboxr5Zcreate_rectangle�dndidr )rrrr#r$�x1�y1�x2�y2ZdxZdyrrr	r"s
zTester.dnd_enterc	CsF|�|j|�\}}|j�|j�\}}}}|j�|j||||�dSr)rCr3rNrOrD)	rrrr#r$rPrQrRrSrrr	r szTester.dnd_motioncCs"|j��|j�|j�d|_dSr)rJrMr3r>rOrLrrr	r!$s
zTester.dnd_leavecCs2|�||�|�|j|�\}}|�|j||�dSr)r!rCr3r=)rrrr#r$rrr	r-)szTester.dnd_commitN)	r.r/r0rrr"r r!r-rrrr	rFsrFcCs�t��}|�d�tj|jdd���t|�}|j�d�t|�}|j�d�t|�}|j�d�td�}td�}td	�}|�	|j
�|�	|j
�|�	|j
�|��dS)
Nz+1+1ZQuit)Zcommandr8z+1+60z+120+60z+240+60ZICON1ZICON2ZICON3)r;ZTkZgeometryZButton�quitrKrFrJr1r=r3Zmainloop)r�t1�t2Zt3Zi1Zi2Zi3rrr	�test/s 
rW�__main__)r;r
rr1rFrWr.rrrr	�<module>gs
Y=#PK+�\D��@�*�*!simpledialog.cpython-38.opt-1.pycnu�[���U

e5d�-�@s�dZddlTddlmZmZGdd�d�ZGdd�de�Zdd	�ZGd
d�de�ZGdd
�d
e�Z	dd�Z
Gdd�de�Zdd�ZGdd�de�Z
dd�Zedkr�dd�Ze�dS)a&This modules handles dialog boxes.

It contains the following public symbols:

SimpleDialog -- A simple but flexible modal dialog box

Dialog -- a base class for dialogs

askinteger -- get an integer from the user

askfloat -- get a float from the user

askstring -- get a string from the user
�)�*)�
messagebox�_get_default_rootc@sLeZdZdgddddfdd�Zddd�Zd	d
�Zdd�Zd
d�Zdd�ZdS)�SimpleDialog�NcCs|rt||d�|_n
t|�|_|r:|j�|�|j�|�t|j�t|j|dd�|_|jjdtd�t	|j�|_
|j
��||_||_||_
|j�d|j�tt|��D]L}||}	t|j
|	||fdd�d	�}
||kr�|
jtd
d�|
jttdd�q�|j�d
|j�|�|�dS)N)�class_i�)�textZaspect�)�expand�fill�<Return>cSs
|�|�S�N)�done��self�num�r�,/usr/lib64/python3.8/tkinter/simpledialog.py�<lambda>8�z'SimpleDialog.__init__.<locals>.<lambda>�r�command�)ZreliefZborderwidth)�siderr
�WM_DELETE_WINDOW)�Toplevel�root�titleZiconname�
_setup_dialogZMessage�message�packZBOTH�Frame�framer�cancel�default�bind�return_event�range�len�ButtonZconfigZRIDGE�LEFT�protocol�wm_delete_window�_set_transient)r�masterr�buttonsr$r#rrr�s�brrr�__init__ s2


�zSimpleDialog.__init__��?�333333�?c
Cs|j}|��|�|�|��|��rJ|��}|��}|��}|��}n|�	�}|�
�}d}}|��}	|��}
|||	|}|||
|}||	|�	�kr�|�	�|	}n|dkr�d}||
|�
�kr�|�
�|
}n|dkr�d}|�
d||f�|��dS)Nr�+%d+%d)r�withdraw�	transient�update_idletasksZwinfo_ismappedZwinfo_widthZwinfo_height�winfo_rootx�winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheight�geometry�	deiconify)
rr.ZrelxZrelyZwidgetZm_widthZm_heightZm_xZm_yZw_widthZw_height�x�yrrrr-?s4

zSimpleDialog._set_transientcCs.|j��|j��|j��|j��|jSr
)r�wait_visibility�grab_set�mainloop�destroyr�rrrr�go\s




zSimpleDialog.gocCs&|jdkr|j��n|�|j�dSr
)r$r�bellr�rZeventrrrr&cs
zSimpleDialog.return_eventcCs&|jdkr|j��n|�|j�dSr
)r#rrErrCrrrr,is
zSimpleDialog.wm_delete_windowcCs||_|j��dSr
)rr�quitrrrrroszSimpleDialog.done)r3r4)	�__name__�
__module__�__qualname__r2r-rDr&r,rrrrrrs�

rc@sVeZdZdZddd�Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	dd�Z
dd�ZdS)�DialogzZClass to open dialogs.

    This class is intended as a base class for custom dialogs
    NcCs�|}|std�}t�||�|��|dk	r>|��r>|�|�|rL|�|�t|�||_d|_	t
|�}|�|�|_|j
ddd�|��|js�||_|�d|j�|dk	r�|�d|��d|��df�|��|j��|��|��|�|�dS)z�Initialize a dialog.

        Arguments:

            parent -- a parent window (the application window)

            title -- the dialog title
        zcreate dialog windowN�)�padx�padyrr5�2)rrr2r6Zwinfo_viewabler7rr�parent�resultr!�body�
initial_focusr �	buttonboxr+r#r;r9r:r<�	focus_setr?r@Zwait_window)rrPrr.rRrrrr2{s8	


�
zDialog.__init__cCsd|_t�|�dS)zDestroy the windowN)rSrrBrCrrrrB�szDialog.destroycCsdS)z�create dialog body.

        return widget that should have initial focus.
        This method should be overridden, and is called
        by the __init__ method.
        Nr)rr.rrrrR�szDialog.bodycCsvt|�}t|dd|jtd�}|jtddd�t|dd|jd�}|jtddd�|�d|j�|�d	|j�|��d
S)z[add standard button box.

        override if you do not want the standard buttons
        ZOK�
)r�widthrr$rL)rrMrN�Cancel)rrWrrz<Escape>N)r!r)�okZACTIVEr r*r#r%)rZbox�wrrrrT�szDialog.buttonboxcCsB|��s|j��dS|��|��z|��W5|��XdSr
)�validaterSrUr6r8r#�applyrFrrrrY�s
z	Dialog.okcCs |jdk	r|j��|��dSr
)rPrUrBrFrrrr#�s

z
Dialog.cancelcCsdS)z�validate the data

        This method is called automatically to validate the data before the
        dialog is destroyed. By default, it always validates OK.
        r	rrCrrrr[�szDialog.validatecCsdS)z�process the data

        This method is called automatically to process the data, *after*
        the dialog is destroyed. By default, it does nothing.
        NrrCrrrr\�szDialog.apply)N)N)N)rHrIrJ�__doc__r2rBrRrTrYr#r[r\rrrrrKts
7	


	rKcCs:|jdkr |j�dd|dd�n|jdkr6|�dd�dS)	NZaquaz!::tk::unsupported::MacWindowStyleZstyleZ
moveableModalrZx11z-typeZdialog)Z_windowingsystemZtkZcallZ
wm_attributes)rZrrrrs

�
rc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�_QueryDialogNcCs*||_||_||_||_t�|||�dSr
)�prompt�minvalue�maxvalue�initialvaluerKr2)rrr_rbr`rarPrrrr2s
z_QueryDialog.__init__cCsd|_t�|�dSr
)�entryrKrBrCrrrrBsz_QueryDialog.destroycCsrt||jtd�}|jddtd�t|dd�|_|jjddttd�|jdk	rl|j�	d|j�|j�
dt�|jS)N)rZjustifyrrL)�rowrMZstickyrc)�namer	)ZLabelr_r*Zgrid�WZEntryrc�Erb�insertZselect_rangeZEND)rr.rZrrrrR s
z_QueryDialog.bodycCs�z|��}Wn,tk
r8tjd|jd|d�YdSX|jdk	rh||jkrhtjdd|j|d�dS|jdk	r�||jkr�tjdd|j|d�dS||_d	S)
Nz
Illegal valuez
Please try again)rPrz	Too smallz2The allowed minimum value is %s. Please try again.z	Too largez2The allowed maximum value is %s. Please try again.r	)�	getresult�
ValueErrorr�showwarning�errormessager`rarQ)rrQrrrr[.s:�����z_QueryDialog.validate)NNNN)rHrIrJr2rBrRr[rrrrr^
s�

r^c@seZdZdZdd�ZdS)�
_QueryIntegerzNot an integer.cCs|�|j���Sr
)Zgetintrc�getrCrrrriSsz_QueryInteger.getresultN�rHrIrJrlrirrrrrmPsrmcKst||f|�}|jS)z�get an integer from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is an integer
    )rmrQ�rr_�kw�drrr�
askintegerWsrsc@seZdZdZdd�ZdS)�_QueryFloatzNot a floating point value.cCs|�|j���Sr
)Z	getdoublercrnrCrrrriisz_QueryFloat.getresultNrorrrrrtfsrtcKst||f|�}|jS)z�get a float from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is a float
    )rtrQrprrr�askfloatmsruc@s$eZdZdd�Zdd�Zdd�ZdS)�_QueryStringcOs6d|kr|d|_|d=nd|_tj|f|�|�dS)N�show)�_QueryString__showr^r2)r�argsrqrrrr2}s

z_QueryString.__init__cCs(t�||�}|jdk	r$|j|jd�|S)N)rw)r^rRrxZ	configure)rr.rcrrrrR�s
z_QueryString.bodycCs
|j��Sr
)rcrnrCrrrri�sz_QueryString.getresultN)rHrIrJr2rRrirrrrrv|srvcKst||f|�}|jS)z�get a string from the user

    Arguments:

        title -- the dialog title
        prompt -- the label text
        **kw -- see SimpleDialog class

    Return value is a string
    )rvrQrprrr�	askstring�srz�__main__cCsLt�}|fdd�}t|d|d�}|��t|d|jd�}|��|��dS)NcSs^t|ddddgdddd�}t|���ttd	d
dd��ttd	d
ddd��ttd	d��dS)Nz�This is a test dialog.  Would this have been an actual dialog, the buttons below would have been glowing in soft pink light.
Do you believe this?ZYesZNorXr�zTest Dialog)rr/r$r#rZSpamz	Egg count�)rbzEgg weight
(in tons)r	�d)r`raz	Egg label)r�printrDrsrurz)rrrrrr�doit�s�

�ztest.<locals>.doitZTestrZQuit)ZTkr)r rGrA)rr��t�qrrr�test�sr�N)r]ZtkinterrrrrrKrr^rmrsrtrurvrzrHr�rrrr�<module>s V
CPK+�\�1&���messagebox.cpython-38.opt-1.pycnu�[���U

e5d}�@sHddlmZdZdZdZdZdZdZdZd	Z	d
Z
dZdZd
Z
dZdZdZdZdZGdd�de�Zd5dd�Zd6dd�Zd7dd�Zd8dd�Zd9dd�Zd:dd �Zd;d!d"�Zd<d#d$�Zd=d%d&�Zed'k�rDeded(d)��eded(d*��eded(d+��eded(d,��ed-ed(d.��ed/ed(d0��ed1ed(d2��ed3ed(d4��dS)>�)�Dialog�error�infoZquestionZwarningZabortretryignore�okZokcancelZretrycancelZyesnoZyesnocancel�abortZretry�ignoreZcancelZyesZnoc@seZdZdZdZdS)�Messagez
A message boxZ
tk_messageBoxN)�__name__�
__module__�__qualname__�__doc__Zcommand�r
r
�*/usr/lib64/python3.8/tkinter/messagebox.pyr9srNcKsl|rd|kr||d<|r(d|kr(||d<|r4||d<|r@||d<tf|���}t|t�rd|r`tStSt|�S)NZicon�type�title�message)rZshow�
isinstance�bool�YES�NO�str)rrZ_iconZ_type�options�resr
r
r�_showCs
rcKst||ttf|�S)zShow an info message)r�INFO�OK�rrrr
r
r�showinfoRsrcKst||ttf|�S)zShow a warning message)r�WARNINGrrr
r
r�showwarningWsrcKst||ttf|�S)zShow an error message)r�ERRORrrr
r
r�	showerror\sr!cKst||ttf|�S)zAsk a question)r�QUESTION�YESNOrr
r
r�askquestionasr$cKst||ttf|�}|tkS)z@Ask if operation should proceed; return true if the answer is ok)rr"�OKCANCELr�rrr�sr
r
r�askokcancelfsr(cKst||ttf|�}|tkS)z0Ask a question; return true if the answer is yes)rr"r#rr&r
r
r�askyesnolsr)cKs.t||ttf|�}t|�}|tkr&dS|tkS)zDAsk a question; return true if the answer is yes, None if cancelled.N)rr"�YESNOCANCELr�CANCELrr&r
r
r�askyesnocancelrs
r,cKst||ttf|�}|tkS)zDAsk if operation should be retried; return true if the answer is yes)rr�RETRYCANCEL�RETRYr&r
r
r�askretrycancel|sr/�__main__ZSpamzEgg InformationzEgg Warningz	Egg Alertz	Question?ZproceedzProceed?zyes/nozGot it?z
yes/no/cancelzWant it?z	try againz
Try again?)NNNN)NN)NN)NN)NN)NN)NN)NN)NN)Ztkinter.commondialogrr rr"rZABORTRETRYIGNORErr%r-r#r*ZABORTr.ZIGNOREr+rrrrrrr!r$r(r)r,r/r	�printr
r
r
r�<module>sH










	
PK+�\�1&���messagebox.cpython-38.pycnu�[���U

e5d}�@sHddlmZdZdZdZdZdZdZdZd	Z	d
Z
dZdZd
Z
dZdZdZdZdZGdd�de�Zd5dd�Zd6dd�Zd7dd�Zd8dd�Zd9dd�Zd:dd �Zd;d!d"�Zd<d#d$�Zd=d%d&�Zed'k�rDeded(d)��eded(d*��eded(d+��eded(d,��ed-ed(d.��ed/ed(d0��ed1ed(d2��ed3ed(d4��dS)>�)�Dialog�error�infoZquestionZwarningZabortretryignore�okZokcancelZretrycancelZyesnoZyesnocancel�abortZretry�ignoreZcancelZyesZnoc@seZdZdZdZdS)�Messagez
A message boxZ
tk_messageBoxN)�__name__�
__module__�__qualname__�__doc__Zcommand�r
r
�*/usr/lib64/python3.8/tkinter/messagebox.pyr9srNcKsl|rd|kr||d<|r(d|kr(||d<|r4||d<|r@||d<tf|���}t|t�rd|r`tStSt|�S)NZicon�type�title�message)rZshow�
isinstance�bool�YES�NO�str)rrZ_iconZ_type�options�resr
r
r�_showCs
rcKst||ttf|�S)zShow an info message)r�INFO�OK�rrrr
r
r�showinfoRsrcKst||ttf|�S)zShow a warning message)r�WARNINGrrr
r
r�showwarningWsrcKst||ttf|�S)zShow an error message)r�ERRORrrr
r
r�	showerror\sr!cKst||ttf|�S)zAsk a question)r�QUESTION�YESNOrr
r
r�askquestionasr$cKst||ttf|�}|tkS)z@Ask if operation should proceed; return true if the answer is ok)rr"�OKCANCELr�rrr�sr
r
r�askokcancelfsr(cKst||ttf|�}|tkS)z0Ask a question; return true if the answer is yes)rr"r#rr&r
r
r�askyesnolsr)cKs.t||ttf|�}t|�}|tkr&dS|tkS)zDAsk a question; return true if the answer is yes, None if cancelled.N)rr"�YESNOCANCELr�CANCELrr&r
r
r�askyesnocancelrs
r,cKst||ttf|�}|tkS)zDAsk if operation should be retried; return true if the answer is yes)rr�RETRYCANCEL�RETRYr&r
r
r�askretrycancel|sr/�__main__ZSpamzEgg InformationzEgg Warningz	Egg Alertz	Question?ZproceedzProceed?zyes/nozGot it?z
yes/no/cancelzWant it?z	try againz
Try again?)NNNN)NN)NN)NN)NN)NN)NN)NN)NN)Ztkinter.commondialogrr rr"rZABORTRETRYIGNORErr%r-r#r*ZABORTr.ZIGNOREr+rrrrrrr!r$r(r)r,r/r	�printr
r
r
r�<module>sH










	
PK+�\z��YVV!scrolledtext.cpython-38.opt-2.pycnu�[���U

e5d�@shdgZddlmZmZmZmZmZmZddlm	Z	m
Z
mZmZGdd�de�Z
dd�Zedkrde�dS)	�ScrolledText�)�Frame�Text�	Scrollbar�Pack�Grid�Place)�RIGHT�LEFT�Y�BOTHc@seZdZddd�Zdd�ZdS)rNcKs�t|�|_t|j�|_|jjttd�|�d|jji�t	j
||jf|�|jttdd�|j
|jd<tt	���}tt���tt���Btt���B}|�|�}|D]4}|ddkr�|dkr�|d	kr�t||t|j|��q�dS)
N)�side�fillZyscrollcommandT)r
r�expandZcommandr�_ZconfigZ	configure)r�framerZvbar�packr	r�update�setr�__init__r
rZyview�vars�keysrrr�
difference�setattr�getattr)�selfZmaster�kwZ
text_meths�methods�m�r�,/usr/lib64/python3.8/tkinter/scrolledtext.pyrs
$
zScrolledText.__init__cCs
t|j�S)N)�strr)rrrr �__str__)szScrolledText.__str__)N)�__name__�
__module__�__qualname__rr"rrrr rs
cCsHddlm}tddd�}|�|t�|jttdd�|��|�	�dS)Nr)�ENDZwhite�
)ZbgZheightT)rr
r)
�tkinter.constantsr&r�insert�__doc__rrr
Z	focus_setZmainloop)r&Zstextrrr �example-sr+�__main__N)�__all__Ztkinterrrrrrrr(r	r
rrrr+r#rrrr �<module>s 
PK+�\��z`,,dnd.cpython-38.pycnu�[���U

e5d�,�@sXdZddlZdd�ZGdd�d�ZGdd�d�ZGd	d
�d
�Zdd�Zed
krTe�dS)aFDrag-and-drop support for Tkinter.

This is very preliminary.  I currently only support dnd *within* one
application, between different windows (or within the same window).

I am trying to make this as generic as possible -- not dependent on
the use of a particular widget or icon type, etc.  I also hope that
this will work with Pmw.

To enable an object to be dragged, you must create an event binding
for it that starts the drag-and-drop process. Typically, you should
bind <ButtonPress> to a callback function that you write. The function
should call Tkdnd.dnd_start(source, event), where 'source' is the
object to be dragged, and 'event' is the event that invoked the call
(the argument to your callback function).  Even though this is a class
instantiation, the returned instance should not be stored -- it will
be kept alive automatically for the duration of the drag-and-drop.

When a drag-and-drop is already in process for the Tk interpreter, the
call is *ignored*; this normally averts starting multiple simultaneous
dnd processes, e.g. because different button callbacks all
dnd_start().

The object is *not* necessarily a widget -- it can be any
application-specific object that is meaningful to potential
drag-and-drop targets.

Potential drag-and-drop targets are discovered as follows.  Whenever
the mouse moves, and at the start and end of a drag-and-drop move, the
Tk widget directly under the mouse is inspected.  This is the target
widget (not to be confused with the target object, yet to be
determined).  If there is no target widget, there is no dnd target
object.  If there is a target widget, and it has an attribute
dnd_accept, this should be a function (or any callable object).  The
function is called as dnd_accept(source, event), where 'source' is the
object being dragged (the object passed to dnd_start() above), and
'event' is the most recent event object (generally a <Motion> event;
it can also be <ButtonPress> or <ButtonRelease>).  If the dnd_accept()
function returns something other than None, this is the new dnd target
object.  If dnd_accept() returns None, or if the target widget has no
dnd_accept attribute, the target widget's parent is considered as the
target widget, and the search for a target object is repeated from
there.  If necessary, the search is repeated all the way up to the
root widget.  If none of the target widgets can produce a target
object, there is no target object (the target object is None).

The target object thus produced, if any, is called the new target
object.  It is compared with the old target object (or None, if there
was no old target widget).  There are several cases ('source' is the
source object, and 'event' is the most recent event object):

- Both the old and new target objects are None.  Nothing happens.

- The old and new target objects are the same object.  Its method
dnd_motion(source, event) is called.

- The old target object was None, and the new target object is not
None.  The new target object's method dnd_enter(source, event) is
called.

- The new target object is None, and the old target object is not
None.  The old target object's method dnd_leave(source, event) is
called.

- The old and new target objects differ and neither is None.  The old
target object's method dnd_leave(source, event), and then the new
target object's method dnd_enter(source, event) is called.

Once this is done, the new target object replaces the old one, and the
Tk mainloop proceeds.  The return value of the methods mentioned above
is ignored; if they raise an exception, the normal exception handling
mechanisms take over.

The drag-and-drop processes can end in two ways: a final target object
is selected, or no final target object is selected.  When a final
target object is selected, it will always have been notified of the
potential drop by a call to its dnd_enter() method, as described
above, and possibly one or more calls to its dnd_motion() method; its
dnd_leave() method has not been called since the last call to
dnd_enter().  The target is notified of the drop by a call to its
method dnd_commit(source, event).

If no final target object is selected, and there was an old target
object, its dnd_leave(source, event) method is called to complete the
dnd sequence.

Finally, the source object is notified that the drag-and-drop process
is over, by a call to source.dnd_end(target, event), specifying either
the selected target object, or None if no target object was selected.
The source object can use this to implement the commit action; this is
sometimes simpler than to do it in the target's dnd_commit().  The
target's dnd_commit() method could then simply be aliased to
dnd_leave().

At any time during a dnd sequence, the application can cancel the
sequence by calling the cancel() method on the object returned by
dnd_start().  This will call dnd_leave() if a target is currently
active; it will never call dnd_commit().

�NcCst||�}|jr|SdSdS�N)�
DndHandler�root)�source�event�h�r�#/usr/lib64/python3.8/tkinter/dnd.py�	dnd_startls
r
c@sDeZdZdZdd�Zdd�Zdd�Zdd	�Zdd
d�Zdd
d�Z	dS)rNcCs�|jdkrdS|j��}z|jWdStk
rD||_||_YnX||_d|_|j|_}|j|_	}d||f|_
|dp�d|_|�|j
|j
�|�d|j�d|d<dS)N�z<B%d-ButtonRelease-%d>�cursor��<Motion>Zhand2)Znum�widgetZ_root�_DndHandler__dnd�AttributeErrorrr�targetZinitial_button�initial_widget�release_pattern�save_cursor�bind�
on_release�	on_motion)�selfrrrZbuttonrrrr	�__init__zs$

zDndHandler.__init__cCs2|j}d|_|r.z|`Wntk
r,YnXdSr)rrr�rrrrr	�__del__�szDndHandler.__del__c	Cs�|j|j}}|j�||�}|j}d}|rbz
|j}Wntk
rHYnX|||�}|rZqb|j}q&|j}||kr�|r�|�	||�n,|r�d|_|�
||�|r�|�||�||_dSr)�x_root�y_rootrZwinfo_containingr�
dnd_acceptrZmasterr�
dnd_motion�	dnd_leave�	dnd_enter)	rr�x�yZ
target_widgetr�
new_target�attrZ
old_targetrrr	r�s.

zDndHandler.on_motioncCs|�|d�dS)N���finish�rrrrr	r�szDndHandler.on_releasecCs|�|d�dS)Nrr(r*rrr	�cancel�szDndHandler.cancelrc
Cs�|j}|j}|j}|j}zf|`|j�|j�|j�d�|j|d<d|_|_|_|_|r||rp|�	||�n|�
||�W5|�||�XdS)Nrr)rrrr�dnd_endrZunbindrr�
dnd_commitr!)rrZcommitrrrrrrr	r)�s
zDndHandler.finish)N)r)
�__name__�
__module__�__qualname__rrrrrr+r)rrrr	rvs	
rc@sNeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�IconcCs||_d|_|_|_dSr)�name�canvas�label�id)rr2rrr	r�sz
Icon.__init__�
cCs�||jkr |j�|j||�dS|jr.|��|s6dStj||jddd�}|j|||dd�}||_||_||_|�	d|j
�dS)N�Zraised)�textZborderwidthZreliefZnw)ZwindowZanchorz
<ButtonPress>)r3�coordsr5�detach�tkinterZLabelr2Z
create_windowr4r�press)rr3r#r$r4r5rrr	�attach�s 

�zIcon.attachcCsB|j}|sdS|j}|j}d|_|_|_|�|�|��dSr)r3r5r4�deleteZdestroy)rr3r5r4rrr	r:�s
zIcon.detachcCs4t||�r0|j|_|j|_|j�|j�\|_|_	dSr)
r
r#�x_offr$�y_offr3r9r5�x_orig�y_origr*rrr	r<�s
z
Icon.presscCs(|�|j|�\}}|j�|j||�dSr)�wherer3r9r5)rrr#r$rrr	�move�sz	Icon.movecCs|j�|j|j|j�dSr)r3r9r5rArB)rrrr	�putback�szIcon.putbackcCs8|��}|��}|j|}|j|}||j||jfSr)Zwinfo_rootxZwinfo_rootyrrr?r@)rr3rZx_orgZy_orgr#r$rrr	rC�s


z
Icon.wherecCsdSrr)rrrrrr	r,szIcon.dnd_endN)r6r6)r.r/r0rr=r:r<rDrErCr,rrrr	r1�s


r1c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestercCs>t�|�|_tj|jddd�|_|jjddd�|j|j_dS)N�d)�widthZheightZbothr')Zfill�expand)r;ZToplevel�topZCanvasr3�packrrrrr	rszTester.__init__cCs|Srr�rrrrrr	rszTester.dnd_acceptcCsp|j��|�|j|�\}}|j�|j�\}}}}||||}	}
|j�||||	||
�|_|�||�dSr)r3�	focus_setrC�bboxr5Zcreate_rectangle�dndidr )rrrr#r$�x1�y1�x2�y2ZdxZdyrrr	r"s
zTester.dnd_enterc	CsF|�|j|�\}}|j�|j�\}}}}|j�|j||||�dSr)rCr3rNrOrD)	rrrr#r$rPrQrRrSrrr	r szTester.dnd_motioncCs"|j��|j�|j�d|_dSr)rJrMr3r>rOrLrrr	r!$s
zTester.dnd_leavecCs2|�||�|�|j|�\}}|�|j||�dSr)r!rCr3r=)rrrr#r$rrr	r-)szTester.dnd_commitN)	r.r/r0rrr"r r!r-rrrr	rFsrFcCs�t��}|�d�tj|jdd���t|�}|j�d�t|�}|j�d�t|�}|j�d�td�}td�}td	�}|�	|j
�|�	|j
�|�	|j
�|��dS)
Nz+1+1ZQuit)Zcommandr8z+1+60z+120+60z+240+60ZICON1ZICON2ZICON3)r;ZTkZgeometryZButton�quitrKrFrJr1r=r3Zmainloop)r�t1�t2Zt3Zi1Zi2Zi3rrr	�test/s 
rW�__main__)�__doc__r;r
rr1rFrWr.rrrr	�<module>sf
Y=#PK+�\ ���I�I�tix.cpython-38.opt-2.pycnu�[���U

e5d-,�@sLddlZddlZddlTddlmZddlZdZdZdZdZdZd	Z	d
Z
dZdZd
Z
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZGdd �d �Z Gd!d"�d"ej!e �Z!Gd#d$�d$�Z"ej#j$e"fej#_$Gd%d&�d&ej#�Z%Gd'd(�d(e%�Z&Gd)d*�d*�Z'Gd+d,�d,e%�Z(Gd-d.�d.e%�Z)Gd/d0�d0e%�Z*Gd1d2�d2e%�Z+Gd3d4�d4e%�Z,Gd5d6�d6e%�Z-Gd7d8�d8e%�Z.Gd9d:�d:e%�Z/Gd;d<�d<e%�Z0Gd=d>�d>e%�Z1Gd?d@�d@e%�Z2GdAdB�dBe%�Z3GdCdD�dDe%�Z4GdEdF�dFe%e5e6�Z7GdGdH�dHe%�Z8GdIdJ�dJe%�Z9GdKdL�dLe%�Z:GdMdN�dNe%�Z;GdOdP�dPe%�Z<GdQdR�dRe%�Z=GdSdT�dTe%�Z>GdUdV�dVe%�Z?GdWdX�dXe%�Z@GdYdZ�dZe%�ZAGd[d\�d\e%�ZBGd]d^�d^e%�ZCGd_d`�d`e%�ZDGdadb�dbe%�ZEGdcdd�dde%�ZFGdedf�dfe%�ZGGdgdh�dhe%�ZHGdidj�dje%�ZIGdkdl�dle%�ZJGdmdn�dne%�ZKGdodp�dpe%e5e6�ZLGdqdr�dre%�ZMGdsdt�dte%�ZNGdudv�dveOe&�ZPGdwdx�dxeQe&�ZRGdydz�dzeSe&�ZTGd{d|�d|eUe&�ZVGd}d~�d~eWe&�ZXGdd��d�eYe&�ZZGd�d��d�e[e&�Z\Gd�d��d�e]e&�Z^Gd�d��d�e_e&�Z`Gd�d��d�eae&�ZbGd�d��d�eDe&�ZcGd�d��d�e7e&�ZdGd�d��d�eCe&�ZeGd�d��d�eLe&�ZfGd�d��d�e*e&�ZgGd�d��d�e,e&�ZhGd�d��d�e.e&�ZiGd�d��d�e/e&�ZjGd�d��d�e2e&�ZkGd�d��d�e*e&�ZlGd�d��d�eKe&�ZmGd�d��d�e>e&�ZnGd�d��d�e@e&�Zod�d��Zpd�d��ZqGd�d��d�e%�ZrGd�d��d�e%e5e6�ZsGd�d��d�es�ZtdS)��N)�*)�	_cnfmerge�window�textZstatusZ	immediate�imageZ	imagetextZballoon�autoZ	acrosstop�asciiZcell�columnZ
decreasingZ
increasingZinteger�main�max�real�rowzs-regionzx-regionzy-region����� c@sReZdZdd�Zdd�Zddd�Zddd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
dS)�
tixCommandcCs|j�dd|�S)N�tixZaddbitmapdir��tk�call)�selfZ	directory�r�#/usr/lib64/python3.8/tkinter/tix.py�tix_addbitmapdirRs
ztixCommand.tix_addbitmapdircCs|j�dd|�S)Nr�cgetr�r�optionrrr�tix_cget^sztixCommand.tix_cgetNcKsd|rt||f�}n|rt|�}|dkr2|�dd�St|t�rN|�ddd|�S|j�d|�|��S)Nr�	configure�-)rr )r�
_getconfigure�
isinstance�strZ_getconfigure1rr�_options�r�cnf�kwrrr�
tix_configurees
ztixCommand.tix_configurecCs*|dk	r|j�dd|�S|j�dd�SdS)NrZ
filedialogr)rZdlgclassrrr�tix_filedialog{s	ztixCommand.tix_filedialogcCs|j�dd|�S)NrZ	getbitmapr�r�namerrr�
tix_getbitmap�s	ztixCommand.tix_getbitmapcCs|j�dd|�S)NrZgetimagerr+rrr�tix_getimage�sztixCommand.tix_getimagecCs|j�ddd|�S)Nrr�getrr+rrr�tix_option_get�sztixCommand.tix_option_getcCs2|dk	r|j�dd|||�S|j�dd||�SdS)NrZresetoptionsr)rZ	newSchemeZ
newFontSetZ
newScmPriorrr�tix_resetoptions�sztixCommand.tix_resetoptions)N)N)N)�__name__�
__module__�__qualname__rrr)r*r-r.r0r1rrrrrGs

rc@seZdZddd�Zdd�ZdS)�TkN�TixcCsbtj�||||�tj�d�}|j�d�|dk	rR|j�d|�|j�d|�|j�d�dS)NZTIX_LIBRARYz<global auto_path; lappend auto_path [file dir [info nameof]]z(global auto_path; lappend auto_path {%s}z,global tcl_pkgPath; lappend tcl_pkgPath {%s}zpackage require Tix)�tkinterr5�__init__�os�environr/r�eval)rZ
screenNameZbaseNameZ	classNameZtixlibrrrr8�szTk.__init__cCs|�dd�tj�|�dS)NZWM_DELETE_WINDOW�)Zprotocolr7r5�destroy�rrrrr=�sz
Tk.destroy)NNr6�r2r3r4r8r=rrrrr5�s
r5c@sPeZdZifdd�ZeZdd�Zdd�Zdd�Zdd
d�Zdd
d�Z	dd�Z
dS)�FormcKs"|jjd|jf|�||���dS)N�tixForm�rr�_wr%r&rrr�config�szForm.configcCst�|||i�dS�N)r@�form�r�key�valuerrr�__setitem__�szForm.__setitem__cCs|j�dd|j�S)NrA�check�rrrCr>rrrrK�sz
Form.checkcCs|j�dd|j�dS)NrA�forgetrLr>rrrrM�szForm.forgetrcCs`|sJ|sJ|j�dd|j�}|j�|�}d}|D]}||j�|�f}q.|S|j�dd|j||�S)NrA�gridr)rrrC�	splitlistZgetint)rZxsizeZysize�x�y�zrrrrN�sz	Form.gridNcCs>|s|j�dd|j�S|ddkr*d|}|j�dd|j|�S)NrA�inforr!rLrrrrrS�s
z	Form.infocs(�fdd��j��j�dd�j��D�S)Ncsg|]}��|��qSr)�
_nametowidget��.0rPr>rr�
<listcomp>szForm.slaves.<locals>.<listcomp>rA�slaves�rrOrrCr>rr>rrXs
���zForm.slaves)rr)N)r2r3r4rDrFrJrKrMrNrSrXrrrrr@�s


r@c@sneZdZdddiifdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
idfdd�Zdd�ZdS)�	TixWidgetNc	Cs�|rt||f�}nt|�}d}|r.|�d�ndg}t|���D]&\}}||kr@|d||f}||=q@||_t�|||�|r�|jj||j	f|��|r�t�
||�i|_dS)Nr�optionsr!)r�append�list�items�
widgetName�Widget�_setuprrrCrD�subwidget_list)	r�masterr_Zstatic_optionsr'r(Zextra�k�vrrrr8s$zTixWidget.__init__cCs ||jkr|j|St|��dSrE)rb�AttributeErrorr+rrr�__getattr__Gs

zTixWidget.__getattr__cCs|j�d|j|�dS)NZtixSetSilentrL)rrIrrr�
set_silentLszTixWidget.set_silentcCsD|�|�}|s$td|d|j��|t|j�dd�}|�|�S)Nz
Subwidget z not child of �)�_subwidget_name�TclError�_name�lenrCrT)rr,�nrrr�	subwidgetPs

zTixWidget.subwidgetcCsZ|��}|sgSg}|D]<}|t|j�dd�}z|�|�|��WqYqXq|S)Nri)�_subwidget_namesrmrCr\rT)r�namesZretlistr,rrr�subwidgets_allZszTixWidget.subwidgets_allcCs0z|j�|jd|�WStk
r*YdSXdS)Nro)rrrCrkr+rrrrjiszTixWidget._subwidget_namecCs<z |j�|jdd�}|j�|�WStk
r6YdSXdS)NZ
subwidgetsz-all)rrrCrOrk)rrPrrrrpps
zTixWidget._subwidget_namescCs\|dkrdSt|t�st|�}t|t�s0t|�}|��}|D]}|j�|dd||�q<dS)Nr<r r!)r#r$�reprrprr)rrrIrqr,rrr�
config_allxs

zTixWidget.config_allcKst|s|}|r|rt||f�}n|r&|}d}|��D]*\}}t|�rL|�|�}|d||f}q2|j�dd|f|�S)Nrr!r�create)rr^�callable�	_registerrr)rZimgtyper'rcr(r[rdrerrr�image_create�s
zTixWidget.image_createcCs.z|j�dd|�Wntk
r(YnXdS)Nr�delete)rrrk)rZimgnamerrr�image_delete�szTixWidget.image_delete)
r2r3r4r8rgrhrorrrjrprtrxrzrrrrrZ
s
�
-
rZc@seZdZddd�Zdd�ZdS)�TixSubWidgetric
Cs�|rD|�|�}z$|t|j�dd�}|�d�}Wng}YnX|s`t�||ddd|i�n�|}tt|�d�D]V}d�|d|d��}	z|�|	�}
|
}Wqtt	k
r�t
|||ddd�}YqtXqt|r�|d}t�||ddd|i�||_dS)Nri�.r,r)�destroy_physically�check_intermediate���)rjrmrC�splitrZr8�range�joinrT�KeyErrorr{r})rrcr,r}r~�pathZplist�parent�irn�wrrrr8�s0



�zTixSubWidget.__init__cCsjt|j���D]}|��q|j|jjkr6|jj|j=|j|jjkrP|jj|j=|jrf|j�	d|j
�dS)Nr=)r]�children�valuesr=rlrcrbr}rrrC�r�crrrr=�s
zTixSubWidget.destroyN)ririr?rrrrr{�s�
 r{c@sReZdZifdd�dd�Zdd�Zdd�Zd	d
�Zdd�Zifd
d�Zdd�Z	dS)�DisplayStyleN)rccKs\|s2d|kr|d}nd|kr(|d}n
t�d�}|j|_|jjd|f|�||���|_dS)NZ	refwindowzcreate display styleZtixDisplayStyle)r7Z_get_default_rootrrr%�	stylename)r�itemtyper'rcr(rrrr8�s



�zDisplayStyle.__init__cCs|jSrE)r�r>rrr�__str__�szDisplayStyle.__str__cCsH|r|rt||f�}n|r|}d}|��D]\}}|d||f}q*|S)Nrr!)rr^)rr'r(Zoptsrdrerrrr%�szDisplayStyle._optionscCs|j�|jd�dS�Nry�rrr�r>rrrry�szDisplayStyle.deletecCs|j�|jdd||�dS)Nr �-%sr�rGrrrrJ�szDisplayStyle.__setitem__cKs|j|jdf|�||���S)Nr )r"r�r%r&rrrrD�s�
�zDisplayStyle.configcCs|j�|jdd|�S)Nrr�r�)rrHrrr�__getitem__�szDisplayStyle.__getitem__)
r2r3r4r8r�r%ryrJrDr�rrrrr��s
r�c@s.eZdZdifdd�Zifdd�Zdd�ZdS)�BalloonNcKsNdddddg}t�||d|||�t|ddd	�|jd<t|d
dd	�|jd
<dS)Nr[ZinstallcolormapZinitwaitZ	statusbarZcursorZ
tixBalloon�labelr�r}�message�rZr8�_dummyLabelrb�rrcr'r(Zstaticrrrr8	s���zBalloon.__init__cKs&|jj|jd|jf|�||���dS�NZbindrB)r�widgetr'r(rrr�bind_widgetszBalloon.bind_widgetcCs|j�|jd|j�dS�NZunbindrL�rr�rrr�
unbind_widgetszBalloon.unbind_widget)r2r3r4r8r�r�rrrrr�s	
r�c@s.eZdZdifdd�Zifdd�Zdd�ZdS)�	ButtonBoxNcKst�||dddg||�dS)NZtixButtonBox�orientationr[�rZr8�rrcr'r(rrrr8s

�zButtonBox.__init__cKs4|jj|jd|f|�||���}t||�|j|<|S�N�add�rrrCr%�_dummyButtonrb)rr,r'r(Zbtnrrrr�#s z
ButtonBox.addcCs ||jkr|j�|jd|�dS�N�invoke�rbrrrCr+rrrr�*s
zButtonBox.invoke�r2r3r4r8r�r�rrrrr�sr�c@s:eZdZdifdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�ComboBoxNc	Ks�t�||dddddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d	�|jd	<z$t|d
�|jd
<t|d�|jd<Wntk
r�YnXdS)NZtixComboBoxZeditableZdropdown�fancyr[r��entry�arrow�slistbox�tick�cross)rZr8r�rb�_dummyEntryr��_dummyScrolledListBox�	TypeErrorr�rrrr8<s 

��
zComboBox.__init__cCs|j�|jd|�dS)NZ
addhistoryrL�rr$rrr�add_historyNszComboBox.add_historycCs|j�|jd|�dS)NZ
appendhistoryrLr�rrr�append_historyQszComboBox.append_historycCs|j�|jd||�dS�N�insertrL)r�indexr$rrrr�TszComboBox.insertcCs|j�|jd|�dS)N�pickrL�rr�rrrr�Wsz
ComboBox.pick)r2r3r4r8r�r�r�r�rrrrr�.s
r�c@s:eZdZdifdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�ControlNcKsZt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixControlr[�incr�decrr�r�)rZr8r�rbr�r�r�rrrr8hs
zControl.__init__cCs|j�|jd�dS)Nr�rLr>rrr�	decrementoszControl.decrementcCs|j�|jd�dS)Nr�rLr>rrr�	incrementrszControl.incrementcCs|j�|jd�dSr�rLr>rrrr�uszControl.invokecCs|j�|jd�dS)N�updaterLr>rrrr�xszControl.update)r2r3r4r8r�r�r�r�rrrrr�Zs
r�c@s eZdZifdd�Zdd�ZdS)�DirListcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixDirListr[�hlist�vsb�hsb�rZr8�_dummyHListrb�_dummyScrollbarr�rrrr8�szDirList.__init__cCs|j�|jd|�dS�N�chdirrL�r�dirrrrr��sz
DirList.chdirN�r2r3r4r8r�rrrrr�{sr�c@s eZdZifdd�Zdd�ZdS)�DirTreecKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZ
tixDirTreer[r�r�r�r�r�rrrr8�szDirTree.__init__cCs|j�|jd|�dSr�rLr�rrrr��sz
DirTree.chdirNr�rrrrr��s
r�c@seZdZifdd�ZdS)�DirSelectBoxcKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixDirSelectBoxr[�dirlist�dircbx)rZr8�
_dummyDirListrb�_dummyFileComboBoxr�rrrr8�szDirSelectBox.__init__N�r2r3r4r8rrrrr��sr�c@s(eZdZifdd�Zdd�Zdd�ZdS)�ExFileSelectBoxcKs�t�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d	�|jd	<t|d
�|jd
<dS)NZtixExFileSelectBoxr[�cancel�ok�hidden�typesr�r��file�filelist)rZr8r�rb�_dummyCheckbutton�_dummyComboBoxr�r�r�rrrr8�szExFileSelectBox.__init__cCs|j�|jd�dS�N�filterrLr>rrrr��szExFileSelectBox.filtercCs|j�|jd�dSr�rLr>rrrr��szExFileSelectBox.invokeN)r2r3r4r8r�r�rrrrr��sr�c@s(eZdZifdd�Zdd�Zdd�ZdS)�DirSelectDialogcKs*t�||ddg||�t|d�|jd<dS)NZtixDirSelectDialogr[Zdirbox)rZr8�_dummyDirSelectBoxrbr�rrrr8�s
�zDirSelectDialog.__init__cCs|j�|jd�dS�N�popuprLr>rrrr��szDirSelectDialog.popupcCs|j�|jd�dS�N�popdownrLr>rrrr��szDirSelectDialog.popdownN�r2r3r4r8r�r�rrrrr��s
r�c@s(eZdZifdd�Zdd�Zdd�ZdS)�ExFileSelectDialogcKs*t�||ddg||�t|d�|jd<dS)NZtixExFileSelectDialogr[�fsbox)rZr8�_dummyExFileSelectBoxrbr�rrrr8�s
�zExFileSelectDialog.__init__cCs|j�|jd�dSr�rLr>rrrr�szExFileSelectDialog.popupcCs|j�|jd�dSr�rLr>rrrr�szExFileSelectDialog.popdownNr�rrrrr��s	r�c@s(eZdZifdd�Zdd�Zdd�ZdS)�
FileSelectBoxcKsZt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixFileSelectBoxr[r�r�r��	selection)rZr8r�rbr�r�rrrr8s
zFileSelectBox.__init__cCs|j�|jd�dSr�rLr>rrr�apply_filterszFileSelectBox.apply_filtercCs|j�|jd�dSr�rLr>rrrr�szFileSelectBox.invokeN)r2r3r4r8r�r�rrrrr�sr�c@s(eZdZifdd�Zdd�Zdd�ZdS)�FileSelectDialogcKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixFileSelectDialogr[Zbtnsr�)rZr8�_dummyStdButtonBoxrb�_dummyFileSelectBoxr�rrrr8,s
�zFileSelectDialog.__init__cCs|j�|jd�dSr�rLr>rrrr�2szFileSelectDialog.popupcCs|j�|jd�dSr�rLr>rrrr�5szFileSelectDialog.popdownNr�rrrrr�#s	r�c@s(eZdZifdd�Zdd�Zdd�ZdS)�	FileEntrycKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZtixFileEntryZ
dialogtyper[Zbuttonr�)rZr8r�rbr�r�rrrr8Ds
�zFileEntry.__init__cCs|j�|jd�dSr�rLr>rrrr�JszFileEntry.invokecCsdSrErr>rrr�file_dialogMszFileEntry.file_dialogN)r2r3r4r8r�r�rrrrr�8sr�c@s�eZdZdifdd�Zifdd�Zdifdd�Zdd	�Zd
d�Zdkd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zifdd �Zifd!d"�Zd#d$�Zd%d&�ZeZd'd(�Zd)d*�Zd+d,�Zifd-d.�Zifd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z dld=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+ifdSdT�Z,ifdUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0ifd]d^�Z1d_d`�Z2dadb�Z3ifdcdd�Z4dedf�Z5dmdgdh�Z6didj�Z7dS)n�HListNcKst�||dddg||�dS)NZtixHList�columnsr[r�r�rrrr8Ys

�zHList.__init__cKs |jj|jd|f|�||���Sr�rB�rr�r'r(rrrr�]sz	HList.addcKs(|sd}|jj|jd|f|�||���S)Nr<ZaddchildrB)rr�r'r(rrr�	add_child`s�
�zHList.add_childcCs|j�|jdd|�dS�N�anchor�setrL�rr�rrr�
anchor_setfszHList.anchor_setcCs|j�|jdd�dS�Nr��clearrLr>rrr�anchor_cleariszHList.anchor_clearrcCs6|s|j�|jdd||�S|j�|jdd|d|�SdS)Nr	�widthz-charrL)r�colr�charsrrr�column_widthls�zHList.column_widthcCs|j�|jdd�dS)Nry�allrLr>rrr�
delete_allsszHList.delete_allcCs|j�|jdd|�dS)Nryr�rLr�rrr�delete_entryvszHList.delete_entrycCs|j�|jdd|�dS)NryZ
offspringsrLr�rrr�delete_offspringsyszHList.delete_offspringscCs|j�|jdd|�dS)NryZsiblingsrLr�rrr�delete_siblings|szHList.delete_siblingscCs|j�|jdd|�dS�N�dragsiter�rLr�rrr�dragsite_setszHList.dragsite_setcCs|j�|jdd�dS�Nrr�rLr>rrr�dragsite_clear�szHList.dragsite_clearcCs|j�|jdd|�dS�N�dropsiter�rLr�rrr�dropsite_set�szHList.dropsite_setcCs|j�|jdd�dS�Nrr�rLr>rrr�dropsite_clear�szHList.dropsite_clearcKs&|jj|jdd|f|�||���dS)N�headerrurB�rrr'r(rrr�
header_create�szHList.header_createcKs@|dkr|�|jdd|�S|jj|jdd|f|�||���dS)Nrr �r"rCrrr%rrrr�header_configure�s

�zHList.header_configurecCs|j�|jdd||�S)NrrrL)rr�optrrr�header_cget�szHList.header_cgetcCs|j�|j�|jdd|��S)NrZexist)rZ
getbooleanrrC�rrrrr�
header_exists�szHList.header_existscCs|j�|jdd|�dS)NrryrLrrrr�
header_delete�szHList.header_deletecCs|j�|jdd|�S)Nr�sizerLrrrr�header_size�szHList.header_sizecCs|j�|jdd|�dS)N�hider�rLr�rrr�
hide_entry�szHList.hide_entrycKs&|jj|jdd|f|�||���dS)N�	indicatorrurBr�rrr�indicator_create�s�
�zHList.indicator_createcKs@|dkr|�|jdd|�S|jj|jdd|f|�||���dS)Nr"r rr�rrr�indicator_configure�s��
�zHList.indicator_configurecCs|j�|jdd||�S)Nr"rrL�rr�rrrr�indicator_cget�szHList.indicator_cgetcCs|j�|jdd|�S)Nr"�existsrLr�rrr�indicator_exists�szHList.indicator_existscCs|j�|jdd|�dS)Nr"ryrLr�rrr�indicator_delete�szHList.indicator_deletecCs|j�|jdd|�S)Nr"rrLr�rrr�indicator_size�szHList.indicator_sizecCs|j�|jdd�S�NrSr�rLr>rrr�info_anchor�szHList.info_anchorcCs|�|j�|jdd|��pdS�NrSZbbox)�_getintsrrrCr�rrr�	info_bbox�s
��zHList.info_bboxcCs |j�|jdd|�}|j�|�S)NrSr��rrrCrO)rr�r�rrr�
info_children�szHList.info_childrencCs|j�|jdd|�S)NrS�datarLr�rrr�	info_data�szHList.info_datacCs|j�|jdd�S)NrSrrLr>rrr�
info_dragsite�szHList.info_dragsitecCs|j�|jdd�S)NrSrrLr>rrr�
info_dropsite�szHList.info_dropsitecCs|j�|jdd|�S�NrSr'rLr�rrr�info_exists�szHList.info_existscCs|j�|jdd|�S)NrSr�rLr�rrr�info_hidden�szHList.info_hiddencCs|j�|jdd|�S)NrS�nextrLr�rrr�	info_next�szHList.info_nextcCs|j�|jdd|�S)NrSr�rLr�rrr�info_parent�szHList.info_parentcCs|j�|jdd|�S)NrS�prevrLr�rrr�	info_prev�szHList.info_prevcCs|j�|jdd�}|j�|�S�NrSr�r0r�rrr�info_selection�szHList.info_selectioncCs|j�|jdd|||�S)N�itemrrL)rr�rrrrr�	item_cget�szHList.item_cgetcKsD|dkr|�|jdd||�S|jj|jdd||f|�||���dS)Nr@r r�rr�rr'r(rrr�item_configure�s

�zHList.item_configurecKs(|jj|jdd||f|�||���dS)Nr@rurBrBrrr�item_create�s�
�zHList.item_createcCs|j�|jdd||�S)Nr@r'rL�rr�rrrr�item_exists�szHList.item_existscCs|j�|jdd||�dS)Nr@ryrLrErrr�item_delete�szHList.item_deletecCs|j�|jd||�S)N�	entrycgetrLr%rrrrH�szHList.entrycgetcKs<|dkr|�|jd|�S|jj|jd|f|�||���dS�N�entryconfigurerr�rrrrJ�s

�zHList.entryconfigurecCs|j�|jd|�S�N�nearestrL)rrQrrrrLsz
HList.nearestcCs|j�|jd|�dS�N�seerLr�rrrrNsz	HList.seecKs$|jj|jddf|�||���dS�Nr�r�rBr&rrr�selection_clearszHList.selection_clearcCs|j�|jdd|�S�Nr�ZincludesrLr�rrr�selection_includes
szHList.selection_includescCs|j�|jdd||�dS�Nr�r�rL�r�firstZlastrrr�
selection_set
szHList.selection_setcCs|j�|jdd|�S)N�showr�rLr�rrr�
show_entryszHList.show_entry)rNN)N)N)8r2r3r4r8r�r�r�rrrrrr	rrrrrrrrZheader_existrrr!r#r$r&r(r)r*r,r/r1r3r4r5r7r8r:r;r=r?rArCrDrFrGrHrJrLrNrPrRrVrXrrrrr�Qsj


r�c@seZdZdifdd�ZdS)�	InputOnlyNcKst�||dd||�dS)NZtixInputOnlyr�r�rrrr8szInputOnly.__init__r�rrrrrYsrYc@seZdZdifdd�ZdS)�
LabelEntryNcKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZ
tixLabelEntry�	labelsider[r�r�)rZr8r�rbr�r�rrrr8%s
�zLabelEntry.__init__r�rrrrrZs
rZc@seZdZdifdd�ZdS)�
LabelFrameNcKs<t�||dddg||�t|d�|jd<t|d�|jd<dS)NZ
tixLabelFramer[r[r��frame)rZr8r�rb�_dummyFramer�rrrr86s
�zLabelFrame.__init__r�rrrrr\+sr\c@s<eZdZifdd�Zifdd�Zdd�Zdd�Zd	d
�ZdS)�ListNoteBookcKsNt�||ddg||�t|ddd�|jd<t|d�|jd<t|d�|jd<dS)NZtixListNoteBookr[Zpanerr�r�Zshlist)rZr8�_dummyPanedWindowrbr��_dummyScrolledHListr�rrrr8Es�zListNoteBook.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr��rrrCr%r{rb�rr,r'r(rrrr�Ms zListNoteBook.addcCs
|�|�SrE�ror+rrr�pageRszListNoteBook.pagecCs:|j�|j�|jd��}g}|D]}|�|�|��q |S�N�pages�rrOrrCr\ro�rrqZretrPrrrrgUs
zListNoteBook.pagescCs|j�|jd|�dS�N�raiserLr+rrr�
raise_page]szListNoteBook.raise_pageN)r2r3r4r8r�rergrlrrrrr_=s
r_c@seZdZdifdd�ZdS)�MeterNcKst�||ddg||�dS)NZtixMeterr[r�r�rrrr8es

�zMeter.__init__r�rrrrrm`srmc@sNeZdZdifdd�Zifdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�NoteBookNcKs.t�||ddg||�t|ddd�|jd<dS)NZtixNoteBookr[Znbframerr�)rZr8r{rbr�rrrr8qs�zNoteBook.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr�rbrcrrrr�vs zNoteBook.addcCs,|j�|jd|�|j|��|j|=dSr��rrrCrbr=r+rrrry{szNoteBook.deletecCs
|�|�SrErdr+rrrre�sz
NoteBook.pagecCs:|j�|j�|jd��}g}|D]}|�|�|��q |Srfrhrirrrrg�s
zNoteBook.pagescCs|j�|jd|�dSrjrLr+rrrrl�szNoteBook.raise_pagecCs|j�|jd�S)N�raisedrLr>rrrrp�szNoteBook.raised)
r2r3r4r8r�ryrergrlrprrrrrnisrnc@seZdZdS)�
NoteBookFrameN�r2r3r4rrrrrq�srqc@sHeZdZifdd�Zifdd�Zifdd�Zdd�Zd	d
�Zdd�Zd
S)�
OptionMenucKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZ
tixOptionMenur[�
menubutton�menu�rZr8�_dummyMenubuttonrb�
_dummyMenur�rrrr8�szOptionMenu.__init__cKs&|jj|jdd|f|�||���dS)Nr��commandrBrcrrr�add_command�szOptionMenu.add_commandcKs&|jj|jdd|f|�||���dS)Nr�Z	separatorrBrcrrr�
add_separator�szOptionMenu.add_separatorcCs|j�|jd|�dSr�rLr+rrrry�szOptionMenu.deletecCs|j�|jd|�dS)N�disablerLr+rrrr|�szOptionMenu.disablecCs|j�|jd|�dS)N�enablerLr+rrrr}�szOptionMenu.enableN)	r2r3r4r8rzr{ryr|r}rrrrrs�srsc@sPeZdZifdd�Zifdd�Zdd�Zdd�Zd	d
�Zifdd�Zd
d�Z	dS)�PanedWindowcKst�||dddg||�dS)NZtixPanedWindowr�r[r�r�rrrr8�szPanedWindow.__init__cKs>|jj|jd|f|�||���t||dd�|j|<|j|S)Nr�r)r~rbrcrrrr��s
 �zPanedWindow.addcCs,|j�|jd|�|j|��|j|=dSr�ror+rrrry�szPanedWindow.deletecCs|j�|jd|�dS)NrMrLr+rrrrM�szPanedWindow.forgetcCs|j�|jd||�S)N�panecgetrLr%rrrr�szPanedWindow.panecgetcKs<|dkr|�|jd|�S|jj|jd|f|�||���dS)N�
paneconfigurerr�rrrr��szPanedWindow.paneconfigurecs*�j��j��jd��}�fdd�|D�S)N�panescsg|]}��|��qSrrdrUr>rrrW�sz%PanedWindow.panes.<locals>.<listcomp>rY)rrqrr>rr��szPanedWindow.panesN)
r2r3r4r8r�ryrMrr�r�rrrrr~�sr~c@s0eZdZifdd�Zdd�Zdd�Zdd�Zd	S)
�	PopupMenucKs:t�||ddg||�t|d�|jd<t|d�|jd<dS)NZtixPopupMenur[rtrurvr�rrrr8�szPopupMenu.__init__cCs|j�|jd|j�dSr�rLr�rrrr��szPopupMenu.bind_widgetcCs|j�|jd|j�dSr�rLr�rrrr��szPopupMenu.unbind_widgetcCs|j�|jd|j||�dS)NZpostrL)rr�rPrQrrr�post_widget�szPopupMenu.post_widgetN)r2r3r4r8r�r�r�rrrrr��sr�c@s8eZdZifdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ResizeHandlec	Ks.ddddddddd	g	}t�||d
|||�dS)Nr[ryZcursorfgZcursorbgZ
handlesizeZ	hintcolorZ	hintwidthrPrQZtixResizeHandler�)rrcr'r(�flagsrrrr8�s�
�zResizeHandle.__init__cCs|j�|jd|j�dS)NZattachwidgetrLr�rrr�
attach_widgetszResizeHandle.attach_widgetcCs|j�|jd|j�dS)NZdetachwidgetrLr�rrr�
detach_widgetszResizeHandle.detach_widgetcCs|j�|jd|j�dS)Nr rLr�rrrr szResizeHandle.hidecCs|j�|jd|j�dS)NrWrLr�rrrrW	szResizeHandle.showN)r2r3r4r8r�r�r rWrrrrr��s

r�c@seZdZifdd�ZdS)�
ScrolledHListcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledHListr[r�r�r�r�r�rrrr8s�zScrolledHList.__init__Nr�rrrrr�sr�c@seZdZifdd�ZdS)�ScrolledListBoxcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledListBoxr[�listboxr�r�)rZr8�
_dummyListboxrbr�r�rrrr8szScrolledListBox.__init__Nr�rrrrr�sr�c@seZdZifdd�ZdS)�ScrolledTextcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledTextr[rr�r�)rZr8�
_dummyTextrbr�r�rrrr8%szScrolledText.__init__Nr�rrrrr�!sr�c@seZdZifdd�ZdS)�
ScrolledTListcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledTListr[Ztlistr�r�)rZr8�_dummyTListrbr�r�rrrr8/s�zScrolledTList.__init__Nr�rrrrr�+sr�c@seZdZifdd�ZdS)�ScrolledWindowcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixScrolledWindowr[rr�r�)rZr8r^rbr�r�rrrr8:szScrolledWindow.__init__Nr�rrrrr�6sr�c@s,eZdZifdd�Zifdd�Zdd�ZdS)�Selectc
Ks2t�||ddddddg||�t|d�|jd<dS)NZ	tixSelectZ	allowzero�radior�r[r[r�r�r�rrrr8Gs
��zSelect.__init__cKs:|jj|jd|f|�||���t||�|j|<|j|Sr�r�rcrrrr�Ns z
Select.addcCs|j�|jd|�dSr�rLr+rrrr�Ssz
Select.invokeNr�rrrrr�@sr�c@seZdZdifdd�ZdS)�ShellNcKst�||dddg||�dS)NZtixShellr[�titler�r�rrrr8[szShell.__init__r�rrrrr�Vsr�c@s2eZdZdifdd�Zdd�Zdd�Zdd	�ZdS)
�DialogShellNcKs&t�||ddddddddg||�dS)	NZtixDialogShellr[r�ZmappedZ	minheightZminwidthr�Z	transientr�r�rrrr8gs��zDialogShell.__init__cCs|j�|jd�dSr�rLr>rrrr�nszDialogShell.popdowncCs|j�|jd�dSr�rLr>rrrr�qszDialogShell.popupcCs|j�|jd�dS)N�centerrLr>rrrr�tszDialogShell.center)r2r3r4r8r�r�r�rrrrr�^s	r�c@s"eZdZdifdd�Zdd�ZdS)�StdButtonBoxNcKs\t�||dddg||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixStdButtonBoxr�r[r��applyr��help)rZr8r�rbr�rrrr8zs
�zStdButtonBox.__init__cCs ||jkr|j�|jd|�dSr�r�r+rrrr��s
zStdButtonBox.invoke)r2r3r4r8r�rrrrr�wsr�c@s�eZdZdifdd�Zdd�Zdd�Zdd	�Zd
d�Zd2dd
�Zdd�Z	dd�Z
dd�Zdd�Zifdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zifd,d-�Zd.d/�Zd3d0d1�ZdS)4�TListNcKst�||ddg||�dS)NZtixTListr[r�r�rrrr8�szTList.__init__cCs|j�|jdd|�dS)N�activer�rLr�rrr�
active_set�szTList.active_setcCs|j�|jdd�dS)Nr�r�rLr>rrr�active_clear�szTList.active_clearcCs|j�|jdd|�dSr�rLr�rrrr��szTList.anchor_setcCs|j�|jdd�dSr�rLr>rrrr�szTList.anchor_clearcCs|j�|jd||�dSr�rL�r�from_�torrrry�szTList.deletecCs|j�|jdd|�dSr
rLr�rrrr�szTList.dragsite_setcCs|j�|jdd�dSr
rLr>rrrr�szTList.dragsite_clearcCs|j�|jdd|�dSrrLr�rrrr�szTList.dropsite_setcCs|j�|jdd�dSrrLr>rrrr�szTList.dropsite_clearcKs$|jj|jd|f|�||���dSr�rB)rr�r'r(rrrr��szTList.insertcCs|j�|jdd�S)NrSr�rLr>rrr�info_active�szTList.info_activecCs|j�|jdd�Sr+rLr>rrrr,�szTList.info_anchorcCs|j�|jdd|�S)NrSZdownrLr�rrr�	info_down�szTList.info_downcCs|j�|jdd|�S)NrS�leftrLr�rrr�	info_left�szTList.info_leftcCs|j�|jdd|�S)NrS�rightrLr�rrr�
info_right�szTList.info_rightcCs|j�|jdd�}|j�|�Sr>r0r�rrrr?�szTList.info_selectioncCs|j�|jdd�S)NrSrrLr>rrr�	info_size�szTList.info_sizecCs|j�|jdd|�S)NrSZuprLr�rrr�info_up�sz
TList.info_upcCs|j�|jd||�SrKrL�rrPrQrrrrL�sz
TList.nearestcCs|j�|jd|�dSrMrLr�rrrrN�sz	TList.seecKs$|jj|jddf|�||���dSrOrBr&rrrrP�szTList.selection_clearcCs|j�|jdd|�SrQrLr�rrrrR�szTList.selection_includescCs|j�|jdd||�dSrSrLrTrrrrV�szTList.selection_set)N)N)r2r3r4r8r�r�r�rryrrrrr�r�r,r�r�r�r?r�r�rLrNrPrRrVrrrrr��s0

r�c@sDeZdZdifdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�ZdS)�TreeNcKsJt�||ddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixTreer[r�r�r�r�r�rrrr8�s
�z
Tree.__init__cCs|j�|jd�dS�N�autosetmoderLr>rrrr��szTree.autosetmodecCs|j�|jd|�dS�N�closerL�r�	entrypathrrrr��sz
Tree.closecCs|j�|jd|�S�N�getmoderLr�rrrr��szTree.getmodecCs|j�|jd|�dS�N�openrLr�rrrr��sz	Tree.open�nonecCs|j�|jd||�dS)N�setmoderL�rr��moderrrr��s
zTree.setmode)r�)	r2r3r4r8r�r�r�r�r�rrrrr��sr�c@sVeZdZdifdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Zdd�Z	ddd�Z
dS)�	CheckListNcKsLt�||dddg||�t|d�|jd<t|d�|jd<t|d�|jd<dS)NZtixCheckListr[r�r�r�r�r�r�rrrr8s
�zCheckList.__init__cCs|j�|jd�dSr�rLr>rrrr�szCheckList.autosetmodecCs|j�|jd|�dSr�rLr�rrrr�szCheckList.closecCs|j�|jd|�Sr�rLr�rrrr� szCheckList.getmodecCs|j�|jd|�dSr�rLr�rrrr�$szCheckList.open�oncCs|j�|j�|jd|��S)N�getselectionrY)rr�rrrr�(szCheckList.getselectioncCs|j�|jd|�S)N�	getstatusrLr�rrrr�.szCheckList.getstatuscCs|j�|jd||�dS)N�	setstatusrLr�rrrr�2szCheckList.setstatus)r�)r�)r2r3r4r8r�r�r�r�r�r�r�rrrrr�s
r�c@seZdZddd�ZdS)r�ricCst�||||�dSrE�r{r8�rrcr,r}rrrr8>sz_dummyButton.__init__N)rir�rrrrr�=sr�c@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8Bsz_dummyCheckbutton.__init__N)rir�rrrrr�Asr�c@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8Fsz_dummyEntry.__init__N)rir�rrrrr�Esr�c@seZdZddd�ZdS)r^ricCst�||||�dSrEr�r�rrrr8Jsz_dummyFrame.__init__N)rir�rrrrr^Isr^c@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8Nsz_dummyLabel.__init__N)rir�rrrrr�Msr�c@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8Rsz_dummyListbox.__init__N)rir�rrrrr�Qsr�c@seZdZddd�ZdS)rxricCst�||||�dSrEr�r�rrrr8Vsz_dummyMenu.__init__N)rir�rrrrrxUsrxc@seZdZddd�ZdS)rwricCst�||||�dSrEr�r�rrrr8Zsz_dummyMenubutton.__init__N)rir�rrrrrwYsrwc@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8^sz_dummyScrollbar.__init__N)rir�rrrrr�]sr�c@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8bsz_dummyText.__init__N)rir�rrrrr�asr�c@seZdZddd�ZdS)r�ricCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�)r{r8r�rbr�r�rrrr8fsz_dummyScrolledListBox.__init__N)rir�rrrrr�esr�c@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8msz_dummyHList.__init__N)rir�rrrrr�lsr�c@seZdZddd�ZdS)raricCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dS�Nr�r�r��r{r8r�rbr�r�rrrr8qsz_dummyScrolledHList.__init__N)rir�rrrrrapsrac@seZdZddd�ZdS)r�ricCst�||||�dSrEr�r�rrrr8xsz_dummyTList.__init__N)rir�rrrrr�wsr�c@seZdZddd�ZdS)r�ricCs�t�|||d|g�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<z$t|d�|jd<t|d�|jd<Wntk
r�YnXdS)Nr�r�r�r�r�r�r�)r{r8r�rbr�r�r�r�r�rrrr8|s�
z_dummyComboBox.__init__N)rir�rrrrr�{sr�c@seZdZddd�ZdS)r�ricCsDt�||||�t|d�|jd<t|d�|jd<t|d�|jd<dSr�r�r�rrrr8�sz_dummyDirList.__init__N)rir�rrrrr��sr�c@seZdZddd�ZdS)r�ricCs4t�||||�t|d�|jd<t|d�|jd<dS)Nr�r�)r{r8r�rbr�r�rrrr8�sz_dummyDirSelectBox.__init__N)rir�rrrrr��sr�c@seZdZddd�ZdS)r�ricCs�t�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)	Nr�r�r�r�r�r�r�r�)r{r8r�rbr�r�r�r�rrrr8�sz_dummyExFileSelectBox.__init__N)rir�rrrrr��sr�c@seZdZddd�ZdS)r�ricCsTt�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�r�)r{r8r�rbr�r�rrrr8�s
z_dummyFileSelectBox.__init__N)rir�rrrrr��sr�c@seZdZddd�ZdS)r�ricCs$t�||||�t|d�|jd<dS)Nr�)r{r8r�rbr�rrrr8�sz_dummyFileComboBox.__init__N)rir�rrrrr��sr�c@seZdZddd�ZdS)r�ricCsTt�||||�t|d�|jd<t|d�|jd<t|d�|jd<t|d�|jd<dS)Nr�r�r�r�)r{r8r�rbr�rrrr8�s
z_dummyStdButtonBox.__init__N)rir�rrrrr��sr�c@seZdZddd�ZdS)�_dummyNoteBookFramercCst�||||�dSrEr�r�rrrr8�sz_dummyNoteBookFrame.__init__N)rr�rrrrr��sr�c@seZdZddd�ZdS)r`ricCst�||||�dSrEr�r�rrrr8�sz_dummyPanedWindow.__init__N)rir�rrrrr`�sr`cCs|j�d|j�S)NZ
tixOptionNamerL)r�rrr�
OptionName�sr�cCs:d}|��D](}|d|d|d||d}q|S)Nr<z{{z} {z - z}} )�keys)�dict�s�typerrr�FileTypeList�s&r�c@seZdZdS)�CObjViewNrrrrrrr��sr�c@s�eZdZdifdd�Zdd�Zdd�Zdd	�Zd(d
d�Zd)dd
�Zdd�Z	dd�Z
dd�Zd*dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd+d d!�Zd"d#�Zd$d%�Zd&d'�ZdS),�GridNcKs"g}||_t�||d|||�dS)NZtixGrid�r'rZr8r�rrrr8�sz
Grid.__init__cCs|j�|dd�dSr�rr>rrrrszGrid.anchor_clearcCs|�|j�|dd��S)Nr�r/�r.rrr>rrr�
anchor_getszGrid.anchor_getcCs|j�|dd||�dSr�rr�rrrr�szGrid.anchor_setcCs4|dkr|j�|dd|�n|j�|dd||�dS)Nryr
rr�rrr�
delete_rowszGrid.delete_rowcCs4|dkr|j�|dd|�n|j�|dd||�dS)Nryr	rr�rrr�
delete_columnszGrid.delete_columncCs|j�|dd�dS)N�editr�rr>rrr�
edit_applyszGrid.edit_applycCs|j�|dd||�dS)Nr�r�rr�rrr�edit_set!sz
Grid.edit_setcCs,|r|ddkrd|}|j�|d|||�S)Nrr!rHr)rrPrQrrrrrH&szGrid.entrycgetcKs|�d||f||�SrI)Z
_configure)rrPrQr'r(rrrrJ,szGrid.entryconfigurec	Cs|�|j�|dd||��Sr6)Z_getbooleanrrr�rrrr72szGrid.info_existscCs|j�|dd||�Sr-rr�rrrr/6szGrid.info_bboxcCs|j�|dd|||�dS)N�mover	r�rr�r��offsetrrr�move_column:szGrid.move_columncCs|j�|dd|||�dS)Nr�r
rr�rrr�move_row@sz
Grid.move_rowcCs|�|j�|d||��SrKr�r�rrrrLFszGrid.nearestcKs>|�|j|�}|dk	r"d|f|}|jj|d||f|��dS)Nz	-itemtyper�)r%r'rr)rrPrQr�r(�argsrrrr�PszGrid.setcKs*|j�|jj|jdd|f|�i|����S)Nrr	)rrOrrCr%�rr�r(rrr�size_columnVs
�zGrid.size_columncKs(|j�|jj|dd|f|�i|����S)Nrr
)rrOrr%r�rrr�size_rowps�
�z
Grid.size_rowcCs|j�|jd||�dS)N�unsetrLr�rrrr��sz
Grid.unset)N)N)N)N)r2r3r4r8rr�r�r�r�r�r�rHrJr7r/r�r�rLr�r�r�r�rrrrr��s&	




r�c@seZdZdifdd�ZdS)�ScrolledGridNcKs"g}||_t�||d|||�dS)NZtixScrolledGridr�r�rrrr8�szScrolledGrid.__init__r�rrrrr��sr�)ur9r7rZ_tkinterZWINDOWZTEXTZSTATUSZ	IMMEDIATEZIMAGEZ	IMAGETEXTZBALLOONZAUTOZ	ACROSSTOP�ASCIIZCELLZCOLUMNZ
DECREASINGZ
INCREASINGZINTEGERZMAIN�MAXZREALZROWZS_REGIONZX_REGIONZY_REGIONZ
TCL_DONT_WAITZTCL_WINDOW_EVENTSZTCL_FILE_EVENTSZTCL_TIMER_EVENTSZTCL_IDLE_EVENTSZTCL_ALL_EVENTSrr5r@r`�	__bases__rZr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZXViewZYViewr�rYrZr\r_rmrnrqrsr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZButtonr�ZCheckbuttonr�ZEntryr�ZFramer^ZLabelr�ZListboxr�ZMenurxZ
MenubuttonrwZ	Scrollbarr�ZTextr�r�r�rar�r�r�r�r�r�r�r�r�r`r�r�r�r�r�rrrr�<module>s�-
8/,!"C#	()


S.6

*PK+�\�x��2$2$!simpledialog.cpython-38.opt-2.pycnu�[���U

e5d�-�@s�ddlTddlmZmZGdd�d�ZGdd�de�Zdd�ZGd	d
�d
e�ZGdd�de�Zd
d�Z	Gdd�de�Z
dd�ZGdd�de�Zdd�Z
edkr�dd�Ze�dS)�)�*)�
messagebox�_get_default_rootc@sLeZdZdgddddfdd�Zddd�Zd	d
�Zdd�Zd
d�Zdd�ZdS)�SimpleDialog�NcCs|rt||d�|_n
t|�|_|r:|j�|�|j�|�t|j�t|j|dd�|_|jjdtd�t	|j�|_
|j
��||_||_||_
|j�d|j�tt|��D]L}||}	t|j
|	||fdd�d	�}
||kr�|
jtd
d�|
jttdd�q�|j�d
|j�|�|�dS)N)�class_i�)�textZaspect�)�expand�fill�<Return>cSs
|�|�S�N)�done��self�num�r�,/usr/lib64/python3.8/tkinter/simpledialog.py�<lambda>8�z'SimpleDialog.__init__.<locals>.<lambda>�r�command�)ZreliefZborderwidth)�siderr
�WM_DELETE_WINDOW)�Toplevel�root�titleZiconname�
_setup_dialogZMessage�message�packZBOTH�Frame�framer�cancel�default�bind�return_event�range�len�ButtonZconfigZRIDGE�LEFT�protocol�wm_delete_window�_set_transient)r�masterr�buttonsr$r#rrr�s�brrr�__init__ s2


�zSimpleDialog.__init__��?�333333�?c
Cs|j}|��|�|�|��|��rJ|��}|��}|��}|��}n|�	�}|�
�}d}}|��}	|��}
|||	|}|||
|}||	|�	�kr�|�	�|	}n|dkr�d}||
|�
�kr�|�
�|
}n|dkr�d}|�
d||f�|��dS)Nr�+%d+%d)r�withdraw�	transient�update_idletasksZwinfo_ismappedZwinfo_widthZwinfo_height�winfo_rootx�winfo_rootyZwinfo_screenwidthZwinfo_screenheightZwinfo_reqwidthZwinfo_reqheight�geometry�	deiconify)
rr.ZrelxZrelyZwidgetZm_widthZm_heightZm_xZm_yZw_widthZw_height�x�yrrrr-?s4

zSimpleDialog._set_transientcCs.|j��|j��|j��|j��|jSr
)r�wait_visibility�grab_set�mainloop�destroyr�rrrr�go\s




zSimpleDialog.gocCs&|jdkr|j��n|�|j�dSr
)r$r�bellr�rZeventrrrr&cs
zSimpleDialog.return_eventcCs&|jdkr|j��n|�|j�dSr
)r#rrErrCrrrr,is
zSimpleDialog.wm_delete_windowcCs||_|j��dSr
)rr�quitrrrrroszSimpleDialog.done)r3r4)	�__name__�
__module__�__qualname__r2r-rDr&r,rrrrrrs�

rc@sReZdZddd�Zdd�Zdd�Zdd	�Zdd
d�Zddd
�Zdd�Z	dd�Z
dS)�DialogNcCs�|}|std�}t�||�|��|dk	r>|��r>|�|�|rL|�|�t|�||_d|_	t
|�}|�|�|_|j
ddd�|��|js�||_|�d|j�|dk	r�|�d|��d|��df�|��|j��|��|��|�|�dS)Nzcreate dialog window�)�padx�padyrr5�2)rrr2r6Zwinfo_viewabler7rr�parent�resultr!�body�
initial_focusr �	buttonboxr+r#r;r9r:r<�	focus_setr?r@Zwait_window)rrPrr.rRrrrr2{s8	


�
zDialog.__init__cCsd|_t�|�dSr
)rSrrBrCrrrrB�szDialog.destroycCsdSr
r)rr.rrrrR�szDialog.bodycCsvt|�}t|dd|jtd�}|jtddd�t|dd|jd�}|jtddd�|�d|j�|�d	|j�|��dS)
NZOK�
)r�widthrr$rL)rrMrN�Cancel)rrWrrz<Escape>)r!r)�okZACTIVEr r*r#r%)rZbox�wrrrrT�szDialog.buttonboxcCsB|��s|j��dS|��|��z|��W5|��XdSr
)�validaterSrUr6r8r#�applyrFrrrrY�s
z	Dialog.okcCs |jdk	r|j��|��dSr
)rPrUrBrFrrrr#�s

z
Dialog.cancelcCsdS)Nr	rrCrrrr[�szDialog.validatecCsdSr
rrCrrrr\�szDialog.apply)N)N)N)rHrIrJr2rBrRrTrYr#r[r\rrrrrKts
7	


	rKcCs:|jdkr |j�dd|dd�n|jdkr6|�dd�dS)	NZaquaz!::tk::unsupported::MacWindowStyleZstyleZ
moveableModalrZx11z-typeZdialog)Z_windowingsystemZtkZcallZ
wm_attributes)rZrrrrs

�
rc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�_QueryDialogNcCs*||_||_||_||_t�|||�dSr
)�prompt�minvalue�maxvalue�initialvaluerKr2)rrr^rar_r`rPrrrr2s
z_QueryDialog.__init__cCsd|_t�|�dSr
)�entryrKrBrCrrrrBsz_QueryDialog.destroycCsrt||jtd�}|jddtd�t|dd�|_|jjddttd�|jdk	rl|j�	d|j�|j�
dt�|jS)N)rZjustifyrrL)�rowrMZstickyrb)�namer	)ZLabelr^r*Zgrid�WZEntryrb�Era�insertZselect_rangeZEND)rr.rZrrrrR s
z_QueryDialog.bodycCs�z|��}Wn,tk
r8tjd|jd|d�YdSX|jdk	rh||jkrhtjdd|j|d�dS|jdk	r�||jkr�tjdd|j|d�dS||_d	S)
Nz
Illegal valuez
Please try again)rPrz	Too smallz2The allowed minimum value is %s. Please try again.z	Too largez2The allowed maximum value is %s. Please try again.r	)�	getresult�
ValueErrorr�showwarning�errormessager_r`rQ)rrQrrrr[.s:�����z_QueryDialog.validate)NNNN)rHrIrJr2rBrRr[rrrrr]
s�

r]c@seZdZdZdd�ZdS)�
_QueryIntegerzNot an integer.cCs|�|j���Sr
)Zgetintrb�getrCrrrrhSsz_QueryInteger.getresultN�rHrIrJrkrhrrrrrlPsrlcKst||f|�}|jSr
)rlrQ�rr^�kw�drrr�
askintegerWsrrc@seZdZdZdd�ZdS)�_QueryFloatzNot a floating point value.cCs|�|j���Sr
)Z	getdoublerbrmrCrrrrhisz_QueryFloat.getresultNrnrrrrrsfsrscKst||f|�}|jSr
)rsrQrorrr�askfloatmsrtc@s$eZdZdd�Zdd�Zdd�ZdS)�_QueryStringcOs6d|kr|d|_|d=nd|_tj|f|�|�dS)N�show)�_QueryString__showr]r2)r�argsrprrrr2}s

z_QueryString.__init__cCs(t�||�}|jdk	r$|j|jd�|S)N)rv)r]rRrwZ	configure)rr.rbrrrrR�s
z_QueryString.bodycCs
|j��Sr
)rbrmrCrrrrh�sz_QueryString.getresultN)rHrIrJr2rRrhrrrrru|srucKst||f|�}|jSr
)rurQrorrr�	askstring�sry�__main__cCsLt�}|fdd�}t|d|d�}|��t|d|jd�}|��|��dS)NcSs^t|ddddgdddd�}t|���ttd	d
dd��ttd	d
ddd��ttd	d��dS)Nz�This is a test dialog.  Would this have been an actual dialog, the buttons below would have been glowing in soft pink light.
Do you believe this?ZYesZNorXr�zTest Dialog)rr/r$r#rZSpamz	Egg count�)razEgg weight
(in tons)r	�d)r_r`z	Egg label)r�printrDrrrtry)rrqrrr�doit�s�

�ztest.<locals>.doitZTestrZQuit)ZTkr)r rGrA)rr�t�qrrr�test�sr�N)ZtkinterrrrrrKrr]rlrrrsrtruryrHr�rrrr�<module>sV
CPK+�\s����scrolledtext.cpython-38.pycnu�[���U

e5d�@sldZdgZddlmZmZmZmZmZmZddl	m
Z
mZmZm
Z
Gdd�de�Zdd�Zedkrhe�d	S)
aA ScrolledText widget feels like a text widget but also has a
vertical scroll bar on its right.  (Later, options may be added to
add a horizontal bar as well, to make the bars disappear
automatically when not needed, to move them to the other side of the
window, etc.)

Configuration options are passed to the Text widget.
A Frame widget is inserted between the master and the text, to hold
the Scrollbar widget.
Most methods calls are inherited from the Text widget; Pack, Grid and
Place methods are redirected to the Frame widget however.
�ScrolledText�)�Frame�Text�	Scrollbar�Pack�Grid�Place)�RIGHT�LEFT�Y�BOTHc@seZdZddd�Zdd�ZdS)rNcKs�t|�|_t|j�|_|jjttd�|�d|jji�t	j
||jf|�|jttdd�|j
|jd<tt	���}tt���tt���Btt���B}|�|�}|D]4}|ddkr�|dkr�|d	kr�t||t|j|��q�dS)
N)�side�fillZyscrollcommandT)r
r�expandZcommandr�_ZconfigZ	configure)r�framerZvbar�packr	r�update�setr�__init__r
rZyview�vars�keysrrr�
difference�setattr�getattr)�selfZmaster�kwZ
text_meths�methods�m�r�,/usr/lib64/python3.8/tkinter/scrolledtext.pyrs
$
zScrolledText.__init__cCs
t|j�S)N)�strr)rrrr �__str__)szScrolledText.__str__)N)�__name__�
__module__�__qualname__rr"rrrr rs
cCsHddlm}tddd�}|�|t�|jttdd�|��|�	�dS)Nr)�ENDZwhite�
)ZbgZheightT)rr
r)
�tkinter.constantsr&r�insert�__doc__rrr
Z	focus_setZmainloop)r&Zstextrrr �example-sr+�__main__N)r*�__all__Ztkinterrrrrrrr(r	r
rrrr+r#rrrr �<module>s
 
PKq#�\=տtool.cpython-36.pycnu�[���3


 \m�@s>dZddlZddlZddlZddlZdd�Zedkr:e�dS)aCommand-line tool to validate and pretty-print JSON

Usage::

    $ echo '{"json":"obj"}' | python -m json.tool
    {
        "json": "obj"
    }
    $ echo '{ 1.2:3.4}' | python -m json.tool
    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

�Nc	"Csd}d}tj||d�}|jddtj�dd�|jddtjd	�d
d�|jddd
dd�|j�}|jphtj}|jpttj	}|j
}|�Vy$|r�tj|�}ntj|t
jd�}Wn*tk
r�}zt|��WYdd}~XnXWdQRX|�"tj|||dd�|jd�WdQRXdS)Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)�prog�description�infile�?z-a JSON file to be validated or pretty-printed)�nargs�type�help�outfile�wz%write the output of infile to outfilez--sort-keys�
store_trueFz5sort the output of dictionaries alphabetically by key)�action�defaultr)Zobject_pairs_hook�)�	sort_keys�indent�
)�argparse�ArgumentParser�add_argumentZFileType�
parse_argsr�sys�stdinr	�stdoutr�json�load�collections�OrderedDict�
ValueError�
SystemExit�dump�write)	rr�parserZoptionsrr	r�obj�e�r$�!/usr/lib64/python3.6/json/tool.py�mains0
$r&�__main__)�__doc__rrrrr&�__name__r$r$r$r%�<module>sPKq#�\ީi��tool.cpython-36.opt-2.pycnu�[���3


 \m�@s:ddlZddlZddlZddlZdd�Zedkr6e�dS)�Nc	"Csd}d}tj||d�}|jddtj�dd�|jddtjd	�d
d�|jddd
dd�|j�}|jphtj}|jpttj	}|j
}|�Vy$|r�tj|�}ntj|t
jd�}Wn*tk
r�}zt|��WYdd}~XnXWdQRX|�"tj|||dd�|jd�WdQRXdS)Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)�prog�description�infile�?z-a JSON file to be validated or pretty-printed)�nargs�type�help�outfile�wz%write the output of infile to outfilez--sort-keys�
store_trueFz5sort the output of dictionaries alphabetically by key)�action�defaultr)Zobject_pairs_hook�)�	sort_keys�indent�
)�argparse�ArgumentParser�add_argumentZFileType�
parse_argsr�sys�stdinr	�stdoutr�json�load�collections�OrderedDict�
ValueError�
SystemExit�dump�write)	rr�parserZoptionsrr	r�obj�e�r$�!/usr/lib64/python3.6/json/tool.py�mains0
$r&�__main__)rrrrr&�__name__r$r$r$r%�<module>
sPKq#�\�.kW�&�&decoder.cpython-36.pycnu�[���3


 \)1�@sdZddlZddlmZyddlmZWnek
r@dZYnXddgZej	ej
BejBZe
d�Ze
d�Ze
d	�ZGd
d�de�Zeeed�Zejde�Zd
dddddddd�Zdd�Zdeejfdd�Zep�eZejde�ZdZdejefdd�Zejefdd �ZGd!d�de�ZdS)"zImplementation of JSONDecoder
�N)�scanner)�
scanstring�JSONDecoder�JSONDecodeError�nan�infz-infc@s eZdZdZdd�Zdd�ZdS)ra Subclass of ValueError with the following additional properties:

    msg: The unformatted error message
    doc: The JSON document being parsed
    pos: The start index of doc where parsing failed
    lineno: The line corresponding to pos
    colno: The column corresponding to pos

    cCsb|jdd|�d}||jdd|�}d||||f}tj||�||_||_||_||_||_dS)N�
r�z%s: line %d column %d (char %d))	�count�rfind�
ValueError�__init__�msg�doc�pos�lineno�colno)�selfrrrrr�errmsg�r�$/usr/lib64/python3.6/json/decoder.pyr
szJSONDecodeError.__init__cCs|j|j|j|jffS)N)�	__class__rrr)rrrr�
__reduce__*szJSONDecodeError.__reduce__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrs	)z	-InfinityZInfinity�NaNz(.*?)(["\\\x00-\x1f])�"�\�/��r�
�	)rrr �b�f�n�r�tcCs`||d|d�}t|�dkrL|ddkrLy
t|d�Stk
rJYnXd}t|||��dS)Nr	��ZxX�zInvalid \uXXXX escape)�len�intrr)�sr�escrrrr�
_decode_uXXXX;s
r1TcCs�g}|j}|d}�x�|||�}|dkr4td||��|j�}|j�\}	}
|	rT||	�|
dkr`Pn.|
dkr�|r�dj|
�}t|||��n
||
�qy||}Wn tk
r�td||��YnX|dk�ry||}
Wn*tk
r�dj|�}t|||��YnX|d7}n�t||�}|d	7}d
|k�o.dkn�r�|||d�d
k�r�t||d�}d|k�ondkn�r�d|d
d>|dB}|d7}t|�}
||
�qWdj	|�|fS)a�Scan the string s for a JSON string. End is the index of the
    character in s after the quote that started the JSON string.
    Unescapes all valid JSON string escape sequences and raises ValueError
    on attempt to decode an invalid string. If strict is False then literal
    control characters are allowed in the string.

    Returns a tuple of the decoded string and the index of the character in s
    after the end quote.r	NzUnterminated string starting atrrz"Invalid control character {0!r} at�uzInvalid \escape: {0!r}r*i�i���z\ui�i��i�
��)
�appendr�end�groups�format�
IndexError�KeyErrorr1�chr�join)r/r8�strictZ_bZ_mZchunks�_appendZbegin�chunkZcontent�
terminatorrr0�charZuniZuni2rrr�
py_scanstringEsP






2rDz
[ \t\n\r]*z 	

c#Cs�|\}}	g}
|
j}|dkri}|j}||	|	d�}
|
dkr�|
|krb|||	�j�}	||	|	d�}
|
dkr�|dk	r�||
�}||	dfSi}
|dk	r�||
�}
|
|	dfS|
dkr�td||	��|	d7}	�x�t||	|�\}}	|||�}||	|	d�dk�r&|||	�j�}	||	|	d�dk�r&td||	��|	d7}	y:||	|k�rf|	d7}	||	|k�rf|||	d�j�}	Wntk
�r~YnXy|||	�\}}	Wn4tk
�r�}ztd||j�d�WYdd}~XnX|||f�y0||	}
|
|k�r|||	d�j�}	||	}
Wntk
�rd}
YnX|	d7}	|
dk�r6Pn|
d	k�rPtd
||	d��|||	�j�}	||	|	d�}
|	d7}	|
dkr�td||	d��q�W|dk	�r�||
�}||	fSt|
�}
|dk	�r�||
�}
|
|	fS)Nr	r�}z1Expecting property name enclosed in double quotes�:zExpecting ':' delimiterzExpecting valuer6�,zExpecting ',' delimiter)	r7�
setdefaultr8rrr;�
StopIteration�value�dict)�	s_and_endr?�	scan_once�object_hook�object_pairs_hook�memo�_w�_wsr/r8ZpairsZpairs_appendZmemo_get�nextchar�result�keyrJ�errrrr�
JSONObject�s�

"





rWcCsz|\}}g}|||d�}||krF|||d�j�}|||d�}|dkrZ||dfS|j}�xy|||�\}	}Wn2tk
r�}
ztd||
j�d�WYdd}
~
XnX||	�|||d�}||kr�|||d�j�}|||d�}|d7}|dk�rPn|dk�rtd||d��y:|||k�rT|d7}|||k�rT|||d�j�}Wqdtk
�rlYqdXqdW||fS)Nr	�]zExpecting valuerGzExpecting ',' delimiter)r8r7rIrrJr;)rLrMrQrRr/r8�valuesrSr@rJrVrrr�	JSONArray�s@"


rZc@s@eZdZdZddddddd�dd�Zejfdd�Zdd
d�ZdS)
raSimple JSON <http://json.org> decoder

    Performs the following translations in decoding by default:

    +---------------+-------------------+
    | JSON          | Python            |
    +===============+===================+
    | object        | dict              |
    +---------------+-------------------+
    | array         | list              |
    +---------------+-------------------+
    | string        | str               |
    +---------------+-------------------+
    | number (int)  | int               |
    +---------------+-------------------+
    | number (real) | float             |
    +---------------+-------------------+
    | true          | True              |
    +---------------+-------------------+
    | false         | False             |
    +---------------+-------------------+
    | null          | None              |
    +---------------+-------------------+

    It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
    their corresponding ``float`` values, which is outside the JSON spec.

    NT)rN�parse_float�	parse_int�parse_constantr?rOcCsZ||_|pt|_|pt|_|p"tj|_||_||_	t
|_t|_
t|_i|_tj|�|_dS)aD``object_hook``, if specified, will be called with the result
        of every JSON object decoded and its return value will be used in
        place of the given ``dict``.  This can be used to provide custom
        deserializations (e.g. to support JSON-RPC class hinting).

        ``object_pairs_hook``, if specified will be called with the result of
        every JSON object decoded with an ordered list of pairs.  The return
        value of ``object_pairs_hook`` will be used instead of the ``dict``.
        This feature can be used to implement custom decoders that rely on the
        order that the key and value pairs are decoded (for example,
        collections.OrderedDict will remember the order of insertion). If
        ``object_hook`` is also defined, the ``object_pairs_hook`` takes
        priority.

        ``parse_float``, if specified, will be called with the string
        of every JSON float to be decoded. By default this is equivalent to
        float(num_str). This can be used to use another datatype or parser
        for JSON floats (e.g. decimal.Decimal).

        ``parse_int``, if specified, will be called with the string
        of every JSON int to be decoded. By default this is equivalent to
        int(num_str). This can be used to use another datatype or parser
        for JSON integers (e.g. float).

        ``parse_constant``, if specified, will be called with one of the
        following strings: -Infinity, Infinity, NaN.
        This can be used to raise an exception if invalid JSON numbers
        are encountered.

        If ``strict`` is false (true is the default), then control
        characters will be allowed inside strings.  Control characters in
        this context are those with character codes in the 0-31 range,
        including ``'\t'`` (tab), ``'\n'``, ``'\r'`` and ``'\0'``.

        N)rN�floatr[r.r\�
_CONSTANTS�__getitem__r]r?rOrWZparse_objectrZZparse_arrayrZparse_stringrPrZmake_scannerrM)rrNr[r\r]r?rOrrrr
s&

zJSONDecoder.__init__cCsF|j|||d�j�d�\}}|||�j�}|t|�krBtd||��|S)zlReturn the Python representation of ``s`` (a ``str`` instance
        containing a JSON document).

        r)�idxz
Extra data)�
raw_decoder8r-r)rr/rQ�objr8rrr�decodeNs
zJSONDecoder.decodercCsPy|j||�\}}Wn2tk
rF}ztd||j�d�WYdd}~XnX||fS)a=Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.

        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.

        zExpecting valueN)rMrIrrJ)rr/rarcr8rVrrrrbYs
	"zJSONDecoder.raw_decode)r)	rrrrr
�
WHITESPACE�matchrdrbrrrrr�s1) r�reZjsonrZ_jsonrZc_scanstring�ImportError�__all__�VERBOSE�	MULTILINE�DOTALL�FLAGSr^rZPosInfZNegInfrrr_�compileZSTRINGCHUNKZ	BACKSLASHr1rfrDreZWHITESPACE_STRrWrZ�objectrrrrr�<module>s6

;P%PKq#�\N�TM�+�+encoder.cpython-36.opt-1.pycnu�[���3


 \�>�"@sBdZddlZyddlmZWnek
r4dZYnXyddlmZWnek
r^dZYnXyddlmZ	Wnek
r�dZ	YnXej
d�Zej
d�Zej
d�Z
d	d
ddd
ddd�Zx&ed�D]Zejee�dje��q�Wed�Zdd�Zep�eZdd�Ze�peZGdd�de�Zeeeeeeee e!ej"f
dd�Z#dS)zImplementation of JSONEncoder
�N)�encode_basestring_ascii)�encode_basestring)�make_encoderz[\x00-\x1f\\"\b\f\n\r\t]z([\\"]|[^\ -~])s[�-�]z\\z\"z\bz\fz\nz\rz\t)�\�"���
�
�	� z	\u{0:04x}�infcCsdd�}dtj||�dS)z5Return a JSON representation of a Python string

    cSst|jd�S)Nr)�
ESCAPE_DCT�group)�match�r�$/usr/lib64/python3.6/json/encoder.py�replace(sz%py_encode_basestring.<locals>.replacer)�ESCAPE�sub)�srrrr�py_encode_basestring$srcCsdd�}dtj||�dS)zAReturn an ASCII-only JSON representation of a Python string

    cSsv|jd�}yt|Stk
rpt|�}|dkr<dj|�S|d8}d|d?d@B}d|d@B}dj||�SYnXdS)	Nriz	\u{0:04x}i��
i�i�z\u{0:04x}\u{1:04x})rr�KeyError�ord�format)rr�n�s1�s2rrrr4s

z+py_encode_basestring_ascii.<locals>.replacer)�ESCAPE_ASCIIr)rrrrr�py_encode_basestring_ascii0sr c	@sNeZdZdZdZdZddddddddd�dd	�Zd
d�Zdd
�Zddd�Z	dS)�JSONEncoderaZExtensible JSON <http://json.org> encoder for Python data structures.

    Supports the following objects and types by default:

    +-------------------+---------------+
    | Python            | JSON          |
    +===================+===============+
    | dict              | object        |
    +-------------------+---------------+
    | list, tuple       | array         |
    +-------------------+---------------+
    | str               | string        |
    +-------------------+---------------+
    | int, float        | number        |
    +-------------------+---------------+
    | True              | true          |
    +-------------------+---------------+
    | False             | false         |
    +-------------------+---------------+
    | None              | null          |
    +-------------------+---------------+

    To extend this to recognize other objects, subclass and implement a
    ``.default()`` method with another method that returns a serializable
    object for ``o`` if possible, otherwise it should call the superclass
    implementation (to raise ``TypeError``).

    z, z: FTN)�skipkeys�ensure_ascii�check_circular�	allow_nan�	sort_keys�indent�
separators�defaultc	CsZ||_||_||_||_||_||_|dk	r:|\|_|_n|dk	rHd|_|dk	rV||_dS)a�Constructor for JSONEncoder, with sensible defaults.

        If skipkeys is false, then it is a TypeError to attempt
        encoding of keys that are not str, int, float or None.  If
        skipkeys is True, such items are simply skipped.

        If ensure_ascii is true, the output is guaranteed to be str
        objects with all incoming non-ASCII characters escaped.  If
        ensure_ascii is false, the output can contain non-ASCII characters.

        If check_circular is true, then lists, dicts, and custom encoded
        objects will be checked for circular references during encoding to
        prevent an infinite recursion (which would cause an OverflowError).
        Otherwise, no such check takes place.

        If allow_nan is true, then NaN, Infinity, and -Infinity will be
        encoded as such.  This behavior is not JSON specification compliant,
        but is consistent with most JavaScript based encoders and decoders.
        Otherwise, it will be a ValueError to encode such floats.

        If sort_keys is true, then the output of dictionaries will be
        sorted by key; this is useful for regression tests to ensure
        that JSON serializations can be compared on a day-to-day basis.

        If indent is a non-negative integer, then JSON array
        elements and object members will be pretty-printed with that
        indent level.  An indent level of 0 will only insert newlines.
        None is the most compact representation.

        If specified, separators should be an (item_separator, key_separator)
        tuple.  The default is (', ', ': ') if *indent* is ``None`` and
        (',', ': ') otherwise.  To get the most compact JSON representation,
        you should specify (',', ':') to eliminate whitespace.

        If specified, default is a function that gets called for objects
        that can't otherwise be serialized.  It should return a JSON encodable
        version of the object or raise a ``TypeError``.

        N�,)	r"r#r$r%r&r'�item_separator�
key_separatorr))	�selfr"r#r$r%r&r'r(r)rrr�__init__hs+zJSONEncoder.__init__cCstd|jj��dS)alImplement this method in a subclass such that it returns
        a serializable object for ``o``, or calls the base implementation
        (to raise a ``TypeError``).

        For example, to support arbitrary iterators, you could
        implement default like this::

            def default(self, o):
                try:
                    iterable = iter(o)
                except TypeError:
                    pass
                else:
                    return list(iterable)
                # Let the base class default method raise the TypeError
                return JSONEncoder.default(self, o)

        z,Object of type '%s' is not JSON serializableN)�	TypeError�	__class__�__name__)r-�orrrr)�szJSONEncoder.defaultcCsNt|t�r |jrt|�St|�S|j|dd�}t|ttf�sDt|�}dj|�S)z�Return a JSON string representation of a Python data structure.

        >>> from json.encoder import JSONEncoder
        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
        '{"foo": ["bar", "baz"]}'

        T)�	_one_shot�)	�
isinstance�strr#rr�
iterencode�list�tuple�join)r-r2�chunksrrr�encode�s	
zJSONEncoder.encodecCs�|jri}nd}|jrt}nt}|jtjttfdd�}|rvtdk	rv|j	dkrvt||j
||j	|j|j|j
|j|j�	}n&t||j
||j	||j|j|j
|j|�
}||d�S)z�Encode the given object and yield each string
        representation as available.

        For example::

            for chunk in JSONEncoder().iterencode(bigobject):
                mysocket.write(chunk)

        NcSsJ||krd}n$||krd}n||kr*d}n||�S|sFtdt|���|S)NZNaNZInfinityz	-Infinityz2Out of range float values are not JSON compliant: )�
ValueError�repr)r2r%Z_reprZ_infZ_neginf�textrrr�floatstr�sz(JSONEncoder.iterencode.<locals>.floatstrr)r$r#rrr%�float�__repr__�INFINITY�c_make_encoderr'r)r,r+r&r"�_make_iterencode)r-r2r3�markers�_encoderr@�_iterencoderrrr7�s&


zJSONEncoder.iterencode)F)
r1�
__module__�__qualname__�__doc__r+r,r.r)r<r7rrrrr!Is6r!cs��dk	r����rd�����������	�
��������fdd��	���������	�
���
��������fdd����������	�
��������fdd���S)N� c	3s�|sdVdS�dk	r6�|�}|�kr.�d��|�|<d}�dk	rh|d7}d�|}�|}||7}nd}�}d}x�|D]�}|r�d}n|}�
|��r�|�|�Vqz|dkr�|dVqz|dkr�|d	Vqz|dkr�|d
Vqz�
|��r�|�|�Vqz�
|�
��r|�|�Vqz|V�
|��f��r:�||�}n"�
|�	��rR�||�}n
�||�}|EdHqzW|dk	�r�|d8}d�|VdV�dk	�r��|=dS)Nz[]zCircular reference detected�[�r	TF�null�true�false�]r)	Zlst�_current_indent_level�markeridZbuf�newline_indentZ	separator�first�valuer;)r=rG�	_floatstr�_indent�_intstr�_item_separatorrH�_iterencode_dict�_iterencode_list�dictrA�id�intr5r8rFr6r9rrr]s\






z*_make_iterencode.<locals>._iterencode_listc
3sL|sdVdS�dk	r6�|�}|�kr.�d��|�|<dV�dk	rh|d7}d�|}�|}|Vnd}�}d}�r�t|j�dd�d	�}n|j�}�xx|D�]n\}}�|��r�nr�|�
�rȈ|�}n^|dkr�d
}nP|dkr�d}nB|dkr�d
}n4�|���r�|�}n�
�rq�ntdt|�d��|�r2d}n|V�|�V�	V�|���r`�|�Vq�|dk�rrd
Vq�|dk�r�d
Vq�|dk�r�dVq��|���r��|�Vq��|�
��rƈ|�Vq��|��f��r�||�}	n"�|���r��||�}	n
�||�}	|	EdHq�W|dk	�r2|d8}d�|VdV�dk	�rH�|=dS)Nz{}zCircular reference detected�{rNr	TcSs|dS)Nrr)Zkvrrr�<lambda>asz<_make_iterencode.<locals>._iterencode_dict.<locals>.<lambda>)�keyrPFrQrOzkey z is not a string�})�sorted�itemsr/r>)
ZdctrSrTrUr+rVrfrcrWr;)r=rGrXrYrZr[rHr\r]�_key_separator�	_skipkeys�
_sort_keysr^rAr_r`r5r8rFr6r9rrr\Ms�










z*_make_iterencode.<locals>._iterencode_dictc3s�|��r�|�Vn�|dkr&dVn�|dkr6dVn�|dkrFdVn��|��r\�|�Vn��|�	�rr�|�Vn��|�
�f�r��||�EdHnj�|��r��||�EdHnN�dk	rֈ
|�}|�krΈd��|�|<�|�}�||�EdH�dk	r��|=dS)NrOTrPFrQzCircular reference detectedr)r2rSrT)r=�_defaultrGrXrZrHr\r]r^rAr_r`r5r8rFr6r9rrrH�s2



z%_make_iterencode.<locals>._iterencoder)rFrjrGrYrXrgr[rirhr3r=r^rAr_r`r5r8r6r9rZr)r=rjrGrXrYrZr[rHr\r]rgrhrir^rAr_r`r5r8rFr6r9rrEs.84O,rE)$rK�reZ_jsonrZc_encode_basestring_ascii�ImportErrorrZc_encode_basestringrrD�compilerrZHAS_UTF8r�range�i�
setdefault�chrrrArCrr �objectr!r=r^r_r`r5r8r6r9�__str__rErrrr�<module>sT





	
>PKq#�\N�TM�+�+encoder.cpython-36.pycnu�[���3


 \�>�"@sBdZddlZyddlmZWnek
r4dZYnXyddlmZWnek
r^dZYnXyddlmZ	Wnek
r�dZ	YnXej
d�Zej
d�Zej
d�Z
d	d
ddd
ddd�Zx&ed�D]Zejee�dje��q�Wed�Zdd�Zep�eZdd�Ze�peZGdd�de�Zeeeeeeee e!ej"f
dd�Z#dS)zImplementation of JSONEncoder
�N)�encode_basestring_ascii)�encode_basestring)�make_encoderz[\x00-\x1f\\"\b\f\n\r\t]z([\\"]|[^\ -~])s[�-�]z\\z\"z\bz\fz\nz\rz\t)�\�"���
�
�	� z	\u{0:04x}�infcCsdd�}dtj||�dS)z5Return a JSON representation of a Python string

    cSst|jd�S)Nr)�
ESCAPE_DCT�group)�match�r�$/usr/lib64/python3.6/json/encoder.py�replace(sz%py_encode_basestring.<locals>.replacer)�ESCAPE�sub)�srrrr�py_encode_basestring$srcCsdd�}dtj||�dS)zAReturn an ASCII-only JSON representation of a Python string

    cSsv|jd�}yt|Stk
rpt|�}|dkr<dj|�S|d8}d|d?d@B}d|d@B}dj||�SYnXdS)	Nriz	\u{0:04x}i��
i�i�z\u{0:04x}\u{1:04x})rr�KeyError�ord�format)rr�n�s1�s2rrrr4s

z+py_encode_basestring_ascii.<locals>.replacer)�ESCAPE_ASCIIr)rrrrr�py_encode_basestring_ascii0sr c	@sNeZdZdZdZdZddddddddd�dd	�Zd
d�Zdd
�Zddd�Z	dS)�JSONEncoderaZExtensible JSON <http://json.org> encoder for Python data structures.

    Supports the following objects and types by default:

    +-------------------+---------------+
    | Python            | JSON          |
    +===================+===============+
    | dict              | object        |
    +-------------------+---------------+
    | list, tuple       | array         |
    +-------------------+---------------+
    | str               | string        |
    +-------------------+---------------+
    | int, float        | number        |
    +-------------------+---------------+
    | True              | true          |
    +-------------------+---------------+
    | False             | false         |
    +-------------------+---------------+
    | None              | null          |
    +-------------------+---------------+

    To extend this to recognize other objects, subclass and implement a
    ``.default()`` method with another method that returns a serializable
    object for ``o`` if possible, otherwise it should call the superclass
    implementation (to raise ``TypeError``).

    z, z: FTN)�skipkeys�ensure_ascii�check_circular�	allow_nan�	sort_keys�indent�
separators�defaultc	CsZ||_||_||_||_||_||_|dk	r:|\|_|_n|dk	rHd|_|dk	rV||_dS)a�Constructor for JSONEncoder, with sensible defaults.

        If skipkeys is false, then it is a TypeError to attempt
        encoding of keys that are not str, int, float or None.  If
        skipkeys is True, such items are simply skipped.

        If ensure_ascii is true, the output is guaranteed to be str
        objects with all incoming non-ASCII characters escaped.  If
        ensure_ascii is false, the output can contain non-ASCII characters.

        If check_circular is true, then lists, dicts, and custom encoded
        objects will be checked for circular references during encoding to
        prevent an infinite recursion (which would cause an OverflowError).
        Otherwise, no such check takes place.

        If allow_nan is true, then NaN, Infinity, and -Infinity will be
        encoded as such.  This behavior is not JSON specification compliant,
        but is consistent with most JavaScript based encoders and decoders.
        Otherwise, it will be a ValueError to encode such floats.

        If sort_keys is true, then the output of dictionaries will be
        sorted by key; this is useful for regression tests to ensure
        that JSON serializations can be compared on a day-to-day basis.

        If indent is a non-negative integer, then JSON array
        elements and object members will be pretty-printed with that
        indent level.  An indent level of 0 will only insert newlines.
        None is the most compact representation.

        If specified, separators should be an (item_separator, key_separator)
        tuple.  The default is (', ', ': ') if *indent* is ``None`` and
        (',', ': ') otherwise.  To get the most compact JSON representation,
        you should specify (',', ':') to eliminate whitespace.

        If specified, default is a function that gets called for objects
        that can't otherwise be serialized.  It should return a JSON encodable
        version of the object or raise a ``TypeError``.

        N�,)	r"r#r$r%r&r'�item_separator�
key_separatorr))	�selfr"r#r$r%r&r'r(r)rrr�__init__hs+zJSONEncoder.__init__cCstd|jj��dS)alImplement this method in a subclass such that it returns
        a serializable object for ``o``, or calls the base implementation
        (to raise a ``TypeError``).

        For example, to support arbitrary iterators, you could
        implement default like this::

            def default(self, o):
                try:
                    iterable = iter(o)
                except TypeError:
                    pass
                else:
                    return list(iterable)
                # Let the base class default method raise the TypeError
                return JSONEncoder.default(self, o)

        z,Object of type '%s' is not JSON serializableN)�	TypeError�	__class__�__name__)r-�orrrr)�szJSONEncoder.defaultcCsNt|t�r |jrt|�St|�S|j|dd�}t|ttf�sDt|�}dj|�S)z�Return a JSON string representation of a Python data structure.

        >>> from json.encoder import JSONEncoder
        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
        '{"foo": ["bar", "baz"]}'

        T)�	_one_shot�)	�
isinstance�strr#rr�
iterencode�list�tuple�join)r-r2�chunksrrr�encode�s	
zJSONEncoder.encodecCs�|jri}nd}|jrt}nt}|jtjttfdd�}|rvtdk	rv|j	dkrvt||j
||j	|j|j|j
|j|j�	}n&t||j
||j	||j|j|j
|j|�
}||d�S)z�Encode the given object and yield each string
        representation as available.

        For example::

            for chunk in JSONEncoder().iterencode(bigobject):
                mysocket.write(chunk)

        NcSsJ||krd}n$||krd}n||kr*d}n||�S|sFtdt|���|S)NZNaNZInfinityz	-Infinityz2Out of range float values are not JSON compliant: )�
ValueError�repr)r2r%Z_reprZ_infZ_neginf�textrrr�floatstr�sz(JSONEncoder.iterencode.<locals>.floatstrr)r$r#rrr%�float�__repr__�INFINITY�c_make_encoderr'r)r,r+r&r"�_make_iterencode)r-r2r3�markers�_encoderr@�_iterencoderrrr7�s&


zJSONEncoder.iterencode)F)
r1�
__module__�__qualname__�__doc__r+r,r.r)r<r7rrrrr!Is6r!cs��dk	r����rd�����������	�
��������fdd��	���������	�
���
��������fdd����������	�
��������fdd���S)N� c	3s�|sdVdS�dk	r6�|�}|�kr.�d��|�|<d}�dk	rh|d7}d�|}�|}||7}nd}�}d}x�|D]�}|r�d}n|}�
|��r�|�|�Vqz|dkr�|dVqz|dkr�|d	Vqz|dkr�|d
Vqz�
|��r�|�|�Vqz�
|�
��r|�|�Vqz|V�
|��f��r:�||�}n"�
|�	��rR�||�}n
�||�}|EdHqzW|dk	�r�|d8}d�|VdV�dk	�r��|=dS)Nz[]zCircular reference detected�[�r	TF�null�true�false�]r)	Zlst�_current_indent_level�markeridZbuf�newline_indentZ	separator�first�valuer;)r=rG�	_floatstr�_indent�_intstr�_item_separatorrH�_iterencode_dict�_iterencode_list�dictrA�id�intr5r8rFr6r9rrr]s\






z*_make_iterencode.<locals>._iterencode_listc
3sL|sdVdS�dk	r6�|�}|�kr.�d��|�|<dV�dk	rh|d7}d�|}�|}|Vnd}�}d}�r�t|j�dd�d	�}n|j�}�xx|D�]n\}}�|��r�nr�|�
�rȈ|�}n^|dkr�d
}nP|dkr�d}nB|dkr�d
}n4�|���r�|�}n�
�rq�ntdt|�d��|�r2d}n|V�|�V�	V�|���r`�|�Vq�|dk�rrd
Vq�|dk�r�d
Vq�|dk�r�dVq��|���r��|�Vq��|�
��rƈ|�Vq��|��f��r�||�}	n"�|���r��||�}	n
�||�}	|	EdHq�W|dk	�r2|d8}d�|VdV�dk	�rH�|=dS)Nz{}zCircular reference detected�{rNr	TcSs|dS)Nrr)Zkvrrr�<lambda>asz<_make_iterencode.<locals>._iterencode_dict.<locals>.<lambda>)�keyrPFrQrOzkey z is not a string�})�sorted�itemsr/r>)
ZdctrSrTrUr+rVrfrcrWr;)r=rGrXrYrZr[rHr\r]�_key_separator�	_skipkeys�
_sort_keysr^rAr_r`r5r8rFr6r9rrr\Ms�










z*_make_iterencode.<locals>._iterencode_dictc3s�|��r�|�Vn�|dkr&dVn�|dkr6dVn�|dkrFdVn��|��r\�|�Vn��|�	�rr�|�Vn��|�
�f�r��||�EdHnj�|��r��||�EdHnN�dk	rֈ
|�}|�krΈd��|�|<�|�}�||�EdH�dk	r��|=dS)NrOTrPFrQzCircular reference detectedr)r2rSrT)r=�_defaultrGrXrZrHr\r]r^rAr_r`r5r8rFr6r9rrrH�s2



z%_make_iterencode.<locals>._iterencoder)rFrjrGrYrXrgr[rirhr3r=r^rAr_r`r5r8r6r9rZr)r=rjrGrXrYrZr[rHr\r]rgrhrir^rAr_r`r5r8rFr6r9rrEs.84O,rE)$rK�reZ_jsonrZc_encode_basestring_ascii�ImportErrorrZc_encode_basestringrrD�compilerrZHAS_UTF8r�range�i�
setdefault�chrrrArCrr �objectr!r=r^r_r`r5r8r6r9�__str__rErrrr�<module>sT





	
>PKq#�\������scanner.cpython-36.pycnu�[���3


 \o	�@sjdZddlZyddlmZWnek
r4dZYnXdgZejdejej	Bej
B�Zdd�ZepdeZdS)zJSON token scanner
�N)�make_scannerrz)(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?csv|j�	|j�|j�
tj�|j�|j�|j�|j�|j	�|j
�|j�����������	�
�fdd����fdd�}|S)Ncs�y||}Wntk
r(t|��YnX|dkrB�
||d��S|dkrd�	||df������S|dkr~�||df��S|dkr�|||d�dkr�d|dfS|dkr�|||d�d	kr�d
|dfS|dko�|||d�d
k�r�d|dfS�||�}|dk	�rX|j�\}}}|�s&|�rD�||�p2d|�p<d�}n�|�}||j�fS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r�d�|dfSt|��dS)N�"��{�[�n�Znull�t�trueT�f�ZfalseF��N�ZNaN�I�ZInfinity�-�	z	-Infinity)�
IndexError�
StopIteration�groups�end)�string�idxZnextchar�mZintegerZfracZexp�res)�
_scan_once�match_number�memo�object_hook�object_pairs_hook�parse_array�parse_constant�parse_float�	parse_int�parse_object�parse_string�strict��$/usr/lib64/python3.6/json/scanner.pyrs>

   z#py_make_scanner.<locals>._scan_oncec
sz
�||�S�j�XdS)N)�clear)rr)rrr(r)�	scan_onceAs
z"py_make_scanner.<locals>.scan_once)r%r!r&�	NUMBER_RE�matchr'r#r$r"rr r)�contextr+r()rrrrr r!r"r#r$r%r&r'r)�py_make_scanners"%r/)
�__doc__�reZ_jsonrZc_make_scanner�ImportError�__all__�compile�VERBOSE�	MULTILINE�DOTALLr,r/r(r(r(r)�<module>s
:PKq#�\������scanner.cpython-36.opt-1.pycnu�[���3


 \o	�@sjdZddlZyddlmZWnek
r4dZYnXdgZejdejej	Bej
B�Zdd�ZepdeZdS)zJSON token scanner
�N)�make_scannerrz)(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?csv|j�	|j�|j�
tj�|j�|j�|j�|j�|j	�|j
�|j�����������	�
�fdd����fdd�}|S)Ncs�y||}Wntk
r(t|��YnX|dkrB�
||d��S|dkrd�	||df������S|dkr~�||df��S|dkr�|||d�dkr�d|dfS|dkr�|||d�d	kr�d
|dfS|dko�|||d�d
k�r�d|dfS�||�}|dk	�rX|j�\}}}|�s&|�rD�||�p2d|�p<d�}n�|�}||j�fS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r�d�|dfSt|��dS)N�"��{�[�n�Znull�t�trueT�f�ZfalseF��N�ZNaN�I�ZInfinity�-�	z	-Infinity)�
IndexError�
StopIteration�groups�end)�string�idxZnextchar�mZintegerZfracZexp�res)�
_scan_once�match_number�memo�object_hook�object_pairs_hook�parse_array�parse_constant�parse_float�	parse_int�parse_object�parse_string�strict��$/usr/lib64/python3.6/json/scanner.pyrs>

   z#py_make_scanner.<locals>._scan_oncec
sz
�||�S�j�XdS)N)�clear)rr)rrr(r)�	scan_onceAs
z"py_make_scanner.<locals>.scan_once)r%r!r&�	NUMBER_RE�matchr'r#r$r"rr r)�contextr+r()rrrrr r!r"r#r$r%r&r'r)�py_make_scanners"%r/)
�__doc__�reZ_jsonrZc_make_scanner�ImportError�__all__�compile�VERBOSE�	MULTILINE�DOTALLr,r/r(r(r(r)�<module>s
:PKq#�\��]���scanner.cpython-36.opt-2.pycnu�[���3


 \o	�@sfddlZyddlmZWnek
r0dZYnXdgZejdejejBej	B�Z
dd�Zep`eZdS)�N)�make_scannerrz)(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?csv|j�	|j�|j�
tj�|j�|j�|j�|j�|j	�|j
�|j�����������	�
�fdd����fdd�}|S)Ncs�y||}Wntk
r(t|��YnX|dkrB�
||d��S|dkrd�	||df������S|dkr~�||df��S|dkr�|||d�dkr�d|dfS|dkr�|||d�d	kr�d
|dfS|dko�|||d�d
k�r�d|dfS�||�}|dk	�rX|j�\}}}|�s&|�rD�||�p2d|�p<d�}n�|�}||j�fS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r�d�|dfSt|��dS)N�"��{�[�n�Znull�t�trueT�f�ZfalseF��N�ZNaN�I�ZInfinity�-�	z	-Infinity)�
IndexError�
StopIteration�groups�end)�string�idxZnextchar�mZintegerZfracZexp�res)�
_scan_once�match_number�memo�object_hook�object_pairs_hook�parse_array�parse_constant�parse_float�	parse_int�parse_object�parse_string�strict��$/usr/lib64/python3.6/json/scanner.pyrs>

   z#py_make_scanner.<locals>._scan_oncec
sz
�||�S�j�XdS)N)�clear)rr)rrr(r)�	scan_onceAs
z"py_make_scanner.<locals>.scan_once)r%r!r&�	NUMBER_RE�matchr'r#r$r"rr r)�contextr+r()rrrrr r!r"r#r$r%r&r'r)�py_make_scanners"%r/)�reZ_jsonrZc_make_scanner�ImportError�__all__�compile�VERBOSE�	MULTILINE�DOTALLr,r/r(r(r(r)�<module>s
:PKq#�\=տtool.cpython-36.opt-1.pycnu�[���3


 \m�@s>dZddlZddlZddlZddlZdd�Zedkr:e�dS)aCommand-line tool to validate and pretty-print JSON

Usage::

    $ echo '{"json":"obj"}' | python -m json.tool
    {
        "json": "obj"
    }
    $ echo '{ 1.2:3.4}' | python -m json.tool
    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

�Nc	"Csd}d}tj||d�}|jddtj�dd�|jddtjd	�d
d�|jddd
dd�|j�}|jphtj}|jpttj	}|j
}|�Vy$|r�tj|�}ntj|t
jd�}Wn*tk
r�}zt|��WYdd}~XnXWdQRX|�"tj|||dd�|jd�WdQRXdS)Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)�prog�description�infile�?z-a JSON file to be validated or pretty-printed)�nargs�type�help�outfile�wz%write the output of infile to outfilez--sort-keys�
store_trueFz5sort the output of dictionaries alphabetically by key)�action�defaultr)Zobject_pairs_hook�)�	sort_keys�indent�
)�argparse�ArgumentParser�add_argumentZFileType�
parse_argsr�sys�stdinr	�stdoutr�json�load�collections�OrderedDict�
ValueError�
SystemExit�dump�write)	rr�parserZoptionsrr	r�obj�e�r$�!/usr/lib64/python3.6/json/tool.py�mains0
$r&�__main__)�__doc__rrrrr&�__name__r$r$r$r%�<module>sPKq#�\�.kW�&�&decoder.cpython-36.opt-1.pycnu�[���3


 \)1�@sdZddlZddlmZyddlmZWnek
r@dZYnXddgZej	ej
BejBZe
d�Ze
d�Ze
d	�ZGd
d�de�Zeeed�Zejde�Zd
dddddddd�Zdd�Zdeejfdd�Zep�eZejde�ZdZdejefdd�Zejefdd �ZGd!d�de�ZdS)"zImplementation of JSONDecoder
�N)�scanner)�
scanstring�JSONDecoder�JSONDecodeError�nan�infz-infc@s eZdZdZdd�Zdd�ZdS)ra Subclass of ValueError with the following additional properties:

    msg: The unformatted error message
    doc: The JSON document being parsed
    pos: The start index of doc where parsing failed
    lineno: The line corresponding to pos
    colno: The column corresponding to pos

    cCsb|jdd|�d}||jdd|�}d||||f}tj||�||_||_||_||_||_dS)N�
r�z%s: line %d column %d (char %d))	�count�rfind�
ValueError�__init__�msg�doc�pos�lineno�colno)�selfrrrrr�errmsg�r�$/usr/lib64/python3.6/json/decoder.pyr
szJSONDecodeError.__init__cCs|j|j|j|jffS)N)�	__class__rrr)rrrr�
__reduce__*szJSONDecodeError.__reduce__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrs	)z	-InfinityZInfinity�NaNz(.*?)(["\\\x00-\x1f])�"�\�/��r�
�	)rrr �b�f�n�r�tcCs`||d|d�}t|�dkrL|ddkrLy
t|d�Stk
rJYnXd}t|||��dS)Nr	��ZxX�zInvalid \uXXXX escape)�len�intrr)�sr�escrrrr�
_decode_uXXXX;s
r1TcCs�g}|j}|d}�x�|||�}|dkr4td||��|j�}|j�\}	}
|	rT||	�|
dkr`Pn.|
dkr�|r�dj|
�}t|||��n
||
�qy||}Wn tk
r�td||��YnX|dk�ry||}
Wn*tk
r�dj|�}t|||��YnX|d7}n�t||�}|d	7}d
|k�o.dkn�r�|||d�d
k�r�t||d�}d|k�ondkn�r�d|d
d>|dB}|d7}t|�}
||
�qWdj	|�|fS)a�Scan the string s for a JSON string. End is the index of the
    character in s after the quote that started the JSON string.
    Unescapes all valid JSON string escape sequences and raises ValueError
    on attempt to decode an invalid string. If strict is False then literal
    control characters are allowed in the string.

    Returns a tuple of the decoded string and the index of the character in s
    after the end quote.r	NzUnterminated string starting atrrz"Invalid control character {0!r} at�uzInvalid \escape: {0!r}r*i�i���z\ui�i��i�
��)
�appendr�end�groups�format�
IndexError�KeyErrorr1�chr�join)r/r8�strictZ_bZ_mZchunks�_appendZbegin�chunkZcontent�
terminatorrr0�charZuniZuni2rrr�
py_scanstringEsP






2rDz
[ \t\n\r]*z 	

c#Cs�|\}}	g}
|
j}|dkri}|j}||	|	d�}
|
dkr�|
|krb|||	�j�}	||	|	d�}
|
dkr�|dk	r�||
�}||	dfSi}
|dk	r�||
�}
|
|	dfS|
dkr�td||	��|	d7}	�x�t||	|�\}}	|||�}||	|	d�dk�r&|||	�j�}	||	|	d�dk�r&td||	��|	d7}	y:||	|k�rf|	d7}	||	|k�rf|||	d�j�}	Wntk
�r~YnXy|||	�\}}	Wn4tk
�r�}ztd||j�d�WYdd}~XnX|||f�y0||	}
|
|k�r|||	d�j�}	||	}
Wntk
�rd}
YnX|	d7}	|
dk�r6Pn|
d	k�rPtd
||	d��|||	�j�}	||	|	d�}
|	d7}	|
dkr�td||	d��q�W|dk	�r�||
�}||	fSt|
�}
|dk	�r�||
�}
|
|	fS)Nr	r�}z1Expecting property name enclosed in double quotes�:zExpecting ':' delimiterzExpecting valuer6�,zExpecting ',' delimiter)	r7�
setdefaultr8rrr;�
StopIteration�value�dict)�	s_and_endr?�	scan_once�object_hook�object_pairs_hook�memo�_w�_wsr/r8ZpairsZpairs_appendZmemo_get�nextchar�result�keyrJ�errrrr�
JSONObject�s�

"





rWcCsz|\}}g}|||d�}||krF|||d�j�}|||d�}|dkrZ||dfS|j}�xy|||�\}	}Wn2tk
r�}
ztd||
j�d�WYdd}
~
XnX||	�|||d�}||kr�|||d�j�}|||d�}|d7}|dk�rPn|dk�rtd||d��y:|||k�rT|d7}|||k�rT|||d�j�}Wqdtk
�rlYqdXqdW||fS)Nr	�]zExpecting valuerGzExpecting ',' delimiter)r8r7rIrrJr;)rLrMrQrRr/r8�valuesrSr@rJrVrrr�	JSONArray�s@"


rZc@s@eZdZdZddddddd�dd�Zejfdd�Zdd
d�ZdS)
raSimple JSON <http://json.org> decoder

    Performs the following translations in decoding by default:

    +---------------+-------------------+
    | JSON          | Python            |
    +===============+===================+
    | object        | dict              |
    +---------------+-------------------+
    | array         | list              |
    +---------------+-------------------+
    | string        | str               |
    +---------------+-------------------+
    | number (int)  | int               |
    +---------------+-------------------+
    | number (real) | float             |
    +---------------+-------------------+
    | true          | True              |
    +---------------+-------------------+
    | false         | False             |
    +---------------+-------------------+
    | null          | None              |
    +---------------+-------------------+

    It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
    their corresponding ``float`` values, which is outside the JSON spec.

    NT)rN�parse_float�	parse_int�parse_constantr?rOcCsZ||_|pt|_|pt|_|p"tj|_||_||_	t
|_t|_
t|_i|_tj|�|_dS)aD``object_hook``, if specified, will be called with the result
        of every JSON object decoded and its return value will be used in
        place of the given ``dict``.  This can be used to provide custom
        deserializations (e.g. to support JSON-RPC class hinting).

        ``object_pairs_hook``, if specified will be called with the result of
        every JSON object decoded with an ordered list of pairs.  The return
        value of ``object_pairs_hook`` will be used instead of the ``dict``.
        This feature can be used to implement custom decoders that rely on the
        order that the key and value pairs are decoded (for example,
        collections.OrderedDict will remember the order of insertion). If
        ``object_hook`` is also defined, the ``object_pairs_hook`` takes
        priority.

        ``parse_float``, if specified, will be called with the string
        of every JSON float to be decoded. By default this is equivalent to
        float(num_str). This can be used to use another datatype or parser
        for JSON floats (e.g. decimal.Decimal).

        ``parse_int``, if specified, will be called with the string
        of every JSON int to be decoded. By default this is equivalent to
        int(num_str). This can be used to use another datatype or parser
        for JSON integers (e.g. float).

        ``parse_constant``, if specified, will be called with one of the
        following strings: -Infinity, Infinity, NaN.
        This can be used to raise an exception if invalid JSON numbers
        are encountered.

        If ``strict`` is false (true is the default), then control
        characters will be allowed inside strings.  Control characters in
        this context are those with character codes in the 0-31 range,
        including ``'\t'`` (tab), ``'\n'``, ``'\r'`` and ``'\0'``.

        N)rN�floatr[r.r\�
_CONSTANTS�__getitem__r]r?rOrWZparse_objectrZZparse_arrayrZparse_stringrPrZmake_scannerrM)rrNr[r\r]r?rOrrrr
s&

zJSONDecoder.__init__cCsF|j|||d�j�d�\}}|||�j�}|t|�krBtd||��|S)zlReturn the Python representation of ``s`` (a ``str`` instance
        containing a JSON document).

        r)�idxz
Extra data)�
raw_decoder8r-r)rr/rQ�objr8rrr�decodeNs
zJSONDecoder.decodercCsPy|j||�\}}Wn2tk
rF}ztd||j�d�WYdd}~XnX||fS)a=Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.

        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.

        zExpecting valueN)rMrIrrJ)rr/rarcr8rVrrrrbYs
	"zJSONDecoder.raw_decode)r)	rrrrr
�
WHITESPACE�matchrdrbrrrrr�s1) r�reZjsonrZ_jsonrZc_scanstring�ImportError�__all__�VERBOSE�	MULTILINE�DOTALL�FLAGSr^rZPosInfZNegInfrrr_�compileZSTRINGCHUNKZ	BACKSLASHr1rfrDreZWHITESPACE_STRrWrZ�objectrrrrr�<module>s6

;P%PKq#�\����encoder.cpython-36.opt-2.pycnu�[���3


 \�>�"@s>ddlZyddlmZWnek
r0dZYnXyddlmZWnek
rZdZYnXyddlmZWnek
r�dZYnXej	d�Z
ej	d�Zej	d�Zdd	d
ddd
dd�Z
x&ed�D]Ze
jee�dje��q�Wed�Zdd�Zep�eZdd�Ze�peZGdd�de�Zeeeeeeeee ej!f
dd�Z"dS)�N)�encode_basestring_ascii)�encode_basestring)�make_encoderz[\x00-\x1f\\"\b\f\n\r\t]z([\\"]|[^\ -~])s[�-�]z\\z\"z\bz\fz\nz\rz\t)�\�"���
�
�	� z	\u{0:04x}�infcCsdd�}dtj||�dS)NcSst|jd�S)Nr)�
ESCAPE_DCT�group)�match�r�$/usr/lib64/python3.6/json/encoder.py�replace(sz%py_encode_basestring.<locals>.replacer)�ESCAPE�sub)�srrrr�py_encode_basestring$srcCsdd�}dtj||�dS)NcSsv|jd�}yt|Stk
rpt|�}|dkr<dj|�S|d8}d|d?d@B}d|d@B}dj||�SYnXdS)	Nriz	\u{0:04x}i��
i�i�z\u{0:04x}\u{1:04x})rr�KeyError�ord�format)rr�n�s1�s2rrrr4s

z+py_encode_basestring_ascii.<locals>.replacer)�ESCAPE_ASCIIr)rrrrr�py_encode_basestring_ascii0sr c	@sJeZdZdZdZddddddddd�dd�Zd	d
�Zdd�Zdd
d�ZdS)�JSONEncoderz, z: FTN)�skipkeys�ensure_ascii�check_circular�	allow_nan�	sort_keys�indent�
separators�defaultc	CsZ||_||_||_||_||_||_|dk	r:|\|_|_n|dk	rHd|_|dk	rV||_dS)N�,)	r"r#r$r%r&r'�item_separator�
key_separatorr))	�selfr"r#r$r%r&r'r(r)rrr�__init__hs+zJSONEncoder.__init__cCstd|jj��dS)Nz,Object of type '%s' is not JSON serializable)�	TypeError�	__class__�__name__)r-�orrrr)�szJSONEncoder.defaultcCsNt|t�r |jrt|�St|�S|j|dd�}t|ttf�sDt|�}dj|�S)NT)�	_one_shot�)	�
isinstance�strr#rr�
iterencode�list�tuple�join)r-r2�chunksrrr�encode�s	
zJSONEncoder.encodecCs�|jri}nd}|jrt}nt}|jtjttfdd�}|rvtdk	rv|j	dkrvt||j
||j	|j|j|j
|j|j�	}n&t||j
||j	||j|j|j
|j|�
}||d�S)NcSsJ||krd}n$||krd}n||kr*d}n||�S|sFtdt|���|S)NZNaNZInfinityz	-Infinityz2Out of range float values are not JSON compliant: )�
ValueError�repr)r2r%Z_reprZ_infZ_neginf�textrrr�floatstr�sz(JSONEncoder.iterencode.<locals>.floatstrr)r$r#rrr%�float�__repr__�INFINITY�c_make_encoderr'r)r,r+r&r"�_make_iterencode)r-r2r3�markers�_encoderr@�_iterencoderrrr7�s&


zJSONEncoder.iterencode)F)	r1�
__module__�__qualname__r+r,r.r)r<r7rrrrr!Is6r!cs��dk	r����rd�����������	�
��������fdd��	���������	�
���
��������fdd����������	�
��������fdd���S)N� c	3s�|sdVdS�dk	r6�|�}|�kr.�d��|�|<d}�dk	rh|d7}d�|}�|}||7}nd}�}d}x�|D]�}|r�d}n|}�
|��r�|�|�Vqz|dkr�|dVqz|dkr�|d	Vqz|dkr�|d
Vqz�
|��r�|�|�Vqz�
|�
��r|�|�Vqz|V�
|��f��r:�||�}n"�
|�	��rR�||�}n
�||�}|EdHqzW|dk	�r�|d8}d�|VdV�dk	�r��|=dS)Nz[]zCircular reference detected�[�r	TF�null�true�false�]r)	Zlst�_current_indent_level�markeridZbuf�newline_indentZ	separator�first�valuer;)r=rG�	_floatstr�_indent�_intstr�_item_separatorrH�_iterencode_dict�_iterencode_list�dictrA�id�intr5r8rFr6r9rrr\s\






z*_make_iterencode.<locals>._iterencode_listc
3sL|sdVdS�dk	r6�|�}|�kr.�d��|�|<dV�dk	rh|d7}d�|}�|}|Vnd}�}d}�r�t|j�dd�d	�}n|j�}�xx|D�]n\}}�|��r�nr�|�
�rȈ|�}n^|dkr�d
}nP|dkr�d}nB|dkr�d
}n4�|���r�|�}n�
�rq�ntdt|�d��|�r2d}n|V�|�V�	V�|���r`�|�Vq�|dk�rrd
Vq�|dk�r�d
Vq�|dk�r�dVq��|���r��|�Vq��|�
��rƈ|�Vq��|��f��r�||�}	n"�|���r��||�}	n
�||�}	|	EdHq�W|dk	�r2|d8}d�|VdV�dk	�rH�|=dS)Nz{}zCircular reference detected�{rMr	TcSs|dS)Nrr)Zkvrrr�<lambda>asz<_make_iterencode.<locals>._iterencode_dict.<locals>.<lambda>)�keyrOFrPrNzkey z is not a string�})�sorted�itemsr/r>)
ZdctrRrSrTr+rUrerbrVr;)r=rGrWrXrYrZrHr[r\�_key_separator�	_skipkeys�
_sort_keysr]rAr^r_r5r8rFr6r9rrr[Ms�










z*_make_iterencode.<locals>._iterencode_dictc3s�|��r�|�Vn�|dkr&dVn�|dkr6dVn�|dkrFdVn��|��r\�|�Vn��|�	�rr�|�Vn��|�
�f�r��||�EdHnj�|��r��||�EdHnN�dk	rֈ
|�}|�krΈd��|�|<�|�}�||�EdH�dk	r��|=dS)NrNTrOFrPzCircular reference detectedr)r2rRrS)r=�_defaultrGrWrYrHr[r\r]rAr^r_r5r8rFr6r9rrrH�s2



z%_make_iterencode.<locals>._iterencoder)rFrirGrXrWrfrZrhrgr3r=r]rAr^r_r5r8r6r9rYr)r=rirGrWrXrYrZrHr[r\rfrgrhr]rAr^r_r5r8rFr6r9rrEs.84O,rE)#�reZ_jsonrZc_encode_basestring_ascii�ImportErrorrZc_encode_basestringrrD�compilerrZHAS_UTF8r�range�i�
setdefault�chrrrArCrr �objectr!r=r]r^r_r5r8r6r9�__str__rErrrr�<module>sR





	
>PKq#�\f	n��decoder.cpython-36.opt-2.pycnu�[���3


 \)1�@sddlZddlmZyddlmZWnek
r<dZYnXddgZejej	Bej
BZed�Z
ed�Zed�ZGd	d�de�Zeee
d
�Zejde�Zdd
ddddddd�Zdd�Zdeejfdd�Zep�eZejde�ZdZdejefdd�Zejefdd�ZGd d�de�ZdS)!�N)�scanner)�
scanstring�JSONDecoder�JSONDecodeError�nan�infz-infc@seZdZdd�Zdd�ZdS)rcCsb|jdd|�d}||jdd|�}d||||f}tj||�||_||_||_||_||_dS)N�
r�z%s: line %d column %d (char %d))	�count�rfind�
ValueError�__init__�msg�doc�pos�lineno�colno)�selfrrrrr�errmsg�r�$/usr/lib64/python3.6/json/decoder.pyr
szJSONDecodeError.__init__cCs|j|j|j|jffS)N)�	__class__rrr)rrrr�
__reduce__*szJSONDecodeError.__reduce__N)�__name__�
__module__�__qualname__r
rrrrrrs)z	-InfinityZInfinity�NaNz(.*?)(["\\\x00-\x1f])�"�\�/��r�
�	)rrr�b�f�n�r�tcCs`||d|d�}t|�dkrL|ddkrLy
t|d�Stk
rJYnXd}t|||��dS)Nr	��ZxX�zInvalid \uXXXX escape)�len�intrr)�sr�escrrrr�
_decode_uXXXX;s
r0TcCs�g}|j}|d}�x�|||�}|dkr4td||��|j�}|j�\}	}
|	rT||	�|
dkr`Pn.|
dkr�|r�dj|
�}t|||��n
||
�qy||}Wn tk
r�td||��YnX|dk�ry||}
Wn*tk
r�dj|�}t|||��YnX|d7}n�t||�}|d7}d	|k�o.d
kn�r�|||d�dk�r�t||d�}d
|k�ondkn�r�d|d	d>|d
B}|d7}t|�}
||
�qWdj	|�|fS)Nr	zUnterminated string starting atrrz"Invalid control character {0!r} at�uzInvalid \escape: {0!r}r)i�i���z\ui�i��i�
��)
�appendr�end�groups�format�
IndexError�KeyErrorr0�chr�join)r.r7�strictZ_bZ_mZchunks�_appendZbegin�chunkZcontent�
terminatorrr/�charZuniZuni2rrr�
py_scanstringEsP






2rCz
[ \t\n\r]*z 	

c#Cs�|\}}	g}
|
j}|dkri}|j}||	|	d�}
|
dkr�|
|krb|||	�j�}	||	|	d�}
|
dkr�|dk	r�||
�}||	dfSi}
|dk	r�||
�}
|
|	dfS|
dkr�td||	��|	d7}	�x�t||	|�\}}	|||�}||	|	d�dk�r&|||	�j�}	||	|	d�dk�r&td||	��|	d7}	y:||	|k�rf|	d7}	||	|k�rf|||	d�j�}	Wntk
�r~YnXy|||	�\}}	Wn4tk
�r�}ztd||j�d�WYdd}~XnX|||f�y0||	}
|
|k�r|||	d�j�}	||	}
Wntk
�rd}
YnX|	d7}	|
dk�r6Pn|
d	k�rPtd
||	d��|||	�j�}	||	|	d�}
|	d7}	|
dkr�td||	d��q�W|dk	�r�||
�}||	fSt|
�}
|dk	�r�||
�}
|
|	fS)Nr	r�}z1Expecting property name enclosed in double quotes�:zExpecting ':' delimiterzExpecting valuer5�,zExpecting ',' delimiter)	r6�
setdefaultr7rrr:�
StopIteration�value�dict)�	s_and_endr>�	scan_once�object_hook�object_pairs_hook�memo�_w�_wsr.r7ZpairsZpairs_appendZmemo_get�nextchar�result�keyrI�errrrr�
JSONObject�s�

"





rVcCsz|\}}g}|||d�}||krF|||d�j�}|||d�}|dkrZ||dfS|j}�xy|||�\}	}Wn2tk
r�}
ztd||
j�d�WYdd}
~
XnX||	�|||d�}||kr�|||d�j�}|||d�}|d7}|dk�rPn|dk�rtd||d��y:|||k�rT|d7}|||k�rT|||d�j�}Wqdtk
�rlYqdXqdW||fS)Nr	�]zExpecting valuerFzExpecting ',' delimiter)r7r6rHrrIr:)rKrLrPrQr.r7�valuesrRr?rIrUrrr�	JSONArray�s@"


rYc@s<eZdZddddddd�dd�Zejfdd�Zdd	d
�ZdS)rNT)rM�parse_float�	parse_int�parse_constantr>rNcCsZ||_|pt|_|pt|_|p"tj|_||_||_	t
|_t|_
t|_i|_tj|�|_dS)N)rM�floatrZr-r[�
_CONSTANTS�__getitem__r\r>rNrVZparse_objectrYZparse_arrayrZparse_stringrOrZmake_scannerrL)rrMrZr[r\r>rNrrrr
s&

zJSONDecoder.__init__cCsF|j|||d�j�d�\}}|||�j�}|t|�krBtd||��|S)Nr)�idxz
Extra data)�
raw_decoder7r,r)rr.rP�objr7rrr�decodeNs
zJSONDecoder.decodercCsPy|j||�\}}Wn2tk
rF}ztd||j�d�WYdd}~XnX||fS)NzExpecting value)rLrHrrI)rr.r`rbr7rUrrrraYs
	"zJSONDecoder.raw_decode)r)rrrr
�
WHITESPACE�matchrcrarrrrr�s
1)�reZjsonrZ_jsonrZc_scanstring�ImportError�__all__�VERBOSE�	MULTILINE�DOTALL�FLAGSr]rZPosInfZNegInfrrr^�compileZSTRINGCHUNKZ	BACKSLASHr0rerCrdZWHITESPACE_STRrVrY�objectrrrrr�<module>s4

;P%PK86�\�W�~�~topics.cpython-38.opt-1.pycnu�[���U

e5d�s
�P@s�dddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(dd)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdN�OZdOS)PauThe "assert" statement
**********************

Assert statements are a convenient way to insert debugging assertions
into a program:

   assert_stmt ::= "assert" expression ["," expression]

The simple form, "assert expression", is equivalent to

   if __debug__:
       if not expression: raise AssertionError

The extended form, "assert expression1, expression2", is equivalent to

   if __debug__:
       if not expression1: raise AssertionError(expression2)

These equivalences assume that "__debug__" and "AssertionError" refer
to the built-in variables with those names.  In the current
implementation, the built-in variable "__debug__" is "True" under
normal circumstances, "False" when optimization is requested (command
line option "-O").  The current code generator emits no code for an
assert statement when optimization is requested at compile time.  Note
that it is unnecessary to include the source code for the expression
that failed in the error message; it will be displayed as part of the
stack trace.

Assignments to "__debug__" are illegal.  The value for the built-in
variable is determined when the interpreter starts.
u�,Assignment statements
*********************

Assignment statements are used to (re)bind names to values and to
modify attributes or items of mutable objects:

   assignment_stmt ::= (target_list "=")+ (starred_expression | yield_expression)
   target_list     ::= target ("," target)* [","]
   target          ::= identifier
              | "(" [target_list] ")"
              | "[" [target_list] "]"
              | attributeref
              | subscription
              | slicing
              | "*" target

(See section Primaries for the syntax definitions for *attributeref*,
*subscription*, and *slicing*.)

An assignment statement evaluates the expression list (remember that
this can be a single expression or a comma-separated list, the latter
yielding a tuple) and assigns the single resulting object to each of
the target lists, from left to right.

Assignment is defined recursively depending on the form of the target
(list). When a target is part of a mutable object (an attribute
reference, subscription or slicing), the mutable object must
ultimately perform the assignment and decide about its validity, and
may raise an exception if the assignment is unacceptable.  The rules
observed by various types and the exceptions raised are given with the
definition of the object types (see section The standard type
hierarchy).

Assignment of an object to a target list, optionally enclosed in
parentheses or square brackets, is recursively defined as follows.

* If the target list is a single target with no trailing comma,
  optionally in parentheses, the object is assigned to that target.

* Else: The object must be an iterable with the same number of items
  as there are targets in the target list, and the items are assigned,
  from left to right, to the corresponding targets.

  * If the target list contains one target prefixed with an asterisk,
    called a “starred” target: The object must be an iterable with at
    least as many items as there are targets in the target list, minus
    one.  The first items of the iterable are assigned, from left to
    right, to the targets before the starred target.  The final items
    of the iterable are assigned to the targets after the starred
    target.  A list of the remaining items in the iterable is then
    assigned to the starred target (the list can be empty).

  * Else: The object must be an iterable with the same number of items
    as there are targets in the target list, and the items are
    assigned, from left to right, to the corresponding targets.

Assignment of an object to a single target is recursively defined as
follows.

* If the target is an identifier (name):

  * If the name does not occur in a "global" or "nonlocal" statement
    in the current code block: the name is bound to the object in the
    current local namespace.

  * Otherwise: the name is bound to the object in the global namespace
    or the outer namespace determined by "nonlocal", respectively.

  The name is rebound if it was already bound.  This may cause the
  reference count for the object previously bound to the name to reach
  zero, causing the object to be deallocated and its destructor (if it
  has one) to be called.

* If the target is an attribute reference: The primary expression in
  the reference is evaluated.  It should yield an object with
  assignable attributes; if this is not the case, "TypeError" is
  raised.  That object is then asked to assign the assigned object to
  the given attribute; if it cannot perform the assignment, it raises
  an exception (usually but not necessarily "AttributeError").

  Note: If the object is a class instance and the attribute reference
  occurs on both sides of the assignment operator, the right-hand side
  expression, "a.x" can access either an instance attribute or (if no
  instance attribute exists) a class attribute.  The left-hand side
  target "a.x" is always set as an instance attribute, creating it if
  necessary.  Thus, the two occurrences of "a.x" do not necessarily
  refer to the same attribute: if the right-hand side expression
  refers to a class attribute, the left-hand side creates a new
  instance attribute as the target of the assignment:

     class Cls:
         x = 3             # class variable
     inst = Cls()
     inst.x = inst.x + 1   # writes inst.x as 4 leaving Cls.x as 3

  This description does not necessarily apply to descriptor
  attributes, such as properties created with "property()".

* If the target is a subscription: The primary expression in the
  reference is evaluated.  It should yield either a mutable sequence
  object (such as a list) or a mapping object (such as a dictionary).
  Next, the subscript expression is evaluated.

  If the primary is a mutable sequence object (such as a list), the
  subscript must yield an integer.  If it is negative, the sequence’s
  length is added to it.  The resulting value must be a nonnegative
  integer less than the sequence’s length, and the sequence is asked
  to assign the assigned object to its item with that index.  If the
  index is out of range, "IndexError" is raised (assignment to a
  subscripted sequence cannot add new items to a list).

  If the primary is a mapping object (such as a dictionary), the
  subscript must have a type compatible with the mapping’s key type,
  and the mapping is then asked to create a key/datum pair which maps
  the subscript to the assigned object.  This can either replace an
  existing key/value pair with the same key value, or insert a new
  key/value pair (if no key with the same value existed).

  For user-defined objects, the "__setitem__()" method is called with
  appropriate arguments.

* If the target is a slicing: The primary expression in the reference
  is evaluated.  It should yield a mutable sequence object (such as a
  list).  The assigned object should be a sequence object of the same
  type.  Next, the lower and upper bound expressions are evaluated,
  insofar they are present; defaults are zero and the sequence’s
  length.  The bounds should evaluate to integers. If either bound is
  negative, the sequence’s length is added to it.  The resulting
  bounds are clipped to lie between zero and the sequence’s length,
  inclusive.  Finally, the sequence object is asked to replace the
  slice with the items of the assigned sequence.  The length of the
  slice may be different from the length of the assigned sequence,
  thus changing the length of the target sequence, if the target
  sequence allows it.

**CPython implementation detail:** In the current implementation, the
syntax for targets is taken to be the same as for expressions, and
invalid syntax is rejected during the code generation phase, causing
less detailed error messages.

Although the definition of assignment implies that overlaps between
the left-hand side and the right-hand side are ‘simultaneous’ (for
example "a, b = b, a" swaps two variables), overlaps *within* the
collection of assigned-to variables occur left-to-right, sometimes
resulting in confusion.  For instance, the following program prints
"[0, 2]":

   x = [0, 1]
   i = 0
   i, x[i] = 1, 2         # i is updated, then x[i] is updated
   print(x)

See also:

  **PEP 3132** - Extended Iterable Unpacking
     The specification for the "*target" feature.


Augmented assignment statements
===============================

Augmented assignment is the combination, in a single statement, of a
binary operation and an assignment statement:

   augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)
   augtarget                 ::= identifier | attributeref | subscription | slicing
   augop                     ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
             | ">>=" | "<<=" | "&=" | "^=" | "|="

(See section Primaries for the syntax definitions of the last three
symbols.)

An augmented assignment evaluates the target (which, unlike normal
assignment statements, cannot be an unpacking) and the expression
list, performs the binary operation specific to the type of assignment
on the two operands, and assigns the result to the original target.
The target is only evaluated once.

An augmented assignment expression like "x += 1" can be rewritten as
"x = x + 1" to achieve a similar, but not exactly equal effect. In the
augmented version, "x" is only evaluated once. Also, when possible,
the actual operation is performed *in-place*, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.

Unlike normal assignments, augmented assignments evaluate the left-
hand side *before* evaluating the right-hand side.  For example, "a[i]
+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs
the addition, and lastly, it writes the result back to "a[i]".

With the exception of assigning to tuples and multiple targets in a
single statement, the assignment done by augmented assignment
statements is handled the same way as normal assignments. Similarly,
with the exception of the possible *in-place* behavior, the binary
operation performed by augmented assignment is the same as the normal
binary operations.

For targets which are attribute references, the same caveat about
class and instance attributes applies as for regular assignments.


Annotated assignment statements
===============================

*Annotation* assignment is the combination, in a single statement, of
a variable or attribute annotation and an optional assignment
statement:

   annotated_assignment_stmt ::= augtarget ":" expression
                                 ["=" (starred_expression | yield_expression)]

The difference from normal Assignment statements is that only single
target is allowed.

For simple names as assignment targets, if in class or module scope,
the annotations are evaluated and stored in a special class or module
attribute "__annotations__" that is a dictionary mapping from variable
names (mangled if private) to evaluated annotations. This attribute is
writable and is automatically created at the start of class or module
body execution, if annotations are found statically.

For expressions as assignment targets, the annotations are evaluated
if in class or module scope, but not stored.

If a name is annotated in a function scope, then this name is local
for that scope. Annotations are never evaluated and stored in function
scopes.

If the right hand side is present, an annotated assignment performs
the actual assignment before evaluating annotations (where
applicable). If the right hand side is not present for an expression
target, then the interpreter evaluates the target except for the last
"__setitem__()" or "__setattr__()" call.

See also:

  **PEP 526** - Syntax for Variable Annotations
     The proposal that added syntax for annotating the types of
     variables (including class variables and instance variables),
     instead of expressing them through comments.

  **PEP 484** - Type hints
     The proposal that added the "typing" module to provide a standard
     syntax for type annotations that can be used in static analysis
     tools and IDEs.

Changed in version 3.8: Now annotated assignments allow same
expressions in the right hand side as the regular assignments.
Previously, some expressions (like un-parenthesized tuple expressions)
caused a syntax error.
u>
Coroutines
**********

New in version 3.5.


Coroutine function definition
=============================

   async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")"
                     ["->" expression] ":" suite

Execution of Python coroutines can be suspended and resumed at many
points (see *coroutine*).  Inside the body of a coroutine function,
"await" and "async" identifiers become reserved keywords; "await"
expressions, "async for" and "async with" can only be used in
coroutine function bodies.

Functions defined with "async def" syntax are always coroutine
functions, even if they do not contain "await" or "async" keywords.

It is a "SyntaxError" to use a "yield from" expression inside the body
of a coroutine function.

An example of a coroutine function:

   async def func(param1, param2):
       do_stuff()
       await some_coroutine()


The "async for" statement
=========================

   async_for_stmt ::= "async" for_stmt

An *asynchronous iterable* is able to call asynchronous code in its
*iter* implementation, and *asynchronous iterator* can call
asynchronous code in its *next* method.

The "async for" statement allows convenient iteration over
asynchronous iterators.

The following code:

   async for TARGET in ITER:
       SUITE
   else:
       SUITE2

Is semantically equivalent to:

   iter = (ITER)
   iter = type(iter).__aiter__(iter)
   running = True

   while running:
       try:
           TARGET = await type(iter).__anext__(iter)
       except StopAsyncIteration:
           running = False
       else:
           SUITE
   else:
       SUITE2

See also "__aiter__()" and "__anext__()" for details.

It is a "SyntaxError" to use an "async for" statement outside the body
of a coroutine function.


The "async with" statement
==========================

   async_with_stmt ::= "async" with_stmt

An *asynchronous context manager* is a *context manager* that is able
to suspend execution in its *enter* and *exit* methods.

The following code:

   async with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   aexit = type(manager).__aexit__
   aenter = type(manager).__aenter__
   value = await aenter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not await aexit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           await aexit(manager, None, None, None)

See also "__aenter__()" and "__aexit__()" for details.

It is a "SyntaxError" to use an "async with" statement outside the
body of a coroutine function.

See also:

  **PEP 492** - Coroutines with async and await syntax
     The proposal that made coroutines a proper standalone concept in
     Python, and added supporting syntax.

-[ Footnotes ]-

[1] The exception is propagated to the invocation stack unless there
    is a "finally" clause which happens to raise another exception.
    That new exception causes the old one to be lost.

[2] A string literal appearing as the first statement in the function
    body is transformed into the function’s "__doc__" attribute and
    therefore the function’s *docstring*.

[3] A string literal appearing as the first statement in the class
    body is transformed into the namespace’s "__doc__" item and
    therefore the class’s *docstring*.
a�Identifiers (Names)
*******************

An identifier occurring as an atom is a name.  See section Identifiers
and keywords for lexical definition and section Naming and binding for
documentation of naming and binding.

When the name is bound to an object, evaluation of the atom yields
that object. When a name is not bound, an attempt to evaluate it
raises a "NameError" exception.

**Private name mangling:** When an identifier that textually occurs in
a class definition begins with two or more underscore characters and
does not end in two or more underscores, it is considered a *private
name* of that class. Private names are transformed to a longer form
before code is generated for them.  The transformation inserts the
class name, with leading underscores removed and a single underscore
inserted, in front of the name.  For example, the identifier "__spam"
occurring in a class named "Ham" will be transformed to "_Ham__spam".
This transformation is independent of the syntactical context in which
the identifier is used.  If the transformed name is extremely long
(longer than 255 characters), implementation defined truncation may
happen. If the class name consists only of underscores, no
transformation is done.
u
Literals
********

Python supports string and bytes literals and various numeric
literals:

   literal ::= stringliteral | bytesliteral
               | integer | floatnumber | imagnumber

Evaluation of a literal yields an object of the given type (string,
bytes, integer, floating point number, complex number) with the given
value.  The value may be approximated in the case of floating point
and imaginary (complex) literals.  See section Literals for details.

All literals correspond to immutable data types, and hence the
object’s identity is less important than its value.  Multiple
evaluations of literals with the same value (either the same
occurrence in the program text or a different occurrence) may obtain
the same object or a different object with the same value.
uA7Customizing attribute access
****************************

The following methods can be defined to customize the meaning of
attribute access (use of, assignment to, or deletion of "x.name") for
class instances.

object.__getattr__(self, name)

   Called when the default attribute access fails with an
   "AttributeError" (either "__getattribute__()" raises an
   "AttributeError" because *name* is not an instance attribute or an
   attribute in the class tree for "self"; or "__get__()" of a *name*
   property raises "AttributeError").  This method should either
   return the (computed) attribute value or raise an "AttributeError"
   exception.

   Note that if the attribute is found through the normal mechanism,
   "__getattr__()" is not called.  (This is an intentional asymmetry
   between "__getattr__()" and "__setattr__()".) This is done both for
   efficiency reasons and because otherwise "__getattr__()" would have
   no way to access other attributes of the instance.  Note that at
   least for instance variables, you can fake total control by not
   inserting any values in the instance attribute dictionary (but
   instead inserting them in another object).  See the
   "__getattribute__()" method below for a way to actually get total
   control over attribute access.

object.__getattribute__(self, name)

   Called unconditionally to implement attribute accesses for
   instances of the class. If the class also defines "__getattr__()",
   the latter will not be called unless "__getattribute__()" either
   calls it explicitly or raises an "AttributeError". This method
   should return the (computed) attribute value or raise an
   "AttributeError" exception. In order to avoid infinite recursion in
   this method, its implementation should always call the base class
   method with the same name to access any attributes it needs, for
   example, "object.__getattribute__(self, name)".

   Note:

     This method may still be bypassed when looking up special methods
     as the result of implicit invocation via language syntax or
     built-in functions. See Special method lookup.

   For certain sensitive attribute accesses, raises an auditing event
   "object.__getattr__" with arguments "obj" and "name".

object.__setattr__(self, name, value)

   Called when an attribute assignment is attempted.  This is called
   instead of the normal mechanism (i.e. store the value in the
   instance dictionary). *name* is the attribute name, *value* is the
   value to be assigned to it.

   If "__setattr__()" wants to assign to an instance attribute, it
   should call the base class method with the same name, for example,
   "object.__setattr__(self, name, value)".

   For certain sensitive attribute assignments, raises an auditing
   event "object.__setattr__" with arguments "obj", "name", "value".

object.__delattr__(self, name)

   Like "__setattr__()" but for attribute deletion instead of
   assignment.  This should only be implemented if "del obj.name" is
   meaningful for the object.

   For certain sensitive attribute deletions, raises an auditing event
   "object.__delattr__" with arguments "obj" and "name".

object.__dir__(self)

   Called when "dir()" is called on the object. A sequence must be
   returned. "dir()" converts the returned sequence to a list and
   sorts it.


Customizing module attribute access
===================================

Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
attribute and return the computed value or raise an "AttributeError".
If an attribute is not found on a module object through the normal
lookup, i.e. "object.__getattribute__()", then "__getattr__" is
searched in the module "__dict__" before raising an "AttributeError".
If found, it is called with the attribute name and the result is
returned.

The "__dir__" function should accept no arguments, and return a
sequence of strings that represents the names accessible on module. If
present, this function overrides the standard "dir()" search on a
module.

For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:

   import sys
   from types import ModuleType

   class VerboseModule(ModuleType):
       def __repr__(self):
           return f'Verbose {self.__name__}'

       def __setattr__(self, attr, value):
           print(f'Setting {attr}...')
           super().__setattr__(attr, value)

   sys.modules[__name__].__class__ = VerboseModule

Note:

  Defining module "__getattr__" and setting module "__class__" only
  affect lookups made using the attribute access syntax – directly
  accessing the module globals (whether by code within the module, or
  via a reference to the module’s globals dictionary) is unaffected.

Changed in version 3.5: "__class__" module attribute is now writable.

New in version 3.7: "__getattr__" and "__dir__" module attributes.

See also:

  **PEP 562** - Module __getattr__ and __dir__
     Describes the "__getattr__" and "__dir__" functions on modules.


Implementing Descriptors
========================

The following methods only apply when an instance of the class
containing the method (a so-called *descriptor* class) appears in an
*owner* class (the descriptor must be in either the owner’s class
dictionary or in the class dictionary for one of its parents).  In the
examples below, “the attribute” refers to the attribute whose name is
the key of the property in the owner class’ "__dict__".

object.__get__(self, instance, owner=None)

   Called to get the attribute of the owner class (class attribute
   access) or of an instance of that class (instance attribute
   access). The optional *owner* argument is the owner class, while
   *instance* is the instance that the attribute was accessed through,
   or "None" when the attribute is accessed through the *owner*.

   This method should return the computed attribute value or raise an
   "AttributeError" exception.

   **PEP 252** specifies that "__get__()" is callable with one or two
   arguments.  Python’s own built-in descriptors support this
   specification; however, it is likely that some third-party tools
   have descriptors that require both arguments.  Python’s own
   "__getattribute__()" implementation always passes in both arguments
   whether they are required or not.

object.__set__(self, instance, value)

   Called to set the attribute on an instance *instance* of the owner
   class to a new value, *value*.

   Note, adding "__set__()" or "__delete__()" changes the kind of
   descriptor to a “data descriptor”.  See Invoking Descriptors for
   more details.

object.__delete__(self, instance)

   Called to delete the attribute on an instance *instance* of the
   owner class.

object.__set_name__(self, owner, name)

   Called at the time the owning class *owner* is created. The
   descriptor has been assigned to *name*.

   Note:

     "__set_name__()" is only called implicitly as part of the "type"
     constructor, so it will need to be called explicitly with the
     appropriate parameters when a descriptor is added to a class
     after initial creation:

        class A:
           pass
        descr = custom_descriptor()
        A.attr = descr
        descr.__set_name__(A, 'attr')

     See Creating the class object for more details.

   New in version 3.6.

The attribute "__objclass__" is interpreted by the "inspect" module as
specifying the class where this object was defined (setting this
appropriately can assist in runtime introspection of dynamic class
attributes). For callables, it may indicate that an instance of the
given type (or a subclass) is expected or required as the first
positional argument (for example, CPython sets this attribute for
unbound methods that are implemented in C).


Invoking Descriptors
====================

In general, a descriptor is an object attribute with “binding
behavior”, one whose attribute access has been overridden by methods
in the descriptor protocol:  "__get__()", "__set__()", and
"__delete__()". If any of those methods are defined for an object, it
is said to be a descriptor.

The default behavior for attribute access is to get, set, or delete
the attribute from an object’s dictionary. For instance, "a.x" has a
lookup chain starting with "a.__dict__['x']", then
"type(a).__dict__['x']", and continuing through the base classes of
"type(a)" excluding metaclasses.

However, if the looked-up value is an object defining one of the
descriptor methods, then Python may override the default behavior and
invoke the descriptor method instead.  Where this occurs in the
precedence chain depends on which descriptor methods were defined and
how they were called.

The starting point for descriptor invocation is a binding, "a.x". How
the arguments are assembled depends on "a":

Direct Call
   The simplest and least common call is when user code directly
   invokes a descriptor method:    "x.__get__(a)".

Instance Binding
   If binding to an object instance, "a.x" is transformed into the
   call: "type(a).__dict__['x'].__get__(a, type(a))".

Class Binding
   If binding to a class, "A.x" is transformed into the call:
   "A.__dict__['x'].__get__(None, A)".

Super Binding
   If "a" is an instance of "super", then the binding "super(B,
   obj).m()" searches "obj.__class__.__mro__" for the base class "A"
   immediately preceding "B" and then invokes the descriptor with the
   call: "A.__dict__['m'].__get__(obj, obj.__class__)".

For instance bindings, the precedence of descriptor invocation depends
on which descriptor methods are defined.  A descriptor can define any
combination of "__get__()", "__set__()" and "__delete__()".  If it
does not define "__get__()", then accessing the attribute will return
the descriptor object itself unless there is a value in the object’s
instance dictionary.  If the descriptor defines "__set__()" and/or
"__delete__()", it is a data descriptor; if it defines neither, it is
a non-data descriptor.  Normally, data descriptors define both
"__get__()" and "__set__()", while non-data descriptors have just the
"__get__()" method.  Data descriptors with "__set__()" and "__get__()"
defined always override a redefinition in an instance dictionary.  In
contrast, non-data descriptors can be overridden by instances.

Python methods (including "staticmethod()" and "classmethod()") are
implemented as non-data descriptors.  Accordingly, instances can
redefine and override methods.  This allows individual instances to
acquire behaviors that differ from other instances of the same class.

The "property()" function is implemented as a data descriptor.
Accordingly, instances cannot override the behavior of a property.


__slots__
=========

*__slots__* allow us to explicitly declare data members (like
properties) and deny the creation of *__dict__* and *__weakref__*
(unless explicitly declared in *__slots__* or available in a parent.)

The space saved over using *__dict__* can be significant. Attribute
lookup speed can be significantly improved as well.

object.__slots__

   This class variable can be assigned a string, iterable, or sequence
   of strings with variable names used by instances.  *__slots__*
   reserves space for the declared variables and prevents the
   automatic creation of *__dict__* and *__weakref__* for each
   instance.


Notes on using *__slots__*
--------------------------

* When inheriting from a class without *__slots__*, the *__dict__* and
  *__weakref__* attribute of the instances will always be accessible.

* Without a *__dict__* variable, instances cannot be assigned new
  variables not listed in the *__slots__* definition.  Attempts to
  assign to an unlisted variable name raises "AttributeError". If
  dynamic assignment of new variables is desired, then add
  "'__dict__'" to the sequence of strings in the *__slots__*
  declaration.

* Without a *__weakref__* variable for each instance, classes defining
  *__slots__* do not support weak references to its instances. If weak
  reference support is needed, then add "'__weakref__'" to the
  sequence of strings in the *__slots__* declaration.

* *__slots__* are implemented at the class level by creating
  descriptors (Implementing Descriptors) for each variable name.  As a
  result, class attributes cannot be used to set default values for
  instance variables defined by *__slots__*; otherwise, the class
  attribute would overwrite the descriptor assignment.

* The action of a *__slots__* declaration is not limited to the class
  where it is defined.  *__slots__* declared in parents are available
  in child classes. However, child subclasses will get a *__dict__*
  and *__weakref__* unless they also define *__slots__* (which should
  only contain names of any *additional* slots).

* If a class defines a slot also defined in a base class, the instance
  variable defined by the base class slot is inaccessible (except by
  retrieving its descriptor directly from the base class). This
  renders the meaning of the program undefined.  In the future, a
  check may be added to prevent this.

* Nonempty *__slots__* does not work for classes derived from
  “variable-length” built-in types such as "int", "bytes" and "tuple".

* Any non-string iterable may be assigned to *__slots__*. Mappings may
  also be used; however, in the future, special meaning may be
  assigned to the values corresponding to each key.

* *__class__* assignment works only if both classes have the same
  *__slots__*.

* Multiple inheritance with multiple slotted parent classes can be
  used, but only one parent is allowed to have attributes created by
  slots (the other bases must have empty slot layouts) - violations
  raise "TypeError".

* If an iterator is used for *__slots__* then a descriptor is created
  for each of the iterator’s values. However, the *__slots__*
  attribute will be an empty iterator.
a�Attribute references
********************

An attribute reference is a primary followed by a period and a name:

   attributeref ::= primary "." identifier

The primary must evaluate to an object of a type that supports
attribute references, which most objects do.  This object is then
asked to produce the attribute whose name is the identifier.  This
production can be customized by overriding the "__getattr__()" method.
If this attribute is not available, the exception "AttributeError" is
raised.  Otherwise, the type and value of the object produced is
determined by the object.  Multiple evaluations of the same attribute
reference may yield different objects.
a�Augmented assignment statements
*******************************

Augmented assignment is the combination, in a single statement, of a
binary operation and an assignment statement:

   augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)
   augtarget                 ::= identifier | attributeref | subscription | slicing
   augop                     ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
             | ">>=" | "<<=" | "&=" | "^=" | "|="

(See section Primaries for the syntax definitions of the last three
symbols.)

An augmented assignment evaluates the target (which, unlike normal
assignment statements, cannot be an unpacking) and the expression
list, performs the binary operation specific to the type of assignment
on the two operands, and assigns the result to the original target.
The target is only evaluated once.

An augmented assignment expression like "x += 1" can be rewritten as
"x = x + 1" to achieve a similar, but not exactly equal effect. In the
augmented version, "x" is only evaluated once. Also, when possible,
the actual operation is performed *in-place*, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.

Unlike normal assignments, augmented assignments evaluate the left-
hand side *before* evaluating the right-hand side.  For example, "a[i]
+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs
the addition, and lastly, it writes the result back to "a[i]".

With the exception of assigning to tuples and multiple targets in a
single statement, the assignment done by augmented assignment
statements is handled the same way as normal assignments. Similarly,
with the exception of the possible *in-place* behavior, the binary
operation performed by augmented assignment is the same as the normal
binary operations.

For targets which are attribute references, the same caveat about
class and instance attributes applies as for regular assignments.
z�Await expression
****************

Suspend the execution of *coroutine* on an *awaitable* object. Can
only be used inside a *coroutine function*.

   await_expr ::= "await" primary

New in version 3.5.
ujBinary arithmetic operations
****************************

The binary arithmetic operations have the conventional priority
levels.  Note that some of these operations also apply to certain non-
numeric types.  Apart from the power operator, there are only two
levels, one for multiplicative operators and one for additive
operators:

   m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |
              m_expr "//" u_expr | m_expr "/" u_expr |
              m_expr "%" u_expr
   a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr

The "*" (multiplication) operator yields the product of its arguments.
The arguments must either both be numbers, or one argument must be an
integer and the other must be a sequence. In the former case, the
numbers are converted to a common type and then multiplied together.
In the latter case, sequence repetition is performed; a negative
repetition factor yields an empty sequence.

The "@" (at) operator is intended to be used for matrix
multiplication.  No builtin Python types implement this operator.

New in version 3.5.

The "/" (division) and "//" (floor division) operators yield the
quotient of their arguments.  The numeric arguments are first
converted to a common type. Division of integers yields a float, while
floor division of integers results in an integer; the result is that
of mathematical division with the ‘floor’ function applied to the
result.  Division by zero raises the "ZeroDivisionError" exception.

The "%" (modulo) operator yields the remainder from the division of
the first argument by the second.  The numeric arguments are first
converted to a common type.  A zero right argument raises the
"ZeroDivisionError" exception.  The arguments may be floating point
numbers, e.g., "3.14%0.7" equals "0.34" (since "3.14" equals "4*0.7 +
0.34".)  The modulo operator always yields a result with the same sign
as its second operand (or zero); the absolute value of the result is
strictly smaller than the absolute value of the second operand [1].

The floor division and modulo operators are connected by the following
identity: "x == (x//y)*y + (x%y)".  Floor division and modulo are also
connected with the built-in function "divmod()": "divmod(x, y) ==
(x//y, x%y)". [2].

In addition to performing the modulo operation on numbers, the "%"
operator is also overloaded by string objects to perform old-style
string formatting (also known as interpolation).  The syntax for
string formatting is described in the Python Library Reference,
section printf-style String Formatting.

The floor division operator, the modulo operator, and the "divmod()"
function are not defined for complex numbers.  Instead, convert to a
floating point number using the "abs()" function if appropriate.

The "+" (addition) operator yields the sum of its arguments.  The
arguments must either both be numbers or both be sequences of the same
type.  In the former case, the numbers are converted to a common type
and then added together. In the latter case, the sequences are
concatenated.

The "-" (subtraction) operator yields the difference of its arguments.
The numeric arguments are first converted to a common type.
a$Binary bitwise operations
*************************

Each of the three bitwise operations has a different priority level:

   and_expr ::= shift_expr | and_expr "&" shift_expr
   xor_expr ::= and_expr | xor_expr "^" and_expr
   or_expr  ::= xor_expr | or_expr "|" xor_expr

The "&" operator yields the bitwise AND of its arguments, which must
be integers.

The "^" operator yields the bitwise XOR (exclusive OR) of its
arguments, which must be integers.

The "|" operator yields the bitwise (inclusive) OR of its arguments,
which must be integers.
u�Code Objects
************

Code objects are used by the implementation to represent “pseudo-
compiled” executable Python code such as a function body. They differ
from function objects because they don’t contain a reference to their
global execution environment.  Code objects are returned by the built-
in "compile()" function and can be extracted from function objects
through their "__code__" attribute. See also the "code" module.

Accessing "__code__" raises an auditing event "object.__getattr__"
with arguments "obj" and ""__code__"".

A code object can be executed or evaluated by passing it (instead of a
source string) to the "exec()" or "eval()"  built-in functions.

See The standard type hierarchy for more information.
a.The Ellipsis Object
*******************

This object is commonly used by slicing (see Slicings).  It supports
no special operations.  There is exactly one ellipsis object, named
"Ellipsis" (a built-in name).  "type(Ellipsis)()" produces the
"Ellipsis" singleton.

It is written as "Ellipsis" or "...".
uThe Null Object
***************

This object is returned by functions that don’t explicitly return a
value.  It supports no special operations.  There is exactly one null
object, named "None" (a built-in name).  "type(None)()" produces the
same singleton.

It is written as "None".
u5Type Objects
************

Type objects represent the various object types.  An object’s type is
accessed by the built-in function "type()".  There are no special
operations on types.  The standard module "types" defines names for
all standard built-in types.

Types are written like this: "<class 'int'>".
a�Boolean operations
******************

   or_test  ::= and_test | or_test "or" and_test
   and_test ::= not_test | and_test "and" not_test
   not_test ::= comparison | "not" not_test

In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are interpreted
as false: "False", "None", numeric zero of all types, and empty
strings and containers (including strings, tuples, lists,
dictionaries, sets and frozensets).  All other values are interpreted
as true.  User-defined objects can customize their truth value by
providing a "__bool__()" method.

The operator "not" yields "True" if its argument is false, "False"
otherwise.

The expression "x and y" first evaluates *x*; if *x* is false, its
value is returned; otherwise, *y* is evaluated and the resulting value
is returned.

The expression "x or y" first evaluates *x*; if *x* is true, its value
is returned; otherwise, *y* is evaluated and the resulting value is
returned.

Note that neither "and" nor "or" restrict the value and type they
return to "False" and "True", but rather return the last evaluated
argument.  This is sometimes useful, e.g., if "s" is a string that
should be replaced by a default value if it is empty, the expression
"s or 'foo'" yields the desired value.  Because "not" has to create a
new value, it returns a boolean value regardless of the type of its
argument (for example, "not 'foo'" produces "False" rather than "''".)
a$The "break" statement
*********************

   break_stmt ::= "break"

"break" may only occur syntactically nested in a "for" or "while"
loop, but not nested in a function or class definition within that
loop.

It terminates the nearest enclosing loop, skipping the optional "else"
clause if the loop has one.

If a "for" loop is terminated by "break", the loop control target
keeps its current value.

When "break" passes control out of a "try" statement with a "finally"
clause, that "finally" clause is executed before really leaving the
loop.
uEmulating callable objects
**************************

object.__call__(self[, args...])

   Called when the instance is “called” as a function; if this method
   is defined, "x(arg1, arg2, ...)" roughly translates to
   "type(x).__call__(x, arg1, ...)".
u�Calls
*****

A call calls a callable object (e.g., a *function*) with a possibly
empty series of *arguments*:

   call                 ::= primary "(" [argument_list [","] | comprehension] ")"
   argument_list        ::= positional_arguments ["," starred_and_keywords]
                       ["," keywords_arguments]
                     | starred_and_keywords ["," keywords_arguments]
                     | keywords_arguments
   positional_arguments ::= positional_item ("," positional_item)*
   positional_item      ::= assignment_expression | "*" expression
   starred_and_keywords ::= ("*" expression | keyword_item)
                            ("," "*" expression | "," keyword_item)*
   keywords_arguments   ::= (keyword_item | "**" expression)
                          ("," keyword_item | "," "**" expression)*
   keyword_item         ::= identifier "=" expression

An optional trailing comma may be present after the positional and
keyword arguments but does not affect the semantics.

The primary must evaluate to a callable object (user-defined
functions, built-in functions, methods of built-in objects, class
objects, methods of class instances, and all objects having a
"__call__()" method are callable).  All argument expressions are
evaluated before the call is attempted.  Please refer to section
Function definitions for the syntax of formal *parameter* lists.

If keyword arguments are present, they are first converted to
positional arguments, as follows.  First, a list of unfilled slots is
created for the formal parameters.  If there are N positional
arguments, they are placed in the first N slots.  Next, for each
keyword argument, the identifier is used to determine the
corresponding slot (if the identifier is the same as the first formal
parameter name, the first slot is used, and so on).  If the slot is
already filled, a "TypeError" exception is raised. Otherwise, the
value of the argument is placed in the slot, filling it (even if the
expression is "None", it fills the slot).  When all arguments have
been processed, the slots that are still unfilled are filled with the
corresponding default value from the function definition.  (Default
values are calculated, once, when the function is defined; thus, a
mutable object such as a list or dictionary used as default value will
be shared by all calls that don’t specify an argument value for the
corresponding slot; this should usually be avoided.)  If there are any
unfilled slots for which no default value is specified, a "TypeError"
exception is raised.  Otherwise, the list of filled slots is used as
the argument list for the call.

**CPython implementation detail:** An implementation may provide
built-in functions whose positional parameters do not have names, even
if they are ‘named’ for the purpose of documentation, and which
therefore cannot be supplied by keyword.  In CPython, this is the case
for functions implemented in C that use "PyArg_ParseTuple()" to parse
their arguments.

If there are more positional arguments than there are formal parameter
slots, a "TypeError" exception is raised, unless a formal parameter
using the syntax "*identifier" is present; in this case, that formal
parameter receives a tuple containing the excess positional arguments
(or an empty tuple if there were no excess positional arguments).

If any keyword argument does not correspond to a formal parameter
name, a "TypeError" exception is raised, unless a formal parameter
using the syntax "**identifier" is present; in this case, that formal
parameter receives a dictionary containing the excess keyword
arguments (using the keywords as keys and the argument values as
corresponding values), or a (new) empty dictionary if there were no
excess keyword arguments.

If the syntax "*expression" appears in the function call, "expression"
must evaluate to an *iterable*.  Elements from these iterables are
treated as if they were additional positional arguments.  For the call
"f(x1, x2, *y, x3, x4)", if *y* evaluates to a sequence *y1*, …, *yM*,
this is equivalent to a call with M+4 positional arguments *x1*, *x2*,
*y1*, …, *yM*, *x3*, *x4*.

A consequence of this is that although the "*expression" syntax may
appear *after* explicit keyword arguments, it is processed *before*
the keyword arguments (and any "**expression" arguments – see below).
So:

   >>> def f(a, b):
   ...     print(a, b)
   ...
   >>> f(b=1, *(2,))
   2 1
   >>> f(a=1, *(2,))
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: f() got multiple values for keyword argument 'a'
   >>> f(1, *(2,))
   1 2

It is unusual for both keyword arguments and the "*expression" syntax
to be used in the same call, so in practice this confusion does not
arise.

If the syntax "**expression" appears in the function call,
"expression" must evaluate to a *mapping*, the contents of which are
treated as additional keyword arguments.  If a keyword is already
present (as an explicit keyword argument, or from another unpacking),
a "TypeError" exception is raised.

Formal parameters using the syntax "*identifier" or "**identifier"
cannot be used as positional argument slots or as keyword argument
names.

Changed in version 3.5: Function calls accept any number of "*" and
"**" unpackings, positional arguments may follow iterable unpackings
("*"), and keyword arguments may follow dictionary unpackings ("**").
Originally proposed by **PEP 448**.

A call always returns some value, possibly "None", unless it raises an
exception.  How this value is computed depends on the type of the
callable object.

If it is—

a user-defined function:
   The code block for the function is executed, passing it the
   argument list.  The first thing the code block will do is bind the
   formal parameters to the arguments; this is described in section
   Function definitions.  When the code block executes a "return"
   statement, this specifies the return value of the function call.

a built-in function or method:
   The result is up to the interpreter; see Built-in Functions for the
   descriptions of built-in functions and methods.

a class object:
   A new instance of that class is returned.

a class instance method:
   The corresponding user-defined function is called, with an argument
   list that is one longer than the argument list of the call: the
   instance becomes the first argument.

a class instance:
   The class must define a "__call__()" method; the effect is then the
   same as if that method was called.
uClass definitions
*****************

A class definition defines a class object (see section The standard
type hierarchy):

   classdef    ::= [decorators] "class" classname [inheritance] ":" suite
   inheritance ::= "(" [argument_list] ")"
   classname   ::= identifier

A class definition is an executable statement.  The inheritance list
usually gives a list of base classes (see Metaclasses for more
advanced uses), so each item in the list should evaluate to a class
object which allows subclassing.  Classes without an inheritance list
inherit, by default, from the base class "object"; hence,

   class Foo:
       pass

is equivalent to

   class Foo(object):
       pass

The class’s suite is then executed in a new execution frame (see
Naming and binding), using a newly created local namespace and the
original global namespace. (Usually, the suite contains mostly
function definitions.)  When the class’s suite finishes execution, its
execution frame is discarded but its local namespace is saved. [3] A
class object is then created using the inheritance list for the base
classes and the saved local namespace for the attribute dictionary.
The class name is bound to this class object in the original local
namespace.

The order in which attributes are defined in the class body is
preserved in the new class’s "__dict__".  Note that this is reliable
only right after the class is created and only for classes that were
defined using the definition syntax.

Class creation can be customized heavily using metaclasses.

Classes can also be decorated: just like when decorating functions,

   @f1(arg)
   @f2
   class Foo: pass

is roughly equivalent to

   class Foo: pass
   Foo = f1(arg)(f2(Foo))

The evaluation rules for the decorator expressions are the same as for
function decorators.  The result is then bound to the class name.

**Programmer’s note:** Variables defined in the class definition are
class attributes; they are shared by instances.  Instance attributes
can be set in a method with "self.name = value".  Both class and
instance attributes are accessible through the notation “"self.name"”,
and an instance attribute hides a class attribute with the same name
when accessed in this way.  Class attributes can be used as defaults
for instance attributes, but using mutable values there can lead to
unexpected results.  Descriptors can be used to create instance
variables with different implementation details.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     The proposal that changed the declaration of metaclasses to the
     current syntax, and the semantics for how classes with
     metaclasses are constructed.

  **PEP 3129** - Class Decorators
     The proposal that added class decorators.  Function and method
     decorators were introduced in **PEP 318**.
u�'Comparisons
***********

Unlike C, all comparison operations in Python have the same priority,
which is lower than that of any arithmetic, shifting or bitwise
operation.  Also unlike C, expressions like "a < b < c" have the
interpretation that is conventional in mathematics:

   comparison    ::= or_expr (comp_operator or_expr)*
   comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="
                     | "is" ["not"] | ["not"] "in"

Comparisons yield boolean values: "True" or "False".

Comparisons can be chained arbitrarily, e.g., "x < y <= z" is
equivalent to "x < y and y <= z", except that "y" is evaluated only
once (but in both cases "z" is not evaluated at all when "x < y" is
found to be false).

Formally, if *a*, *b*, *c*, …, *y*, *z* are expressions and *op1*,
*op2*, …, *opN* are comparison operators, then "a op1 b op2 c ... y
opN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except
that each expression is evaluated at most once.

Note that "a op1 b op2 c" doesn’t imply any kind of comparison between
*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though
perhaps not pretty).


Value comparisons
=================

The operators "<", ">", "==", ">=", "<=", and "!=" compare the values
of two objects.  The objects do not need to have the same type.

Chapter Objects, values and types states that objects have a value (in
addition to type and identity).  The value of an object is a rather
abstract notion in Python: For example, there is no canonical access
method for an object’s value.  Also, there is no requirement that the
value of an object should be constructed in a particular way, e.g.
comprised of all its data attributes. Comparison operators implement a
particular notion of what the value of an object is.  One can think of
them as defining the value of an object indirectly, by means of their
comparison implementation.

Because all types are (direct or indirect) subtypes of "object", they
inherit the default comparison behavior from "object".  Types can
customize their comparison behavior by implementing *rich comparison
methods* like "__lt__()", described in Basic customization.

The default behavior for equality comparison ("==" and "!=") is based
on the identity of the objects.  Hence, equality comparison of
instances with the same identity results in equality, and equality
comparison of instances with different identities results in
inequality.  A motivation for this default behavior is the desire that
all objects should be reflexive (i.e. "x is y" implies "x == y").

A default order comparison ("<", ">", "<=", and ">=") is not provided;
an attempt raises "TypeError".  A motivation for this default behavior
is the lack of a similar invariant as for equality.

The behavior of the default equality comparison, that instances with
different identities are always unequal, may be in contrast to what
types will need that have a sensible definition of object value and
value-based equality.  Such types will need to customize their
comparison behavior, and in fact, a number of built-in types have done
that.

The following list describes the comparison behavior of the most
important built-in types.

* Numbers of built-in numeric types (Numeric Types — int, float,
  complex) and of the standard library types "fractions.Fraction" and
  "decimal.Decimal" can be compared within and across their types,
  with the restriction that complex numbers do not support order
  comparison.  Within the limits of the types involved, they compare
  mathematically (algorithmically) correct without loss of precision.

  The not-a-number values "float('NaN')" and "decimal.Decimal('NaN')"
  are special.  Any ordered comparison of a number to a not-a-number
  value is false. A counter-intuitive implication is that not-a-number
  values are not equal to themselves.  For example, if "x =
  float('NaN')", "3 < x", "x < 3" and "x == x" are all false, while "x
  != x" is true.  This behavior is compliant with IEEE 754.

* "None" and "NotImplemented" are singletons.  **PEP 8** advises that
  comparisons for singletons should always be done with "is" or "is
  not", never the equality operators.

* Binary sequences (instances of "bytes" or "bytearray") can be
  compared within and across their types.  They compare
  lexicographically using the numeric values of their elements.

* Strings (instances of "str") compare lexicographically using the
  numerical Unicode code points (the result of the built-in function
  "ord()") of their characters. [3]

  Strings and binary sequences cannot be directly compared.

* Sequences (instances of "tuple", "list", or "range") can be compared
  only within each of their types, with the restriction that ranges do
  not support order comparison.  Equality comparison across these
  types results in inequality, and ordering comparison across these
  types raises "TypeError".

  Sequences compare lexicographically using comparison of
  corresponding elements.  The built-in containers typically assume
  identical objects are equal to themselves.  That lets them bypass
  equality tests for identical objects to improve performance and to
  maintain their internal invariants.

  Lexicographical comparison between built-in collections works as
  follows:

  * For two collections to compare equal, they must be of the same
    type, have the same length, and each pair of corresponding
    elements must compare equal (for example, "[1,2] == (1,2)" is
    false because the type is not the same).

  * Collections that support order comparison are ordered the same as
    their first unequal elements (for example, "[1,2,x] <= [1,2,y]"
    has the same value as "x <= y").  If a corresponding element does
    not exist, the shorter collection is ordered first (for example,
    "[1,2] < [1,2,3]" is true).

* Mappings (instances of "dict") compare equal if and only if they
  have equal *(key, value)* pairs. Equality comparison of the keys and
  values enforces reflexivity.

  Order comparisons ("<", ">", "<=", and ">=") raise "TypeError".

* Sets (instances of "set" or "frozenset") can be compared within and
  across their types.

  They define order comparison operators to mean subset and superset
  tests.  Those relations do not define total orderings (for example,
  the two sets "{1,2}" and "{2,3}" are not equal, nor subsets of one
  another, nor supersets of one another).  Accordingly, sets are not
  appropriate arguments for functions which depend on total ordering
  (for example, "min()", "max()", and "sorted()" produce undefined
  results given a list of sets as inputs).

  Comparison of sets enforces reflexivity of its elements.

* Most other built-in types have no comparison methods implemented, so
  they inherit the default comparison behavior.

User-defined classes that customize their comparison behavior should
follow some consistency rules, if possible:

* Equality comparison should be reflexive. In other words, identical
  objects should compare equal:

     "x is y" implies "x == y"

* Comparison should be symmetric. In other words, the following
  expressions should have the same result:

     "x == y" and "y == x"

     "x != y" and "y != x"

     "x < y" and "y > x"

     "x <= y" and "y >= x"

* Comparison should be transitive. The following (non-exhaustive)
  examples illustrate that:

     "x > y and y > z" implies "x > z"

     "x < y and y <= z" implies "x < z"

* Inverse comparison should result in the boolean negation. In other
  words, the following expressions should have the same result:

     "x == y" and "not x != y"

     "x < y" and "not x >= y" (for total ordering)

     "x > y" and "not x <= y" (for total ordering)

  The last two expressions apply to totally ordered collections (e.g.
  to sequences, but not to sets or mappings). See also the
  "total_ordering()" decorator.

* The "hash()" result should be consistent with equality. Objects that
  are equal should either have the same hash value, or be marked as
  unhashable.

Python does not enforce these consistency rules. In fact, the
not-a-number values are an example for not following these rules.


Membership test operations
==========================

The operators "in" and "not in" test for membership.  "x in s"
evaluates to "True" if *x* is a member of *s*, and "False" otherwise.
"x not in s" returns the negation of "x in s".  All built-in sequences
and set types support this as well as dictionary, for which "in" tests
whether the dictionary has a given key. For container types such as
list, tuple, set, frozenset, dict, or collections.deque, the
expression "x in y" is equivalent to "any(x is e or x == e for e in
y)".

For the string and bytes types, "x in y" is "True" if and only if *x*
is a substring of *y*.  An equivalent test is "y.find(x) != -1".
Empty strings are always considered to be a substring of any other
string, so """ in "abc"" will return "True".

For user-defined classes which define the "__contains__()" method, "x
in y" returns "True" if "y.__contains__(x)" returns a true value, and
"False" otherwise.

For user-defined classes which do not define "__contains__()" but do
define "__iter__()", "x in y" is "True" if some value "z", for which
the expression "x is z or x == z" is true, is produced while iterating
over "y". If an exception is raised during the iteration, it is as if
"in" raised that exception.

Lastly, the old-style iteration protocol is tried: if a class defines
"__getitem__()", "x in y" is "True" if and only if there is a non-
negative integer index *i* such that "x is y[i] or x == y[i]", and no
lower integer index raises the "IndexError" exception.  (If any other
exception is raised, it is as if "in" raised that exception).

The operator "not in" is defined to have the inverse truth value of
"in".


Identity comparisons
====================

The operators "is" and "is not" test for an object’s identity: "x is
y" is true if and only if *x* and *y* are the same object.  An
Object’s identity is determined using the "id()" function.  "x is not
y" yields the inverse truth value. [4]
u�lCompound statements
*******************

Compound statements contain (groups of) other statements; they affect
or control the execution of those other statements in some way.  In
general, compound statements span multiple lines, although in simple
incarnations a whole compound statement may be contained in one line.

The "if", "while" and "for" statements implement traditional control
flow constructs.  "try" specifies exception handlers and/or cleanup
code for a group of statements, while the "with" statement allows the
execution of initialization and finalization code around a block of
code.  Function and class definitions are also syntactically compound
statements.

A compound statement consists of one or more ‘clauses.’  A clause
consists of a header and a ‘suite.’  The clause headers of a
particular compound statement are all at the same indentation level.
Each clause header begins with a uniquely identifying keyword and ends
with a colon.  A suite is a group of statements controlled by a
clause.  A suite can be one or more semicolon-separated simple
statements on the same line as the header, following the header’s
colon, or it can be one or more indented statements on subsequent
lines.  Only the latter form of a suite can contain nested compound
statements; the following is illegal, mostly because it wouldn’t be
clear to which "if" clause a following "else" clause would belong:

   if test1: if test2: print(x)

Also note that the semicolon binds tighter than the colon in this
context, so that in the following example, either all or none of the
"print()" calls are executed:

   if x < y < z: print(x); print(y); print(z)

Summarizing:

   compound_stmt ::= if_stmt
                     | while_stmt
                     | for_stmt
                     | try_stmt
                     | with_stmt
                     | funcdef
                     | classdef
                     | async_with_stmt
                     | async_for_stmt
                     | async_funcdef
   suite         ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT
   statement     ::= stmt_list NEWLINE | compound_stmt
   stmt_list     ::= simple_stmt (";" simple_stmt)* [";"]

Note that statements always end in a "NEWLINE" possibly followed by a
"DEDENT".  Also note that optional continuation clauses always begin
with a keyword that cannot start a statement, thus there are no
ambiguities (the ‘dangling "else"’ problem is solved in Python by
requiring nested "if" statements to be indented).

The formatting of the grammar rules in the following sections places
each clause on a separate line for clarity.


The "if" statement
==================

The "if" statement is used for conditional execution:

   if_stmt ::= "if" assignment_expression ":" suite
               ("elif" assignment_expression ":" suite)*
               ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section Boolean operations
for the definition of true and false); then that suite is executed
(and no other part of the "if" statement is executed or evaluated).
If all expressions are false, the suite of the "else" clause, if
present, is executed.


The "while" statement
=====================

The "while" statement is used for repeated execution as long as an
expression is true:

   while_stmt ::= "while" assignment_expression ":" suite
                  ["else" ":" suite]

This repeatedly tests the expression and, if it is true, executes the
first suite; if the expression is false (which may be the first time
it is tested) the suite of the "else" clause, if present, is executed
and the loop terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and goes back
to testing the expression.


The "for" statement
===================

The "for" statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object:

   for_stmt ::= "for" target_list "in" expression_list ":" suite
                ["else" ":" suite]

The expression list is evaluated once; it should yield an iterable
object.  An iterator is created for the result of the
"expression_list".  The suite is then executed once for each item
provided by the iterator, in the order returned by the iterator.  Each
item in turn is assigned to the target list using the standard rules
for assignments (see Assignment statements), and then the suite is
executed.  When the items are exhausted (which is immediately when the
sequence is empty or an iterator raises a "StopIteration" exception),
the suite in the "else" clause, if present, is executed, and the loop
terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and continues
with the next item, or with the "else" clause if there is no next
item.

The for-loop makes assignments to the variables in the target list.
This overwrites all previous assignments to those variables including
those made in the suite of the for-loop:

   for i in range(10):
       print(i)
       i = 5             # this will not affect the for-loop
                         # because i will be overwritten with the next
                         # index in the range

Names in the target list are not deleted when the loop is finished,
but if the sequence is empty, they will not have been assigned to at
all by the loop.  Hint: the built-in function "range()" returns an
iterator of integers suitable to emulate the effect of Pascal’s "for i
:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".

Note:

  There is a subtlety when the sequence is being modified by the loop
  (this can only occur for mutable sequences, e.g. lists).  An
  internal counter is used to keep track of which item is used next,
  and this is incremented on each iteration.  When this counter has
  reached the length of the sequence the loop terminates.  This means
  that if the suite deletes the current (or a previous) item from the
  sequence, the next item will be skipped (since it gets the index of
  the current item which has already been treated).  Likewise, if the
  suite inserts an item in the sequence before the current item, the
  current item will be treated again the next time through the loop.
  This can lead to nasty bugs that can be avoided by making a
  temporary copy using a slice of the whole sequence, e.g.,

     for x in a[:]:
         if x < 0: a.remove(x)


The "try" statement
===================

The "try" statement specifies exception handlers and/or cleanup code
for a group of statements:

   try_stmt  ::= try1_stmt | try2_stmt
   try1_stmt ::= "try" ":" suite
                 ("except" [expression ["as" identifier]] ":" suite)+
                 ["else" ":" suite]
                 ["finally" ":" suite]
   try2_stmt ::= "try" ":" suite
                 "finally" ":" suite

The "except" clause(s) specify one or more exception handlers. When no
exception occurs in the "try" clause, no exception handler is
executed. When an exception occurs in the "try" suite, a search for an
exception handler is started.  This search inspects the except clauses
in turn until one is found that matches the exception.  An expression-
less except clause, if present, must be last; it matches any
exception.  For an except clause with an expression, that expression
is evaluated, and the clause matches the exception if the resulting
object is “compatible” with the exception.  An object is compatible
with an exception if it is the class or a base class of the exception
object, or a tuple containing an item that is the class or a base
class of the exception object.

If no except clause matches the exception, the search for an exception
handler continues in the surrounding code and on the invocation stack.
[1]

If the evaluation of an expression in the header of an except clause
raises an exception, the original search for a handler is canceled and
a search starts for the new exception in the surrounding code and on
the call stack (it is treated as if the entire "try" statement raised
the exception).

When a matching except clause is found, the exception is assigned to
the target specified after the "as" keyword in that except clause, if
present, and the except clause’s suite is executed.  All except
clauses must have an executable block.  When the end of this block is
reached, execution continues normally after the entire try statement.
(This means that if two nested handlers exist for the same exception,
and the exception occurs in the try clause of the inner handler, the
outer handler will not handle the exception.)

When an exception has been assigned using "as target", it is cleared
at the end of the except clause.  This is as if

   except E as N:
       foo

was translated to

   except E as N:
       try:
           foo
       finally:
           del N

This means the exception must be assigned to a different name to be
able to refer to it after the except clause.  Exceptions are cleared
because with the traceback attached to them, they form a reference
cycle with the stack frame, keeping all locals in that frame alive
until the next garbage collection occurs.

Before an except clause’s suite is executed, details about the
exception are stored in the "sys" module and can be accessed via
"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the
exception class, the exception instance and a traceback object (see
section The standard type hierarchy) identifying the point in the
program where the exception occurred.  "sys.exc_info()" values are
restored to their previous values (before the call) when returning
from a function that handled an exception.

The optional "else" clause is executed if the control flow leaves the
"try" suite, no exception was raised, and no "return", "continue", or
"break" statement was executed.  Exceptions in the "else" clause are
not handled by the preceding "except" clauses.

If "finally" is present, it specifies a ‘cleanup’ handler.  The "try"
clause is executed, including any "except" and "else" clauses.  If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed.  If
there is a saved exception it is re-raised at the end of the "finally"
clause.  If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:

   >>> def f():
   ...     try:
   ...         1/0
   ...     finally:
   ...         return 42
   ...
   >>> f()
   42

The exception information is not available to the program during
execution of the "finally" clause.

When a "return", "break" or "continue" statement is executed in the
"try" suite of a "try"…"finally" statement, the "finally" clause is
also executed ‘on the way out.’

The return value of a function is determined by the last "return"
statement executed.  Since the "finally" clause always executes, a
"return" statement executed in the "finally" clause will always be the
last one executed:

   >>> def foo():
   ...     try:
   ...         return 'try'
   ...     finally:
   ...         return 'finally'
   ...
   >>> foo()
   'finally'

Additional information on exceptions can be found in section
Exceptions, and information on using the "raise" statement to generate
exceptions may be found in section The raise statement.

Changed in version 3.8: Prior to Python 3.8, a "continue" statement
was illegal in the "finally" clause due to a problem with the
implementation.


The "with" statement
====================

The "with" statement is used to wrap the execution of a block with
methods defined by a context manager (see section With Statement
Context Managers). This allows common "try"…"except"…"finally" usage
patterns to be encapsulated for convenient reuse.

   with_stmt ::= "with" with_item ("," with_item)* ":" suite
   with_item ::= expression ["as" target]

The execution of the "with" statement with one “item” proceeds as
follows:

1. The context expression (the expression given in the "with_item") is
   evaluated to obtain a context manager.

2. The context manager’s "__enter__()" is loaded for later use.

3. The context manager’s "__exit__()" is loaded for later use.

4. The context manager’s "__enter__()" method is invoked.

5. If a target was included in the "with" statement, the return value
   from "__enter__()" is assigned to it.

   Note:

     The "with" statement guarantees that if the "__enter__()" method
     returns without an error, then "__exit__()" will always be
     called. Thus, if an error occurs during the assignment to the
     target list, it will be treated the same as an error occurring
     within the suite would be. See step 6 below.

6. The suite is executed.

7. The context manager’s "__exit__()" method is invoked.  If an
   exception caused the suite to be exited, its type, value, and
   traceback are passed as arguments to "__exit__()". Otherwise, three
   "None" arguments are supplied.

   If the suite was exited due to an exception, and the return value
   from the "__exit__()" method was false, the exception is reraised.
   If the return value was true, the exception is suppressed, and
   execution continues with the statement following the "with"
   statement.

   If the suite was exited for any reason other than an exception, the
   return value from "__exit__()" is ignored, and execution proceeds
   at the normal location for the kind of exit that was taken.

The following code:

   with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   enter = type(manager).__enter__
   exit = type(manager).__exit__
   value = enter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not exit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           exit(manager, None, None, None)

With more than one item, the context managers are processed as if
multiple "with" statements were nested:

   with A() as a, B() as b:
       SUITE

is semantically equivalent to:

   with A() as a:
       with B() as b:
           SUITE

Changed in version 3.1: Support for multiple context expressions.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.


Function definitions
====================

A function definition defines a user-defined function object (see
section The standard type hierarchy):

   funcdef                   ::= [decorators] "def" funcname "(" [parameter_list] ")"
               ["->" expression] ":" suite
   decorators                ::= decorator+
   decorator                 ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
   dotted_name               ::= identifier ("." identifier)*
   parameter_list            ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
                        | parameter_list_no_posonly
   parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
                                 | parameter_list_starargs
   parameter_list_starargs   ::= "*" [parameter] ("," defparameter)* ["," ["**" parameter [","]]]
                               | "**" parameter [","]
   parameter                 ::= identifier [":" expression]
   defparameter              ::= parameter ["=" expression]
   funcname                  ::= identifier

A function definition is an executable statement.  Its execution binds
the function name in the current local namespace to a function object
(a wrapper around the executable code for the function).  This
function object contains a reference to the current global namespace
as the global namespace to be used when the function is called.

The function definition does not execute the function body; this gets
executed only when the function is called. [2]

A function definition may be wrapped by one or more *decorator*
expressions. Decorator expressions are evaluated when the function is
defined, in the scope that contains the function definition.  The
result must be a callable, which is invoked with the function object
as the only argument. The returned value is bound to the function name
instead of the function object.  Multiple decorators are applied in
nested fashion. For example, the following code

   @f1(arg)
   @f2
   def func(): pass

is roughly equivalent to

   def func(): pass
   func = f1(arg)(f2(func))

except that the original function is not temporarily bound to the name
"func".

When one or more *parameters* have the form *parameter* "="
*expression*, the function is said to have “default parameter values.”
For a parameter with a default value, the corresponding *argument* may
be omitted from a call, in which case the parameter’s default value is
substituted.  If a parameter has a default value, all following
parameters up until the “"*"” must also have a default value — this is
a syntactic restriction that is not expressed by the grammar.

**Default parameter values are evaluated from left to right when the
function definition is executed.** This means that the expression is
evaluated once, when the function is defined, and that the same “pre-
computed” value is used for each call.  This is especially important
to understand when a default parameter is a mutable object, such as a
list or a dictionary: if the function modifies the object (e.g. by
appending an item to a list), the default value is in effect modified.
This is generally not what was intended.  A way around this is to use
"None" as the default, and explicitly test for it in the body of the
function, e.g.:

   def whats_on_the_telly(penguin=None):
       if penguin is None:
           penguin = []
       penguin.append("property of the zoo")
       return penguin

Function call semantics are described in more detail in section Calls.
A function call always assigns values to all parameters mentioned in
the parameter list, either from positional arguments, from keyword
arguments, or from default values.  If the form “"*identifier"” is
present, it is initialized to a tuple receiving any excess positional
parameters, defaulting to the empty tuple. If the form
“"**identifier"” is present, it is initialized to a new ordered
mapping receiving any excess keyword arguments, defaulting to a new
empty mapping of the same type.  Parameters after “"*"” or
“"*identifier"” are keyword-only parameters and may only be passed by
keyword arguments.  Parameters before “"/"” are positional-only
parameters and may only be passed by positional arguments.

Changed in version 3.8: The "/" function parameter syntax may be used
to indicate positional-only parameters. See **PEP 570** for details.

Parameters may have an *annotation* of the form “": expression"”
following the parameter name.  Any parameter may have an annotation,
even those of the form "*identifier" or "**identifier".  Functions may
have “return” annotation of the form “"-> expression"” after the
parameter list.  These annotations can be any valid Python expression.
The presence of annotations does not change the semantics of a
function.  The annotation values are available as values of a
dictionary keyed by the parameters’ names in the "__annotations__"
attribute of the function object.  If the "annotations" import from
"__future__" is used, annotations are preserved as strings at runtime
which enables postponed evaluation.  Otherwise, they are evaluated
when the function definition is executed.  In this case annotations
may be evaluated in a different order than they appear in the source
code.

It is also possible to create anonymous functions (functions not bound
to a name), for immediate use in expressions.  This uses lambda
expressions, described in section Lambdas.  Note that the lambda
expression is merely a shorthand for a simplified function definition;
a function defined in a “"def"” statement can be passed around or
assigned to another name just like a function defined by a lambda
expression.  The “"def"” form is actually more powerful since it
allows the execution of multiple statements and annotations.

**Programmer’s note:** Functions are first-class objects.  A “"def"”
statement executed inside a function definition defines a local
function that can be returned or passed around.  Free variables used
in the nested function can access the local variables of the function
containing the def.  See section Naming and binding for details.

See also:

  **PEP 3107** - Function Annotations
     The original specification for function annotations.

  **PEP 484** - Type Hints
     Definition of a standard meaning for annotations: type hints.

  **PEP 526** - Syntax for Variable Annotations
     Ability to type hint variable declarations, including class
     variables and instance variables

  **PEP 563** - Postponed Evaluation of Annotations
     Support for forward references within annotations by preserving
     annotations in a string form at runtime instead of eager
     evaluation.


Class definitions
=================

A class definition defines a class object (see section The standard
type hierarchy):

   classdef    ::= [decorators] "class" classname [inheritance] ":" suite
   inheritance ::= "(" [argument_list] ")"
   classname   ::= identifier

A class definition is an executable statement.  The inheritance list
usually gives a list of base classes (see Metaclasses for more
advanced uses), so each item in the list should evaluate to a class
object which allows subclassing.  Classes without an inheritance list
inherit, by default, from the base class "object"; hence,

   class Foo:
       pass

is equivalent to

   class Foo(object):
       pass

The class’s suite is then executed in a new execution frame (see
Naming and binding), using a newly created local namespace and the
original global namespace. (Usually, the suite contains mostly
function definitions.)  When the class’s suite finishes execution, its
execution frame is discarded but its local namespace is saved. [3] A
class object is then created using the inheritance list for the base
classes and the saved local namespace for the attribute dictionary.
The class name is bound to this class object in the original local
namespace.

The order in which attributes are defined in the class body is
preserved in the new class’s "__dict__".  Note that this is reliable
only right after the class is created and only for classes that were
defined using the definition syntax.

Class creation can be customized heavily using metaclasses.

Classes can also be decorated: just like when decorating functions,

   @f1(arg)
   @f2
   class Foo: pass

is roughly equivalent to

   class Foo: pass
   Foo = f1(arg)(f2(Foo))

The evaluation rules for the decorator expressions are the same as for
function decorators.  The result is then bound to the class name.

**Programmer’s note:** Variables defined in the class definition are
class attributes; they are shared by instances.  Instance attributes
can be set in a method with "self.name = value".  Both class and
instance attributes are accessible through the notation “"self.name"”,
and an instance attribute hides a class attribute with the same name
when accessed in this way.  Class attributes can be used as defaults
for instance attributes, but using mutable values there can lead to
unexpected results.  Descriptors can be used to create instance
variables with different implementation details.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     The proposal that changed the declaration of metaclasses to the
     current syntax, and the semantics for how classes with
     metaclasses are constructed.

  **PEP 3129** - Class Decorators
     The proposal that added class decorators.  Function and method
     decorators were introduced in **PEP 318**.


Coroutines
==========

New in version 3.5.


Coroutine function definition
-----------------------------

   async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")"
                     ["->" expression] ":" suite

Execution of Python coroutines can be suspended and resumed at many
points (see *coroutine*).  Inside the body of a coroutine function,
"await" and "async" identifiers become reserved keywords; "await"
expressions, "async for" and "async with" can only be used in
coroutine function bodies.

Functions defined with "async def" syntax are always coroutine
functions, even if they do not contain "await" or "async" keywords.

It is a "SyntaxError" to use a "yield from" expression inside the body
of a coroutine function.

An example of a coroutine function:

   async def func(param1, param2):
       do_stuff()
       await some_coroutine()


The "async for" statement
-------------------------

   async_for_stmt ::= "async" for_stmt

An *asynchronous iterable* is able to call asynchronous code in its
*iter* implementation, and *asynchronous iterator* can call
asynchronous code in its *next* method.

The "async for" statement allows convenient iteration over
asynchronous iterators.

The following code:

   async for TARGET in ITER:
       SUITE
   else:
       SUITE2

Is semantically equivalent to:

   iter = (ITER)
   iter = type(iter).__aiter__(iter)
   running = True

   while running:
       try:
           TARGET = await type(iter).__anext__(iter)
       except StopAsyncIteration:
           running = False
       else:
           SUITE
   else:
       SUITE2

See also "__aiter__()" and "__anext__()" for details.

It is a "SyntaxError" to use an "async for" statement outside the body
of a coroutine function.


The "async with" statement
--------------------------

   async_with_stmt ::= "async" with_stmt

An *asynchronous context manager* is a *context manager* that is able
to suspend execution in its *enter* and *exit* methods.

The following code:

   async with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   aexit = type(manager).__aexit__
   aenter = type(manager).__aenter__
   value = await aenter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not await aexit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           await aexit(manager, None, None, None)

See also "__aenter__()" and "__aexit__()" for details.

It is a "SyntaxError" to use an "async with" statement outside the
body of a coroutine function.

See also:

  **PEP 492** - Coroutines with async and await syntax
     The proposal that made coroutines a proper standalone concept in
     Python, and added supporting syntax.

-[ Footnotes ]-

[1] The exception is propagated to the invocation stack unless there
    is a "finally" clause which happens to raise another exception.
    That new exception causes the old one to be lost.

[2] A string literal appearing as the first statement in the function
    body is transformed into the function’s "__doc__" attribute and
    therefore the function’s *docstring*.

[3] A string literal appearing as the first statement in the class
    body is transformed into the namespace’s "__doc__" item and
    therefore the class’s *docstring*.
u�With Statement Context Managers
*******************************

A *context manager* is an object that defines the runtime context to
be established when executing a "with" statement. The context manager
handles the entry into, and the exit from, the desired runtime context
for the execution of the block of code.  Context managers are normally
invoked using the "with" statement (described in section The with
statement), but can also be used by directly invoking their methods.

Typical uses of context managers include saving and restoring various
kinds of global state, locking and unlocking resources, closing opened
files, etc.

For more information on context managers, see Context Manager Types.

object.__enter__(self)

   Enter the runtime context related to this object. The "with"
   statement will bind this method’s return value to the target(s)
   specified in the "as" clause of the statement, if any.

object.__exit__(self, exc_type, exc_value, traceback)

   Exit the runtime context related to this object. The parameters
   describe the exception that caused the context to be exited. If the
   context was exited without an exception, all three arguments will
   be "None".

   If an exception is supplied, and the method wishes to suppress the
   exception (i.e., prevent it from being propagated), it should
   return a true value. Otherwise, the exception will be processed
   normally upon exit from this method.

   Note that "__exit__()" methods should not reraise the passed-in
   exception; this is the caller’s responsibility.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.
a�The "continue" statement
************************

   continue_stmt ::= "continue"

"continue" may only occur syntactically nested in a "for" or "while"
loop, but not nested in a function or class definition within that
loop.  It continues with the next cycle of the nearest enclosing loop.

When "continue" passes control out of a "try" statement with a
"finally" clause, that "finally" clause is executed before really
starting the next loop cycle.
u�Arithmetic conversions
**********************

When a description of an arithmetic operator below uses the phrase
“the numeric arguments are converted to a common type”, this means
that the operator implementation for built-in types works as follows:

* If either argument is a complex number, the other is converted to
  complex;

* otherwise, if either argument is a floating point number, the other
  is converted to floating point;

* otherwise, both must be integers and no conversion is necessary.

Some additional rules apply for certain operators (e.g., a string as a
left argument to the ‘%’ operator).  Extensions must define their own
conversion behavior.
uS5Basic customization
*******************

object.__new__(cls[, ...])

   Called to create a new instance of class *cls*.  "__new__()" is a
   static method (special-cased so you need not declare it as such)
   that takes the class of which an instance was requested as its
   first argument.  The remaining arguments are those passed to the
   object constructor expression (the call to the class).  The return
   value of "__new__()" should be the new object instance (usually an
   instance of *cls*).

   Typical implementations create a new instance of the class by
   invoking the superclass’s "__new__()" method using
   "super().__new__(cls[, ...])" with appropriate arguments and then
   modifying the newly-created instance as necessary before returning
   it.

   If "__new__()" is invoked during object construction and it returns
   an instance of *cls*, then the new instance’s "__init__()" method
   will be invoked like "__init__(self[, ...])", where *self* is the
   new instance and the remaining arguments are the same as were
   passed to the object constructor.

   If "__new__()" does not return an instance of *cls*, then the new
   instance’s "__init__()" method will not be invoked.

   "__new__()" is intended mainly to allow subclasses of immutable
   types (like int, str, or tuple) to customize instance creation.  It
   is also commonly overridden in custom metaclasses in order to
   customize class creation.

object.__init__(self[, ...])

   Called after the instance has been created (by "__new__()"), but
   before it is returned to the caller.  The arguments are those
   passed to the class constructor expression.  If a base class has an
   "__init__()" method, the derived class’s "__init__()" method, if
   any, must explicitly call it to ensure proper initialization of the
   base class part of the instance; for example:
   "super().__init__([args...])".

   Because "__new__()" and "__init__()" work together in constructing
   objects ("__new__()" to create it, and "__init__()" to customize
   it), no non-"None" value may be returned by "__init__()"; doing so
   will cause a "TypeError" to be raised at runtime.

object.__del__(self)

   Called when the instance is about to be destroyed.  This is also
   called a finalizer or (improperly) a destructor.  If a base class
   has a "__del__()" method, the derived class’s "__del__()" method,
   if any, must explicitly call it to ensure proper deletion of the
   base class part of the instance.

   It is possible (though not recommended!) for the "__del__()" method
   to postpone destruction of the instance by creating a new reference
   to it.  This is called object *resurrection*.  It is
   implementation-dependent whether "__del__()" is called a second
   time when a resurrected object is about to be destroyed; the
   current *CPython* implementation only calls it once.

   It is not guaranteed that "__del__()" methods are called for
   objects that still exist when the interpreter exits.

   Note:

     "del x" doesn’t directly call "x.__del__()" — the former
     decrements the reference count for "x" by one, and the latter is
     only called when "x"’s reference count reaches zero.

   **CPython implementation detail:** It is possible for a reference
   cycle to prevent the reference count of an object from going to
   zero.  In this case, the cycle will be later detected and deleted
   by the *cyclic garbage collector*.  A common cause of reference
   cycles is when an exception has been caught in a local variable.
   The frame’s locals then reference the exception, which references
   its own traceback, which references the locals of all frames caught
   in the traceback.

   See also: Documentation for the "gc" module.

   Warning:

     Due to the precarious circumstances under which "__del__()"
     methods are invoked, exceptions that occur during their execution
     are ignored, and a warning is printed to "sys.stderr" instead.
     In particular:

     * "__del__()" can be invoked when arbitrary code is being
       executed, including from any arbitrary thread.  If "__del__()"
       needs to take a lock or invoke any other blocking resource, it
       may deadlock as the resource may already be taken by the code
       that gets interrupted to execute "__del__()".

     * "__del__()" can be executed during interpreter shutdown.  As a
       consequence, the global variables it needs to access (including
       other modules) may already have been deleted or set to "None".
       Python guarantees that globals whose name begins with a single
       underscore are deleted from their module before other globals
       are deleted; if no other references to such globals exist, this
       may help in assuring that imported modules are still available
       at the time when the "__del__()" method is called.

object.__repr__(self)

   Called by the "repr()" built-in function to compute the “official”
   string representation of an object.  If at all possible, this
   should look like a valid Python expression that could be used to
   recreate an object with the same value (given an appropriate
   environment).  If this is not possible, a string of the form
   "<...some useful description...>" should be returned. The return
   value must be a string object. If a class defines "__repr__()" but
   not "__str__()", then "__repr__()" is also used when an “informal”
   string representation of instances of that class is required.

   This is typically used for debugging, so it is important that the
   representation is information-rich and unambiguous.

object.__str__(self)

   Called by "str(object)" and the built-in functions "format()" and
   "print()" to compute the “informal” or nicely printable string
   representation of an object.  The return value must be a string
   object.

   This method differs from "object.__repr__()" in that there is no
   expectation that "__str__()" return a valid Python expression: a
   more convenient or concise representation can be used.

   The default implementation defined by the built-in type "object"
   calls "object.__repr__()".

object.__bytes__(self)

   Called by bytes to compute a byte-string representation of an
   object. This should return a "bytes" object.

object.__format__(self, format_spec)

   Called by the "format()" built-in function, and by extension,
   evaluation of formatted string literals and the "str.format()"
   method, to produce a “formatted” string representation of an
   object. The *format_spec* argument is a string that contains a
   description of the formatting options desired. The interpretation
   of the *format_spec* argument is up to the type implementing
   "__format__()", however most classes will either delegate
   formatting to one of the built-in types, or use a similar
   formatting option syntax.

   See Format Specification Mini-Language for a description of the
   standard formatting syntax.

   The return value must be a string object.

   Changed in version 3.4: The __format__ method of "object" itself
   raises a "TypeError" if passed any non-empty string.

   Changed in version 3.7: "object.__format__(x, '')" is now
   equivalent to "str(x)" rather than "format(str(self), '')".

object.__lt__(self, other)
object.__le__(self, other)
object.__eq__(self, other)
object.__ne__(self, other)
object.__gt__(self, other)
object.__ge__(self, other)

   These are the so-called “rich comparison” methods. The
   correspondence between operator symbols and method names is as
   follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",
   "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls
   "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".

   A rich comparison method may return the singleton "NotImplemented"
   if it does not implement the operation for a given pair of
   arguments. By convention, "False" and "True" are returned for a
   successful comparison. However, these methods can return any value,
   so if the comparison operator is used in a Boolean context (e.g.,
   in the condition of an "if" statement), Python will call "bool()"
   on the value to determine if the result is true or false.

   By default, "object" implements "__eq__()" by using "is", returning
   "NotImplemented" in the case of a false comparison: "True if x is y
   else NotImplemented". For "__ne__()", by default it delegates to
   "__eq__()" and inverts the result unless it is "NotImplemented".
   There are no other implied relationships among the comparison
   operators or default implementations; for example, the truth of
   "(x<y or x==y)" does not imply "x<=y". To automatically generate
   ordering operations from a single root operation, see
   "functools.total_ordering()".

   See the paragraph on "__hash__()" for some important notes on
   creating *hashable* objects which support custom comparison
   operations and are usable as dictionary keys.

   There are no swapped-argument versions of these methods (to be used
   when the left argument does not support the operation but the right
   argument does); rather, "__lt__()" and "__gt__()" are each other’s
   reflection, "__le__()" and "__ge__()" are each other’s reflection,
   and "__eq__()" and "__ne__()" are their own reflection. If the
   operands are of different types, and right operand’s type is a
   direct or indirect subclass of the left operand’s type, the
   reflected method of the right operand has priority, otherwise the
   left operand’s method has priority.  Virtual subclassing is not
   considered.

object.__hash__(self)

   Called by built-in function "hash()" and for operations on members
   of hashed collections including "set", "frozenset", and "dict".
   "__hash__()" should return an integer. The only required property
   is that objects which compare equal have the same hash value; it is
   advised to mix together the hash values of the components of the
   object that also play a part in comparison of objects by packing
   them into a tuple and hashing the tuple. Example:

      def __hash__(self):
          return hash((self.name, self.nick, self.color))

   Note:

     "hash()" truncates the value returned from an object’s custom
     "__hash__()" method to the size of a "Py_ssize_t".  This is
     typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds.
     If an object’s   "__hash__()" must interoperate on builds of
     different bit sizes, be sure to check the width on all supported
     builds.  An easy way to do this is with "python -c "import sys;
     print(sys.hash_info.width)"".

   If a class does not define an "__eq__()" method it should not
   define a "__hash__()" operation either; if it defines "__eq__()"
   but not "__hash__()", its instances will not be usable as items in
   hashable collections.  If a class defines mutable objects and
   implements an "__eq__()" method, it should not implement
   "__hash__()", since the implementation of hashable collections
   requires that a key’s hash value is immutable (if the object’s hash
   value changes, it will be in the wrong hash bucket).

   User-defined classes have "__eq__()" and "__hash__()" methods by
   default; with them, all objects compare unequal (except with
   themselves) and "x.__hash__()" returns an appropriate value such
   that "x == y" implies both that "x is y" and "hash(x) == hash(y)".

   A class that overrides "__eq__()" and does not define "__hash__()"
   will have its "__hash__()" implicitly set to "None".  When the
   "__hash__()" method of a class is "None", instances of the class
   will raise an appropriate "TypeError" when a program attempts to
   retrieve their hash value, and will also be correctly identified as
   unhashable when checking "isinstance(obj,
   collections.abc.Hashable)".

   If a class that overrides "__eq__()" needs to retain the
   implementation of "__hash__()" from a parent class, the interpreter
   must be told this explicitly by setting "__hash__ =
   <ParentClass>.__hash__".

   If a class that does not override "__eq__()" wishes to suppress
   hash support, it should include "__hash__ = None" in the class
   definition. A class which defines its own "__hash__()" that
   explicitly raises a "TypeError" would be incorrectly identified as
   hashable by an "isinstance(obj, collections.abc.Hashable)" call.

   Note:

     By default, the "__hash__()" values of str and bytes objects are
     “salted” with an unpredictable random value.  Although they
     remain constant within an individual Python process, they are not
     predictable between repeated invocations of Python.This is
     intended to provide protection against a denial-of-service caused
     by carefully-chosen inputs that exploit the worst case
     performance of a dict insertion, O(n^2) complexity.  See
     http://www.ocert.org/advisories/ocert-2011-003.html for
     details.Changing hash values affects the iteration order of sets.
     Python has never made guarantees about this ordering (and it
     typically varies between 32-bit and 64-bit builds).See also
     "PYTHONHASHSEED".

   Changed in version 3.3: Hash randomization is enabled by default.

object.__bool__(self)

   Called to implement truth value testing and the built-in operation
   "bool()"; should return "False" or "True".  When this method is not
   defined, "__len__()" is called, if it is defined, and the object is
   considered true if its result is nonzero.  If a class defines
   neither "__len__()" nor "__bool__()", all its instances are
   considered true.
u�I"pdb" — The Python Debugger
***************************

**Source code:** Lib/pdb.py

======================================================================

The module "pdb" defines an interactive source code debugger for
Python programs.  It supports setting (conditional) breakpoints and
single stepping at the source line level, inspection of stack frames,
source code listing, and evaluation of arbitrary Python code in the
context of any stack frame.  It also supports post-mortem debugging
and can be called under program control.

The debugger is extensible – it is actually defined as the class
"Pdb". This is currently undocumented but easily understood by reading
the source.  The extension interface uses the modules "bdb" and "cmd".

The debugger’s prompt is "(Pdb)". Typical usage to run a program under
control of the debugger is:

   >>> import pdb
   >>> import mymodule
   >>> pdb.run('mymodule.test()')
   > <string>(0)?()
   (Pdb) continue
   > <string>(1)?()
   (Pdb) continue
   NameError: 'spam'
   > <string>(1)?()
   (Pdb)

Changed in version 3.3: Tab-completion via the "readline" module is
available for commands and command arguments, e.g. the current global
and local names are offered as arguments of the "p" command.

"pdb.py" can also be invoked as a script to debug other scripts.  For
example:

   python3 -m pdb myscript.py

When invoked as a script, pdb will automatically enter post-mortem
debugging if the program being debugged exits abnormally.  After post-
mortem debugging (or after normal exit of the program), pdb will
restart the program.  Automatic restarting preserves pdb’s state (such
as breakpoints) and in most cases is more useful than quitting the
debugger upon program’s exit.

New in version 3.2: "pdb.py" now accepts a "-c" option that executes
commands as if given in a ".pdbrc" file, see Debugger Commands.

New in version 3.7: "pdb.py" now accepts a "-m" option that execute
modules similar to the way "python3 -m" does. As with a script, the
debugger will pause execution just before the first line of the
module.

The typical usage to break into the debugger from a running program is
to insert

   import pdb; pdb.set_trace()

at the location you want to break into the debugger.  You can then
step through the code following this statement, and continue running
without the debugger using the "continue" command.

New in version 3.7: The built-in "breakpoint()", when called with
defaults, can be used instead of "import pdb; pdb.set_trace()".

The typical usage to inspect a crashed program is:

   >>> import pdb
   >>> import mymodule
   >>> mymodule.test()
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "./mymodule.py", line 4, in test
       test2()
     File "./mymodule.py", line 3, in test2
       print(spam)
   NameError: spam
   >>> pdb.pm()
   > ./mymodule.py(3)test2()
   -> print(spam)
   (Pdb)

The module defines the following functions; each enters the debugger
in a slightly different way:

pdb.run(statement, globals=None, locals=None)

   Execute the *statement* (given as a string or a code object) under
   debugger control.  The debugger prompt appears before any code is
   executed; you can set breakpoints and type "continue", or you can
   step through the statement using "step" or "next" (all these
   commands are explained below).  The optional *globals* and *locals*
   arguments specify the environment in which the code is executed; by
   default the dictionary of the module "__main__" is used.  (See the
   explanation of the built-in "exec()" or "eval()" functions.)

pdb.runeval(expression, globals=None, locals=None)

   Evaluate the *expression* (given as a string or a code object)
   under debugger control.  When "runeval()" returns, it returns the
   value of the expression.  Otherwise this function is similar to
   "run()".

pdb.runcall(function, *args, **kwds)

   Call the *function* (a function or method object, not a string)
   with the given arguments.  When "runcall()" returns, it returns
   whatever the function call returned.  The debugger prompt appears
   as soon as the function is entered.

pdb.set_trace(*, header=None)

   Enter the debugger at the calling stack frame.  This is useful to
   hard-code a breakpoint at a given point in a program, even if the
   code is not otherwise being debugged (e.g. when an assertion
   fails).  If given, *header* is printed to the console just before
   debugging begins.

   Changed in version 3.7: The keyword-only argument *header*.

pdb.post_mortem(traceback=None)

   Enter post-mortem debugging of the given *traceback* object.  If no
   *traceback* is given, it uses the one of the exception that is
   currently being handled (an exception must be being handled if the
   default is to be used).

pdb.pm()

   Enter post-mortem debugging of the traceback found in
   "sys.last_traceback".

The "run*" functions and "set_trace()" are aliases for instantiating
the "Pdb" class and calling the method of the same name.  If you want
to access further features, you have to do this yourself:

class pdb.Pdb(completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False, readrc=True)

   "Pdb" is the debugger class.

   The *completekey*, *stdin* and *stdout* arguments are passed to the
   underlying "cmd.Cmd" class; see the description there.

   The *skip* argument, if given, must be an iterable of glob-style
   module name patterns.  The debugger will not step into frames that
   originate in a module that matches one of these patterns. [1]

   By default, Pdb sets a handler for the SIGINT signal (which is sent
   when the user presses "Ctrl-C" on the console) when you give a
   "continue" command. This allows you to break into the debugger
   again by pressing "Ctrl-C".  If you want Pdb not to touch the
   SIGINT handler, set *nosigint* to true.

   The *readrc* argument defaults to true and controls whether Pdb
   will load .pdbrc files from the filesystem.

   Example call to enable tracing with *skip*:

      import pdb; pdb.Pdb(skip=['django.*']).set_trace()

   Raises an auditing event "pdb.Pdb" with no arguments.

   New in version 3.1: The *skip* argument.

   New in version 3.2: The *nosigint* argument.  Previously, a SIGINT
   handler was never set by Pdb.

   Changed in version 3.6: The *readrc* argument.

   run(statement, globals=None, locals=None)
   runeval(expression, globals=None, locals=None)
   runcall(function, *args, **kwds)
   set_trace()

      See the documentation for the functions explained above.


Debugger Commands
=================

The commands recognized by the debugger are listed below.  Most
commands can be abbreviated to one or two letters as indicated; e.g.
"h(elp)" means that either "h" or "help" can be used to enter the help
command (but not "he" or "hel", nor "H" or "Help" or "HELP").
Arguments to commands must be separated by whitespace (spaces or
tabs).  Optional arguments are enclosed in square brackets ("[]") in
the command syntax; the square brackets must not be typed.
Alternatives in the command syntax are separated by a vertical bar
("|").

Entering a blank line repeats the last command entered.  Exception: if
the last command was a "list" command, the next 11 lines are listed.

Commands that the debugger doesn’t recognize are assumed to be Python
statements and are executed in the context of the program being
debugged.  Python statements can also be prefixed with an exclamation
point ("!").  This is a powerful way to inspect the program being
debugged; it is even possible to change a variable or call a function.
When an exception occurs in such a statement, the exception name is
printed but the debugger’s state is not changed.

The debugger supports aliases.  Aliases can have parameters which
allows one a certain level of adaptability to the context under
examination.

Multiple commands may be entered on a single line, separated by ";;".
(A single ";" is not used as it is the separator for multiple commands
in a line that is passed to the Python parser.)  No intelligence is
applied to separating the commands; the input is split at the first
";;" pair, even if it is in the middle of a quoted string.

If a file ".pdbrc" exists in the user’s home directory or in the
current directory, it is read in and executed as if it had been typed
at the debugger prompt.  This is particularly useful for aliases.  If
both files exist, the one in the home directory is read first and
aliases defined there can be overridden by the local file.

Changed in version 3.2: ".pdbrc" can now contain commands that
continue debugging, such as "continue" or "next".  Previously, these
commands had no effect.

h(elp) [command]

   Without argument, print the list of available commands.  With a
   *command* as argument, print help about that command.  "help pdb"
   displays the full documentation (the docstring of the "pdb"
   module).  Since the *command* argument must be an identifier, "help
   exec" must be entered to get help on the "!" command.

w(here)

   Print a stack trace, with the most recent frame at the bottom.  An
   arrow indicates the current frame, which determines the context of
   most commands.

d(own) [count]

   Move the current frame *count* (default one) levels down in the
   stack trace (to a newer frame).

u(p) [count]

   Move the current frame *count* (default one) levels up in the stack
   trace (to an older frame).

b(reak) [([filename:]lineno | function) [, condition]]

   With a *lineno* argument, set a break there in the current file.
   With a *function* argument, set a break at the first executable
   statement within that function.  The line number may be prefixed
   with a filename and a colon, to specify a breakpoint in another
   file (probably one that hasn’t been loaded yet).  The file is
   searched on "sys.path".  Note that each breakpoint is assigned a
   number to which all the other breakpoint commands refer.

   If a second argument is present, it is an expression which must
   evaluate to true before the breakpoint is honored.

   Without argument, list all breaks, including for each breakpoint,
   the number of times that breakpoint has been hit, the current
   ignore count, and the associated condition if any.

tbreak [([filename:]lineno | function) [, condition]]

   Temporary breakpoint, which is removed automatically when it is
   first hit. The arguments are the same as for "break".

cl(ear) [filename:lineno | bpnumber [bpnumber ...]]

   With a *filename:lineno* argument, clear all the breakpoints at
   this line. With a space separated list of breakpoint numbers, clear
   those breakpoints. Without argument, clear all breaks (but first
   ask confirmation).

disable [bpnumber [bpnumber ...]]

   Disable the breakpoints given as a space separated list of
   breakpoint numbers.  Disabling a breakpoint means it cannot cause
   the program to stop execution, but unlike clearing a breakpoint, it
   remains in the list of breakpoints and can be (re-)enabled.

enable [bpnumber [bpnumber ...]]

   Enable the breakpoints specified.

ignore bpnumber [count]

   Set the ignore count for the given breakpoint number.  If count is
   omitted, the ignore count is set to 0.  A breakpoint becomes active
   when the ignore count is zero.  When non-zero, the count is
   decremented each time the breakpoint is reached and the breakpoint
   is not disabled and any associated condition evaluates to true.

condition bpnumber [condition]

   Set a new *condition* for the breakpoint, an expression which must
   evaluate to true before the breakpoint is honored.  If *condition*
   is absent, any existing condition is removed; i.e., the breakpoint
   is made unconditional.

commands [bpnumber]

   Specify a list of commands for breakpoint number *bpnumber*.  The
   commands themselves appear on the following lines.  Type a line
   containing just "end" to terminate the commands. An example:

      (Pdb) commands 1
      (com) p some_variable
      (com) end
      (Pdb)

   To remove all commands from a breakpoint, type "commands" and
   follow it immediately with "end"; that is, give no commands.

   With no *bpnumber* argument, "commands" refers to the last
   breakpoint set.

   You can use breakpoint commands to start your program up again.
   Simply use the "continue" command, or "step", or any other command
   that resumes execution.

   Specifying any command resuming execution (currently "continue",
   "step", "next", "return", "jump", "quit" and their abbreviations)
   terminates the command list (as if that command was immediately
   followed by end). This is because any time you resume execution
   (even with a simple next or step), you may encounter another
   breakpoint—which could have its own command list, leading to
   ambiguities about which list to execute.

   If you use the ‘silent’ command in the command list, the usual
   message about stopping at a breakpoint is not printed.  This may be
   desirable for breakpoints that are to print a specific message and
   then continue.  If none of the other commands print anything, you
   see no sign that the breakpoint was reached.

s(tep)

   Execute the current line, stop at the first possible occasion
   (either in a function that is called or on the next line in the
   current function).

n(ext)

   Continue execution until the next line in the current function is
   reached or it returns.  (The difference between "next" and "step"
   is that "step" stops inside a called function, while "next"
   executes called functions at (nearly) full speed, only stopping at
   the next line in the current function.)

unt(il) [lineno]

   Without argument, continue execution until the line with a number
   greater than the current one is reached.

   With a line number, continue execution until a line with a number
   greater or equal to that is reached.  In both cases, also stop when
   the current frame returns.

   Changed in version 3.2: Allow giving an explicit line number.

r(eturn)

   Continue execution until the current function returns.

c(ont(inue))

   Continue execution, only stop when a breakpoint is encountered.

j(ump) lineno

   Set the next line that will be executed.  Only available in the
   bottom-most frame.  This lets you jump back and execute code again,
   or jump forward to skip code that you don’t want to run.

   It should be noted that not all jumps are allowed – for instance it
   is not possible to jump into the middle of a "for" loop or out of a
   "finally" clause.

l(ist) [first[, last]]

   List source code for the current file.  Without arguments, list 11
   lines around the current line or continue the previous listing.
   With "." as argument, list 11 lines around the current line.  With
   one argument, list 11 lines around at that line.  With two
   arguments, list the given range; if the second argument is less
   than the first, it is interpreted as a count.

   The current line in the current frame is indicated by "->".  If an
   exception is being debugged, the line where the exception was
   originally raised or propagated is indicated by ">>", if it differs
   from the current line.

   New in version 3.2: The ">>" marker.

ll | longlist

   List all source code for the current function or frame.
   Interesting lines are marked as for "list".

   New in version 3.2.

a(rgs)

   Print the argument list of the current function.

p expression

   Evaluate the *expression* in the current context and print its
   value.

   Note:

     "print()" can also be used, but is not a debugger command — this
     executes the Python "print()" function.

pp expression

   Like the "p" command, except the value of the expression is pretty-
   printed using the "pprint" module.

whatis expression

   Print the type of the *expression*.

source expression

   Try to get source code for the given object and display it.

   New in version 3.2.

display [expression]

   Display the value of the expression if it changed, each time
   execution stops in the current frame.

   Without expression, list all display expressions for the current
   frame.

   New in version 3.2.

undisplay [expression]

   Do not display the expression any more in the current frame.
   Without expression, clear all display expressions for the current
   frame.

   New in version 3.2.

interact

   Start an interactive interpreter (using the "code" module) whose
   global namespace contains all the (global and local) names found in
   the current scope.

   New in version 3.2.

alias [name [command]]

   Create an alias called *name* that executes *command*.  The command
   must *not* be enclosed in quotes.  Replaceable parameters can be
   indicated by "%1", "%2", and so on, while "%*" is replaced by all
   the parameters. If no command is given, the current alias for
   *name* is shown. If no arguments are given, all aliases are listed.

   Aliases may be nested and can contain anything that can be legally
   typed at the pdb prompt.  Note that internal pdb commands *can* be
   overridden by aliases.  Such a command is then hidden until the
   alias is removed.  Aliasing is recursively applied to the first
   word of the command line; all other words in the line are left
   alone.

   As an example, here are two useful aliases (especially when placed
   in the ".pdbrc" file):

      # Print instance variables (usage "pi classInst")
      alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])
      # Print instance variables in self
      alias ps pi self

unalias name

   Delete the specified alias.

! statement

   Execute the (one-line) *statement* in the context of the current
   stack frame. The exclamation point can be omitted unless the first
   word of the statement resembles a debugger command.  To set a
   global variable, you can prefix the assignment command with a
   "global" statement on the same line, e.g.:

      (Pdb) global list_options; list_options = ['-l']
      (Pdb)

run [args ...]
restart [args ...]

   Restart the debugged Python program.  If an argument is supplied,
   it is split with "shlex" and the result is used as the new
   "sys.argv". History, breakpoints, actions and debugger options are
   preserved. "restart" is an alias for "run".

q(uit)

   Quit from the debugger.  The program being executed is aborted.

debug code

   Enter a recursive debugger that steps through the code argument
   (which is an arbitrary expression or statement to be executed in
   the current environment).

retval

   Print the return value for the last return of a function.

-[ Footnotes ]-

[1] Whether a frame is considered to originate in a certain module is
    determined by the "__name__" in the frame globals.
a�The "del" statement
*******************

   del_stmt ::= "del" target_list

Deletion is recursively defined very similar to the way assignment is
defined. Rather than spelling it out in full details, here are some
hints.

Deletion of a target list recursively deletes each target, from left
to right.

Deletion of a name removes the binding of that name from the local or
global namespace, depending on whether the name occurs in a "global"
statement in the same code block.  If the name is unbound, a
"NameError" exception will be raised.

Deletion of attribute references, subscriptions and slicings is passed
to the primary object involved; deletion of a slicing is in general
equivalent to assignment of an empty slice of the right type (but even
this is determined by the sliced object).

Changed in version 3.2: Previously it was illegal to delete a name
from the local namespace if it occurs as a free variable in a nested
block.
uDictionary displays
*******************

A dictionary display is a possibly empty series of key/datum pairs
enclosed in curly braces:

   dict_display       ::= "{" [key_datum_list | dict_comprehension] "}"
   key_datum_list     ::= key_datum ("," key_datum)* [","]
   key_datum          ::= expression ":" expression | "**" or_expr
   dict_comprehension ::= expression ":" expression comp_for

A dictionary display yields a new dictionary object.

If a comma-separated sequence of key/datum pairs is given, they are
evaluated from left to right to define the entries of the dictionary:
each key object is used as a key into the dictionary to store the
corresponding datum.  This means that you can specify the same key
multiple times in the key/datum list, and the final dictionary’s value
for that key will be the last one given.

A double asterisk "**" denotes *dictionary unpacking*. Its operand
must be a *mapping*.  Each mapping item is added to the new
dictionary.  Later values replace values already set by earlier
key/datum pairs and earlier dictionary unpackings.

New in version 3.5: Unpacking into dictionary displays, originally
proposed by **PEP 448**.

A dict comprehension, in contrast to list and set comprehensions,
needs two expressions separated with a colon followed by the usual
“for” and “if” clauses. When the comprehension is run, the resulting
key and value elements are inserted in the new dictionary in the order
they are produced.

Restrictions on the types of the key values are listed earlier in
section The standard type hierarchy.  (To summarize, the key type
should be *hashable*, which excludes all mutable objects.)  Clashes
between duplicate keys are not detected; the last datum (textually
rightmost in the display) stored for a given key value prevails.

Changed in version 3.8: Prior to Python 3.8, in dict comprehensions,
the evaluation order of key and value was not well-defined.  In
CPython, the value was evaluated before the key.  Starting with 3.8,
the key is evaluated before the value, as proposed by **PEP 572**.
a�Interaction with dynamic features
*********************************

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.
aXThe "if" statement
******************

The "if" statement is used for conditional execution:

   if_stmt ::= "if" assignment_expression ":" suite
               ("elif" assignment_expression ":" suite)*
               ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section Boolean operations
for the definition of true and false); then that suite is executed
(and no other part of the "if" statement is executed or evaluated).
If all expressions are false, the suite of the "else" clause, if
present, is executed.
u�Exceptions
**********

Exceptions are a means of breaking out of the normal flow of control
of a code block in order to handle errors or other exceptional
conditions.  An exception is *raised* at the point where the error is
detected; it may be *handled* by the surrounding code block or by any
code block that directly or indirectly invoked the code block where
the error occurred.

The Python interpreter raises an exception when it detects a run-time
error (such as division by zero).  A Python program can also
explicitly raise an exception with the "raise" statement. Exception
handlers are specified with the "try" … "except" statement.  The
"finally" clause of such a statement can be used to specify cleanup
code which does not handle the exception, but is executed whether an
exception occurred or not in the preceding code.

Python uses the “termination” model of error handling: an exception
handler can find out what happened and continue execution at an outer
level, but it cannot repair the cause of the error and retry the
failing operation (except by re-entering the offending piece of code
from the top).

When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.  In
either case, it prints a stack traceback, except when the exception is
"SystemExit".

Exceptions are identified by class instances.  The "except" clause is
selected depending on the class of the instance: it must reference the
class of the instance or a base class thereof.  The instance can be
received by the handler and can carry additional information about the
exceptional condition.

Note:

  Exception messages are not part of the Python API.  Their contents
  may change from one version of Python to the next without warning
  and should not be relied on by code which will run under multiple
  versions of the interpreter.

See also the description of the "try" statement in section The try
statement and "raise" statement in section The raise statement.

-[ Footnotes ]-

[1] This limitation occurs because the code that is executed by these
    operations is not available at the time the module is compiled.
u$Execution model
***************


Structure of a program
======================

A Python program is constructed from code blocks. A *block* is a piece
of Python program text that is executed as a unit. The following are
blocks: a module, a function body, and a class definition. Each
command typed interactively is a block.  A script file (a file given
as standard input to the interpreter or specified as a command line
argument to the interpreter) is a code block.  A script command (a
command specified on the interpreter command line with the "-c"
option) is a code block.  The string argument passed to the built-in
functions "eval()" and "exec()" is a code block.

A code block is executed in an *execution frame*.  A frame contains
some administrative information (used for debugging) and determines
where and how execution continues after the code block’s execution has
completed.


Naming and binding
==================


Binding of names
----------------

*Names* refer to objects.  Names are introduced by name binding
operations.

The following constructs bind names: formal parameters to functions,
"import" statements, class and function definitions (these bind the
class or function name in the defining block), and targets that are
identifiers if occurring in an assignment, "for" loop header, or after
"as" in a "with" statement or "except" clause. The "import" statement
of the form "from ... import *" binds all names defined in the
imported module, except those beginning with an underscore.  This form
may only be used at the module level.

A target occurring in a "del" statement is also considered bound for
this purpose (though the actual semantics are to unbind the name).

Each assignment or import statement occurs within a block defined by a
class or function definition or at the module level (the top-level
code block).

If a name is bound in a block, it is a local variable of that block,
unless declared as "nonlocal" or "global".  If a name is bound at the
module level, it is a global variable.  (The variables of the module
code block are local and global.)  If a variable is used in a code
block but not defined there, it is a *free variable*.

Each occurrence of a name in the program text refers to the *binding*
of that name established by the following name resolution rules.


Resolution of names
-------------------

A *scope* defines the visibility of a name within a block.  If a local
variable is defined in a block, its scope includes that block.  If the
definition occurs in a function block, the scope extends to any blocks
contained within the defining one, unless a contained block introduces
a different binding for the name.

When a name is used in a code block, it is resolved using the nearest
enclosing scope.  The set of all such scopes visible to a code block
is called the block’s *environment*.

When a name is not found at all, a "NameError" exception is raised. If
the current scope is a function scope, and the name refers to a local
variable that has not yet been bound to a value at the point where the
name is used, an "UnboundLocalError" exception is raised.
"UnboundLocalError" is a subclass of "NameError".

If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block.  This can lead to errors when a name is used within a
block before it is bound.  This rule is subtle.  Python lacks
declarations and allows name binding operations to occur anywhere
within a code block.  The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.

If the "global" statement occurs within a block, all uses of the name
specified in the statement refer to the binding of that name in the
top-level namespace.  Names are resolved in the top-level namespace by
searching the global namespace, i.e. the namespace of the module
containing the code block, and the builtins namespace, the namespace
of the module "builtins".  The global namespace is searched first.  If
the name is not found there, the builtins namespace is searched.  The
"global" statement must precede all uses of the name.

The "global" statement has the same scope as a name binding operation
in the same block.  If the nearest enclosing scope for a free variable
contains a global statement, the free variable is treated as a global.

The "nonlocal" statement causes corresponding names to refer to
previously bound variables in the nearest enclosing function scope.
"SyntaxError" is raised at compile time if the given name does not
exist in any enclosing function scope.

The namespace for a module is automatically created the first time a
module is imported.  The main module for a script is always called
"__main__".

Class definition blocks and arguments to "exec()" and "eval()" are
special in the context of name resolution. A class definition is an
executable statement that may use and define names. These references
follow the normal rules for name resolution with an exception that
unbound local variables are looked up in the global namespace. The
namespace of the class definition becomes the attribute dictionary of
the class. The scope of names defined in a class block is limited to
the class block; it does not extend to the code blocks of methods –
this includes comprehensions and generator expressions since they are
implemented using a function scope.  This means that the following
will fail:

   class A:
       a = 42
       b = list(a + i for i in range(10))


Builtins and restricted execution
---------------------------------

**CPython implementation detail:** Users should not touch
"__builtins__"; it is strictly an implementation detail.  Users
wanting to override values in the builtins namespace should "import"
the "builtins" module and modify its attributes appropriately.

The builtins namespace associated with the execution of a code block
is actually found by looking up the name "__builtins__" in its global
namespace; this should be a dictionary or a module (in the latter case
the module’s dictionary is used).  By default, when in the "__main__"
module, "__builtins__" is the built-in module "builtins"; when in any
other module, "__builtins__" is an alias for the dictionary of the
"builtins" module itself.


Interaction with dynamic features
---------------------------------

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.


Exceptions
==========

Exceptions are a means of breaking out of the normal flow of control
of a code block in order to handle errors or other exceptional
conditions.  An exception is *raised* at the point where the error is
detected; it may be *handled* by the surrounding code block or by any
code block that directly or indirectly invoked the code block where
the error occurred.

The Python interpreter raises an exception when it detects a run-time
error (such as division by zero).  A Python program can also
explicitly raise an exception with the "raise" statement. Exception
handlers are specified with the "try" … "except" statement.  The
"finally" clause of such a statement can be used to specify cleanup
code which does not handle the exception, but is executed whether an
exception occurred or not in the preceding code.

Python uses the “termination” model of error handling: an exception
handler can find out what happened and continue execution at an outer
level, but it cannot repair the cause of the error and retry the
failing operation (except by re-entering the offending piece of code
from the top).

When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.  In
either case, it prints a stack traceback, except when the exception is
"SystemExit".

Exceptions are identified by class instances.  The "except" clause is
selected depending on the class of the instance: it must reference the
class of the instance or a base class thereof.  The instance can be
received by the handler and can carry additional information about the
exceptional condition.

Note:

  Exception messages are not part of the Python API.  Their contents
  may change from one version of Python to the next without warning
  and should not be relied on by code which will run under multiple
  versions of the interpreter.

See also the description of the "try" statement in section The try
statement and "raise" statement in section The raise statement.

-[ Footnotes ]-

[1] This limitation occurs because the code that is executed by these
    operations is not available at the time the module is compiled.
uzExpression lists
****************

   expression_list    ::= expression ("," expression)* [","]
   starred_list       ::= starred_item ("," starred_item)* [","]
   starred_expression ::= expression | (starred_item ",")* [starred_item]
   starred_item       ::= assignment_expression | "*" or_expr

Except when part of a list or set display, an expression list
containing at least one comma yields a tuple.  The length of the tuple
is the number of expressions in the list.  The expressions are
evaluated from left to right.

An asterisk "*" denotes *iterable unpacking*.  Its operand must be an
*iterable*.  The iterable is expanded into a sequence of items, which
are included in the new tuple, list, or set, at the site of the
unpacking.

New in version 3.5: Iterable unpacking in expression lists, originally
proposed by **PEP 448**.

The trailing comma is required only to create a single tuple (a.k.a. a
*singleton*); it is optional in all other cases.  A single expression
without a trailing comma doesn’t create a tuple, but rather yields the
value of that expression. (To create an empty tuple, use an empty pair
of parentheses: "()".)
a�Floating point literals
***********************

Floating point literals are described by the following lexical
definitions:

   floatnumber   ::= pointfloat | exponentfloat
   pointfloat    ::= [digitpart] fraction | digitpart "."
   exponentfloat ::= (digitpart | pointfloat) exponent
   digitpart     ::= digit (["_"] digit)*
   fraction      ::= "." digitpart
   exponent      ::= ("e" | "E") ["+" | "-"] digitpart

Note that the integer and exponent parts are always interpreted using
radix 10. For example, "077e010" is legal, and denotes the same number
as "77e10". The allowed range of floating point literals is
implementation-dependent.  As in integer literals, underscores are
supported for digit grouping.

Some examples of floating point literals:

   3.14    10.    .001    1e100    3.14e-10    0e0    3.14_15_93

Changed in version 3.6: Underscores are now allowed for grouping
purposes in literals.
u�
The "for" statement
*******************

The "for" statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object:

   for_stmt ::= "for" target_list "in" expression_list ":" suite
                ["else" ":" suite]

The expression list is evaluated once; it should yield an iterable
object.  An iterator is created for the result of the
"expression_list".  The suite is then executed once for each item
provided by the iterator, in the order returned by the iterator.  Each
item in turn is assigned to the target list using the standard rules
for assignments (see Assignment statements), and then the suite is
executed.  When the items are exhausted (which is immediately when the
sequence is empty or an iterator raises a "StopIteration" exception),
the suite in the "else" clause, if present, is executed, and the loop
terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and continues
with the next item, or with the "else" clause if there is no next
item.

The for-loop makes assignments to the variables in the target list.
This overwrites all previous assignments to those variables including
those made in the suite of the for-loop:

   for i in range(10):
       print(i)
       i = 5             # this will not affect the for-loop
                         # because i will be overwritten with the next
                         # index in the range

Names in the target list are not deleted when the loop is finished,
but if the sequence is empty, they will not have been assigned to at
all by the loop.  Hint: the built-in function "range()" returns an
iterator of integers suitable to emulate the effect of Pascal’s "for i
:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".

Note:

  There is a subtlety when the sequence is being modified by the loop
  (this can only occur for mutable sequences, e.g. lists).  An
  internal counter is used to keep track of which item is used next,
  and this is incremented on each iteration.  When this counter has
  reached the length of the sequence the loop terminates.  This means
  that if the suite deletes the current (or a previous) item from the
  sequence, the next item will be skipped (since it gets the index of
  the current item which has already been treated).  Likewise, if the
  suite inserts an item in the sequence before the current item, the
  current item will be treated again the next time through the loop.
  This can lead to nasty bugs that can be avoided by making a
  temporary copy using a slice of the whole sequence, e.g.,

     for x in a[:]:
         if x < 0: a.remove(x)
u�`Format String Syntax
********************

The "str.format()" method and the "Formatter" class share the same
syntax for format strings (although in the case of "Formatter",
subclasses can define their own format string syntax).  The syntax is
related to that of formatted string literals, but it is less
sophisticated and, in particular, does not support arbitrary
expressions.

Format strings contain “replacement fields” surrounded by curly braces
"{}". Anything that is not contained in braces is considered literal
text, which is copied unchanged to the output.  If you need to include
a brace character in the literal text, it can be escaped by doubling:
"{{" and "}}".

The grammar for a replacement field is as follows:

      replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"
      field_name        ::= arg_name ("." attribute_name | "[" element_index "]")*
      arg_name          ::= [identifier | digit+]
      attribute_name    ::= identifier
      element_index     ::= digit+ | index_string
      index_string      ::= <any source character except "]"> +
      conversion        ::= "r" | "s" | "a"
      format_spec       ::= <described in the next section>

In less formal terms, the replacement field can start with a
*field_name* that specifies the object whose value is to be formatted
and inserted into the output instead of the replacement field. The
*field_name* is optionally followed by a  *conversion* field, which is
preceded by an exclamation point "'!'", and a *format_spec*, which is
preceded by a colon "':'".  These specify a non-default format for the
replacement value.

See also the Format Specification Mini-Language section.

The *field_name* itself begins with an *arg_name* that is either a
number or a keyword.  If it’s a number, it refers to a positional
argument, and if it’s a keyword, it refers to a named keyword
argument.  If the numerical arg_names in a format string are 0, 1, 2,
… in sequence, they can all be omitted (not just some) and the numbers
0, 1, 2, … will be automatically inserted in that order. Because
*arg_name* is not quote-delimited, it is not possible to specify
arbitrary dictionary keys (e.g., the strings "'10'" or "':-]'") within
a format string. The *arg_name* can be followed by any number of index
or attribute expressions. An expression of the form "'.name'" selects
the named attribute using "getattr()", while an expression of the form
"'[index]'" does an index lookup using "__getitem__()".

Changed in version 3.1: The positional argument specifiers can be
omitted for "str.format()", so "'{} {}'.format(a, b)" is equivalent to
"'{0} {1}'.format(a, b)".

Changed in version 3.4: The positional argument specifiers can be
omitted for "Formatter".

Some simple format string examples:

   "First, thou shalt count to {0}"  # References first positional argument
   "Bring me a {}"                   # Implicitly references the first positional argument
   "From {} to {}"                   # Same as "From {0} to {1}"
   "My quest is {name}"              # References keyword argument 'name'
   "Weight in tons {0.weight}"       # 'weight' attribute of first positional arg
   "Units destroyed: {players[0]}"   # First element of keyword argument 'players'.

The *conversion* field causes a type coercion before formatting.
Normally, the job of formatting a value is done by the "__format__()"
method of the value itself.  However, in some cases it is desirable to
force a type to be formatted as a string, overriding its own
definition of formatting.  By converting the value to a string before
calling "__format__()", the normal formatting logic is bypassed.

Three conversion flags are currently supported: "'!s'" which calls
"str()" on the value, "'!r'" which calls "repr()" and "'!a'" which
calls "ascii()".

Some examples:

   "Harold's a clever {0!s}"        # Calls str() on the argument first
   "Bring out the holy {name!r}"    # Calls repr() on the argument first
   "More {!a}"                      # Calls ascii() on the argument first

The *format_spec* field contains a specification of how the value
should be presented, including such details as field width, alignment,
padding, decimal precision and so on.  Each value type can define its
own “formatting mini-language” or interpretation of the *format_spec*.

Most built-in types support a common formatting mini-language, which
is described in the next section.

A *format_spec* field can also include nested replacement fields
within it. These nested replacement fields may contain a field name,
conversion flag and format specification, but deeper nesting is not
allowed.  The replacement fields within the format_spec are
substituted before the *format_spec* string is interpreted. This
allows the formatting of a value to be dynamically specified.

See the Format examples section for some examples.


Format Specification Mini-Language
==================================

“Format specifications” are used within replacement fields contained
within a format string to define how individual values are presented
(see Format String Syntax and Formatted string literals). They can
also be passed directly to the built-in "format()" function.  Each
formattable type may define how the format specification is to be
interpreted.

Most built-in types implement the following options for format
specifications, although some of the formatting options are only
supported by the numeric types.

A general convention is that an empty format specification produces
the same result as if you had called "str()" on the value. A non-empty
format specification typically modifies the result.

The general form of a *standard format specifier* is:

   format_spec     ::= [[fill]align][sign][#][0][width][grouping_option][.precision][type]
   fill            ::= <any character>
   align           ::= "<" | ">" | "=" | "^"
   sign            ::= "+" | "-" | " "
   width           ::= digit+
   grouping_option ::= "_" | ","
   precision       ::= digit+
   type            ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"

If a valid *align* value is specified, it can be preceded by a *fill*
character that can be any character and defaults to a space if
omitted. It is not possible to use a literal curly brace (”"{"” or
“"}"”) as the *fill* character in a formatted string literal or when
using the "str.format()" method.  However, it is possible to insert a
curly brace with a nested replacement field.  This limitation doesn’t
affect the "format()" function.

The meaning of the various alignment options is as follows:

   +-----------+------------------------------------------------------------+
   | Option    | Meaning                                                    |
   |===========|============================================================|
   | "'<'"     | Forces the field to be left-aligned within the available   |
   |           | space (this is the default for most objects).              |
   +-----------+------------------------------------------------------------+
   | "'>'"     | Forces the field to be right-aligned within the available  |
   |           | space (this is the default for numbers).                   |
   +-----------+------------------------------------------------------------+
   | "'='"     | Forces the padding to be placed after the sign (if any)    |
   |           | but before the digits.  This is used for printing fields   |
   |           | in the form ‘+000000120’. This alignment option is only    |
   |           | valid for numeric types.  It becomes the default when ‘0’  |
   |           | immediately precedes the field width.                      |
   +-----------+------------------------------------------------------------+
   | "'^'"     | Forces the field to be centered within the available       |
   |           | space.                                                     |
   +-----------+------------------------------------------------------------+

Note that unless a minimum field width is defined, the field width
will always be the same size as the data to fill it, so that the
alignment option has no meaning in this case.

The *sign* option is only valid for number types, and can be one of
the following:

   +-----------+------------------------------------------------------------+
   | Option    | Meaning                                                    |
   |===========|============================================================|
   | "'+'"     | indicates that a sign should be used for both positive as  |
   |           | well as negative numbers.                                  |
   +-----------+------------------------------------------------------------+
   | "'-'"     | indicates that a sign should be used only for negative     |
   |           | numbers (this is the default behavior).                    |
   +-----------+------------------------------------------------------------+
   | space     | indicates that a leading space should be used on positive  |
   |           | numbers, and a minus sign on negative numbers.             |
   +-----------+------------------------------------------------------------+

The "'#'" option causes the “alternate form” to be used for the
conversion.  The alternate form is defined differently for different
types.  This option is only valid for integer, float and complex
types. For integers, when binary, octal, or hexadecimal output is
used, this option adds the prefix respective "'0b'", "'0o'", or "'0x'"
to the output value. For float and complex the alternate form causes
the result of the conversion to always contain a decimal-point
character, even if no digits follow it. Normally, a decimal-point
character appears in the result of these conversions only if a digit
follows it. In addition, for "'g'" and "'G'" conversions, trailing
zeros are not removed from the result.

The "','" option signals the use of a comma for a thousands separator.
For a locale aware separator, use the "'n'" integer presentation type
instead.

Changed in version 3.1: Added the "','" option (see also **PEP 378**).

The "'_'" option signals the use of an underscore for a thousands
separator for floating point presentation types and for integer
presentation type "'d'".  For integer presentation types "'b'", "'o'",
"'x'", and "'X'", underscores will be inserted every 4 digits.  For
other presentation types, specifying this option is an error.

Changed in version 3.6: Added the "'_'" option (see also **PEP 515**).

*width* is a decimal integer defining the minimum total field width,
including any prefixes, separators, and other formatting characters.
If not specified, then the field width will be determined by the
content.

When no explicit alignment is given, preceding the *width* field by a
zero ("'0'") character enables sign-aware zero-padding for numeric
types.  This is equivalent to a *fill* character of "'0'" with an
*alignment* type of "'='".

The *precision* is a decimal number indicating how many digits should
be displayed after the decimal point for a floating point value
formatted with "'f'" and "'F'", or before and after the decimal point
for a floating point value formatted with "'g'" or "'G'".  For non-
number types the field indicates the maximum field size - in other
words, how many characters will be used from the field content. The
*precision* is not allowed for integer values.

Finally, the *type* determines how the data should be presented.

The available string presentation types are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'s'"     | String format. This is the default type for strings and    |
   |           | may be omitted.                                            |
   +-----------+------------------------------------------------------------+
   | None      | The same as "'s'".                                         |
   +-----------+------------------------------------------------------------+

The available integer presentation types are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'b'"     | Binary format. Outputs the number in base 2.               |
   +-----------+------------------------------------------------------------+
   | "'c'"     | Character. Converts the integer to the corresponding       |
   |           | unicode character before printing.                         |
   +-----------+------------------------------------------------------------+
   | "'d'"     | Decimal Integer. Outputs the number in base 10.            |
   +-----------+------------------------------------------------------------+
   | "'o'"     | Octal format. Outputs the number in base 8.                |
   +-----------+------------------------------------------------------------+
   | "'x'"     | Hex format. Outputs the number in base 16, using lower-    |
   |           | case letters for the digits above 9.                       |
   +-----------+------------------------------------------------------------+
   | "'X'"     | Hex format. Outputs the number in base 16, using upper-    |
   |           | case letters for the digits above 9.                       |
   +-----------+------------------------------------------------------------+
   | "'n'"     | Number. This is the same as "'d'", except that it uses the |
   |           | current locale setting to insert the appropriate number    |
   |           | separator characters.                                      |
   +-----------+------------------------------------------------------------+
   | None      | The same as "'d'".                                         |
   +-----------+------------------------------------------------------------+

In addition to the above presentation types, integers can be formatted
with the floating point presentation types listed below (except "'n'"
and "None"). When doing so, "float()" is used to convert the integer
to a floating point number before formatting.

The available presentation types for "float" and "Decimal" values are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'e'"     | Scientific notation. For a given precision "p", formats    |
   |           | the number in scientific notation with the letter ‘e’      |
   |           | separating the coefficient from the exponent. The          |
   |           | coefficient has one digit before and "p" digits after the  |
   |           | decimal point, for a total of "p + 1" significant digits.  |
   |           | With no precision given, uses a precision of "6" digits    |
   |           | after the decimal point for "float", and shows all         |
   |           | coefficient digits for "Decimal". If no digits follow the  |
   |           | decimal point, the decimal point is also removed unless    |
   |           | the "#" option is used.                                    |
   +-----------+------------------------------------------------------------+
   | "'E'"     | Scientific notation. Same as "'e'" except it uses an upper |
   |           | case ‘E’ as the separator character.                       |
   +-----------+------------------------------------------------------------+
   | "'f'"     | Fixed-point notation. For a given precision "p", formats   |
   |           | the number as a decimal number with exactly "p" digits     |
   |           | following the decimal point. With no precision given, uses |
   |           | a precision of "6" digits after the decimal point for      |
   |           | "float", and uses a precision large enough to show all     |
   |           | coefficient digits for "Decimal". If no digits follow the  |
   |           | decimal point, the decimal point is also removed unless    |
   |           | the "#" option is used.                                    |
   +-----------+------------------------------------------------------------+
   | "'F'"     | Fixed-point notation. Same as "'f'", but converts "nan" to |
   |           | "NAN" and "inf" to "INF".                                  |
   +-----------+------------------------------------------------------------+
   | "'g'"     | General format.  For a given precision "p >= 1", this      |
   |           | rounds the number to "p" significant digits and then       |
   |           | formats the result in either fixed-point format or in      |
   |           | scientific notation, depending on its magnitude. A         |
   |           | precision of "0" is treated as equivalent to a precision   |
   |           | of "1".  The precise rules are as follows: suppose that    |
   |           | the result formatted with presentation type "'e'" and      |
   |           | precision "p-1" would have exponent "exp".  Then, if "m <= |
   |           | exp < p", where "m" is -4 for floats and -6 for            |
   |           | "Decimals", the number is formatted with presentation type |
   |           | "'f'" and precision "p-1-exp".  Otherwise, the number is   |
   |           | formatted with presentation type "'e'" and precision       |
   |           | "p-1". In both cases insignificant trailing zeros are      |
   |           | removed from the significand, and the decimal point is     |
   |           | also removed if there are no remaining digits following    |
   |           | it, unless the "'#'" option is used.  With no precision    |
   |           | given, uses a precision of "6" significant digits for      |
   |           | "float". For "Decimal", the coefficient of the result is   |
   |           | formed from the coefficient digits of the value;           |
   |           | scientific notation is used for values smaller than "1e-6" |
   |           | in absolute value and values where the place value of the  |
   |           | least significant digit is larger than 1, and fixed-point  |
   |           | notation is used otherwise.  Positive and negative         |
   |           | infinity, positive and negative zero, and nans, are        |
   |           | formatted as "inf", "-inf", "0", "-0" and "nan"            |
   |           | respectively, regardless of the precision.                 |
   +-----------+------------------------------------------------------------+
   | "'G'"     | General format. Same as "'g'" except switches to "'E'" if  |
   |           | the number gets too large. The representations of infinity |
   |           | and NaN are uppercased, too.                               |
   +-----------+------------------------------------------------------------+
   | "'n'"     | Number. This is the same as "'g'", except that it uses the |
   |           | current locale setting to insert the appropriate number    |
   |           | separator characters.                                      |
   +-----------+------------------------------------------------------------+
   | "'%'"     | Percentage. Multiplies the number by 100 and displays in   |
   |           | fixed ("'f'") format, followed by a percent sign.          |
   +-----------+------------------------------------------------------------+
   | None      | For "float" this is the same as "'g'", except that when    |
   |           | fixed-point notation is used to format the result, it      |
   |           | always includes at least one digit past the decimal point. |
   |           | The precision used is as large as needed to represent the  |
   |           | given value faithfully.  For "Decimal", this is the same   |
   |           | as either "'g'" or "'G'" depending on the value of         |
   |           | "context.capitals" for the current decimal context.  The   |
   |           | overall effect is to match the output of "str()" as        |
   |           | altered by the other format modifiers.                     |
   +-----------+------------------------------------------------------------+


Format examples
===============

This section contains examples of the "str.format()" syntax and
comparison with the old "%"-formatting.

In most of the cases the syntax is similar to the old "%"-formatting,
with the addition of the "{}" and with ":" used instead of "%". For
example, "'%03.2f'" can be translated to "'{:03.2f}'".

The new format syntax also supports new and different options, shown
in the following examples.

Accessing arguments by position:

   >>> '{0}, {1}, {2}'.format('a', 'b', 'c')
   'a, b, c'
   >>> '{}, {}, {}'.format('a', 'b', 'c')  # 3.1+ only
   'a, b, c'
   >>> '{2}, {1}, {0}'.format('a', 'b', 'c')
   'c, b, a'
   >>> '{2}, {1}, {0}'.format(*'abc')      # unpacking argument sequence
   'c, b, a'
   >>> '{0}{1}{0}'.format('abra', 'cad')   # arguments' indices can be repeated
   'abracadabra'

Accessing arguments by name:

   >>> 'Coordinates: {latitude}, {longitude}'.format(latitude='37.24N', longitude='-115.81W')
   'Coordinates: 37.24N, -115.81W'
   >>> coord = {'latitude': '37.24N', 'longitude': '-115.81W'}
   >>> 'Coordinates: {latitude}, {longitude}'.format(**coord)
   'Coordinates: 37.24N, -115.81W'

Accessing arguments’ attributes:

   >>> c = 3-5j
   >>> ('The complex number {0} is formed from the real part {0.real} '
   ...  'and the imaginary part {0.imag}.').format(c)
   'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.'
   >>> class Point:
   ...     def __init__(self, x, y):
   ...         self.x, self.y = x, y
   ...     def __str__(self):
   ...         return 'Point({self.x}, {self.y})'.format(self=self)
   ...
   >>> str(Point(4, 2))
   'Point(4, 2)'

Accessing arguments’ items:

   >>> coord = (3, 5)
   >>> 'X: {0[0]};  Y: {0[1]}'.format(coord)
   'X: 3;  Y: 5'

Replacing "%s" and "%r":

   >>> "repr() shows quotes: {!r}; str() doesn't: {!s}".format('test1', 'test2')
   "repr() shows quotes: 'test1'; str() doesn't: test2"

Aligning the text and specifying a width:

   >>> '{:<30}'.format('left aligned')
   'left aligned                  '
   >>> '{:>30}'.format('right aligned')
   '                 right aligned'
   >>> '{:^30}'.format('centered')
   '           centered           '
   >>> '{:*^30}'.format('centered')  # use '*' as a fill char
   '***********centered***********'

Replacing "%+f", "%-f", and "% f" and specifying a sign:

   >>> '{:+f}; {:+f}'.format(3.14, -3.14)  # show it always
   '+3.140000; -3.140000'
   >>> '{: f}; {: f}'.format(3.14, -3.14)  # show a space for positive numbers
   ' 3.140000; -3.140000'
   >>> '{:-f}; {:-f}'.format(3.14, -3.14)  # show only the minus -- same as '{:f}; {:f}'
   '3.140000; -3.140000'

Replacing "%x" and "%o" and converting the value to different bases:

   >>> # format also supports binary numbers
   >>> "int: {0:d};  hex: {0:x};  oct: {0:o};  bin: {0:b}".format(42)
   'int: 42;  hex: 2a;  oct: 52;  bin: 101010'
   >>> # with 0x, 0o, or 0b as prefix:
   >>> "int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}".format(42)
   'int: 42;  hex: 0x2a;  oct: 0o52;  bin: 0b101010'

Using the comma as a thousands separator:

   >>> '{:,}'.format(1234567890)
   '1,234,567,890'

Expressing a percentage:

   >>> points = 19
   >>> total = 22
   >>> 'Correct answers: {:.2%}'.format(points/total)
   'Correct answers: 86.36%'

Using type-specific formatting:

   >>> import datetime
   >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
   >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
   '2010-07-04 12:15:58'

Nesting arguments and more complex examples:

   >>> for align, text in zip('<^>', ['left', 'center', 'right']):
   ...     '{0:{fill}{align}16}'.format(text, fill=align, align=align)
   ...
   'left<<<<<<<<<<<<'
   '^^^^^center^^^^^'
   '>>>>>>>>>>>right'
   >>>
   >>> octets = [192, 168, 0, 1]
   >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)
   'C0A80001'
   >>> int(_, 16)
   3232235521
   >>>
   >>> width = 5
   >>> for num in range(5,12): 
   ...     for base in 'dXob':
   ...         print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ')
   ...     print()
   ...
       5     5     5   101
       6     6     6   110
       7     7     7   111
       8     8    10  1000
       9     9    11  1001
      10     A    12  1010
      11     B    13  1011
u|Function definitions
********************

A function definition defines a user-defined function object (see
section The standard type hierarchy):

   funcdef                   ::= [decorators] "def" funcname "(" [parameter_list] ")"
               ["->" expression] ":" suite
   decorators                ::= decorator+
   decorator                 ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
   dotted_name               ::= identifier ("." identifier)*
   parameter_list            ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
                        | parameter_list_no_posonly
   parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
                                 | parameter_list_starargs
   parameter_list_starargs   ::= "*" [parameter] ("," defparameter)* ["," ["**" parameter [","]]]
                               | "**" parameter [","]
   parameter                 ::= identifier [":" expression]
   defparameter              ::= parameter ["=" expression]
   funcname                  ::= identifier

A function definition is an executable statement.  Its execution binds
the function name in the current local namespace to a function object
(a wrapper around the executable code for the function).  This
function object contains a reference to the current global namespace
as the global namespace to be used when the function is called.

The function definition does not execute the function body; this gets
executed only when the function is called. [2]

A function definition may be wrapped by one or more *decorator*
expressions. Decorator expressions are evaluated when the function is
defined, in the scope that contains the function definition.  The
result must be a callable, which is invoked with the function object
as the only argument. The returned value is bound to the function name
instead of the function object.  Multiple decorators are applied in
nested fashion. For example, the following code

   @f1(arg)
   @f2
   def func(): pass

is roughly equivalent to

   def func(): pass
   func = f1(arg)(f2(func))

except that the original function is not temporarily bound to the name
"func".

When one or more *parameters* have the form *parameter* "="
*expression*, the function is said to have “default parameter values.”
For a parameter with a default value, the corresponding *argument* may
be omitted from a call, in which case the parameter’s default value is
substituted.  If a parameter has a default value, all following
parameters up until the “"*"” must also have a default value — this is
a syntactic restriction that is not expressed by the grammar.

**Default parameter values are evaluated from left to right when the
function definition is executed.** This means that the expression is
evaluated once, when the function is defined, and that the same “pre-
computed” value is used for each call.  This is especially important
to understand when a default parameter is a mutable object, such as a
list or a dictionary: if the function modifies the object (e.g. by
appending an item to a list), the default value is in effect modified.
This is generally not what was intended.  A way around this is to use
"None" as the default, and explicitly test for it in the body of the
function, e.g.:

   def whats_on_the_telly(penguin=None):
       if penguin is None:
           penguin = []
       penguin.append("property of the zoo")
       return penguin

Function call semantics are described in more detail in section Calls.
A function call always assigns values to all parameters mentioned in
the parameter list, either from positional arguments, from keyword
arguments, or from default values.  If the form “"*identifier"” is
present, it is initialized to a tuple receiving any excess positional
parameters, defaulting to the empty tuple. If the form
“"**identifier"” is present, it is initialized to a new ordered
mapping receiving any excess keyword arguments, defaulting to a new
empty mapping of the same type.  Parameters after “"*"” or
“"*identifier"” are keyword-only parameters and may only be passed by
keyword arguments.  Parameters before “"/"” are positional-only
parameters and may only be passed by positional arguments.

Changed in version 3.8: The "/" function parameter syntax may be used
to indicate positional-only parameters. See **PEP 570** for details.

Parameters may have an *annotation* of the form “": expression"”
following the parameter name.  Any parameter may have an annotation,
even those of the form "*identifier" or "**identifier".  Functions may
have “return” annotation of the form “"-> expression"” after the
parameter list.  These annotations can be any valid Python expression.
The presence of annotations does not change the semantics of a
function.  The annotation values are available as values of a
dictionary keyed by the parameters’ names in the "__annotations__"
attribute of the function object.  If the "annotations" import from
"__future__" is used, annotations are preserved as strings at runtime
which enables postponed evaluation.  Otherwise, they are evaluated
when the function definition is executed.  In this case annotations
may be evaluated in a different order than they appear in the source
code.

It is also possible to create anonymous functions (functions not bound
to a name), for immediate use in expressions.  This uses lambda
expressions, described in section Lambdas.  Note that the lambda
expression is merely a shorthand for a simplified function definition;
a function defined in a “"def"” statement can be passed around or
assigned to another name just like a function defined by a lambda
expression.  The “"def"” form is actually more powerful since it
allows the execution of multiple statements and annotations.

**Programmer’s note:** Functions are first-class objects.  A “"def"”
statement executed inside a function definition defines a local
function that can be returned or passed around.  Free variables used
in the nested function can access the local variables of the function
containing the def.  See section Naming and binding for details.

See also:

  **PEP 3107** - Function Annotations
     The original specification for function annotations.

  **PEP 484** - Type Hints
     Definition of a standard meaning for annotations: type hints.

  **PEP 526** - Syntax for Variable Annotations
     Ability to type hint variable declarations, including class
     variables and instance variables

  **PEP 563** - Postponed Evaluation of Annotations
     Support for forward references within annotations by preserving
     annotations in a string form at runtime instead of eager
     evaluation.
u�The "global" statement
**********************

   global_stmt ::= "global" identifier ("," identifier)*

The "global" statement is a declaration which holds for the entire
current code block.  It means that the listed identifiers are to be
interpreted as globals.  It would be impossible to assign to a global
variable without "global", although free variables may refer to
globals without being declared global.

Names listed in a "global" statement must not be used in the same code
block textually preceding that "global" statement.

Names listed in a "global" statement must not be defined as formal
parameters or in a "for" loop control target, "class" definition,
function definition, "import" statement, or variable annotation.

**CPython implementation detail:** The current implementation does not
enforce some of these restrictions, but programs should not abuse this
freedom, as future implementations may enforce them or silently change
the meaning of the program.

**Programmer’s note:** "global" is a directive to the parser.  It
applies only to code parsed at the same time as the "global"
statement. In particular, a "global" statement contained in a string
or code object supplied to the built-in "exec()" function does not
affect the code block *containing* the function call, and code
contained in such a string is unaffected by "global" statements in the
code containing the function call.  The same applies to the "eval()"
and "compile()" functions.
u�Reserved classes of identifiers
*******************************

Certain classes of identifiers (besides keywords) have special
meanings.  These classes are identified by the patterns of leading and
trailing underscore characters:

"_*"
   Not imported by "from module import *".  The special identifier "_"
   is used in the interactive interpreter to store the result of the
   last evaluation; it is stored in the "builtins" module.  When not
   in interactive mode, "_" has no special meaning and is not defined.
   See section The import statement.

   Note:

     The name "_" is often used in conjunction with
     internationalization; refer to the documentation for the
     "gettext" module for more information on this convention.

"__*__"
   System-defined names, informally known as “dunder” names. These
   names are defined by the interpreter and its implementation
   (including the standard library). Current system names are
   discussed in the Special method names section and elsewhere. More
   will likely be defined in future versions of Python.  *Any* use of
   "__*__" names, in any context, that does not follow explicitly
   documented use, is subject to breakage without warning.

"__*"
   Class-private names.  Names in this category, when used within the
   context of a class definition, are re-written to use a mangled form
   to help avoid name clashes between “private” attributes of base and
   derived classes. See section Identifiers (Names).
umIdentifiers and keywords
************************

Identifiers (also referred to as *names*) are described by the
following lexical definitions.

The syntax of identifiers in Python is based on the Unicode standard
annex UAX-31, with elaboration and changes as defined below; see also
**PEP 3131** for further details.

Within the ASCII range (U+0001..U+007F), the valid characters for
identifiers are the same as in Python 2.x: the uppercase and lowercase
letters "A" through "Z", the underscore "_" and, except for the first
character, the digits "0" through "9".

Python 3.0 introduces additional characters from outside the ASCII
range (see **PEP 3131**).  For these characters, the classification
uses the version of the Unicode Character Database as included in the
"unicodedata" module.

Identifiers are unlimited in length.  Case is significant.

   identifier   ::= xid_start xid_continue*
   id_start     ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
   id_continue  ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
   xid_start    ::= <all characters in id_start whose NFKC normalization is in "id_start xid_continue*">
   xid_continue ::= <all characters in id_continue whose NFKC normalization is in "id_continue*">

The Unicode category codes mentioned above stand for:

* *Lu* - uppercase letters

* *Ll* - lowercase letters

* *Lt* - titlecase letters

* *Lm* - modifier letters

* *Lo* - other letters

* *Nl* - letter numbers

* *Mn* - nonspacing marks

* *Mc* - spacing combining marks

* *Nd* - decimal numbers

* *Pc* - connector punctuations

* *Other_ID_Start* - explicit list of characters in PropList.txt to
  support backwards compatibility

* *Other_ID_Continue* - likewise

All identifiers are converted into the normal form NFKC while parsing;
comparison of identifiers is based on NFKC.

A non-normative HTML file listing all valid identifier characters for
Unicode 4.1 can be found at
https://www.unicode.org/Public/13.0.0/ucd/DerivedCoreProperties.txt


Keywords
========

The following identifiers are used as reserved words, or *keywords* of
the language, and cannot be used as ordinary identifiers.  They must
be spelled exactly as written here:

   False      await      else       import     pass
   None       break      except     in         raise
   True       class      finally    is         return
   and        continue   for        lambda     try
   as         def        from       nonlocal   while
   assert     del        global     not        with
   async      elif       if         or         yield


Reserved classes of identifiers
===============================

Certain classes of identifiers (besides keywords) have special
meanings.  These classes are identified by the patterns of leading and
trailing underscore characters:

"_*"
   Not imported by "from module import *".  The special identifier "_"
   is used in the interactive interpreter to store the result of the
   last evaluation; it is stored in the "builtins" module.  When not
   in interactive mode, "_" has no special meaning and is not defined.
   See section The import statement.

   Note:

     The name "_" is often used in conjunction with
     internationalization; refer to the documentation for the
     "gettext" module for more information on this convention.

"__*__"
   System-defined names, informally known as “dunder” names. These
   names are defined by the interpreter and its implementation
   (including the standard library). Current system names are
   discussed in the Special method names section and elsewhere. More
   will likely be defined in future versions of Python.  *Any* use of
   "__*__" names, in any context, that does not follow explicitly
   documented use, is subject to breakage without warning.

"__*"
   Class-private names.  Names in this category, when used within the
   context of a class definition, are re-written to use a mangled form
   to help avoid name clashes between “private” attributes of base and
   derived classes. See section Identifiers (Names).
a5Imaginary literals
******************

Imaginary literals are described by the following lexical definitions:

   imagnumber ::= (floatnumber | digitpart) ("j" | "J")

An imaginary literal yields a complex number with a real part of 0.0.
Complex numbers are represented as a pair of floating point numbers
and have the same restrictions on their range.  To create a complex
number with a nonzero real part, add a floating point number to it,
e.g., "(3+4j)".  Some examples of imaginary literals:

   3.14j   10.j    10j     .001j   1e100j   3.14e-10j   3.14_15_93j
u8"The "import" statement
**********************

   import_stmt     ::= "import" module ["as" identifier] ("," module ["as" identifier])*
                   | "from" relative_module "import" identifier ["as" identifier]
                   ("," identifier ["as" identifier])*
                   | "from" relative_module "import" "(" identifier ["as" identifier]
                   ("," identifier ["as" identifier])* [","] ")"
                   | "from" module "import" "*"
   module          ::= (identifier ".")* identifier
   relative_module ::= "."* module | "."+

The basic import statement (no "from" clause) is executed in two
steps:

1. find a module, loading and initializing it if necessary

2. define a name or names in the local namespace for the scope where
   the "import" statement occurs.

When the statement contains multiple clauses (separated by commas) the
two steps are carried out separately for each clause, just as though
the clauses had been separated out into individual import statements.

The details of the first step, finding and loading modules are
described in greater detail in the section on the import system, which
also describes the various types of packages and modules that can be
imported, as well as all the hooks that can be used to customize the
import system. Note that failures in this step may indicate either
that the module could not be located, *or* that an error occurred
while initializing the module, which includes execution of the
module’s code.

If the requested module is retrieved successfully, it will be made
available in the local namespace in one of three ways:

* If the module name is followed by "as", then the name following "as"
  is bound directly to the imported module.

* If no other name is specified, and the module being imported is a
  top level module, the module’s name is bound in the local namespace
  as a reference to the imported module

* If the module being imported is *not* a top level module, then the
  name of the top level package that contains the module is bound in
  the local namespace as a reference to the top level package. The
  imported module must be accessed using its full qualified name
  rather than directly

The "from" form uses a slightly more complex process:

1. find the module specified in the "from" clause, loading and
   initializing it if necessary;

2. for each of the identifiers specified in the "import" clauses:

   1. check if the imported module has an attribute by that name

   2. if not, attempt to import a submodule with that name and then
      check the imported module again for that attribute

   3. if the attribute is not found, "ImportError" is raised.

   4. otherwise, a reference to that value is stored in the local
      namespace, using the name in the "as" clause if it is present,
      otherwise using the attribute name

Examples:

   import foo                 # foo imported and bound locally
   import foo.bar.baz         # foo.bar.baz imported, foo bound locally
   import foo.bar.baz as fbb  # foo.bar.baz imported and bound as fbb
   from foo.bar import baz    # foo.bar.baz imported and bound as baz
   from foo import attr       # foo imported and foo.attr bound as attr

If the list of identifiers is replaced by a star ("'*'"), all public
names defined in the module are bound in the local namespace for the
scope where the "import" statement occurs.

The *public names* defined by a module are determined by checking the
module’s namespace for a variable named "__all__"; if defined, it must
be a sequence of strings which are names defined or imported by that
module.  The names given in "__all__" are all considered public and
are required to exist.  If "__all__" is not defined, the set of public
names includes all names found in the module’s namespace which do not
begin with an underscore character ("'_'").  "__all__" should contain
the entire public API. It is intended to avoid accidentally exporting
items that are not part of the API (such as library modules which were
imported and used within the module).

The wild card form of import — "from module import *" — is only
allowed at the module level.  Attempting to use it in class or
function definitions will raise a "SyntaxError".

When specifying what module to import you do not have to specify the
absolute name of the module. When a module or package is contained
within another package it is possible to make a relative import within
the same top package without having to mention the package name. By
using leading dots in the specified module or package after "from" you
can specify how high to traverse up the current package hierarchy
without specifying exact names. One leading dot means the current
package where the module making the import exists. Two dots means up
one package level. Three dots is up two levels, etc. So if you execute
"from . import mod" from a module in the "pkg" package then you will
end up importing "pkg.mod". If you execute "from ..subpkg2 import mod"
from within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The
specification for relative imports is contained in the Package
Relative Imports section.

"importlib.import_module()" is provided to support applications that
determine dynamically the modules to be loaded.

Raises an auditing event "import" with arguments "module", "filename",
"sys.path", "sys.meta_path", "sys.path_hooks".


Future statements
=================

A *future statement* is a directive to the compiler that a particular
module should be compiled using syntax or semantics that will be
available in a specified future release of Python where the feature
becomes standard.

The future statement is intended to ease migration to future versions
of Python that introduce incompatible changes to the language.  It
allows use of the new features on a per-module basis before the
release in which the feature becomes standard.

   future_stmt ::= "from" "__future__" "import" feature ["as" identifier]
                   ("," feature ["as" identifier])*
                   | "from" "__future__" "import" "(" feature ["as" identifier]
                   ("," feature ["as" identifier])* [","] ")"
   feature     ::= identifier

A future statement must appear near the top of the module.  The only
lines that can appear before a future statement are:

* the module docstring (if any),

* comments,

* blank lines, and

* other future statements.

The only feature that requires using the future statement is
"annotations" (see **PEP 563**).

All historical features enabled by the future statement are still
recognized by Python 3.  The list includes "absolute_import",
"division", "generators", "generator_stop", "unicode_literals",
"print_function", "nested_scopes" and "with_statement".  They are all
redundant because they are always enabled, and only kept for backwards
compatibility.

A future statement is recognized and treated specially at compile
time: Changes to the semantics of core constructs are often
implemented by generating different code.  It may even be the case
that a new feature introduces new incompatible syntax (such as a new
reserved word), in which case the compiler may need to parse the
module differently.  Such decisions cannot be pushed off until
runtime.

For any given release, the compiler knows which feature names have
been defined, and raises a compile-time error if a future statement
contains a feature not known to it.

The direct runtime semantics are the same as for any import statement:
there is a standard module "__future__", described later, and it will
be imported in the usual way at the time the future statement is
executed.

The interesting runtime semantics depend on the specific feature
enabled by the future statement.

Note that there is nothing special about the statement:

   import __future__ [as name]

That is not a future statement; it’s an ordinary import statement with
no special semantics or syntax restrictions.

Code compiled by calls to the built-in functions "exec()" and
"compile()" that occur in a module "M" containing a future statement
will, by default, use the new syntax or semantics associated with the
future statement.  This can be controlled by optional arguments to
"compile()" — see the documentation of that function for details.

A future statement typed at an interactive interpreter prompt will
take effect for the rest of the interpreter session.  If an
interpreter is started with the "-i" option, is passed a script name
to execute, and the script includes a future statement, it will be in
effect in the interactive session started after the script is
executed.

See also:

  **PEP 236** - Back to the __future__
     The original proposal for the __future__ mechanism.
aMembership test operations
**************************

The operators "in" and "not in" test for membership.  "x in s"
evaluates to "True" if *x* is a member of *s*, and "False" otherwise.
"x not in s" returns the negation of "x in s".  All built-in sequences
and set types support this as well as dictionary, for which "in" tests
whether the dictionary has a given key. For container types such as
list, tuple, set, frozenset, dict, or collections.deque, the
expression "x in y" is equivalent to "any(x is e or x == e for e in
y)".

For the string and bytes types, "x in y" is "True" if and only if *x*
is a substring of *y*.  An equivalent test is "y.find(x) != -1".
Empty strings are always considered to be a substring of any other
string, so """ in "abc"" will return "True".

For user-defined classes which define the "__contains__()" method, "x
in y" returns "True" if "y.__contains__(x)" returns a true value, and
"False" otherwise.

For user-defined classes which do not define "__contains__()" but do
define "__iter__()", "x in y" is "True" if some value "z", for which
the expression "x is z or x == z" is true, is produced while iterating
over "y". If an exception is raised during the iteration, it is as if
"in" raised that exception.

Lastly, the old-style iteration protocol is tried: if a class defines
"__getitem__()", "x in y" is "True" if and only if there is a non-
negative integer index *i* such that "x is y[i] or x == y[i]", and no
lower integer index raises the "IndexError" exception.  (If any other
exception is raised, it is as if "in" raised that exception).

The operator "not in" is defined to have the inverse truth value of
"in".
aVInteger literals
****************

Integer literals are described by the following lexical definitions:

   integer      ::= decinteger | bininteger | octinteger | hexinteger
   decinteger   ::= nonzerodigit (["_"] digit)* | "0"+ (["_"] "0")*
   bininteger   ::= "0" ("b" | "B") (["_"] bindigit)+
   octinteger   ::= "0" ("o" | "O") (["_"] octdigit)+
   hexinteger   ::= "0" ("x" | "X") (["_"] hexdigit)+
   nonzerodigit ::= "1"..."9"
   digit        ::= "0"..."9"
   bindigit     ::= "0" | "1"
   octdigit     ::= "0"..."7"
   hexdigit     ::= digit | "a"..."f" | "A"..."F"

There is no limit for the length of integer literals apart from what
can be stored in available memory.

Underscores are ignored for determining the numeric value of the
literal.  They can be used to group digits for enhanced readability.
One underscore can occur between digits, and after base specifiers
like "0x".

Note that leading zeros in a non-zero decimal number are not allowed.
This is for disambiguation with C-style octal literals, which Python
used before version 3.0.

Some examples of integer literals:

   7     2147483647                        0o177    0b100110111
   3     79228162514264337593543950336     0o377    0xdeadbeef
         100_000_000_000                   0b_1110_0101

Changed in version 3.6: Underscores are now allowed for grouping
purposes in literals.
a^Lambdas
*******

   lambda_expr        ::= "lambda" [parameter_list] ":" expression
   lambda_expr_nocond ::= "lambda" [parameter_list] ":" expression_nocond

Lambda expressions (sometimes called lambda forms) are used to create
anonymous functions. The expression "lambda parameters: expression"
yields a function object.  The unnamed object behaves like a function
object defined with:

   def <lambda>(parameters):
       return expression

See section Function definitions for the syntax of parameter lists.
Note that functions created with lambda expressions cannot contain
statements or annotations.
a/List displays
*************

A list display is a possibly empty series of expressions enclosed in
square brackets:

   list_display ::= "[" [starred_list | comprehension] "]"

A list display yields a new list object, the contents being specified
by either a list of expressions or a comprehension.  When a comma-
separated list of expressions is supplied, its elements are evaluated
from left to right and placed into the list object in that order.
When a comprehension is supplied, the list is constructed from the
elements resulting from the comprehension.
u�Naming and binding
******************


Binding of names
================

*Names* refer to objects.  Names are introduced by name binding
operations.

The following constructs bind names: formal parameters to functions,
"import" statements, class and function definitions (these bind the
class or function name in the defining block), and targets that are
identifiers if occurring in an assignment, "for" loop header, or after
"as" in a "with" statement or "except" clause. The "import" statement
of the form "from ... import *" binds all names defined in the
imported module, except those beginning with an underscore.  This form
may only be used at the module level.

A target occurring in a "del" statement is also considered bound for
this purpose (though the actual semantics are to unbind the name).

Each assignment or import statement occurs within a block defined by a
class or function definition or at the module level (the top-level
code block).

If a name is bound in a block, it is a local variable of that block,
unless declared as "nonlocal" or "global".  If a name is bound at the
module level, it is a global variable.  (The variables of the module
code block are local and global.)  If a variable is used in a code
block but not defined there, it is a *free variable*.

Each occurrence of a name in the program text refers to the *binding*
of that name established by the following name resolution rules.


Resolution of names
===================

A *scope* defines the visibility of a name within a block.  If a local
variable is defined in a block, its scope includes that block.  If the
definition occurs in a function block, the scope extends to any blocks
contained within the defining one, unless a contained block introduces
a different binding for the name.

When a name is used in a code block, it is resolved using the nearest
enclosing scope.  The set of all such scopes visible to a code block
is called the block’s *environment*.

When a name is not found at all, a "NameError" exception is raised. If
the current scope is a function scope, and the name refers to a local
variable that has not yet been bound to a value at the point where the
name is used, an "UnboundLocalError" exception is raised.
"UnboundLocalError" is a subclass of "NameError".

If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block.  This can lead to errors when a name is used within a
block before it is bound.  This rule is subtle.  Python lacks
declarations and allows name binding operations to occur anywhere
within a code block.  The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.

If the "global" statement occurs within a block, all uses of the name
specified in the statement refer to the binding of that name in the
top-level namespace.  Names are resolved in the top-level namespace by
searching the global namespace, i.e. the namespace of the module
containing the code block, and the builtins namespace, the namespace
of the module "builtins".  The global namespace is searched first.  If
the name is not found there, the builtins namespace is searched.  The
"global" statement must precede all uses of the name.

The "global" statement has the same scope as a name binding operation
in the same block.  If the nearest enclosing scope for a free variable
contains a global statement, the free variable is treated as a global.

The "nonlocal" statement causes corresponding names to refer to
previously bound variables in the nearest enclosing function scope.
"SyntaxError" is raised at compile time if the given name does not
exist in any enclosing function scope.

The namespace for a module is automatically created the first time a
module is imported.  The main module for a script is always called
"__main__".

Class definition blocks and arguments to "exec()" and "eval()" are
special in the context of name resolution. A class definition is an
executable statement that may use and define names. These references
follow the normal rules for name resolution with an exception that
unbound local variables are looked up in the global namespace. The
namespace of the class definition becomes the attribute dictionary of
the class. The scope of names defined in a class block is limited to
the class block; it does not extend to the code blocks of methods –
this includes comprehensions and generator expressions since they are
implemented using a function scope.  This means that the following
will fail:

   class A:
       a = 42
       b = list(a + i for i in range(10))


Builtins and restricted execution
=================================

**CPython implementation detail:** Users should not touch
"__builtins__"; it is strictly an implementation detail.  Users
wanting to override values in the builtins namespace should "import"
the "builtins" module and modify its attributes appropriately.

The builtins namespace associated with the execution of a code block
is actually found by looking up the name "__builtins__" in its global
namespace; this should be a dictionary or a module (in the latter case
the module’s dictionary is used).  By default, when in the "__main__"
module, "__builtins__" is the built-in module "builtins"; when in any
other module, "__builtins__" is an alias for the dictionary of the
"builtins" module itself.


Interaction with dynamic features
=================================

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.
a�The "nonlocal" statement
************************

   nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*

The "nonlocal" statement causes the listed identifiers to refer to
previously bound variables in the nearest enclosing scope excluding
globals. This is important because the default behavior for binding is
to search the local namespace first.  The statement allows
encapsulated code to rebind variables outside of the local scope
besides the global (module) scope.

Names listed in a "nonlocal" statement, unlike those listed in a
"global" statement, must refer to pre-existing bindings in an
enclosing scope (the scope in which a new binding should be created
cannot be determined unambiguously).

Names listed in a "nonlocal" statement must not collide with pre-
existing bindings in the local scope.

See also:

  **PEP 3104** - Access to Names in Outer Scopes
     The specification for the "nonlocal" statement.
u�Numeric literals
****************

There are three types of numeric literals: integers, floating point
numbers, and imaginary numbers.  There are no complex literals
(complex numbers can be formed by adding a real number and an
imaginary number).

Note that numeric literals do not include a sign; a phrase like "-1"
is actually an expression composed of the unary operator ‘"-"’ and the
literal "1".
uEmulating numeric types
***********************

The following methods can be defined to emulate numeric objects.
Methods corresponding to operations that are not supported by the
particular kind of number implemented (e.g., bitwise operations for
non-integral numbers) should be left undefined.

object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
object.__matmul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
object.__divmod__(self, other)
object.__pow__(self, other[, modulo])
object.__lshift__(self, other)
object.__rshift__(self, other)
object.__and__(self, other)
object.__xor__(self, other)
object.__or__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|").  For instance, to
   evaluate the expression "x + y", where *x* is an instance of a
   class that has an "__add__()" method, "x.__add__(y)" is called.
   The "__divmod__()" method should be the equivalent to using
   "__floordiv__()" and "__mod__()"; it should not be related to
   "__truediv__()".  Note that "__pow__()" should be defined to accept
   an optional third argument if the ternary version of the built-in
   "pow()" function is to be supported.

   If one of those methods does not support the operation with the
   supplied arguments, it should return "NotImplemented".

object.__radd__(self, other)
object.__rsub__(self, other)
object.__rmul__(self, other)
object.__rmatmul__(self, other)
object.__rtruediv__(self, other)
object.__rfloordiv__(self, other)
object.__rmod__(self, other)
object.__rdivmod__(self, other)
object.__rpow__(self, other[, modulo])
object.__rlshift__(self, other)
object.__rrshift__(self, other)
object.__rand__(self, other)
object.__rxor__(self, other)
object.__ror__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)
   operands.  These functions are only called if the left operand does
   not support the corresponding operation [3] and the operands are of
   different types. [4] For instance, to evaluate the expression "x -
   y", where *y* is an instance of a class that has an "__rsub__()"
   method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns
   *NotImplemented*.

   Note that ternary "pow()" will not try calling "__rpow__()" (the
   coercion rules would become too complicated).

   Note:

     If the right operand’s type is a subclass of the left operand’s
     type and that subclass provides a different implementation of the
     reflected method for the operation, this method will be called
     before the left operand’s non-reflected method. This behavior
     allows subclasses to override their ancestors’ operations.

object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
object.__imatmul__(self, other)
object.__itruediv__(self, other)
object.__ifloordiv__(self, other)
object.__imod__(self, other)
object.__ipow__(self, other[, modulo])
object.__ilshift__(self, other)
object.__irshift__(self, other)
object.__iand__(self, other)
object.__ixor__(self, other)
object.__ior__(self, other)

   These methods are called to implement the augmented arithmetic
   assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",
   "<<=", ">>=", "&=", "^=", "|=").  These methods should attempt to
   do the operation in-place (modifying *self*) and return the result
   (which could be, but does not have to be, *self*).  If a specific
   method is not defined, the augmented assignment falls back to the
   normal methods.  For instance, if *x* is an instance of a class
   with an "__iadd__()" method, "x += y" is equivalent to "x =
   x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are
   considered, as with the evaluation of "x + y". In certain
   situations, augmented assignment can result in unexpected errors
   (see Why does a_tuple[i] += [‘item’] raise an exception when the
   addition works?), but this behavior is in fact part of the data
   model.

   Note:

     Due to a bug in the dispatching mechanism for "**=", a class that
     defines "__ipow__()" but returns "NotImplemented" would fail to
     fall back to "x.__pow__(y)" and "y.__rpow__(x)". This bug is
     fixed in Python 3.10.

object.__neg__(self)
object.__pos__(self)
object.__abs__(self)
object.__invert__(self)

   Called to implement the unary arithmetic operations ("-", "+",
   "abs()" and "~").

object.__complex__(self)
object.__int__(self)
object.__float__(self)

   Called to implement the built-in functions "complex()", "int()" and
   "float()".  Should return a value of the appropriate type.

object.__index__(self)

   Called to implement "operator.index()", and whenever Python needs
   to losslessly convert the numeric object to an integer object (such
   as in slicing, or in the built-in "bin()", "hex()" and "oct()"
   functions). Presence of this method indicates that the numeric
   object is an integer type.  Must return an integer.

   If "__int__()", "__float__()" and "__complex__()" are not defined
   then corresponding built-in functions "int()", "float()" and
   "complex()" fall back to "__index__()".

object.__round__(self[, ndigits])
object.__trunc__(self)
object.__floor__(self)
object.__ceil__(self)

   Called to implement the built-in function "round()" and "math"
   functions "trunc()", "floor()" and "ceil()". Unless *ndigits* is
   passed to "__round__()" all these methods should return the value
   of the object truncated to an "Integral" (typically an "int").

   The built-in function "int()" falls back to "__trunc__()" if
   neither "__int__()" nor "__index__()" is defined.
uObjects, values and types
*************************

*Objects* are Python’s abstraction for data.  All data in a Python
program is represented by objects or by relations between objects. (In
a sense, and in conformance to Von Neumann’s model of a “stored
program computer”, code is also represented by objects.)

Every object has an identity, a type and a value.  An object’s
*identity* never changes once it has been created; you may think of it
as the object’s address in memory.  The ‘"is"’ operator compares the
identity of two objects; the "id()" function returns an integer
representing its identity.

**CPython implementation detail:** For CPython, "id(x)" is the memory
address where "x" is stored.

An object’s type determines the operations that the object supports
(e.g., “does it have a length?”) and also defines the possible values
for objects of that type.  The "type()" function returns an object’s
type (which is an object itself).  Like its identity, an object’s
*type* is also unchangeable. [1]

The *value* of some objects can change.  Objects whose value can
change are said to be *mutable*; objects whose value is unchangeable
once they are created are called *immutable*. (The value of an
immutable container object that contains a reference to a mutable
object can change when the latter’s value is changed; however the
container is still considered immutable, because the collection of
objects it contains cannot be changed.  So, immutability is not
strictly the same as having an unchangeable value, it is more subtle.)
An object’s mutability is determined by its type; for instance,
numbers, strings and tuples are immutable, while dictionaries and
lists are mutable.

Objects are never explicitly destroyed; however, when they become
unreachable they may be garbage-collected.  An implementation is
allowed to postpone garbage collection or omit it altogether — it is a
matter of implementation quality how garbage collection is
implemented, as long as no objects are collected that are still
reachable.

**CPython implementation detail:** CPython currently uses a reference-
counting scheme with (optional) delayed detection of cyclically linked
garbage, which collects most objects as soon as they become
unreachable, but is not guaranteed to collect garbage containing
circular references.  See the documentation of the "gc" module for
information on controlling the collection of cyclic garbage. Other
implementations act differently and CPython may change. Do not depend
on immediate finalization of objects when they become unreachable (so
you should always close files explicitly).

Note that the use of the implementation’s tracing or debugging
facilities may keep objects alive that would normally be collectable.
Also note that catching an exception with a ‘"try"…"except"’ statement
may keep objects alive.

Some objects contain references to “external” resources such as open
files or windows.  It is understood that these resources are freed
when the object is garbage-collected, but since garbage collection is
not guaranteed to happen, such objects also provide an explicit way to
release the external resource, usually a "close()" method. Programs
are strongly recommended to explicitly close such objects.  The
‘"try"…"finally"’ statement and the ‘"with"’ statement provide
convenient ways to do this.

Some objects contain references to other objects; these are called
*containers*. Examples of containers are tuples, lists and
dictionaries.  The references are part of a container’s value.  In
most cases, when we talk about the value of a container, we imply the
values, not the identities of the contained objects; however, when we
talk about the mutability of a container, only the identities of the
immediately contained objects are implied.  So, if an immutable
container (like a tuple) contains a reference to a mutable object, its
value changes if that mutable object is changed.

Types affect almost all aspects of object behavior.  Even the
importance of object identity is affected in some sense: for immutable
types, operations that compute new values may actually return a
reference to any existing object with the same type and value, while
for mutable objects this is not allowed.  E.g., after "a = 1; b = 1",
"a" and "b" may or may not refer to the same object with the value
one, depending on the implementation, but after "c = []; d = []", "c"
and "d" are guaranteed to refer to two different, unique, newly
created empty lists. (Note that "c = d = []" assigns the same object
to both "c" and "d".)
u�Operator precedence
*******************

The following table summarizes the operator precedence in Python, from
lowest precedence (least binding) to highest precedence (most
binding).  Operators in the same box have the same precedence.  Unless
the syntax is explicitly given, operators are binary.  Operators in
the same box group left to right (except for exponentiation, which
groups from right to left).

Note that comparisons, membership tests, and identity tests, all have
the same precedence and have a left-to-right chaining feature as
described in the Comparisons section.

+-------------------------------------------------+---------------------------------------+
| Operator                                        | Description                           |
|=================================================|=======================================|
| ":="                                            | Assignment expression                 |
+-------------------------------------------------+---------------------------------------+
| "lambda"                                        | Lambda expression                     |
+-------------------------------------------------+---------------------------------------+
| "if" – "else"                                   | Conditional expression                |
+-------------------------------------------------+---------------------------------------+
| "or"                                            | Boolean OR                            |
+-------------------------------------------------+---------------------------------------+
| "and"                                           | Boolean AND                           |
+-------------------------------------------------+---------------------------------------+
| "not" "x"                                       | Boolean NOT                           |
+-------------------------------------------------+---------------------------------------+
| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership     |
| ">=", "!=", "=="                                | tests and identity tests              |
+-------------------------------------------------+---------------------------------------+
| "|"                                             | Bitwise OR                            |
+-------------------------------------------------+---------------------------------------+
| "^"                                             | Bitwise XOR                           |
+-------------------------------------------------+---------------------------------------+
| "&"                                             | Bitwise AND                           |
+-------------------------------------------------+---------------------------------------+
| "<<", ">>"                                      | Shifts                                |
+-------------------------------------------------+---------------------------------------+
| "+", "-"                                        | Addition and subtraction              |
+-------------------------------------------------+---------------------------------------+
| "*", "@", "/", "//", "%"                        | Multiplication, matrix                |
|                                                 | multiplication, division, floor       |
|                                                 | division, remainder [5]               |
+-------------------------------------------------+---------------------------------------+
| "+x", "-x", "~x"                                | Positive, negative, bitwise NOT       |
+-------------------------------------------------+---------------------------------------+
| "**"                                            | Exponentiation [6]                    |
+-------------------------------------------------+---------------------------------------+
| "await" "x"                                     | Await expression                      |
+-------------------------------------------------+---------------------------------------+
| "x[index]", "x[index:index]",                   | Subscription, slicing, call,          |
| "x(arguments...)", "x.attribute"                | attribute reference                   |
+-------------------------------------------------+---------------------------------------+
| "(expressions...)",  "[expressions...]", "{key: | Binding or parenthesized expression,  |
| value...}", "{expressions...}"                  | list display, dictionary display, set |
|                                                 | display                               |
+-------------------------------------------------+---------------------------------------+

-[ Footnotes ]-

[1] While "abs(x%y) < abs(y)" is true mathematically, for floats it
    may not be true numerically due to roundoff.  For example, and
    assuming a platform on which a Python float is an IEEE 754 double-
    precision number, in order that "-1e-100 % 1e100" have the same
    sign as "1e100", the computed result is "-1e-100 + 1e100", which
    is numerically exactly equal to "1e100".  The function
    "math.fmod()" returns a result whose sign matches the sign of the
    first argument instead, and so returns "-1e-100" in this case.
    Which approach is more appropriate depends on the application.

[2] If x is very close to an exact integer multiple of y, it’s
    possible for "x//y" to be one larger than "(x-x%y)//y" due to
    rounding.  In such cases, Python returns the latter result, in
    order to preserve that "divmod(x,y)[0] * y + x % y" be very close
    to "x".

[3] The Unicode standard distinguishes between *code points* (e.g.
    U+0041) and *abstract characters* (e.g. “LATIN CAPITAL LETTER A”).
    While most abstract characters in Unicode are only represented
    using one code point, there is a number of abstract characters
    that can in addition be represented using a sequence of more than
    one code point.  For example, the abstract character “LATIN
    CAPITAL LETTER C WITH CEDILLA” can be represented as a single
    *precomposed character* at code position U+00C7, or as a sequence
    of a *base character* at code position U+0043 (LATIN CAPITAL
    LETTER C), followed by a *combining character* at code position
    U+0327 (COMBINING CEDILLA).

    The comparison operators on strings compare at the level of
    Unicode code points. This may be counter-intuitive to humans.  For
    example, ""\u00C7" == "\u0043\u0327"" is "False", even though both
    strings represent the same abstract character “LATIN CAPITAL
    LETTER C WITH CEDILLA”.

    To compare strings at the level of abstract characters (that is,
    in a way intuitive to humans), use "unicodedata.normalize()".

[4] Due to automatic garbage-collection, free lists, and the dynamic
    nature of descriptors, you may notice seemingly unusual behaviour
    in certain uses of the "is" operator, like those involving
    comparisons between instance methods, or constants.  Check their
    documentation for more info.

[5] The "%" operator is also used for string formatting; the same
    precedence applies.

[6] The power operator "**" binds less tightly than an arithmetic or
    bitwise unary operator on its right, that is, "2**-1" is "0.5".
uwThe "pass" statement
********************

   pass_stmt ::= "pass"

"pass" is a null operation — when it is executed, nothing happens. It
is useful as a placeholder when a statement is required syntactically,
but no code needs to be executed, for example:

   def f(arg): pass    # a function that does nothing (yet)

   class C: pass       # a class with no methods (yet)
a�The power operator
******************

The power operator binds more tightly than unary operators on its
left; it binds less tightly than unary operators on its right.  The
syntax is:

   power ::= (await_expr | primary) ["**" u_expr]

Thus, in an unparenthesized sequence of power and unary operators, the
operators are evaluated from right to left (this does not constrain
the evaluation order for the operands): "-1**2" results in "-1".

The power operator has the same semantics as the built-in "pow()"
function, when called with two arguments: it yields its left argument
raised to the power of its right argument.  The numeric arguments are
first converted to a common type, and the result is of that type.

For int operands, the result has the same type as the operands unless
the second argument is negative; in that case, all arguments are
converted to float and a float result is delivered. For example,
"10**2" returns "100", but "10**-2" returns "0.01".

Raising "0.0" to a negative power results in a "ZeroDivisionError".
Raising a negative number to a fractional power results in a "complex"
number. (In earlier versions it raised a "ValueError".)
uJ
The "raise" statement
*********************

   raise_stmt ::= "raise" [expression ["from" expression]]

If no expressions are present, "raise" re-raises the last exception
that was active in the current scope.  If no exception is active in
the current scope, a "RuntimeError" exception is raised indicating
that this is an error.

Otherwise, "raise" evaluates the first expression as the exception
object.  It must be either a subclass or an instance of
"BaseException". If it is a class, the exception instance will be
obtained when needed by instantiating the class with no arguments.

The *type* of the exception is the exception instance’s class, the
*value* is the instance itself.

A traceback object is normally created automatically when an exception
is raised and attached to it as the "__traceback__" attribute, which
is writable. You can create an exception and set your own traceback in
one step using the "with_traceback()" exception method (which returns
the same exception instance, with its traceback set to its argument),
like so:

   raise Exception("foo occurred").with_traceback(tracebackobj)

The "from" clause is used for exception chaining: if given, the second
*expression* must be another exception class or instance. If the
second expression is an exception instance, it will be attached to the
raised exception as the "__cause__" attribute (which is writable). If
the expression is an exception class, the class will be instantiated
and the resulting exception instance will be attached to the raised
exception as the "__cause__" attribute. If the raised exception is not
handled, both exceptions will be printed:

   >>> try:
   ...     print(1 / 0)
   ... except Exception as exc:
   ...     raise RuntimeError("Something bad happened") from exc
   ...
   Traceback (most recent call last):
     File "<stdin>", line 2, in <module>
   ZeroDivisionError: division by zero

   The above exception was the direct cause of the following exception:

   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

A similar mechanism works implicitly if an exception is raised inside
an exception handler or a "finally" clause: the previous exception is
then attached as the new exception’s "__context__" attribute:

   >>> try:
   ...     print(1 / 0)
   ... except:
   ...     raise RuntimeError("Something bad happened")
   ...
   Traceback (most recent call last):
     File "<stdin>", line 2, in <module>
   ZeroDivisionError: division by zero

   During handling of the above exception, another exception occurred:

   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

Exception chaining can be explicitly suppressed by specifying "None"
in the "from" clause:

   >>> try:
   ...     print(1 / 0)
   ... except:
   ...     raise RuntimeError("Something bad happened") from None
   ...
   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

Additional information on exceptions can be found in section
Exceptions, and information about handling exceptions is in section
The try statement.

Changed in version 3.3: "None" is now permitted as "Y" in "raise X
from Y".

New in version 3.3: The "__suppress_context__" attribute to suppress
automatic display of the exception context.
aThe "return" statement
**********************

   return_stmt ::= "return" [expression_list]

"return" may only occur syntactically nested in a function definition,
not within a nested class definition.

If an expression list is present, it is evaluated, else "None" is
substituted.

"return" leaves the current function call with the expression list (or
"None") as return value.

When "return" passes control out of a "try" statement with a "finally"
clause, that "finally" clause is executed before really leaving the
function.

In a generator function, the "return" statement indicates that the
generator is done and will cause "StopIteration" to be raised. The
returned value (if any) is used as an argument to construct
"StopIteration" and becomes the "StopIteration.value" attribute.

In an asynchronous generator function, an empty "return" statement
indicates that the asynchronous generator is done and will cause
"StopAsyncIteration" to be raised.  A non-empty "return" statement is
a syntax error in an asynchronous generator function.
u�Emulating container types
*************************

The following methods can be defined to implement container objects.
Containers usually are sequences (such as lists or tuples) or mappings
(like dictionaries), but can represent other containers as well.  The
first set of methods is used either to emulate a sequence or to
emulate a mapping; the difference is that for a sequence, the
allowable keys should be the integers *k* for which "0 <= k < N" where
*N* is the length of the sequence, or slice objects, which define a
range of items.  It is also recommended that mappings provide the
methods "keys()", "values()", "items()", "get()", "clear()",
"setdefault()", "pop()", "popitem()", "copy()", and "update()"
behaving similar to those for Python’s standard dictionary objects.
The "collections.abc" module provides a "MutableMapping" abstract base
class to help create those methods from a base set of "__getitem__()",
"__setitem__()", "__delitem__()", and "keys()". Mutable sequences
should provide methods "append()", "count()", "index()", "extend()",
"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python
standard list objects.  Finally, sequence types should implement
addition (meaning concatenation) and multiplication (meaning
repetition) by defining the methods "__add__()", "__radd__()",
"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described
below; they should not define other numerical operators.  It is
recommended that both mappings and sequences implement the
"__contains__()" method to allow efficient use of the "in" operator;
for mappings, "in" should search the mapping’s keys; for sequences, it
should search through the values.  It is further recommended that both
mappings and sequences implement the "__iter__()" method to allow
efficient iteration through the container; for mappings, "__iter__()"
should iterate through the object’s keys; for sequences, it should
iterate through the values.

object.__len__(self)

   Called to implement the built-in function "len()".  Should return
   the length of the object, an integer ">=" 0.  Also, an object that
   doesn’t define a "__bool__()" method and whose "__len__()" method
   returns zero is considered to be false in a Boolean context.

   **CPython implementation detail:** In CPython, the length is
   required to be at most "sys.maxsize". If the length is larger than
   "sys.maxsize" some features (such as "len()") may raise
   "OverflowError".  To prevent raising "OverflowError" by truth value
   testing, an object must define a "__bool__()" method.

object.__length_hint__(self)

   Called to implement "operator.length_hint()". Should return an
   estimated length for the object (which may be greater or less than
   the actual length). The length must be an integer ">=" 0. The
   return value may also be "NotImplemented", which is treated the
   same as if the "__length_hint__" method didn’t exist at all. This
   method is purely an optimization and is never required for
   correctness.

   New in version 3.4.

Note:

  Slicing is done exclusively with the following three methods.  A
  call like

     a[1:2] = b

  is translated to

     a[slice(1, 2, None)] = b

  and so forth.  Missing slice items are always filled in with "None".

object.__getitem__(self, key)

   Called to implement evaluation of "self[key]". For sequence types,
   the accepted keys should be integers and slice objects.  Note that
   the special interpretation of negative indexes (if the class wishes
   to emulate a sequence type) is up to the "__getitem__()" method. If
   *key* is of an inappropriate type, "TypeError" may be raised; if of
   a value outside the set of indexes for the sequence (after any
   special interpretation of negative values), "IndexError" should be
   raised. For mapping types, if *key* is missing (not in the
   container), "KeyError" should be raised.

   Note:

     "for" loops expect that an "IndexError" will be raised for
     illegal indexes to allow proper detection of the end of the
     sequence.

object.__setitem__(self, key, value)

   Called to implement assignment to "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support changes to the values for keys, or if new keys
   can be added, or for sequences if elements can be replaced.  The
   same exceptions should be raised for improper *key* values as for
   the "__getitem__()" method.

object.__delitem__(self, key)

   Called to implement deletion of "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support removal of keys, or for sequences if elements
   can be removed from the sequence.  The same exceptions should be
   raised for improper *key* values as for the "__getitem__()" method.

object.__missing__(self, key)

   Called by "dict"."__getitem__()" to implement "self[key]" for dict
   subclasses when key is not in the dictionary.

object.__iter__(self)

   This method is called when an iterator is required for a container.
   This method should return a new iterator object that can iterate
   over all the objects in the container.  For mappings, it should
   iterate over the keys of the container.

   Iterator objects also need to implement this method; they are
   required to return themselves.  For more information on iterator
   objects, see Iterator Types.

object.__reversed__(self)

   Called (if present) by the "reversed()" built-in to implement
   reverse iteration.  It should return a new iterator object that
   iterates over all the objects in the container in reverse order.

   If the "__reversed__()" method is not provided, the "reversed()"
   built-in will fall back to using the sequence protocol ("__len__()"
   and "__getitem__()").  Objects that support the sequence protocol
   should only provide "__reversed__()" if they can provide an
   implementation that is more efficient than the one provided by
   "reversed()".

The membership test operators ("in" and "not in") are normally
implemented as an iteration through a container. However, container
objects can supply the following special method with a more efficient
implementation, which also does not require the object be iterable.

object.__contains__(self, item)

   Called to implement membership test operators.  Should return true
   if *item* is in *self*, false otherwise.  For mapping objects, this
   should consider the keys of the mapping rather than the values or
   the key-item pairs.

   For objects that don’t define "__contains__()", the membership test
   first tries iteration via "__iter__()", then the old sequence
   iteration protocol via "__getitem__()", see this section in the
   language reference.
a�Shifting operations
*******************

The shifting operations have lower priority than the arithmetic
operations:

   shift_expr ::= a_expr | shift_expr ("<<" | ">>") a_expr

These operators accept integers as arguments.  They shift the first
argument to the left or right by the number of bits given by the
second argument.

A right shift by *n* bits is defined as floor division by "pow(2,n)".
A left shift by *n* bits is defined as multiplication with "pow(2,n)".
a�Slicings
********

A slicing selects a range of items in a sequence object (e.g., a
string, tuple or list).  Slicings may be used as expressions or as
targets in assignment or "del" statements.  The syntax for a slicing:

   slicing      ::= primary "[" slice_list "]"
   slice_list   ::= slice_item ("," slice_item)* [","]
   slice_item   ::= expression | proper_slice
   proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]
   lower_bound  ::= expression
   upper_bound  ::= expression
   stride       ::= expression

There is ambiguity in the formal syntax here: anything that looks like
an expression list also looks like a slice list, so any subscription
can be interpreted as a slicing.  Rather than further complicating the
syntax, this is disambiguated by defining that in this case the
interpretation as a subscription takes priority over the
interpretation as a slicing (this is the case if the slice list
contains no proper slice).

The semantics for a slicing are as follows.  The primary is indexed
(using the same "__getitem__()" method as normal subscription) with a
key that is constructed from the slice list, as follows.  If the slice
list contains at least one comma, the key is a tuple containing the
conversion of the slice items; otherwise, the conversion of the lone
slice item is the key.  The conversion of a slice item that is an
expression is that expression.  The conversion of a proper slice is a
slice object (see section The standard type hierarchy) whose "start",
"stop" and "step" attributes are the values of the expressions given
as lower bound, upper bound and stride, respectively, substituting
"None" for missing expressions.
uSpecial Attributes
******************

The implementation adds a few special read-only attributes to several
object types, where they are relevant.  Some of these are not reported
by the "dir()" built-in function.

object.__dict__

   A dictionary or other mapping object used to store an object’s
   (writable) attributes.

instance.__class__

   The class to which a class instance belongs.

class.__bases__

   The tuple of base classes of a class object.

definition.__name__

   The name of the class, function, method, descriptor, or generator
   instance.

definition.__qualname__

   The *qualified name* of the class, function, method, descriptor, or
   generator instance.

   New in version 3.3.

class.__mro__

   This attribute is a tuple of classes that are considered when
   looking for base classes during method resolution.

class.mro()

   This method can be overridden by a metaclass to customize the
   method resolution order for its instances.  It is called at class
   instantiation, and its result is stored in "__mro__".

class.__subclasses__()

   Each class keeps a list of weak references to its immediate
   subclasses.  This method returns a list of all those references
   still alive. Example:

      >>> int.__subclasses__()
      [<class 'bool'>]
u��Special method names
********************

A class can implement certain operations that are invoked by special
syntax (such as arithmetic operations or subscripting and slicing) by
defining methods with special names. This is Python’s approach to
*operator overloading*, allowing classes to define their own behavior
with respect to language operators.  For instance, if a class defines
a method named "__getitem__()", and "x" is an instance of this class,
then "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".
Except where mentioned, attempts to execute an operation raise an
exception when no appropriate method is defined (typically
"AttributeError" or "TypeError").

Setting a special method to "None" indicates that the corresponding
operation is not available.  For example, if a class sets "__iter__()"
to "None", the class is not iterable, so calling "iter()" on its
instances will raise a "TypeError" (without falling back to
"__getitem__()"). [2]

When implementing a class that emulates any built-in type, it is
important that the emulation only be implemented to the degree that it
makes sense for the object being modelled.  For example, some
sequences may work well with retrieval of individual elements, but
extracting a slice may not make sense.  (One example of this is the
"NodeList" interface in the W3C’s Document Object Model.)


Basic customization
===================

object.__new__(cls[, ...])

   Called to create a new instance of class *cls*.  "__new__()" is a
   static method (special-cased so you need not declare it as such)
   that takes the class of which an instance was requested as its
   first argument.  The remaining arguments are those passed to the
   object constructor expression (the call to the class).  The return
   value of "__new__()" should be the new object instance (usually an
   instance of *cls*).

   Typical implementations create a new instance of the class by
   invoking the superclass’s "__new__()" method using
   "super().__new__(cls[, ...])" with appropriate arguments and then
   modifying the newly-created instance as necessary before returning
   it.

   If "__new__()" is invoked during object construction and it returns
   an instance of *cls*, then the new instance’s "__init__()" method
   will be invoked like "__init__(self[, ...])", where *self* is the
   new instance and the remaining arguments are the same as were
   passed to the object constructor.

   If "__new__()" does not return an instance of *cls*, then the new
   instance’s "__init__()" method will not be invoked.

   "__new__()" is intended mainly to allow subclasses of immutable
   types (like int, str, or tuple) to customize instance creation.  It
   is also commonly overridden in custom metaclasses in order to
   customize class creation.

object.__init__(self[, ...])

   Called after the instance has been created (by "__new__()"), but
   before it is returned to the caller.  The arguments are those
   passed to the class constructor expression.  If a base class has an
   "__init__()" method, the derived class’s "__init__()" method, if
   any, must explicitly call it to ensure proper initialization of the
   base class part of the instance; for example:
   "super().__init__([args...])".

   Because "__new__()" and "__init__()" work together in constructing
   objects ("__new__()" to create it, and "__init__()" to customize
   it), no non-"None" value may be returned by "__init__()"; doing so
   will cause a "TypeError" to be raised at runtime.

object.__del__(self)

   Called when the instance is about to be destroyed.  This is also
   called a finalizer or (improperly) a destructor.  If a base class
   has a "__del__()" method, the derived class’s "__del__()" method,
   if any, must explicitly call it to ensure proper deletion of the
   base class part of the instance.

   It is possible (though not recommended!) for the "__del__()" method
   to postpone destruction of the instance by creating a new reference
   to it.  This is called object *resurrection*.  It is
   implementation-dependent whether "__del__()" is called a second
   time when a resurrected object is about to be destroyed; the
   current *CPython* implementation only calls it once.

   It is not guaranteed that "__del__()" methods are called for
   objects that still exist when the interpreter exits.

   Note:

     "del x" doesn’t directly call "x.__del__()" — the former
     decrements the reference count for "x" by one, and the latter is
     only called when "x"’s reference count reaches zero.

   **CPython implementation detail:** It is possible for a reference
   cycle to prevent the reference count of an object from going to
   zero.  In this case, the cycle will be later detected and deleted
   by the *cyclic garbage collector*.  A common cause of reference
   cycles is when an exception has been caught in a local variable.
   The frame’s locals then reference the exception, which references
   its own traceback, which references the locals of all frames caught
   in the traceback.

   See also: Documentation for the "gc" module.

   Warning:

     Due to the precarious circumstances under which "__del__()"
     methods are invoked, exceptions that occur during their execution
     are ignored, and a warning is printed to "sys.stderr" instead.
     In particular:

     * "__del__()" can be invoked when arbitrary code is being
       executed, including from any arbitrary thread.  If "__del__()"
       needs to take a lock or invoke any other blocking resource, it
       may deadlock as the resource may already be taken by the code
       that gets interrupted to execute "__del__()".

     * "__del__()" can be executed during interpreter shutdown.  As a
       consequence, the global variables it needs to access (including
       other modules) may already have been deleted or set to "None".
       Python guarantees that globals whose name begins with a single
       underscore are deleted from their module before other globals
       are deleted; if no other references to such globals exist, this
       may help in assuring that imported modules are still available
       at the time when the "__del__()" method is called.

object.__repr__(self)

   Called by the "repr()" built-in function to compute the “official”
   string representation of an object.  If at all possible, this
   should look like a valid Python expression that could be used to
   recreate an object with the same value (given an appropriate
   environment).  If this is not possible, a string of the form
   "<...some useful description...>" should be returned. The return
   value must be a string object. If a class defines "__repr__()" but
   not "__str__()", then "__repr__()" is also used when an “informal”
   string representation of instances of that class is required.

   This is typically used for debugging, so it is important that the
   representation is information-rich and unambiguous.

object.__str__(self)

   Called by "str(object)" and the built-in functions "format()" and
   "print()" to compute the “informal” or nicely printable string
   representation of an object.  The return value must be a string
   object.

   This method differs from "object.__repr__()" in that there is no
   expectation that "__str__()" return a valid Python expression: a
   more convenient or concise representation can be used.

   The default implementation defined by the built-in type "object"
   calls "object.__repr__()".

object.__bytes__(self)

   Called by bytes to compute a byte-string representation of an
   object. This should return a "bytes" object.

object.__format__(self, format_spec)

   Called by the "format()" built-in function, and by extension,
   evaluation of formatted string literals and the "str.format()"
   method, to produce a “formatted” string representation of an
   object. The *format_spec* argument is a string that contains a
   description of the formatting options desired. The interpretation
   of the *format_spec* argument is up to the type implementing
   "__format__()", however most classes will either delegate
   formatting to one of the built-in types, or use a similar
   formatting option syntax.

   See Format Specification Mini-Language for a description of the
   standard formatting syntax.

   The return value must be a string object.

   Changed in version 3.4: The __format__ method of "object" itself
   raises a "TypeError" if passed any non-empty string.

   Changed in version 3.7: "object.__format__(x, '')" is now
   equivalent to "str(x)" rather than "format(str(self), '')".

object.__lt__(self, other)
object.__le__(self, other)
object.__eq__(self, other)
object.__ne__(self, other)
object.__gt__(self, other)
object.__ge__(self, other)

   These are the so-called “rich comparison” methods. The
   correspondence between operator symbols and method names is as
   follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",
   "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls
   "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".

   A rich comparison method may return the singleton "NotImplemented"
   if it does not implement the operation for a given pair of
   arguments. By convention, "False" and "True" are returned for a
   successful comparison. However, these methods can return any value,
   so if the comparison operator is used in a Boolean context (e.g.,
   in the condition of an "if" statement), Python will call "bool()"
   on the value to determine if the result is true or false.

   By default, "object" implements "__eq__()" by using "is", returning
   "NotImplemented" in the case of a false comparison: "True if x is y
   else NotImplemented". For "__ne__()", by default it delegates to
   "__eq__()" and inverts the result unless it is "NotImplemented".
   There are no other implied relationships among the comparison
   operators or default implementations; for example, the truth of
   "(x<y or x==y)" does not imply "x<=y". To automatically generate
   ordering operations from a single root operation, see
   "functools.total_ordering()".

   See the paragraph on "__hash__()" for some important notes on
   creating *hashable* objects which support custom comparison
   operations and are usable as dictionary keys.

   There are no swapped-argument versions of these methods (to be used
   when the left argument does not support the operation but the right
   argument does); rather, "__lt__()" and "__gt__()" are each other’s
   reflection, "__le__()" and "__ge__()" are each other’s reflection,
   and "__eq__()" and "__ne__()" are their own reflection. If the
   operands are of different types, and right operand’s type is a
   direct or indirect subclass of the left operand’s type, the
   reflected method of the right operand has priority, otherwise the
   left operand’s method has priority.  Virtual subclassing is not
   considered.

object.__hash__(self)

   Called by built-in function "hash()" and for operations on members
   of hashed collections including "set", "frozenset", and "dict".
   "__hash__()" should return an integer. The only required property
   is that objects which compare equal have the same hash value; it is
   advised to mix together the hash values of the components of the
   object that also play a part in comparison of objects by packing
   them into a tuple and hashing the tuple. Example:

      def __hash__(self):
          return hash((self.name, self.nick, self.color))

   Note:

     "hash()" truncates the value returned from an object’s custom
     "__hash__()" method to the size of a "Py_ssize_t".  This is
     typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds.
     If an object’s   "__hash__()" must interoperate on builds of
     different bit sizes, be sure to check the width on all supported
     builds.  An easy way to do this is with "python -c "import sys;
     print(sys.hash_info.width)"".

   If a class does not define an "__eq__()" method it should not
   define a "__hash__()" operation either; if it defines "__eq__()"
   but not "__hash__()", its instances will not be usable as items in
   hashable collections.  If a class defines mutable objects and
   implements an "__eq__()" method, it should not implement
   "__hash__()", since the implementation of hashable collections
   requires that a key’s hash value is immutable (if the object’s hash
   value changes, it will be in the wrong hash bucket).

   User-defined classes have "__eq__()" and "__hash__()" methods by
   default; with them, all objects compare unequal (except with
   themselves) and "x.__hash__()" returns an appropriate value such
   that "x == y" implies both that "x is y" and "hash(x) == hash(y)".

   A class that overrides "__eq__()" and does not define "__hash__()"
   will have its "__hash__()" implicitly set to "None".  When the
   "__hash__()" method of a class is "None", instances of the class
   will raise an appropriate "TypeError" when a program attempts to
   retrieve their hash value, and will also be correctly identified as
   unhashable when checking "isinstance(obj,
   collections.abc.Hashable)".

   If a class that overrides "__eq__()" needs to retain the
   implementation of "__hash__()" from a parent class, the interpreter
   must be told this explicitly by setting "__hash__ =
   <ParentClass>.__hash__".

   If a class that does not override "__eq__()" wishes to suppress
   hash support, it should include "__hash__ = None" in the class
   definition. A class which defines its own "__hash__()" that
   explicitly raises a "TypeError" would be incorrectly identified as
   hashable by an "isinstance(obj, collections.abc.Hashable)" call.

   Note:

     By default, the "__hash__()" values of str and bytes objects are
     “salted” with an unpredictable random value.  Although they
     remain constant within an individual Python process, they are not
     predictable between repeated invocations of Python.This is
     intended to provide protection against a denial-of-service caused
     by carefully-chosen inputs that exploit the worst case
     performance of a dict insertion, O(n^2) complexity.  See
     http://www.ocert.org/advisories/ocert-2011-003.html for
     details.Changing hash values affects the iteration order of sets.
     Python has never made guarantees about this ordering (and it
     typically varies between 32-bit and 64-bit builds).See also
     "PYTHONHASHSEED".

   Changed in version 3.3: Hash randomization is enabled by default.

object.__bool__(self)

   Called to implement truth value testing and the built-in operation
   "bool()"; should return "False" or "True".  When this method is not
   defined, "__len__()" is called, if it is defined, and the object is
   considered true if its result is nonzero.  If a class defines
   neither "__len__()" nor "__bool__()", all its instances are
   considered true.


Customizing attribute access
============================

The following methods can be defined to customize the meaning of
attribute access (use of, assignment to, or deletion of "x.name") for
class instances.

object.__getattr__(self, name)

   Called when the default attribute access fails with an
   "AttributeError" (either "__getattribute__()" raises an
   "AttributeError" because *name* is not an instance attribute or an
   attribute in the class tree for "self"; or "__get__()" of a *name*
   property raises "AttributeError").  This method should either
   return the (computed) attribute value or raise an "AttributeError"
   exception.

   Note that if the attribute is found through the normal mechanism,
   "__getattr__()" is not called.  (This is an intentional asymmetry
   between "__getattr__()" and "__setattr__()".) This is done both for
   efficiency reasons and because otherwise "__getattr__()" would have
   no way to access other attributes of the instance.  Note that at
   least for instance variables, you can fake total control by not
   inserting any values in the instance attribute dictionary (but
   instead inserting them in another object).  See the
   "__getattribute__()" method below for a way to actually get total
   control over attribute access.

object.__getattribute__(self, name)

   Called unconditionally to implement attribute accesses for
   instances of the class. If the class also defines "__getattr__()",
   the latter will not be called unless "__getattribute__()" either
   calls it explicitly or raises an "AttributeError". This method
   should return the (computed) attribute value or raise an
   "AttributeError" exception. In order to avoid infinite recursion in
   this method, its implementation should always call the base class
   method with the same name to access any attributes it needs, for
   example, "object.__getattribute__(self, name)".

   Note:

     This method may still be bypassed when looking up special methods
     as the result of implicit invocation via language syntax or
     built-in functions. See Special method lookup.

   For certain sensitive attribute accesses, raises an auditing event
   "object.__getattr__" with arguments "obj" and "name".

object.__setattr__(self, name, value)

   Called when an attribute assignment is attempted.  This is called
   instead of the normal mechanism (i.e. store the value in the
   instance dictionary). *name* is the attribute name, *value* is the
   value to be assigned to it.

   If "__setattr__()" wants to assign to an instance attribute, it
   should call the base class method with the same name, for example,
   "object.__setattr__(self, name, value)".

   For certain sensitive attribute assignments, raises an auditing
   event "object.__setattr__" with arguments "obj", "name", "value".

object.__delattr__(self, name)

   Like "__setattr__()" but for attribute deletion instead of
   assignment.  This should only be implemented if "del obj.name" is
   meaningful for the object.

   For certain sensitive attribute deletions, raises an auditing event
   "object.__delattr__" with arguments "obj" and "name".

object.__dir__(self)

   Called when "dir()" is called on the object. A sequence must be
   returned. "dir()" converts the returned sequence to a list and
   sorts it.


Customizing module attribute access
-----------------------------------

Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
attribute and return the computed value or raise an "AttributeError".
If an attribute is not found on a module object through the normal
lookup, i.e. "object.__getattribute__()", then "__getattr__" is
searched in the module "__dict__" before raising an "AttributeError".
If found, it is called with the attribute name and the result is
returned.

The "__dir__" function should accept no arguments, and return a
sequence of strings that represents the names accessible on module. If
present, this function overrides the standard "dir()" search on a
module.

For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:

   import sys
   from types import ModuleType

   class VerboseModule(ModuleType):
       def __repr__(self):
           return f'Verbose {self.__name__}'

       def __setattr__(self, attr, value):
           print(f'Setting {attr}...')
           super().__setattr__(attr, value)

   sys.modules[__name__].__class__ = VerboseModule

Note:

  Defining module "__getattr__" and setting module "__class__" only
  affect lookups made using the attribute access syntax – directly
  accessing the module globals (whether by code within the module, or
  via a reference to the module’s globals dictionary) is unaffected.

Changed in version 3.5: "__class__" module attribute is now writable.

New in version 3.7: "__getattr__" and "__dir__" module attributes.

See also:

  **PEP 562** - Module __getattr__ and __dir__
     Describes the "__getattr__" and "__dir__" functions on modules.


Implementing Descriptors
------------------------

The following methods only apply when an instance of the class
containing the method (a so-called *descriptor* class) appears in an
*owner* class (the descriptor must be in either the owner’s class
dictionary or in the class dictionary for one of its parents).  In the
examples below, “the attribute” refers to the attribute whose name is
the key of the property in the owner class’ "__dict__".

object.__get__(self, instance, owner=None)

   Called to get the attribute of the owner class (class attribute
   access) or of an instance of that class (instance attribute
   access). The optional *owner* argument is the owner class, while
   *instance* is the instance that the attribute was accessed through,
   or "None" when the attribute is accessed through the *owner*.

   This method should return the computed attribute value or raise an
   "AttributeError" exception.

   **PEP 252** specifies that "__get__()" is callable with one or two
   arguments.  Python’s own built-in descriptors support this
   specification; however, it is likely that some third-party tools
   have descriptors that require both arguments.  Python’s own
   "__getattribute__()" implementation always passes in both arguments
   whether they are required or not.

object.__set__(self, instance, value)

   Called to set the attribute on an instance *instance* of the owner
   class to a new value, *value*.

   Note, adding "__set__()" or "__delete__()" changes the kind of
   descriptor to a “data descriptor”.  See Invoking Descriptors for
   more details.

object.__delete__(self, instance)

   Called to delete the attribute on an instance *instance* of the
   owner class.

object.__set_name__(self, owner, name)

   Called at the time the owning class *owner* is created. The
   descriptor has been assigned to *name*.

   Note:

     "__set_name__()" is only called implicitly as part of the "type"
     constructor, so it will need to be called explicitly with the
     appropriate parameters when a descriptor is added to a class
     after initial creation:

        class A:
           pass
        descr = custom_descriptor()
        A.attr = descr
        descr.__set_name__(A, 'attr')

     See Creating the class object for more details.

   New in version 3.6.

The attribute "__objclass__" is interpreted by the "inspect" module as
specifying the class where this object was defined (setting this
appropriately can assist in runtime introspection of dynamic class
attributes). For callables, it may indicate that an instance of the
given type (or a subclass) is expected or required as the first
positional argument (for example, CPython sets this attribute for
unbound methods that are implemented in C).


Invoking Descriptors
--------------------

In general, a descriptor is an object attribute with “binding
behavior”, one whose attribute access has been overridden by methods
in the descriptor protocol:  "__get__()", "__set__()", and
"__delete__()". If any of those methods are defined for an object, it
is said to be a descriptor.

The default behavior for attribute access is to get, set, or delete
the attribute from an object’s dictionary. For instance, "a.x" has a
lookup chain starting with "a.__dict__['x']", then
"type(a).__dict__['x']", and continuing through the base classes of
"type(a)" excluding metaclasses.

However, if the looked-up value is an object defining one of the
descriptor methods, then Python may override the default behavior and
invoke the descriptor method instead.  Where this occurs in the
precedence chain depends on which descriptor methods were defined and
how they were called.

The starting point for descriptor invocation is a binding, "a.x". How
the arguments are assembled depends on "a":

Direct Call
   The simplest and least common call is when user code directly
   invokes a descriptor method:    "x.__get__(a)".

Instance Binding
   If binding to an object instance, "a.x" is transformed into the
   call: "type(a).__dict__['x'].__get__(a, type(a))".

Class Binding
   If binding to a class, "A.x" is transformed into the call:
   "A.__dict__['x'].__get__(None, A)".

Super Binding
   If "a" is an instance of "super", then the binding "super(B,
   obj).m()" searches "obj.__class__.__mro__" for the base class "A"
   immediately preceding "B" and then invokes the descriptor with the
   call: "A.__dict__['m'].__get__(obj, obj.__class__)".

For instance bindings, the precedence of descriptor invocation depends
on which descriptor methods are defined.  A descriptor can define any
combination of "__get__()", "__set__()" and "__delete__()".  If it
does not define "__get__()", then accessing the attribute will return
the descriptor object itself unless there is a value in the object’s
instance dictionary.  If the descriptor defines "__set__()" and/or
"__delete__()", it is a data descriptor; if it defines neither, it is
a non-data descriptor.  Normally, data descriptors define both
"__get__()" and "__set__()", while non-data descriptors have just the
"__get__()" method.  Data descriptors with "__set__()" and "__get__()"
defined always override a redefinition in an instance dictionary.  In
contrast, non-data descriptors can be overridden by instances.

Python methods (including "staticmethod()" and "classmethod()") are
implemented as non-data descriptors.  Accordingly, instances can
redefine and override methods.  This allows individual instances to
acquire behaviors that differ from other instances of the same class.

The "property()" function is implemented as a data descriptor.
Accordingly, instances cannot override the behavior of a property.


__slots__
---------

*__slots__* allow us to explicitly declare data members (like
properties) and deny the creation of *__dict__* and *__weakref__*
(unless explicitly declared in *__slots__* or available in a parent.)

The space saved over using *__dict__* can be significant. Attribute
lookup speed can be significantly improved as well.

object.__slots__

   This class variable can be assigned a string, iterable, or sequence
   of strings with variable names used by instances.  *__slots__*
   reserves space for the declared variables and prevents the
   automatic creation of *__dict__* and *__weakref__* for each
   instance.


Notes on using *__slots__*
~~~~~~~~~~~~~~~~~~~~~~~~~~

* When inheriting from a class without *__slots__*, the *__dict__* and
  *__weakref__* attribute of the instances will always be accessible.

* Without a *__dict__* variable, instances cannot be assigned new
  variables not listed in the *__slots__* definition.  Attempts to
  assign to an unlisted variable name raises "AttributeError". If
  dynamic assignment of new variables is desired, then add
  "'__dict__'" to the sequence of strings in the *__slots__*
  declaration.

* Without a *__weakref__* variable for each instance, classes defining
  *__slots__* do not support weak references to its instances. If weak
  reference support is needed, then add "'__weakref__'" to the
  sequence of strings in the *__slots__* declaration.

* *__slots__* are implemented at the class level by creating
  descriptors (Implementing Descriptors) for each variable name.  As a
  result, class attributes cannot be used to set default values for
  instance variables defined by *__slots__*; otherwise, the class
  attribute would overwrite the descriptor assignment.

* The action of a *__slots__* declaration is not limited to the class
  where it is defined.  *__slots__* declared in parents are available
  in child classes. However, child subclasses will get a *__dict__*
  and *__weakref__* unless they also define *__slots__* (which should
  only contain names of any *additional* slots).

* If a class defines a slot also defined in a base class, the instance
  variable defined by the base class slot is inaccessible (except by
  retrieving its descriptor directly from the base class). This
  renders the meaning of the program undefined.  In the future, a
  check may be added to prevent this.

* Nonempty *__slots__* does not work for classes derived from
  “variable-length” built-in types such as "int", "bytes" and "tuple".

* Any non-string iterable may be assigned to *__slots__*. Mappings may
  also be used; however, in the future, special meaning may be
  assigned to the values corresponding to each key.

* *__class__* assignment works only if both classes have the same
  *__slots__*.

* Multiple inheritance with multiple slotted parent classes can be
  used, but only one parent is allowed to have attributes created by
  slots (the other bases must have empty slot layouts) - violations
  raise "TypeError".

* If an iterator is used for *__slots__* then a descriptor is created
  for each of the iterator’s values. However, the *__slots__*
  attribute will be an empty iterator.


Customizing class creation
==========================

Whenever a class inherits from another class, *__init_subclass__* is
called on that class. This way, it is possible to write classes which
change the behavior of subclasses. This is closely related to class
decorators, but where class decorators only affect the specific class
they’re applied to, "__init_subclass__" solely applies to future
subclasses of the class defining the method.

classmethod object.__init_subclass__(cls)

   This method is called whenever the containing class is subclassed.
   *cls* is then the new subclass. If defined as a normal instance
   method, this method is implicitly converted to a class method.

   Keyword arguments which are given to a new class are passed to the
   parent’s class "__init_subclass__". For compatibility with other
   classes using "__init_subclass__", one should take out the needed
   keyword arguments and pass the others over to the base class, as
   in:

      class Philosopher:
          def __init_subclass__(cls, /, default_name, **kwargs):
              super().__init_subclass__(**kwargs)
              cls.default_name = default_name

      class AustralianPhilosopher(Philosopher, default_name="Bruce"):
          pass

   The default implementation "object.__init_subclass__" does nothing,
   but raises an error if it is called with any arguments.

   Note:

     The metaclass hint "metaclass" is consumed by the rest of the
     type machinery, and is never passed to "__init_subclass__"
     implementations. The actual metaclass (rather than the explicit
     hint) can be accessed as "type(cls)".

   New in version 3.6.


Metaclasses
-----------

By default, classes are constructed using "type()". The class body is
executed in a new namespace and the class name is bound locally to the
result of "type(name, bases, namespace)".

The class creation process can be customized by passing the
"metaclass" keyword argument in the class definition line, or by
inheriting from an existing class that included such an argument. In
the following example, both "MyClass" and "MySubclass" are instances
of "Meta":

   class Meta(type):
       pass

   class MyClass(metaclass=Meta):
       pass

   class MySubclass(MyClass):
       pass

Any other keyword arguments that are specified in the class definition
are passed through to all metaclass operations described below.

When a class definition is executed, the following steps occur:

* MRO entries are resolved;

* the appropriate metaclass is determined;

* the class namespace is prepared;

* the class body is executed;

* the class object is created.


Resolving MRO entries
---------------------

If a base that appears in class definition is not an instance of
"type", then an "__mro_entries__" method is searched on it. If found,
it is called with the original bases tuple. This method must return a
tuple of classes that will be used instead of this base. The tuple may
be empty, in such case the original base is ignored.

See also:

  **PEP 560** - Core support for typing module and generic types


Determining the appropriate metaclass
-------------------------------------

The appropriate metaclass for a class definition is determined as
follows:

* if no bases and no explicit metaclass are given, then "type()" is
  used;

* if an explicit metaclass is given and it is *not* an instance of
  "type()", then it is used directly as the metaclass;

* if an instance of "type()" is given as the explicit metaclass, or
  bases are defined, then the most derived metaclass is used.

The most derived metaclass is selected from the explicitly specified
metaclass (if any) and the metaclasses (i.e. "type(cls)") of all
specified base classes. The most derived metaclass is one which is a
subtype of *all* of these candidate metaclasses. If none of the
candidate metaclasses meets that criterion, then the class definition
will fail with "TypeError".


Preparing the class namespace
-----------------------------

Once the appropriate metaclass has been identified, then the class
namespace is prepared. If the metaclass has a "__prepare__" attribute,
it is called as "namespace = metaclass.__prepare__(name, bases,
**kwds)" (where the additional keyword arguments, if any, come from
the class definition). The "__prepare__" method should be implemented
as a "classmethod()". The namespace returned by "__prepare__" is
passed in to "__new__", but when the final class object is created the
namespace is copied into a new "dict".

If the metaclass has no "__prepare__" attribute, then the class
namespace is initialised as an empty ordered mapping.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     Introduced the "__prepare__" namespace hook


Executing the class body
------------------------

The class body is executed (approximately) as "exec(body, globals(),
namespace)". The key difference from a normal call to "exec()" is that
lexical scoping allows the class body (including any methods) to
reference names from the current and outer scopes when the class
definition occurs inside a function.

However, even when the class definition occurs inside the function,
methods defined inside the class still cannot see names defined at the
class scope. Class variables must be accessed through the first
parameter of instance or class methods, or through the implicit
lexically scoped "__class__" reference described in the next section.


Creating the class object
-------------------------

Once the class namespace has been populated by executing the class
body, the class object is created by calling "metaclass(name, bases,
namespace, **kwds)" (the additional keywords passed here are the same
as those passed to "__prepare__").

This class object is the one that will be referenced by the zero-
argument form of "super()". "__class__" is an implicit closure
reference created by the compiler if any methods in a class body refer
to either "__class__" or "super". This allows the zero argument form
of "super()" to correctly identify the class being defined based on
lexical scoping, while the class or instance that was used to make the
current call is identified based on the first argument passed to the
method.

**CPython implementation detail:** In CPython 3.6 and later, the
"__class__" cell is passed to the metaclass as a "__classcell__" entry
in the class namespace. If present, this must be propagated up to the
"type.__new__" call in order for the class to be initialised
correctly. Failing to do so will result in a "RuntimeError" in Python
3.8.

When using the default metaclass "type", or any metaclass that
ultimately calls "type.__new__", the following additional
customisation steps are invoked after creating the class object:

* first, "type.__new__" collects all of the descriptors in the class
  namespace that define a "__set_name__()" method;

* second, all of these "__set_name__" methods are called with the
  class being defined and the assigned name of that particular
  descriptor;

* finally, the "__init_subclass__()" hook is called on the immediate
  parent of the new class in its method resolution order.

After the class object is created, it is passed to the class
decorators included in the class definition (if any) and the resulting
object is bound in the local namespace as the defined class.

When a new class is created by "type.__new__", the object provided as
the namespace parameter is copied to a new ordered mapping and the
original object is discarded. The new copy is wrapped in a read-only
proxy, which becomes the "__dict__" attribute of the class object.

See also:

  **PEP 3135** - New super
     Describes the implicit "__class__" closure reference


Uses for metaclasses
--------------------

The potential uses for metaclasses are boundless. Some ideas that have
been explored include enum, logging, interface checking, automatic
delegation, automatic property creation, proxies, frameworks, and
automatic resource locking/synchronization.


Customizing instance and subclass checks
========================================

The following methods are used to override the default behavior of the
"isinstance()" and "issubclass()" built-in functions.

In particular, the metaclass "abc.ABCMeta" implements these methods in
order to allow the addition of Abstract Base Classes (ABCs) as
“virtual base classes” to any class or type (including built-in
types), including other ABCs.

class.__instancecheck__(self, instance)

   Return true if *instance* should be considered a (direct or
   indirect) instance of *class*. If defined, called to implement
   "isinstance(instance, class)".

class.__subclasscheck__(self, subclass)

   Return true if *subclass* should be considered a (direct or
   indirect) subclass of *class*.  If defined, called to implement
   "issubclass(subclass, class)".

Note that these methods are looked up on the type (metaclass) of a
class.  They cannot be defined as class methods in the actual class.
This is consistent with the lookup of special methods that are called
on instances, only in this case the instance is itself a class.

See also:

  **PEP 3119** - Introducing Abstract Base Classes
     Includes the specification for customizing "isinstance()" and
     "issubclass()" behavior through "__instancecheck__()" and
     "__subclasscheck__()", with motivation for this functionality in
     the context of adding Abstract Base Classes (see the "abc"
     module) to the language.


Emulating generic types
=======================

One can implement the generic class syntax as specified by **PEP 484**
(for example "List[int]") by defining a special method:

classmethod object.__class_getitem__(cls, key)

   Return an object representing the specialization of a generic class
   by type arguments found in *key*.

This method is looked up on the class object itself, and when defined
in the class body, this method is implicitly a class method.  Note,
this mechanism is primarily reserved for use with static type hints,
other usage is discouraged.

See also:

  **PEP 560** - Core support for typing module and generic types


Emulating callable objects
==========================

object.__call__(self[, args...])

   Called when the instance is “called” as a function; if this method
   is defined, "x(arg1, arg2, ...)" roughly translates to
   "type(x).__call__(x, arg1, ...)".


Emulating container types
=========================

The following methods can be defined to implement container objects.
Containers usually are sequences (such as lists or tuples) or mappings
(like dictionaries), but can represent other containers as well.  The
first set of methods is used either to emulate a sequence or to
emulate a mapping; the difference is that for a sequence, the
allowable keys should be the integers *k* for which "0 <= k < N" where
*N* is the length of the sequence, or slice objects, which define a
range of items.  It is also recommended that mappings provide the
methods "keys()", "values()", "items()", "get()", "clear()",
"setdefault()", "pop()", "popitem()", "copy()", and "update()"
behaving similar to those for Python’s standard dictionary objects.
The "collections.abc" module provides a "MutableMapping" abstract base
class to help create those methods from a base set of "__getitem__()",
"__setitem__()", "__delitem__()", and "keys()". Mutable sequences
should provide methods "append()", "count()", "index()", "extend()",
"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python
standard list objects.  Finally, sequence types should implement
addition (meaning concatenation) and multiplication (meaning
repetition) by defining the methods "__add__()", "__radd__()",
"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described
below; they should not define other numerical operators.  It is
recommended that both mappings and sequences implement the
"__contains__()" method to allow efficient use of the "in" operator;
for mappings, "in" should search the mapping’s keys; for sequences, it
should search through the values.  It is further recommended that both
mappings and sequences implement the "__iter__()" method to allow
efficient iteration through the container; for mappings, "__iter__()"
should iterate through the object’s keys; for sequences, it should
iterate through the values.

object.__len__(self)

   Called to implement the built-in function "len()".  Should return
   the length of the object, an integer ">=" 0.  Also, an object that
   doesn’t define a "__bool__()" method and whose "__len__()" method
   returns zero is considered to be false in a Boolean context.

   **CPython implementation detail:** In CPython, the length is
   required to be at most "sys.maxsize". If the length is larger than
   "sys.maxsize" some features (such as "len()") may raise
   "OverflowError".  To prevent raising "OverflowError" by truth value
   testing, an object must define a "__bool__()" method.

object.__length_hint__(self)

   Called to implement "operator.length_hint()". Should return an
   estimated length for the object (which may be greater or less than
   the actual length). The length must be an integer ">=" 0. The
   return value may also be "NotImplemented", which is treated the
   same as if the "__length_hint__" method didn’t exist at all. This
   method is purely an optimization and is never required for
   correctness.

   New in version 3.4.

Note:

  Slicing is done exclusively with the following three methods.  A
  call like

     a[1:2] = b

  is translated to

     a[slice(1, 2, None)] = b

  and so forth.  Missing slice items are always filled in with "None".

object.__getitem__(self, key)

   Called to implement evaluation of "self[key]". For sequence types,
   the accepted keys should be integers and slice objects.  Note that
   the special interpretation of negative indexes (if the class wishes
   to emulate a sequence type) is up to the "__getitem__()" method. If
   *key* is of an inappropriate type, "TypeError" may be raised; if of
   a value outside the set of indexes for the sequence (after any
   special interpretation of negative values), "IndexError" should be
   raised. For mapping types, if *key* is missing (not in the
   container), "KeyError" should be raised.

   Note:

     "for" loops expect that an "IndexError" will be raised for
     illegal indexes to allow proper detection of the end of the
     sequence.

object.__setitem__(self, key, value)

   Called to implement assignment to "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support changes to the values for keys, or if new keys
   can be added, or for sequences if elements can be replaced.  The
   same exceptions should be raised for improper *key* values as for
   the "__getitem__()" method.

object.__delitem__(self, key)

   Called to implement deletion of "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support removal of keys, or for sequences if elements
   can be removed from the sequence.  The same exceptions should be
   raised for improper *key* values as for the "__getitem__()" method.

object.__missing__(self, key)

   Called by "dict"."__getitem__()" to implement "self[key]" for dict
   subclasses when key is not in the dictionary.

object.__iter__(self)

   This method is called when an iterator is required for a container.
   This method should return a new iterator object that can iterate
   over all the objects in the container.  For mappings, it should
   iterate over the keys of the container.

   Iterator objects also need to implement this method; they are
   required to return themselves.  For more information on iterator
   objects, see Iterator Types.

object.__reversed__(self)

   Called (if present) by the "reversed()" built-in to implement
   reverse iteration.  It should return a new iterator object that
   iterates over all the objects in the container in reverse order.

   If the "__reversed__()" method is not provided, the "reversed()"
   built-in will fall back to using the sequence protocol ("__len__()"
   and "__getitem__()").  Objects that support the sequence protocol
   should only provide "__reversed__()" if they can provide an
   implementation that is more efficient than the one provided by
   "reversed()".

The membership test operators ("in" and "not in") are normally
implemented as an iteration through a container. However, container
objects can supply the following special method with a more efficient
implementation, which also does not require the object be iterable.

object.__contains__(self, item)

   Called to implement membership test operators.  Should return true
   if *item* is in *self*, false otherwise.  For mapping objects, this
   should consider the keys of the mapping rather than the values or
   the key-item pairs.

   For objects that don’t define "__contains__()", the membership test
   first tries iteration via "__iter__()", then the old sequence
   iteration protocol via "__getitem__()", see this section in the
   language reference.


Emulating numeric types
=======================

The following methods can be defined to emulate numeric objects.
Methods corresponding to operations that are not supported by the
particular kind of number implemented (e.g., bitwise operations for
non-integral numbers) should be left undefined.

object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
object.__matmul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
object.__divmod__(self, other)
object.__pow__(self, other[, modulo])
object.__lshift__(self, other)
object.__rshift__(self, other)
object.__and__(self, other)
object.__xor__(self, other)
object.__or__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|").  For instance, to
   evaluate the expression "x + y", where *x* is an instance of a
   class that has an "__add__()" method, "x.__add__(y)" is called.
   The "__divmod__()" method should be the equivalent to using
   "__floordiv__()" and "__mod__()"; it should not be related to
   "__truediv__()".  Note that "__pow__()" should be defined to accept
   an optional third argument if the ternary version of the built-in
   "pow()" function is to be supported.

   If one of those methods does not support the operation with the
   supplied arguments, it should return "NotImplemented".

object.__radd__(self, other)
object.__rsub__(self, other)
object.__rmul__(self, other)
object.__rmatmul__(self, other)
object.__rtruediv__(self, other)
object.__rfloordiv__(self, other)
object.__rmod__(self, other)
object.__rdivmod__(self, other)
object.__rpow__(self, other[, modulo])
object.__rlshift__(self, other)
object.__rrshift__(self, other)
object.__rand__(self, other)
object.__rxor__(self, other)
object.__ror__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)
   operands.  These functions are only called if the left operand does
   not support the corresponding operation [3] and the operands are of
   different types. [4] For instance, to evaluate the expression "x -
   y", where *y* is an instance of a class that has an "__rsub__()"
   method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns
   *NotImplemented*.

   Note that ternary "pow()" will not try calling "__rpow__()" (the
   coercion rules would become too complicated).

   Note:

     If the right operand’s type is a subclass of the left operand’s
     type and that subclass provides a different implementation of the
     reflected method for the operation, this method will be called
     before the left operand’s non-reflected method. This behavior
     allows subclasses to override their ancestors’ operations.

object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
object.__imatmul__(self, other)
object.__itruediv__(self, other)
object.__ifloordiv__(self, other)
object.__imod__(self, other)
object.__ipow__(self, other[, modulo])
object.__ilshift__(self, other)
object.__irshift__(self, other)
object.__iand__(self, other)
object.__ixor__(self, other)
object.__ior__(self, other)

   These methods are called to implement the augmented arithmetic
   assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",
   "<<=", ">>=", "&=", "^=", "|=").  These methods should attempt to
   do the operation in-place (modifying *self*) and return the result
   (which could be, but does not have to be, *self*).  If a specific
   method is not defined, the augmented assignment falls back to the
   normal methods.  For instance, if *x* is an instance of a class
   with an "__iadd__()" method, "x += y" is equivalent to "x =
   x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are
   considered, as with the evaluation of "x + y". In certain
   situations, augmented assignment can result in unexpected errors
   (see Why does a_tuple[i] += [‘item’] raise an exception when the
   addition works?), but this behavior is in fact part of the data
   model.

   Note:

     Due to a bug in the dispatching mechanism for "**=", a class that
     defines "__ipow__()" but returns "NotImplemented" would fail to
     fall back to "x.__pow__(y)" and "y.__rpow__(x)". This bug is
     fixed in Python 3.10.

object.__neg__(self)
object.__pos__(self)
object.__abs__(self)
object.__invert__(self)

   Called to implement the unary arithmetic operations ("-", "+",
   "abs()" and "~").

object.__complex__(self)
object.__int__(self)
object.__float__(self)

   Called to implement the built-in functions "complex()", "int()" and
   "float()".  Should return a value of the appropriate type.

object.__index__(self)

   Called to implement "operator.index()", and whenever Python needs
   to losslessly convert the numeric object to an integer object (such
   as in slicing, or in the built-in "bin()", "hex()" and "oct()"
   functions). Presence of this method indicates that the numeric
   object is an integer type.  Must return an integer.

   If "__int__()", "__float__()" and "__complex__()" are not defined
   then corresponding built-in functions "int()", "float()" and
   "complex()" fall back to "__index__()".

object.__round__(self[, ndigits])
object.__trunc__(self)
object.__floor__(self)
object.__ceil__(self)

   Called to implement the built-in function "round()" and "math"
   functions "trunc()", "floor()" and "ceil()". Unless *ndigits* is
   passed to "__round__()" all these methods should return the value
   of the object truncated to an "Integral" (typically an "int").

   The built-in function "int()" falls back to "__trunc__()" if
   neither "__int__()" nor "__index__()" is defined.


With Statement Context Managers
===============================

A *context manager* is an object that defines the runtime context to
be established when executing a "with" statement. The context manager
handles the entry into, and the exit from, the desired runtime context
for the execution of the block of code.  Context managers are normally
invoked using the "with" statement (described in section The with
statement), but can also be used by directly invoking their methods.

Typical uses of context managers include saving and restoring various
kinds of global state, locking and unlocking resources, closing opened
files, etc.

For more information on context managers, see Context Manager Types.

object.__enter__(self)

   Enter the runtime context related to this object. The "with"
   statement will bind this method’s return value to the target(s)
   specified in the "as" clause of the statement, if any.

object.__exit__(self, exc_type, exc_value, traceback)

   Exit the runtime context related to this object. The parameters
   describe the exception that caused the context to be exited. If the
   context was exited without an exception, all three arguments will
   be "None".

   If an exception is supplied, and the method wishes to suppress the
   exception (i.e., prevent it from being propagated), it should
   return a true value. Otherwise, the exception will be processed
   normally upon exit from this method.

   Note that "__exit__()" methods should not reraise the passed-in
   exception; this is the caller’s responsibility.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.


Special method lookup
=====================

For custom classes, implicit invocations of special methods are only
guaranteed to work correctly if defined on an object’s type, not in
the object’s instance dictionary.  That behaviour is the reason why
the following code raises an exception:

   >>> class C:
   ...     pass
   ...
   >>> c = C()
   >>> c.__len__ = lambda: 5
   >>> len(c)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: object of type 'C' has no len()

The rationale behind this behaviour lies with a number of special
methods such as "__hash__()" and "__repr__()" that are implemented by
all objects, including type objects. If the implicit lookup of these
methods used the conventional lookup process, they would fail when
invoked on the type object itself:

   >>> 1 .__hash__() == hash(1)
   True
   >>> int.__hash__() == hash(int)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: descriptor '__hash__' of 'int' object needs an argument

Incorrectly attempting to invoke an unbound method of a class in this
way is sometimes referred to as ‘metaclass confusion’, and is avoided
by bypassing the instance when looking up special methods:

   >>> type(1).__hash__(1) == hash(1)
   True
   >>> type(int).__hash__(int) == hash(int)
   True

In addition to bypassing any instance attributes in the interest of
correctness, implicit special method lookup generally also bypasses
the "__getattribute__()" method even of the object’s metaclass:

   >>> class Meta(type):
   ...     def __getattribute__(*args):
   ...         print("Metaclass getattribute invoked")
   ...         return type.__getattribute__(*args)
   ...
   >>> class C(object, metaclass=Meta):
   ...     def __len__(self):
   ...         return 10
   ...     def __getattribute__(*args):
   ...         print("Class getattribute invoked")
   ...         return object.__getattribute__(*args)
   ...
   >>> c = C()
   >>> c.__len__()                 # Explicit lookup via instance
   Class getattribute invoked
   10
   >>> type(c).__len__(c)          # Explicit lookup via type
   Metaclass getattribute invoked
   10
   >>> len(c)                      # Implicit lookup
   10

Bypassing the "__getattribute__()" machinery in this fashion provides
significant scope for speed optimisations within the interpreter, at
the cost of some flexibility in the handling of special methods (the
special method *must* be set on the class object itself in order to be
consistently invoked by the interpreter).
u�YString Methods
**************

Strings implement all of the common sequence operations, along with
the additional methods described below.

Strings also support two styles of string formatting, one providing a
large degree of flexibility and customization (see "str.format()",
Format String Syntax and Custom String Formatting) and the other based
on C "printf" style formatting that handles a narrower range of types
and is slightly harder to use correctly, but is often faster for the
cases it can handle (printf-style String Formatting).

The Text Processing Services section of the standard library covers a
number of other modules that provide various text related utilities
(including regular expression support in the "re" module).

str.capitalize()

   Return a copy of the string with its first character capitalized
   and the rest lowercased.

   Changed in version 3.8: The first character is now put into
   titlecase rather than uppercase. This means that characters like
   digraphs will only have their first letter capitalized, instead of
   the full character.

str.casefold()

   Return a casefolded copy of the string. Casefolded strings may be
   used for caseless matching.

   Casefolding is similar to lowercasing but more aggressive because
   it is intended to remove all case distinctions in a string. For
   example, the German lowercase letter "'ß'" is equivalent to ""ss"".
   Since it is already lowercase, "lower()" would do nothing to "'ß'";
   "casefold()" converts it to ""ss"".

   The casefolding algorithm is described in section 3.13 of the
   Unicode Standard.

   New in version 3.3.

str.center(width[, fillchar])

   Return centered in a string of length *width*. Padding is done
   using the specified *fillchar* (default is an ASCII space). The
   original string is returned if *width* is less than or equal to
   "len(s)".

str.count(sub[, start[, end]])

   Return the number of non-overlapping occurrences of substring *sub*
   in the range [*start*, *end*].  Optional arguments *start* and
   *end* are interpreted as in slice notation.

str.encode(encoding="utf-8", errors="strict")

   Return an encoded version of the string as a bytes object. Default
   encoding is "'utf-8'". *errors* may be given to set a different
   error handling scheme. The default for *errors* is "'strict'",
   meaning that encoding errors raise a "UnicodeError". Other possible
   values are "'ignore'", "'replace'", "'xmlcharrefreplace'",
   "'backslashreplace'" and any other name registered via
   "codecs.register_error()", see section Error Handlers. For a list
   of possible encodings, see section Standard Encodings.

   Changed in version 3.1: Support for keyword arguments added.

str.endswith(suffix[, start[, end]])

   Return "True" if the string ends with the specified *suffix*,
   otherwise return "False".  *suffix* can also be a tuple of suffixes
   to look for.  With optional *start*, test beginning at that
   position.  With optional *end*, stop comparing at that position.

str.expandtabs(tabsize=8)

   Return a copy of the string where all tab characters are replaced
   by one or more spaces, depending on the current column and the
   given tab size.  Tab positions occur every *tabsize* characters
   (default is 8, giving tab positions at columns 0, 8, 16 and so on).
   To expand the string, the current column is set to zero and the
   string is examined character by character.  If the character is a
   tab ("\t"), one or more space characters are inserted in the result
   until the current column is equal to the next tab position. (The
   tab character itself is not copied.)  If the character is a newline
   ("\n") or return ("\r"), it is copied and the current column is
   reset to zero.  Any other character is copied unchanged and the
   current column is incremented by one regardless of how the
   character is represented when printed.

   >>> '01\t012\t0123\t01234'.expandtabs()
   '01      012     0123    01234'
   >>> '01\t012\t0123\t01234'.expandtabs(4)
   '01  012 0123    01234'

str.find(sub[, start[, end]])

   Return the lowest index in the string where substring *sub* is
   found within the slice "s[start:end]".  Optional arguments *start*
   and *end* are interpreted as in slice notation.  Return "-1" if
   *sub* is not found.

   Note:

     The "find()" method should be used only if you need to know the
     position of *sub*.  To check if *sub* is a substring or not, use
     the "in" operator:

        >>> 'Py' in 'Python'
        True

str.format(*args, **kwargs)

   Perform a string formatting operation.  The string on which this
   method is called can contain literal text or replacement fields
   delimited by braces "{}".  Each replacement field contains either
   the numeric index of a positional argument, or the name of a
   keyword argument.  Returns a copy of the string where each
   replacement field is replaced with the string value of the
   corresponding argument.

   >>> "The sum of 1 + 2 is {0}".format(1+2)
   'The sum of 1 + 2 is 3'

   See Format String Syntax for a description of the various
   formatting options that can be specified in format strings.

   Note:

     When formatting a number ("int", "float", "complex",
     "decimal.Decimal" and subclasses) with the "n" type (ex:
     "'{:n}'.format(1234)"), the function temporarily sets the
     "LC_CTYPE" locale to the "LC_NUMERIC" locale to decode
     "decimal_point" and "thousands_sep" fields of "localeconv()" if
     they are non-ASCII or longer than 1 byte, and the "LC_NUMERIC"
     locale is different than the "LC_CTYPE" locale.  This temporary
     change affects other threads.

   Changed in version 3.7: When formatting a number with the "n" type,
   the function sets temporarily the "LC_CTYPE" locale to the
   "LC_NUMERIC" locale in some cases.

str.format_map(mapping)

   Similar to "str.format(**mapping)", except that "mapping" is used
   directly and not copied to a "dict".  This is useful if for example
   "mapping" is a dict subclass:

   >>> class Default(dict):
   ...     def __missing__(self, key):
   ...         return key
   ...
   >>> '{name} was born in {country}'.format_map(Default(name='Guido'))
   'Guido was born in country'

   New in version 3.2.

str.index(sub[, start[, end]])

   Like "find()", but raise "ValueError" when the substring is not
   found.

str.isalnum()

   Return "True" if all characters in the string are alphanumeric and
   there is at least one character, "False" otherwise.  A character
   "c" is alphanumeric if one of the following returns "True":
   "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".

str.isalpha()

   Return "True" if all characters in the string are alphabetic and
   there is at least one character, "False" otherwise.  Alphabetic
   characters are those characters defined in the Unicode character
   database as “Letter”, i.e., those with general category property
   being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”.  Note that this is
   different from the “Alphabetic” property defined in the Unicode
   Standard.

str.isascii()

   Return "True" if the string is empty or all characters in the
   string are ASCII, "False" otherwise. ASCII characters have code
   points in the range U+0000-U+007F.

   New in version 3.7.

str.isdecimal()

   Return "True" if all characters in the string are decimal
   characters and there is at least one character, "False" otherwise.
   Decimal characters are those that can be used to form numbers in
   base 10, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.  Formally a decimal
   character is a character in the Unicode General Category “Nd”.

str.isdigit()

   Return "True" if all characters in the string are digits and there
   is at least one character, "False" otherwise.  Digits include
   decimal characters and digits that need special handling, such as
   the compatibility superscript digits. This covers digits which
   cannot be used to form numbers in base 10, like the Kharosthi
   numbers.  Formally, a digit is a character that has the property
   value Numeric_Type=Digit or Numeric_Type=Decimal.

str.isidentifier()

   Return "True" if the string is a valid identifier according to the
   language definition, section Identifiers and keywords.

   Call "keyword.iskeyword()" to test whether string "s" is a reserved
   identifier, such as "def" and "class".

   Example:

      >>> from keyword import iskeyword

      >>> 'hello'.isidentifier(), iskeyword('hello')
      True, False
      >>> 'def'.isidentifier(), iskeyword('def')
      True, True

str.islower()

   Return "True" if all cased characters [4] in the string are
   lowercase and there is at least one cased character, "False"
   otherwise.

str.isnumeric()

   Return "True" if all characters in the string are numeric
   characters, and there is at least one character, "False" otherwise.
   Numeric characters include digit characters, and all characters
   that have the Unicode numeric value property, e.g. U+2155, VULGAR
   FRACTION ONE FIFTH.  Formally, numeric characters are those with
   the property value Numeric_Type=Digit, Numeric_Type=Decimal or
   Numeric_Type=Numeric.

str.isprintable()

   Return "True" if all characters in the string are printable or the
   string is empty, "False" otherwise.  Nonprintable characters are
   those characters defined in the Unicode character database as
   “Other” or “Separator”, excepting the ASCII space (0x20) which is
   considered printable.  (Note that printable characters in this
   context are those which should not be escaped when "repr()" is
   invoked on a string.  It has no bearing on the handling of strings
   written to "sys.stdout" or "sys.stderr".)

str.isspace()

   Return "True" if there are only whitespace characters in the string
   and there is at least one character, "False" otherwise.

   A character is *whitespace* if in the Unicode character database
   (see "unicodedata"), either its general category is "Zs"
   (“Separator, space”), or its bidirectional class is one of "WS",
   "B", or "S".

str.istitle()

   Return "True" if the string is a titlecased string and there is at
   least one character, for example uppercase characters may only
   follow uncased characters and lowercase characters only cased ones.
   Return "False" otherwise.

str.isupper()

   Return "True" if all cased characters [4] in the string are
   uppercase and there is at least one cased character, "False"
   otherwise.

str.join(iterable)

   Return a string which is the concatenation of the strings in
   *iterable*. A "TypeError" will be raised if there are any non-
   string values in *iterable*, including "bytes" objects.  The
   separator between elements is the string providing this method.

str.ljust(width[, fillchar])

   Return the string left justified in a string of length *width*.
   Padding is done using the specified *fillchar* (default is an ASCII
   space). The original string is returned if *width* is less than or
   equal to "len(s)".

str.lower()

   Return a copy of the string with all the cased characters [4]
   converted to lowercase.

   The lowercasing algorithm used is described in section 3.13 of the
   Unicode Standard.

str.lstrip([chars])

   Return a copy of the string with leading characters removed.  The
   *chars* argument is a string specifying the set of characters to be
   removed.  If omitted or "None", the *chars* argument defaults to
   removing whitespace.  The *chars* argument is not a prefix; rather,
   all combinations of its values are stripped:

      >>> '   spacious   '.lstrip()
      'spacious   '
      >>> 'www.example.com'.lstrip('cmowz.')
      'example.com'

static str.maketrans(x[, y[, z]])

   This static method returns a translation table usable for
   "str.translate()".

   If there is only one argument, it must be a dictionary mapping
   Unicode ordinals (integers) or characters (strings of length 1) to
   Unicode ordinals, strings (of arbitrary lengths) or "None".
   Character keys will then be converted to ordinals.

   If there are two arguments, they must be strings of equal length,
   and in the resulting dictionary, each character in x will be mapped
   to the character at the same position in y.  If there is a third
   argument, it must be a string, whose characters will be mapped to
   "None" in the result.

str.partition(sep)

   Split the string at the first occurrence of *sep*, and return a
   3-tuple containing the part before the separator, the separator
   itself, and the part after the separator.  If the separator is not
   found, return a 3-tuple containing the string itself, followed by
   two empty strings.

str.replace(old, new[, count])

   Return a copy of the string with all occurrences of substring *old*
   replaced by *new*.  If the optional argument *count* is given, only
   the first *count* occurrences are replaced.

str.rfind(sub[, start[, end]])

   Return the highest index in the string where substring *sub* is
   found, such that *sub* is contained within "s[start:end]".
   Optional arguments *start* and *end* are interpreted as in slice
   notation.  Return "-1" on failure.

str.rindex(sub[, start[, end]])

   Like "rfind()" but raises "ValueError" when the substring *sub* is
   not found.

str.rjust(width[, fillchar])

   Return the string right justified in a string of length *width*.
   Padding is done using the specified *fillchar* (default is an ASCII
   space). The original string is returned if *width* is less than or
   equal to "len(s)".

str.rpartition(sep)

   Split the string at the last occurrence of *sep*, and return a
   3-tuple containing the part before the separator, the separator
   itself, and the part after the separator.  If the separator is not
   found, return a 3-tuple containing two empty strings, followed by
   the string itself.

str.rsplit(sep=None, maxsplit=-1)

   Return a list of the words in the string, using *sep* as the
   delimiter string. If *maxsplit* is given, at most *maxsplit* splits
   are done, the *rightmost* ones.  If *sep* is not specified or
   "None", any whitespace string is a separator.  Except for splitting
   from the right, "rsplit()" behaves like "split()" which is
   described in detail below.

str.rstrip([chars])

   Return a copy of the string with trailing characters removed.  The
   *chars* argument is a string specifying the set of characters to be
   removed.  If omitted or "None", the *chars* argument defaults to
   removing whitespace.  The *chars* argument is not a suffix; rather,
   all combinations of its values are stripped:

      >>> '   spacious   '.rstrip()
      '   spacious'
      >>> 'mississippi'.rstrip('ipz')
      'mississ'

str.split(sep=None, maxsplit=-1)

   Return a list of the words in the string, using *sep* as the
   delimiter string.  If *maxsplit* is given, at most *maxsplit*
   splits are done (thus, the list will have at most "maxsplit+1"
   elements).  If *maxsplit* is not specified or "-1", then there is
   no limit on the number of splits (all possible splits are made).

   If *sep* is given, consecutive delimiters are not grouped together
   and are deemed to delimit empty strings (for example,
   "'1,,2'.split(',')" returns "['1', '', '2']").  The *sep* argument
   may consist of multiple characters (for example,
   "'1<>2<>3'.split('<>')" returns "['1', '2', '3']"). Splitting an
   empty string with a specified separator returns "['']".

   For example:

      >>> '1,2,3'.split(',')
      ['1', '2', '3']
      >>> '1,2,3'.split(',', maxsplit=1)
      ['1', '2,3']
      >>> '1,2,,3,'.split(',')
      ['1', '2', '', '3', '']

   If *sep* is not specified or is "None", a different splitting
   algorithm is applied: runs of consecutive whitespace are regarded
   as a single separator, and the result will contain no empty strings
   at the start or end if the string has leading or trailing
   whitespace.  Consequently, splitting an empty string or a string
   consisting of just whitespace with a "None" separator returns "[]".

   For example:

      >>> '1 2 3'.split()
      ['1', '2', '3']
      >>> '1 2 3'.split(maxsplit=1)
      ['1', '2 3']
      >>> '   1   2   3   '.split()
      ['1', '2', '3']

str.splitlines([keepends])

   Return a list of the lines in the string, breaking at line
   boundaries.  Line breaks are not included in the resulting list
   unless *keepends* is given and true.

   This method splits on the following line boundaries.  In
   particular, the boundaries are a superset of *universal newlines*.

   +-------------------------+-------------------------------+
   | Representation          | Description                   |
   |=========================|===============================|
   | "\n"                    | Line Feed                     |
   +-------------------------+-------------------------------+
   | "\r"                    | Carriage Return               |
   +-------------------------+-------------------------------+
   | "\r\n"                  | Carriage Return + Line Feed   |
   +-------------------------+-------------------------------+
   | "\v" or "\x0b"          | Line Tabulation               |
   +-------------------------+-------------------------------+
   | "\f" or "\x0c"          | Form Feed                     |
   +-------------------------+-------------------------------+
   | "\x1c"                  | File Separator                |
   +-------------------------+-------------------------------+
   | "\x1d"                  | Group Separator               |
   +-------------------------+-------------------------------+
   | "\x1e"                  | Record Separator              |
   +-------------------------+-------------------------------+
   | "\x85"                  | Next Line (C1 Control Code)   |
   +-------------------------+-------------------------------+
   | "\u2028"                | Line Separator                |
   +-------------------------+-------------------------------+
   | "\u2029"                | Paragraph Separator           |
   +-------------------------+-------------------------------+

   Changed in version 3.2: "\v" and "\f" added to list of line
   boundaries.

   For example:

      >>> 'ab c\n\nde fg\rkl\r\n'.splitlines()
      ['ab c', '', 'de fg', 'kl']
      >>> 'ab c\n\nde fg\rkl\r\n'.splitlines(keepends=True)
      ['ab c\n', '\n', 'de fg\r', 'kl\r\n']

   Unlike "split()" when a delimiter string *sep* is given, this
   method returns an empty list for the empty string, and a terminal
   line break does not result in an extra line:

      >>> "".splitlines()
      []
      >>> "One line\n".splitlines()
      ['One line']

   For comparison, "split('\n')" gives:

      >>> ''.split('\n')
      ['']
      >>> 'Two lines\n'.split('\n')
      ['Two lines', '']

str.startswith(prefix[, start[, end]])

   Return "True" if string starts with the *prefix*, otherwise return
   "False". *prefix* can also be a tuple of prefixes to look for.
   With optional *start*, test string beginning at that position.
   With optional *end*, stop comparing string at that position.

str.strip([chars])

   Return a copy of the string with the leading and trailing
   characters removed. The *chars* argument is a string specifying the
   set of characters to be removed. If omitted or "None", the *chars*
   argument defaults to removing whitespace. The *chars* argument is
   not a prefix or suffix; rather, all combinations of its values are
   stripped:

      >>> '   spacious   '.strip()
      'spacious'
      >>> 'www.example.com'.strip('cmowz.')
      'example'

   The outermost leading and trailing *chars* argument values are
   stripped from the string. Characters are removed from the leading
   end until reaching a string character that is not contained in the
   set of characters in *chars*. A similar action takes place on the
   trailing end. For example:

      >>> comment_string = '#....... Section 3.2.1 Issue #32 .......'
      >>> comment_string.strip('.#! ')
      'Section 3.2.1 Issue #32'

str.swapcase()

   Return a copy of the string with uppercase characters converted to
   lowercase and vice versa. Note that it is not necessarily true that
   "s.swapcase().swapcase() == s".

str.title()

   Return a titlecased version of the string where words start with an
   uppercase character and the remaining characters are lowercase.

   For example:

      >>> 'Hello world'.title()
      'Hello World'

   The algorithm uses a simple language-independent definition of a
   word as groups of consecutive letters.  The definition works in
   many contexts but it means that apostrophes in contractions and
   possessives form word boundaries, which may not be the desired
   result:

      >>> "they're bill's friends from the UK".title()
      "They'Re Bill'S Friends From The Uk"

   A workaround for apostrophes can be constructed using regular
   expressions:

      >>> import re
      >>> def titlecase(s):
      ...     return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
      ...                   lambda mo: mo.group(0).capitalize(),
      ...                   s)
      ...
      >>> titlecase("they're bill's friends.")
      "They're Bill's Friends."

str.translate(table)

   Return a copy of the string in which each character has been mapped
   through the given translation table.  The table must be an object
   that implements indexing via "__getitem__()", typically a *mapping*
   or *sequence*.  When indexed by a Unicode ordinal (an integer), the
   table object can do any of the following: return a Unicode ordinal
   or a string, to map the character to one or more other characters;
   return "None", to delete the character from the return string; or
   raise a "LookupError" exception, to map the character to itself.

   You can use "str.maketrans()" to create a translation map from
   character-to-character mappings in different formats.

   See also the "codecs" module for a more flexible approach to custom
   character mappings.

str.upper()

   Return a copy of the string with all the cased characters [4]
   converted to uppercase.  Note that "s.upper().isupper()" might be
   "False" if "s" contains uncased characters or if the Unicode
   category of the resulting character(s) is not “Lu” (Letter,
   uppercase), but e.g. “Lt” (Letter, titlecase).

   The uppercasing algorithm used is described in section 3.13 of the
   Unicode Standard.

str.zfill(width)

   Return a copy of the string left filled with ASCII "'0'" digits to
   make a string of length *width*. A leading sign prefix
   ("'+'"/"'-'") is handled by inserting the padding *after* the sign
   character rather than before. The original string is returned if
   *width* is less than or equal to "len(s)".

   For example:

      >>> "42".zfill(5)
      '00042'
      >>> "-42".zfill(5)
      '-0042'
u� String and Bytes literals
*************************

String literals are described by the following lexical definitions:

   stringliteral   ::= [stringprefix](shortstring | longstring)
   stringprefix    ::= "r" | "u" | "R" | "U" | "f" | "F"
                    | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
   shortstring     ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
   longstring      ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
   shortstringitem ::= shortstringchar | stringescapeseq
   longstringitem  ::= longstringchar | stringescapeseq
   shortstringchar ::= <any source character except "\" or newline or the quote>
   longstringchar  ::= <any source character except "\">
   stringescapeseq ::= "\" <any source character>

   bytesliteral   ::= bytesprefix(shortbytes | longbytes)
   bytesprefix    ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"
   shortbytes     ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
   longbytes      ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
   shortbytesitem ::= shortbyteschar | bytesescapeseq
   longbytesitem  ::= longbyteschar | bytesescapeseq
   shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
   longbyteschar  ::= <any ASCII character except "\">
   bytesescapeseq ::= "\" <any ASCII character>

One syntactic restriction not indicated by these productions is that
whitespace is not allowed between the "stringprefix" or "bytesprefix"
and the rest of the literal. The source character set is defined by
the encoding declaration; it is UTF-8 if no encoding declaration is
given in the source file; see section Encoding declarations.

In plain English: Both types of literals can be enclosed in matching
single quotes ("'") or double quotes (""").  They can also be enclosed
in matching groups of three single or double quotes (these are
generally referred to as *triple-quoted strings*).  The backslash
("\") character is used to escape characters that otherwise have a
special meaning, such as newline, backslash itself, or the quote
character.

Bytes literals are always prefixed with "'b'" or "'B'"; they produce
an instance of the "bytes" type instead of the "str" type.  They may
only contain ASCII characters; bytes with a numeric value of 128 or
greater must be expressed with escapes.

Both string and bytes literals may optionally be prefixed with a
letter "'r'" or "'R'"; such strings are called *raw strings* and treat
backslashes as literal characters.  As a result, in string literals,
"'\U'" and "'\u'" escapes in raw strings are not treated specially.
Given that Python 2.x’s raw unicode literals behave differently than
Python 3.x’s the "'ur'" syntax is not supported.

New in version 3.3: The "'rb'" prefix of raw bytes literals has been
added as a synonym of "'br'".

New in version 3.3: Support for the unicode legacy literal
("u'value'") was reintroduced to simplify the maintenance of dual
Python 2.x and 3.x codebases. See **PEP 414** for more information.

A string literal with "'f'" or "'F'" in its prefix is a *formatted
string literal*; see Formatted string literals.  The "'f'" may be
combined with "'r'", but not with "'b'" or "'u'", therefore raw
formatted strings are possible, but formatted bytes literals are not.

In triple-quoted literals, unescaped newlines and quotes are allowed
(and are retained), except that three unescaped quotes in a row
terminate the literal.  (A “quote” is the character used to open the
literal, i.e. either "'" or """.)

Unless an "'r'" or "'R'" prefix is present, escape sequences in string
and bytes literals are interpreted according to rules similar to those
used by Standard C.  The recognized escape sequences are:

+-------------------+-----------------------------------+---------+
| Escape Sequence   | Meaning                           | Notes   |
|===================|===================================|=========|
| "\newline"        | Backslash and newline ignored     |         |
+-------------------+-----------------------------------+---------+
| "\\"              | Backslash ("\")                   |         |
+-------------------+-----------------------------------+---------+
| "\'"              | Single quote ("'")                |         |
+-------------------+-----------------------------------+---------+
| "\""              | Double quote (""")                |         |
+-------------------+-----------------------------------+---------+
| "\a"              | ASCII Bell (BEL)                  |         |
+-------------------+-----------------------------------+---------+
| "\b"              | ASCII Backspace (BS)              |         |
+-------------------+-----------------------------------+---------+
| "\f"              | ASCII Formfeed (FF)               |         |
+-------------------+-----------------------------------+---------+
| "\n"              | ASCII Linefeed (LF)               |         |
+-------------------+-----------------------------------+---------+
| "\r"              | ASCII Carriage Return (CR)        |         |
+-------------------+-----------------------------------+---------+
| "\t"              | ASCII Horizontal Tab (TAB)        |         |
+-------------------+-----------------------------------+---------+
| "\v"              | ASCII Vertical Tab (VT)           |         |
+-------------------+-----------------------------------+---------+
| "\ooo"            | Character with octal value *ooo*  | (1,3)   |
+-------------------+-----------------------------------+---------+
| "\xhh"            | Character with hex value *hh*     | (2,3)   |
+-------------------+-----------------------------------+---------+

Escape sequences only recognized in string literals are:

+-------------------+-----------------------------------+---------+
| Escape Sequence   | Meaning                           | Notes   |
|===================|===================================|=========|
| "\N{name}"        | Character named *name* in the     | (4)     |
|                   | Unicode database                  |         |
+-------------------+-----------------------------------+---------+
| "\uxxxx"          | Character with 16-bit hex value   | (5)     |
|                   | *xxxx*                            |         |
+-------------------+-----------------------------------+---------+
| "\Uxxxxxxxx"      | Character with 32-bit hex value   | (6)     |
|                   | *xxxxxxxx*                        |         |
+-------------------+-----------------------------------+---------+

Notes:

1. As in Standard C, up to three octal digits are accepted.

2. Unlike in Standard C, exactly two hex digits are required.

3. In a bytes literal, hexadecimal and octal escapes denote the byte
   with the given value. In a string literal, these escapes denote a
   Unicode character with the given value.

4. Changed in version 3.3: Support for name aliases [1] has been
   added.

5. Exactly four hex digits are required.

6. Any Unicode character can be encoded this way.  Exactly eight hex
   digits are required.

Unlike Standard C, all unrecognized escape sequences are left in the
string unchanged, i.e., *the backslash is left in the result*.  (This
behavior is useful when debugging: if an escape sequence is mistyped,
the resulting output is more easily recognized as broken.)  It is also
important to note that the escape sequences only recognized in string
literals fall into the category of unrecognized escapes for bytes
literals.

   Changed in version 3.6: Unrecognized escape sequences produce a
   "DeprecationWarning".  In a future Python version they will be a
   "SyntaxWarning" and eventually a "SyntaxError".

Even in a raw literal, quotes can be escaped with a backslash, but the
backslash remains in the result; for example, "r"\""" is a valid
string literal consisting of two characters: a backslash and a double
quote; "r"\"" is not a valid string literal (even a raw string cannot
end in an odd number of backslashes).  Specifically, *a raw literal
cannot end in a single backslash* (since the backslash would escape
the following quote character).  Note also that a single backslash
followed by a newline is interpreted as those two characters as part
of the literal, *not* as a line continuation.
uMSubscriptions
*************

A subscription selects an item of a sequence (string, tuple or list)
or mapping (dictionary) object:

   subscription ::= primary "[" expression_list "]"

The primary must evaluate to an object that supports subscription
(lists or dictionaries for example).  User-defined objects can support
subscription by defining a "__getitem__()" method.

For built-in objects, there are two types of objects that support
subscription:

If the primary is a mapping, the expression list must evaluate to an
object whose value is one of the keys of the mapping, and the
subscription selects the value in the mapping that corresponds to that
key.  (The expression list is a tuple except if it has exactly one
item.)

If the primary is a sequence, the expression list must evaluate to an
integer or a slice (as discussed in the following section).

The formal syntax makes no special provision for negative indices in
sequences; however, built-in sequences all provide a "__getitem__()"
method that interprets negative indices by adding the length of the
sequence to the index (so that "x[-1]" selects the last item of "x").
The resulting value must be a nonnegative integer less than the number
of items in the sequence, and the subscription selects the item whose
index is that value (counting from zero). Since the support for
negative indices and slicing occurs in the object’s "__getitem__()"
method, subclasses overriding this method will need to explicitly add
that support.

A string’s items are characters.  A character is not a separate data
type but a string of exactly one character.
axTruth Value Testing
*******************

Any object can be tested for truth value, for use in an "if" or
"while" condition or as operand of the Boolean operations below.

By default, an object is considered true unless its class defines
either a "__bool__()" method that returns "False" or a "__len__()"
method that returns zero, when called with the object. [1]  Here are
most of the built-in objects considered false:

* constants defined to be false: "None" and "False".

* zero of any numeric type: "0", "0.0", "0j", "Decimal(0)",
  "Fraction(0, 1)"

* empty sequences and collections: "''", "()", "[]", "{}", "set()",
  "range(0)"

Operations and built-in functions that have a Boolean result always
return "0" or "False" for false and "1" or "True" for true, unless
otherwise stated. (Important exception: the Boolean operations "or"
and "and" always return one of their operands.)
uRThe "try" statement
*******************

The "try" statement specifies exception handlers and/or cleanup code
for a group of statements:

   try_stmt  ::= try1_stmt | try2_stmt
   try1_stmt ::= "try" ":" suite
                 ("except" [expression ["as" identifier]] ":" suite)+
                 ["else" ":" suite]
                 ["finally" ":" suite]
   try2_stmt ::= "try" ":" suite
                 "finally" ":" suite

The "except" clause(s) specify one or more exception handlers. When no
exception occurs in the "try" clause, no exception handler is
executed. When an exception occurs in the "try" suite, a search for an
exception handler is started.  This search inspects the except clauses
in turn until one is found that matches the exception.  An expression-
less except clause, if present, must be last; it matches any
exception.  For an except clause with an expression, that expression
is evaluated, and the clause matches the exception if the resulting
object is “compatible” with the exception.  An object is compatible
with an exception if it is the class or a base class of the exception
object, or a tuple containing an item that is the class or a base
class of the exception object.

If no except clause matches the exception, the search for an exception
handler continues in the surrounding code and on the invocation stack.
[1]

If the evaluation of an expression in the header of an except clause
raises an exception, the original search for a handler is canceled and
a search starts for the new exception in the surrounding code and on
the call stack (it is treated as if the entire "try" statement raised
the exception).

When a matching except clause is found, the exception is assigned to
the target specified after the "as" keyword in that except clause, if
present, and the except clause’s suite is executed.  All except
clauses must have an executable block.  When the end of this block is
reached, execution continues normally after the entire try statement.
(This means that if two nested handlers exist for the same exception,
and the exception occurs in the try clause of the inner handler, the
outer handler will not handle the exception.)

When an exception has been assigned using "as target", it is cleared
at the end of the except clause.  This is as if

   except E as N:
       foo

was translated to

   except E as N:
       try:
           foo
       finally:
           del N

This means the exception must be assigned to a different name to be
able to refer to it after the except clause.  Exceptions are cleared
because with the traceback attached to them, they form a reference
cycle with the stack frame, keeping all locals in that frame alive
until the next garbage collection occurs.

Before an except clause’s suite is executed, details about the
exception are stored in the "sys" module and can be accessed via
"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the
exception class, the exception instance and a traceback object (see
section The standard type hierarchy) identifying the point in the
program where the exception occurred.  "sys.exc_info()" values are
restored to their previous values (before the call) when returning
from a function that handled an exception.

The optional "else" clause is executed if the control flow leaves the
"try" suite, no exception was raised, and no "return", "continue", or
"break" statement was executed.  Exceptions in the "else" clause are
not handled by the preceding "except" clauses.

If "finally" is present, it specifies a ‘cleanup’ handler.  The "try"
clause is executed, including any "except" and "else" clauses.  If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed.  If
there is a saved exception it is re-raised at the end of the "finally"
clause.  If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:

   >>> def f():
   ...     try:
   ...         1/0
   ...     finally:
   ...         return 42
   ...
   >>> f()
   42

The exception information is not available to the program during
execution of the "finally" clause.

When a "return", "break" or "continue" statement is executed in the
"try" suite of a "try"…"finally" statement, the "finally" clause is
also executed ‘on the way out.’

The return value of a function is determined by the last "return"
statement executed.  Since the "finally" clause always executes, a
"return" statement executed in the "finally" clause will always be the
last one executed:

   >>> def foo():
   ...     try:
   ...         return 'try'
   ...     finally:
   ...         return 'finally'
   ...
   >>> foo()
   'finally'

Additional information on exceptions can be found in section
Exceptions, and information on using the "raise" statement to generate
exceptions may be found in section The raise statement.

Changed in version 3.8: Prior to Python 3.8, a "continue" statement
was illegal in the "finally" clause due to a problem with the
implementation.
ux�The standard type hierarchy
***************************

Below is a list of the types that are built into Python.  Extension
modules (written in C, Java, or other languages, depending on the
implementation) can define additional types.  Future versions of
Python may add types to the type hierarchy (e.g., rational numbers,
efficiently stored arrays of integers, etc.), although such additions
will often be provided via the standard library instead.

Some of the type descriptions below contain a paragraph listing
‘special attributes.’  These are attributes that provide access to the
implementation and are not intended for general use.  Their definition
may change in the future.

None
   This type has a single value.  There is a single object with this
   value. This object is accessed through the built-in name "None". It
   is used to signify the absence of a value in many situations, e.g.,
   it is returned from functions that don’t explicitly return
   anything. Its truth value is false.

NotImplemented
   This type has a single value.  There is a single object with this
   value. This object is accessed through the built-in name
   "NotImplemented". Numeric methods and rich comparison methods
   should return this value if they do not implement the operation for
   the operands provided.  (The interpreter will then try the
   reflected operation, or some other fallback, depending on the
   operator.)  Its truth value is true.

   See Implementing the arithmetic operations for more details.

Ellipsis
   This type has a single value.  There is a single object with this
   value. This object is accessed through the literal "..." or the
   built-in name "Ellipsis".  Its truth value is true.

"numbers.Number"
   These are created by numeric literals and returned as results by
   arithmetic operators and arithmetic built-in functions.  Numeric
   objects are immutable; once created their value never changes.
   Python numbers are of course strongly related to mathematical
   numbers, but subject to the limitations of numerical representation
   in computers.

   The string representations of the numeric classes, computed by
   "__repr__()" and "__str__()", have the following properties:

   * They are valid numeric literals which, when passed to their class
     constructor, produce an object having the value of the original
     numeric.

   * The representation is in base 10, when possible.

   * Leading zeros, possibly excepting a single zero before a decimal
     point, are not shown.

   * Trailing zeros, possibly excepting a single zero after a decimal
     point, are not shown.

   * A sign is shown only when the number is negative.

   Python distinguishes between integers, floating point numbers, and
   complex numbers:

   "numbers.Integral"
      These represent elements from the mathematical set of integers
      (positive and negative).

      There are two types of integers:

      Integers ("int")
         These represent numbers in an unlimited range, subject to
         available (virtual) memory only.  For the purpose of shift
         and mask operations, a binary representation is assumed, and
         negative numbers are represented in a variant of 2’s
         complement which gives the illusion of an infinite string of
         sign bits extending to the left.

      Booleans ("bool")
         These represent the truth values False and True.  The two
         objects representing the values "False" and "True" are the
         only Boolean objects. The Boolean type is a subtype of the
         integer type, and Boolean values behave like the values 0 and
         1, respectively, in almost all contexts, the exception being
         that when converted to a string, the strings ""False"" or
         ""True"" are returned, respectively.

      The rules for integer representation are intended to give the
      most meaningful interpretation of shift and mask operations
      involving negative integers.

   "numbers.Real" ("float")
      These represent machine-level double precision floating point
      numbers. You are at the mercy of the underlying machine
      architecture (and C or Java implementation) for the accepted
      range and handling of overflow. Python does not support single-
      precision floating point numbers; the savings in processor and
      memory usage that are usually the reason for using these are
      dwarfed by the overhead of using objects in Python, so there is
      no reason to complicate the language with two kinds of floating
      point numbers.

   "numbers.Complex" ("complex")
      These represent complex numbers as a pair of machine-level
      double precision floating point numbers.  The same caveats apply
      as for floating point numbers. The real and imaginary parts of a
      complex number "z" can be retrieved through the read-only
      attributes "z.real" and "z.imag".

Sequences
   These represent finite ordered sets indexed by non-negative
   numbers. The built-in function "len()" returns the number of items
   of a sequence. When the length of a sequence is *n*, the index set
   contains the numbers 0, 1, …, *n*-1.  Item *i* of sequence *a* is
   selected by "a[i]".

   Sequences also support slicing: "a[i:j]" selects all items with
   index *k* such that *i* "<=" *k* "<" *j*.  When used as an
   expression, a slice is a sequence of the same type.  This implies
   that the index set is renumbered so that it starts at 0.

   Some sequences also support “extended slicing” with a third “step”
   parameter: "a[i:j:k]" selects all items of *a* with index *x* where
   "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.

   Sequences are distinguished according to their mutability:

   Immutable sequences
      An object of an immutable sequence type cannot change once it is
      created.  (If the object contains references to other objects,
      these other objects may be mutable and may be changed; however,
      the collection of objects directly referenced by an immutable
      object cannot change.)

      The following types are immutable sequences:

      Strings
         A string is a sequence of values that represent Unicode code
         points. All the code points in the range "U+0000 - U+10FFFF"
         can be represented in a string.  Python doesn’t have a "char"
         type; instead, every code point in the string is represented
         as a string object with length "1".  The built-in function
         "ord()" converts a code point from its string form to an
         integer in the range "0 - 10FFFF"; "chr()" converts an
         integer in the range "0 - 10FFFF" to the corresponding length
         "1" string object. "str.encode()" can be used to convert a
         "str" to "bytes" using the given text encoding, and
         "bytes.decode()" can be used to achieve the opposite.

      Tuples
         The items of a tuple are arbitrary Python objects. Tuples of
         two or more items are formed by comma-separated lists of
         expressions.  A tuple of one item (a ‘singleton’) can be
         formed by affixing a comma to an expression (an expression by
         itself does not create a tuple, since parentheses must be
         usable for grouping of expressions).  An empty tuple can be
         formed by an empty pair of parentheses.

      Bytes
         A bytes object is an immutable array.  The items are 8-bit
         bytes, represented by integers in the range 0 <= x < 256.
         Bytes literals (like "b'abc'") and the built-in "bytes()"
         constructor can be used to create bytes objects.  Also, bytes
         objects can be decoded to strings via the "decode()" method.

   Mutable sequences
      Mutable sequences can be changed after they are created.  The
      subscription and slicing notations can be used as the target of
      assignment and "del" (delete) statements.

      There are currently two intrinsic mutable sequence types:

      Lists
         The items of a list are arbitrary Python objects.  Lists are
         formed by placing a comma-separated list of expressions in
         square brackets. (Note that there are no special cases needed
         to form lists of length 0 or 1.)

      Byte Arrays
         A bytearray object is a mutable array. They are created by
         the built-in "bytearray()" constructor.  Aside from being
         mutable (and hence unhashable), byte arrays otherwise provide
         the same interface and functionality as immutable "bytes"
         objects.

      The extension module "array" provides an additional example of a
      mutable sequence type, as does the "collections" module.

Set types
   These represent unordered, finite sets of unique, immutable
   objects. As such, they cannot be indexed by any subscript. However,
   they can be iterated over, and the built-in function "len()"
   returns the number of items in a set. Common uses for sets are fast
   membership testing, removing duplicates from a sequence, and
   computing mathematical operations such as intersection, union,
   difference, and symmetric difference.

   For set elements, the same immutability rules apply as for
   dictionary keys. Note that numeric types obey the normal rules for
   numeric comparison: if two numbers compare equal (e.g., "1" and
   "1.0"), only one of them can be contained in a set.

   There are currently two intrinsic set types:

   Sets
      These represent a mutable set. They are created by the built-in
      "set()" constructor and can be modified afterwards by several
      methods, such as "add()".

   Frozen sets
      These represent an immutable set.  They are created by the
      built-in "frozenset()" constructor.  As a frozenset is immutable
      and *hashable*, it can be used again as an element of another
      set, or as a dictionary key.

Mappings
   These represent finite sets of objects indexed by arbitrary index
   sets. The subscript notation "a[k]" selects the item indexed by "k"
   from the mapping "a"; this can be used in expressions and as the
   target of assignments or "del" statements. The built-in function
   "len()" returns the number of items in a mapping.

   There is currently a single intrinsic mapping type:

   Dictionaries
      These represent finite sets of objects indexed by nearly
      arbitrary values.  The only types of values not acceptable as
      keys are values containing lists or dictionaries or other
      mutable types that are compared by value rather than by object
      identity, the reason being that the efficient implementation of
      dictionaries requires a key’s hash value to remain constant.
      Numeric types used for keys obey the normal rules for numeric
      comparison: if two numbers compare equal (e.g., "1" and "1.0")
      then they can be used interchangeably to index the same
      dictionary entry.

      Dictionaries preserve insertion order, meaning that keys will be
      produced in the same order they were added sequentially over the
      dictionary. Replacing an existing key does not change the order,
      however removing a key and re-inserting it will add it to the
      end instead of keeping its old place.

      Dictionaries are mutable; they can be created by the "{...}"
      notation (see section Dictionary displays).

      The extension modules "dbm.ndbm" and "dbm.gnu" provide
      additional examples of mapping types, as does the "collections"
      module.

      Changed in version 3.7: Dictionaries did not preserve insertion
      order in versions of Python before 3.6. In CPython 3.6,
      insertion order was preserved, but it was considered an
      implementation detail at that time rather than a language
      guarantee.

Callable types
   These are the types to which the function call operation (see
   section Calls) can be applied:

   User-defined functions
      A user-defined function object is created by a function
      definition (see section Function definitions).  It should be
      called with an argument list containing the same number of items
      as the function’s formal parameter list.

      Special attributes:

      +---------------------------+---------------------------------+-------------+
      | Attribute                 | Meaning                         |             |
      |===========================|=================================|=============|
      | "__doc__"                 | The function’s documentation    | Writable    |
      |                           | string, or "None" if            |             |
      |                           | unavailable; not inherited by   |             |
      |                           | subclasses.                     |             |
      +---------------------------+---------------------------------+-------------+
      | "__name__"                | The function’s name.            | Writable    |
      +---------------------------+---------------------------------+-------------+
      | "__qualname__"            | The function’s *qualified       | Writable    |
      |                           | name*.  New in version 3.3.     |             |
      +---------------------------+---------------------------------+-------------+
      | "__module__"              | The name of the module the      | Writable    |
      |                           | function was defined in, or     |             |
      |                           | "None" if unavailable.          |             |
      +---------------------------+---------------------------------+-------------+
      | "__defaults__"            | A tuple containing default      | Writable    |
      |                           | argument values for those       |             |
      |                           | arguments that have defaults,   |             |
      |                           | or "None" if no arguments have  |             |
      |                           | a default value.                |             |
      +---------------------------+---------------------------------+-------------+
      | "__code__"                | The code object representing    | Writable    |
      |                           | the compiled function body.     |             |
      +---------------------------+---------------------------------+-------------+
      | "__globals__"             | A reference to the dictionary   | Read-only   |
      |                           | that holds the function’s       |             |
      |                           | global variables — the global   |             |
      |                           | namespace of the module in      |             |
      |                           | which the function was defined. |             |
      +---------------------------+---------------------------------+-------------+
      | "__dict__"                | The namespace supporting        | Writable    |
      |                           | arbitrary function attributes.  |             |
      +---------------------------+---------------------------------+-------------+
      | "__closure__"             | "None" or a tuple of cells that | Read-only   |
      |                           | contain bindings for the        |             |
      |                           | function’s free variables. See  |             |
      |                           | below for information on the    |             |
      |                           | "cell_contents" attribute.      |             |
      +---------------------------+---------------------------------+-------------+
      | "__annotations__"         | A dict containing annotations   | Writable    |
      |                           | of parameters.  The keys of the |             |
      |                           | dict are the parameter names,   |             |
      |                           | and "'return'" for the return   |             |
      |                           | annotation, if provided.        |             |
      +---------------------------+---------------------------------+-------------+
      | "__kwdefaults__"          | A dict containing defaults for  | Writable    |
      |                           | keyword-only parameters.        |             |
      +---------------------------+---------------------------------+-------------+

      Most of the attributes labelled “Writable” check the type of the
      assigned value.

      Function objects also support getting and setting arbitrary
      attributes, which can be used, for example, to attach metadata
      to functions.  Regular attribute dot-notation is used to get and
      set such attributes. *Note that the current implementation only
      supports function attributes on user-defined functions. Function
      attributes on built-in functions may be supported in the
      future.*

      A cell object has the attribute "cell_contents". This can be
      used to get the value of the cell, as well as set the value.

      Additional information about a function’s definition can be
      retrieved from its code object; see the description of internal
      types below. The "cell" type can be accessed in the "types"
      module.

   Instance methods
      An instance method object combines a class, a class instance and
      any callable object (normally a user-defined function).

      Special read-only attributes: "__self__" is the class instance
      object, "__func__" is the function object; "__doc__" is the
      method’s documentation (same as "__func__.__doc__"); "__name__"
      is the method name (same as "__func__.__name__"); "__module__"
      is the name of the module the method was defined in, or "None"
      if unavailable.

      Methods also support accessing (but not setting) the arbitrary
      function attributes on the underlying function object.

      User-defined method objects may be created when getting an
      attribute of a class (perhaps via an instance of that class), if
      that attribute is a user-defined function object or a class
      method object.

      When an instance method object is created by retrieving a user-
      defined function object from a class via one of its instances,
      its "__self__" attribute is the instance, and the method object
      is said to be bound.  The new method’s "__func__" attribute is
      the original function object.

      When an instance method object is created by retrieving a class
      method object from a class or instance, its "__self__" attribute
      is the class itself, and its "__func__" attribute is the
      function object underlying the class method.

      When an instance method object is called, the underlying
      function ("__func__") is called, inserting the class instance
      ("__self__") in front of the argument list.  For instance, when
      "C" is a class which contains a definition for a function "f()",
      and "x" is an instance of "C", calling "x.f(1)" is equivalent to
      calling "C.f(x, 1)".

      When an instance method object is derived from a class method
      object, the “class instance” stored in "__self__" will actually
      be the class itself, so that calling either "x.f(1)" or "C.f(1)"
      is equivalent to calling "f(C,1)" where "f" is the underlying
      function.

      Note that the transformation from function object to instance
      method object happens each time the attribute is retrieved from
      the instance.  In some cases, a fruitful optimization is to
      assign the attribute to a local variable and call that local
      variable. Also notice that this transformation only happens for
      user-defined functions; other callable objects (and all non-
      callable objects) are retrieved without transformation.  It is
      also important to note that user-defined functions which are
      attributes of a class instance are not converted to bound
      methods; this *only* happens when the function is an attribute
      of the class.

   Generator functions
      A function or method which uses the "yield" statement (see
      section The yield statement) is called a *generator function*.
      Such a function, when called, always returns an iterator object
      which can be used to execute the body of the function:  calling
      the iterator’s "iterator.__next__()" method will cause the
      function to execute until it provides a value using the "yield"
      statement.  When the function executes a "return" statement or
      falls off the end, a "StopIteration" exception is raised and the
      iterator will have reached the end of the set of values to be
      returned.

   Coroutine functions
      A function or method which is defined using "async def" is
      called a *coroutine function*.  Such a function, when called,
      returns a *coroutine* object.  It may contain "await"
      expressions, as well as "async with" and "async for" statements.
      See also the Coroutine Objects section.

   Asynchronous generator functions
      A function or method which is defined using "async def" and
      which uses the "yield" statement is called a *asynchronous
      generator function*.  Such a function, when called, returns an
      asynchronous iterator object which can be used in an "async for"
      statement to execute the body of the function.

      Calling the asynchronous iterator’s "aiterator.__anext__()"
      method will return an *awaitable* which when awaited will
      execute until it provides a value using the "yield" expression.
      When the function executes an empty "return" statement or falls
      off the end, a "StopAsyncIteration" exception is raised and the
      asynchronous iterator will have reached the end of the set of
      values to be yielded.

   Built-in functions
      A built-in function object is a wrapper around a C function.
      Examples of built-in functions are "len()" and "math.sin()"
      ("math" is a standard built-in module). The number and type of
      the arguments are determined by the C function. Special read-
      only attributes: "__doc__" is the function’s documentation
      string, or "None" if unavailable; "__name__" is the function’s
      name; "__self__" is set to "None" (but see the next item);
      "__module__" is the name of the module the function was defined
      in or "None" if unavailable.

   Built-in methods
      This is really a different disguise of a built-in function, this
      time containing an object passed to the C function as an
      implicit extra argument.  An example of a built-in method is
      "alist.append()", assuming *alist* is a list object. In this
      case, the special read-only attribute "__self__" is set to the
      object denoted by *alist*.

   Classes
      Classes are callable.  These objects normally act as factories
      for new instances of themselves, but variations are possible for
      class types that override "__new__()".  The arguments of the
      call are passed to "__new__()" and, in the typical case, to
      "__init__()" to initialize the new instance.

   Class Instances
      Instances of arbitrary classes can be made callable by defining
      a "__call__()" method in their class.

Modules
   Modules are a basic organizational unit of Python code, and are
   created by the import system as invoked either by the "import"
   statement, or by calling functions such as
   "importlib.import_module()" and built-in "__import__()".  A module
   object has a namespace implemented by a dictionary object (this is
   the dictionary referenced by the "__globals__" attribute of
   functions defined in the module).  Attribute references are
   translated to lookups in this dictionary, e.g., "m.x" is equivalent
   to "m.__dict__["x"]". A module object does not contain the code
   object used to initialize the module (since it isn’t needed once
   the initialization is done).

   Attribute assignment updates the module’s namespace dictionary,
   e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".

   Predefined (writable) attributes: "__name__" is the module’s name;
   "__doc__" is the module’s documentation string, or "None" if
   unavailable; "__annotations__" (optional) is a dictionary
   containing *variable annotations* collected during module body
   execution; "__file__" is the pathname of the file from which the
   module was loaded, if it was loaded from a file. The "__file__"
   attribute may be missing for certain types of modules, such as C
   modules that are statically linked into the interpreter; for
   extension modules loaded dynamically from a shared library, it is
   the pathname of the shared library file.

   Special read-only attribute: "__dict__" is the module’s namespace
   as a dictionary object.

   **CPython implementation detail:** Because of the way CPython
   clears module dictionaries, the module dictionary will be cleared
   when the module falls out of scope even if the dictionary still has
   live references.  To avoid this, copy the dictionary or keep the
   module around while using its dictionary directly.

Custom classes
   Custom class types are typically created by class definitions (see
   section Class definitions).  A class has a namespace implemented by
   a dictionary object. Class attribute references are translated to
   lookups in this dictionary, e.g., "C.x" is translated to
   "C.__dict__["x"]" (although there are a number of hooks which allow
   for other means of locating attributes). When the attribute name is
   not found there, the attribute search continues in the base
   classes. This search of the base classes uses the C3 method
   resolution order which behaves correctly even in the presence of
   ‘diamond’ inheritance structures where there are multiple
   inheritance paths leading back to a common ancestor. Additional
   details on the C3 MRO used by Python can be found in the
   documentation accompanying the 2.3 release at
   https://www.python.org/download/releases/2.3/mro/.

   When a class attribute reference (for class "C", say) would yield a
   class method object, it is transformed into an instance method
   object whose "__self__" attribute is "C".  When it would yield a
   static method object, it is transformed into the object wrapped by
   the static method object. See section Implementing Descriptors for
   another way in which attributes retrieved from a class may differ
   from those actually contained in its "__dict__".

   Class attribute assignments update the class’s dictionary, never
   the dictionary of a base class.

   A class object can be called (see above) to yield a class instance
   (see below).

   Special attributes: "__name__" is the class name; "__module__" is
   the module name in which the class was defined; "__dict__" is the
   dictionary containing the class’s namespace; "__bases__" is a tuple
   containing the base classes, in the order of their occurrence in
   the base class list; "__doc__" is the class’s documentation string,
   or "None" if undefined; "__annotations__" (optional) is a
   dictionary containing *variable annotations* collected during class
   body execution.

Class instances
   A class instance is created by calling a class object (see above).
   A class instance has a namespace implemented as a dictionary which
   is the first place in which attribute references are searched.
   When an attribute is not found there, and the instance’s class has
   an attribute by that name, the search continues with the class
   attributes.  If a class attribute is found that is a user-defined
   function object, it is transformed into an instance method object
   whose "__self__" attribute is the instance.  Static method and
   class method objects are also transformed; see above under
   “Classes”.  See section Implementing Descriptors for another way in
   which attributes of a class retrieved via its instances may differ
   from the objects actually stored in the class’s "__dict__".  If no
   class attribute is found, and the object’s class has a
   "__getattr__()" method, that is called to satisfy the lookup.

   Attribute assignments and deletions update the instance’s
   dictionary, never a class’s dictionary.  If the class has a
   "__setattr__()" or "__delattr__()" method, this is called instead
   of updating the instance dictionary directly.

   Class instances can pretend to be numbers, sequences, or mappings
   if they have methods with certain special names.  See section
   Special method names.

   Special attributes: "__dict__" is the attribute dictionary;
   "__class__" is the instance’s class.

I/O objects (also known as file objects)
   A *file object* represents an open file.  Various shortcuts are
   available to create file objects: the "open()" built-in function,
   and also "os.popen()", "os.fdopen()", and the "makefile()" method
   of socket objects (and perhaps by other functions or methods
   provided by extension modules).

   The objects "sys.stdin", "sys.stdout" and "sys.stderr" are
   initialized to file objects corresponding to the interpreter’s
   standard input, output and error streams; they are all open in text
   mode and therefore follow the interface defined by the
   "io.TextIOBase" abstract class.

Internal types
   A few types used internally by the interpreter are exposed to the
   user. Their definitions may change with future versions of the
   interpreter, but they are mentioned here for completeness.

   Code objects
      Code objects represent *byte-compiled* executable Python code,
      or *bytecode*. The difference between a code object and a
      function object is that the function object contains an explicit
      reference to the function’s globals (the module in which it was
      defined), while a code object contains no context; also the
      default argument values are stored in the function object, not
      in the code object (because they represent values calculated at
      run-time).  Unlike function objects, code objects are immutable
      and contain no references (directly or indirectly) to mutable
      objects.

      Special read-only attributes: "co_name" gives the function name;
      "co_argcount" is the total number of positional arguments
      (including positional-only arguments and arguments with default
      values); "co_posonlyargcount" is the number of positional-only
      arguments (including arguments with default values);
      "co_kwonlyargcount" is the number of keyword-only arguments
      (including arguments with default values); "co_nlocals" is the
      number of local variables used by the function (including
      arguments); "co_varnames" is a tuple containing the names of the
      local variables (starting with the argument names);
      "co_cellvars" is a tuple containing the names of local variables
      that are referenced by nested functions; "co_freevars" is a
      tuple containing the names of free variables; "co_code" is a
      string representing the sequence of bytecode instructions;
      "co_consts" is a tuple containing the literals used by the
      bytecode; "co_names" is a tuple containing the names used by the
      bytecode; "co_filename" is the filename from which the code was
      compiled; "co_firstlineno" is the first line number of the
      function; "co_lnotab" is a string encoding the mapping from
      bytecode offsets to line numbers (for details see the source
      code of the interpreter); "co_stacksize" is the required stack
      size; "co_flags" is an integer encoding a number of flags for
      the interpreter.

      The following flag bits are defined for "co_flags": bit "0x04"
      is set if the function uses the "*arguments" syntax to accept an
      arbitrary number of positional arguments; bit "0x08" is set if
      the function uses the "**keywords" syntax to accept arbitrary
      keyword arguments; bit "0x20" is set if the function is a
      generator.

      Future feature declarations ("from __future__ import division")
      also use bits in "co_flags" to indicate whether a code object
      was compiled with a particular feature enabled: bit "0x2000" is
      set if the function was compiled with future division enabled;
      bits "0x10" and "0x1000" were used in earlier versions of
      Python.

      Other bits in "co_flags" are reserved for internal use.

      If a code object represents a function, the first item in
      "co_consts" is the documentation string of the function, or
      "None" if undefined.

   Frame objects
      Frame objects represent execution frames.  They may occur in
      traceback objects (see below), and are also passed to registered
      trace functions.

      Special read-only attributes: "f_back" is to the previous stack
      frame (towards the caller), or "None" if this is the bottom
      stack frame; "f_code" is the code object being executed in this
      frame; "f_locals" is the dictionary used to look up local
      variables; "f_globals" is used for global variables;
      "f_builtins" is used for built-in (intrinsic) names; "f_lasti"
      gives the precise instruction (this is an index into the
      bytecode string of the code object).

      Accessing "f_code" raises an auditing event "object.__getattr__"
      with arguments "obj" and ""f_code"".

      Special writable attributes: "f_trace", if not "None", is a
      function called for various events during code execution (this
      is used by the debugger). Normally an event is triggered for
      each new source line - this can be disabled by setting
      "f_trace_lines" to "False".

      Implementations *may* allow per-opcode events to be requested by
      setting "f_trace_opcodes" to "True". Note that this may lead to
      undefined interpreter behaviour if exceptions raised by the
      trace function escape to the function being traced.

      "f_lineno" is the current line number of the frame — writing to
      this from within a trace function jumps to the given line (only
      for the bottom-most frame).  A debugger can implement a Jump
      command (aka Set Next Statement) by writing to f_lineno.

      Frame objects support one method:

      frame.clear()

         This method clears all references to local variables held by
         the frame.  Also, if the frame belonged to a generator, the
         generator is finalized.  This helps break reference cycles
         involving frame objects (for example when catching an
         exception and storing its traceback for later use).

         "RuntimeError" is raised if the frame is currently executing.

         New in version 3.4.

   Traceback objects
      Traceback objects represent a stack trace of an exception.  A
      traceback object is implicitly created when an exception occurs,
      and may also be explicitly created by calling
      "types.TracebackType".

      For implicitly created tracebacks, when the search for an
      exception handler unwinds the execution stack, at each unwound
      level a traceback object is inserted in front of the current
      traceback.  When an exception handler is entered, the stack
      trace is made available to the program. (See section The try
      statement.) It is accessible as the third item of the tuple
      returned by "sys.exc_info()", and as the "__traceback__"
      attribute of the caught exception.

      When the program contains no suitable handler, the stack trace
      is written (nicely formatted) to the standard error stream; if
      the interpreter is interactive, it is also made available to the
      user as "sys.last_traceback".

      For explicitly created tracebacks, it is up to the creator of
      the traceback to determine how the "tb_next" attributes should
      be linked to form a full stack trace.

      Special read-only attributes: "tb_frame" points to the execution
      frame of the current level; "tb_lineno" gives the line number
      where the exception occurred; "tb_lasti" indicates the precise
      instruction. The line number and last instruction in the
      traceback may differ from the line number of its frame object if
      the exception occurred in a "try" statement with no matching
      except clause or with a finally clause.

      Accessing "tb_frame" raises an auditing event
      "object.__getattr__" with arguments "obj" and ""tb_frame"".

      Special writable attribute: "tb_next" is the next level in the
      stack trace (towards the frame where the exception occurred), or
      "None" if there is no next level.

      Changed in version 3.7: Traceback objects can now be explicitly
      instantiated from Python code, and the "tb_next" attribute of
      existing instances can be updated.

   Slice objects
      Slice objects are used to represent slices for "__getitem__()"
      methods.  They are also created by the built-in "slice()"
      function.

      Special read-only attributes: "start" is the lower bound; "stop"
      is the upper bound; "step" is the step value; each is "None" if
      omitted.  These attributes can have any type.

      Slice objects support one method:

      slice.indices(self, length)

         This method takes a single integer argument *length* and
         computes information about the slice that the slice object
         would describe if applied to a sequence of *length* items.
         It returns a tuple of three integers; respectively these are
         the *start* and *stop* indices and the *step* or stride
         length of the slice. Missing or out-of-bounds indices are
         handled in a manner consistent with regular slices.

   Static method objects
      Static method objects provide a way of defeating the
      transformation of function objects to method objects described
      above. A static method object is a wrapper around any other
      object, usually a user-defined method object. When a static
      method object is retrieved from a class or a class instance, the
      object actually returned is the wrapped object, which is not
      subject to any further transformation. Static method objects are
      not themselves callable, although the objects they wrap usually
      are. Static method objects are created by the built-in
      "staticmethod()" constructor.

   Class method objects
      A class method object, like a static method object, is a wrapper
      around another object that alters the way in which that object
      is retrieved from classes and class instances. The behaviour of
      class method objects upon such retrieval is described above,
      under “User-defined methods”. Class method objects are created
      by the built-in "classmethod()" constructor.
a�Functions
*********

Function objects are created by function definitions.  The only
operation on a function object is to call it: "func(argument-list)".

There are really two flavors of function objects: built-in functions
and user-defined functions.  Both support the same operation (to call
the function), but the implementation is different, hence the
different object types.

See Function definitions for more information.
u(.Mapping Types — "dict"
**********************

A *mapping* object maps *hashable* values to arbitrary objects.
Mappings are mutable objects.  There is currently only one standard
mapping type, the *dictionary*.  (For other containers see the built-
in "list", "set", and "tuple" classes, and the "collections" module.)

A dictionary’s keys are *almost* arbitrary values.  Values that are
not *hashable*, that is, values containing lists, dictionaries or
other mutable types (that are compared by value rather than by object
identity) may not be used as keys.  Numeric types used for keys obey
the normal rules for numeric comparison: if two numbers compare equal
(such as "1" and "1.0") then they can be used interchangeably to index
the same dictionary entry.  (Note however, that since computers store
floating-point numbers as approximations it is usually unwise to use
them as dictionary keys.)

Dictionaries can be created by placing a comma-separated list of "key:
value" pairs within braces, for example: "{'jack': 4098, 'sjoerd':
4127}" or "{4098: 'jack', 4127: 'sjoerd'}", or by the "dict"
constructor.

class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)

   Return a new dictionary initialized from an optional positional
   argument and a possibly empty set of keyword arguments.

   Dictionaries can be created by several means:

   * Use a comma-separated list of "key: value" pairs within braces:
     "{'jack': 4098, 'sjoerd': 4127}" or "{4098: 'jack', 4127:
     'sjoerd'}"

   * Use a dict comprehension: "{}", "{x: x ** 2 for x in range(10)}"

   * Use the type constructor: "dict()", "dict([('foo', 100), ('bar',
     200)])", "dict(foo=100, bar=200)"

   If no positional argument is given, an empty dictionary is created.
   If a positional argument is given and it is a mapping object, a
   dictionary is created with the same key-value pairs as the mapping
   object.  Otherwise, the positional argument must be an *iterable*
   object.  Each item in the iterable must itself be an iterable with
   exactly two objects.  The first object of each item becomes a key
   in the new dictionary, and the second object the corresponding
   value.  If a key occurs more than once, the last value for that key
   becomes the corresponding value in the new dictionary.

   If keyword arguments are given, the keyword arguments and their
   values are added to the dictionary created from the positional
   argument.  If a key being added is already present, the value from
   the keyword argument replaces the value from the positional
   argument.

   To illustrate, the following examples all return a dictionary equal
   to "{"one": 1, "two": 2, "three": 3}":

      >>> a = dict(one=1, two=2, three=3)
      >>> b = {'one': 1, 'two': 2, 'three': 3}
      >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
      >>> d = dict([('two', 2), ('one', 1), ('three', 3)])
      >>> e = dict({'three': 3, 'one': 1, 'two': 2})
      >>> a == b == c == d == e
      True

   Providing keyword arguments as in the first example only works for
   keys that are valid Python identifiers.  Otherwise, any valid keys
   can be used.

   These are the operations that dictionaries support (and therefore,
   custom mapping types should support too):

   list(d)

      Return a list of all the keys used in the dictionary *d*.

   len(d)

      Return the number of items in the dictionary *d*.

   d[key]

      Return the item of *d* with key *key*.  Raises a "KeyError" if
      *key* is not in the map.

      If a subclass of dict defines a method "__missing__()" and *key*
      is not present, the "d[key]" operation calls that method with
      the key *key* as argument.  The "d[key]" operation then returns
      or raises whatever is returned or raised by the
      "__missing__(key)" call. No other operations or methods invoke
      "__missing__()". If "__missing__()" is not defined, "KeyError"
      is raised. "__missing__()" must be a method; it cannot be an
      instance variable:

         >>> class Counter(dict):
         ...     def __missing__(self, key):
         ...         return 0
         >>> c = Counter()
         >>> c['red']
         0
         >>> c['red'] += 1
         >>> c['red']
         1

      The example above shows part of the implementation of
      "collections.Counter".  A different "__missing__" method is used
      by "collections.defaultdict".

   d[key] = value

      Set "d[key]" to *value*.

   del d[key]

      Remove "d[key]" from *d*.  Raises a "KeyError" if *key* is not
      in the map.

   key in d

      Return "True" if *d* has a key *key*, else "False".

   key not in d

      Equivalent to "not key in d".

   iter(d)

      Return an iterator over the keys of the dictionary.  This is a
      shortcut for "iter(d.keys())".

   clear()

      Remove all items from the dictionary.

   copy()

      Return a shallow copy of the dictionary.

   classmethod fromkeys(iterable[, value])

      Create a new dictionary with keys from *iterable* and values set
      to *value*.

      "fromkeys()" is a class method that returns a new dictionary.
      *value* defaults to "None".  All of the values refer to just a
      single instance, so it generally doesn’t make sense for *value*
      to be a mutable object such as an empty list.  To get distinct
      values, use a dict comprehension instead.

   get(key[, default])

      Return the value for *key* if *key* is in the dictionary, else
      *default*. If *default* is not given, it defaults to "None", so
      that this method never raises a "KeyError".

   items()

      Return a new view of the dictionary’s items ("(key, value)"
      pairs). See the documentation of view objects.

   keys()

      Return a new view of the dictionary’s keys.  See the
      documentation of view objects.

   pop(key[, default])

      If *key* is in the dictionary, remove it and return its value,
      else return *default*.  If *default* is not given and *key* is
      not in the dictionary, a "KeyError" is raised.

   popitem()

      Remove and return a "(key, value)" pair from the dictionary.
      Pairs are returned in LIFO (last-in, first-out) order.

      "popitem()" is useful to destructively iterate over a
      dictionary, as often used in set algorithms.  If the dictionary
      is empty, calling "popitem()" raises a "KeyError".

      Changed in version 3.7: LIFO order is now guaranteed. In prior
      versions, "popitem()" would return an arbitrary key/value pair.

   reversed(d)

      Return a reverse iterator over the keys of the dictionary. This
      is a shortcut for "reversed(d.keys())".

      New in version 3.8.

   setdefault(key[, default])

      If *key* is in the dictionary, return its value.  If not, insert
      *key* with a value of *default* and return *default*.  *default*
      defaults to "None".

   update([other])

      Update the dictionary with the key/value pairs from *other*,
      overwriting existing keys.  Return "None".

      "update()" accepts either another dictionary object or an
      iterable of key/value pairs (as tuples or other iterables of
      length two).  If keyword arguments are specified, the dictionary
      is then updated with those key/value pairs: "d.update(red=1,
      blue=2)".

   values()

      Return a new view of the dictionary’s values.  See the
      documentation of view objects.

      An equality comparison between one "dict.values()" view and
      another will always return "False". This also applies when
      comparing "dict.values()" to itself:

         >>> d = {'a': 1}
         >>> d.values() == d.values()
         False

   Dictionaries compare equal if and only if they have the same "(key,
   value)" pairs (regardless of ordering). Order comparisons (‘<’,
   ‘<=’, ‘>=’, ‘>’) raise "TypeError".

   Dictionaries preserve insertion order.  Note that updating a key
   does not affect the order.  Keys added after deletion are inserted
   at the end.

      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
      >>> d
      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
      >>> list(d)
      ['one', 'two', 'three', 'four']
      >>> list(d.values())
      [1, 2, 3, 4]
      >>> d["one"] = 42
      >>> d
      {'one': 42, 'two': 2, 'three': 3, 'four': 4}
      >>> del d["two"]
      >>> d["two"] = None
      >>> d
      {'one': 42, 'three': 3, 'four': 4, 'two': None}

   Changed in version 3.7: Dictionary order is guaranteed to be
   insertion order.  This behavior was an implementation detail of
   CPython from 3.6.

   Dictionaries and dictionary views are reversible.

      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
      >>> d
      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
      >>> list(reversed(d))
      ['four', 'three', 'two', 'one']
      >>> list(reversed(d.values()))
      [4, 3, 2, 1]
      >>> list(reversed(d.items()))
      [('four', 4), ('three', 3), ('two', 2), ('one', 1)]

   Changed in version 3.8: Dictionaries are now reversible.

See also:

  "types.MappingProxyType" can be used to create a read-only view of a
  "dict".


Dictionary view objects
=======================

The objects returned by "dict.keys()", "dict.values()" and
"dict.items()" are *view objects*.  They provide a dynamic view on the
dictionary’s entries, which means that when the dictionary changes,
the view reflects these changes.

Dictionary views can be iterated over to yield their respective data,
and support membership tests:

len(dictview)

   Return the number of entries in the dictionary.

iter(dictview)

   Return an iterator over the keys, values or items (represented as
   tuples of "(key, value)") in the dictionary.

   Keys and values are iterated over in insertion order. This allows
   the creation of "(value, key)" pairs using "zip()": "pairs =
   zip(d.values(), d.keys())".  Another way to create the same list is
   "pairs = [(v, k) for (k, v) in d.items()]".

   Iterating views while adding or deleting entries in the dictionary
   may raise a "RuntimeError" or fail to iterate over all entries.

   Changed in version 3.7: Dictionary order is guaranteed to be
   insertion order.

x in dictview

   Return "True" if *x* is in the underlying dictionary’s keys, values
   or items (in the latter case, *x* should be a "(key, value)"
   tuple).

reversed(dictview)

   Return a reverse iterator over the keys, values or items of the
   dictionary. The view will be iterated in reverse order of the
   insertion.

   Changed in version 3.8: Dictionary views are now reversible.

Keys views are set-like since their entries are unique and hashable.
If all values are hashable, so that "(key, value)" pairs are unique
and hashable, then the items view is also set-like.  (Values views are
not treated as set-like since the entries are generally not unique.)
For set-like views, all of the operations defined for the abstract
base class "collections.abc.Set" are available (for example, "==",
"<", or "^").

An example of dictionary view usage:

   >>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
   >>> keys = dishes.keys()
   >>> values = dishes.values()

   >>> # iteration
   >>> n = 0
   >>> for val in values:
   ...     n += val
   >>> print(n)
   504

   >>> # keys and values are iterated over in the same order (insertion order)
   >>> list(keys)
   ['eggs', 'sausage', 'bacon', 'spam']
   >>> list(values)
   [2, 1, 1, 500]

   >>> # view objects are dynamic and reflect dict changes
   >>> del dishes['eggs']
   >>> del dishes['sausage']
   >>> list(keys)
   ['bacon', 'spam']

   >>> # set operations
   >>> keys & {'eggs', 'bacon', 'salad'}
   {'bacon'}
   >>> keys ^ {'sausage', 'juice'}
   {'juice', 'sausage', 'bacon', 'spam'}
a�Methods
*******

Methods are functions that are called using the attribute notation.
There are two flavors: built-in methods (such as "append()" on lists)
and class instance methods.  Built-in methods are described with the
types that support them.

If you access a method (a function defined in a class namespace)
through an instance, you get a special object: a *bound method* (also
called *instance method*) object. When called, it will add the "self"
argument to the argument list.  Bound methods have two special read-
only attributes: "m.__self__" is the object on which the method
operates, and "m.__func__" is the function implementing the method.
Calling "m(arg-1, arg-2, ..., arg-n)" is completely equivalent to
calling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".

Like function objects, bound method objects support getting arbitrary
attributes.  However, since method attributes are actually stored on
the underlying function object ("meth.__func__"), setting method
attributes on bound methods is disallowed.  Attempting to set an
attribute on a method results in an "AttributeError" being raised.  In
order to set a method attribute, you need to explicitly set it on the
underlying function object:

   >>> class C:
   ...     def method(self):
   ...         pass
   ...
   >>> c = C()
   >>> c.method.whoami = 'my name is method'  # can't set on the method
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   AttributeError: 'method' object has no attribute 'whoami'
   >>> c.method.__func__.whoami = 'my name is method'
   >>> c.method.whoami
   'my name is method'

See The standard type hierarchy for more information.
u$Modules
*******

The only special operation on a module is attribute access: "m.name",
where *m* is a module and *name* accesses a name defined in *m*’s
symbol table. Module attributes can be assigned to.  (Note that the
"import" statement is not, strictly speaking, an operation on a module
object; "import foo" does not require a module object named *foo* to
exist, rather it requires an (external) *definition* for a module
named *foo* somewhere.)

A special attribute of every module is "__dict__". This is the
dictionary containing the module’s symbol table. Modifying this
dictionary will actually change the module’s symbol table, but direct
assignment to the "__dict__" attribute is not possible (you can write
"m.__dict__['a'] = 1", which defines "m.a" to be "1", but you can’t
write "m.__dict__ = {}").  Modifying "__dict__" directly is not
recommended.

Modules built into the interpreter are written like this: "<module
'sys' (built-in)>".  If loaded from a file, they are written as
"<module 'os' from '/usr/local/lib/pythonX.Y/os.pyc'>".
u�ZSequence Types — "list", "tuple", "range"
*****************************************

There are three basic sequence types: lists, tuples, and range
objects. Additional sequence types tailored for processing of binary
data and text strings are described in dedicated sections.


Common Sequence Operations
==========================

The operations in the following table are supported by most sequence
types, both mutable and immutable. The "collections.abc.Sequence" ABC
is provided to make it easier to correctly implement these operations
on custom sequence types.

This table lists the sequence operations sorted in ascending priority.
In the table, *s* and *t* are sequences of the same type, *n*, *i*,
*j* and *k* are integers and *x* is an arbitrary object that meets any
type and value restrictions imposed by *s*.

The "in" and "not in" operations have the same priorities as the
comparison operations. The "+" (concatenation) and "*" (repetition)
operations have the same priority as the corresponding numeric
operations. [3]

+----------------------------+----------------------------------+------------+
| Operation                  | Result                           | Notes      |
|============================|==================================|============|
| "x in s"                   | "True" if an item of *s* is      | (1)        |
|                            | equal to *x*, else "False"       |            |
+----------------------------+----------------------------------+------------+
| "x not in s"               | "False" if an item of *s* is     | (1)        |
|                            | equal to *x*, else "True"        |            |
+----------------------------+----------------------------------+------------+
| "s + t"                    | the concatenation of *s* and *t* | (6)(7)     |
+----------------------------+----------------------------------+------------+
| "s * n" or "n * s"         | equivalent to adding *s* to      | (2)(7)     |
|                            | itself *n* times                 |            |
+----------------------------+----------------------------------+------------+
| "s[i]"                     | *i*th item of *s*, origin 0      | (3)        |
+----------------------------+----------------------------------+------------+
| "s[i:j]"                   | slice of *s* from *i* to *j*     | (3)(4)     |
+----------------------------+----------------------------------+------------+
| "s[i:j:k]"                 | slice of *s* from *i* to *j*     | (3)(5)     |
|                            | with step *k*                    |            |
+----------------------------+----------------------------------+------------+
| "len(s)"                   | length of *s*                    |            |
+----------------------------+----------------------------------+------------+
| "min(s)"                   | smallest item of *s*             |            |
+----------------------------+----------------------------------+------------+
| "max(s)"                   | largest item of *s*              |            |
+----------------------------+----------------------------------+------------+
| "s.index(x[, i[, j]])"     | index of the first occurrence of | (8)        |
|                            | *x* in *s* (at or after index    |            |
|                            | *i* and before index *j*)        |            |
+----------------------------+----------------------------------+------------+
| "s.count(x)"               | total number of occurrences of   |            |
|                            | *x* in *s*                       |            |
+----------------------------+----------------------------------+------------+

Sequences of the same type also support comparisons.  In particular,
tuples and lists are compared lexicographically by comparing
corresponding elements. This means that to compare equal, every
element must compare equal and the two sequences must be of the same
type and have the same length.  (For full details see Comparisons in
the language reference.)

Notes:

1. While the "in" and "not in" operations are used only for simple
   containment testing in the general case, some specialised sequences
   (such as "str", "bytes" and "bytearray") also use them for
   subsequence testing:

      >>> "gg" in "eggs"
      True

2. Values of *n* less than "0" are treated as "0" (which yields an
   empty sequence of the same type as *s*).  Note that items in the
   sequence *s* are not copied; they are referenced multiple times.
   This often haunts new Python programmers; consider:

      >>> lists = [[]] * 3
      >>> lists
      [[], [], []]
      >>> lists[0].append(3)
      >>> lists
      [[3], [3], [3]]

   What has happened is that "[[]]" is a one-element list containing
   an empty list, so all three elements of "[[]] * 3" are references
   to this single empty list.  Modifying any of the elements of
   "lists" modifies this single list. You can create a list of
   different lists this way:

      >>> lists = [[] for i in range(3)]
      >>> lists[0].append(3)
      >>> lists[1].append(5)
      >>> lists[2].append(7)
      >>> lists
      [[3], [5], [7]]

   Further explanation is available in the FAQ entry How do I create a
   multidimensional list?.

3. If *i* or *j* is negative, the index is relative to the end of
   sequence *s*: "len(s) + i" or "len(s) + j" is substituted.  But
   note that "-0" is still "0".

4. The slice of *s* from *i* to *j* is defined as the sequence of
   items with index *k* such that "i <= k < j".  If *i* or *j* is
   greater than "len(s)", use "len(s)".  If *i* is omitted or "None",
   use "0".  If *j* is omitted or "None", use "len(s)".  If *i* is
   greater than or equal to *j*, the slice is empty.

5. The slice of *s* from *i* to *j* with step *k* is defined as the
   sequence of items with index  "x = i + n*k" such that "0 <= n <
   (j-i)/k".  In other words, the indices are "i", "i+k", "i+2*k",
   "i+3*k" and so on, stopping when *j* is reached (but never
   including *j*).  When *k* is positive, *i* and *j* are reduced to
   "len(s)" if they are greater. When *k* is negative, *i* and *j* are
   reduced to "len(s) - 1" if they are greater.  If *i* or *j* are
   omitted or "None", they become “end” values (which end depends on
   the sign of *k*).  Note, *k* cannot be zero. If *k* is "None", it
   is treated like "1".

6. Concatenating immutable sequences always results in a new object.
   This means that building up a sequence by repeated concatenation
   will have a quadratic runtime cost in the total sequence length.
   To get a linear runtime cost, you must switch to one of the
   alternatives below:

   * if concatenating "str" objects, you can build a list and use
     "str.join()" at the end or else write to an "io.StringIO"
     instance and retrieve its value when complete

   * if concatenating "bytes" objects, you can similarly use
     "bytes.join()" or "io.BytesIO", or you can do in-place
     concatenation with a "bytearray" object.  "bytearray" objects are
     mutable and have an efficient overallocation mechanism

   * if concatenating "tuple" objects, extend a "list" instead

   * for other types, investigate the relevant class documentation

7. Some sequence types (such as "range") only support item sequences
   that follow specific patterns, and hence don’t support sequence
   concatenation or repetition.

8. "index" raises "ValueError" when *x* is not found in *s*. Not all
   implementations support passing the additional arguments *i* and
   *j*. These arguments allow efficient searching of subsections of
   the sequence. Passing the extra arguments is roughly equivalent to
   using "s[i:j].index(x)", only without copying any data and with the
   returned index being relative to the start of the sequence rather
   than the start of the slice.


Immutable Sequence Types
========================

The only operation that immutable sequence types generally implement
that is not also implemented by mutable sequence types is support for
the "hash()" built-in.

This support allows immutable sequences, such as "tuple" instances, to
be used as "dict" keys and stored in "set" and "frozenset" instances.

Attempting to hash an immutable sequence that contains unhashable
values will result in "TypeError".


Mutable Sequence Types
======================

The operations in the following table are defined on mutable sequence
types. The "collections.abc.MutableSequence" ABC is provided to make
it easier to correctly implement these operations on custom sequence
types.

In the table *s* is an instance of a mutable sequence type, *t* is any
iterable object and *x* is an arbitrary object that meets any type and
value restrictions imposed by *s* (for example, "bytearray" only
accepts integers that meet the value restriction "0 <= x <= 255").

+--------------------------------+----------------------------------+-----------------------+
| Operation                      | Result                           | Notes                 |
|================================|==================================|=======================|
| "s[i] = x"                     | item *i* of *s* is replaced by   |                       |
|                                | *x*                              |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j] = t"                   | slice of *s* from *i* to *j* is  |                       |
|                                | replaced by the contents of the  |                       |
|                                | iterable *t*                     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j]"                   | same as "s[i:j] = []"            |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j:k] = t"                 | the elements of "s[i:j:k]" are   | (1)                   |
|                                | replaced by those of *t*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j:k]"                 | removes the elements of          |                       |
|                                | "s[i:j:k]" from the list         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)"                  | appends *x* to the end of the    |                       |
|                                | sequence (same as                |                       |
|                                | "s[len(s):len(s)] = [x]")        |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()"                    | removes all items from *s* (same | (5)                   |
|                                | as "del s[:]")                   |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()"                     | creates a shallow copy of *s*    | (5)                   |
|                                | (same as "s[:]")                 |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t"      | extends *s* with the contents of |                       |
|                                | *t* (for the most part the same  |                       |
|                                | as "s[len(s):len(s)] = t")       |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n"                       | updates *s* with its contents    | (6)                   |
|                                | repeated *n* times               |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)"               | inserts *x* into *s* at the      |                       |
|                                | index given by *i* (same as      |                       |
|                                | "s[i:i] = [x]")                  |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)"        | retrieves the item at *i* and    | (2)                   |
|                                | also removes it from *s*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)"                  | remove the first item from *s*   | (3)                   |
|                                | where "s[i]" is equal to *x*     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()"                  | reverses the items of *s* in     | (4)                   |
|                                | place                            |                       |
+--------------------------------+----------------------------------+-----------------------+

Notes:

1. *t* must have the same length as the slice it is replacing.

2. The optional argument *i* defaults to "-1", so that by default the
   last item is removed and returned.

3. "remove()" raises "ValueError" when *x* is not found in *s*.

4. The "reverse()" method modifies the sequence in place for economy
   of space when reversing a large sequence.  To remind users that it
   operates by side effect, it does not return the reversed sequence.

5. "clear()" and "copy()" are included for consistency with the
   interfaces of mutable containers that don’t support slicing
   operations (such as "dict" and "set"). "copy()" is not part of the
   "collections.abc.MutableSequence" ABC, but most concrete mutable
   sequence classes provide it.

   New in version 3.3: "clear()" and "copy()" methods.

6. The value *n* is an integer, or an object implementing
   "__index__()".  Zero and negative values of *n* clear the sequence.
   Items in the sequence are not copied; they are referenced multiple
   times, as explained for "s * n" under Common Sequence Operations.


Lists
=====

Lists are mutable sequences, typically used to store collections of
homogeneous items (where the precise degree of similarity will vary by
application).

class list([iterable])

   Lists may be constructed in several ways:

   * Using a pair of square brackets to denote the empty list: "[]"

   * Using square brackets, separating items with commas: "[a]", "[a,
     b, c]"

   * Using a list comprehension: "[x for x in iterable]"

   * Using the type constructor: "list()" or "list(iterable)"

   The constructor builds a list whose items are the same and in the
   same order as *iterable*’s items.  *iterable* may be either a
   sequence, a container that supports iteration, or an iterator
   object.  If *iterable* is already a list, a copy is made and
   returned, similar to "iterable[:]". For example, "list('abc')"
   returns "['a', 'b', 'c']" and "list( (1, 2, 3) )" returns "[1, 2,
   3]". If no argument is given, the constructor creates a new empty
   list, "[]".

   Many other operations also produce lists, including the "sorted()"
   built-in.

   Lists implement all of the common and mutable sequence operations.
   Lists also provide the following additional method:

   sort(*, key=None, reverse=False)

      This method sorts the list in place, using only "<" comparisons
      between items. Exceptions are not suppressed - if any comparison
      operations fail, the entire sort operation will fail (and the
      list will likely be left in a partially modified state).

      "sort()" accepts two arguments that can only be passed by
      keyword (keyword-only arguments):

      *key* specifies a function of one argument that is used to
      extract a comparison key from each list element (for example,
      "key=str.lower"). The key corresponding to each item in the list
      is calculated once and then used for the entire sorting process.
      The default value of "None" means that list items are sorted
      directly without calculating a separate key value.

      The "functools.cmp_to_key()" utility is available to convert a
      2.x style *cmp* function to a *key* function.

      *reverse* is a boolean value.  If set to "True", then the list
      elements are sorted as if each comparison were reversed.

      This method modifies the sequence in place for economy of space
      when sorting a large sequence.  To remind users that it operates
      by side effect, it does not return the sorted sequence (use
      "sorted()" to explicitly request a new sorted list instance).

      The "sort()" method is guaranteed to be stable.  A sort is
      stable if it guarantees not to change the relative order of
      elements that compare equal — this is helpful for sorting in
      multiple passes (for example, sort by department, then by salary
      grade).

      For sorting examples and a brief sorting tutorial, see Sorting
      HOW TO.

      **CPython implementation detail:** While a list is being sorted,
      the effect of attempting to mutate, or even inspect, the list is
      undefined.  The C implementation of Python makes the list appear
      empty for the duration, and raises "ValueError" if it can detect
      that the list has been mutated during a sort.


Tuples
======

Tuples are immutable sequences, typically used to store collections of
heterogeneous data (such as the 2-tuples produced by the "enumerate()"
built-in). Tuples are also used for cases where an immutable sequence
of homogeneous data is needed (such as allowing storage in a "set" or
"dict" instance).

class tuple([iterable])

   Tuples may be constructed in a number of ways:

   * Using a pair of parentheses to denote the empty tuple: "()"

   * Using a trailing comma for a singleton tuple: "a," or "(a,)"

   * Separating items with commas: "a, b, c" or "(a, b, c)"

   * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"

   The constructor builds a tuple whose items are the same and in the
   same order as *iterable*’s items.  *iterable* may be either a
   sequence, a container that supports iteration, or an iterator
   object.  If *iterable* is already a tuple, it is returned
   unchanged. For example, "tuple('abc')" returns "('a', 'b', 'c')"
   and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is
   given, the constructor creates a new empty tuple, "()".

   Note that it is actually the comma which makes a tuple, not the
   parentheses. The parentheses are optional, except in the empty
   tuple case, or when they are needed to avoid syntactic ambiguity.
   For example, "f(a, b, c)" is a function call with three arguments,
   while "f((a, b, c))" is a function call with a 3-tuple as the sole
   argument.

   Tuples implement all of the common sequence operations.

For heterogeneous collections of data where access by name is clearer
than access by index, "collections.namedtuple()" may be a more
appropriate choice than a simple tuple object.


Ranges
======

The "range" type represents an immutable sequence of numbers and is
commonly used for looping a specific number of times in "for" loops.

class range(stop)
class range(start, stop[, step])

   The arguments to the range constructor must be integers (either
   built-in "int" or any object that implements the "__index__"
   special method).  If the *step* argument is omitted, it defaults to
   "1". If the *start* argument is omitted, it defaults to "0". If
   *step* is zero, "ValueError" is raised.

   For a positive *step*, the contents of a range "r" are determined
   by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <
   stop".

   For a negative *step*, the contents of the range are still
   determined by the formula "r[i] = start + step*i", but the
   constraints are "i >= 0" and "r[i] > stop".

   A range object will be empty if "r[0]" does not meet the value
   constraint. Ranges do support negative indices, but these are
   interpreted as indexing from the end of the sequence determined by
   the positive indices.

   Ranges containing absolute values larger than "sys.maxsize" are
   permitted but some features (such as "len()") may raise
   "OverflowError".

   Range examples:

      >>> list(range(10))
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      >>> list(range(1, 11))
      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      >>> list(range(0, 30, 5))
      [0, 5, 10, 15, 20, 25]
      >>> list(range(0, 10, 3))
      [0, 3, 6, 9]
      >>> list(range(0, -10, -1))
      [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
      >>> list(range(0))
      []
      >>> list(range(1, 0))
      []

   Ranges implement all of the common sequence operations except
   concatenation and repetition (due to the fact that range objects
   can only represent sequences that follow a strict pattern and
   repetition and concatenation will usually violate that pattern).

   start

      The value of the *start* parameter (or "0" if the parameter was
      not supplied)

   stop

      The value of the *stop* parameter

   step

      The value of the *step* parameter (or "1" if the parameter was
      not supplied)

The advantage of the "range" type over a regular "list" or "tuple" is
that a "range" object will always take the same (small) amount of
memory, no matter the size of the range it represents (as it only
stores the "start", "stop" and "step" values, calculating individual
items and subranges as needed).

Range objects implement the "collections.abc.Sequence" ABC, and
provide features such as containment tests, element index lookup,
slicing and support for negative indices (see Sequence Types — list,
tuple, range):

>>> r = range(0, 20, 2)
>>> r
range(0, 20, 2)
>>> 11 in r
False
>>> 10 in r
True
>>> r.index(10)
5
>>> r[5]
10
>>> r[:5]
range(0, 10, 2)
>>> r[-1]
18

Testing range objects for equality with "==" and "!=" compares them as
sequences.  That is, two range objects are considered equal if they
represent the same sequence of values.  (Note that two range objects
that compare equal might have different "start", "stop" and "step"
attributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,
2) == range(0, 4, 2)".)

Changed in version 3.2: Implement the Sequence ABC. Support slicing
and negative indices. Test "int" objects for membership in constant
time instead of iterating through all items.

Changed in version 3.3: Define ‘==’ and ‘!=’ to compare range objects
based on the sequence of values they define (instead of comparing
based on object identity).

New in version 3.3: The "start", "stop" and "step" attributes.

See also:

  * The linspace recipe shows how to implement a lazy version of range
    suitable for floating point applications.
u�Mutable Sequence Types
**********************

The operations in the following table are defined on mutable sequence
types. The "collections.abc.MutableSequence" ABC is provided to make
it easier to correctly implement these operations on custom sequence
types.

In the table *s* is an instance of a mutable sequence type, *t* is any
iterable object and *x* is an arbitrary object that meets any type and
value restrictions imposed by *s* (for example, "bytearray" only
accepts integers that meet the value restriction "0 <= x <= 255").

+--------------------------------+----------------------------------+-----------------------+
| Operation                      | Result                           | Notes                 |
|================================|==================================|=======================|
| "s[i] = x"                     | item *i* of *s* is replaced by   |                       |
|                                | *x*                              |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j] = t"                   | slice of *s* from *i* to *j* is  |                       |
|                                | replaced by the contents of the  |                       |
|                                | iterable *t*                     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j]"                   | same as "s[i:j] = []"            |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j:k] = t"                 | the elements of "s[i:j:k]" are   | (1)                   |
|                                | replaced by those of *t*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j:k]"                 | removes the elements of          |                       |
|                                | "s[i:j:k]" from the list         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)"                  | appends *x* to the end of the    |                       |
|                                | sequence (same as                |                       |
|                                | "s[len(s):len(s)] = [x]")        |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()"                    | removes all items from *s* (same | (5)                   |
|                                | as "del s[:]")                   |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()"                     | creates a shallow copy of *s*    | (5)                   |
|                                | (same as "s[:]")                 |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t"      | extends *s* with the contents of |                       |
|                                | *t* (for the most part the same  |                       |
|                                | as "s[len(s):len(s)] = t")       |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n"                       | updates *s* with its contents    | (6)                   |
|                                | repeated *n* times               |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)"               | inserts *x* into *s* at the      |                       |
|                                | index given by *i* (same as      |                       |
|                                | "s[i:i] = [x]")                  |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)"        | retrieves the item at *i* and    | (2)                   |
|                                | also removes it from *s*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)"                  | remove the first item from *s*   | (3)                   |
|                                | where "s[i]" is equal to *x*     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()"                  | reverses the items of *s* in     | (4)                   |
|                                | place                            |                       |
+--------------------------------+----------------------------------+-----------------------+

Notes:

1. *t* must have the same length as the slice it is replacing.

2. The optional argument *i* defaults to "-1", so that by default the
   last item is removed and returned.

3. "remove()" raises "ValueError" when *x* is not found in *s*.

4. The "reverse()" method modifies the sequence in place for economy
   of space when reversing a large sequence.  To remind users that it
   operates by side effect, it does not return the reversed sequence.

5. "clear()" and "copy()" are included for consistency with the
   interfaces of mutable containers that don’t support slicing
   operations (such as "dict" and "set"). "copy()" is not part of the
   "collections.abc.MutableSequence" ABC, but most concrete mutable
   sequence classes provide it.

   New in version 3.3: "clear()" and "copy()" methods.

6. The value *n* is an integer, or an object implementing
   "__index__()".  Zero and negative values of *n* clear the sequence.
   Items in the sequence are not copied; they are referenced multiple
   times, as explained for "s * n" under Common Sequence Operations.
a~Unary arithmetic and bitwise operations
***************************************

All unary arithmetic and bitwise operations have the same priority:

   u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr

The unary "-" (minus) operator yields the negation of its numeric
argument.

The unary "+" (plus) operator yields its numeric argument unchanged.

The unary "~" (invert) operator yields the bitwise inversion of its
integer argument.  The bitwise inversion of "x" is defined as
"-(x+1)".  It only applies to integral numbers.

In all three cases, if the argument does not have the proper type, a
"TypeError" exception is raised.
u�The "while" statement
*********************

The "while" statement is used for repeated execution as long as an
expression is true:

   while_stmt ::= "while" assignment_expression ":" suite
                  ["else" ":" suite]

This repeatedly tests the expression and, if it is true, executes the
first suite; if the expression is false (which may be the first time
it is tested) the suite of the "else" clause, if present, is executed
and the loop terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and goes back
to testing the expression.
uMThe "with" statement
********************

The "with" statement is used to wrap the execution of a block with
methods defined by a context manager (see section With Statement
Context Managers). This allows common "try"…"except"…"finally" usage
patterns to be encapsulated for convenient reuse.

   with_stmt ::= "with" with_item ("," with_item)* ":" suite
   with_item ::= expression ["as" target]

The execution of the "with" statement with one “item” proceeds as
follows:

1. The context expression (the expression given in the "with_item") is
   evaluated to obtain a context manager.

2. The context manager’s "__enter__()" is loaded for later use.

3. The context manager’s "__exit__()" is loaded for later use.

4. The context manager’s "__enter__()" method is invoked.

5. If a target was included in the "with" statement, the return value
   from "__enter__()" is assigned to it.

   Note:

     The "with" statement guarantees that if the "__enter__()" method
     returns without an error, then "__exit__()" will always be
     called. Thus, if an error occurs during the assignment to the
     target list, it will be treated the same as an error occurring
     within the suite would be. See step 6 below.

6. The suite is executed.

7. The context manager’s "__exit__()" method is invoked.  If an
   exception caused the suite to be exited, its type, value, and
   traceback are passed as arguments to "__exit__()". Otherwise, three
   "None" arguments are supplied.

   If the suite was exited due to an exception, and the return value
   from the "__exit__()" method was false, the exception is reraised.
   If the return value was true, the exception is suppressed, and
   execution continues with the statement following the "with"
   statement.

   If the suite was exited for any reason other than an exception, the
   return value from "__exit__()" is ignored, and execution proceeds
   at the normal location for the kind of exit that was taken.

The following code:

   with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   enter = type(manager).__enter__
   exit = type(manager).__exit__
   value = enter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not exit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           exit(manager, None, None, None)

With more than one item, the context managers are processed as if
multiple "with" statements were nested:

   with A() as a, B() as b:
       SUITE

is semantically equivalent to:

   with A() as a:
       with B() as b:
           SUITE

Changed in version 3.1: Support for multiple context expressions.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.
a,The "yield" statement
*********************

   yield_stmt ::= yield_expression

A "yield" statement is semantically equivalent to a yield expression.
The yield statement can be used to omit the parentheses that would
otherwise be required in the equivalent yield expression statement.
For example, the yield statements

   yield <expr>
   yield from <expr>

are equivalent to the yield expression statements

   (yield <expr>)
   (yield from <expr>)

Yield expressions and statements are only used when defining a
*generator* function, and are only used in the body of the generator
function.  Using yield in a function definition is sufficient to cause
that definition to create a generator function instead of a normal
function.

For full details of "yield" semantics, refer to the Yield expressions
section.
)O�assertZ
assignment�asynczatom-identifiersz
atom-literalszattribute-accesszattribute-referencesZ	augassign�awaitZbinaryZbitwisezbltin-code-objectszbltin-ellipsis-objectzbltin-null-objectzbltin-type-objectsZbooleans�breakzcallable-typesZcalls�classZcomparisonsZcompoundzcontext-managers�continueZconversionsZ
customizationZdebugger�del�dictzdynamic-features�else�
exceptionsZ	execmodelZ	exprlistsZfloating�forZ
formatstringsZfunction�globalz
id-classesZidentifiers�ifZ	imaginary�import�inZintegers�lambdaZlistsZnaming�nonlocalZnumbersz
numeric-typesZobjectszoperator-summary�passZpower�raise�returnzsequence-typesZshiftingZslicingsZspecialattrsZspecialnameszstring-methodsZstringsZ
subscriptions�truth�try�typesZtypesfunctionsZtypesmappingZtypesmethodsZtypesmodulesZtypesseqztypesseq-mutableZunary�while�with�yieldN)Ztopics�rr�)/usr/lib64/python3.8/pydoc_data/topics.py�<module>s'}(@	X1	=`bQ>J:3MD%I
H+1&.LN3"o#p3=^ai9;K9%Hh�������������������������������������������������������������������������������������������������������������PK86�\�W�~�~topics.cpython-38.pycnu�[���U

e5d�s
�P@s�dddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(dd)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdN�OZdOS)PauThe "assert" statement
**********************

Assert statements are a convenient way to insert debugging assertions
into a program:

   assert_stmt ::= "assert" expression ["," expression]

The simple form, "assert expression", is equivalent to

   if __debug__:
       if not expression: raise AssertionError

The extended form, "assert expression1, expression2", is equivalent to

   if __debug__:
       if not expression1: raise AssertionError(expression2)

These equivalences assume that "__debug__" and "AssertionError" refer
to the built-in variables with those names.  In the current
implementation, the built-in variable "__debug__" is "True" under
normal circumstances, "False" when optimization is requested (command
line option "-O").  The current code generator emits no code for an
assert statement when optimization is requested at compile time.  Note
that it is unnecessary to include the source code for the expression
that failed in the error message; it will be displayed as part of the
stack trace.

Assignments to "__debug__" are illegal.  The value for the built-in
variable is determined when the interpreter starts.
u�,Assignment statements
*********************

Assignment statements are used to (re)bind names to values and to
modify attributes or items of mutable objects:

   assignment_stmt ::= (target_list "=")+ (starred_expression | yield_expression)
   target_list     ::= target ("," target)* [","]
   target          ::= identifier
              | "(" [target_list] ")"
              | "[" [target_list] "]"
              | attributeref
              | subscription
              | slicing
              | "*" target

(See section Primaries for the syntax definitions for *attributeref*,
*subscription*, and *slicing*.)

An assignment statement evaluates the expression list (remember that
this can be a single expression or a comma-separated list, the latter
yielding a tuple) and assigns the single resulting object to each of
the target lists, from left to right.

Assignment is defined recursively depending on the form of the target
(list). When a target is part of a mutable object (an attribute
reference, subscription or slicing), the mutable object must
ultimately perform the assignment and decide about its validity, and
may raise an exception if the assignment is unacceptable.  The rules
observed by various types and the exceptions raised are given with the
definition of the object types (see section The standard type
hierarchy).

Assignment of an object to a target list, optionally enclosed in
parentheses or square brackets, is recursively defined as follows.

* If the target list is a single target with no trailing comma,
  optionally in parentheses, the object is assigned to that target.

* Else: The object must be an iterable with the same number of items
  as there are targets in the target list, and the items are assigned,
  from left to right, to the corresponding targets.

  * If the target list contains one target prefixed with an asterisk,
    called a “starred” target: The object must be an iterable with at
    least as many items as there are targets in the target list, minus
    one.  The first items of the iterable are assigned, from left to
    right, to the targets before the starred target.  The final items
    of the iterable are assigned to the targets after the starred
    target.  A list of the remaining items in the iterable is then
    assigned to the starred target (the list can be empty).

  * Else: The object must be an iterable with the same number of items
    as there are targets in the target list, and the items are
    assigned, from left to right, to the corresponding targets.

Assignment of an object to a single target is recursively defined as
follows.

* If the target is an identifier (name):

  * If the name does not occur in a "global" or "nonlocal" statement
    in the current code block: the name is bound to the object in the
    current local namespace.

  * Otherwise: the name is bound to the object in the global namespace
    or the outer namespace determined by "nonlocal", respectively.

  The name is rebound if it was already bound.  This may cause the
  reference count for the object previously bound to the name to reach
  zero, causing the object to be deallocated and its destructor (if it
  has one) to be called.

* If the target is an attribute reference: The primary expression in
  the reference is evaluated.  It should yield an object with
  assignable attributes; if this is not the case, "TypeError" is
  raised.  That object is then asked to assign the assigned object to
  the given attribute; if it cannot perform the assignment, it raises
  an exception (usually but not necessarily "AttributeError").

  Note: If the object is a class instance and the attribute reference
  occurs on both sides of the assignment operator, the right-hand side
  expression, "a.x" can access either an instance attribute or (if no
  instance attribute exists) a class attribute.  The left-hand side
  target "a.x" is always set as an instance attribute, creating it if
  necessary.  Thus, the two occurrences of "a.x" do not necessarily
  refer to the same attribute: if the right-hand side expression
  refers to a class attribute, the left-hand side creates a new
  instance attribute as the target of the assignment:

     class Cls:
         x = 3             # class variable
     inst = Cls()
     inst.x = inst.x + 1   # writes inst.x as 4 leaving Cls.x as 3

  This description does not necessarily apply to descriptor
  attributes, such as properties created with "property()".

* If the target is a subscription: The primary expression in the
  reference is evaluated.  It should yield either a mutable sequence
  object (such as a list) or a mapping object (such as a dictionary).
  Next, the subscript expression is evaluated.

  If the primary is a mutable sequence object (such as a list), the
  subscript must yield an integer.  If it is negative, the sequence’s
  length is added to it.  The resulting value must be a nonnegative
  integer less than the sequence’s length, and the sequence is asked
  to assign the assigned object to its item with that index.  If the
  index is out of range, "IndexError" is raised (assignment to a
  subscripted sequence cannot add new items to a list).

  If the primary is a mapping object (such as a dictionary), the
  subscript must have a type compatible with the mapping’s key type,
  and the mapping is then asked to create a key/datum pair which maps
  the subscript to the assigned object.  This can either replace an
  existing key/value pair with the same key value, or insert a new
  key/value pair (if no key with the same value existed).

  For user-defined objects, the "__setitem__()" method is called with
  appropriate arguments.

* If the target is a slicing: The primary expression in the reference
  is evaluated.  It should yield a mutable sequence object (such as a
  list).  The assigned object should be a sequence object of the same
  type.  Next, the lower and upper bound expressions are evaluated,
  insofar they are present; defaults are zero and the sequence’s
  length.  The bounds should evaluate to integers. If either bound is
  negative, the sequence’s length is added to it.  The resulting
  bounds are clipped to lie between zero and the sequence’s length,
  inclusive.  Finally, the sequence object is asked to replace the
  slice with the items of the assigned sequence.  The length of the
  slice may be different from the length of the assigned sequence,
  thus changing the length of the target sequence, if the target
  sequence allows it.

**CPython implementation detail:** In the current implementation, the
syntax for targets is taken to be the same as for expressions, and
invalid syntax is rejected during the code generation phase, causing
less detailed error messages.

Although the definition of assignment implies that overlaps between
the left-hand side and the right-hand side are ‘simultaneous’ (for
example "a, b = b, a" swaps two variables), overlaps *within* the
collection of assigned-to variables occur left-to-right, sometimes
resulting in confusion.  For instance, the following program prints
"[0, 2]":

   x = [0, 1]
   i = 0
   i, x[i] = 1, 2         # i is updated, then x[i] is updated
   print(x)

See also:

  **PEP 3132** - Extended Iterable Unpacking
     The specification for the "*target" feature.


Augmented assignment statements
===============================

Augmented assignment is the combination, in a single statement, of a
binary operation and an assignment statement:

   augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)
   augtarget                 ::= identifier | attributeref | subscription | slicing
   augop                     ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
             | ">>=" | "<<=" | "&=" | "^=" | "|="

(See section Primaries for the syntax definitions of the last three
symbols.)

An augmented assignment evaluates the target (which, unlike normal
assignment statements, cannot be an unpacking) and the expression
list, performs the binary operation specific to the type of assignment
on the two operands, and assigns the result to the original target.
The target is only evaluated once.

An augmented assignment expression like "x += 1" can be rewritten as
"x = x + 1" to achieve a similar, but not exactly equal effect. In the
augmented version, "x" is only evaluated once. Also, when possible,
the actual operation is performed *in-place*, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.

Unlike normal assignments, augmented assignments evaluate the left-
hand side *before* evaluating the right-hand side.  For example, "a[i]
+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs
the addition, and lastly, it writes the result back to "a[i]".

With the exception of assigning to tuples and multiple targets in a
single statement, the assignment done by augmented assignment
statements is handled the same way as normal assignments. Similarly,
with the exception of the possible *in-place* behavior, the binary
operation performed by augmented assignment is the same as the normal
binary operations.

For targets which are attribute references, the same caveat about
class and instance attributes applies as for regular assignments.


Annotated assignment statements
===============================

*Annotation* assignment is the combination, in a single statement, of
a variable or attribute annotation and an optional assignment
statement:

   annotated_assignment_stmt ::= augtarget ":" expression
                                 ["=" (starred_expression | yield_expression)]

The difference from normal Assignment statements is that only single
target is allowed.

For simple names as assignment targets, if in class or module scope,
the annotations are evaluated and stored in a special class or module
attribute "__annotations__" that is a dictionary mapping from variable
names (mangled if private) to evaluated annotations. This attribute is
writable and is automatically created at the start of class or module
body execution, if annotations are found statically.

For expressions as assignment targets, the annotations are evaluated
if in class or module scope, but not stored.

If a name is annotated in a function scope, then this name is local
for that scope. Annotations are never evaluated and stored in function
scopes.

If the right hand side is present, an annotated assignment performs
the actual assignment before evaluating annotations (where
applicable). If the right hand side is not present for an expression
target, then the interpreter evaluates the target except for the last
"__setitem__()" or "__setattr__()" call.

See also:

  **PEP 526** - Syntax for Variable Annotations
     The proposal that added syntax for annotating the types of
     variables (including class variables and instance variables),
     instead of expressing them through comments.

  **PEP 484** - Type hints
     The proposal that added the "typing" module to provide a standard
     syntax for type annotations that can be used in static analysis
     tools and IDEs.

Changed in version 3.8: Now annotated assignments allow same
expressions in the right hand side as the regular assignments.
Previously, some expressions (like un-parenthesized tuple expressions)
caused a syntax error.
u>
Coroutines
**********

New in version 3.5.


Coroutine function definition
=============================

   async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")"
                     ["->" expression] ":" suite

Execution of Python coroutines can be suspended and resumed at many
points (see *coroutine*).  Inside the body of a coroutine function,
"await" and "async" identifiers become reserved keywords; "await"
expressions, "async for" and "async with" can only be used in
coroutine function bodies.

Functions defined with "async def" syntax are always coroutine
functions, even if they do not contain "await" or "async" keywords.

It is a "SyntaxError" to use a "yield from" expression inside the body
of a coroutine function.

An example of a coroutine function:

   async def func(param1, param2):
       do_stuff()
       await some_coroutine()


The "async for" statement
=========================

   async_for_stmt ::= "async" for_stmt

An *asynchronous iterable* is able to call asynchronous code in its
*iter* implementation, and *asynchronous iterator* can call
asynchronous code in its *next* method.

The "async for" statement allows convenient iteration over
asynchronous iterators.

The following code:

   async for TARGET in ITER:
       SUITE
   else:
       SUITE2

Is semantically equivalent to:

   iter = (ITER)
   iter = type(iter).__aiter__(iter)
   running = True

   while running:
       try:
           TARGET = await type(iter).__anext__(iter)
       except StopAsyncIteration:
           running = False
       else:
           SUITE
   else:
       SUITE2

See also "__aiter__()" and "__anext__()" for details.

It is a "SyntaxError" to use an "async for" statement outside the body
of a coroutine function.


The "async with" statement
==========================

   async_with_stmt ::= "async" with_stmt

An *asynchronous context manager* is a *context manager* that is able
to suspend execution in its *enter* and *exit* methods.

The following code:

   async with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   aexit = type(manager).__aexit__
   aenter = type(manager).__aenter__
   value = await aenter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not await aexit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           await aexit(manager, None, None, None)

See also "__aenter__()" and "__aexit__()" for details.

It is a "SyntaxError" to use an "async with" statement outside the
body of a coroutine function.

See also:

  **PEP 492** - Coroutines with async and await syntax
     The proposal that made coroutines a proper standalone concept in
     Python, and added supporting syntax.

-[ Footnotes ]-

[1] The exception is propagated to the invocation stack unless there
    is a "finally" clause which happens to raise another exception.
    That new exception causes the old one to be lost.

[2] A string literal appearing as the first statement in the function
    body is transformed into the function’s "__doc__" attribute and
    therefore the function’s *docstring*.

[3] A string literal appearing as the first statement in the class
    body is transformed into the namespace’s "__doc__" item and
    therefore the class’s *docstring*.
a�Identifiers (Names)
*******************

An identifier occurring as an atom is a name.  See section Identifiers
and keywords for lexical definition and section Naming and binding for
documentation of naming and binding.

When the name is bound to an object, evaluation of the atom yields
that object. When a name is not bound, an attempt to evaluate it
raises a "NameError" exception.

**Private name mangling:** When an identifier that textually occurs in
a class definition begins with two or more underscore characters and
does not end in two or more underscores, it is considered a *private
name* of that class. Private names are transformed to a longer form
before code is generated for them.  The transformation inserts the
class name, with leading underscores removed and a single underscore
inserted, in front of the name.  For example, the identifier "__spam"
occurring in a class named "Ham" will be transformed to "_Ham__spam".
This transformation is independent of the syntactical context in which
the identifier is used.  If the transformed name is extremely long
(longer than 255 characters), implementation defined truncation may
happen. If the class name consists only of underscores, no
transformation is done.
u
Literals
********

Python supports string and bytes literals and various numeric
literals:

   literal ::= stringliteral | bytesliteral
               | integer | floatnumber | imagnumber

Evaluation of a literal yields an object of the given type (string,
bytes, integer, floating point number, complex number) with the given
value.  The value may be approximated in the case of floating point
and imaginary (complex) literals.  See section Literals for details.

All literals correspond to immutable data types, and hence the
object’s identity is less important than its value.  Multiple
evaluations of literals with the same value (either the same
occurrence in the program text or a different occurrence) may obtain
the same object or a different object with the same value.
uA7Customizing attribute access
****************************

The following methods can be defined to customize the meaning of
attribute access (use of, assignment to, or deletion of "x.name") for
class instances.

object.__getattr__(self, name)

   Called when the default attribute access fails with an
   "AttributeError" (either "__getattribute__()" raises an
   "AttributeError" because *name* is not an instance attribute or an
   attribute in the class tree for "self"; or "__get__()" of a *name*
   property raises "AttributeError").  This method should either
   return the (computed) attribute value or raise an "AttributeError"
   exception.

   Note that if the attribute is found through the normal mechanism,
   "__getattr__()" is not called.  (This is an intentional asymmetry
   between "__getattr__()" and "__setattr__()".) This is done both for
   efficiency reasons and because otherwise "__getattr__()" would have
   no way to access other attributes of the instance.  Note that at
   least for instance variables, you can fake total control by not
   inserting any values in the instance attribute dictionary (but
   instead inserting them in another object).  See the
   "__getattribute__()" method below for a way to actually get total
   control over attribute access.

object.__getattribute__(self, name)

   Called unconditionally to implement attribute accesses for
   instances of the class. If the class also defines "__getattr__()",
   the latter will not be called unless "__getattribute__()" either
   calls it explicitly or raises an "AttributeError". This method
   should return the (computed) attribute value or raise an
   "AttributeError" exception. In order to avoid infinite recursion in
   this method, its implementation should always call the base class
   method with the same name to access any attributes it needs, for
   example, "object.__getattribute__(self, name)".

   Note:

     This method may still be bypassed when looking up special methods
     as the result of implicit invocation via language syntax or
     built-in functions. See Special method lookup.

   For certain sensitive attribute accesses, raises an auditing event
   "object.__getattr__" with arguments "obj" and "name".

object.__setattr__(self, name, value)

   Called when an attribute assignment is attempted.  This is called
   instead of the normal mechanism (i.e. store the value in the
   instance dictionary). *name* is the attribute name, *value* is the
   value to be assigned to it.

   If "__setattr__()" wants to assign to an instance attribute, it
   should call the base class method with the same name, for example,
   "object.__setattr__(self, name, value)".

   For certain sensitive attribute assignments, raises an auditing
   event "object.__setattr__" with arguments "obj", "name", "value".

object.__delattr__(self, name)

   Like "__setattr__()" but for attribute deletion instead of
   assignment.  This should only be implemented if "del obj.name" is
   meaningful for the object.

   For certain sensitive attribute deletions, raises an auditing event
   "object.__delattr__" with arguments "obj" and "name".

object.__dir__(self)

   Called when "dir()" is called on the object. A sequence must be
   returned. "dir()" converts the returned sequence to a list and
   sorts it.


Customizing module attribute access
===================================

Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
attribute and return the computed value or raise an "AttributeError".
If an attribute is not found on a module object through the normal
lookup, i.e. "object.__getattribute__()", then "__getattr__" is
searched in the module "__dict__" before raising an "AttributeError".
If found, it is called with the attribute name and the result is
returned.

The "__dir__" function should accept no arguments, and return a
sequence of strings that represents the names accessible on module. If
present, this function overrides the standard "dir()" search on a
module.

For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:

   import sys
   from types import ModuleType

   class VerboseModule(ModuleType):
       def __repr__(self):
           return f'Verbose {self.__name__}'

       def __setattr__(self, attr, value):
           print(f'Setting {attr}...')
           super().__setattr__(attr, value)

   sys.modules[__name__].__class__ = VerboseModule

Note:

  Defining module "__getattr__" and setting module "__class__" only
  affect lookups made using the attribute access syntax – directly
  accessing the module globals (whether by code within the module, or
  via a reference to the module’s globals dictionary) is unaffected.

Changed in version 3.5: "__class__" module attribute is now writable.

New in version 3.7: "__getattr__" and "__dir__" module attributes.

See also:

  **PEP 562** - Module __getattr__ and __dir__
     Describes the "__getattr__" and "__dir__" functions on modules.


Implementing Descriptors
========================

The following methods only apply when an instance of the class
containing the method (a so-called *descriptor* class) appears in an
*owner* class (the descriptor must be in either the owner’s class
dictionary or in the class dictionary for one of its parents).  In the
examples below, “the attribute” refers to the attribute whose name is
the key of the property in the owner class’ "__dict__".

object.__get__(self, instance, owner=None)

   Called to get the attribute of the owner class (class attribute
   access) or of an instance of that class (instance attribute
   access). The optional *owner* argument is the owner class, while
   *instance* is the instance that the attribute was accessed through,
   or "None" when the attribute is accessed through the *owner*.

   This method should return the computed attribute value or raise an
   "AttributeError" exception.

   **PEP 252** specifies that "__get__()" is callable with one or two
   arguments.  Python’s own built-in descriptors support this
   specification; however, it is likely that some third-party tools
   have descriptors that require both arguments.  Python’s own
   "__getattribute__()" implementation always passes in both arguments
   whether they are required or not.

object.__set__(self, instance, value)

   Called to set the attribute on an instance *instance* of the owner
   class to a new value, *value*.

   Note, adding "__set__()" or "__delete__()" changes the kind of
   descriptor to a “data descriptor”.  See Invoking Descriptors for
   more details.

object.__delete__(self, instance)

   Called to delete the attribute on an instance *instance* of the
   owner class.

object.__set_name__(self, owner, name)

   Called at the time the owning class *owner* is created. The
   descriptor has been assigned to *name*.

   Note:

     "__set_name__()" is only called implicitly as part of the "type"
     constructor, so it will need to be called explicitly with the
     appropriate parameters when a descriptor is added to a class
     after initial creation:

        class A:
           pass
        descr = custom_descriptor()
        A.attr = descr
        descr.__set_name__(A, 'attr')

     See Creating the class object for more details.

   New in version 3.6.

The attribute "__objclass__" is interpreted by the "inspect" module as
specifying the class where this object was defined (setting this
appropriately can assist in runtime introspection of dynamic class
attributes). For callables, it may indicate that an instance of the
given type (or a subclass) is expected or required as the first
positional argument (for example, CPython sets this attribute for
unbound methods that are implemented in C).


Invoking Descriptors
====================

In general, a descriptor is an object attribute with “binding
behavior”, one whose attribute access has been overridden by methods
in the descriptor protocol:  "__get__()", "__set__()", and
"__delete__()". If any of those methods are defined for an object, it
is said to be a descriptor.

The default behavior for attribute access is to get, set, or delete
the attribute from an object’s dictionary. For instance, "a.x" has a
lookup chain starting with "a.__dict__['x']", then
"type(a).__dict__['x']", and continuing through the base classes of
"type(a)" excluding metaclasses.

However, if the looked-up value is an object defining one of the
descriptor methods, then Python may override the default behavior and
invoke the descriptor method instead.  Where this occurs in the
precedence chain depends on which descriptor methods were defined and
how they were called.

The starting point for descriptor invocation is a binding, "a.x". How
the arguments are assembled depends on "a":

Direct Call
   The simplest and least common call is when user code directly
   invokes a descriptor method:    "x.__get__(a)".

Instance Binding
   If binding to an object instance, "a.x" is transformed into the
   call: "type(a).__dict__['x'].__get__(a, type(a))".

Class Binding
   If binding to a class, "A.x" is transformed into the call:
   "A.__dict__['x'].__get__(None, A)".

Super Binding
   If "a" is an instance of "super", then the binding "super(B,
   obj).m()" searches "obj.__class__.__mro__" for the base class "A"
   immediately preceding "B" and then invokes the descriptor with the
   call: "A.__dict__['m'].__get__(obj, obj.__class__)".

For instance bindings, the precedence of descriptor invocation depends
on which descriptor methods are defined.  A descriptor can define any
combination of "__get__()", "__set__()" and "__delete__()".  If it
does not define "__get__()", then accessing the attribute will return
the descriptor object itself unless there is a value in the object’s
instance dictionary.  If the descriptor defines "__set__()" and/or
"__delete__()", it is a data descriptor; if it defines neither, it is
a non-data descriptor.  Normally, data descriptors define both
"__get__()" and "__set__()", while non-data descriptors have just the
"__get__()" method.  Data descriptors with "__set__()" and "__get__()"
defined always override a redefinition in an instance dictionary.  In
contrast, non-data descriptors can be overridden by instances.

Python methods (including "staticmethod()" and "classmethod()") are
implemented as non-data descriptors.  Accordingly, instances can
redefine and override methods.  This allows individual instances to
acquire behaviors that differ from other instances of the same class.

The "property()" function is implemented as a data descriptor.
Accordingly, instances cannot override the behavior of a property.


__slots__
=========

*__slots__* allow us to explicitly declare data members (like
properties) and deny the creation of *__dict__* and *__weakref__*
(unless explicitly declared in *__slots__* or available in a parent.)

The space saved over using *__dict__* can be significant. Attribute
lookup speed can be significantly improved as well.

object.__slots__

   This class variable can be assigned a string, iterable, or sequence
   of strings with variable names used by instances.  *__slots__*
   reserves space for the declared variables and prevents the
   automatic creation of *__dict__* and *__weakref__* for each
   instance.


Notes on using *__slots__*
--------------------------

* When inheriting from a class without *__slots__*, the *__dict__* and
  *__weakref__* attribute of the instances will always be accessible.

* Without a *__dict__* variable, instances cannot be assigned new
  variables not listed in the *__slots__* definition.  Attempts to
  assign to an unlisted variable name raises "AttributeError". If
  dynamic assignment of new variables is desired, then add
  "'__dict__'" to the sequence of strings in the *__slots__*
  declaration.

* Without a *__weakref__* variable for each instance, classes defining
  *__slots__* do not support weak references to its instances. If weak
  reference support is needed, then add "'__weakref__'" to the
  sequence of strings in the *__slots__* declaration.

* *__slots__* are implemented at the class level by creating
  descriptors (Implementing Descriptors) for each variable name.  As a
  result, class attributes cannot be used to set default values for
  instance variables defined by *__slots__*; otherwise, the class
  attribute would overwrite the descriptor assignment.

* The action of a *__slots__* declaration is not limited to the class
  where it is defined.  *__slots__* declared in parents are available
  in child classes. However, child subclasses will get a *__dict__*
  and *__weakref__* unless they also define *__slots__* (which should
  only contain names of any *additional* slots).

* If a class defines a slot also defined in a base class, the instance
  variable defined by the base class slot is inaccessible (except by
  retrieving its descriptor directly from the base class). This
  renders the meaning of the program undefined.  In the future, a
  check may be added to prevent this.

* Nonempty *__slots__* does not work for classes derived from
  “variable-length” built-in types such as "int", "bytes" and "tuple".

* Any non-string iterable may be assigned to *__slots__*. Mappings may
  also be used; however, in the future, special meaning may be
  assigned to the values corresponding to each key.

* *__class__* assignment works only if both classes have the same
  *__slots__*.

* Multiple inheritance with multiple slotted parent classes can be
  used, but only one parent is allowed to have attributes created by
  slots (the other bases must have empty slot layouts) - violations
  raise "TypeError".

* If an iterator is used for *__slots__* then a descriptor is created
  for each of the iterator’s values. However, the *__slots__*
  attribute will be an empty iterator.
a�Attribute references
********************

An attribute reference is a primary followed by a period and a name:

   attributeref ::= primary "." identifier

The primary must evaluate to an object of a type that supports
attribute references, which most objects do.  This object is then
asked to produce the attribute whose name is the identifier.  This
production can be customized by overriding the "__getattr__()" method.
If this attribute is not available, the exception "AttributeError" is
raised.  Otherwise, the type and value of the object produced is
determined by the object.  Multiple evaluations of the same attribute
reference may yield different objects.
a�Augmented assignment statements
*******************************

Augmented assignment is the combination, in a single statement, of a
binary operation and an assignment statement:

   augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)
   augtarget                 ::= identifier | attributeref | subscription | slicing
   augop                     ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
             | ">>=" | "<<=" | "&=" | "^=" | "|="

(See section Primaries for the syntax definitions of the last three
symbols.)

An augmented assignment evaluates the target (which, unlike normal
assignment statements, cannot be an unpacking) and the expression
list, performs the binary operation specific to the type of assignment
on the two operands, and assigns the result to the original target.
The target is only evaluated once.

An augmented assignment expression like "x += 1" can be rewritten as
"x = x + 1" to achieve a similar, but not exactly equal effect. In the
augmented version, "x" is only evaluated once. Also, when possible,
the actual operation is performed *in-place*, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.

Unlike normal assignments, augmented assignments evaluate the left-
hand side *before* evaluating the right-hand side.  For example, "a[i]
+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs
the addition, and lastly, it writes the result back to "a[i]".

With the exception of assigning to tuples and multiple targets in a
single statement, the assignment done by augmented assignment
statements is handled the same way as normal assignments. Similarly,
with the exception of the possible *in-place* behavior, the binary
operation performed by augmented assignment is the same as the normal
binary operations.

For targets which are attribute references, the same caveat about
class and instance attributes applies as for regular assignments.
z�Await expression
****************

Suspend the execution of *coroutine* on an *awaitable* object. Can
only be used inside a *coroutine function*.

   await_expr ::= "await" primary

New in version 3.5.
ujBinary arithmetic operations
****************************

The binary arithmetic operations have the conventional priority
levels.  Note that some of these operations also apply to certain non-
numeric types.  Apart from the power operator, there are only two
levels, one for multiplicative operators and one for additive
operators:

   m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |
              m_expr "//" u_expr | m_expr "/" u_expr |
              m_expr "%" u_expr
   a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr

The "*" (multiplication) operator yields the product of its arguments.
The arguments must either both be numbers, or one argument must be an
integer and the other must be a sequence. In the former case, the
numbers are converted to a common type and then multiplied together.
In the latter case, sequence repetition is performed; a negative
repetition factor yields an empty sequence.

The "@" (at) operator is intended to be used for matrix
multiplication.  No builtin Python types implement this operator.

New in version 3.5.

The "/" (division) and "//" (floor division) operators yield the
quotient of their arguments.  The numeric arguments are first
converted to a common type. Division of integers yields a float, while
floor division of integers results in an integer; the result is that
of mathematical division with the ‘floor’ function applied to the
result.  Division by zero raises the "ZeroDivisionError" exception.

The "%" (modulo) operator yields the remainder from the division of
the first argument by the second.  The numeric arguments are first
converted to a common type.  A zero right argument raises the
"ZeroDivisionError" exception.  The arguments may be floating point
numbers, e.g., "3.14%0.7" equals "0.34" (since "3.14" equals "4*0.7 +
0.34".)  The modulo operator always yields a result with the same sign
as its second operand (or zero); the absolute value of the result is
strictly smaller than the absolute value of the second operand [1].

The floor division and modulo operators are connected by the following
identity: "x == (x//y)*y + (x%y)".  Floor division and modulo are also
connected with the built-in function "divmod()": "divmod(x, y) ==
(x//y, x%y)". [2].

In addition to performing the modulo operation on numbers, the "%"
operator is also overloaded by string objects to perform old-style
string formatting (also known as interpolation).  The syntax for
string formatting is described in the Python Library Reference,
section printf-style String Formatting.

The floor division operator, the modulo operator, and the "divmod()"
function are not defined for complex numbers.  Instead, convert to a
floating point number using the "abs()" function if appropriate.

The "+" (addition) operator yields the sum of its arguments.  The
arguments must either both be numbers or both be sequences of the same
type.  In the former case, the numbers are converted to a common type
and then added together. In the latter case, the sequences are
concatenated.

The "-" (subtraction) operator yields the difference of its arguments.
The numeric arguments are first converted to a common type.
a$Binary bitwise operations
*************************

Each of the three bitwise operations has a different priority level:

   and_expr ::= shift_expr | and_expr "&" shift_expr
   xor_expr ::= and_expr | xor_expr "^" and_expr
   or_expr  ::= xor_expr | or_expr "|" xor_expr

The "&" operator yields the bitwise AND of its arguments, which must
be integers.

The "^" operator yields the bitwise XOR (exclusive OR) of its
arguments, which must be integers.

The "|" operator yields the bitwise (inclusive) OR of its arguments,
which must be integers.
u�Code Objects
************

Code objects are used by the implementation to represent “pseudo-
compiled” executable Python code such as a function body. They differ
from function objects because they don’t contain a reference to their
global execution environment.  Code objects are returned by the built-
in "compile()" function and can be extracted from function objects
through their "__code__" attribute. See also the "code" module.

Accessing "__code__" raises an auditing event "object.__getattr__"
with arguments "obj" and ""__code__"".

A code object can be executed or evaluated by passing it (instead of a
source string) to the "exec()" or "eval()"  built-in functions.

See The standard type hierarchy for more information.
a.The Ellipsis Object
*******************

This object is commonly used by slicing (see Slicings).  It supports
no special operations.  There is exactly one ellipsis object, named
"Ellipsis" (a built-in name).  "type(Ellipsis)()" produces the
"Ellipsis" singleton.

It is written as "Ellipsis" or "...".
uThe Null Object
***************

This object is returned by functions that don’t explicitly return a
value.  It supports no special operations.  There is exactly one null
object, named "None" (a built-in name).  "type(None)()" produces the
same singleton.

It is written as "None".
u5Type Objects
************

Type objects represent the various object types.  An object’s type is
accessed by the built-in function "type()".  There are no special
operations on types.  The standard module "types" defines names for
all standard built-in types.

Types are written like this: "<class 'int'>".
a�Boolean operations
******************

   or_test  ::= and_test | or_test "or" and_test
   and_test ::= not_test | and_test "and" not_test
   not_test ::= comparison | "not" not_test

In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are interpreted
as false: "False", "None", numeric zero of all types, and empty
strings and containers (including strings, tuples, lists,
dictionaries, sets and frozensets).  All other values are interpreted
as true.  User-defined objects can customize their truth value by
providing a "__bool__()" method.

The operator "not" yields "True" if its argument is false, "False"
otherwise.

The expression "x and y" first evaluates *x*; if *x* is false, its
value is returned; otherwise, *y* is evaluated and the resulting value
is returned.

The expression "x or y" first evaluates *x*; if *x* is true, its value
is returned; otherwise, *y* is evaluated and the resulting value is
returned.

Note that neither "and" nor "or" restrict the value and type they
return to "False" and "True", but rather return the last evaluated
argument.  This is sometimes useful, e.g., if "s" is a string that
should be replaced by a default value if it is empty, the expression
"s or 'foo'" yields the desired value.  Because "not" has to create a
new value, it returns a boolean value regardless of the type of its
argument (for example, "not 'foo'" produces "False" rather than "''".)
a$The "break" statement
*********************

   break_stmt ::= "break"

"break" may only occur syntactically nested in a "for" or "while"
loop, but not nested in a function or class definition within that
loop.

It terminates the nearest enclosing loop, skipping the optional "else"
clause if the loop has one.

If a "for" loop is terminated by "break", the loop control target
keeps its current value.

When "break" passes control out of a "try" statement with a "finally"
clause, that "finally" clause is executed before really leaving the
loop.
uEmulating callable objects
**************************

object.__call__(self[, args...])

   Called when the instance is “called” as a function; if this method
   is defined, "x(arg1, arg2, ...)" roughly translates to
   "type(x).__call__(x, arg1, ...)".
u�Calls
*****

A call calls a callable object (e.g., a *function*) with a possibly
empty series of *arguments*:

   call                 ::= primary "(" [argument_list [","] | comprehension] ")"
   argument_list        ::= positional_arguments ["," starred_and_keywords]
                       ["," keywords_arguments]
                     | starred_and_keywords ["," keywords_arguments]
                     | keywords_arguments
   positional_arguments ::= positional_item ("," positional_item)*
   positional_item      ::= assignment_expression | "*" expression
   starred_and_keywords ::= ("*" expression | keyword_item)
                            ("," "*" expression | "," keyword_item)*
   keywords_arguments   ::= (keyword_item | "**" expression)
                          ("," keyword_item | "," "**" expression)*
   keyword_item         ::= identifier "=" expression

An optional trailing comma may be present after the positional and
keyword arguments but does not affect the semantics.

The primary must evaluate to a callable object (user-defined
functions, built-in functions, methods of built-in objects, class
objects, methods of class instances, and all objects having a
"__call__()" method are callable).  All argument expressions are
evaluated before the call is attempted.  Please refer to section
Function definitions for the syntax of formal *parameter* lists.

If keyword arguments are present, they are first converted to
positional arguments, as follows.  First, a list of unfilled slots is
created for the formal parameters.  If there are N positional
arguments, they are placed in the first N slots.  Next, for each
keyword argument, the identifier is used to determine the
corresponding slot (if the identifier is the same as the first formal
parameter name, the first slot is used, and so on).  If the slot is
already filled, a "TypeError" exception is raised. Otherwise, the
value of the argument is placed in the slot, filling it (even if the
expression is "None", it fills the slot).  When all arguments have
been processed, the slots that are still unfilled are filled with the
corresponding default value from the function definition.  (Default
values are calculated, once, when the function is defined; thus, a
mutable object such as a list or dictionary used as default value will
be shared by all calls that don’t specify an argument value for the
corresponding slot; this should usually be avoided.)  If there are any
unfilled slots for which no default value is specified, a "TypeError"
exception is raised.  Otherwise, the list of filled slots is used as
the argument list for the call.

**CPython implementation detail:** An implementation may provide
built-in functions whose positional parameters do not have names, even
if they are ‘named’ for the purpose of documentation, and which
therefore cannot be supplied by keyword.  In CPython, this is the case
for functions implemented in C that use "PyArg_ParseTuple()" to parse
their arguments.

If there are more positional arguments than there are formal parameter
slots, a "TypeError" exception is raised, unless a formal parameter
using the syntax "*identifier" is present; in this case, that formal
parameter receives a tuple containing the excess positional arguments
(or an empty tuple if there were no excess positional arguments).

If any keyword argument does not correspond to a formal parameter
name, a "TypeError" exception is raised, unless a formal parameter
using the syntax "**identifier" is present; in this case, that formal
parameter receives a dictionary containing the excess keyword
arguments (using the keywords as keys and the argument values as
corresponding values), or a (new) empty dictionary if there were no
excess keyword arguments.

If the syntax "*expression" appears in the function call, "expression"
must evaluate to an *iterable*.  Elements from these iterables are
treated as if they were additional positional arguments.  For the call
"f(x1, x2, *y, x3, x4)", if *y* evaluates to a sequence *y1*, …, *yM*,
this is equivalent to a call with M+4 positional arguments *x1*, *x2*,
*y1*, …, *yM*, *x3*, *x4*.

A consequence of this is that although the "*expression" syntax may
appear *after* explicit keyword arguments, it is processed *before*
the keyword arguments (and any "**expression" arguments – see below).
So:

   >>> def f(a, b):
   ...     print(a, b)
   ...
   >>> f(b=1, *(2,))
   2 1
   >>> f(a=1, *(2,))
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: f() got multiple values for keyword argument 'a'
   >>> f(1, *(2,))
   1 2

It is unusual for both keyword arguments and the "*expression" syntax
to be used in the same call, so in practice this confusion does not
arise.

If the syntax "**expression" appears in the function call,
"expression" must evaluate to a *mapping*, the contents of which are
treated as additional keyword arguments.  If a keyword is already
present (as an explicit keyword argument, or from another unpacking),
a "TypeError" exception is raised.

Formal parameters using the syntax "*identifier" or "**identifier"
cannot be used as positional argument slots or as keyword argument
names.

Changed in version 3.5: Function calls accept any number of "*" and
"**" unpackings, positional arguments may follow iterable unpackings
("*"), and keyword arguments may follow dictionary unpackings ("**").
Originally proposed by **PEP 448**.

A call always returns some value, possibly "None", unless it raises an
exception.  How this value is computed depends on the type of the
callable object.

If it is—

a user-defined function:
   The code block for the function is executed, passing it the
   argument list.  The first thing the code block will do is bind the
   formal parameters to the arguments; this is described in section
   Function definitions.  When the code block executes a "return"
   statement, this specifies the return value of the function call.

a built-in function or method:
   The result is up to the interpreter; see Built-in Functions for the
   descriptions of built-in functions and methods.

a class object:
   A new instance of that class is returned.

a class instance method:
   The corresponding user-defined function is called, with an argument
   list that is one longer than the argument list of the call: the
   instance becomes the first argument.

a class instance:
   The class must define a "__call__()" method; the effect is then the
   same as if that method was called.
uClass definitions
*****************

A class definition defines a class object (see section The standard
type hierarchy):

   classdef    ::= [decorators] "class" classname [inheritance] ":" suite
   inheritance ::= "(" [argument_list] ")"
   classname   ::= identifier

A class definition is an executable statement.  The inheritance list
usually gives a list of base classes (see Metaclasses for more
advanced uses), so each item in the list should evaluate to a class
object which allows subclassing.  Classes without an inheritance list
inherit, by default, from the base class "object"; hence,

   class Foo:
       pass

is equivalent to

   class Foo(object):
       pass

The class’s suite is then executed in a new execution frame (see
Naming and binding), using a newly created local namespace and the
original global namespace. (Usually, the suite contains mostly
function definitions.)  When the class’s suite finishes execution, its
execution frame is discarded but its local namespace is saved. [3] A
class object is then created using the inheritance list for the base
classes and the saved local namespace for the attribute dictionary.
The class name is bound to this class object in the original local
namespace.

The order in which attributes are defined in the class body is
preserved in the new class’s "__dict__".  Note that this is reliable
only right after the class is created and only for classes that were
defined using the definition syntax.

Class creation can be customized heavily using metaclasses.

Classes can also be decorated: just like when decorating functions,

   @f1(arg)
   @f2
   class Foo: pass

is roughly equivalent to

   class Foo: pass
   Foo = f1(arg)(f2(Foo))

The evaluation rules for the decorator expressions are the same as for
function decorators.  The result is then bound to the class name.

**Programmer’s note:** Variables defined in the class definition are
class attributes; they are shared by instances.  Instance attributes
can be set in a method with "self.name = value".  Both class and
instance attributes are accessible through the notation “"self.name"”,
and an instance attribute hides a class attribute with the same name
when accessed in this way.  Class attributes can be used as defaults
for instance attributes, but using mutable values there can lead to
unexpected results.  Descriptors can be used to create instance
variables with different implementation details.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     The proposal that changed the declaration of metaclasses to the
     current syntax, and the semantics for how classes with
     metaclasses are constructed.

  **PEP 3129** - Class Decorators
     The proposal that added class decorators.  Function and method
     decorators were introduced in **PEP 318**.
u�'Comparisons
***********

Unlike C, all comparison operations in Python have the same priority,
which is lower than that of any arithmetic, shifting or bitwise
operation.  Also unlike C, expressions like "a < b < c" have the
interpretation that is conventional in mathematics:

   comparison    ::= or_expr (comp_operator or_expr)*
   comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="
                     | "is" ["not"] | ["not"] "in"

Comparisons yield boolean values: "True" or "False".

Comparisons can be chained arbitrarily, e.g., "x < y <= z" is
equivalent to "x < y and y <= z", except that "y" is evaluated only
once (but in both cases "z" is not evaluated at all when "x < y" is
found to be false).

Formally, if *a*, *b*, *c*, …, *y*, *z* are expressions and *op1*,
*op2*, …, *opN* are comparison operators, then "a op1 b op2 c ... y
opN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except
that each expression is evaluated at most once.

Note that "a op1 b op2 c" doesn’t imply any kind of comparison between
*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though
perhaps not pretty).


Value comparisons
=================

The operators "<", ">", "==", ">=", "<=", and "!=" compare the values
of two objects.  The objects do not need to have the same type.

Chapter Objects, values and types states that objects have a value (in
addition to type and identity).  The value of an object is a rather
abstract notion in Python: For example, there is no canonical access
method for an object’s value.  Also, there is no requirement that the
value of an object should be constructed in a particular way, e.g.
comprised of all its data attributes. Comparison operators implement a
particular notion of what the value of an object is.  One can think of
them as defining the value of an object indirectly, by means of their
comparison implementation.

Because all types are (direct or indirect) subtypes of "object", they
inherit the default comparison behavior from "object".  Types can
customize their comparison behavior by implementing *rich comparison
methods* like "__lt__()", described in Basic customization.

The default behavior for equality comparison ("==" and "!=") is based
on the identity of the objects.  Hence, equality comparison of
instances with the same identity results in equality, and equality
comparison of instances with different identities results in
inequality.  A motivation for this default behavior is the desire that
all objects should be reflexive (i.e. "x is y" implies "x == y").

A default order comparison ("<", ">", "<=", and ">=") is not provided;
an attempt raises "TypeError".  A motivation for this default behavior
is the lack of a similar invariant as for equality.

The behavior of the default equality comparison, that instances with
different identities are always unequal, may be in contrast to what
types will need that have a sensible definition of object value and
value-based equality.  Such types will need to customize their
comparison behavior, and in fact, a number of built-in types have done
that.

The following list describes the comparison behavior of the most
important built-in types.

* Numbers of built-in numeric types (Numeric Types — int, float,
  complex) and of the standard library types "fractions.Fraction" and
  "decimal.Decimal" can be compared within and across their types,
  with the restriction that complex numbers do not support order
  comparison.  Within the limits of the types involved, they compare
  mathematically (algorithmically) correct without loss of precision.

  The not-a-number values "float('NaN')" and "decimal.Decimal('NaN')"
  are special.  Any ordered comparison of a number to a not-a-number
  value is false. A counter-intuitive implication is that not-a-number
  values are not equal to themselves.  For example, if "x =
  float('NaN')", "3 < x", "x < 3" and "x == x" are all false, while "x
  != x" is true.  This behavior is compliant with IEEE 754.

* "None" and "NotImplemented" are singletons.  **PEP 8** advises that
  comparisons for singletons should always be done with "is" or "is
  not", never the equality operators.

* Binary sequences (instances of "bytes" or "bytearray") can be
  compared within and across their types.  They compare
  lexicographically using the numeric values of their elements.

* Strings (instances of "str") compare lexicographically using the
  numerical Unicode code points (the result of the built-in function
  "ord()") of their characters. [3]

  Strings and binary sequences cannot be directly compared.

* Sequences (instances of "tuple", "list", or "range") can be compared
  only within each of their types, with the restriction that ranges do
  not support order comparison.  Equality comparison across these
  types results in inequality, and ordering comparison across these
  types raises "TypeError".

  Sequences compare lexicographically using comparison of
  corresponding elements.  The built-in containers typically assume
  identical objects are equal to themselves.  That lets them bypass
  equality tests for identical objects to improve performance and to
  maintain their internal invariants.

  Lexicographical comparison between built-in collections works as
  follows:

  * For two collections to compare equal, they must be of the same
    type, have the same length, and each pair of corresponding
    elements must compare equal (for example, "[1,2] == (1,2)" is
    false because the type is not the same).

  * Collections that support order comparison are ordered the same as
    their first unequal elements (for example, "[1,2,x] <= [1,2,y]"
    has the same value as "x <= y").  If a corresponding element does
    not exist, the shorter collection is ordered first (for example,
    "[1,2] < [1,2,3]" is true).

* Mappings (instances of "dict") compare equal if and only if they
  have equal *(key, value)* pairs. Equality comparison of the keys and
  values enforces reflexivity.

  Order comparisons ("<", ">", "<=", and ">=") raise "TypeError".

* Sets (instances of "set" or "frozenset") can be compared within and
  across their types.

  They define order comparison operators to mean subset and superset
  tests.  Those relations do not define total orderings (for example,
  the two sets "{1,2}" and "{2,3}" are not equal, nor subsets of one
  another, nor supersets of one another).  Accordingly, sets are not
  appropriate arguments for functions which depend on total ordering
  (for example, "min()", "max()", and "sorted()" produce undefined
  results given a list of sets as inputs).

  Comparison of sets enforces reflexivity of its elements.

* Most other built-in types have no comparison methods implemented, so
  they inherit the default comparison behavior.

User-defined classes that customize their comparison behavior should
follow some consistency rules, if possible:

* Equality comparison should be reflexive. In other words, identical
  objects should compare equal:

     "x is y" implies "x == y"

* Comparison should be symmetric. In other words, the following
  expressions should have the same result:

     "x == y" and "y == x"

     "x != y" and "y != x"

     "x < y" and "y > x"

     "x <= y" and "y >= x"

* Comparison should be transitive. The following (non-exhaustive)
  examples illustrate that:

     "x > y and y > z" implies "x > z"

     "x < y and y <= z" implies "x < z"

* Inverse comparison should result in the boolean negation. In other
  words, the following expressions should have the same result:

     "x == y" and "not x != y"

     "x < y" and "not x >= y" (for total ordering)

     "x > y" and "not x <= y" (for total ordering)

  The last two expressions apply to totally ordered collections (e.g.
  to sequences, but not to sets or mappings). See also the
  "total_ordering()" decorator.

* The "hash()" result should be consistent with equality. Objects that
  are equal should either have the same hash value, or be marked as
  unhashable.

Python does not enforce these consistency rules. In fact, the
not-a-number values are an example for not following these rules.


Membership test operations
==========================

The operators "in" and "not in" test for membership.  "x in s"
evaluates to "True" if *x* is a member of *s*, and "False" otherwise.
"x not in s" returns the negation of "x in s".  All built-in sequences
and set types support this as well as dictionary, for which "in" tests
whether the dictionary has a given key. For container types such as
list, tuple, set, frozenset, dict, or collections.deque, the
expression "x in y" is equivalent to "any(x is e or x == e for e in
y)".

For the string and bytes types, "x in y" is "True" if and only if *x*
is a substring of *y*.  An equivalent test is "y.find(x) != -1".
Empty strings are always considered to be a substring of any other
string, so """ in "abc"" will return "True".

For user-defined classes which define the "__contains__()" method, "x
in y" returns "True" if "y.__contains__(x)" returns a true value, and
"False" otherwise.

For user-defined classes which do not define "__contains__()" but do
define "__iter__()", "x in y" is "True" if some value "z", for which
the expression "x is z or x == z" is true, is produced while iterating
over "y". If an exception is raised during the iteration, it is as if
"in" raised that exception.

Lastly, the old-style iteration protocol is tried: if a class defines
"__getitem__()", "x in y" is "True" if and only if there is a non-
negative integer index *i* such that "x is y[i] or x == y[i]", and no
lower integer index raises the "IndexError" exception.  (If any other
exception is raised, it is as if "in" raised that exception).

The operator "not in" is defined to have the inverse truth value of
"in".


Identity comparisons
====================

The operators "is" and "is not" test for an object’s identity: "x is
y" is true if and only if *x* and *y* are the same object.  An
Object’s identity is determined using the "id()" function.  "x is not
y" yields the inverse truth value. [4]
u�lCompound statements
*******************

Compound statements contain (groups of) other statements; they affect
or control the execution of those other statements in some way.  In
general, compound statements span multiple lines, although in simple
incarnations a whole compound statement may be contained in one line.

The "if", "while" and "for" statements implement traditional control
flow constructs.  "try" specifies exception handlers and/or cleanup
code for a group of statements, while the "with" statement allows the
execution of initialization and finalization code around a block of
code.  Function and class definitions are also syntactically compound
statements.

A compound statement consists of one or more ‘clauses.’  A clause
consists of a header and a ‘suite.’  The clause headers of a
particular compound statement are all at the same indentation level.
Each clause header begins with a uniquely identifying keyword and ends
with a colon.  A suite is a group of statements controlled by a
clause.  A suite can be one or more semicolon-separated simple
statements on the same line as the header, following the header’s
colon, or it can be one or more indented statements on subsequent
lines.  Only the latter form of a suite can contain nested compound
statements; the following is illegal, mostly because it wouldn’t be
clear to which "if" clause a following "else" clause would belong:

   if test1: if test2: print(x)

Also note that the semicolon binds tighter than the colon in this
context, so that in the following example, either all or none of the
"print()" calls are executed:

   if x < y < z: print(x); print(y); print(z)

Summarizing:

   compound_stmt ::= if_stmt
                     | while_stmt
                     | for_stmt
                     | try_stmt
                     | with_stmt
                     | funcdef
                     | classdef
                     | async_with_stmt
                     | async_for_stmt
                     | async_funcdef
   suite         ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT
   statement     ::= stmt_list NEWLINE | compound_stmt
   stmt_list     ::= simple_stmt (";" simple_stmt)* [";"]

Note that statements always end in a "NEWLINE" possibly followed by a
"DEDENT".  Also note that optional continuation clauses always begin
with a keyword that cannot start a statement, thus there are no
ambiguities (the ‘dangling "else"’ problem is solved in Python by
requiring nested "if" statements to be indented).

The formatting of the grammar rules in the following sections places
each clause on a separate line for clarity.


The "if" statement
==================

The "if" statement is used for conditional execution:

   if_stmt ::= "if" assignment_expression ":" suite
               ("elif" assignment_expression ":" suite)*
               ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section Boolean operations
for the definition of true and false); then that suite is executed
(and no other part of the "if" statement is executed or evaluated).
If all expressions are false, the suite of the "else" clause, if
present, is executed.


The "while" statement
=====================

The "while" statement is used for repeated execution as long as an
expression is true:

   while_stmt ::= "while" assignment_expression ":" suite
                  ["else" ":" suite]

This repeatedly tests the expression and, if it is true, executes the
first suite; if the expression is false (which may be the first time
it is tested) the suite of the "else" clause, if present, is executed
and the loop terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and goes back
to testing the expression.


The "for" statement
===================

The "for" statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object:

   for_stmt ::= "for" target_list "in" expression_list ":" suite
                ["else" ":" suite]

The expression list is evaluated once; it should yield an iterable
object.  An iterator is created for the result of the
"expression_list".  The suite is then executed once for each item
provided by the iterator, in the order returned by the iterator.  Each
item in turn is assigned to the target list using the standard rules
for assignments (see Assignment statements), and then the suite is
executed.  When the items are exhausted (which is immediately when the
sequence is empty or an iterator raises a "StopIteration" exception),
the suite in the "else" clause, if present, is executed, and the loop
terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and continues
with the next item, or with the "else" clause if there is no next
item.

The for-loop makes assignments to the variables in the target list.
This overwrites all previous assignments to those variables including
those made in the suite of the for-loop:

   for i in range(10):
       print(i)
       i = 5             # this will not affect the for-loop
                         # because i will be overwritten with the next
                         # index in the range

Names in the target list are not deleted when the loop is finished,
but if the sequence is empty, they will not have been assigned to at
all by the loop.  Hint: the built-in function "range()" returns an
iterator of integers suitable to emulate the effect of Pascal’s "for i
:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".

Note:

  There is a subtlety when the sequence is being modified by the loop
  (this can only occur for mutable sequences, e.g. lists).  An
  internal counter is used to keep track of which item is used next,
  and this is incremented on each iteration.  When this counter has
  reached the length of the sequence the loop terminates.  This means
  that if the suite deletes the current (or a previous) item from the
  sequence, the next item will be skipped (since it gets the index of
  the current item which has already been treated).  Likewise, if the
  suite inserts an item in the sequence before the current item, the
  current item will be treated again the next time through the loop.
  This can lead to nasty bugs that can be avoided by making a
  temporary copy using a slice of the whole sequence, e.g.,

     for x in a[:]:
         if x < 0: a.remove(x)


The "try" statement
===================

The "try" statement specifies exception handlers and/or cleanup code
for a group of statements:

   try_stmt  ::= try1_stmt | try2_stmt
   try1_stmt ::= "try" ":" suite
                 ("except" [expression ["as" identifier]] ":" suite)+
                 ["else" ":" suite]
                 ["finally" ":" suite]
   try2_stmt ::= "try" ":" suite
                 "finally" ":" suite

The "except" clause(s) specify one or more exception handlers. When no
exception occurs in the "try" clause, no exception handler is
executed. When an exception occurs in the "try" suite, a search for an
exception handler is started.  This search inspects the except clauses
in turn until one is found that matches the exception.  An expression-
less except clause, if present, must be last; it matches any
exception.  For an except clause with an expression, that expression
is evaluated, and the clause matches the exception if the resulting
object is “compatible” with the exception.  An object is compatible
with an exception if it is the class or a base class of the exception
object, or a tuple containing an item that is the class or a base
class of the exception object.

If no except clause matches the exception, the search for an exception
handler continues in the surrounding code and on the invocation stack.
[1]

If the evaluation of an expression in the header of an except clause
raises an exception, the original search for a handler is canceled and
a search starts for the new exception in the surrounding code and on
the call stack (it is treated as if the entire "try" statement raised
the exception).

When a matching except clause is found, the exception is assigned to
the target specified after the "as" keyword in that except clause, if
present, and the except clause’s suite is executed.  All except
clauses must have an executable block.  When the end of this block is
reached, execution continues normally after the entire try statement.
(This means that if two nested handlers exist for the same exception,
and the exception occurs in the try clause of the inner handler, the
outer handler will not handle the exception.)

When an exception has been assigned using "as target", it is cleared
at the end of the except clause.  This is as if

   except E as N:
       foo

was translated to

   except E as N:
       try:
           foo
       finally:
           del N

This means the exception must be assigned to a different name to be
able to refer to it after the except clause.  Exceptions are cleared
because with the traceback attached to them, they form a reference
cycle with the stack frame, keeping all locals in that frame alive
until the next garbage collection occurs.

Before an except clause’s suite is executed, details about the
exception are stored in the "sys" module and can be accessed via
"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the
exception class, the exception instance and a traceback object (see
section The standard type hierarchy) identifying the point in the
program where the exception occurred.  "sys.exc_info()" values are
restored to their previous values (before the call) when returning
from a function that handled an exception.

The optional "else" clause is executed if the control flow leaves the
"try" suite, no exception was raised, and no "return", "continue", or
"break" statement was executed.  Exceptions in the "else" clause are
not handled by the preceding "except" clauses.

If "finally" is present, it specifies a ‘cleanup’ handler.  The "try"
clause is executed, including any "except" and "else" clauses.  If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed.  If
there is a saved exception it is re-raised at the end of the "finally"
clause.  If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:

   >>> def f():
   ...     try:
   ...         1/0
   ...     finally:
   ...         return 42
   ...
   >>> f()
   42

The exception information is not available to the program during
execution of the "finally" clause.

When a "return", "break" or "continue" statement is executed in the
"try" suite of a "try"…"finally" statement, the "finally" clause is
also executed ‘on the way out.’

The return value of a function is determined by the last "return"
statement executed.  Since the "finally" clause always executes, a
"return" statement executed in the "finally" clause will always be the
last one executed:

   >>> def foo():
   ...     try:
   ...         return 'try'
   ...     finally:
   ...         return 'finally'
   ...
   >>> foo()
   'finally'

Additional information on exceptions can be found in section
Exceptions, and information on using the "raise" statement to generate
exceptions may be found in section The raise statement.

Changed in version 3.8: Prior to Python 3.8, a "continue" statement
was illegal in the "finally" clause due to a problem with the
implementation.


The "with" statement
====================

The "with" statement is used to wrap the execution of a block with
methods defined by a context manager (see section With Statement
Context Managers). This allows common "try"…"except"…"finally" usage
patterns to be encapsulated for convenient reuse.

   with_stmt ::= "with" with_item ("," with_item)* ":" suite
   with_item ::= expression ["as" target]

The execution of the "with" statement with one “item” proceeds as
follows:

1. The context expression (the expression given in the "with_item") is
   evaluated to obtain a context manager.

2. The context manager’s "__enter__()" is loaded for later use.

3. The context manager’s "__exit__()" is loaded for later use.

4. The context manager’s "__enter__()" method is invoked.

5. If a target was included in the "with" statement, the return value
   from "__enter__()" is assigned to it.

   Note:

     The "with" statement guarantees that if the "__enter__()" method
     returns without an error, then "__exit__()" will always be
     called. Thus, if an error occurs during the assignment to the
     target list, it will be treated the same as an error occurring
     within the suite would be. See step 6 below.

6. The suite is executed.

7. The context manager’s "__exit__()" method is invoked.  If an
   exception caused the suite to be exited, its type, value, and
   traceback are passed as arguments to "__exit__()". Otherwise, three
   "None" arguments are supplied.

   If the suite was exited due to an exception, and the return value
   from the "__exit__()" method was false, the exception is reraised.
   If the return value was true, the exception is suppressed, and
   execution continues with the statement following the "with"
   statement.

   If the suite was exited for any reason other than an exception, the
   return value from "__exit__()" is ignored, and execution proceeds
   at the normal location for the kind of exit that was taken.

The following code:

   with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   enter = type(manager).__enter__
   exit = type(manager).__exit__
   value = enter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not exit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           exit(manager, None, None, None)

With more than one item, the context managers are processed as if
multiple "with" statements were nested:

   with A() as a, B() as b:
       SUITE

is semantically equivalent to:

   with A() as a:
       with B() as b:
           SUITE

Changed in version 3.1: Support for multiple context expressions.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.


Function definitions
====================

A function definition defines a user-defined function object (see
section The standard type hierarchy):

   funcdef                   ::= [decorators] "def" funcname "(" [parameter_list] ")"
               ["->" expression] ":" suite
   decorators                ::= decorator+
   decorator                 ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
   dotted_name               ::= identifier ("." identifier)*
   parameter_list            ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
                        | parameter_list_no_posonly
   parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
                                 | parameter_list_starargs
   parameter_list_starargs   ::= "*" [parameter] ("," defparameter)* ["," ["**" parameter [","]]]
                               | "**" parameter [","]
   parameter                 ::= identifier [":" expression]
   defparameter              ::= parameter ["=" expression]
   funcname                  ::= identifier

A function definition is an executable statement.  Its execution binds
the function name in the current local namespace to a function object
(a wrapper around the executable code for the function).  This
function object contains a reference to the current global namespace
as the global namespace to be used when the function is called.

The function definition does not execute the function body; this gets
executed only when the function is called. [2]

A function definition may be wrapped by one or more *decorator*
expressions. Decorator expressions are evaluated when the function is
defined, in the scope that contains the function definition.  The
result must be a callable, which is invoked with the function object
as the only argument. The returned value is bound to the function name
instead of the function object.  Multiple decorators are applied in
nested fashion. For example, the following code

   @f1(arg)
   @f2
   def func(): pass

is roughly equivalent to

   def func(): pass
   func = f1(arg)(f2(func))

except that the original function is not temporarily bound to the name
"func".

When one or more *parameters* have the form *parameter* "="
*expression*, the function is said to have “default parameter values.”
For a parameter with a default value, the corresponding *argument* may
be omitted from a call, in which case the parameter’s default value is
substituted.  If a parameter has a default value, all following
parameters up until the “"*"” must also have a default value — this is
a syntactic restriction that is not expressed by the grammar.

**Default parameter values are evaluated from left to right when the
function definition is executed.** This means that the expression is
evaluated once, when the function is defined, and that the same “pre-
computed” value is used for each call.  This is especially important
to understand when a default parameter is a mutable object, such as a
list or a dictionary: if the function modifies the object (e.g. by
appending an item to a list), the default value is in effect modified.
This is generally not what was intended.  A way around this is to use
"None" as the default, and explicitly test for it in the body of the
function, e.g.:

   def whats_on_the_telly(penguin=None):
       if penguin is None:
           penguin = []
       penguin.append("property of the zoo")
       return penguin

Function call semantics are described in more detail in section Calls.
A function call always assigns values to all parameters mentioned in
the parameter list, either from positional arguments, from keyword
arguments, or from default values.  If the form “"*identifier"” is
present, it is initialized to a tuple receiving any excess positional
parameters, defaulting to the empty tuple. If the form
“"**identifier"” is present, it is initialized to a new ordered
mapping receiving any excess keyword arguments, defaulting to a new
empty mapping of the same type.  Parameters after “"*"” or
“"*identifier"” are keyword-only parameters and may only be passed by
keyword arguments.  Parameters before “"/"” are positional-only
parameters and may only be passed by positional arguments.

Changed in version 3.8: The "/" function parameter syntax may be used
to indicate positional-only parameters. See **PEP 570** for details.

Parameters may have an *annotation* of the form “": expression"”
following the parameter name.  Any parameter may have an annotation,
even those of the form "*identifier" or "**identifier".  Functions may
have “return” annotation of the form “"-> expression"” after the
parameter list.  These annotations can be any valid Python expression.
The presence of annotations does not change the semantics of a
function.  The annotation values are available as values of a
dictionary keyed by the parameters’ names in the "__annotations__"
attribute of the function object.  If the "annotations" import from
"__future__" is used, annotations are preserved as strings at runtime
which enables postponed evaluation.  Otherwise, they are evaluated
when the function definition is executed.  In this case annotations
may be evaluated in a different order than they appear in the source
code.

It is also possible to create anonymous functions (functions not bound
to a name), for immediate use in expressions.  This uses lambda
expressions, described in section Lambdas.  Note that the lambda
expression is merely a shorthand for a simplified function definition;
a function defined in a “"def"” statement can be passed around or
assigned to another name just like a function defined by a lambda
expression.  The “"def"” form is actually more powerful since it
allows the execution of multiple statements and annotations.

**Programmer’s note:** Functions are first-class objects.  A “"def"”
statement executed inside a function definition defines a local
function that can be returned or passed around.  Free variables used
in the nested function can access the local variables of the function
containing the def.  See section Naming and binding for details.

See also:

  **PEP 3107** - Function Annotations
     The original specification for function annotations.

  **PEP 484** - Type Hints
     Definition of a standard meaning for annotations: type hints.

  **PEP 526** - Syntax for Variable Annotations
     Ability to type hint variable declarations, including class
     variables and instance variables

  **PEP 563** - Postponed Evaluation of Annotations
     Support for forward references within annotations by preserving
     annotations in a string form at runtime instead of eager
     evaluation.


Class definitions
=================

A class definition defines a class object (see section The standard
type hierarchy):

   classdef    ::= [decorators] "class" classname [inheritance] ":" suite
   inheritance ::= "(" [argument_list] ")"
   classname   ::= identifier

A class definition is an executable statement.  The inheritance list
usually gives a list of base classes (see Metaclasses for more
advanced uses), so each item in the list should evaluate to a class
object which allows subclassing.  Classes without an inheritance list
inherit, by default, from the base class "object"; hence,

   class Foo:
       pass

is equivalent to

   class Foo(object):
       pass

The class’s suite is then executed in a new execution frame (see
Naming and binding), using a newly created local namespace and the
original global namespace. (Usually, the suite contains mostly
function definitions.)  When the class’s suite finishes execution, its
execution frame is discarded but its local namespace is saved. [3] A
class object is then created using the inheritance list for the base
classes and the saved local namespace for the attribute dictionary.
The class name is bound to this class object in the original local
namespace.

The order in which attributes are defined in the class body is
preserved in the new class’s "__dict__".  Note that this is reliable
only right after the class is created and only for classes that were
defined using the definition syntax.

Class creation can be customized heavily using metaclasses.

Classes can also be decorated: just like when decorating functions,

   @f1(arg)
   @f2
   class Foo: pass

is roughly equivalent to

   class Foo: pass
   Foo = f1(arg)(f2(Foo))

The evaluation rules for the decorator expressions are the same as for
function decorators.  The result is then bound to the class name.

**Programmer’s note:** Variables defined in the class definition are
class attributes; they are shared by instances.  Instance attributes
can be set in a method with "self.name = value".  Both class and
instance attributes are accessible through the notation “"self.name"”,
and an instance attribute hides a class attribute with the same name
when accessed in this way.  Class attributes can be used as defaults
for instance attributes, but using mutable values there can lead to
unexpected results.  Descriptors can be used to create instance
variables with different implementation details.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     The proposal that changed the declaration of metaclasses to the
     current syntax, and the semantics for how classes with
     metaclasses are constructed.

  **PEP 3129** - Class Decorators
     The proposal that added class decorators.  Function and method
     decorators were introduced in **PEP 318**.


Coroutines
==========

New in version 3.5.


Coroutine function definition
-----------------------------

   async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")"
                     ["->" expression] ":" suite

Execution of Python coroutines can be suspended and resumed at many
points (see *coroutine*).  Inside the body of a coroutine function,
"await" and "async" identifiers become reserved keywords; "await"
expressions, "async for" and "async with" can only be used in
coroutine function bodies.

Functions defined with "async def" syntax are always coroutine
functions, even if they do not contain "await" or "async" keywords.

It is a "SyntaxError" to use a "yield from" expression inside the body
of a coroutine function.

An example of a coroutine function:

   async def func(param1, param2):
       do_stuff()
       await some_coroutine()


The "async for" statement
-------------------------

   async_for_stmt ::= "async" for_stmt

An *asynchronous iterable* is able to call asynchronous code in its
*iter* implementation, and *asynchronous iterator* can call
asynchronous code in its *next* method.

The "async for" statement allows convenient iteration over
asynchronous iterators.

The following code:

   async for TARGET in ITER:
       SUITE
   else:
       SUITE2

Is semantically equivalent to:

   iter = (ITER)
   iter = type(iter).__aiter__(iter)
   running = True

   while running:
       try:
           TARGET = await type(iter).__anext__(iter)
       except StopAsyncIteration:
           running = False
       else:
           SUITE
   else:
       SUITE2

See also "__aiter__()" and "__anext__()" for details.

It is a "SyntaxError" to use an "async for" statement outside the body
of a coroutine function.


The "async with" statement
--------------------------

   async_with_stmt ::= "async" with_stmt

An *asynchronous context manager* is a *context manager* that is able
to suspend execution in its *enter* and *exit* methods.

The following code:

   async with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   aexit = type(manager).__aexit__
   aenter = type(manager).__aenter__
   value = await aenter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not await aexit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           await aexit(manager, None, None, None)

See also "__aenter__()" and "__aexit__()" for details.

It is a "SyntaxError" to use an "async with" statement outside the
body of a coroutine function.

See also:

  **PEP 492** - Coroutines with async and await syntax
     The proposal that made coroutines a proper standalone concept in
     Python, and added supporting syntax.

-[ Footnotes ]-

[1] The exception is propagated to the invocation stack unless there
    is a "finally" clause which happens to raise another exception.
    That new exception causes the old one to be lost.

[2] A string literal appearing as the first statement in the function
    body is transformed into the function’s "__doc__" attribute and
    therefore the function’s *docstring*.

[3] A string literal appearing as the first statement in the class
    body is transformed into the namespace’s "__doc__" item and
    therefore the class’s *docstring*.
u�With Statement Context Managers
*******************************

A *context manager* is an object that defines the runtime context to
be established when executing a "with" statement. The context manager
handles the entry into, and the exit from, the desired runtime context
for the execution of the block of code.  Context managers are normally
invoked using the "with" statement (described in section The with
statement), but can also be used by directly invoking their methods.

Typical uses of context managers include saving and restoring various
kinds of global state, locking and unlocking resources, closing opened
files, etc.

For more information on context managers, see Context Manager Types.

object.__enter__(self)

   Enter the runtime context related to this object. The "with"
   statement will bind this method’s return value to the target(s)
   specified in the "as" clause of the statement, if any.

object.__exit__(self, exc_type, exc_value, traceback)

   Exit the runtime context related to this object. The parameters
   describe the exception that caused the context to be exited. If the
   context was exited without an exception, all three arguments will
   be "None".

   If an exception is supplied, and the method wishes to suppress the
   exception (i.e., prevent it from being propagated), it should
   return a true value. Otherwise, the exception will be processed
   normally upon exit from this method.

   Note that "__exit__()" methods should not reraise the passed-in
   exception; this is the caller’s responsibility.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.
a�The "continue" statement
************************

   continue_stmt ::= "continue"

"continue" may only occur syntactically nested in a "for" or "while"
loop, but not nested in a function or class definition within that
loop.  It continues with the next cycle of the nearest enclosing loop.

When "continue" passes control out of a "try" statement with a
"finally" clause, that "finally" clause is executed before really
starting the next loop cycle.
u�Arithmetic conversions
**********************

When a description of an arithmetic operator below uses the phrase
“the numeric arguments are converted to a common type”, this means
that the operator implementation for built-in types works as follows:

* If either argument is a complex number, the other is converted to
  complex;

* otherwise, if either argument is a floating point number, the other
  is converted to floating point;

* otherwise, both must be integers and no conversion is necessary.

Some additional rules apply for certain operators (e.g., a string as a
left argument to the ‘%’ operator).  Extensions must define their own
conversion behavior.
uS5Basic customization
*******************

object.__new__(cls[, ...])

   Called to create a new instance of class *cls*.  "__new__()" is a
   static method (special-cased so you need not declare it as such)
   that takes the class of which an instance was requested as its
   first argument.  The remaining arguments are those passed to the
   object constructor expression (the call to the class).  The return
   value of "__new__()" should be the new object instance (usually an
   instance of *cls*).

   Typical implementations create a new instance of the class by
   invoking the superclass’s "__new__()" method using
   "super().__new__(cls[, ...])" with appropriate arguments and then
   modifying the newly-created instance as necessary before returning
   it.

   If "__new__()" is invoked during object construction and it returns
   an instance of *cls*, then the new instance’s "__init__()" method
   will be invoked like "__init__(self[, ...])", where *self* is the
   new instance and the remaining arguments are the same as were
   passed to the object constructor.

   If "__new__()" does not return an instance of *cls*, then the new
   instance’s "__init__()" method will not be invoked.

   "__new__()" is intended mainly to allow subclasses of immutable
   types (like int, str, or tuple) to customize instance creation.  It
   is also commonly overridden in custom metaclasses in order to
   customize class creation.

object.__init__(self[, ...])

   Called after the instance has been created (by "__new__()"), but
   before it is returned to the caller.  The arguments are those
   passed to the class constructor expression.  If a base class has an
   "__init__()" method, the derived class’s "__init__()" method, if
   any, must explicitly call it to ensure proper initialization of the
   base class part of the instance; for example:
   "super().__init__([args...])".

   Because "__new__()" and "__init__()" work together in constructing
   objects ("__new__()" to create it, and "__init__()" to customize
   it), no non-"None" value may be returned by "__init__()"; doing so
   will cause a "TypeError" to be raised at runtime.

object.__del__(self)

   Called when the instance is about to be destroyed.  This is also
   called a finalizer or (improperly) a destructor.  If a base class
   has a "__del__()" method, the derived class’s "__del__()" method,
   if any, must explicitly call it to ensure proper deletion of the
   base class part of the instance.

   It is possible (though not recommended!) for the "__del__()" method
   to postpone destruction of the instance by creating a new reference
   to it.  This is called object *resurrection*.  It is
   implementation-dependent whether "__del__()" is called a second
   time when a resurrected object is about to be destroyed; the
   current *CPython* implementation only calls it once.

   It is not guaranteed that "__del__()" methods are called for
   objects that still exist when the interpreter exits.

   Note:

     "del x" doesn’t directly call "x.__del__()" — the former
     decrements the reference count for "x" by one, and the latter is
     only called when "x"’s reference count reaches zero.

   **CPython implementation detail:** It is possible for a reference
   cycle to prevent the reference count of an object from going to
   zero.  In this case, the cycle will be later detected and deleted
   by the *cyclic garbage collector*.  A common cause of reference
   cycles is when an exception has been caught in a local variable.
   The frame’s locals then reference the exception, which references
   its own traceback, which references the locals of all frames caught
   in the traceback.

   See also: Documentation for the "gc" module.

   Warning:

     Due to the precarious circumstances under which "__del__()"
     methods are invoked, exceptions that occur during their execution
     are ignored, and a warning is printed to "sys.stderr" instead.
     In particular:

     * "__del__()" can be invoked when arbitrary code is being
       executed, including from any arbitrary thread.  If "__del__()"
       needs to take a lock or invoke any other blocking resource, it
       may deadlock as the resource may already be taken by the code
       that gets interrupted to execute "__del__()".

     * "__del__()" can be executed during interpreter shutdown.  As a
       consequence, the global variables it needs to access (including
       other modules) may already have been deleted or set to "None".
       Python guarantees that globals whose name begins with a single
       underscore are deleted from their module before other globals
       are deleted; if no other references to such globals exist, this
       may help in assuring that imported modules are still available
       at the time when the "__del__()" method is called.

object.__repr__(self)

   Called by the "repr()" built-in function to compute the “official”
   string representation of an object.  If at all possible, this
   should look like a valid Python expression that could be used to
   recreate an object with the same value (given an appropriate
   environment).  If this is not possible, a string of the form
   "<...some useful description...>" should be returned. The return
   value must be a string object. If a class defines "__repr__()" but
   not "__str__()", then "__repr__()" is also used when an “informal”
   string representation of instances of that class is required.

   This is typically used for debugging, so it is important that the
   representation is information-rich and unambiguous.

object.__str__(self)

   Called by "str(object)" and the built-in functions "format()" and
   "print()" to compute the “informal” or nicely printable string
   representation of an object.  The return value must be a string
   object.

   This method differs from "object.__repr__()" in that there is no
   expectation that "__str__()" return a valid Python expression: a
   more convenient or concise representation can be used.

   The default implementation defined by the built-in type "object"
   calls "object.__repr__()".

object.__bytes__(self)

   Called by bytes to compute a byte-string representation of an
   object. This should return a "bytes" object.

object.__format__(self, format_spec)

   Called by the "format()" built-in function, and by extension,
   evaluation of formatted string literals and the "str.format()"
   method, to produce a “formatted” string representation of an
   object. The *format_spec* argument is a string that contains a
   description of the formatting options desired. The interpretation
   of the *format_spec* argument is up to the type implementing
   "__format__()", however most classes will either delegate
   formatting to one of the built-in types, or use a similar
   formatting option syntax.

   See Format Specification Mini-Language for a description of the
   standard formatting syntax.

   The return value must be a string object.

   Changed in version 3.4: The __format__ method of "object" itself
   raises a "TypeError" if passed any non-empty string.

   Changed in version 3.7: "object.__format__(x, '')" is now
   equivalent to "str(x)" rather than "format(str(self), '')".

object.__lt__(self, other)
object.__le__(self, other)
object.__eq__(self, other)
object.__ne__(self, other)
object.__gt__(self, other)
object.__ge__(self, other)

   These are the so-called “rich comparison” methods. The
   correspondence between operator symbols and method names is as
   follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",
   "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls
   "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".

   A rich comparison method may return the singleton "NotImplemented"
   if it does not implement the operation for a given pair of
   arguments. By convention, "False" and "True" are returned for a
   successful comparison. However, these methods can return any value,
   so if the comparison operator is used in a Boolean context (e.g.,
   in the condition of an "if" statement), Python will call "bool()"
   on the value to determine if the result is true or false.

   By default, "object" implements "__eq__()" by using "is", returning
   "NotImplemented" in the case of a false comparison: "True if x is y
   else NotImplemented". For "__ne__()", by default it delegates to
   "__eq__()" and inverts the result unless it is "NotImplemented".
   There are no other implied relationships among the comparison
   operators or default implementations; for example, the truth of
   "(x<y or x==y)" does not imply "x<=y". To automatically generate
   ordering operations from a single root operation, see
   "functools.total_ordering()".

   See the paragraph on "__hash__()" for some important notes on
   creating *hashable* objects which support custom comparison
   operations and are usable as dictionary keys.

   There are no swapped-argument versions of these methods (to be used
   when the left argument does not support the operation but the right
   argument does); rather, "__lt__()" and "__gt__()" are each other’s
   reflection, "__le__()" and "__ge__()" are each other’s reflection,
   and "__eq__()" and "__ne__()" are their own reflection. If the
   operands are of different types, and right operand’s type is a
   direct or indirect subclass of the left operand’s type, the
   reflected method of the right operand has priority, otherwise the
   left operand’s method has priority.  Virtual subclassing is not
   considered.

object.__hash__(self)

   Called by built-in function "hash()" and for operations on members
   of hashed collections including "set", "frozenset", and "dict".
   "__hash__()" should return an integer. The only required property
   is that objects which compare equal have the same hash value; it is
   advised to mix together the hash values of the components of the
   object that also play a part in comparison of objects by packing
   them into a tuple and hashing the tuple. Example:

      def __hash__(self):
          return hash((self.name, self.nick, self.color))

   Note:

     "hash()" truncates the value returned from an object’s custom
     "__hash__()" method to the size of a "Py_ssize_t".  This is
     typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds.
     If an object’s   "__hash__()" must interoperate on builds of
     different bit sizes, be sure to check the width on all supported
     builds.  An easy way to do this is with "python -c "import sys;
     print(sys.hash_info.width)"".

   If a class does not define an "__eq__()" method it should not
   define a "__hash__()" operation either; if it defines "__eq__()"
   but not "__hash__()", its instances will not be usable as items in
   hashable collections.  If a class defines mutable objects and
   implements an "__eq__()" method, it should not implement
   "__hash__()", since the implementation of hashable collections
   requires that a key’s hash value is immutable (if the object’s hash
   value changes, it will be in the wrong hash bucket).

   User-defined classes have "__eq__()" and "__hash__()" methods by
   default; with them, all objects compare unequal (except with
   themselves) and "x.__hash__()" returns an appropriate value such
   that "x == y" implies both that "x is y" and "hash(x) == hash(y)".

   A class that overrides "__eq__()" and does not define "__hash__()"
   will have its "__hash__()" implicitly set to "None".  When the
   "__hash__()" method of a class is "None", instances of the class
   will raise an appropriate "TypeError" when a program attempts to
   retrieve their hash value, and will also be correctly identified as
   unhashable when checking "isinstance(obj,
   collections.abc.Hashable)".

   If a class that overrides "__eq__()" needs to retain the
   implementation of "__hash__()" from a parent class, the interpreter
   must be told this explicitly by setting "__hash__ =
   <ParentClass>.__hash__".

   If a class that does not override "__eq__()" wishes to suppress
   hash support, it should include "__hash__ = None" in the class
   definition. A class which defines its own "__hash__()" that
   explicitly raises a "TypeError" would be incorrectly identified as
   hashable by an "isinstance(obj, collections.abc.Hashable)" call.

   Note:

     By default, the "__hash__()" values of str and bytes objects are
     “salted” with an unpredictable random value.  Although they
     remain constant within an individual Python process, they are not
     predictable between repeated invocations of Python.This is
     intended to provide protection against a denial-of-service caused
     by carefully-chosen inputs that exploit the worst case
     performance of a dict insertion, O(n^2) complexity.  See
     http://www.ocert.org/advisories/ocert-2011-003.html for
     details.Changing hash values affects the iteration order of sets.
     Python has never made guarantees about this ordering (and it
     typically varies between 32-bit and 64-bit builds).See also
     "PYTHONHASHSEED".

   Changed in version 3.3: Hash randomization is enabled by default.

object.__bool__(self)

   Called to implement truth value testing and the built-in operation
   "bool()"; should return "False" or "True".  When this method is not
   defined, "__len__()" is called, if it is defined, and the object is
   considered true if its result is nonzero.  If a class defines
   neither "__len__()" nor "__bool__()", all its instances are
   considered true.
u�I"pdb" — The Python Debugger
***************************

**Source code:** Lib/pdb.py

======================================================================

The module "pdb" defines an interactive source code debugger for
Python programs.  It supports setting (conditional) breakpoints and
single stepping at the source line level, inspection of stack frames,
source code listing, and evaluation of arbitrary Python code in the
context of any stack frame.  It also supports post-mortem debugging
and can be called under program control.

The debugger is extensible – it is actually defined as the class
"Pdb". This is currently undocumented but easily understood by reading
the source.  The extension interface uses the modules "bdb" and "cmd".

The debugger’s prompt is "(Pdb)". Typical usage to run a program under
control of the debugger is:

   >>> import pdb
   >>> import mymodule
   >>> pdb.run('mymodule.test()')
   > <string>(0)?()
   (Pdb) continue
   > <string>(1)?()
   (Pdb) continue
   NameError: 'spam'
   > <string>(1)?()
   (Pdb)

Changed in version 3.3: Tab-completion via the "readline" module is
available for commands and command arguments, e.g. the current global
and local names are offered as arguments of the "p" command.

"pdb.py" can also be invoked as a script to debug other scripts.  For
example:

   python3 -m pdb myscript.py

When invoked as a script, pdb will automatically enter post-mortem
debugging if the program being debugged exits abnormally.  After post-
mortem debugging (or after normal exit of the program), pdb will
restart the program.  Automatic restarting preserves pdb’s state (such
as breakpoints) and in most cases is more useful than quitting the
debugger upon program’s exit.

New in version 3.2: "pdb.py" now accepts a "-c" option that executes
commands as if given in a ".pdbrc" file, see Debugger Commands.

New in version 3.7: "pdb.py" now accepts a "-m" option that execute
modules similar to the way "python3 -m" does. As with a script, the
debugger will pause execution just before the first line of the
module.

The typical usage to break into the debugger from a running program is
to insert

   import pdb; pdb.set_trace()

at the location you want to break into the debugger.  You can then
step through the code following this statement, and continue running
without the debugger using the "continue" command.

New in version 3.7: The built-in "breakpoint()", when called with
defaults, can be used instead of "import pdb; pdb.set_trace()".

The typical usage to inspect a crashed program is:

   >>> import pdb
   >>> import mymodule
   >>> mymodule.test()
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "./mymodule.py", line 4, in test
       test2()
     File "./mymodule.py", line 3, in test2
       print(spam)
   NameError: spam
   >>> pdb.pm()
   > ./mymodule.py(3)test2()
   -> print(spam)
   (Pdb)

The module defines the following functions; each enters the debugger
in a slightly different way:

pdb.run(statement, globals=None, locals=None)

   Execute the *statement* (given as a string or a code object) under
   debugger control.  The debugger prompt appears before any code is
   executed; you can set breakpoints and type "continue", or you can
   step through the statement using "step" or "next" (all these
   commands are explained below).  The optional *globals* and *locals*
   arguments specify the environment in which the code is executed; by
   default the dictionary of the module "__main__" is used.  (See the
   explanation of the built-in "exec()" or "eval()" functions.)

pdb.runeval(expression, globals=None, locals=None)

   Evaluate the *expression* (given as a string or a code object)
   under debugger control.  When "runeval()" returns, it returns the
   value of the expression.  Otherwise this function is similar to
   "run()".

pdb.runcall(function, *args, **kwds)

   Call the *function* (a function or method object, not a string)
   with the given arguments.  When "runcall()" returns, it returns
   whatever the function call returned.  The debugger prompt appears
   as soon as the function is entered.

pdb.set_trace(*, header=None)

   Enter the debugger at the calling stack frame.  This is useful to
   hard-code a breakpoint at a given point in a program, even if the
   code is not otherwise being debugged (e.g. when an assertion
   fails).  If given, *header* is printed to the console just before
   debugging begins.

   Changed in version 3.7: The keyword-only argument *header*.

pdb.post_mortem(traceback=None)

   Enter post-mortem debugging of the given *traceback* object.  If no
   *traceback* is given, it uses the one of the exception that is
   currently being handled (an exception must be being handled if the
   default is to be used).

pdb.pm()

   Enter post-mortem debugging of the traceback found in
   "sys.last_traceback".

The "run*" functions and "set_trace()" are aliases for instantiating
the "Pdb" class and calling the method of the same name.  If you want
to access further features, you have to do this yourself:

class pdb.Pdb(completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False, readrc=True)

   "Pdb" is the debugger class.

   The *completekey*, *stdin* and *stdout* arguments are passed to the
   underlying "cmd.Cmd" class; see the description there.

   The *skip* argument, if given, must be an iterable of glob-style
   module name patterns.  The debugger will not step into frames that
   originate in a module that matches one of these patterns. [1]

   By default, Pdb sets a handler for the SIGINT signal (which is sent
   when the user presses "Ctrl-C" on the console) when you give a
   "continue" command. This allows you to break into the debugger
   again by pressing "Ctrl-C".  If you want Pdb not to touch the
   SIGINT handler, set *nosigint* to true.

   The *readrc* argument defaults to true and controls whether Pdb
   will load .pdbrc files from the filesystem.

   Example call to enable tracing with *skip*:

      import pdb; pdb.Pdb(skip=['django.*']).set_trace()

   Raises an auditing event "pdb.Pdb" with no arguments.

   New in version 3.1: The *skip* argument.

   New in version 3.2: The *nosigint* argument.  Previously, a SIGINT
   handler was never set by Pdb.

   Changed in version 3.6: The *readrc* argument.

   run(statement, globals=None, locals=None)
   runeval(expression, globals=None, locals=None)
   runcall(function, *args, **kwds)
   set_trace()

      See the documentation for the functions explained above.


Debugger Commands
=================

The commands recognized by the debugger are listed below.  Most
commands can be abbreviated to one or two letters as indicated; e.g.
"h(elp)" means that either "h" or "help" can be used to enter the help
command (but not "he" or "hel", nor "H" or "Help" or "HELP").
Arguments to commands must be separated by whitespace (spaces or
tabs).  Optional arguments are enclosed in square brackets ("[]") in
the command syntax; the square brackets must not be typed.
Alternatives in the command syntax are separated by a vertical bar
("|").

Entering a blank line repeats the last command entered.  Exception: if
the last command was a "list" command, the next 11 lines are listed.

Commands that the debugger doesn’t recognize are assumed to be Python
statements and are executed in the context of the program being
debugged.  Python statements can also be prefixed with an exclamation
point ("!").  This is a powerful way to inspect the program being
debugged; it is even possible to change a variable or call a function.
When an exception occurs in such a statement, the exception name is
printed but the debugger’s state is not changed.

The debugger supports aliases.  Aliases can have parameters which
allows one a certain level of adaptability to the context under
examination.

Multiple commands may be entered on a single line, separated by ";;".
(A single ";" is not used as it is the separator for multiple commands
in a line that is passed to the Python parser.)  No intelligence is
applied to separating the commands; the input is split at the first
";;" pair, even if it is in the middle of a quoted string.

If a file ".pdbrc" exists in the user’s home directory or in the
current directory, it is read in and executed as if it had been typed
at the debugger prompt.  This is particularly useful for aliases.  If
both files exist, the one in the home directory is read first and
aliases defined there can be overridden by the local file.

Changed in version 3.2: ".pdbrc" can now contain commands that
continue debugging, such as "continue" or "next".  Previously, these
commands had no effect.

h(elp) [command]

   Without argument, print the list of available commands.  With a
   *command* as argument, print help about that command.  "help pdb"
   displays the full documentation (the docstring of the "pdb"
   module).  Since the *command* argument must be an identifier, "help
   exec" must be entered to get help on the "!" command.

w(here)

   Print a stack trace, with the most recent frame at the bottom.  An
   arrow indicates the current frame, which determines the context of
   most commands.

d(own) [count]

   Move the current frame *count* (default one) levels down in the
   stack trace (to a newer frame).

u(p) [count]

   Move the current frame *count* (default one) levels up in the stack
   trace (to an older frame).

b(reak) [([filename:]lineno | function) [, condition]]

   With a *lineno* argument, set a break there in the current file.
   With a *function* argument, set a break at the first executable
   statement within that function.  The line number may be prefixed
   with a filename and a colon, to specify a breakpoint in another
   file (probably one that hasn’t been loaded yet).  The file is
   searched on "sys.path".  Note that each breakpoint is assigned a
   number to which all the other breakpoint commands refer.

   If a second argument is present, it is an expression which must
   evaluate to true before the breakpoint is honored.

   Without argument, list all breaks, including for each breakpoint,
   the number of times that breakpoint has been hit, the current
   ignore count, and the associated condition if any.

tbreak [([filename:]lineno | function) [, condition]]

   Temporary breakpoint, which is removed automatically when it is
   first hit. The arguments are the same as for "break".

cl(ear) [filename:lineno | bpnumber [bpnumber ...]]

   With a *filename:lineno* argument, clear all the breakpoints at
   this line. With a space separated list of breakpoint numbers, clear
   those breakpoints. Without argument, clear all breaks (but first
   ask confirmation).

disable [bpnumber [bpnumber ...]]

   Disable the breakpoints given as a space separated list of
   breakpoint numbers.  Disabling a breakpoint means it cannot cause
   the program to stop execution, but unlike clearing a breakpoint, it
   remains in the list of breakpoints and can be (re-)enabled.

enable [bpnumber [bpnumber ...]]

   Enable the breakpoints specified.

ignore bpnumber [count]

   Set the ignore count for the given breakpoint number.  If count is
   omitted, the ignore count is set to 0.  A breakpoint becomes active
   when the ignore count is zero.  When non-zero, the count is
   decremented each time the breakpoint is reached and the breakpoint
   is not disabled and any associated condition evaluates to true.

condition bpnumber [condition]

   Set a new *condition* for the breakpoint, an expression which must
   evaluate to true before the breakpoint is honored.  If *condition*
   is absent, any existing condition is removed; i.e., the breakpoint
   is made unconditional.

commands [bpnumber]

   Specify a list of commands for breakpoint number *bpnumber*.  The
   commands themselves appear on the following lines.  Type a line
   containing just "end" to terminate the commands. An example:

      (Pdb) commands 1
      (com) p some_variable
      (com) end
      (Pdb)

   To remove all commands from a breakpoint, type "commands" and
   follow it immediately with "end"; that is, give no commands.

   With no *bpnumber* argument, "commands" refers to the last
   breakpoint set.

   You can use breakpoint commands to start your program up again.
   Simply use the "continue" command, or "step", or any other command
   that resumes execution.

   Specifying any command resuming execution (currently "continue",
   "step", "next", "return", "jump", "quit" and their abbreviations)
   terminates the command list (as if that command was immediately
   followed by end). This is because any time you resume execution
   (even with a simple next or step), you may encounter another
   breakpoint—which could have its own command list, leading to
   ambiguities about which list to execute.

   If you use the ‘silent’ command in the command list, the usual
   message about stopping at a breakpoint is not printed.  This may be
   desirable for breakpoints that are to print a specific message and
   then continue.  If none of the other commands print anything, you
   see no sign that the breakpoint was reached.

s(tep)

   Execute the current line, stop at the first possible occasion
   (either in a function that is called or on the next line in the
   current function).

n(ext)

   Continue execution until the next line in the current function is
   reached or it returns.  (The difference between "next" and "step"
   is that "step" stops inside a called function, while "next"
   executes called functions at (nearly) full speed, only stopping at
   the next line in the current function.)

unt(il) [lineno]

   Without argument, continue execution until the line with a number
   greater than the current one is reached.

   With a line number, continue execution until a line with a number
   greater or equal to that is reached.  In both cases, also stop when
   the current frame returns.

   Changed in version 3.2: Allow giving an explicit line number.

r(eturn)

   Continue execution until the current function returns.

c(ont(inue))

   Continue execution, only stop when a breakpoint is encountered.

j(ump) lineno

   Set the next line that will be executed.  Only available in the
   bottom-most frame.  This lets you jump back and execute code again,
   or jump forward to skip code that you don’t want to run.

   It should be noted that not all jumps are allowed – for instance it
   is not possible to jump into the middle of a "for" loop or out of a
   "finally" clause.

l(ist) [first[, last]]

   List source code for the current file.  Without arguments, list 11
   lines around the current line or continue the previous listing.
   With "." as argument, list 11 lines around the current line.  With
   one argument, list 11 lines around at that line.  With two
   arguments, list the given range; if the second argument is less
   than the first, it is interpreted as a count.

   The current line in the current frame is indicated by "->".  If an
   exception is being debugged, the line where the exception was
   originally raised or propagated is indicated by ">>", if it differs
   from the current line.

   New in version 3.2: The ">>" marker.

ll | longlist

   List all source code for the current function or frame.
   Interesting lines are marked as for "list".

   New in version 3.2.

a(rgs)

   Print the argument list of the current function.

p expression

   Evaluate the *expression* in the current context and print its
   value.

   Note:

     "print()" can also be used, but is not a debugger command — this
     executes the Python "print()" function.

pp expression

   Like the "p" command, except the value of the expression is pretty-
   printed using the "pprint" module.

whatis expression

   Print the type of the *expression*.

source expression

   Try to get source code for the given object and display it.

   New in version 3.2.

display [expression]

   Display the value of the expression if it changed, each time
   execution stops in the current frame.

   Without expression, list all display expressions for the current
   frame.

   New in version 3.2.

undisplay [expression]

   Do not display the expression any more in the current frame.
   Without expression, clear all display expressions for the current
   frame.

   New in version 3.2.

interact

   Start an interactive interpreter (using the "code" module) whose
   global namespace contains all the (global and local) names found in
   the current scope.

   New in version 3.2.

alias [name [command]]

   Create an alias called *name* that executes *command*.  The command
   must *not* be enclosed in quotes.  Replaceable parameters can be
   indicated by "%1", "%2", and so on, while "%*" is replaced by all
   the parameters. If no command is given, the current alias for
   *name* is shown. If no arguments are given, all aliases are listed.

   Aliases may be nested and can contain anything that can be legally
   typed at the pdb prompt.  Note that internal pdb commands *can* be
   overridden by aliases.  Such a command is then hidden until the
   alias is removed.  Aliasing is recursively applied to the first
   word of the command line; all other words in the line are left
   alone.

   As an example, here are two useful aliases (especially when placed
   in the ".pdbrc" file):

      # Print instance variables (usage "pi classInst")
      alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])
      # Print instance variables in self
      alias ps pi self

unalias name

   Delete the specified alias.

! statement

   Execute the (one-line) *statement* in the context of the current
   stack frame. The exclamation point can be omitted unless the first
   word of the statement resembles a debugger command.  To set a
   global variable, you can prefix the assignment command with a
   "global" statement on the same line, e.g.:

      (Pdb) global list_options; list_options = ['-l']
      (Pdb)

run [args ...]
restart [args ...]

   Restart the debugged Python program.  If an argument is supplied,
   it is split with "shlex" and the result is used as the new
   "sys.argv". History, breakpoints, actions and debugger options are
   preserved. "restart" is an alias for "run".

q(uit)

   Quit from the debugger.  The program being executed is aborted.

debug code

   Enter a recursive debugger that steps through the code argument
   (which is an arbitrary expression or statement to be executed in
   the current environment).

retval

   Print the return value for the last return of a function.

-[ Footnotes ]-

[1] Whether a frame is considered to originate in a certain module is
    determined by the "__name__" in the frame globals.
a�The "del" statement
*******************

   del_stmt ::= "del" target_list

Deletion is recursively defined very similar to the way assignment is
defined. Rather than spelling it out in full details, here are some
hints.

Deletion of a target list recursively deletes each target, from left
to right.

Deletion of a name removes the binding of that name from the local or
global namespace, depending on whether the name occurs in a "global"
statement in the same code block.  If the name is unbound, a
"NameError" exception will be raised.

Deletion of attribute references, subscriptions and slicings is passed
to the primary object involved; deletion of a slicing is in general
equivalent to assignment of an empty slice of the right type (but even
this is determined by the sliced object).

Changed in version 3.2: Previously it was illegal to delete a name
from the local namespace if it occurs as a free variable in a nested
block.
uDictionary displays
*******************

A dictionary display is a possibly empty series of key/datum pairs
enclosed in curly braces:

   dict_display       ::= "{" [key_datum_list | dict_comprehension] "}"
   key_datum_list     ::= key_datum ("," key_datum)* [","]
   key_datum          ::= expression ":" expression | "**" or_expr
   dict_comprehension ::= expression ":" expression comp_for

A dictionary display yields a new dictionary object.

If a comma-separated sequence of key/datum pairs is given, they are
evaluated from left to right to define the entries of the dictionary:
each key object is used as a key into the dictionary to store the
corresponding datum.  This means that you can specify the same key
multiple times in the key/datum list, and the final dictionary’s value
for that key will be the last one given.

A double asterisk "**" denotes *dictionary unpacking*. Its operand
must be a *mapping*.  Each mapping item is added to the new
dictionary.  Later values replace values already set by earlier
key/datum pairs and earlier dictionary unpackings.

New in version 3.5: Unpacking into dictionary displays, originally
proposed by **PEP 448**.

A dict comprehension, in contrast to list and set comprehensions,
needs two expressions separated with a colon followed by the usual
“for” and “if” clauses. When the comprehension is run, the resulting
key and value elements are inserted in the new dictionary in the order
they are produced.

Restrictions on the types of the key values are listed earlier in
section The standard type hierarchy.  (To summarize, the key type
should be *hashable*, which excludes all mutable objects.)  Clashes
between duplicate keys are not detected; the last datum (textually
rightmost in the display) stored for a given key value prevails.

Changed in version 3.8: Prior to Python 3.8, in dict comprehensions,
the evaluation order of key and value was not well-defined.  In
CPython, the value was evaluated before the key.  Starting with 3.8,
the key is evaluated before the value, as proposed by **PEP 572**.
a�Interaction with dynamic features
*********************************

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.
aXThe "if" statement
******************

The "if" statement is used for conditional execution:

   if_stmt ::= "if" assignment_expression ":" suite
               ("elif" assignment_expression ":" suite)*
               ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section Boolean operations
for the definition of true and false); then that suite is executed
(and no other part of the "if" statement is executed or evaluated).
If all expressions are false, the suite of the "else" clause, if
present, is executed.
u�Exceptions
**********

Exceptions are a means of breaking out of the normal flow of control
of a code block in order to handle errors or other exceptional
conditions.  An exception is *raised* at the point where the error is
detected; it may be *handled* by the surrounding code block or by any
code block that directly or indirectly invoked the code block where
the error occurred.

The Python interpreter raises an exception when it detects a run-time
error (such as division by zero).  A Python program can also
explicitly raise an exception with the "raise" statement. Exception
handlers are specified with the "try" … "except" statement.  The
"finally" clause of such a statement can be used to specify cleanup
code which does not handle the exception, but is executed whether an
exception occurred or not in the preceding code.

Python uses the “termination” model of error handling: an exception
handler can find out what happened and continue execution at an outer
level, but it cannot repair the cause of the error and retry the
failing operation (except by re-entering the offending piece of code
from the top).

When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.  In
either case, it prints a stack traceback, except when the exception is
"SystemExit".

Exceptions are identified by class instances.  The "except" clause is
selected depending on the class of the instance: it must reference the
class of the instance or a base class thereof.  The instance can be
received by the handler and can carry additional information about the
exceptional condition.

Note:

  Exception messages are not part of the Python API.  Their contents
  may change from one version of Python to the next without warning
  and should not be relied on by code which will run under multiple
  versions of the interpreter.

See also the description of the "try" statement in section The try
statement and "raise" statement in section The raise statement.

-[ Footnotes ]-

[1] This limitation occurs because the code that is executed by these
    operations is not available at the time the module is compiled.
u$Execution model
***************


Structure of a program
======================

A Python program is constructed from code blocks. A *block* is a piece
of Python program text that is executed as a unit. The following are
blocks: a module, a function body, and a class definition. Each
command typed interactively is a block.  A script file (a file given
as standard input to the interpreter or specified as a command line
argument to the interpreter) is a code block.  A script command (a
command specified on the interpreter command line with the "-c"
option) is a code block.  The string argument passed to the built-in
functions "eval()" and "exec()" is a code block.

A code block is executed in an *execution frame*.  A frame contains
some administrative information (used for debugging) and determines
where and how execution continues after the code block’s execution has
completed.


Naming and binding
==================


Binding of names
----------------

*Names* refer to objects.  Names are introduced by name binding
operations.

The following constructs bind names: formal parameters to functions,
"import" statements, class and function definitions (these bind the
class or function name in the defining block), and targets that are
identifiers if occurring in an assignment, "for" loop header, or after
"as" in a "with" statement or "except" clause. The "import" statement
of the form "from ... import *" binds all names defined in the
imported module, except those beginning with an underscore.  This form
may only be used at the module level.

A target occurring in a "del" statement is also considered bound for
this purpose (though the actual semantics are to unbind the name).

Each assignment or import statement occurs within a block defined by a
class or function definition or at the module level (the top-level
code block).

If a name is bound in a block, it is a local variable of that block,
unless declared as "nonlocal" or "global".  If a name is bound at the
module level, it is a global variable.  (The variables of the module
code block are local and global.)  If a variable is used in a code
block but not defined there, it is a *free variable*.

Each occurrence of a name in the program text refers to the *binding*
of that name established by the following name resolution rules.


Resolution of names
-------------------

A *scope* defines the visibility of a name within a block.  If a local
variable is defined in a block, its scope includes that block.  If the
definition occurs in a function block, the scope extends to any blocks
contained within the defining one, unless a contained block introduces
a different binding for the name.

When a name is used in a code block, it is resolved using the nearest
enclosing scope.  The set of all such scopes visible to a code block
is called the block’s *environment*.

When a name is not found at all, a "NameError" exception is raised. If
the current scope is a function scope, and the name refers to a local
variable that has not yet been bound to a value at the point where the
name is used, an "UnboundLocalError" exception is raised.
"UnboundLocalError" is a subclass of "NameError".

If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block.  This can lead to errors when a name is used within a
block before it is bound.  This rule is subtle.  Python lacks
declarations and allows name binding operations to occur anywhere
within a code block.  The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.

If the "global" statement occurs within a block, all uses of the name
specified in the statement refer to the binding of that name in the
top-level namespace.  Names are resolved in the top-level namespace by
searching the global namespace, i.e. the namespace of the module
containing the code block, and the builtins namespace, the namespace
of the module "builtins".  The global namespace is searched first.  If
the name is not found there, the builtins namespace is searched.  The
"global" statement must precede all uses of the name.

The "global" statement has the same scope as a name binding operation
in the same block.  If the nearest enclosing scope for a free variable
contains a global statement, the free variable is treated as a global.

The "nonlocal" statement causes corresponding names to refer to
previously bound variables in the nearest enclosing function scope.
"SyntaxError" is raised at compile time if the given name does not
exist in any enclosing function scope.

The namespace for a module is automatically created the first time a
module is imported.  The main module for a script is always called
"__main__".

Class definition blocks and arguments to "exec()" and "eval()" are
special in the context of name resolution. A class definition is an
executable statement that may use and define names. These references
follow the normal rules for name resolution with an exception that
unbound local variables are looked up in the global namespace. The
namespace of the class definition becomes the attribute dictionary of
the class. The scope of names defined in a class block is limited to
the class block; it does not extend to the code blocks of methods –
this includes comprehensions and generator expressions since they are
implemented using a function scope.  This means that the following
will fail:

   class A:
       a = 42
       b = list(a + i for i in range(10))


Builtins and restricted execution
---------------------------------

**CPython implementation detail:** Users should not touch
"__builtins__"; it is strictly an implementation detail.  Users
wanting to override values in the builtins namespace should "import"
the "builtins" module and modify its attributes appropriately.

The builtins namespace associated with the execution of a code block
is actually found by looking up the name "__builtins__" in its global
namespace; this should be a dictionary or a module (in the latter case
the module’s dictionary is used).  By default, when in the "__main__"
module, "__builtins__" is the built-in module "builtins"; when in any
other module, "__builtins__" is an alias for the dictionary of the
"builtins" module itself.


Interaction with dynamic features
---------------------------------

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.


Exceptions
==========

Exceptions are a means of breaking out of the normal flow of control
of a code block in order to handle errors or other exceptional
conditions.  An exception is *raised* at the point where the error is
detected; it may be *handled* by the surrounding code block or by any
code block that directly or indirectly invoked the code block where
the error occurred.

The Python interpreter raises an exception when it detects a run-time
error (such as division by zero).  A Python program can also
explicitly raise an exception with the "raise" statement. Exception
handlers are specified with the "try" … "except" statement.  The
"finally" clause of such a statement can be used to specify cleanup
code which does not handle the exception, but is executed whether an
exception occurred or not in the preceding code.

Python uses the “termination” model of error handling: an exception
handler can find out what happened and continue execution at an outer
level, but it cannot repair the cause of the error and retry the
failing operation (except by re-entering the offending piece of code
from the top).

When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.  In
either case, it prints a stack traceback, except when the exception is
"SystemExit".

Exceptions are identified by class instances.  The "except" clause is
selected depending on the class of the instance: it must reference the
class of the instance or a base class thereof.  The instance can be
received by the handler and can carry additional information about the
exceptional condition.

Note:

  Exception messages are not part of the Python API.  Their contents
  may change from one version of Python to the next without warning
  and should not be relied on by code which will run under multiple
  versions of the interpreter.

See also the description of the "try" statement in section The try
statement and "raise" statement in section The raise statement.

-[ Footnotes ]-

[1] This limitation occurs because the code that is executed by these
    operations is not available at the time the module is compiled.
uzExpression lists
****************

   expression_list    ::= expression ("," expression)* [","]
   starred_list       ::= starred_item ("," starred_item)* [","]
   starred_expression ::= expression | (starred_item ",")* [starred_item]
   starred_item       ::= assignment_expression | "*" or_expr

Except when part of a list or set display, an expression list
containing at least one comma yields a tuple.  The length of the tuple
is the number of expressions in the list.  The expressions are
evaluated from left to right.

An asterisk "*" denotes *iterable unpacking*.  Its operand must be an
*iterable*.  The iterable is expanded into a sequence of items, which
are included in the new tuple, list, or set, at the site of the
unpacking.

New in version 3.5: Iterable unpacking in expression lists, originally
proposed by **PEP 448**.

The trailing comma is required only to create a single tuple (a.k.a. a
*singleton*); it is optional in all other cases.  A single expression
without a trailing comma doesn’t create a tuple, but rather yields the
value of that expression. (To create an empty tuple, use an empty pair
of parentheses: "()".)
a�Floating point literals
***********************

Floating point literals are described by the following lexical
definitions:

   floatnumber   ::= pointfloat | exponentfloat
   pointfloat    ::= [digitpart] fraction | digitpart "."
   exponentfloat ::= (digitpart | pointfloat) exponent
   digitpart     ::= digit (["_"] digit)*
   fraction      ::= "." digitpart
   exponent      ::= ("e" | "E") ["+" | "-"] digitpart

Note that the integer and exponent parts are always interpreted using
radix 10. For example, "077e010" is legal, and denotes the same number
as "77e10". The allowed range of floating point literals is
implementation-dependent.  As in integer literals, underscores are
supported for digit grouping.

Some examples of floating point literals:

   3.14    10.    .001    1e100    3.14e-10    0e0    3.14_15_93

Changed in version 3.6: Underscores are now allowed for grouping
purposes in literals.
u�
The "for" statement
*******************

The "for" statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object:

   for_stmt ::= "for" target_list "in" expression_list ":" suite
                ["else" ":" suite]

The expression list is evaluated once; it should yield an iterable
object.  An iterator is created for the result of the
"expression_list".  The suite is then executed once for each item
provided by the iterator, in the order returned by the iterator.  Each
item in turn is assigned to the target list using the standard rules
for assignments (see Assignment statements), and then the suite is
executed.  When the items are exhausted (which is immediately when the
sequence is empty or an iterator raises a "StopIteration" exception),
the suite in the "else" clause, if present, is executed, and the loop
terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and continues
with the next item, or with the "else" clause if there is no next
item.

The for-loop makes assignments to the variables in the target list.
This overwrites all previous assignments to those variables including
those made in the suite of the for-loop:

   for i in range(10):
       print(i)
       i = 5             # this will not affect the for-loop
                         # because i will be overwritten with the next
                         # index in the range

Names in the target list are not deleted when the loop is finished,
but if the sequence is empty, they will not have been assigned to at
all by the loop.  Hint: the built-in function "range()" returns an
iterator of integers suitable to emulate the effect of Pascal’s "for i
:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".

Note:

  There is a subtlety when the sequence is being modified by the loop
  (this can only occur for mutable sequences, e.g. lists).  An
  internal counter is used to keep track of which item is used next,
  and this is incremented on each iteration.  When this counter has
  reached the length of the sequence the loop terminates.  This means
  that if the suite deletes the current (or a previous) item from the
  sequence, the next item will be skipped (since it gets the index of
  the current item which has already been treated).  Likewise, if the
  suite inserts an item in the sequence before the current item, the
  current item will be treated again the next time through the loop.
  This can lead to nasty bugs that can be avoided by making a
  temporary copy using a slice of the whole sequence, e.g.,

     for x in a[:]:
         if x < 0: a.remove(x)
u�`Format String Syntax
********************

The "str.format()" method and the "Formatter" class share the same
syntax for format strings (although in the case of "Formatter",
subclasses can define their own format string syntax).  The syntax is
related to that of formatted string literals, but it is less
sophisticated and, in particular, does not support arbitrary
expressions.

Format strings contain “replacement fields” surrounded by curly braces
"{}". Anything that is not contained in braces is considered literal
text, which is copied unchanged to the output.  If you need to include
a brace character in the literal text, it can be escaped by doubling:
"{{" and "}}".

The grammar for a replacement field is as follows:

      replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"
      field_name        ::= arg_name ("." attribute_name | "[" element_index "]")*
      arg_name          ::= [identifier | digit+]
      attribute_name    ::= identifier
      element_index     ::= digit+ | index_string
      index_string      ::= <any source character except "]"> +
      conversion        ::= "r" | "s" | "a"
      format_spec       ::= <described in the next section>

In less formal terms, the replacement field can start with a
*field_name* that specifies the object whose value is to be formatted
and inserted into the output instead of the replacement field. The
*field_name* is optionally followed by a  *conversion* field, which is
preceded by an exclamation point "'!'", and a *format_spec*, which is
preceded by a colon "':'".  These specify a non-default format for the
replacement value.

See also the Format Specification Mini-Language section.

The *field_name* itself begins with an *arg_name* that is either a
number or a keyword.  If it’s a number, it refers to a positional
argument, and if it’s a keyword, it refers to a named keyword
argument.  If the numerical arg_names in a format string are 0, 1, 2,
… in sequence, they can all be omitted (not just some) and the numbers
0, 1, 2, … will be automatically inserted in that order. Because
*arg_name* is not quote-delimited, it is not possible to specify
arbitrary dictionary keys (e.g., the strings "'10'" or "':-]'") within
a format string. The *arg_name* can be followed by any number of index
or attribute expressions. An expression of the form "'.name'" selects
the named attribute using "getattr()", while an expression of the form
"'[index]'" does an index lookup using "__getitem__()".

Changed in version 3.1: The positional argument specifiers can be
omitted for "str.format()", so "'{} {}'.format(a, b)" is equivalent to
"'{0} {1}'.format(a, b)".

Changed in version 3.4: The positional argument specifiers can be
omitted for "Formatter".

Some simple format string examples:

   "First, thou shalt count to {0}"  # References first positional argument
   "Bring me a {}"                   # Implicitly references the first positional argument
   "From {} to {}"                   # Same as "From {0} to {1}"
   "My quest is {name}"              # References keyword argument 'name'
   "Weight in tons {0.weight}"       # 'weight' attribute of first positional arg
   "Units destroyed: {players[0]}"   # First element of keyword argument 'players'.

The *conversion* field causes a type coercion before formatting.
Normally, the job of formatting a value is done by the "__format__()"
method of the value itself.  However, in some cases it is desirable to
force a type to be formatted as a string, overriding its own
definition of formatting.  By converting the value to a string before
calling "__format__()", the normal formatting logic is bypassed.

Three conversion flags are currently supported: "'!s'" which calls
"str()" on the value, "'!r'" which calls "repr()" and "'!a'" which
calls "ascii()".

Some examples:

   "Harold's a clever {0!s}"        # Calls str() on the argument first
   "Bring out the holy {name!r}"    # Calls repr() on the argument first
   "More {!a}"                      # Calls ascii() on the argument first

The *format_spec* field contains a specification of how the value
should be presented, including such details as field width, alignment,
padding, decimal precision and so on.  Each value type can define its
own “formatting mini-language” or interpretation of the *format_spec*.

Most built-in types support a common formatting mini-language, which
is described in the next section.

A *format_spec* field can also include nested replacement fields
within it. These nested replacement fields may contain a field name,
conversion flag and format specification, but deeper nesting is not
allowed.  The replacement fields within the format_spec are
substituted before the *format_spec* string is interpreted. This
allows the formatting of a value to be dynamically specified.

See the Format examples section for some examples.


Format Specification Mini-Language
==================================

“Format specifications” are used within replacement fields contained
within a format string to define how individual values are presented
(see Format String Syntax and Formatted string literals). They can
also be passed directly to the built-in "format()" function.  Each
formattable type may define how the format specification is to be
interpreted.

Most built-in types implement the following options for format
specifications, although some of the formatting options are only
supported by the numeric types.

A general convention is that an empty format specification produces
the same result as if you had called "str()" on the value. A non-empty
format specification typically modifies the result.

The general form of a *standard format specifier* is:

   format_spec     ::= [[fill]align][sign][#][0][width][grouping_option][.precision][type]
   fill            ::= <any character>
   align           ::= "<" | ">" | "=" | "^"
   sign            ::= "+" | "-" | " "
   width           ::= digit+
   grouping_option ::= "_" | ","
   precision       ::= digit+
   type            ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"

If a valid *align* value is specified, it can be preceded by a *fill*
character that can be any character and defaults to a space if
omitted. It is not possible to use a literal curly brace (”"{"” or
“"}"”) as the *fill* character in a formatted string literal or when
using the "str.format()" method.  However, it is possible to insert a
curly brace with a nested replacement field.  This limitation doesn’t
affect the "format()" function.

The meaning of the various alignment options is as follows:

   +-----------+------------------------------------------------------------+
   | Option    | Meaning                                                    |
   |===========|============================================================|
   | "'<'"     | Forces the field to be left-aligned within the available   |
   |           | space (this is the default for most objects).              |
   +-----------+------------------------------------------------------------+
   | "'>'"     | Forces the field to be right-aligned within the available  |
   |           | space (this is the default for numbers).                   |
   +-----------+------------------------------------------------------------+
   | "'='"     | Forces the padding to be placed after the sign (if any)    |
   |           | but before the digits.  This is used for printing fields   |
   |           | in the form ‘+000000120’. This alignment option is only    |
   |           | valid for numeric types.  It becomes the default when ‘0’  |
   |           | immediately precedes the field width.                      |
   +-----------+------------------------------------------------------------+
   | "'^'"     | Forces the field to be centered within the available       |
   |           | space.                                                     |
   +-----------+------------------------------------------------------------+

Note that unless a minimum field width is defined, the field width
will always be the same size as the data to fill it, so that the
alignment option has no meaning in this case.

The *sign* option is only valid for number types, and can be one of
the following:

   +-----------+------------------------------------------------------------+
   | Option    | Meaning                                                    |
   |===========|============================================================|
   | "'+'"     | indicates that a sign should be used for both positive as  |
   |           | well as negative numbers.                                  |
   +-----------+------------------------------------------------------------+
   | "'-'"     | indicates that a sign should be used only for negative     |
   |           | numbers (this is the default behavior).                    |
   +-----------+------------------------------------------------------------+
   | space     | indicates that a leading space should be used on positive  |
   |           | numbers, and a minus sign on negative numbers.             |
   +-----------+------------------------------------------------------------+

The "'#'" option causes the “alternate form” to be used for the
conversion.  The alternate form is defined differently for different
types.  This option is only valid for integer, float and complex
types. For integers, when binary, octal, or hexadecimal output is
used, this option adds the prefix respective "'0b'", "'0o'", or "'0x'"
to the output value. For float and complex the alternate form causes
the result of the conversion to always contain a decimal-point
character, even if no digits follow it. Normally, a decimal-point
character appears in the result of these conversions only if a digit
follows it. In addition, for "'g'" and "'G'" conversions, trailing
zeros are not removed from the result.

The "','" option signals the use of a comma for a thousands separator.
For a locale aware separator, use the "'n'" integer presentation type
instead.

Changed in version 3.1: Added the "','" option (see also **PEP 378**).

The "'_'" option signals the use of an underscore for a thousands
separator for floating point presentation types and for integer
presentation type "'d'".  For integer presentation types "'b'", "'o'",
"'x'", and "'X'", underscores will be inserted every 4 digits.  For
other presentation types, specifying this option is an error.

Changed in version 3.6: Added the "'_'" option (see also **PEP 515**).

*width* is a decimal integer defining the minimum total field width,
including any prefixes, separators, and other formatting characters.
If not specified, then the field width will be determined by the
content.

When no explicit alignment is given, preceding the *width* field by a
zero ("'0'") character enables sign-aware zero-padding for numeric
types.  This is equivalent to a *fill* character of "'0'" with an
*alignment* type of "'='".

The *precision* is a decimal number indicating how many digits should
be displayed after the decimal point for a floating point value
formatted with "'f'" and "'F'", or before and after the decimal point
for a floating point value formatted with "'g'" or "'G'".  For non-
number types the field indicates the maximum field size - in other
words, how many characters will be used from the field content. The
*precision* is not allowed for integer values.

Finally, the *type* determines how the data should be presented.

The available string presentation types are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'s'"     | String format. This is the default type for strings and    |
   |           | may be omitted.                                            |
   +-----------+------------------------------------------------------------+
   | None      | The same as "'s'".                                         |
   +-----------+------------------------------------------------------------+

The available integer presentation types are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'b'"     | Binary format. Outputs the number in base 2.               |
   +-----------+------------------------------------------------------------+
   | "'c'"     | Character. Converts the integer to the corresponding       |
   |           | unicode character before printing.                         |
   +-----------+------------------------------------------------------------+
   | "'d'"     | Decimal Integer. Outputs the number in base 10.            |
   +-----------+------------------------------------------------------------+
   | "'o'"     | Octal format. Outputs the number in base 8.                |
   +-----------+------------------------------------------------------------+
   | "'x'"     | Hex format. Outputs the number in base 16, using lower-    |
   |           | case letters for the digits above 9.                       |
   +-----------+------------------------------------------------------------+
   | "'X'"     | Hex format. Outputs the number in base 16, using upper-    |
   |           | case letters for the digits above 9.                       |
   +-----------+------------------------------------------------------------+
   | "'n'"     | Number. This is the same as "'d'", except that it uses the |
   |           | current locale setting to insert the appropriate number    |
   |           | separator characters.                                      |
   +-----------+------------------------------------------------------------+
   | None      | The same as "'d'".                                         |
   +-----------+------------------------------------------------------------+

In addition to the above presentation types, integers can be formatted
with the floating point presentation types listed below (except "'n'"
and "None"). When doing so, "float()" is used to convert the integer
to a floating point number before formatting.

The available presentation types for "float" and "Decimal" values are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'e'"     | Scientific notation. For a given precision "p", formats    |
   |           | the number in scientific notation with the letter ‘e’      |
   |           | separating the coefficient from the exponent. The          |
   |           | coefficient has one digit before and "p" digits after the  |
   |           | decimal point, for a total of "p + 1" significant digits.  |
   |           | With no precision given, uses a precision of "6" digits    |
   |           | after the decimal point for "float", and shows all         |
   |           | coefficient digits for "Decimal". If no digits follow the  |
   |           | decimal point, the decimal point is also removed unless    |
   |           | the "#" option is used.                                    |
   +-----------+------------------------------------------------------------+
   | "'E'"     | Scientific notation. Same as "'e'" except it uses an upper |
   |           | case ‘E’ as the separator character.                       |
   +-----------+------------------------------------------------------------+
   | "'f'"     | Fixed-point notation. For a given precision "p", formats   |
   |           | the number as a decimal number with exactly "p" digits     |
   |           | following the decimal point. With no precision given, uses |
   |           | a precision of "6" digits after the decimal point for      |
   |           | "float", and uses a precision large enough to show all     |
   |           | coefficient digits for "Decimal". If no digits follow the  |
   |           | decimal point, the decimal point is also removed unless    |
   |           | the "#" option is used.                                    |
   +-----------+------------------------------------------------------------+
   | "'F'"     | Fixed-point notation. Same as "'f'", but converts "nan" to |
   |           | "NAN" and "inf" to "INF".                                  |
   +-----------+------------------------------------------------------------+
   | "'g'"     | General format.  For a given precision "p >= 1", this      |
   |           | rounds the number to "p" significant digits and then       |
   |           | formats the result in either fixed-point format or in      |
   |           | scientific notation, depending on its magnitude. A         |
   |           | precision of "0" is treated as equivalent to a precision   |
   |           | of "1".  The precise rules are as follows: suppose that    |
   |           | the result formatted with presentation type "'e'" and      |
   |           | precision "p-1" would have exponent "exp".  Then, if "m <= |
   |           | exp < p", where "m" is -4 for floats and -6 for            |
   |           | "Decimals", the number is formatted with presentation type |
   |           | "'f'" and precision "p-1-exp".  Otherwise, the number is   |
   |           | formatted with presentation type "'e'" and precision       |
   |           | "p-1". In both cases insignificant trailing zeros are      |
   |           | removed from the significand, and the decimal point is     |
   |           | also removed if there are no remaining digits following    |
   |           | it, unless the "'#'" option is used.  With no precision    |
   |           | given, uses a precision of "6" significant digits for      |
   |           | "float". For "Decimal", the coefficient of the result is   |
   |           | formed from the coefficient digits of the value;           |
   |           | scientific notation is used for values smaller than "1e-6" |
   |           | in absolute value and values where the place value of the  |
   |           | least significant digit is larger than 1, and fixed-point  |
   |           | notation is used otherwise.  Positive and negative         |
   |           | infinity, positive and negative zero, and nans, are        |
   |           | formatted as "inf", "-inf", "0", "-0" and "nan"            |
   |           | respectively, regardless of the precision.                 |
   +-----------+------------------------------------------------------------+
   | "'G'"     | General format. Same as "'g'" except switches to "'E'" if  |
   |           | the number gets too large. The representations of infinity |
   |           | and NaN are uppercased, too.                               |
   +-----------+------------------------------------------------------------+
   | "'n'"     | Number. This is the same as "'g'", except that it uses the |
   |           | current locale setting to insert the appropriate number    |
   |           | separator characters.                                      |
   +-----------+------------------------------------------------------------+
   | "'%'"     | Percentage. Multiplies the number by 100 and displays in   |
   |           | fixed ("'f'") format, followed by a percent sign.          |
   +-----------+------------------------------------------------------------+
   | None      | For "float" this is the same as "'g'", except that when    |
   |           | fixed-point notation is used to format the result, it      |
   |           | always includes at least one digit past the decimal point. |
   |           | The precision used is as large as needed to represent the  |
   |           | given value faithfully.  For "Decimal", this is the same   |
   |           | as either "'g'" or "'G'" depending on the value of         |
   |           | "context.capitals" for the current decimal context.  The   |
   |           | overall effect is to match the output of "str()" as        |
   |           | altered by the other format modifiers.                     |
   +-----------+------------------------------------------------------------+


Format examples
===============

This section contains examples of the "str.format()" syntax and
comparison with the old "%"-formatting.

In most of the cases the syntax is similar to the old "%"-formatting,
with the addition of the "{}" and with ":" used instead of "%". For
example, "'%03.2f'" can be translated to "'{:03.2f}'".

The new format syntax also supports new and different options, shown
in the following examples.

Accessing arguments by position:

   >>> '{0}, {1}, {2}'.format('a', 'b', 'c')
   'a, b, c'
   >>> '{}, {}, {}'.format('a', 'b', 'c')  # 3.1+ only
   'a, b, c'
   >>> '{2}, {1}, {0}'.format('a', 'b', 'c')
   'c, b, a'
   >>> '{2}, {1}, {0}'.format(*'abc')      # unpacking argument sequence
   'c, b, a'
   >>> '{0}{1}{0}'.format('abra', 'cad')   # arguments' indices can be repeated
   'abracadabra'

Accessing arguments by name:

   >>> 'Coordinates: {latitude}, {longitude}'.format(latitude='37.24N', longitude='-115.81W')
   'Coordinates: 37.24N, -115.81W'
   >>> coord = {'latitude': '37.24N', 'longitude': '-115.81W'}
   >>> 'Coordinates: {latitude}, {longitude}'.format(**coord)
   'Coordinates: 37.24N, -115.81W'

Accessing arguments’ attributes:

   >>> c = 3-5j
   >>> ('The complex number {0} is formed from the real part {0.real} '
   ...  'and the imaginary part {0.imag}.').format(c)
   'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.'
   >>> class Point:
   ...     def __init__(self, x, y):
   ...         self.x, self.y = x, y
   ...     def __str__(self):
   ...         return 'Point({self.x}, {self.y})'.format(self=self)
   ...
   >>> str(Point(4, 2))
   'Point(4, 2)'

Accessing arguments’ items:

   >>> coord = (3, 5)
   >>> 'X: {0[0]};  Y: {0[1]}'.format(coord)
   'X: 3;  Y: 5'

Replacing "%s" and "%r":

   >>> "repr() shows quotes: {!r}; str() doesn't: {!s}".format('test1', 'test2')
   "repr() shows quotes: 'test1'; str() doesn't: test2"

Aligning the text and specifying a width:

   >>> '{:<30}'.format('left aligned')
   'left aligned                  '
   >>> '{:>30}'.format('right aligned')
   '                 right aligned'
   >>> '{:^30}'.format('centered')
   '           centered           '
   >>> '{:*^30}'.format('centered')  # use '*' as a fill char
   '***********centered***********'

Replacing "%+f", "%-f", and "% f" and specifying a sign:

   >>> '{:+f}; {:+f}'.format(3.14, -3.14)  # show it always
   '+3.140000; -3.140000'
   >>> '{: f}; {: f}'.format(3.14, -3.14)  # show a space for positive numbers
   ' 3.140000; -3.140000'
   >>> '{:-f}; {:-f}'.format(3.14, -3.14)  # show only the minus -- same as '{:f}; {:f}'
   '3.140000; -3.140000'

Replacing "%x" and "%o" and converting the value to different bases:

   >>> # format also supports binary numbers
   >>> "int: {0:d};  hex: {0:x};  oct: {0:o};  bin: {0:b}".format(42)
   'int: 42;  hex: 2a;  oct: 52;  bin: 101010'
   >>> # with 0x, 0o, or 0b as prefix:
   >>> "int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}".format(42)
   'int: 42;  hex: 0x2a;  oct: 0o52;  bin: 0b101010'

Using the comma as a thousands separator:

   >>> '{:,}'.format(1234567890)
   '1,234,567,890'

Expressing a percentage:

   >>> points = 19
   >>> total = 22
   >>> 'Correct answers: {:.2%}'.format(points/total)
   'Correct answers: 86.36%'

Using type-specific formatting:

   >>> import datetime
   >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
   >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
   '2010-07-04 12:15:58'

Nesting arguments and more complex examples:

   >>> for align, text in zip('<^>', ['left', 'center', 'right']):
   ...     '{0:{fill}{align}16}'.format(text, fill=align, align=align)
   ...
   'left<<<<<<<<<<<<'
   '^^^^^center^^^^^'
   '>>>>>>>>>>>right'
   >>>
   >>> octets = [192, 168, 0, 1]
   >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)
   'C0A80001'
   >>> int(_, 16)
   3232235521
   >>>
   >>> width = 5
   >>> for num in range(5,12): 
   ...     for base in 'dXob':
   ...         print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ')
   ...     print()
   ...
       5     5     5   101
       6     6     6   110
       7     7     7   111
       8     8    10  1000
       9     9    11  1001
      10     A    12  1010
      11     B    13  1011
u|Function definitions
********************

A function definition defines a user-defined function object (see
section The standard type hierarchy):

   funcdef                   ::= [decorators] "def" funcname "(" [parameter_list] ")"
               ["->" expression] ":" suite
   decorators                ::= decorator+
   decorator                 ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
   dotted_name               ::= identifier ("." identifier)*
   parameter_list            ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
                        | parameter_list_no_posonly
   parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
                                 | parameter_list_starargs
   parameter_list_starargs   ::= "*" [parameter] ("," defparameter)* ["," ["**" parameter [","]]]
                               | "**" parameter [","]
   parameter                 ::= identifier [":" expression]
   defparameter              ::= parameter ["=" expression]
   funcname                  ::= identifier

A function definition is an executable statement.  Its execution binds
the function name in the current local namespace to a function object
(a wrapper around the executable code for the function).  This
function object contains a reference to the current global namespace
as the global namespace to be used when the function is called.

The function definition does not execute the function body; this gets
executed only when the function is called. [2]

A function definition may be wrapped by one or more *decorator*
expressions. Decorator expressions are evaluated when the function is
defined, in the scope that contains the function definition.  The
result must be a callable, which is invoked with the function object
as the only argument. The returned value is bound to the function name
instead of the function object.  Multiple decorators are applied in
nested fashion. For example, the following code

   @f1(arg)
   @f2
   def func(): pass

is roughly equivalent to

   def func(): pass
   func = f1(arg)(f2(func))

except that the original function is not temporarily bound to the name
"func".

When one or more *parameters* have the form *parameter* "="
*expression*, the function is said to have “default parameter values.”
For a parameter with a default value, the corresponding *argument* may
be omitted from a call, in which case the parameter’s default value is
substituted.  If a parameter has a default value, all following
parameters up until the “"*"” must also have a default value — this is
a syntactic restriction that is not expressed by the grammar.

**Default parameter values are evaluated from left to right when the
function definition is executed.** This means that the expression is
evaluated once, when the function is defined, and that the same “pre-
computed” value is used for each call.  This is especially important
to understand when a default parameter is a mutable object, such as a
list or a dictionary: if the function modifies the object (e.g. by
appending an item to a list), the default value is in effect modified.
This is generally not what was intended.  A way around this is to use
"None" as the default, and explicitly test for it in the body of the
function, e.g.:

   def whats_on_the_telly(penguin=None):
       if penguin is None:
           penguin = []
       penguin.append("property of the zoo")
       return penguin

Function call semantics are described in more detail in section Calls.
A function call always assigns values to all parameters mentioned in
the parameter list, either from positional arguments, from keyword
arguments, or from default values.  If the form “"*identifier"” is
present, it is initialized to a tuple receiving any excess positional
parameters, defaulting to the empty tuple. If the form
“"**identifier"” is present, it is initialized to a new ordered
mapping receiving any excess keyword arguments, defaulting to a new
empty mapping of the same type.  Parameters after “"*"” or
“"*identifier"” are keyword-only parameters and may only be passed by
keyword arguments.  Parameters before “"/"” are positional-only
parameters and may only be passed by positional arguments.

Changed in version 3.8: The "/" function parameter syntax may be used
to indicate positional-only parameters. See **PEP 570** for details.

Parameters may have an *annotation* of the form “": expression"”
following the parameter name.  Any parameter may have an annotation,
even those of the form "*identifier" or "**identifier".  Functions may
have “return” annotation of the form “"-> expression"” after the
parameter list.  These annotations can be any valid Python expression.
The presence of annotations does not change the semantics of a
function.  The annotation values are available as values of a
dictionary keyed by the parameters’ names in the "__annotations__"
attribute of the function object.  If the "annotations" import from
"__future__" is used, annotations are preserved as strings at runtime
which enables postponed evaluation.  Otherwise, they are evaluated
when the function definition is executed.  In this case annotations
may be evaluated in a different order than they appear in the source
code.

It is also possible to create anonymous functions (functions not bound
to a name), for immediate use in expressions.  This uses lambda
expressions, described in section Lambdas.  Note that the lambda
expression is merely a shorthand for a simplified function definition;
a function defined in a “"def"” statement can be passed around or
assigned to another name just like a function defined by a lambda
expression.  The “"def"” form is actually more powerful since it
allows the execution of multiple statements and annotations.

**Programmer’s note:** Functions are first-class objects.  A “"def"”
statement executed inside a function definition defines a local
function that can be returned or passed around.  Free variables used
in the nested function can access the local variables of the function
containing the def.  See section Naming and binding for details.

See also:

  **PEP 3107** - Function Annotations
     The original specification for function annotations.

  **PEP 484** - Type Hints
     Definition of a standard meaning for annotations: type hints.

  **PEP 526** - Syntax for Variable Annotations
     Ability to type hint variable declarations, including class
     variables and instance variables

  **PEP 563** - Postponed Evaluation of Annotations
     Support for forward references within annotations by preserving
     annotations in a string form at runtime instead of eager
     evaluation.
u�The "global" statement
**********************

   global_stmt ::= "global" identifier ("," identifier)*

The "global" statement is a declaration which holds for the entire
current code block.  It means that the listed identifiers are to be
interpreted as globals.  It would be impossible to assign to a global
variable without "global", although free variables may refer to
globals without being declared global.

Names listed in a "global" statement must not be used in the same code
block textually preceding that "global" statement.

Names listed in a "global" statement must not be defined as formal
parameters or in a "for" loop control target, "class" definition,
function definition, "import" statement, or variable annotation.

**CPython implementation detail:** The current implementation does not
enforce some of these restrictions, but programs should not abuse this
freedom, as future implementations may enforce them or silently change
the meaning of the program.

**Programmer’s note:** "global" is a directive to the parser.  It
applies only to code parsed at the same time as the "global"
statement. In particular, a "global" statement contained in a string
or code object supplied to the built-in "exec()" function does not
affect the code block *containing* the function call, and code
contained in such a string is unaffected by "global" statements in the
code containing the function call.  The same applies to the "eval()"
and "compile()" functions.
u�Reserved classes of identifiers
*******************************

Certain classes of identifiers (besides keywords) have special
meanings.  These classes are identified by the patterns of leading and
trailing underscore characters:

"_*"
   Not imported by "from module import *".  The special identifier "_"
   is used in the interactive interpreter to store the result of the
   last evaluation; it is stored in the "builtins" module.  When not
   in interactive mode, "_" has no special meaning and is not defined.
   See section The import statement.

   Note:

     The name "_" is often used in conjunction with
     internationalization; refer to the documentation for the
     "gettext" module for more information on this convention.

"__*__"
   System-defined names, informally known as “dunder” names. These
   names are defined by the interpreter and its implementation
   (including the standard library). Current system names are
   discussed in the Special method names section and elsewhere. More
   will likely be defined in future versions of Python.  *Any* use of
   "__*__" names, in any context, that does not follow explicitly
   documented use, is subject to breakage without warning.

"__*"
   Class-private names.  Names in this category, when used within the
   context of a class definition, are re-written to use a mangled form
   to help avoid name clashes between “private” attributes of base and
   derived classes. See section Identifiers (Names).
umIdentifiers and keywords
************************

Identifiers (also referred to as *names*) are described by the
following lexical definitions.

The syntax of identifiers in Python is based on the Unicode standard
annex UAX-31, with elaboration and changes as defined below; see also
**PEP 3131** for further details.

Within the ASCII range (U+0001..U+007F), the valid characters for
identifiers are the same as in Python 2.x: the uppercase and lowercase
letters "A" through "Z", the underscore "_" and, except for the first
character, the digits "0" through "9".

Python 3.0 introduces additional characters from outside the ASCII
range (see **PEP 3131**).  For these characters, the classification
uses the version of the Unicode Character Database as included in the
"unicodedata" module.

Identifiers are unlimited in length.  Case is significant.

   identifier   ::= xid_start xid_continue*
   id_start     ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
   id_continue  ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
   xid_start    ::= <all characters in id_start whose NFKC normalization is in "id_start xid_continue*">
   xid_continue ::= <all characters in id_continue whose NFKC normalization is in "id_continue*">

The Unicode category codes mentioned above stand for:

* *Lu* - uppercase letters

* *Ll* - lowercase letters

* *Lt* - titlecase letters

* *Lm* - modifier letters

* *Lo* - other letters

* *Nl* - letter numbers

* *Mn* - nonspacing marks

* *Mc* - spacing combining marks

* *Nd* - decimal numbers

* *Pc* - connector punctuations

* *Other_ID_Start* - explicit list of characters in PropList.txt to
  support backwards compatibility

* *Other_ID_Continue* - likewise

All identifiers are converted into the normal form NFKC while parsing;
comparison of identifiers is based on NFKC.

A non-normative HTML file listing all valid identifier characters for
Unicode 4.1 can be found at
https://www.unicode.org/Public/13.0.0/ucd/DerivedCoreProperties.txt


Keywords
========

The following identifiers are used as reserved words, or *keywords* of
the language, and cannot be used as ordinary identifiers.  They must
be spelled exactly as written here:

   False      await      else       import     pass
   None       break      except     in         raise
   True       class      finally    is         return
   and        continue   for        lambda     try
   as         def        from       nonlocal   while
   assert     del        global     not        with
   async      elif       if         or         yield


Reserved classes of identifiers
===============================

Certain classes of identifiers (besides keywords) have special
meanings.  These classes are identified by the patterns of leading and
trailing underscore characters:

"_*"
   Not imported by "from module import *".  The special identifier "_"
   is used in the interactive interpreter to store the result of the
   last evaluation; it is stored in the "builtins" module.  When not
   in interactive mode, "_" has no special meaning and is not defined.
   See section The import statement.

   Note:

     The name "_" is often used in conjunction with
     internationalization; refer to the documentation for the
     "gettext" module for more information on this convention.

"__*__"
   System-defined names, informally known as “dunder” names. These
   names are defined by the interpreter and its implementation
   (including the standard library). Current system names are
   discussed in the Special method names section and elsewhere. More
   will likely be defined in future versions of Python.  *Any* use of
   "__*__" names, in any context, that does not follow explicitly
   documented use, is subject to breakage without warning.

"__*"
   Class-private names.  Names in this category, when used within the
   context of a class definition, are re-written to use a mangled form
   to help avoid name clashes between “private” attributes of base and
   derived classes. See section Identifiers (Names).
a5Imaginary literals
******************

Imaginary literals are described by the following lexical definitions:

   imagnumber ::= (floatnumber | digitpart) ("j" | "J")

An imaginary literal yields a complex number with a real part of 0.0.
Complex numbers are represented as a pair of floating point numbers
and have the same restrictions on their range.  To create a complex
number with a nonzero real part, add a floating point number to it,
e.g., "(3+4j)".  Some examples of imaginary literals:

   3.14j   10.j    10j     .001j   1e100j   3.14e-10j   3.14_15_93j
u8"The "import" statement
**********************

   import_stmt     ::= "import" module ["as" identifier] ("," module ["as" identifier])*
                   | "from" relative_module "import" identifier ["as" identifier]
                   ("," identifier ["as" identifier])*
                   | "from" relative_module "import" "(" identifier ["as" identifier]
                   ("," identifier ["as" identifier])* [","] ")"
                   | "from" module "import" "*"
   module          ::= (identifier ".")* identifier
   relative_module ::= "."* module | "."+

The basic import statement (no "from" clause) is executed in two
steps:

1. find a module, loading and initializing it if necessary

2. define a name or names in the local namespace for the scope where
   the "import" statement occurs.

When the statement contains multiple clauses (separated by commas) the
two steps are carried out separately for each clause, just as though
the clauses had been separated out into individual import statements.

The details of the first step, finding and loading modules are
described in greater detail in the section on the import system, which
also describes the various types of packages and modules that can be
imported, as well as all the hooks that can be used to customize the
import system. Note that failures in this step may indicate either
that the module could not be located, *or* that an error occurred
while initializing the module, which includes execution of the
module’s code.

If the requested module is retrieved successfully, it will be made
available in the local namespace in one of three ways:

* If the module name is followed by "as", then the name following "as"
  is bound directly to the imported module.

* If no other name is specified, and the module being imported is a
  top level module, the module’s name is bound in the local namespace
  as a reference to the imported module

* If the module being imported is *not* a top level module, then the
  name of the top level package that contains the module is bound in
  the local namespace as a reference to the top level package. The
  imported module must be accessed using its full qualified name
  rather than directly

The "from" form uses a slightly more complex process:

1. find the module specified in the "from" clause, loading and
   initializing it if necessary;

2. for each of the identifiers specified in the "import" clauses:

   1. check if the imported module has an attribute by that name

   2. if not, attempt to import a submodule with that name and then
      check the imported module again for that attribute

   3. if the attribute is not found, "ImportError" is raised.

   4. otherwise, a reference to that value is stored in the local
      namespace, using the name in the "as" clause if it is present,
      otherwise using the attribute name

Examples:

   import foo                 # foo imported and bound locally
   import foo.bar.baz         # foo.bar.baz imported, foo bound locally
   import foo.bar.baz as fbb  # foo.bar.baz imported and bound as fbb
   from foo.bar import baz    # foo.bar.baz imported and bound as baz
   from foo import attr       # foo imported and foo.attr bound as attr

If the list of identifiers is replaced by a star ("'*'"), all public
names defined in the module are bound in the local namespace for the
scope where the "import" statement occurs.

The *public names* defined by a module are determined by checking the
module’s namespace for a variable named "__all__"; if defined, it must
be a sequence of strings which are names defined or imported by that
module.  The names given in "__all__" are all considered public and
are required to exist.  If "__all__" is not defined, the set of public
names includes all names found in the module’s namespace which do not
begin with an underscore character ("'_'").  "__all__" should contain
the entire public API. It is intended to avoid accidentally exporting
items that are not part of the API (such as library modules which were
imported and used within the module).

The wild card form of import — "from module import *" — is only
allowed at the module level.  Attempting to use it in class or
function definitions will raise a "SyntaxError".

When specifying what module to import you do not have to specify the
absolute name of the module. When a module or package is contained
within another package it is possible to make a relative import within
the same top package without having to mention the package name. By
using leading dots in the specified module or package after "from" you
can specify how high to traverse up the current package hierarchy
without specifying exact names. One leading dot means the current
package where the module making the import exists. Two dots means up
one package level. Three dots is up two levels, etc. So if you execute
"from . import mod" from a module in the "pkg" package then you will
end up importing "pkg.mod". If you execute "from ..subpkg2 import mod"
from within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The
specification for relative imports is contained in the Package
Relative Imports section.

"importlib.import_module()" is provided to support applications that
determine dynamically the modules to be loaded.

Raises an auditing event "import" with arguments "module", "filename",
"sys.path", "sys.meta_path", "sys.path_hooks".


Future statements
=================

A *future statement* is a directive to the compiler that a particular
module should be compiled using syntax or semantics that will be
available in a specified future release of Python where the feature
becomes standard.

The future statement is intended to ease migration to future versions
of Python that introduce incompatible changes to the language.  It
allows use of the new features on a per-module basis before the
release in which the feature becomes standard.

   future_stmt ::= "from" "__future__" "import" feature ["as" identifier]
                   ("," feature ["as" identifier])*
                   | "from" "__future__" "import" "(" feature ["as" identifier]
                   ("," feature ["as" identifier])* [","] ")"
   feature     ::= identifier

A future statement must appear near the top of the module.  The only
lines that can appear before a future statement are:

* the module docstring (if any),

* comments,

* blank lines, and

* other future statements.

The only feature that requires using the future statement is
"annotations" (see **PEP 563**).

All historical features enabled by the future statement are still
recognized by Python 3.  The list includes "absolute_import",
"division", "generators", "generator_stop", "unicode_literals",
"print_function", "nested_scopes" and "with_statement".  They are all
redundant because they are always enabled, and only kept for backwards
compatibility.

A future statement is recognized and treated specially at compile
time: Changes to the semantics of core constructs are often
implemented by generating different code.  It may even be the case
that a new feature introduces new incompatible syntax (such as a new
reserved word), in which case the compiler may need to parse the
module differently.  Such decisions cannot be pushed off until
runtime.

For any given release, the compiler knows which feature names have
been defined, and raises a compile-time error if a future statement
contains a feature not known to it.

The direct runtime semantics are the same as for any import statement:
there is a standard module "__future__", described later, and it will
be imported in the usual way at the time the future statement is
executed.

The interesting runtime semantics depend on the specific feature
enabled by the future statement.

Note that there is nothing special about the statement:

   import __future__ [as name]

That is not a future statement; it’s an ordinary import statement with
no special semantics or syntax restrictions.

Code compiled by calls to the built-in functions "exec()" and
"compile()" that occur in a module "M" containing a future statement
will, by default, use the new syntax or semantics associated with the
future statement.  This can be controlled by optional arguments to
"compile()" — see the documentation of that function for details.

A future statement typed at an interactive interpreter prompt will
take effect for the rest of the interpreter session.  If an
interpreter is started with the "-i" option, is passed a script name
to execute, and the script includes a future statement, it will be in
effect in the interactive session started after the script is
executed.

See also:

  **PEP 236** - Back to the __future__
     The original proposal for the __future__ mechanism.
aMembership test operations
**************************

The operators "in" and "not in" test for membership.  "x in s"
evaluates to "True" if *x* is a member of *s*, and "False" otherwise.
"x not in s" returns the negation of "x in s".  All built-in sequences
and set types support this as well as dictionary, for which "in" tests
whether the dictionary has a given key. For container types such as
list, tuple, set, frozenset, dict, or collections.deque, the
expression "x in y" is equivalent to "any(x is e or x == e for e in
y)".

For the string and bytes types, "x in y" is "True" if and only if *x*
is a substring of *y*.  An equivalent test is "y.find(x) != -1".
Empty strings are always considered to be a substring of any other
string, so """ in "abc"" will return "True".

For user-defined classes which define the "__contains__()" method, "x
in y" returns "True" if "y.__contains__(x)" returns a true value, and
"False" otherwise.

For user-defined classes which do not define "__contains__()" but do
define "__iter__()", "x in y" is "True" if some value "z", for which
the expression "x is z or x == z" is true, is produced while iterating
over "y". If an exception is raised during the iteration, it is as if
"in" raised that exception.

Lastly, the old-style iteration protocol is tried: if a class defines
"__getitem__()", "x in y" is "True" if and only if there is a non-
negative integer index *i* such that "x is y[i] or x == y[i]", and no
lower integer index raises the "IndexError" exception.  (If any other
exception is raised, it is as if "in" raised that exception).

The operator "not in" is defined to have the inverse truth value of
"in".
aVInteger literals
****************

Integer literals are described by the following lexical definitions:

   integer      ::= decinteger | bininteger | octinteger | hexinteger
   decinteger   ::= nonzerodigit (["_"] digit)* | "0"+ (["_"] "0")*
   bininteger   ::= "0" ("b" | "B") (["_"] bindigit)+
   octinteger   ::= "0" ("o" | "O") (["_"] octdigit)+
   hexinteger   ::= "0" ("x" | "X") (["_"] hexdigit)+
   nonzerodigit ::= "1"..."9"
   digit        ::= "0"..."9"
   bindigit     ::= "0" | "1"
   octdigit     ::= "0"..."7"
   hexdigit     ::= digit | "a"..."f" | "A"..."F"

There is no limit for the length of integer literals apart from what
can be stored in available memory.

Underscores are ignored for determining the numeric value of the
literal.  They can be used to group digits for enhanced readability.
One underscore can occur between digits, and after base specifiers
like "0x".

Note that leading zeros in a non-zero decimal number are not allowed.
This is for disambiguation with C-style octal literals, which Python
used before version 3.0.

Some examples of integer literals:

   7     2147483647                        0o177    0b100110111
   3     79228162514264337593543950336     0o377    0xdeadbeef
         100_000_000_000                   0b_1110_0101

Changed in version 3.6: Underscores are now allowed for grouping
purposes in literals.
a^Lambdas
*******

   lambda_expr        ::= "lambda" [parameter_list] ":" expression
   lambda_expr_nocond ::= "lambda" [parameter_list] ":" expression_nocond

Lambda expressions (sometimes called lambda forms) are used to create
anonymous functions. The expression "lambda parameters: expression"
yields a function object.  The unnamed object behaves like a function
object defined with:

   def <lambda>(parameters):
       return expression

See section Function definitions for the syntax of parameter lists.
Note that functions created with lambda expressions cannot contain
statements or annotations.
a/List displays
*************

A list display is a possibly empty series of expressions enclosed in
square brackets:

   list_display ::= "[" [starred_list | comprehension] "]"

A list display yields a new list object, the contents being specified
by either a list of expressions or a comprehension.  When a comma-
separated list of expressions is supplied, its elements are evaluated
from left to right and placed into the list object in that order.
When a comprehension is supplied, the list is constructed from the
elements resulting from the comprehension.
u�Naming and binding
******************


Binding of names
================

*Names* refer to objects.  Names are introduced by name binding
operations.

The following constructs bind names: formal parameters to functions,
"import" statements, class and function definitions (these bind the
class or function name in the defining block), and targets that are
identifiers if occurring in an assignment, "for" loop header, or after
"as" in a "with" statement or "except" clause. The "import" statement
of the form "from ... import *" binds all names defined in the
imported module, except those beginning with an underscore.  This form
may only be used at the module level.

A target occurring in a "del" statement is also considered bound for
this purpose (though the actual semantics are to unbind the name).

Each assignment or import statement occurs within a block defined by a
class or function definition or at the module level (the top-level
code block).

If a name is bound in a block, it is a local variable of that block,
unless declared as "nonlocal" or "global".  If a name is bound at the
module level, it is a global variable.  (The variables of the module
code block are local and global.)  If a variable is used in a code
block but not defined there, it is a *free variable*.

Each occurrence of a name in the program text refers to the *binding*
of that name established by the following name resolution rules.


Resolution of names
===================

A *scope* defines the visibility of a name within a block.  If a local
variable is defined in a block, its scope includes that block.  If the
definition occurs in a function block, the scope extends to any blocks
contained within the defining one, unless a contained block introduces
a different binding for the name.

When a name is used in a code block, it is resolved using the nearest
enclosing scope.  The set of all such scopes visible to a code block
is called the block’s *environment*.

When a name is not found at all, a "NameError" exception is raised. If
the current scope is a function scope, and the name refers to a local
variable that has not yet been bound to a value at the point where the
name is used, an "UnboundLocalError" exception is raised.
"UnboundLocalError" is a subclass of "NameError".

If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block.  This can lead to errors when a name is used within a
block before it is bound.  This rule is subtle.  Python lacks
declarations and allows name binding operations to occur anywhere
within a code block.  The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.

If the "global" statement occurs within a block, all uses of the name
specified in the statement refer to the binding of that name in the
top-level namespace.  Names are resolved in the top-level namespace by
searching the global namespace, i.e. the namespace of the module
containing the code block, and the builtins namespace, the namespace
of the module "builtins".  The global namespace is searched first.  If
the name is not found there, the builtins namespace is searched.  The
"global" statement must precede all uses of the name.

The "global" statement has the same scope as a name binding operation
in the same block.  If the nearest enclosing scope for a free variable
contains a global statement, the free variable is treated as a global.

The "nonlocal" statement causes corresponding names to refer to
previously bound variables in the nearest enclosing function scope.
"SyntaxError" is raised at compile time if the given name does not
exist in any enclosing function scope.

The namespace for a module is automatically created the first time a
module is imported.  The main module for a script is always called
"__main__".

Class definition blocks and arguments to "exec()" and "eval()" are
special in the context of name resolution. A class definition is an
executable statement that may use and define names. These references
follow the normal rules for name resolution with an exception that
unbound local variables are looked up in the global namespace. The
namespace of the class definition becomes the attribute dictionary of
the class. The scope of names defined in a class block is limited to
the class block; it does not extend to the code blocks of methods –
this includes comprehensions and generator expressions since they are
implemented using a function scope.  This means that the following
will fail:

   class A:
       a = 42
       b = list(a + i for i in range(10))


Builtins and restricted execution
=================================

**CPython implementation detail:** Users should not touch
"__builtins__"; it is strictly an implementation detail.  Users
wanting to override values in the builtins namespace should "import"
the "builtins" module and modify its attributes appropriately.

The builtins namespace associated with the execution of a code block
is actually found by looking up the name "__builtins__" in its global
namespace; this should be a dictionary or a module (in the latter case
the module’s dictionary is used).  By default, when in the "__main__"
module, "__builtins__" is the built-in module "builtins"; when in any
other module, "__builtins__" is an alias for the dictionary of the
"builtins" module itself.


Interaction with dynamic features
=================================

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.
a�The "nonlocal" statement
************************

   nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*

The "nonlocal" statement causes the listed identifiers to refer to
previously bound variables in the nearest enclosing scope excluding
globals. This is important because the default behavior for binding is
to search the local namespace first.  The statement allows
encapsulated code to rebind variables outside of the local scope
besides the global (module) scope.

Names listed in a "nonlocal" statement, unlike those listed in a
"global" statement, must refer to pre-existing bindings in an
enclosing scope (the scope in which a new binding should be created
cannot be determined unambiguously).

Names listed in a "nonlocal" statement must not collide with pre-
existing bindings in the local scope.

See also:

  **PEP 3104** - Access to Names in Outer Scopes
     The specification for the "nonlocal" statement.
u�Numeric literals
****************

There are three types of numeric literals: integers, floating point
numbers, and imaginary numbers.  There are no complex literals
(complex numbers can be formed by adding a real number and an
imaginary number).

Note that numeric literals do not include a sign; a phrase like "-1"
is actually an expression composed of the unary operator ‘"-"’ and the
literal "1".
uEmulating numeric types
***********************

The following methods can be defined to emulate numeric objects.
Methods corresponding to operations that are not supported by the
particular kind of number implemented (e.g., bitwise operations for
non-integral numbers) should be left undefined.

object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
object.__matmul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
object.__divmod__(self, other)
object.__pow__(self, other[, modulo])
object.__lshift__(self, other)
object.__rshift__(self, other)
object.__and__(self, other)
object.__xor__(self, other)
object.__or__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|").  For instance, to
   evaluate the expression "x + y", where *x* is an instance of a
   class that has an "__add__()" method, "x.__add__(y)" is called.
   The "__divmod__()" method should be the equivalent to using
   "__floordiv__()" and "__mod__()"; it should not be related to
   "__truediv__()".  Note that "__pow__()" should be defined to accept
   an optional third argument if the ternary version of the built-in
   "pow()" function is to be supported.

   If one of those methods does not support the operation with the
   supplied arguments, it should return "NotImplemented".

object.__radd__(self, other)
object.__rsub__(self, other)
object.__rmul__(self, other)
object.__rmatmul__(self, other)
object.__rtruediv__(self, other)
object.__rfloordiv__(self, other)
object.__rmod__(self, other)
object.__rdivmod__(self, other)
object.__rpow__(self, other[, modulo])
object.__rlshift__(self, other)
object.__rrshift__(self, other)
object.__rand__(self, other)
object.__rxor__(self, other)
object.__ror__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)
   operands.  These functions are only called if the left operand does
   not support the corresponding operation [3] and the operands are of
   different types. [4] For instance, to evaluate the expression "x -
   y", where *y* is an instance of a class that has an "__rsub__()"
   method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns
   *NotImplemented*.

   Note that ternary "pow()" will not try calling "__rpow__()" (the
   coercion rules would become too complicated).

   Note:

     If the right operand’s type is a subclass of the left operand’s
     type and that subclass provides a different implementation of the
     reflected method for the operation, this method will be called
     before the left operand’s non-reflected method. This behavior
     allows subclasses to override their ancestors’ operations.

object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
object.__imatmul__(self, other)
object.__itruediv__(self, other)
object.__ifloordiv__(self, other)
object.__imod__(self, other)
object.__ipow__(self, other[, modulo])
object.__ilshift__(self, other)
object.__irshift__(self, other)
object.__iand__(self, other)
object.__ixor__(self, other)
object.__ior__(self, other)

   These methods are called to implement the augmented arithmetic
   assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",
   "<<=", ">>=", "&=", "^=", "|=").  These methods should attempt to
   do the operation in-place (modifying *self*) and return the result
   (which could be, but does not have to be, *self*).  If a specific
   method is not defined, the augmented assignment falls back to the
   normal methods.  For instance, if *x* is an instance of a class
   with an "__iadd__()" method, "x += y" is equivalent to "x =
   x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are
   considered, as with the evaluation of "x + y". In certain
   situations, augmented assignment can result in unexpected errors
   (see Why does a_tuple[i] += [‘item’] raise an exception when the
   addition works?), but this behavior is in fact part of the data
   model.

   Note:

     Due to a bug in the dispatching mechanism for "**=", a class that
     defines "__ipow__()" but returns "NotImplemented" would fail to
     fall back to "x.__pow__(y)" and "y.__rpow__(x)". This bug is
     fixed in Python 3.10.

object.__neg__(self)
object.__pos__(self)
object.__abs__(self)
object.__invert__(self)

   Called to implement the unary arithmetic operations ("-", "+",
   "abs()" and "~").

object.__complex__(self)
object.__int__(self)
object.__float__(self)

   Called to implement the built-in functions "complex()", "int()" and
   "float()".  Should return a value of the appropriate type.

object.__index__(self)

   Called to implement "operator.index()", and whenever Python needs
   to losslessly convert the numeric object to an integer object (such
   as in slicing, or in the built-in "bin()", "hex()" and "oct()"
   functions). Presence of this method indicates that the numeric
   object is an integer type.  Must return an integer.

   If "__int__()", "__float__()" and "__complex__()" are not defined
   then corresponding built-in functions "int()", "float()" and
   "complex()" fall back to "__index__()".

object.__round__(self[, ndigits])
object.__trunc__(self)
object.__floor__(self)
object.__ceil__(self)

   Called to implement the built-in function "round()" and "math"
   functions "trunc()", "floor()" and "ceil()". Unless *ndigits* is
   passed to "__round__()" all these methods should return the value
   of the object truncated to an "Integral" (typically an "int").

   The built-in function "int()" falls back to "__trunc__()" if
   neither "__int__()" nor "__index__()" is defined.
uObjects, values and types
*************************

*Objects* are Python’s abstraction for data.  All data in a Python
program is represented by objects or by relations between objects. (In
a sense, and in conformance to Von Neumann’s model of a “stored
program computer”, code is also represented by objects.)

Every object has an identity, a type and a value.  An object’s
*identity* never changes once it has been created; you may think of it
as the object’s address in memory.  The ‘"is"’ operator compares the
identity of two objects; the "id()" function returns an integer
representing its identity.

**CPython implementation detail:** For CPython, "id(x)" is the memory
address where "x" is stored.

An object’s type determines the operations that the object supports
(e.g., “does it have a length?”) and also defines the possible values
for objects of that type.  The "type()" function returns an object’s
type (which is an object itself).  Like its identity, an object’s
*type* is also unchangeable. [1]

The *value* of some objects can change.  Objects whose value can
change are said to be *mutable*; objects whose value is unchangeable
once they are created are called *immutable*. (The value of an
immutable container object that contains a reference to a mutable
object can change when the latter’s value is changed; however the
container is still considered immutable, because the collection of
objects it contains cannot be changed.  So, immutability is not
strictly the same as having an unchangeable value, it is more subtle.)
An object’s mutability is determined by its type; for instance,
numbers, strings and tuples are immutable, while dictionaries and
lists are mutable.

Objects are never explicitly destroyed; however, when they become
unreachable they may be garbage-collected.  An implementation is
allowed to postpone garbage collection or omit it altogether — it is a
matter of implementation quality how garbage collection is
implemented, as long as no objects are collected that are still
reachable.

**CPython implementation detail:** CPython currently uses a reference-
counting scheme with (optional) delayed detection of cyclically linked
garbage, which collects most objects as soon as they become
unreachable, but is not guaranteed to collect garbage containing
circular references.  See the documentation of the "gc" module for
information on controlling the collection of cyclic garbage. Other
implementations act differently and CPython may change. Do not depend
on immediate finalization of objects when they become unreachable (so
you should always close files explicitly).

Note that the use of the implementation’s tracing or debugging
facilities may keep objects alive that would normally be collectable.
Also note that catching an exception with a ‘"try"…"except"’ statement
may keep objects alive.

Some objects contain references to “external” resources such as open
files or windows.  It is understood that these resources are freed
when the object is garbage-collected, but since garbage collection is
not guaranteed to happen, such objects also provide an explicit way to
release the external resource, usually a "close()" method. Programs
are strongly recommended to explicitly close such objects.  The
‘"try"…"finally"’ statement and the ‘"with"’ statement provide
convenient ways to do this.

Some objects contain references to other objects; these are called
*containers*. Examples of containers are tuples, lists and
dictionaries.  The references are part of a container’s value.  In
most cases, when we talk about the value of a container, we imply the
values, not the identities of the contained objects; however, when we
talk about the mutability of a container, only the identities of the
immediately contained objects are implied.  So, if an immutable
container (like a tuple) contains a reference to a mutable object, its
value changes if that mutable object is changed.

Types affect almost all aspects of object behavior.  Even the
importance of object identity is affected in some sense: for immutable
types, operations that compute new values may actually return a
reference to any existing object with the same type and value, while
for mutable objects this is not allowed.  E.g., after "a = 1; b = 1",
"a" and "b" may or may not refer to the same object with the value
one, depending on the implementation, but after "c = []; d = []", "c"
and "d" are guaranteed to refer to two different, unique, newly
created empty lists. (Note that "c = d = []" assigns the same object
to both "c" and "d".)
u�Operator precedence
*******************

The following table summarizes the operator precedence in Python, from
lowest precedence (least binding) to highest precedence (most
binding).  Operators in the same box have the same precedence.  Unless
the syntax is explicitly given, operators are binary.  Operators in
the same box group left to right (except for exponentiation, which
groups from right to left).

Note that comparisons, membership tests, and identity tests, all have
the same precedence and have a left-to-right chaining feature as
described in the Comparisons section.

+-------------------------------------------------+---------------------------------------+
| Operator                                        | Description                           |
|=================================================|=======================================|
| ":="                                            | Assignment expression                 |
+-------------------------------------------------+---------------------------------------+
| "lambda"                                        | Lambda expression                     |
+-------------------------------------------------+---------------------------------------+
| "if" – "else"                                   | Conditional expression                |
+-------------------------------------------------+---------------------------------------+
| "or"                                            | Boolean OR                            |
+-------------------------------------------------+---------------------------------------+
| "and"                                           | Boolean AND                           |
+-------------------------------------------------+---------------------------------------+
| "not" "x"                                       | Boolean NOT                           |
+-------------------------------------------------+---------------------------------------+
| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership     |
| ">=", "!=", "=="                                | tests and identity tests              |
+-------------------------------------------------+---------------------------------------+
| "|"                                             | Bitwise OR                            |
+-------------------------------------------------+---------------------------------------+
| "^"                                             | Bitwise XOR                           |
+-------------------------------------------------+---------------------------------------+
| "&"                                             | Bitwise AND                           |
+-------------------------------------------------+---------------------------------------+
| "<<", ">>"                                      | Shifts                                |
+-------------------------------------------------+---------------------------------------+
| "+", "-"                                        | Addition and subtraction              |
+-------------------------------------------------+---------------------------------------+
| "*", "@", "/", "//", "%"                        | Multiplication, matrix                |
|                                                 | multiplication, division, floor       |
|                                                 | division, remainder [5]               |
+-------------------------------------------------+---------------------------------------+
| "+x", "-x", "~x"                                | Positive, negative, bitwise NOT       |
+-------------------------------------------------+---------------------------------------+
| "**"                                            | Exponentiation [6]                    |
+-------------------------------------------------+---------------------------------------+
| "await" "x"                                     | Await expression                      |
+-------------------------------------------------+---------------------------------------+
| "x[index]", "x[index:index]",                   | Subscription, slicing, call,          |
| "x(arguments...)", "x.attribute"                | attribute reference                   |
+-------------------------------------------------+---------------------------------------+
| "(expressions...)",  "[expressions...]", "{key: | Binding or parenthesized expression,  |
| value...}", "{expressions...}"                  | list display, dictionary display, set |
|                                                 | display                               |
+-------------------------------------------------+---------------------------------------+

-[ Footnotes ]-

[1] While "abs(x%y) < abs(y)" is true mathematically, for floats it
    may not be true numerically due to roundoff.  For example, and
    assuming a platform on which a Python float is an IEEE 754 double-
    precision number, in order that "-1e-100 % 1e100" have the same
    sign as "1e100", the computed result is "-1e-100 + 1e100", which
    is numerically exactly equal to "1e100".  The function
    "math.fmod()" returns a result whose sign matches the sign of the
    first argument instead, and so returns "-1e-100" in this case.
    Which approach is more appropriate depends on the application.

[2] If x is very close to an exact integer multiple of y, it’s
    possible for "x//y" to be one larger than "(x-x%y)//y" due to
    rounding.  In such cases, Python returns the latter result, in
    order to preserve that "divmod(x,y)[0] * y + x % y" be very close
    to "x".

[3] The Unicode standard distinguishes between *code points* (e.g.
    U+0041) and *abstract characters* (e.g. “LATIN CAPITAL LETTER A”).
    While most abstract characters in Unicode are only represented
    using one code point, there is a number of abstract characters
    that can in addition be represented using a sequence of more than
    one code point.  For example, the abstract character “LATIN
    CAPITAL LETTER C WITH CEDILLA” can be represented as a single
    *precomposed character* at code position U+00C7, or as a sequence
    of a *base character* at code position U+0043 (LATIN CAPITAL
    LETTER C), followed by a *combining character* at code position
    U+0327 (COMBINING CEDILLA).

    The comparison operators on strings compare at the level of
    Unicode code points. This may be counter-intuitive to humans.  For
    example, ""\u00C7" == "\u0043\u0327"" is "False", even though both
    strings represent the same abstract character “LATIN CAPITAL
    LETTER C WITH CEDILLA”.

    To compare strings at the level of abstract characters (that is,
    in a way intuitive to humans), use "unicodedata.normalize()".

[4] Due to automatic garbage-collection, free lists, and the dynamic
    nature of descriptors, you may notice seemingly unusual behaviour
    in certain uses of the "is" operator, like those involving
    comparisons between instance methods, or constants.  Check their
    documentation for more info.

[5] The "%" operator is also used for string formatting; the same
    precedence applies.

[6] The power operator "**" binds less tightly than an arithmetic or
    bitwise unary operator on its right, that is, "2**-1" is "0.5".
uwThe "pass" statement
********************

   pass_stmt ::= "pass"

"pass" is a null operation — when it is executed, nothing happens. It
is useful as a placeholder when a statement is required syntactically,
but no code needs to be executed, for example:

   def f(arg): pass    # a function that does nothing (yet)

   class C: pass       # a class with no methods (yet)
a�The power operator
******************

The power operator binds more tightly than unary operators on its
left; it binds less tightly than unary operators on its right.  The
syntax is:

   power ::= (await_expr | primary) ["**" u_expr]

Thus, in an unparenthesized sequence of power and unary operators, the
operators are evaluated from right to left (this does not constrain
the evaluation order for the operands): "-1**2" results in "-1".

The power operator has the same semantics as the built-in "pow()"
function, when called with two arguments: it yields its left argument
raised to the power of its right argument.  The numeric arguments are
first converted to a common type, and the result is of that type.

For int operands, the result has the same type as the operands unless
the second argument is negative; in that case, all arguments are
converted to float and a float result is delivered. For example,
"10**2" returns "100", but "10**-2" returns "0.01".

Raising "0.0" to a negative power results in a "ZeroDivisionError".
Raising a negative number to a fractional power results in a "complex"
number. (In earlier versions it raised a "ValueError".)
uJ
The "raise" statement
*********************

   raise_stmt ::= "raise" [expression ["from" expression]]

If no expressions are present, "raise" re-raises the last exception
that was active in the current scope.  If no exception is active in
the current scope, a "RuntimeError" exception is raised indicating
that this is an error.

Otherwise, "raise" evaluates the first expression as the exception
object.  It must be either a subclass or an instance of
"BaseException". If it is a class, the exception instance will be
obtained when needed by instantiating the class with no arguments.

The *type* of the exception is the exception instance’s class, the
*value* is the instance itself.

A traceback object is normally created automatically when an exception
is raised and attached to it as the "__traceback__" attribute, which
is writable. You can create an exception and set your own traceback in
one step using the "with_traceback()" exception method (which returns
the same exception instance, with its traceback set to its argument),
like so:

   raise Exception("foo occurred").with_traceback(tracebackobj)

The "from" clause is used for exception chaining: if given, the second
*expression* must be another exception class or instance. If the
second expression is an exception instance, it will be attached to the
raised exception as the "__cause__" attribute (which is writable). If
the expression is an exception class, the class will be instantiated
and the resulting exception instance will be attached to the raised
exception as the "__cause__" attribute. If the raised exception is not
handled, both exceptions will be printed:

   >>> try:
   ...     print(1 / 0)
   ... except Exception as exc:
   ...     raise RuntimeError("Something bad happened") from exc
   ...
   Traceback (most recent call last):
     File "<stdin>", line 2, in <module>
   ZeroDivisionError: division by zero

   The above exception was the direct cause of the following exception:

   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

A similar mechanism works implicitly if an exception is raised inside
an exception handler or a "finally" clause: the previous exception is
then attached as the new exception’s "__context__" attribute:

   >>> try:
   ...     print(1 / 0)
   ... except:
   ...     raise RuntimeError("Something bad happened")
   ...
   Traceback (most recent call last):
     File "<stdin>", line 2, in <module>
   ZeroDivisionError: division by zero

   During handling of the above exception, another exception occurred:

   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

Exception chaining can be explicitly suppressed by specifying "None"
in the "from" clause:

   >>> try:
   ...     print(1 / 0)
   ... except:
   ...     raise RuntimeError("Something bad happened") from None
   ...
   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

Additional information on exceptions can be found in section
Exceptions, and information about handling exceptions is in section
The try statement.

Changed in version 3.3: "None" is now permitted as "Y" in "raise X
from Y".

New in version 3.3: The "__suppress_context__" attribute to suppress
automatic display of the exception context.
aThe "return" statement
**********************

   return_stmt ::= "return" [expression_list]

"return" may only occur syntactically nested in a function definition,
not within a nested class definition.

If an expression list is present, it is evaluated, else "None" is
substituted.

"return" leaves the current function call with the expression list (or
"None") as return value.

When "return" passes control out of a "try" statement with a "finally"
clause, that "finally" clause is executed before really leaving the
function.

In a generator function, the "return" statement indicates that the
generator is done and will cause "StopIteration" to be raised. The
returned value (if any) is used as an argument to construct
"StopIteration" and becomes the "StopIteration.value" attribute.

In an asynchronous generator function, an empty "return" statement
indicates that the asynchronous generator is done and will cause
"StopAsyncIteration" to be raised.  A non-empty "return" statement is
a syntax error in an asynchronous generator function.
u�Emulating container types
*************************

The following methods can be defined to implement container objects.
Containers usually are sequences (such as lists or tuples) or mappings
(like dictionaries), but can represent other containers as well.  The
first set of methods is used either to emulate a sequence or to
emulate a mapping; the difference is that for a sequence, the
allowable keys should be the integers *k* for which "0 <= k < N" where
*N* is the length of the sequence, or slice objects, which define a
range of items.  It is also recommended that mappings provide the
methods "keys()", "values()", "items()", "get()", "clear()",
"setdefault()", "pop()", "popitem()", "copy()", and "update()"
behaving similar to those for Python’s standard dictionary objects.
The "collections.abc" module provides a "MutableMapping" abstract base
class to help create those methods from a base set of "__getitem__()",
"__setitem__()", "__delitem__()", and "keys()". Mutable sequences
should provide methods "append()", "count()", "index()", "extend()",
"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python
standard list objects.  Finally, sequence types should implement
addition (meaning concatenation) and multiplication (meaning
repetition) by defining the methods "__add__()", "__radd__()",
"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described
below; they should not define other numerical operators.  It is
recommended that both mappings and sequences implement the
"__contains__()" method to allow efficient use of the "in" operator;
for mappings, "in" should search the mapping’s keys; for sequences, it
should search through the values.  It is further recommended that both
mappings and sequences implement the "__iter__()" method to allow
efficient iteration through the container; for mappings, "__iter__()"
should iterate through the object’s keys; for sequences, it should
iterate through the values.

object.__len__(self)

   Called to implement the built-in function "len()".  Should return
   the length of the object, an integer ">=" 0.  Also, an object that
   doesn’t define a "__bool__()" method and whose "__len__()" method
   returns zero is considered to be false in a Boolean context.

   **CPython implementation detail:** In CPython, the length is
   required to be at most "sys.maxsize". If the length is larger than
   "sys.maxsize" some features (such as "len()") may raise
   "OverflowError".  To prevent raising "OverflowError" by truth value
   testing, an object must define a "__bool__()" method.

object.__length_hint__(self)

   Called to implement "operator.length_hint()". Should return an
   estimated length for the object (which may be greater or less than
   the actual length). The length must be an integer ">=" 0. The
   return value may also be "NotImplemented", which is treated the
   same as if the "__length_hint__" method didn’t exist at all. This
   method is purely an optimization and is never required for
   correctness.

   New in version 3.4.

Note:

  Slicing is done exclusively with the following three methods.  A
  call like

     a[1:2] = b

  is translated to

     a[slice(1, 2, None)] = b

  and so forth.  Missing slice items are always filled in with "None".

object.__getitem__(self, key)

   Called to implement evaluation of "self[key]". For sequence types,
   the accepted keys should be integers and slice objects.  Note that
   the special interpretation of negative indexes (if the class wishes
   to emulate a sequence type) is up to the "__getitem__()" method. If
   *key* is of an inappropriate type, "TypeError" may be raised; if of
   a value outside the set of indexes for the sequence (after any
   special interpretation of negative values), "IndexError" should be
   raised. For mapping types, if *key* is missing (not in the
   container), "KeyError" should be raised.

   Note:

     "for" loops expect that an "IndexError" will be raised for
     illegal indexes to allow proper detection of the end of the
     sequence.

object.__setitem__(self, key, value)

   Called to implement assignment to "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support changes to the values for keys, or if new keys
   can be added, or for sequences if elements can be replaced.  The
   same exceptions should be raised for improper *key* values as for
   the "__getitem__()" method.

object.__delitem__(self, key)

   Called to implement deletion of "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support removal of keys, or for sequences if elements
   can be removed from the sequence.  The same exceptions should be
   raised for improper *key* values as for the "__getitem__()" method.

object.__missing__(self, key)

   Called by "dict"."__getitem__()" to implement "self[key]" for dict
   subclasses when key is not in the dictionary.

object.__iter__(self)

   This method is called when an iterator is required for a container.
   This method should return a new iterator object that can iterate
   over all the objects in the container.  For mappings, it should
   iterate over the keys of the container.

   Iterator objects also need to implement this method; they are
   required to return themselves.  For more information on iterator
   objects, see Iterator Types.

object.__reversed__(self)

   Called (if present) by the "reversed()" built-in to implement
   reverse iteration.  It should return a new iterator object that
   iterates over all the objects in the container in reverse order.

   If the "__reversed__()" method is not provided, the "reversed()"
   built-in will fall back to using the sequence protocol ("__len__()"
   and "__getitem__()").  Objects that support the sequence protocol
   should only provide "__reversed__()" if they can provide an
   implementation that is more efficient than the one provided by
   "reversed()".

The membership test operators ("in" and "not in") are normally
implemented as an iteration through a container. However, container
objects can supply the following special method with a more efficient
implementation, which also does not require the object be iterable.

object.__contains__(self, item)

   Called to implement membership test operators.  Should return true
   if *item* is in *self*, false otherwise.  For mapping objects, this
   should consider the keys of the mapping rather than the values or
   the key-item pairs.

   For objects that don’t define "__contains__()", the membership test
   first tries iteration via "__iter__()", then the old sequence
   iteration protocol via "__getitem__()", see this section in the
   language reference.
a�Shifting operations
*******************

The shifting operations have lower priority than the arithmetic
operations:

   shift_expr ::= a_expr | shift_expr ("<<" | ">>") a_expr

These operators accept integers as arguments.  They shift the first
argument to the left or right by the number of bits given by the
second argument.

A right shift by *n* bits is defined as floor division by "pow(2,n)".
A left shift by *n* bits is defined as multiplication with "pow(2,n)".
a�Slicings
********

A slicing selects a range of items in a sequence object (e.g., a
string, tuple or list).  Slicings may be used as expressions or as
targets in assignment or "del" statements.  The syntax for a slicing:

   slicing      ::= primary "[" slice_list "]"
   slice_list   ::= slice_item ("," slice_item)* [","]
   slice_item   ::= expression | proper_slice
   proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]
   lower_bound  ::= expression
   upper_bound  ::= expression
   stride       ::= expression

There is ambiguity in the formal syntax here: anything that looks like
an expression list also looks like a slice list, so any subscription
can be interpreted as a slicing.  Rather than further complicating the
syntax, this is disambiguated by defining that in this case the
interpretation as a subscription takes priority over the
interpretation as a slicing (this is the case if the slice list
contains no proper slice).

The semantics for a slicing are as follows.  The primary is indexed
(using the same "__getitem__()" method as normal subscription) with a
key that is constructed from the slice list, as follows.  If the slice
list contains at least one comma, the key is a tuple containing the
conversion of the slice items; otherwise, the conversion of the lone
slice item is the key.  The conversion of a slice item that is an
expression is that expression.  The conversion of a proper slice is a
slice object (see section The standard type hierarchy) whose "start",
"stop" and "step" attributes are the values of the expressions given
as lower bound, upper bound and stride, respectively, substituting
"None" for missing expressions.
uSpecial Attributes
******************

The implementation adds a few special read-only attributes to several
object types, where they are relevant.  Some of these are not reported
by the "dir()" built-in function.

object.__dict__

   A dictionary or other mapping object used to store an object’s
   (writable) attributes.

instance.__class__

   The class to which a class instance belongs.

class.__bases__

   The tuple of base classes of a class object.

definition.__name__

   The name of the class, function, method, descriptor, or generator
   instance.

definition.__qualname__

   The *qualified name* of the class, function, method, descriptor, or
   generator instance.

   New in version 3.3.

class.__mro__

   This attribute is a tuple of classes that are considered when
   looking for base classes during method resolution.

class.mro()

   This method can be overridden by a metaclass to customize the
   method resolution order for its instances.  It is called at class
   instantiation, and its result is stored in "__mro__".

class.__subclasses__()

   Each class keeps a list of weak references to its immediate
   subclasses.  This method returns a list of all those references
   still alive. Example:

      >>> int.__subclasses__()
      [<class 'bool'>]
u��Special method names
********************

A class can implement certain operations that are invoked by special
syntax (such as arithmetic operations or subscripting and slicing) by
defining methods with special names. This is Python’s approach to
*operator overloading*, allowing classes to define their own behavior
with respect to language operators.  For instance, if a class defines
a method named "__getitem__()", and "x" is an instance of this class,
then "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".
Except where mentioned, attempts to execute an operation raise an
exception when no appropriate method is defined (typically
"AttributeError" or "TypeError").

Setting a special method to "None" indicates that the corresponding
operation is not available.  For example, if a class sets "__iter__()"
to "None", the class is not iterable, so calling "iter()" on its
instances will raise a "TypeError" (without falling back to
"__getitem__()"). [2]

When implementing a class that emulates any built-in type, it is
important that the emulation only be implemented to the degree that it
makes sense for the object being modelled.  For example, some
sequences may work well with retrieval of individual elements, but
extracting a slice may not make sense.  (One example of this is the
"NodeList" interface in the W3C’s Document Object Model.)


Basic customization
===================

object.__new__(cls[, ...])

   Called to create a new instance of class *cls*.  "__new__()" is a
   static method (special-cased so you need not declare it as such)
   that takes the class of which an instance was requested as its
   first argument.  The remaining arguments are those passed to the
   object constructor expression (the call to the class).  The return
   value of "__new__()" should be the new object instance (usually an
   instance of *cls*).

   Typical implementations create a new instance of the class by
   invoking the superclass’s "__new__()" method using
   "super().__new__(cls[, ...])" with appropriate arguments and then
   modifying the newly-created instance as necessary before returning
   it.

   If "__new__()" is invoked during object construction and it returns
   an instance of *cls*, then the new instance’s "__init__()" method
   will be invoked like "__init__(self[, ...])", where *self* is the
   new instance and the remaining arguments are the same as were
   passed to the object constructor.

   If "__new__()" does not return an instance of *cls*, then the new
   instance’s "__init__()" method will not be invoked.

   "__new__()" is intended mainly to allow subclasses of immutable
   types (like int, str, or tuple) to customize instance creation.  It
   is also commonly overridden in custom metaclasses in order to
   customize class creation.

object.__init__(self[, ...])

   Called after the instance has been created (by "__new__()"), but
   before it is returned to the caller.  The arguments are those
   passed to the class constructor expression.  If a base class has an
   "__init__()" method, the derived class’s "__init__()" method, if
   any, must explicitly call it to ensure proper initialization of the
   base class part of the instance; for example:
   "super().__init__([args...])".

   Because "__new__()" and "__init__()" work together in constructing
   objects ("__new__()" to create it, and "__init__()" to customize
   it), no non-"None" value may be returned by "__init__()"; doing so
   will cause a "TypeError" to be raised at runtime.

object.__del__(self)

   Called when the instance is about to be destroyed.  This is also
   called a finalizer or (improperly) a destructor.  If a base class
   has a "__del__()" method, the derived class’s "__del__()" method,
   if any, must explicitly call it to ensure proper deletion of the
   base class part of the instance.

   It is possible (though not recommended!) for the "__del__()" method
   to postpone destruction of the instance by creating a new reference
   to it.  This is called object *resurrection*.  It is
   implementation-dependent whether "__del__()" is called a second
   time when a resurrected object is about to be destroyed; the
   current *CPython* implementation only calls it once.

   It is not guaranteed that "__del__()" methods are called for
   objects that still exist when the interpreter exits.

   Note:

     "del x" doesn’t directly call "x.__del__()" — the former
     decrements the reference count for "x" by one, and the latter is
     only called when "x"’s reference count reaches zero.

   **CPython implementation detail:** It is possible for a reference
   cycle to prevent the reference count of an object from going to
   zero.  In this case, the cycle will be later detected and deleted
   by the *cyclic garbage collector*.  A common cause of reference
   cycles is when an exception has been caught in a local variable.
   The frame’s locals then reference the exception, which references
   its own traceback, which references the locals of all frames caught
   in the traceback.

   See also: Documentation for the "gc" module.

   Warning:

     Due to the precarious circumstances under which "__del__()"
     methods are invoked, exceptions that occur during their execution
     are ignored, and a warning is printed to "sys.stderr" instead.
     In particular:

     * "__del__()" can be invoked when arbitrary code is being
       executed, including from any arbitrary thread.  If "__del__()"
       needs to take a lock or invoke any other blocking resource, it
       may deadlock as the resource may already be taken by the code
       that gets interrupted to execute "__del__()".

     * "__del__()" can be executed during interpreter shutdown.  As a
       consequence, the global variables it needs to access (including
       other modules) may already have been deleted or set to "None".
       Python guarantees that globals whose name begins with a single
       underscore are deleted from their module before other globals
       are deleted; if no other references to such globals exist, this
       may help in assuring that imported modules are still available
       at the time when the "__del__()" method is called.

object.__repr__(self)

   Called by the "repr()" built-in function to compute the “official”
   string representation of an object.  If at all possible, this
   should look like a valid Python expression that could be used to
   recreate an object with the same value (given an appropriate
   environment).  If this is not possible, a string of the form
   "<...some useful description...>" should be returned. The return
   value must be a string object. If a class defines "__repr__()" but
   not "__str__()", then "__repr__()" is also used when an “informal”
   string representation of instances of that class is required.

   This is typically used for debugging, so it is important that the
   representation is information-rich and unambiguous.

object.__str__(self)

   Called by "str(object)" and the built-in functions "format()" and
   "print()" to compute the “informal” or nicely printable string
   representation of an object.  The return value must be a string
   object.

   This method differs from "object.__repr__()" in that there is no
   expectation that "__str__()" return a valid Python expression: a
   more convenient or concise representation can be used.

   The default implementation defined by the built-in type "object"
   calls "object.__repr__()".

object.__bytes__(self)

   Called by bytes to compute a byte-string representation of an
   object. This should return a "bytes" object.

object.__format__(self, format_spec)

   Called by the "format()" built-in function, and by extension,
   evaluation of formatted string literals and the "str.format()"
   method, to produce a “formatted” string representation of an
   object. The *format_spec* argument is a string that contains a
   description of the formatting options desired. The interpretation
   of the *format_spec* argument is up to the type implementing
   "__format__()", however most classes will either delegate
   formatting to one of the built-in types, or use a similar
   formatting option syntax.

   See Format Specification Mini-Language for a description of the
   standard formatting syntax.

   The return value must be a string object.

   Changed in version 3.4: The __format__ method of "object" itself
   raises a "TypeError" if passed any non-empty string.

   Changed in version 3.7: "object.__format__(x, '')" is now
   equivalent to "str(x)" rather than "format(str(self), '')".

object.__lt__(self, other)
object.__le__(self, other)
object.__eq__(self, other)
object.__ne__(self, other)
object.__gt__(self, other)
object.__ge__(self, other)

   These are the so-called “rich comparison” methods. The
   correspondence between operator symbols and method names is as
   follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",
   "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls
   "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".

   A rich comparison method may return the singleton "NotImplemented"
   if it does not implement the operation for a given pair of
   arguments. By convention, "False" and "True" are returned for a
   successful comparison. However, these methods can return any value,
   so if the comparison operator is used in a Boolean context (e.g.,
   in the condition of an "if" statement), Python will call "bool()"
   on the value to determine if the result is true or false.

   By default, "object" implements "__eq__()" by using "is", returning
   "NotImplemented" in the case of a false comparison: "True if x is y
   else NotImplemented". For "__ne__()", by default it delegates to
   "__eq__()" and inverts the result unless it is "NotImplemented".
   There are no other implied relationships among the comparison
   operators or default implementations; for example, the truth of
   "(x<y or x==y)" does not imply "x<=y". To automatically generate
   ordering operations from a single root operation, see
   "functools.total_ordering()".

   See the paragraph on "__hash__()" for some important notes on
   creating *hashable* objects which support custom comparison
   operations and are usable as dictionary keys.

   There are no swapped-argument versions of these methods (to be used
   when the left argument does not support the operation but the right
   argument does); rather, "__lt__()" and "__gt__()" are each other’s
   reflection, "__le__()" and "__ge__()" are each other’s reflection,
   and "__eq__()" and "__ne__()" are their own reflection. If the
   operands are of different types, and right operand’s type is a
   direct or indirect subclass of the left operand’s type, the
   reflected method of the right operand has priority, otherwise the
   left operand’s method has priority.  Virtual subclassing is not
   considered.

object.__hash__(self)

   Called by built-in function "hash()" and for operations on members
   of hashed collections including "set", "frozenset", and "dict".
   "__hash__()" should return an integer. The only required property
   is that objects which compare equal have the same hash value; it is
   advised to mix together the hash values of the components of the
   object that also play a part in comparison of objects by packing
   them into a tuple and hashing the tuple. Example:

      def __hash__(self):
          return hash((self.name, self.nick, self.color))

   Note:

     "hash()" truncates the value returned from an object’s custom
     "__hash__()" method to the size of a "Py_ssize_t".  This is
     typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds.
     If an object’s   "__hash__()" must interoperate on builds of
     different bit sizes, be sure to check the width on all supported
     builds.  An easy way to do this is with "python -c "import sys;
     print(sys.hash_info.width)"".

   If a class does not define an "__eq__()" method it should not
   define a "__hash__()" operation either; if it defines "__eq__()"
   but not "__hash__()", its instances will not be usable as items in
   hashable collections.  If a class defines mutable objects and
   implements an "__eq__()" method, it should not implement
   "__hash__()", since the implementation of hashable collections
   requires that a key’s hash value is immutable (if the object’s hash
   value changes, it will be in the wrong hash bucket).

   User-defined classes have "__eq__()" and "__hash__()" methods by
   default; with them, all objects compare unequal (except with
   themselves) and "x.__hash__()" returns an appropriate value such
   that "x == y" implies both that "x is y" and "hash(x) == hash(y)".

   A class that overrides "__eq__()" and does not define "__hash__()"
   will have its "__hash__()" implicitly set to "None".  When the
   "__hash__()" method of a class is "None", instances of the class
   will raise an appropriate "TypeError" when a program attempts to
   retrieve their hash value, and will also be correctly identified as
   unhashable when checking "isinstance(obj,
   collections.abc.Hashable)".

   If a class that overrides "__eq__()" needs to retain the
   implementation of "__hash__()" from a parent class, the interpreter
   must be told this explicitly by setting "__hash__ =
   <ParentClass>.__hash__".

   If a class that does not override "__eq__()" wishes to suppress
   hash support, it should include "__hash__ = None" in the class
   definition. A class which defines its own "__hash__()" that
   explicitly raises a "TypeError" would be incorrectly identified as
   hashable by an "isinstance(obj, collections.abc.Hashable)" call.

   Note:

     By default, the "__hash__()" values of str and bytes objects are
     “salted” with an unpredictable random value.  Although they
     remain constant within an individual Python process, they are not
     predictable between repeated invocations of Python.This is
     intended to provide protection against a denial-of-service caused
     by carefully-chosen inputs that exploit the worst case
     performance of a dict insertion, O(n^2) complexity.  See
     http://www.ocert.org/advisories/ocert-2011-003.html for
     details.Changing hash values affects the iteration order of sets.
     Python has never made guarantees about this ordering (and it
     typically varies between 32-bit and 64-bit builds).See also
     "PYTHONHASHSEED".

   Changed in version 3.3: Hash randomization is enabled by default.

object.__bool__(self)

   Called to implement truth value testing and the built-in operation
   "bool()"; should return "False" or "True".  When this method is not
   defined, "__len__()" is called, if it is defined, and the object is
   considered true if its result is nonzero.  If a class defines
   neither "__len__()" nor "__bool__()", all its instances are
   considered true.


Customizing attribute access
============================

The following methods can be defined to customize the meaning of
attribute access (use of, assignment to, or deletion of "x.name") for
class instances.

object.__getattr__(self, name)

   Called when the default attribute access fails with an
   "AttributeError" (either "__getattribute__()" raises an
   "AttributeError" because *name* is not an instance attribute or an
   attribute in the class tree for "self"; or "__get__()" of a *name*
   property raises "AttributeError").  This method should either
   return the (computed) attribute value or raise an "AttributeError"
   exception.

   Note that if the attribute is found through the normal mechanism,
   "__getattr__()" is not called.  (This is an intentional asymmetry
   between "__getattr__()" and "__setattr__()".) This is done both for
   efficiency reasons and because otherwise "__getattr__()" would have
   no way to access other attributes of the instance.  Note that at
   least for instance variables, you can fake total control by not
   inserting any values in the instance attribute dictionary (but
   instead inserting them in another object).  See the
   "__getattribute__()" method below for a way to actually get total
   control over attribute access.

object.__getattribute__(self, name)

   Called unconditionally to implement attribute accesses for
   instances of the class. If the class also defines "__getattr__()",
   the latter will not be called unless "__getattribute__()" either
   calls it explicitly or raises an "AttributeError". This method
   should return the (computed) attribute value or raise an
   "AttributeError" exception. In order to avoid infinite recursion in
   this method, its implementation should always call the base class
   method with the same name to access any attributes it needs, for
   example, "object.__getattribute__(self, name)".

   Note:

     This method may still be bypassed when looking up special methods
     as the result of implicit invocation via language syntax or
     built-in functions. See Special method lookup.

   For certain sensitive attribute accesses, raises an auditing event
   "object.__getattr__" with arguments "obj" and "name".

object.__setattr__(self, name, value)

   Called when an attribute assignment is attempted.  This is called
   instead of the normal mechanism (i.e. store the value in the
   instance dictionary). *name* is the attribute name, *value* is the
   value to be assigned to it.

   If "__setattr__()" wants to assign to an instance attribute, it
   should call the base class method with the same name, for example,
   "object.__setattr__(self, name, value)".

   For certain sensitive attribute assignments, raises an auditing
   event "object.__setattr__" with arguments "obj", "name", "value".

object.__delattr__(self, name)

   Like "__setattr__()" but for attribute deletion instead of
   assignment.  This should only be implemented if "del obj.name" is
   meaningful for the object.

   For certain sensitive attribute deletions, raises an auditing event
   "object.__delattr__" with arguments "obj" and "name".

object.__dir__(self)

   Called when "dir()" is called on the object. A sequence must be
   returned. "dir()" converts the returned sequence to a list and
   sorts it.


Customizing module attribute access
-----------------------------------

Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
attribute and return the computed value or raise an "AttributeError".
If an attribute is not found on a module object through the normal
lookup, i.e. "object.__getattribute__()", then "__getattr__" is
searched in the module "__dict__" before raising an "AttributeError".
If found, it is called with the attribute name and the result is
returned.

The "__dir__" function should accept no arguments, and return a
sequence of strings that represents the names accessible on module. If
present, this function overrides the standard "dir()" search on a
module.

For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:

   import sys
   from types import ModuleType

   class VerboseModule(ModuleType):
       def __repr__(self):
           return f'Verbose {self.__name__}'

       def __setattr__(self, attr, value):
           print(f'Setting {attr}...')
           super().__setattr__(attr, value)

   sys.modules[__name__].__class__ = VerboseModule

Note:

  Defining module "__getattr__" and setting module "__class__" only
  affect lookups made using the attribute access syntax – directly
  accessing the module globals (whether by code within the module, or
  via a reference to the module’s globals dictionary) is unaffected.

Changed in version 3.5: "__class__" module attribute is now writable.

New in version 3.7: "__getattr__" and "__dir__" module attributes.

See also:

  **PEP 562** - Module __getattr__ and __dir__
     Describes the "__getattr__" and "__dir__" functions on modules.


Implementing Descriptors
------------------------

The following methods only apply when an instance of the class
containing the method (a so-called *descriptor* class) appears in an
*owner* class (the descriptor must be in either the owner’s class
dictionary or in the class dictionary for one of its parents).  In the
examples below, “the attribute” refers to the attribute whose name is
the key of the property in the owner class’ "__dict__".

object.__get__(self, instance, owner=None)

   Called to get the attribute of the owner class (class attribute
   access) or of an instance of that class (instance attribute
   access). The optional *owner* argument is the owner class, while
   *instance* is the instance that the attribute was accessed through,
   or "None" when the attribute is accessed through the *owner*.

   This method should return the computed attribute value or raise an
   "AttributeError" exception.

   **PEP 252** specifies that "__get__()" is callable with one or two
   arguments.  Python’s own built-in descriptors support this
   specification; however, it is likely that some third-party tools
   have descriptors that require both arguments.  Python’s own
   "__getattribute__()" implementation always passes in both arguments
   whether they are required or not.

object.__set__(self, instance, value)

   Called to set the attribute on an instance *instance* of the owner
   class to a new value, *value*.

   Note, adding "__set__()" or "__delete__()" changes the kind of
   descriptor to a “data descriptor”.  See Invoking Descriptors for
   more details.

object.__delete__(self, instance)

   Called to delete the attribute on an instance *instance* of the
   owner class.

object.__set_name__(self, owner, name)

   Called at the time the owning class *owner* is created. The
   descriptor has been assigned to *name*.

   Note:

     "__set_name__()" is only called implicitly as part of the "type"
     constructor, so it will need to be called explicitly with the
     appropriate parameters when a descriptor is added to a class
     after initial creation:

        class A:
           pass
        descr = custom_descriptor()
        A.attr = descr
        descr.__set_name__(A, 'attr')

     See Creating the class object for more details.

   New in version 3.6.

The attribute "__objclass__" is interpreted by the "inspect" module as
specifying the class where this object was defined (setting this
appropriately can assist in runtime introspection of dynamic class
attributes). For callables, it may indicate that an instance of the
given type (or a subclass) is expected or required as the first
positional argument (for example, CPython sets this attribute for
unbound methods that are implemented in C).


Invoking Descriptors
--------------------

In general, a descriptor is an object attribute with “binding
behavior”, one whose attribute access has been overridden by methods
in the descriptor protocol:  "__get__()", "__set__()", and
"__delete__()". If any of those methods are defined for an object, it
is said to be a descriptor.

The default behavior for attribute access is to get, set, or delete
the attribute from an object’s dictionary. For instance, "a.x" has a
lookup chain starting with "a.__dict__['x']", then
"type(a).__dict__['x']", and continuing through the base classes of
"type(a)" excluding metaclasses.

However, if the looked-up value is an object defining one of the
descriptor methods, then Python may override the default behavior and
invoke the descriptor method instead.  Where this occurs in the
precedence chain depends on which descriptor methods were defined and
how they were called.

The starting point for descriptor invocation is a binding, "a.x". How
the arguments are assembled depends on "a":

Direct Call
   The simplest and least common call is when user code directly
   invokes a descriptor method:    "x.__get__(a)".

Instance Binding
   If binding to an object instance, "a.x" is transformed into the
   call: "type(a).__dict__['x'].__get__(a, type(a))".

Class Binding
   If binding to a class, "A.x" is transformed into the call:
   "A.__dict__['x'].__get__(None, A)".

Super Binding
   If "a" is an instance of "super", then the binding "super(B,
   obj).m()" searches "obj.__class__.__mro__" for the base class "A"
   immediately preceding "B" and then invokes the descriptor with the
   call: "A.__dict__['m'].__get__(obj, obj.__class__)".

For instance bindings, the precedence of descriptor invocation depends
on which descriptor methods are defined.  A descriptor can define any
combination of "__get__()", "__set__()" and "__delete__()".  If it
does not define "__get__()", then accessing the attribute will return
the descriptor object itself unless there is a value in the object’s
instance dictionary.  If the descriptor defines "__set__()" and/or
"__delete__()", it is a data descriptor; if it defines neither, it is
a non-data descriptor.  Normally, data descriptors define both
"__get__()" and "__set__()", while non-data descriptors have just the
"__get__()" method.  Data descriptors with "__set__()" and "__get__()"
defined always override a redefinition in an instance dictionary.  In
contrast, non-data descriptors can be overridden by instances.

Python methods (including "staticmethod()" and "classmethod()") are
implemented as non-data descriptors.  Accordingly, instances can
redefine and override methods.  This allows individual instances to
acquire behaviors that differ from other instances of the same class.

The "property()" function is implemented as a data descriptor.
Accordingly, instances cannot override the behavior of a property.


__slots__
---------

*__slots__* allow us to explicitly declare data members (like
properties) and deny the creation of *__dict__* and *__weakref__*
(unless explicitly declared in *__slots__* or available in a parent.)

The space saved over using *__dict__* can be significant. Attribute
lookup speed can be significantly improved as well.

object.__slots__

   This class variable can be assigned a string, iterable, or sequence
   of strings with variable names used by instances.  *__slots__*
   reserves space for the declared variables and prevents the
   automatic creation of *__dict__* and *__weakref__* for each
   instance.


Notes on using *__slots__*
~~~~~~~~~~~~~~~~~~~~~~~~~~

* When inheriting from a class without *__slots__*, the *__dict__* and
  *__weakref__* attribute of the instances will always be accessible.

* Without a *__dict__* variable, instances cannot be assigned new
  variables not listed in the *__slots__* definition.  Attempts to
  assign to an unlisted variable name raises "AttributeError". If
  dynamic assignment of new variables is desired, then add
  "'__dict__'" to the sequence of strings in the *__slots__*
  declaration.

* Without a *__weakref__* variable for each instance, classes defining
  *__slots__* do not support weak references to its instances. If weak
  reference support is needed, then add "'__weakref__'" to the
  sequence of strings in the *__slots__* declaration.

* *__slots__* are implemented at the class level by creating
  descriptors (Implementing Descriptors) for each variable name.  As a
  result, class attributes cannot be used to set default values for
  instance variables defined by *__slots__*; otherwise, the class
  attribute would overwrite the descriptor assignment.

* The action of a *__slots__* declaration is not limited to the class
  where it is defined.  *__slots__* declared in parents are available
  in child classes. However, child subclasses will get a *__dict__*
  and *__weakref__* unless they also define *__slots__* (which should
  only contain names of any *additional* slots).

* If a class defines a slot also defined in a base class, the instance
  variable defined by the base class slot is inaccessible (except by
  retrieving its descriptor directly from the base class). This
  renders the meaning of the program undefined.  In the future, a
  check may be added to prevent this.

* Nonempty *__slots__* does not work for classes derived from
  “variable-length” built-in types such as "int", "bytes" and "tuple".

* Any non-string iterable may be assigned to *__slots__*. Mappings may
  also be used; however, in the future, special meaning may be
  assigned to the values corresponding to each key.

* *__class__* assignment works only if both classes have the same
  *__slots__*.

* Multiple inheritance with multiple slotted parent classes can be
  used, but only one parent is allowed to have attributes created by
  slots (the other bases must have empty slot layouts) - violations
  raise "TypeError".

* If an iterator is used for *__slots__* then a descriptor is created
  for each of the iterator’s values. However, the *__slots__*
  attribute will be an empty iterator.


Customizing class creation
==========================

Whenever a class inherits from another class, *__init_subclass__* is
called on that class. This way, it is possible to write classes which
change the behavior of subclasses. This is closely related to class
decorators, but where class decorators only affect the specific class
they’re applied to, "__init_subclass__" solely applies to future
subclasses of the class defining the method.

classmethod object.__init_subclass__(cls)

   This method is called whenever the containing class is subclassed.
   *cls* is then the new subclass. If defined as a normal instance
   method, this method is implicitly converted to a class method.

   Keyword arguments which are given to a new class are passed to the
   parent’s class "__init_subclass__". For compatibility with other
   classes using "__init_subclass__", one should take out the needed
   keyword arguments and pass the others over to the base class, as
   in:

      class Philosopher:
          def __init_subclass__(cls, /, default_name, **kwargs):
              super().__init_subclass__(**kwargs)
              cls.default_name = default_name

      class AustralianPhilosopher(Philosopher, default_name="Bruce"):
          pass

   The default implementation "object.__init_subclass__" does nothing,
   but raises an error if it is called with any arguments.

   Note:

     The metaclass hint "metaclass" is consumed by the rest of the
     type machinery, and is never passed to "__init_subclass__"
     implementations. The actual metaclass (rather than the explicit
     hint) can be accessed as "type(cls)".

   New in version 3.6.


Metaclasses
-----------

By default, classes are constructed using "type()". The class body is
executed in a new namespace and the class name is bound locally to the
result of "type(name, bases, namespace)".

The class creation process can be customized by passing the
"metaclass" keyword argument in the class definition line, or by
inheriting from an existing class that included such an argument. In
the following example, both "MyClass" and "MySubclass" are instances
of "Meta":

   class Meta(type):
       pass

   class MyClass(metaclass=Meta):
       pass

   class MySubclass(MyClass):
       pass

Any other keyword arguments that are specified in the class definition
are passed through to all metaclass operations described below.

When a class definition is executed, the following steps occur:

* MRO entries are resolved;

* the appropriate metaclass is determined;

* the class namespace is prepared;

* the class body is executed;

* the class object is created.


Resolving MRO entries
---------------------

If a base that appears in class definition is not an instance of
"type", then an "__mro_entries__" method is searched on it. If found,
it is called with the original bases tuple. This method must return a
tuple of classes that will be used instead of this base. The tuple may
be empty, in such case the original base is ignored.

See also:

  **PEP 560** - Core support for typing module and generic types


Determining the appropriate metaclass
-------------------------------------

The appropriate metaclass for a class definition is determined as
follows:

* if no bases and no explicit metaclass are given, then "type()" is
  used;

* if an explicit metaclass is given and it is *not* an instance of
  "type()", then it is used directly as the metaclass;

* if an instance of "type()" is given as the explicit metaclass, or
  bases are defined, then the most derived metaclass is used.

The most derived metaclass is selected from the explicitly specified
metaclass (if any) and the metaclasses (i.e. "type(cls)") of all
specified base classes. The most derived metaclass is one which is a
subtype of *all* of these candidate metaclasses. If none of the
candidate metaclasses meets that criterion, then the class definition
will fail with "TypeError".


Preparing the class namespace
-----------------------------

Once the appropriate metaclass has been identified, then the class
namespace is prepared. If the metaclass has a "__prepare__" attribute,
it is called as "namespace = metaclass.__prepare__(name, bases,
**kwds)" (where the additional keyword arguments, if any, come from
the class definition). The "__prepare__" method should be implemented
as a "classmethod()". The namespace returned by "__prepare__" is
passed in to "__new__", but when the final class object is created the
namespace is copied into a new "dict".

If the metaclass has no "__prepare__" attribute, then the class
namespace is initialised as an empty ordered mapping.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     Introduced the "__prepare__" namespace hook


Executing the class body
------------------------

The class body is executed (approximately) as "exec(body, globals(),
namespace)". The key difference from a normal call to "exec()" is that
lexical scoping allows the class body (including any methods) to
reference names from the current and outer scopes when the class
definition occurs inside a function.

However, even when the class definition occurs inside the function,
methods defined inside the class still cannot see names defined at the
class scope. Class variables must be accessed through the first
parameter of instance or class methods, or through the implicit
lexically scoped "__class__" reference described in the next section.


Creating the class object
-------------------------

Once the class namespace has been populated by executing the class
body, the class object is created by calling "metaclass(name, bases,
namespace, **kwds)" (the additional keywords passed here are the same
as those passed to "__prepare__").

This class object is the one that will be referenced by the zero-
argument form of "super()". "__class__" is an implicit closure
reference created by the compiler if any methods in a class body refer
to either "__class__" or "super". This allows the zero argument form
of "super()" to correctly identify the class being defined based on
lexical scoping, while the class or instance that was used to make the
current call is identified based on the first argument passed to the
method.

**CPython implementation detail:** In CPython 3.6 and later, the
"__class__" cell is passed to the metaclass as a "__classcell__" entry
in the class namespace. If present, this must be propagated up to the
"type.__new__" call in order for the class to be initialised
correctly. Failing to do so will result in a "RuntimeError" in Python
3.8.

When using the default metaclass "type", or any metaclass that
ultimately calls "type.__new__", the following additional
customisation steps are invoked after creating the class object:

* first, "type.__new__" collects all of the descriptors in the class
  namespace that define a "__set_name__()" method;

* second, all of these "__set_name__" methods are called with the
  class being defined and the assigned name of that particular
  descriptor;

* finally, the "__init_subclass__()" hook is called on the immediate
  parent of the new class in its method resolution order.

After the class object is created, it is passed to the class
decorators included in the class definition (if any) and the resulting
object is bound in the local namespace as the defined class.

When a new class is created by "type.__new__", the object provided as
the namespace parameter is copied to a new ordered mapping and the
original object is discarded. The new copy is wrapped in a read-only
proxy, which becomes the "__dict__" attribute of the class object.

See also:

  **PEP 3135** - New super
     Describes the implicit "__class__" closure reference


Uses for metaclasses
--------------------

The potential uses for metaclasses are boundless. Some ideas that have
been explored include enum, logging, interface checking, automatic
delegation, automatic property creation, proxies, frameworks, and
automatic resource locking/synchronization.


Customizing instance and subclass checks
========================================

The following methods are used to override the default behavior of the
"isinstance()" and "issubclass()" built-in functions.

In particular, the metaclass "abc.ABCMeta" implements these methods in
order to allow the addition of Abstract Base Classes (ABCs) as
“virtual base classes” to any class or type (including built-in
types), including other ABCs.

class.__instancecheck__(self, instance)

   Return true if *instance* should be considered a (direct or
   indirect) instance of *class*. If defined, called to implement
   "isinstance(instance, class)".

class.__subclasscheck__(self, subclass)

   Return true if *subclass* should be considered a (direct or
   indirect) subclass of *class*.  If defined, called to implement
   "issubclass(subclass, class)".

Note that these methods are looked up on the type (metaclass) of a
class.  They cannot be defined as class methods in the actual class.
This is consistent with the lookup of special methods that are called
on instances, only in this case the instance is itself a class.

See also:

  **PEP 3119** - Introducing Abstract Base Classes
     Includes the specification for customizing "isinstance()" and
     "issubclass()" behavior through "__instancecheck__()" and
     "__subclasscheck__()", with motivation for this functionality in
     the context of adding Abstract Base Classes (see the "abc"
     module) to the language.


Emulating generic types
=======================

One can implement the generic class syntax as specified by **PEP 484**
(for example "List[int]") by defining a special method:

classmethod object.__class_getitem__(cls, key)

   Return an object representing the specialization of a generic class
   by type arguments found in *key*.

This method is looked up on the class object itself, and when defined
in the class body, this method is implicitly a class method.  Note,
this mechanism is primarily reserved for use with static type hints,
other usage is discouraged.

See also:

  **PEP 560** - Core support for typing module and generic types


Emulating callable objects
==========================

object.__call__(self[, args...])

   Called when the instance is “called” as a function; if this method
   is defined, "x(arg1, arg2, ...)" roughly translates to
   "type(x).__call__(x, arg1, ...)".


Emulating container types
=========================

The following methods can be defined to implement container objects.
Containers usually are sequences (such as lists or tuples) or mappings
(like dictionaries), but can represent other containers as well.  The
first set of methods is used either to emulate a sequence or to
emulate a mapping; the difference is that for a sequence, the
allowable keys should be the integers *k* for which "0 <= k < N" where
*N* is the length of the sequence, or slice objects, which define a
range of items.  It is also recommended that mappings provide the
methods "keys()", "values()", "items()", "get()", "clear()",
"setdefault()", "pop()", "popitem()", "copy()", and "update()"
behaving similar to those for Python’s standard dictionary objects.
The "collections.abc" module provides a "MutableMapping" abstract base
class to help create those methods from a base set of "__getitem__()",
"__setitem__()", "__delitem__()", and "keys()". Mutable sequences
should provide methods "append()", "count()", "index()", "extend()",
"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python
standard list objects.  Finally, sequence types should implement
addition (meaning concatenation) and multiplication (meaning
repetition) by defining the methods "__add__()", "__radd__()",
"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described
below; they should not define other numerical operators.  It is
recommended that both mappings and sequences implement the
"__contains__()" method to allow efficient use of the "in" operator;
for mappings, "in" should search the mapping’s keys; for sequences, it
should search through the values.  It is further recommended that both
mappings and sequences implement the "__iter__()" method to allow
efficient iteration through the container; for mappings, "__iter__()"
should iterate through the object’s keys; for sequences, it should
iterate through the values.

object.__len__(self)

   Called to implement the built-in function "len()".  Should return
   the length of the object, an integer ">=" 0.  Also, an object that
   doesn’t define a "__bool__()" method and whose "__len__()" method
   returns zero is considered to be false in a Boolean context.

   **CPython implementation detail:** In CPython, the length is
   required to be at most "sys.maxsize". If the length is larger than
   "sys.maxsize" some features (such as "len()") may raise
   "OverflowError".  To prevent raising "OverflowError" by truth value
   testing, an object must define a "__bool__()" method.

object.__length_hint__(self)

   Called to implement "operator.length_hint()". Should return an
   estimated length for the object (which may be greater or less than
   the actual length). The length must be an integer ">=" 0. The
   return value may also be "NotImplemented", which is treated the
   same as if the "__length_hint__" method didn’t exist at all. This
   method is purely an optimization and is never required for
   correctness.

   New in version 3.4.

Note:

  Slicing is done exclusively with the following three methods.  A
  call like

     a[1:2] = b

  is translated to

     a[slice(1, 2, None)] = b

  and so forth.  Missing slice items are always filled in with "None".

object.__getitem__(self, key)

   Called to implement evaluation of "self[key]". For sequence types,
   the accepted keys should be integers and slice objects.  Note that
   the special interpretation of negative indexes (if the class wishes
   to emulate a sequence type) is up to the "__getitem__()" method. If
   *key* is of an inappropriate type, "TypeError" may be raised; if of
   a value outside the set of indexes for the sequence (after any
   special interpretation of negative values), "IndexError" should be
   raised. For mapping types, if *key* is missing (not in the
   container), "KeyError" should be raised.

   Note:

     "for" loops expect that an "IndexError" will be raised for
     illegal indexes to allow proper detection of the end of the
     sequence.

object.__setitem__(self, key, value)

   Called to implement assignment to "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support changes to the values for keys, or if new keys
   can be added, or for sequences if elements can be replaced.  The
   same exceptions should be raised for improper *key* values as for
   the "__getitem__()" method.

object.__delitem__(self, key)

   Called to implement deletion of "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support removal of keys, or for sequences if elements
   can be removed from the sequence.  The same exceptions should be
   raised for improper *key* values as for the "__getitem__()" method.

object.__missing__(self, key)

   Called by "dict"."__getitem__()" to implement "self[key]" for dict
   subclasses when key is not in the dictionary.

object.__iter__(self)

   This method is called when an iterator is required for a container.
   This method should return a new iterator object that can iterate
   over all the objects in the container.  For mappings, it should
   iterate over the keys of the container.

   Iterator objects also need to implement this method; they are
   required to return themselves.  For more information on iterator
   objects, see Iterator Types.

object.__reversed__(self)

   Called (if present) by the "reversed()" built-in to implement
   reverse iteration.  It should return a new iterator object that
   iterates over all the objects in the container in reverse order.

   If the "__reversed__()" method is not provided, the "reversed()"
   built-in will fall back to using the sequence protocol ("__len__()"
   and "__getitem__()").  Objects that support the sequence protocol
   should only provide "__reversed__()" if they can provide an
   implementation that is more efficient than the one provided by
   "reversed()".

The membership test operators ("in" and "not in") are normally
implemented as an iteration through a container. However, container
objects can supply the following special method with a more efficient
implementation, which also does not require the object be iterable.

object.__contains__(self, item)

   Called to implement membership test operators.  Should return true
   if *item* is in *self*, false otherwise.  For mapping objects, this
   should consider the keys of the mapping rather than the values or
   the key-item pairs.

   For objects that don’t define "__contains__()", the membership test
   first tries iteration via "__iter__()", then the old sequence
   iteration protocol via "__getitem__()", see this section in the
   language reference.


Emulating numeric types
=======================

The following methods can be defined to emulate numeric objects.
Methods corresponding to operations that are not supported by the
particular kind of number implemented (e.g., bitwise operations for
non-integral numbers) should be left undefined.

object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
object.__matmul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
object.__divmod__(self, other)
object.__pow__(self, other[, modulo])
object.__lshift__(self, other)
object.__rshift__(self, other)
object.__and__(self, other)
object.__xor__(self, other)
object.__or__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|").  For instance, to
   evaluate the expression "x + y", where *x* is an instance of a
   class that has an "__add__()" method, "x.__add__(y)" is called.
   The "__divmod__()" method should be the equivalent to using
   "__floordiv__()" and "__mod__()"; it should not be related to
   "__truediv__()".  Note that "__pow__()" should be defined to accept
   an optional third argument if the ternary version of the built-in
   "pow()" function is to be supported.

   If one of those methods does not support the operation with the
   supplied arguments, it should return "NotImplemented".

object.__radd__(self, other)
object.__rsub__(self, other)
object.__rmul__(self, other)
object.__rmatmul__(self, other)
object.__rtruediv__(self, other)
object.__rfloordiv__(self, other)
object.__rmod__(self, other)
object.__rdivmod__(self, other)
object.__rpow__(self, other[, modulo])
object.__rlshift__(self, other)
object.__rrshift__(self, other)
object.__rand__(self, other)
object.__rxor__(self, other)
object.__ror__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)
   operands.  These functions are only called if the left operand does
   not support the corresponding operation [3] and the operands are of
   different types. [4] For instance, to evaluate the expression "x -
   y", where *y* is an instance of a class that has an "__rsub__()"
   method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns
   *NotImplemented*.

   Note that ternary "pow()" will not try calling "__rpow__()" (the
   coercion rules would become too complicated).

   Note:

     If the right operand’s type is a subclass of the left operand’s
     type and that subclass provides a different implementation of the
     reflected method for the operation, this method will be called
     before the left operand’s non-reflected method. This behavior
     allows subclasses to override their ancestors’ operations.

object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
object.__imatmul__(self, other)
object.__itruediv__(self, other)
object.__ifloordiv__(self, other)
object.__imod__(self, other)
object.__ipow__(self, other[, modulo])
object.__ilshift__(self, other)
object.__irshift__(self, other)
object.__iand__(self, other)
object.__ixor__(self, other)
object.__ior__(self, other)

   These methods are called to implement the augmented arithmetic
   assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",
   "<<=", ">>=", "&=", "^=", "|=").  These methods should attempt to
   do the operation in-place (modifying *self*) and return the result
   (which could be, but does not have to be, *self*).  If a specific
   method is not defined, the augmented assignment falls back to the
   normal methods.  For instance, if *x* is an instance of a class
   with an "__iadd__()" method, "x += y" is equivalent to "x =
   x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are
   considered, as with the evaluation of "x + y". In certain
   situations, augmented assignment can result in unexpected errors
   (see Why does a_tuple[i] += [‘item’] raise an exception when the
   addition works?), but this behavior is in fact part of the data
   model.

   Note:

     Due to a bug in the dispatching mechanism for "**=", a class that
     defines "__ipow__()" but returns "NotImplemented" would fail to
     fall back to "x.__pow__(y)" and "y.__rpow__(x)". This bug is
     fixed in Python 3.10.

object.__neg__(self)
object.__pos__(self)
object.__abs__(self)
object.__invert__(self)

   Called to implement the unary arithmetic operations ("-", "+",
   "abs()" and "~").

object.__complex__(self)
object.__int__(self)
object.__float__(self)

   Called to implement the built-in functions "complex()", "int()" and
   "float()".  Should return a value of the appropriate type.

object.__index__(self)

   Called to implement "operator.index()", and whenever Python needs
   to losslessly convert the numeric object to an integer object (such
   as in slicing, or in the built-in "bin()", "hex()" and "oct()"
   functions). Presence of this method indicates that the numeric
   object is an integer type.  Must return an integer.

   If "__int__()", "__float__()" and "__complex__()" are not defined
   then corresponding built-in functions "int()", "float()" and
   "complex()" fall back to "__index__()".

object.__round__(self[, ndigits])
object.__trunc__(self)
object.__floor__(self)
object.__ceil__(self)

   Called to implement the built-in function "round()" and "math"
   functions "trunc()", "floor()" and "ceil()". Unless *ndigits* is
   passed to "__round__()" all these methods should return the value
   of the object truncated to an "Integral" (typically an "int").

   The built-in function "int()" falls back to "__trunc__()" if
   neither "__int__()" nor "__index__()" is defined.


With Statement Context Managers
===============================

A *context manager* is an object that defines the runtime context to
be established when executing a "with" statement. The context manager
handles the entry into, and the exit from, the desired runtime context
for the execution of the block of code.  Context managers are normally
invoked using the "with" statement (described in section The with
statement), but can also be used by directly invoking their methods.

Typical uses of context managers include saving and restoring various
kinds of global state, locking and unlocking resources, closing opened
files, etc.

For more information on context managers, see Context Manager Types.

object.__enter__(self)

   Enter the runtime context related to this object. The "with"
   statement will bind this method’s return value to the target(s)
   specified in the "as" clause of the statement, if any.

object.__exit__(self, exc_type, exc_value, traceback)

   Exit the runtime context related to this object. The parameters
   describe the exception that caused the context to be exited. If the
   context was exited without an exception, all three arguments will
   be "None".

   If an exception is supplied, and the method wishes to suppress the
   exception (i.e., prevent it from being propagated), it should
   return a true value. Otherwise, the exception will be processed
   normally upon exit from this method.

   Note that "__exit__()" methods should not reraise the passed-in
   exception; this is the caller’s responsibility.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.


Special method lookup
=====================

For custom classes, implicit invocations of special methods are only
guaranteed to work correctly if defined on an object’s type, not in
the object’s instance dictionary.  That behaviour is the reason why
the following code raises an exception:

   >>> class C:
   ...     pass
   ...
   >>> c = C()
   >>> c.__len__ = lambda: 5
   >>> len(c)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: object of type 'C' has no len()

The rationale behind this behaviour lies with a number of special
methods such as "__hash__()" and "__repr__()" that are implemented by
all objects, including type objects. If the implicit lookup of these
methods used the conventional lookup process, they would fail when
invoked on the type object itself:

   >>> 1 .__hash__() == hash(1)
   True
   >>> int.__hash__() == hash(int)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: descriptor '__hash__' of 'int' object needs an argument

Incorrectly attempting to invoke an unbound method of a class in this
way is sometimes referred to as ‘metaclass confusion’, and is avoided
by bypassing the instance when looking up special methods:

   >>> type(1).__hash__(1) == hash(1)
   True
   >>> type(int).__hash__(int) == hash(int)
   True

In addition to bypassing any instance attributes in the interest of
correctness, implicit special method lookup generally also bypasses
the "__getattribute__()" method even of the object’s metaclass:

   >>> class Meta(type):
   ...     def __getattribute__(*args):
   ...         print("Metaclass getattribute invoked")
   ...         return type.__getattribute__(*args)
   ...
   >>> class C(object, metaclass=Meta):
   ...     def __len__(self):
   ...         return 10
   ...     def __getattribute__(*args):
   ...         print("Class getattribute invoked")
   ...         return object.__getattribute__(*args)
   ...
   >>> c = C()
   >>> c.__len__()                 # Explicit lookup via instance
   Class getattribute invoked
   10
   >>> type(c).__len__(c)          # Explicit lookup via type
   Metaclass getattribute invoked
   10
   >>> len(c)                      # Implicit lookup
   10

Bypassing the "__getattribute__()" machinery in this fashion provides
significant scope for speed optimisations within the interpreter, at
the cost of some flexibility in the handling of special methods (the
special method *must* be set on the class object itself in order to be
consistently invoked by the interpreter).
u�YString Methods
**************

Strings implement all of the common sequence operations, along with
the additional methods described below.

Strings also support two styles of string formatting, one providing a
large degree of flexibility and customization (see "str.format()",
Format String Syntax and Custom String Formatting) and the other based
on C "printf" style formatting that handles a narrower range of types
and is slightly harder to use correctly, but is often faster for the
cases it can handle (printf-style String Formatting).

The Text Processing Services section of the standard library covers a
number of other modules that provide various text related utilities
(including regular expression support in the "re" module).

str.capitalize()

   Return a copy of the string with its first character capitalized
   and the rest lowercased.

   Changed in version 3.8: The first character is now put into
   titlecase rather than uppercase. This means that characters like
   digraphs will only have their first letter capitalized, instead of
   the full character.

str.casefold()

   Return a casefolded copy of the string. Casefolded strings may be
   used for caseless matching.

   Casefolding is similar to lowercasing but more aggressive because
   it is intended to remove all case distinctions in a string. For
   example, the German lowercase letter "'ß'" is equivalent to ""ss"".
   Since it is already lowercase, "lower()" would do nothing to "'ß'";
   "casefold()" converts it to ""ss"".

   The casefolding algorithm is described in section 3.13 of the
   Unicode Standard.

   New in version 3.3.

str.center(width[, fillchar])

   Return centered in a string of length *width*. Padding is done
   using the specified *fillchar* (default is an ASCII space). The
   original string is returned if *width* is less than or equal to
   "len(s)".

str.count(sub[, start[, end]])

   Return the number of non-overlapping occurrences of substring *sub*
   in the range [*start*, *end*].  Optional arguments *start* and
   *end* are interpreted as in slice notation.

str.encode(encoding="utf-8", errors="strict")

   Return an encoded version of the string as a bytes object. Default
   encoding is "'utf-8'". *errors* may be given to set a different
   error handling scheme. The default for *errors* is "'strict'",
   meaning that encoding errors raise a "UnicodeError". Other possible
   values are "'ignore'", "'replace'", "'xmlcharrefreplace'",
   "'backslashreplace'" and any other name registered via
   "codecs.register_error()", see section Error Handlers. For a list
   of possible encodings, see section Standard Encodings.

   Changed in version 3.1: Support for keyword arguments added.

str.endswith(suffix[, start[, end]])

   Return "True" if the string ends with the specified *suffix*,
   otherwise return "False".  *suffix* can also be a tuple of suffixes
   to look for.  With optional *start*, test beginning at that
   position.  With optional *end*, stop comparing at that position.

str.expandtabs(tabsize=8)

   Return a copy of the string where all tab characters are replaced
   by one or more spaces, depending on the current column and the
   given tab size.  Tab positions occur every *tabsize* characters
   (default is 8, giving tab positions at columns 0, 8, 16 and so on).
   To expand the string, the current column is set to zero and the
   string is examined character by character.  If the character is a
   tab ("\t"), one or more space characters are inserted in the result
   until the current column is equal to the next tab position. (The
   tab character itself is not copied.)  If the character is a newline
   ("\n") or return ("\r"), it is copied and the current column is
   reset to zero.  Any other character is copied unchanged and the
   current column is incremented by one regardless of how the
   character is represented when printed.

   >>> '01\t012\t0123\t01234'.expandtabs()
   '01      012     0123    01234'
   >>> '01\t012\t0123\t01234'.expandtabs(4)
   '01  012 0123    01234'

str.find(sub[, start[, end]])

   Return the lowest index in the string where substring *sub* is
   found within the slice "s[start:end]".  Optional arguments *start*
   and *end* are interpreted as in slice notation.  Return "-1" if
   *sub* is not found.

   Note:

     The "find()" method should be used only if you need to know the
     position of *sub*.  To check if *sub* is a substring or not, use
     the "in" operator:

        >>> 'Py' in 'Python'
        True

str.format(*args, **kwargs)

   Perform a string formatting operation.  The string on which this
   method is called can contain literal text or replacement fields
   delimited by braces "{}".  Each replacement field contains either
   the numeric index of a positional argument, or the name of a
   keyword argument.  Returns a copy of the string where each
   replacement field is replaced with the string value of the
   corresponding argument.

   >>> "The sum of 1 + 2 is {0}".format(1+2)
   'The sum of 1 + 2 is 3'

   See Format String Syntax for a description of the various
   formatting options that can be specified in format strings.

   Note:

     When formatting a number ("int", "float", "complex",
     "decimal.Decimal" and subclasses) with the "n" type (ex:
     "'{:n}'.format(1234)"), the function temporarily sets the
     "LC_CTYPE" locale to the "LC_NUMERIC" locale to decode
     "decimal_point" and "thousands_sep" fields of "localeconv()" if
     they are non-ASCII or longer than 1 byte, and the "LC_NUMERIC"
     locale is different than the "LC_CTYPE" locale.  This temporary
     change affects other threads.

   Changed in version 3.7: When formatting a number with the "n" type,
   the function sets temporarily the "LC_CTYPE" locale to the
   "LC_NUMERIC" locale in some cases.

str.format_map(mapping)

   Similar to "str.format(**mapping)", except that "mapping" is used
   directly and not copied to a "dict".  This is useful if for example
   "mapping" is a dict subclass:

   >>> class Default(dict):
   ...     def __missing__(self, key):
   ...         return key
   ...
   >>> '{name} was born in {country}'.format_map(Default(name='Guido'))
   'Guido was born in country'

   New in version 3.2.

str.index(sub[, start[, end]])

   Like "find()", but raise "ValueError" when the substring is not
   found.

str.isalnum()

   Return "True" if all characters in the string are alphanumeric and
   there is at least one character, "False" otherwise.  A character
   "c" is alphanumeric if one of the following returns "True":
   "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".

str.isalpha()

   Return "True" if all characters in the string are alphabetic and
   there is at least one character, "False" otherwise.  Alphabetic
   characters are those characters defined in the Unicode character
   database as “Letter”, i.e., those with general category property
   being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”.  Note that this is
   different from the “Alphabetic” property defined in the Unicode
   Standard.

str.isascii()

   Return "True" if the string is empty or all characters in the
   string are ASCII, "False" otherwise. ASCII characters have code
   points in the range U+0000-U+007F.

   New in version 3.7.

str.isdecimal()

   Return "True" if all characters in the string are decimal
   characters and there is at least one character, "False" otherwise.
   Decimal characters are those that can be used to form numbers in
   base 10, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.  Formally a decimal
   character is a character in the Unicode General Category “Nd”.

str.isdigit()

   Return "True" if all characters in the string are digits and there
   is at least one character, "False" otherwise.  Digits include
   decimal characters and digits that need special handling, such as
   the compatibility superscript digits. This covers digits which
   cannot be used to form numbers in base 10, like the Kharosthi
   numbers.  Formally, a digit is a character that has the property
   value Numeric_Type=Digit or Numeric_Type=Decimal.

str.isidentifier()

   Return "True" if the string is a valid identifier according to the
   language definition, section Identifiers and keywords.

   Call "keyword.iskeyword()" to test whether string "s" is a reserved
   identifier, such as "def" and "class".

   Example:

      >>> from keyword import iskeyword

      >>> 'hello'.isidentifier(), iskeyword('hello')
      True, False
      >>> 'def'.isidentifier(), iskeyword('def')
      True, True

str.islower()

   Return "True" if all cased characters [4] in the string are
   lowercase and there is at least one cased character, "False"
   otherwise.

str.isnumeric()

   Return "True" if all characters in the string are numeric
   characters, and there is at least one character, "False" otherwise.
   Numeric characters include digit characters, and all characters
   that have the Unicode numeric value property, e.g. U+2155, VULGAR
   FRACTION ONE FIFTH.  Formally, numeric characters are those with
   the property value Numeric_Type=Digit, Numeric_Type=Decimal or
   Numeric_Type=Numeric.

str.isprintable()

   Return "True" if all characters in the string are printable or the
   string is empty, "False" otherwise.  Nonprintable characters are
   those characters defined in the Unicode character database as
   “Other” or “Separator”, excepting the ASCII space (0x20) which is
   considered printable.  (Note that printable characters in this
   context are those which should not be escaped when "repr()" is
   invoked on a string.  It has no bearing on the handling of strings
   written to "sys.stdout" or "sys.stderr".)

str.isspace()

   Return "True" if there are only whitespace characters in the string
   and there is at least one character, "False" otherwise.

   A character is *whitespace* if in the Unicode character database
   (see "unicodedata"), either its general category is "Zs"
   (“Separator, space”), or its bidirectional class is one of "WS",
   "B", or "S".

str.istitle()

   Return "True" if the string is a titlecased string and there is at
   least one character, for example uppercase characters may only
   follow uncased characters and lowercase characters only cased ones.
   Return "False" otherwise.

str.isupper()

   Return "True" if all cased characters [4] in the string are
   uppercase and there is at least one cased character, "False"
   otherwise.

str.join(iterable)

   Return a string which is the concatenation of the strings in
   *iterable*. A "TypeError" will be raised if there are any non-
   string values in *iterable*, including "bytes" objects.  The
   separator between elements is the string providing this method.

str.ljust(width[, fillchar])

   Return the string left justified in a string of length *width*.
   Padding is done using the specified *fillchar* (default is an ASCII
   space). The original string is returned if *width* is less than or
   equal to "len(s)".

str.lower()

   Return a copy of the string with all the cased characters [4]
   converted to lowercase.

   The lowercasing algorithm used is described in section 3.13 of the
   Unicode Standard.

str.lstrip([chars])

   Return a copy of the string with leading characters removed.  The
   *chars* argument is a string specifying the set of characters to be
   removed.  If omitted or "None", the *chars* argument defaults to
   removing whitespace.  The *chars* argument is not a prefix; rather,
   all combinations of its values are stripped:

      >>> '   spacious   '.lstrip()
      'spacious   '
      >>> 'www.example.com'.lstrip('cmowz.')
      'example.com'

static str.maketrans(x[, y[, z]])

   This static method returns a translation table usable for
   "str.translate()".

   If there is only one argument, it must be a dictionary mapping
   Unicode ordinals (integers) or characters (strings of length 1) to
   Unicode ordinals, strings (of arbitrary lengths) or "None".
   Character keys will then be converted to ordinals.

   If there are two arguments, they must be strings of equal length,
   and in the resulting dictionary, each character in x will be mapped
   to the character at the same position in y.  If there is a third
   argument, it must be a string, whose characters will be mapped to
   "None" in the result.

str.partition(sep)

   Split the string at the first occurrence of *sep*, and return a
   3-tuple containing the part before the separator, the separator
   itself, and the part after the separator.  If the separator is not
   found, return a 3-tuple containing the string itself, followed by
   two empty strings.

str.replace(old, new[, count])

   Return a copy of the string with all occurrences of substring *old*
   replaced by *new*.  If the optional argument *count* is given, only
   the first *count* occurrences are replaced.

str.rfind(sub[, start[, end]])

   Return the highest index in the string where substring *sub* is
   found, such that *sub* is contained within "s[start:end]".
   Optional arguments *start* and *end* are interpreted as in slice
   notation.  Return "-1" on failure.

str.rindex(sub[, start[, end]])

   Like "rfind()" but raises "ValueError" when the substring *sub* is
   not found.

str.rjust(width[, fillchar])

   Return the string right justified in a string of length *width*.
   Padding is done using the specified *fillchar* (default is an ASCII
   space). The original string is returned if *width* is less than or
   equal to "len(s)".

str.rpartition(sep)

   Split the string at the last occurrence of *sep*, and return a
   3-tuple containing the part before the separator, the separator
   itself, and the part after the separator.  If the separator is not
   found, return a 3-tuple containing two empty strings, followed by
   the string itself.

str.rsplit(sep=None, maxsplit=-1)

   Return a list of the words in the string, using *sep* as the
   delimiter string. If *maxsplit* is given, at most *maxsplit* splits
   are done, the *rightmost* ones.  If *sep* is not specified or
   "None", any whitespace string is a separator.  Except for splitting
   from the right, "rsplit()" behaves like "split()" which is
   described in detail below.

str.rstrip([chars])

   Return a copy of the string with trailing characters removed.  The
   *chars* argument is a string specifying the set of characters to be
   removed.  If omitted or "None", the *chars* argument defaults to
   removing whitespace.  The *chars* argument is not a suffix; rather,
   all combinations of its values are stripped:

      >>> '   spacious   '.rstrip()
      '   spacious'
      >>> 'mississippi'.rstrip('ipz')
      'mississ'

str.split(sep=None, maxsplit=-1)

   Return a list of the words in the string, using *sep* as the
   delimiter string.  If *maxsplit* is given, at most *maxsplit*
   splits are done (thus, the list will have at most "maxsplit+1"
   elements).  If *maxsplit* is not specified or "-1", then there is
   no limit on the number of splits (all possible splits are made).

   If *sep* is given, consecutive delimiters are not grouped together
   and are deemed to delimit empty strings (for example,
   "'1,,2'.split(',')" returns "['1', '', '2']").  The *sep* argument
   may consist of multiple characters (for example,
   "'1<>2<>3'.split('<>')" returns "['1', '2', '3']"). Splitting an
   empty string with a specified separator returns "['']".

   For example:

      >>> '1,2,3'.split(',')
      ['1', '2', '3']
      >>> '1,2,3'.split(',', maxsplit=1)
      ['1', '2,3']
      >>> '1,2,,3,'.split(',')
      ['1', '2', '', '3', '']

   If *sep* is not specified or is "None", a different splitting
   algorithm is applied: runs of consecutive whitespace are regarded
   as a single separator, and the result will contain no empty strings
   at the start or end if the string has leading or trailing
   whitespace.  Consequently, splitting an empty string or a string
   consisting of just whitespace with a "None" separator returns "[]".

   For example:

      >>> '1 2 3'.split()
      ['1', '2', '3']
      >>> '1 2 3'.split(maxsplit=1)
      ['1', '2 3']
      >>> '   1   2   3   '.split()
      ['1', '2', '3']

str.splitlines([keepends])

   Return a list of the lines in the string, breaking at line
   boundaries.  Line breaks are not included in the resulting list
   unless *keepends* is given and true.

   This method splits on the following line boundaries.  In
   particular, the boundaries are a superset of *universal newlines*.

   +-------------------------+-------------------------------+
   | Representation          | Description                   |
   |=========================|===============================|
   | "\n"                    | Line Feed                     |
   +-------------------------+-------------------------------+
   | "\r"                    | Carriage Return               |
   +-------------------------+-------------------------------+
   | "\r\n"                  | Carriage Return + Line Feed   |
   +-------------------------+-------------------------------+
   | "\v" or "\x0b"          | Line Tabulation               |
   +-------------------------+-------------------------------+
   | "\f" or "\x0c"          | Form Feed                     |
   +-------------------------+-------------------------------+
   | "\x1c"                  | File Separator                |
   +-------------------------+-------------------------------+
   | "\x1d"                  | Group Separator               |
   +-------------------------+-------------------------------+
   | "\x1e"                  | Record Separator              |
   +-------------------------+-------------------------------+
   | "\x85"                  | Next Line (C1 Control Code)   |
   +-------------------------+-------------------------------+
   | "\u2028"                | Line Separator                |
   +-------------------------+-------------------------------+
   | "\u2029"                | Paragraph Separator           |
   +-------------------------+-------------------------------+

   Changed in version 3.2: "\v" and "\f" added to list of line
   boundaries.

   For example:

      >>> 'ab c\n\nde fg\rkl\r\n'.splitlines()
      ['ab c', '', 'de fg', 'kl']
      >>> 'ab c\n\nde fg\rkl\r\n'.splitlines(keepends=True)
      ['ab c\n', '\n', 'de fg\r', 'kl\r\n']

   Unlike "split()" when a delimiter string *sep* is given, this
   method returns an empty list for the empty string, and a terminal
   line break does not result in an extra line:

      >>> "".splitlines()
      []
      >>> "One line\n".splitlines()
      ['One line']

   For comparison, "split('\n')" gives:

      >>> ''.split('\n')
      ['']
      >>> 'Two lines\n'.split('\n')
      ['Two lines', '']

str.startswith(prefix[, start[, end]])

   Return "True" if string starts with the *prefix*, otherwise return
   "False". *prefix* can also be a tuple of prefixes to look for.
   With optional *start*, test string beginning at that position.
   With optional *end*, stop comparing string at that position.

str.strip([chars])

   Return a copy of the string with the leading and trailing
   characters removed. The *chars* argument is a string specifying the
   set of characters to be removed. If omitted or "None", the *chars*
   argument defaults to removing whitespace. The *chars* argument is
   not a prefix or suffix; rather, all combinations of its values are
   stripped:

      >>> '   spacious   '.strip()
      'spacious'
      >>> 'www.example.com'.strip('cmowz.')
      'example'

   The outermost leading and trailing *chars* argument values are
   stripped from the string. Characters are removed from the leading
   end until reaching a string character that is not contained in the
   set of characters in *chars*. A similar action takes place on the
   trailing end. For example:

      >>> comment_string = '#....... Section 3.2.1 Issue #32 .......'
      >>> comment_string.strip('.#! ')
      'Section 3.2.1 Issue #32'

str.swapcase()

   Return a copy of the string with uppercase characters converted to
   lowercase and vice versa. Note that it is not necessarily true that
   "s.swapcase().swapcase() == s".

str.title()

   Return a titlecased version of the string where words start with an
   uppercase character and the remaining characters are lowercase.

   For example:

      >>> 'Hello world'.title()
      'Hello World'

   The algorithm uses a simple language-independent definition of a
   word as groups of consecutive letters.  The definition works in
   many contexts but it means that apostrophes in contractions and
   possessives form word boundaries, which may not be the desired
   result:

      >>> "they're bill's friends from the UK".title()
      "They'Re Bill'S Friends From The Uk"

   A workaround for apostrophes can be constructed using regular
   expressions:

      >>> import re
      >>> def titlecase(s):
      ...     return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
      ...                   lambda mo: mo.group(0).capitalize(),
      ...                   s)
      ...
      >>> titlecase("they're bill's friends.")
      "They're Bill's Friends."

str.translate(table)

   Return a copy of the string in which each character has been mapped
   through the given translation table.  The table must be an object
   that implements indexing via "__getitem__()", typically a *mapping*
   or *sequence*.  When indexed by a Unicode ordinal (an integer), the
   table object can do any of the following: return a Unicode ordinal
   or a string, to map the character to one or more other characters;
   return "None", to delete the character from the return string; or
   raise a "LookupError" exception, to map the character to itself.

   You can use "str.maketrans()" to create a translation map from
   character-to-character mappings in different formats.

   See also the "codecs" module for a more flexible approach to custom
   character mappings.

str.upper()

   Return a copy of the string with all the cased characters [4]
   converted to uppercase.  Note that "s.upper().isupper()" might be
   "False" if "s" contains uncased characters or if the Unicode
   category of the resulting character(s) is not “Lu” (Letter,
   uppercase), but e.g. “Lt” (Letter, titlecase).

   The uppercasing algorithm used is described in section 3.13 of the
   Unicode Standard.

str.zfill(width)

   Return a copy of the string left filled with ASCII "'0'" digits to
   make a string of length *width*. A leading sign prefix
   ("'+'"/"'-'") is handled by inserting the padding *after* the sign
   character rather than before. The original string is returned if
   *width* is less than or equal to "len(s)".

   For example:

      >>> "42".zfill(5)
      '00042'
      >>> "-42".zfill(5)
      '-0042'
u� String and Bytes literals
*************************

String literals are described by the following lexical definitions:

   stringliteral   ::= [stringprefix](shortstring | longstring)
   stringprefix    ::= "r" | "u" | "R" | "U" | "f" | "F"
                    | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
   shortstring     ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
   longstring      ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
   shortstringitem ::= shortstringchar | stringescapeseq
   longstringitem  ::= longstringchar | stringescapeseq
   shortstringchar ::= <any source character except "\" or newline or the quote>
   longstringchar  ::= <any source character except "\">
   stringescapeseq ::= "\" <any source character>

   bytesliteral   ::= bytesprefix(shortbytes | longbytes)
   bytesprefix    ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"
   shortbytes     ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
   longbytes      ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
   shortbytesitem ::= shortbyteschar | bytesescapeseq
   longbytesitem  ::= longbyteschar | bytesescapeseq
   shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
   longbyteschar  ::= <any ASCII character except "\">
   bytesescapeseq ::= "\" <any ASCII character>

One syntactic restriction not indicated by these productions is that
whitespace is not allowed between the "stringprefix" or "bytesprefix"
and the rest of the literal. The source character set is defined by
the encoding declaration; it is UTF-8 if no encoding declaration is
given in the source file; see section Encoding declarations.

In plain English: Both types of literals can be enclosed in matching
single quotes ("'") or double quotes (""").  They can also be enclosed
in matching groups of three single or double quotes (these are
generally referred to as *triple-quoted strings*).  The backslash
("\") character is used to escape characters that otherwise have a
special meaning, such as newline, backslash itself, or the quote
character.

Bytes literals are always prefixed with "'b'" or "'B'"; they produce
an instance of the "bytes" type instead of the "str" type.  They may
only contain ASCII characters; bytes with a numeric value of 128 or
greater must be expressed with escapes.

Both string and bytes literals may optionally be prefixed with a
letter "'r'" or "'R'"; such strings are called *raw strings* and treat
backslashes as literal characters.  As a result, in string literals,
"'\U'" and "'\u'" escapes in raw strings are not treated specially.
Given that Python 2.x’s raw unicode literals behave differently than
Python 3.x’s the "'ur'" syntax is not supported.

New in version 3.3: The "'rb'" prefix of raw bytes literals has been
added as a synonym of "'br'".

New in version 3.3: Support for the unicode legacy literal
("u'value'") was reintroduced to simplify the maintenance of dual
Python 2.x and 3.x codebases. See **PEP 414** for more information.

A string literal with "'f'" or "'F'" in its prefix is a *formatted
string literal*; see Formatted string literals.  The "'f'" may be
combined with "'r'", but not with "'b'" or "'u'", therefore raw
formatted strings are possible, but formatted bytes literals are not.

In triple-quoted literals, unescaped newlines and quotes are allowed
(and are retained), except that three unescaped quotes in a row
terminate the literal.  (A “quote” is the character used to open the
literal, i.e. either "'" or """.)

Unless an "'r'" or "'R'" prefix is present, escape sequences in string
and bytes literals are interpreted according to rules similar to those
used by Standard C.  The recognized escape sequences are:

+-------------------+-----------------------------------+---------+
| Escape Sequence   | Meaning                           | Notes   |
|===================|===================================|=========|
| "\newline"        | Backslash and newline ignored     |         |
+-------------------+-----------------------------------+---------+
| "\\"              | Backslash ("\")                   |         |
+-------------------+-----------------------------------+---------+
| "\'"              | Single quote ("'")                |         |
+-------------------+-----------------------------------+---------+
| "\""              | Double quote (""")                |         |
+-------------------+-----------------------------------+---------+
| "\a"              | ASCII Bell (BEL)                  |         |
+-------------------+-----------------------------------+---------+
| "\b"              | ASCII Backspace (BS)              |         |
+-------------------+-----------------------------------+---------+
| "\f"              | ASCII Formfeed (FF)               |         |
+-------------------+-----------------------------------+---------+
| "\n"              | ASCII Linefeed (LF)               |         |
+-------------------+-----------------------------------+---------+
| "\r"              | ASCII Carriage Return (CR)        |         |
+-------------------+-----------------------------------+---------+
| "\t"              | ASCII Horizontal Tab (TAB)        |         |
+-------------------+-----------------------------------+---------+
| "\v"              | ASCII Vertical Tab (VT)           |         |
+-------------------+-----------------------------------+---------+
| "\ooo"            | Character with octal value *ooo*  | (1,3)   |
+-------------------+-----------------------------------+---------+
| "\xhh"            | Character with hex value *hh*     | (2,3)   |
+-------------------+-----------------------------------+---------+

Escape sequences only recognized in string literals are:

+-------------------+-----------------------------------+---------+
| Escape Sequence   | Meaning                           | Notes   |
|===================|===================================|=========|
| "\N{name}"        | Character named *name* in the     | (4)     |
|                   | Unicode database                  |         |
+-------------------+-----------------------------------+---------+
| "\uxxxx"          | Character with 16-bit hex value   | (5)     |
|                   | *xxxx*                            |         |
+-------------------+-----------------------------------+---------+
| "\Uxxxxxxxx"      | Character with 32-bit hex value   | (6)     |
|                   | *xxxxxxxx*                        |         |
+-------------------+-----------------------------------+---------+

Notes:

1. As in Standard C, up to three octal digits are accepted.

2. Unlike in Standard C, exactly two hex digits are required.

3. In a bytes literal, hexadecimal and octal escapes denote the byte
   with the given value. In a string literal, these escapes denote a
   Unicode character with the given value.

4. Changed in version 3.3: Support for name aliases [1] has been
   added.

5. Exactly four hex digits are required.

6. Any Unicode character can be encoded this way.  Exactly eight hex
   digits are required.

Unlike Standard C, all unrecognized escape sequences are left in the
string unchanged, i.e., *the backslash is left in the result*.  (This
behavior is useful when debugging: if an escape sequence is mistyped,
the resulting output is more easily recognized as broken.)  It is also
important to note that the escape sequences only recognized in string
literals fall into the category of unrecognized escapes for bytes
literals.

   Changed in version 3.6: Unrecognized escape sequences produce a
   "DeprecationWarning".  In a future Python version they will be a
   "SyntaxWarning" and eventually a "SyntaxError".

Even in a raw literal, quotes can be escaped with a backslash, but the
backslash remains in the result; for example, "r"\""" is a valid
string literal consisting of two characters: a backslash and a double
quote; "r"\"" is not a valid string literal (even a raw string cannot
end in an odd number of backslashes).  Specifically, *a raw literal
cannot end in a single backslash* (since the backslash would escape
the following quote character).  Note also that a single backslash
followed by a newline is interpreted as those two characters as part
of the literal, *not* as a line continuation.
uMSubscriptions
*************

A subscription selects an item of a sequence (string, tuple or list)
or mapping (dictionary) object:

   subscription ::= primary "[" expression_list "]"

The primary must evaluate to an object that supports subscription
(lists or dictionaries for example).  User-defined objects can support
subscription by defining a "__getitem__()" method.

For built-in objects, there are two types of objects that support
subscription:

If the primary is a mapping, the expression list must evaluate to an
object whose value is one of the keys of the mapping, and the
subscription selects the value in the mapping that corresponds to that
key.  (The expression list is a tuple except if it has exactly one
item.)

If the primary is a sequence, the expression list must evaluate to an
integer or a slice (as discussed in the following section).

The formal syntax makes no special provision for negative indices in
sequences; however, built-in sequences all provide a "__getitem__()"
method that interprets negative indices by adding the length of the
sequence to the index (so that "x[-1]" selects the last item of "x").
The resulting value must be a nonnegative integer less than the number
of items in the sequence, and the subscription selects the item whose
index is that value (counting from zero). Since the support for
negative indices and slicing occurs in the object’s "__getitem__()"
method, subclasses overriding this method will need to explicitly add
that support.

A string’s items are characters.  A character is not a separate data
type but a string of exactly one character.
axTruth Value Testing
*******************

Any object can be tested for truth value, for use in an "if" or
"while" condition or as operand of the Boolean operations below.

By default, an object is considered true unless its class defines
either a "__bool__()" method that returns "False" or a "__len__()"
method that returns zero, when called with the object. [1]  Here are
most of the built-in objects considered false:

* constants defined to be false: "None" and "False".

* zero of any numeric type: "0", "0.0", "0j", "Decimal(0)",
  "Fraction(0, 1)"

* empty sequences and collections: "''", "()", "[]", "{}", "set()",
  "range(0)"

Operations and built-in functions that have a Boolean result always
return "0" or "False" for false and "1" or "True" for true, unless
otherwise stated. (Important exception: the Boolean operations "or"
and "and" always return one of their operands.)
uRThe "try" statement
*******************

The "try" statement specifies exception handlers and/or cleanup code
for a group of statements:

   try_stmt  ::= try1_stmt | try2_stmt
   try1_stmt ::= "try" ":" suite
                 ("except" [expression ["as" identifier]] ":" suite)+
                 ["else" ":" suite]
                 ["finally" ":" suite]
   try2_stmt ::= "try" ":" suite
                 "finally" ":" suite

The "except" clause(s) specify one or more exception handlers. When no
exception occurs in the "try" clause, no exception handler is
executed. When an exception occurs in the "try" suite, a search for an
exception handler is started.  This search inspects the except clauses
in turn until one is found that matches the exception.  An expression-
less except clause, if present, must be last; it matches any
exception.  For an except clause with an expression, that expression
is evaluated, and the clause matches the exception if the resulting
object is “compatible” with the exception.  An object is compatible
with an exception if it is the class or a base class of the exception
object, or a tuple containing an item that is the class or a base
class of the exception object.

If no except clause matches the exception, the search for an exception
handler continues in the surrounding code and on the invocation stack.
[1]

If the evaluation of an expression in the header of an except clause
raises an exception, the original search for a handler is canceled and
a search starts for the new exception in the surrounding code and on
the call stack (it is treated as if the entire "try" statement raised
the exception).

When a matching except clause is found, the exception is assigned to
the target specified after the "as" keyword in that except clause, if
present, and the except clause’s suite is executed.  All except
clauses must have an executable block.  When the end of this block is
reached, execution continues normally after the entire try statement.
(This means that if two nested handlers exist for the same exception,
and the exception occurs in the try clause of the inner handler, the
outer handler will not handle the exception.)

When an exception has been assigned using "as target", it is cleared
at the end of the except clause.  This is as if

   except E as N:
       foo

was translated to

   except E as N:
       try:
           foo
       finally:
           del N

This means the exception must be assigned to a different name to be
able to refer to it after the except clause.  Exceptions are cleared
because with the traceback attached to them, they form a reference
cycle with the stack frame, keeping all locals in that frame alive
until the next garbage collection occurs.

Before an except clause’s suite is executed, details about the
exception are stored in the "sys" module and can be accessed via
"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the
exception class, the exception instance and a traceback object (see
section The standard type hierarchy) identifying the point in the
program where the exception occurred.  "sys.exc_info()" values are
restored to their previous values (before the call) when returning
from a function that handled an exception.

The optional "else" clause is executed if the control flow leaves the
"try" suite, no exception was raised, and no "return", "continue", or
"break" statement was executed.  Exceptions in the "else" clause are
not handled by the preceding "except" clauses.

If "finally" is present, it specifies a ‘cleanup’ handler.  The "try"
clause is executed, including any "except" and "else" clauses.  If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed.  If
there is a saved exception it is re-raised at the end of the "finally"
clause.  If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:

   >>> def f():
   ...     try:
   ...         1/0
   ...     finally:
   ...         return 42
   ...
   >>> f()
   42

The exception information is not available to the program during
execution of the "finally" clause.

When a "return", "break" or "continue" statement is executed in the
"try" suite of a "try"…"finally" statement, the "finally" clause is
also executed ‘on the way out.’

The return value of a function is determined by the last "return"
statement executed.  Since the "finally" clause always executes, a
"return" statement executed in the "finally" clause will always be the
last one executed:

   >>> def foo():
   ...     try:
   ...         return 'try'
   ...     finally:
   ...         return 'finally'
   ...
   >>> foo()
   'finally'

Additional information on exceptions can be found in section
Exceptions, and information on using the "raise" statement to generate
exceptions may be found in section The raise statement.

Changed in version 3.8: Prior to Python 3.8, a "continue" statement
was illegal in the "finally" clause due to a problem with the
implementation.
ux�The standard type hierarchy
***************************

Below is a list of the types that are built into Python.  Extension
modules (written in C, Java, or other languages, depending on the
implementation) can define additional types.  Future versions of
Python may add types to the type hierarchy (e.g., rational numbers,
efficiently stored arrays of integers, etc.), although such additions
will often be provided via the standard library instead.

Some of the type descriptions below contain a paragraph listing
‘special attributes.’  These are attributes that provide access to the
implementation and are not intended for general use.  Their definition
may change in the future.

None
   This type has a single value.  There is a single object with this
   value. This object is accessed through the built-in name "None". It
   is used to signify the absence of a value in many situations, e.g.,
   it is returned from functions that don’t explicitly return
   anything. Its truth value is false.

NotImplemented
   This type has a single value.  There is a single object with this
   value. This object is accessed through the built-in name
   "NotImplemented". Numeric methods and rich comparison methods
   should return this value if they do not implement the operation for
   the operands provided.  (The interpreter will then try the
   reflected operation, or some other fallback, depending on the
   operator.)  Its truth value is true.

   See Implementing the arithmetic operations for more details.

Ellipsis
   This type has a single value.  There is a single object with this
   value. This object is accessed through the literal "..." or the
   built-in name "Ellipsis".  Its truth value is true.

"numbers.Number"
   These are created by numeric literals and returned as results by
   arithmetic operators and arithmetic built-in functions.  Numeric
   objects are immutable; once created their value never changes.
   Python numbers are of course strongly related to mathematical
   numbers, but subject to the limitations of numerical representation
   in computers.

   The string representations of the numeric classes, computed by
   "__repr__()" and "__str__()", have the following properties:

   * They are valid numeric literals which, when passed to their class
     constructor, produce an object having the value of the original
     numeric.

   * The representation is in base 10, when possible.

   * Leading zeros, possibly excepting a single zero before a decimal
     point, are not shown.

   * Trailing zeros, possibly excepting a single zero after a decimal
     point, are not shown.

   * A sign is shown only when the number is negative.

   Python distinguishes between integers, floating point numbers, and
   complex numbers:

   "numbers.Integral"
      These represent elements from the mathematical set of integers
      (positive and negative).

      There are two types of integers:

      Integers ("int")
         These represent numbers in an unlimited range, subject to
         available (virtual) memory only.  For the purpose of shift
         and mask operations, a binary representation is assumed, and
         negative numbers are represented in a variant of 2’s
         complement which gives the illusion of an infinite string of
         sign bits extending to the left.

      Booleans ("bool")
         These represent the truth values False and True.  The two
         objects representing the values "False" and "True" are the
         only Boolean objects. The Boolean type is a subtype of the
         integer type, and Boolean values behave like the values 0 and
         1, respectively, in almost all contexts, the exception being
         that when converted to a string, the strings ""False"" or
         ""True"" are returned, respectively.

      The rules for integer representation are intended to give the
      most meaningful interpretation of shift and mask operations
      involving negative integers.

   "numbers.Real" ("float")
      These represent machine-level double precision floating point
      numbers. You are at the mercy of the underlying machine
      architecture (and C or Java implementation) for the accepted
      range and handling of overflow. Python does not support single-
      precision floating point numbers; the savings in processor and
      memory usage that are usually the reason for using these are
      dwarfed by the overhead of using objects in Python, so there is
      no reason to complicate the language with two kinds of floating
      point numbers.

   "numbers.Complex" ("complex")
      These represent complex numbers as a pair of machine-level
      double precision floating point numbers.  The same caveats apply
      as for floating point numbers. The real and imaginary parts of a
      complex number "z" can be retrieved through the read-only
      attributes "z.real" and "z.imag".

Sequences
   These represent finite ordered sets indexed by non-negative
   numbers. The built-in function "len()" returns the number of items
   of a sequence. When the length of a sequence is *n*, the index set
   contains the numbers 0, 1, …, *n*-1.  Item *i* of sequence *a* is
   selected by "a[i]".

   Sequences also support slicing: "a[i:j]" selects all items with
   index *k* such that *i* "<=" *k* "<" *j*.  When used as an
   expression, a slice is a sequence of the same type.  This implies
   that the index set is renumbered so that it starts at 0.

   Some sequences also support “extended slicing” with a third “step”
   parameter: "a[i:j:k]" selects all items of *a* with index *x* where
   "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.

   Sequences are distinguished according to their mutability:

   Immutable sequences
      An object of an immutable sequence type cannot change once it is
      created.  (If the object contains references to other objects,
      these other objects may be mutable and may be changed; however,
      the collection of objects directly referenced by an immutable
      object cannot change.)

      The following types are immutable sequences:

      Strings
         A string is a sequence of values that represent Unicode code
         points. All the code points in the range "U+0000 - U+10FFFF"
         can be represented in a string.  Python doesn’t have a "char"
         type; instead, every code point in the string is represented
         as a string object with length "1".  The built-in function
         "ord()" converts a code point from its string form to an
         integer in the range "0 - 10FFFF"; "chr()" converts an
         integer in the range "0 - 10FFFF" to the corresponding length
         "1" string object. "str.encode()" can be used to convert a
         "str" to "bytes" using the given text encoding, and
         "bytes.decode()" can be used to achieve the opposite.

      Tuples
         The items of a tuple are arbitrary Python objects. Tuples of
         two or more items are formed by comma-separated lists of
         expressions.  A tuple of one item (a ‘singleton’) can be
         formed by affixing a comma to an expression (an expression by
         itself does not create a tuple, since parentheses must be
         usable for grouping of expressions).  An empty tuple can be
         formed by an empty pair of parentheses.

      Bytes
         A bytes object is an immutable array.  The items are 8-bit
         bytes, represented by integers in the range 0 <= x < 256.
         Bytes literals (like "b'abc'") and the built-in "bytes()"
         constructor can be used to create bytes objects.  Also, bytes
         objects can be decoded to strings via the "decode()" method.

   Mutable sequences
      Mutable sequences can be changed after they are created.  The
      subscription and slicing notations can be used as the target of
      assignment and "del" (delete) statements.

      There are currently two intrinsic mutable sequence types:

      Lists
         The items of a list are arbitrary Python objects.  Lists are
         formed by placing a comma-separated list of expressions in
         square brackets. (Note that there are no special cases needed
         to form lists of length 0 or 1.)

      Byte Arrays
         A bytearray object is a mutable array. They are created by
         the built-in "bytearray()" constructor.  Aside from being
         mutable (and hence unhashable), byte arrays otherwise provide
         the same interface and functionality as immutable "bytes"
         objects.

      The extension module "array" provides an additional example of a
      mutable sequence type, as does the "collections" module.

Set types
   These represent unordered, finite sets of unique, immutable
   objects. As such, they cannot be indexed by any subscript. However,
   they can be iterated over, and the built-in function "len()"
   returns the number of items in a set. Common uses for sets are fast
   membership testing, removing duplicates from a sequence, and
   computing mathematical operations such as intersection, union,
   difference, and symmetric difference.

   For set elements, the same immutability rules apply as for
   dictionary keys. Note that numeric types obey the normal rules for
   numeric comparison: if two numbers compare equal (e.g., "1" and
   "1.0"), only one of them can be contained in a set.

   There are currently two intrinsic set types:

   Sets
      These represent a mutable set. They are created by the built-in
      "set()" constructor and can be modified afterwards by several
      methods, such as "add()".

   Frozen sets
      These represent an immutable set.  They are created by the
      built-in "frozenset()" constructor.  As a frozenset is immutable
      and *hashable*, it can be used again as an element of another
      set, or as a dictionary key.

Mappings
   These represent finite sets of objects indexed by arbitrary index
   sets. The subscript notation "a[k]" selects the item indexed by "k"
   from the mapping "a"; this can be used in expressions and as the
   target of assignments or "del" statements. The built-in function
   "len()" returns the number of items in a mapping.

   There is currently a single intrinsic mapping type:

   Dictionaries
      These represent finite sets of objects indexed by nearly
      arbitrary values.  The only types of values not acceptable as
      keys are values containing lists or dictionaries or other
      mutable types that are compared by value rather than by object
      identity, the reason being that the efficient implementation of
      dictionaries requires a key’s hash value to remain constant.
      Numeric types used for keys obey the normal rules for numeric
      comparison: if two numbers compare equal (e.g., "1" and "1.0")
      then they can be used interchangeably to index the same
      dictionary entry.

      Dictionaries preserve insertion order, meaning that keys will be
      produced in the same order they were added sequentially over the
      dictionary. Replacing an existing key does not change the order,
      however removing a key and re-inserting it will add it to the
      end instead of keeping its old place.

      Dictionaries are mutable; they can be created by the "{...}"
      notation (see section Dictionary displays).

      The extension modules "dbm.ndbm" and "dbm.gnu" provide
      additional examples of mapping types, as does the "collections"
      module.

      Changed in version 3.7: Dictionaries did not preserve insertion
      order in versions of Python before 3.6. In CPython 3.6,
      insertion order was preserved, but it was considered an
      implementation detail at that time rather than a language
      guarantee.

Callable types
   These are the types to which the function call operation (see
   section Calls) can be applied:

   User-defined functions
      A user-defined function object is created by a function
      definition (see section Function definitions).  It should be
      called with an argument list containing the same number of items
      as the function’s formal parameter list.

      Special attributes:

      +---------------------------+---------------------------------+-------------+
      | Attribute                 | Meaning                         |             |
      |===========================|=================================|=============|
      | "__doc__"                 | The function’s documentation    | Writable    |
      |                           | string, or "None" if            |             |
      |                           | unavailable; not inherited by   |             |
      |                           | subclasses.                     |             |
      +---------------------------+---------------------------------+-------------+
      | "__name__"                | The function’s name.            | Writable    |
      +---------------------------+---------------------------------+-------------+
      | "__qualname__"            | The function’s *qualified       | Writable    |
      |                           | name*.  New in version 3.3.     |             |
      +---------------------------+---------------------------------+-------------+
      | "__module__"              | The name of the module the      | Writable    |
      |                           | function was defined in, or     |             |
      |                           | "None" if unavailable.          |             |
      +---------------------------+---------------------------------+-------------+
      | "__defaults__"            | A tuple containing default      | Writable    |
      |                           | argument values for those       |             |
      |                           | arguments that have defaults,   |             |
      |                           | or "None" if no arguments have  |             |
      |                           | a default value.                |             |
      +---------------------------+---------------------------------+-------------+
      | "__code__"                | The code object representing    | Writable    |
      |                           | the compiled function body.     |             |
      +---------------------------+---------------------------------+-------------+
      | "__globals__"             | A reference to the dictionary   | Read-only   |
      |                           | that holds the function’s       |             |
      |                           | global variables — the global   |             |
      |                           | namespace of the module in      |             |
      |                           | which the function was defined. |             |
      +---------------------------+---------------------------------+-------------+
      | "__dict__"                | The namespace supporting        | Writable    |
      |                           | arbitrary function attributes.  |             |
      +---------------------------+---------------------------------+-------------+
      | "__closure__"             | "None" or a tuple of cells that | Read-only   |
      |                           | contain bindings for the        |             |
      |                           | function’s free variables. See  |             |
      |                           | below for information on the    |             |
      |                           | "cell_contents" attribute.      |             |
      +---------------------------+---------------------------------+-------------+
      | "__annotations__"         | A dict containing annotations   | Writable    |
      |                           | of parameters.  The keys of the |             |
      |                           | dict are the parameter names,   |             |
      |                           | and "'return'" for the return   |             |
      |                           | annotation, if provided.        |             |
      +---------------------------+---------------------------------+-------------+
      | "__kwdefaults__"          | A dict containing defaults for  | Writable    |
      |                           | keyword-only parameters.        |             |
      +---------------------------+---------------------------------+-------------+

      Most of the attributes labelled “Writable” check the type of the
      assigned value.

      Function objects also support getting and setting arbitrary
      attributes, which can be used, for example, to attach metadata
      to functions.  Regular attribute dot-notation is used to get and
      set such attributes. *Note that the current implementation only
      supports function attributes on user-defined functions. Function
      attributes on built-in functions may be supported in the
      future.*

      A cell object has the attribute "cell_contents". This can be
      used to get the value of the cell, as well as set the value.

      Additional information about a function’s definition can be
      retrieved from its code object; see the description of internal
      types below. The "cell" type can be accessed in the "types"
      module.

   Instance methods
      An instance method object combines a class, a class instance and
      any callable object (normally a user-defined function).

      Special read-only attributes: "__self__" is the class instance
      object, "__func__" is the function object; "__doc__" is the
      method’s documentation (same as "__func__.__doc__"); "__name__"
      is the method name (same as "__func__.__name__"); "__module__"
      is the name of the module the method was defined in, or "None"
      if unavailable.

      Methods also support accessing (but not setting) the arbitrary
      function attributes on the underlying function object.

      User-defined method objects may be created when getting an
      attribute of a class (perhaps via an instance of that class), if
      that attribute is a user-defined function object or a class
      method object.

      When an instance method object is created by retrieving a user-
      defined function object from a class via one of its instances,
      its "__self__" attribute is the instance, and the method object
      is said to be bound.  The new method’s "__func__" attribute is
      the original function object.

      When an instance method object is created by retrieving a class
      method object from a class or instance, its "__self__" attribute
      is the class itself, and its "__func__" attribute is the
      function object underlying the class method.

      When an instance method object is called, the underlying
      function ("__func__") is called, inserting the class instance
      ("__self__") in front of the argument list.  For instance, when
      "C" is a class which contains a definition for a function "f()",
      and "x" is an instance of "C", calling "x.f(1)" is equivalent to
      calling "C.f(x, 1)".

      When an instance method object is derived from a class method
      object, the “class instance” stored in "__self__" will actually
      be the class itself, so that calling either "x.f(1)" or "C.f(1)"
      is equivalent to calling "f(C,1)" where "f" is the underlying
      function.

      Note that the transformation from function object to instance
      method object happens each time the attribute is retrieved from
      the instance.  In some cases, a fruitful optimization is to
      assign the attribute to a local variable and call that local
      variable. Also notice that this transformation only happens for
      user-defined functions; other callable objects (and all non-
      callable objects) are retrieved without transformation.  It is
      also important to note that user-defined functions which are
      attributes of a class instance are not converted to bound
      methods; this *only* happens when the function is an attribute
      of the class.

   Generator functions
      A function or method which uses the "yield" statement (see
      section The yield statement) is called a *generator function*.
      Such a function, when called, always returns an iterator object
      which can be used to execute the body of the function:  calling
      the iterator’s "iterator.__next__()" method will cause the
      function to execute until it provides a value using the "yield"
      statement.  When the function executes a "return" statement or
      falls off the end, a "StopIteration" exception is raised and the
      iterator will have reached the end of the set of values to be
      returned.

   Coroutine functions
      A function or method which is defined using "async def" is
      called a *coroutine function*.  Such a function, when called,
      returns a *coroutine* object.  It may contain "await"
      expressions, as well as "async with" and "async for" statements.
      See also the Coroutine Objects section.

   Asynchronous generator functions
      A function or method which is defined using "async def" and
      which uses the "yield" statement is called a *asynchronous
      generator function*.  Such a function, when called, returns an
      asynchronous iterator object which can be used in an "async for"
      statement to execute the body of the function.

      Calling the asynchronous iterator’s "aiterator.__anext__()"
      method will return an *awaitable* which when awaited will
      execute until it provides a value using the "yield" expression.
      When the function executes an empty "return" statement or falls
      off the end, a "StopAsyncIteration" exception is raised and the
      asynchronous iterator will have reached the end of the set of
      values to be yielded.

   Built-in functions
      A built-in function object is a wrapper around a C function.
      Examples of built-in functions are "len()" and "math.sin()"
      ("math" is a standard built-in module). The number and type of
      the arguments are determined by the C function. Special read-
      only attributes: "__doc__" is the function’s documentation
      string, or "None" if unavailable; "__name__" is the function’s
      name; "__self__" is set to "None" (but see the next item);
      "__module__" is the name of the module the function was defined
      in or "None" if unavailable.

   Built-in methods
      This is really a different disguise of a built-in function, this
      time containing an object passed to the C function as an
      implicit extra argument.  An example of a built-in method is
      "alist.append()", assuming *alist* is a list object. In this
      case, the special read-only attribute "__self__" is set to the
      object denoted by *alist*.

   Classes
      Classes are callable.  These objects normally act as factories
      for new instances of themselves, but variations are possible for
      class types that override "__new__()".  The arguments of the
      call are passed to "__new__()" and, in the typical case, to
      "__init__()" to initialize the new instance.

   Class Instances
      Instances of arbitrary classes can be made callable by defining
      a "__call__()" method in their class.

Modules
   Modules are a basic organizational unit of Python code, and are
   created by the import system as invoked either by the "import"
   statement, or by calling functions such as
   "importlib.import_module()" and built-in "__import__()".  A module
   object has a namespace implemented by a dictionary object (this is
   the dictionary referenced by the "__globals__" attribute of
   functions defined in the module).  Attribute references are
   translated to lookups in this dictionary, e.g., "m.x" is equivalent
   to "m.__dict__["x"]". A module object does not contain the code
   object used to initialize the module (since it isn’t needed once
   the initialization is done).

   Attribute assignment updates the module’s namespace dictionary,
   e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".

   Predefined (writable) attributes: "__name__" is the module’s name;
   "__doc__" is the module’s documentation string, or "None" if
   unavailable; "__annotations__" (optional) is a dictionary
   containing *variable annotations* collected during module body
   execution; "__file__" is the pathname of the file from which the
   module was loaded, if it was loaded from a file. The "__file__"
   attribute may be missing for certain types of modules, such as C
   modules that are statically linked into the interpreter; for
   extension modules loaded dynamically from a shared library, it is
   the pathname of the shared library file.

   Special read-only attribute: "__dict__" is the module’s namespace
   as a dictionary object.

   **CPython implementation detail:** Because of the way CPython
   clears module dictionaries, the module dictionary will be cleared
   when the module falls out of scope even if the dictionary still has
   live references.  To avoid this, copy the dictionary or keep the
   module around while using its dictionary directly.

Custom classes
   Custom class types are typically created by class definitions (see
   section Class definitions).  A class has a namespace implemented by
   a dictionary object. Class attribute references are translated to
   lookups in this dictionary, e.g., "C.x" is translated to
   "C.__dict__["x"]" (although there are a number of hooks which allow
   for other means of locating attributes). When the attribute name is
   not found there, the attribute search continues in the base
   classes. This search of the base classes uses the C3 method
   resolution order which behaves correctly even in the presence of
   ‘diamond’ inheritance structures where there are multiple
   inheritance paths leading back to a common ancestor. Additional
   details on the C3 MRO used by Python can be found in the
   documentation accompanying the 2.3 release at
   https://www.python.org/download/releases/2.3/mro/.

   When a class attribute reference (for class "C", say) would yield a
   class method object, it is transformed into an instance method
   object whose "__self__" attribute is "C".  When it would yield a
   static method object, it is transformed into the object wrapped by
   the static method object. See section Implementing Descriptors for
   another way in which attributes retrieved from a class may differ
   from those actually contained in its "__dict__".

   Class attribute assignments update the class’s dictionary, never
   the dictionary of a base class.

   A class object can be called (see above) to yield a class instance
   (see below).

   Special attributes: "__name__" is the class name; "__module__" is
   the module name in which the class was defined; "__dict__" is the
   dictionary containing the class’s namespace; "__bases__" is a tuple
   containing the base classes, in the order of their occurrence in
   the base class list; "__doc__" is the class’s documentation string,
   or "None" if undefined; "__annotations__" (optional) is a
   dictionary containing *variable annotations* collected during class
   body execution.

Class instances
   A class instance is created by calling a class object (see above).
   A class instance has a namespace implemented as a dictionary which
   is the first place in which attribute references are searched.
   When an attribute is not found there, and the instance’s class has
   an attribute by that name, the search continues with the class
   attributes.  If a class attribute is found that is a user-defined
   function object, it is transformed into an instance method object
   whose "__self__" attribute is the instance.  Static method and
   class method objects are also transformed; see above under
   “Classes”.  See section Implementing Descriptors for another way in
   which attributes of a class retrieved via its instances may differ
   from the objects actually stored in the class’s "__dict__".  If no
   class attribute is found, and the object’s class has a
   "__getattr__()" method, that is called to satisfy the lookup.

   Attribute assignments and deletions update the instance’s
   dictionary, never a class’s dictionary.  If the class has a
   "__setattr__()" or "__delattr__()" method, this is called instead
   of updating the instance dictionary directly.

   Class instances can pretend to be numbers, sequences, or mappings
   if they have methods with certain special names.  See section
   Special method names.

   Special attributes: "__dict__" is the attribute dictionary;
   "__class__" is the instance’s class.

I/O objects (also known as file objects)
   A *file object* represents an open file.  Various shortcuts are
   available to create file objects: the "open()" built-in function,
   and also "os.popen()", "os.fdopen()", and the "makefile()" method
   of socket objects (and perhaps by other functions or methods
   provided by extension modules).

   The objects "sys.stdin", "sys.stdout" and "sys.stderr" are
   initialized to file objects corresponding to the interpreter’s
   standard input, output and error streams; they are all open in text
   mode and therefore follow the interface defined by the
   "io.TextIOBase" abstract class.

Internal types
   A few types used internally by the interpreter are exposed to the
   user. Their definitions may change with future versions of the
   interpreter, but they are mentioned here for completeness.

   Code objects
      Code objects represent *byte-compiled* executable Python code,
      or *bytecode*. The difference between a code object and a
      function object is that the function object contains an explicit
      reference to the function’s globals (the module in which it was
      defined), while a code object contains no context; also the
      default argument values are stored in the function object, not
      in the code object (because they represent values calculated at
      run-time).  Unlike function objects, code objects are immutable
      and contain no references (directly or indirectly) to mutable
      objects.

      Special read-only attributes: "co_name" gives the function name;
      "co_argcount" is the total number of positional arguments
      (including positional-only arguments and arguments with default
      values); "co_posonlyargcount" is the number of positional-only
      arguments (including arguments with default values);
      "co_kwonlyargcount" is the number of keyword-only arguments
      (including arguments with default values); "co_nlocals" is the
      number of local variables used by the function (including
      arguments); "co_varnames" is a tuple containing the names of the
      local variables (starting with the argument names);
      "co_cellvars" is a tuple containing the names of local variables
      that are referenced by nested functions; "co_freevars" is a
      tuple containing the names of free variables; "co_code" is a
      string representing the sequence of bytecode instructions;
      "co_consts" is a tuple containing the literals used by the
      bytecode; "co_names" is a tuple containing the names used by the
      bytecode; "co_filename" is the filename from which the code was
      compiled; "co_firstlineno" is the first line number of the
      function; "co_lnotab" is a string encoding the mapping from
      bytecode offsets to line numbers (for details see the source
      code of the interpreter); "co_stacksize" is the required stack
      size; "co_flags" is an integer encoding a number of flags for
      the interpreter.

      The following flag bits are defined for "co_flags": bit "0x04"
      is set if the function uses the "*arguments" syntax to accept an
      arbitrary number of positional arguments; bit "0x08" is set if
      the function uses the "**keywords" syntax to accept arbitrary
      keyword arguments; bit "0x20" is set if the function is a
      generator.

      Future feature declarations ("from __future__ import division")
      also use bits in "co_flags" to indicate whether a code object
      was compiled with a particular feature enabled: bit "0x2000" is
      set if the function was compiled with future division enabled;
      bits "0x10" and "0x1000" were used in earlier versions of
      Python.

      Other bits in "co_flags" are reserved for internal use.

      If a code object represents a function, the first item in
      "co_consts" is the documentation string of the function, or
      "None" if undefined.

   Frame objects
      Frame objects represent execution frames.  They may occur in
      traceback objects (see below), and are also passed to registered
      trace functions.

      Special read-only attributes: "f_back" is to the previous stack
      frame (towards the caller), or "None" if this is the bottom
      stack frame; "f_code" is the code object being executed in this
      frame; "f_locals" is the dictionary used to look up local
      variables; "f_globals" is used for global variables;
      "f_builtins" is used for built-in (intrinsic) names; "f_lasti"
      gives the precise instruction (this is an index into the
      bytecode string of the code object).

      Accessing "f_code" raises an auditing event "object.__getattr__"
      with arguments "obj" and ""f_code"".

      Special writable attributes: "f_trace", if not "None", is a
      function called for various events during code execution (this
      is used by the debugger). Normally an event is triggered for
      each new source line - this can be disabled by setting
      "f_trace_lines" to "False".

      Implementations *may* allow per-opcode events to be requested by
      setting "f_trace_opcodes" to "True". Note that this may lead to
      undefined interpreter behaviour if exceptions raised by the
      trace function escape to the function being traced.

      "f_lineno" is the current line number of the frame — writing to
      this from within a trace function jumps to the given line (only
      for the bottom-most frame).  A debugger can implement a Jump
      command (aka Set Next Statement) by writing to f_lineno.

      Frame objects support one method:

      frame.clear()

         This method clears all references to local variables held by
         the frame.  Also, if the frame belonged to a generator, the
         generator is finalized.  This helps break reference cycles
         involving frame objects (for example when catching an
         exception and storing its traceback for later use).

         "RuntimeError" is raised if the frame is currently executing.

         New in version 3.4.

   Traceback objects
      Traceback objects represent a stack trace of an exception.  A
      traceback object is implicitly created when an exception occurs,
      and may also be explicitly created by calling
      "types.TracebackType".

      For implicitly created tracebacks, when the search for an
      exception handler unwinds the execution stack, at each unwound
      level a traceback object is inserted in front of the current
      traceback.  When an exception handler is entered, the stack
      trace is made available to the program. (See section The try
      statement.) It is accessible as the third item of the tuple
      returned by "sys.exc_info()", and as the "__traceback__"
      attribute of the caught exception.

      When the program contains no suitable handler, the stack trace
      is written (nicely formatted) to the standard error stream; if
      the interpreter is interactive, it is also made available to the
      user as "sys.last_traceback".

      For explicitly created tracebacks, it is up to the creator of
      the traceback to determine how the "tb_next" attributes should
      be linked to form a full stack trace.

      Special read-only attributes: "tb_frame" points to the execution
      frame of the current level; "tb_lineno" gives the line number
      where the exception occurred; "tb_lasti" indicates the precise
      instruction. The line number and last instruction in the
      traceback may differ from the line number of its frame object if
      the exception occurred in a "try" statement with no matching
      except clause or with a finally clause.

      Accessing "tb_frame" raises an auditing event
      "object.__getattr__" with arguments "obj" and ""tb_frame"".

      Special writable attribute: "tb_next" is the next level in the
      stack trace (towards the frame where the exception occurred), or
      "None" if there is no next level.

      Changed in version 3.7: Traceback objects can now be explicitly
      instantiated from Python code, and the "tb_next" attribute of
      existing instances can be updated.

   Slice objects
      Slice objects are used to represent slices for "__getitem__()"
      methods.  They are also created by the built-in "slice()"
      function.

      Special read-only attributes: "start" is the lower bound; "stop"
      is the upper bound; "step" is the step value; each is "None" if
      omitted.  These attributes can have any type.

      Slice objects support one method:

      slice.indices(self, length)

         This method takes a single integer argument *length* and
         computes information about the slice that the slice object
         would describe if applied to a sequence of *length* items.
         It returns a tuple of three integers; respectively these are
         the *start* and *stop* indices and the *step* or stride
         length of the slice. Missing or out-of-bounds indices are
         handled in a manner consistent with regular slices.

   Static method objects
      Static method objects provide a way of defeating the
      transformation of function objects to method objects described
      above. A static method object is a wrapper around any other
      object, usually a user-defined method object. When a static
      method object is retrieved from a class or a class instance, the
      object actually returned is the wrapped object, which is not
      subject to any further transformation. Static method objects are
      not themselves callable, although the objects they wrap usually
      are. Static method objects are created by the built-in
      "staticmethod()" constructor.

   Class method objects
      A class method object, like a static method object, is a wrapper
      around another object that alters the way in which that object
      is retrieved from classes and class instances. The behaviour of
      class method objects upon such retrieval is described above,
      under “User-defined methods”. Class method objects are created
      by the built-in "classmethod()" constructor.
a�Functions
*********

Function objects are created by function definitions.  The only
operation on a function object is to call it: "func(argument-list)".

There are really two flavors of function objects: built-in functions
and user-defined functions.  Both support the same operation (to call
the function), but the implementation is different, hence the
different object types.

See Function definitions for more information.
u(.Mapping Types — "dict"
**********************

A *mapping* object maps *hashable* values to arbitrary objects.
Mappings are mutable objects.  There is currently only one standard
mapping type, the *dictionary*.  (For other containers see the built-
in "list", "set", and "tuple" classes, and the "collections" module.)

A dictionary’s keys are *almost* arbitrary values.  Values that are
not *hashable*, that is, values containing lists, dictionaries or
other mutable types (that are compared by value rather than by object
identity) may not be used as keys.  Numeric types used for keys obey
the normal rules for numeric comparison: if two numbers compare equal
(such as "1" and "1.0") then they can be used interchangeably to index
the same dictionary entry.  (Note however, that since computers store
floating-point numbers as approximations it is usually unwise to use
them as dictionary keys.)

Dictionaries can be created by placing a comma-separated list of "key:
value" pairs within braces, for example: "{'jack': 4098, 'sjoerd':
4127}" or "{4098: 'jack', 4127: 'sjoerd'}", or by the "dict"
constructor.

class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)

   Return a new dictionary initialized from an optional positional
   argument and a possibly empty set of keyword arguments.

   Dictionaries can be created by several means:

   * Use a comma-separated list of "key: value" pairs within braces:
     "{'jack': 4098, 'sjoerd': 4127}" or "{4098: 'jack', 4127:
     'sjoerd'}"

   * Use a dict comprehension: "{}", "{x: x ** 2 for x in range(10)}"

   * Use the type constructor: "dict()", "dict([('foo', 100), ('bar',
     200)])", "dict(foo=100, bar=200)"

   If no positional argument is given, an empty dictionary is created.
   If a positional argument is given and it is a mapping object, a
   dictionary is created with the same key-value pairs as the mapping
   object.  Otherwise, the positional argument must be an *iterable*
   object.  Each item in the iterable must itself be an iterable with
   exactly two objects.  The first object of each item becomes a key
   in the new dictionary, and the second object the corresponding
   value.  If a key occurs more than once, the last value for that key
   becomes the corresponding value in the new dictionary.

   If keyword arguments are given, the keyword arguments and their
   values are added to the dictionary created from the positional
   argument.  If a key being added is already present, the value from
   the keyword argument replaces the value from the positional
   argument.

   To illustrate, the following examples all return a dictionary equal
   to "{"one": 1, "two": 2, "three": 3}":

      >>> a = dict(one=1, two=2, three=3)
      >>> b = {'one': 1, 'two': 2, 'three': 3}
      >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
      >>> d = dict([('two', 2), ('one', 1), ('three', 3)])
      >>> e = dict({'three': 3, 'one': 1, 'two': 2})
      >>> a == b == c == d == e
      True

   Providing keyword arguments as in the first example only works for
   keys that are valid Python identifiers.  Otherwise, any valid keys
   can be used.

   These are the operations that dictionaries support (and therefore,
   custom mapping types should support too):

   list(d)

      Return a list of all the keys used in the dictionary *d*.

   len(d)

      Return the number of items in the dictionary *d*.

   d[key]

      Return the item of *d* with key *key*.  Raises a "KeyError" if
      *key* is not in the map.

      If a subclass of dict defines a method "__missing__()" and *key*
      is not present, the "d[key]" operation calls that method with
      the key *key* as argument.  The "d[key]" operation then returns
      or raises whatever is returned or raised by the
      "__missing__(key)" call. No other operations or methods invoke
      "__missing__()". If "__missing__()" is not defined, "KeyError"
      is raised. "__missing__()" must be a method; it cannot be an
      instance variable:

         >>> class Counter(dict):
         ...     def __missing__(self, key):
         ...         return 0
         >>> c = Counter()
         >>> c['red']
         0
         >>> c['red'] += 1
         >>> c['red']
         1

      The example above shows part of the implementation of
      "collections.Counter".  A different "__missing__" method is used
      by "collections.defaultdict".

   d[key] = value

      Set "d[key]" to *value*.

   del d[key]

      Remove "d[key]" from *d*.  Raises a "KeyError" if *key* is not
      in the map.

   key in d

      Return "True" if *d* has a key *key*, else "False".

   key not in d

      Equivalent to "not key in d".

   iter(d)

      Return an iterator over the keys of the dictionary.  This is a
      shortcut for "iter(d.keys())".

   clear()

      Remove all items from the dictionary.

   copy()

      Return a shallow copy of the dictionary.

   classmethod fromkeys(iterable[, value])

      Create a new dictionary with keys from *iterable* and values set
      to *value*.

      "fromkeys()" is a class method that returns a new dictionary.
      *value* defaults to "None".  All of the values refer to just a
      single instance, so it generally doesn’t make sense for *value*
      to be a mutable object such as an empty list.  To get distinct
      values, use a dict comprehension instead.

   get(key[, default])

      Return the value for *key* if *key* is in the dictionary, else
      *default*. If *default* is not given, it defaults to "None", so
      that this method never raises a "KeyError".

   items()

      Return a new view of the dictionary’s items ("(key, value)"
      pairs). See the documentation of view objects.

   keys()

      Return a new view of the dictionary’s keys.  See the
      documentation of view objects.

   pop(key[, default])

      If *key* is in the dictionary, remove it and return its value,
      else return *default*.  If *default* is not given and *key* is
      not in the dictionary, a "KeyError" is raised.

   popitem()

      Remove and return a "(key, value)" pair from the dictionary.
      Pairs are returned in LIFO (last-in, first-out) order.

      "popitem()" is useful to destructively iterate over a
      dictionary, as often used in set algorithms.  If the dictionary
      is empty, calling "popitem()" raises a "KeyError".

      Changed in version 3.7: LIFO order is now guaranteed. In prior
      versions, "popitem()" would return an arbitrary key/value pair.

   reversed(d)

      Return a reverse iterator over the keys of the dictionary. This
      is a shortcut for "reversed(d.keys())".

      New in version 3.8.

   setdefault(key[, default])

      If *key* is in the dictionary, return its value.  If not, insert
      *key* with a value of *default* and return *default*.  *default*
      defaults to "None".

   update([other])

      Update the dictionary with the key/value pairs from *other*,
      overwriting existing keys.  Return "None".

      "update()" accepts either another dictionary object or an
      iterable of key/value pairs (as tuples or other iterables of
      length two).  If keyword arguments are specified, the dictionary
      is then updated with those key/value pairs: "d.update(red=1,
      blue=2)".

   values()

      Return a new view of the dictionary’s values.  See the
      documentation of view objects.

      An equality comparison between one "dict.values()" view and
      another will always return "False". This also applies when
      comparing "dict.values()" to itself:

         >>> d = {'a': 1}
         >>> d.values() == d.values()
         False

   Dictionaries compare equal if and only if they have the same "(key,
   value)" pairs (regardless of ordering). Order comparisons (‘<’,
   ‘<=’, ‘>=’, ‘>’) raise "TypeError".

   Dictionaries preserve insertion order.  Note that updating a key
   does not affect the order.  Keys added after deletion are inserted
   at the end.

      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
      >>> d
      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
      >>> list(d)
      ['one', 'two', 'three', 'four']
      >>> list(d.values())
      [1, 2, 3, 4]
      >>> d["one"] = 42
      >>> d
      {'one': 42, 'two': 2, 'three': 3, 'four': 4}
      >>> del d["two"]
      >>> d["two"] = None
      >>> d
      {'one': 42, 'three': 3, 'four': 4, 'two': None}

   Changed in version 3.7: Dictionary order is guaranteed to be
   insertion order.  This behavior was an implementation detail of
   CPython from 3.6.

   Dictionaries and dictionary views are reversible.

      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
      >>> d
      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
      >>> list(reversed(d))
      ['four', 'three', 'two', 'one']
      >>> list(reversed(d.values()))
      [4, 3, 2, 1]
      >>> list(reversed(d.items()))
      [('four', 4), ('three', 3), ('two', 2), ('one', 1)]

   Changed in version 3.8: Dictionaries are now reversible.

See also:

  "types.MappingProxyType" can be used to create a read-only view of a
  "dict".


Dictionary view objects
=======================

The objects returned by "dict.keys()", "dict.values()" and
"dict.items()" are *view objects*.  They provide a dynamic view on the
dictionary’s entries, which means that when the dictionary changes,
the view reflects these changes.

Dictionary views can be iterated over to yield their respective data,
and support membership tests:

len(dictview)

   Return the number of entries in the dictionary.

iter(dictview)

   Return an iterator over the keys, values or items (represented as
   tuples of "(key, value)") in the dictionary.

   Keys and values are iterated over in insertion order. This allows
   the creation of "(value, key)" pairs using "zip()": "pairs =
   zip(d.values(), d.keys())".  Another way to create the same list is
   "pairs = [(v, k) for (k, v) in d.items()]".

   Iterating views while adding or deleting entries in the dictionary
   may raise a "RuntimeError" or fail to iterate over all entries.

   Changed in version 3.7: Dictionary order is guaranteed to be
   insertion order.

x in dictview

   Return "True" if *x* is in the underlying dictionary’s keys, values
   or items (in the latter case, *x* should be a "(key, value)"
   tuple).

reversed(dictview)

   Return a reverse iterator over the keys, values or items of the
   dictionary. The view will be iterated in reverse order of the
   insertion.

   Changed in version 3.8: Dictionary views are now reversible.

Keys views are set-like since their entries are unique and hashable.
If all values are hashable, so that "(key, value)" pairs are unique
and hashable, then the items view is also set-like.  (Values views are
not treated as set-like since the entries are generally not unique.)
For set-like views, all of the operations defined for the abstract
base class "collections.abc.Set" are available (for example, "==",
"<", or "^").

An example of dictionary view usage:

   >>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
   >>> keys = dishes.keys()
   >>> values = dishes.values()

   >>> # iteration
   >>> n = 0
   >>> for val in values:
   ...     n += val
   >>> print(n)
   504

   >>> # keys and values are iterated over in the same order (insertion order)
   >>> list(keys)
   ['eggs', 'sausage', 'bacon', 'spam']
   >>> list(values)
   [2, 1, 1, 500]

   >>> # view objects are dynamic and reflect dict changes
   >>> del dishes['eggs']
   >>> del dishes['sausage']
   >>> list(keys)
   ['bacon', 'spam']

   >>> # set operations
   >>> keys & {'eggs', 'bacon', 'salad'}
   {'bacon'}
   >>> keys ^ {'sausage', 'juice'}
   {'juice', 'sausage', 'bacon', 'spam'}
a�Methods
*******

Methods are functions that are called using the attribute notation.
There are two flavors: built-in methods (such as "append()" on lists)
and class instance methods.  Built-in methods are described with the
types that support them.

If you access a method (a function defined in a class namespace)
through an instance, you get a special object: a *bound method* (also
called *instance method*) object. When called, it will add the "self"
argument to the argument list.  Bound methods have two special read-
only attributes: "m.__self__" is the object on which the method
operates, and "m.__func__" is the function implementing the method.
Calling "m(arg-1, arg-2, ..., arg-n)" is completely equivalent to
calling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".

Like function objects, bound method objects support getting arbitrary
attributes.  However, since method attributes are actually stored on
the underlying function object ("meth.__func__"), setting method
attributes on bound methods is disallowed.  Attempting to set an
attribute on a method results in an "AttributeError" being raised.  In
order to set a method attribute, you need to explicitly set it on the
underlying function object:

   >>> class C:
   ...     def method(self):
   ...         pass
   ...
   >>> c = C()
   >>> c.method.whoami = 'my name is method'  # can't set on the method
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   AttributeError: 'method' object has no attribute 'whoami'
   >>> c.method.__func__.whoami = 'my name is method'
   >>> c.method.whoami
   'my name is method'

See The standard type hierarchy for more information.
u$Modules
*******

The only special operation on a module is attribute access: "m.name",
where *m* is a module and *name* accesses a name defined in *m*’s
symbol table. Module attributes can be assigned to.  (Note that the
"import" statement is not, strictly speaking, an operation on a module
object; "import foo" does not require a module object named *foo* to
exist, rather it requires an (external) *definition* for a module
named *foo* somewhere.)

A special attribute of every module is "__dict__". This is the
dictionary containing the module’s symbol table. Modifying this
dictionary will actually change the module’s symbol table, but direct
assignment to the "__dict__" attribute is not possible (you can write
"m.__dict__['a'] = 1", which defines "m.a" to be "1", but you can’t
write "m.__dict__ = {}").  Modifying "__dict__" directly is not
recommended.

Modules built into the interpreter are written like this: "<module
'sys' (built-in)>".  If loaded from a file, they are written as
"<module 'os' from '/usr/local/lib/pythonX.Y/os.pyc'>".
u�ZSequence Types — "list", "tuple", "range"
*****************************************

There are three basic sequence types: lists, tuples, and range
objects. Additional sequence types tailored for processing of binary
data and text strings are described in dedicated sections.


Common Sequence Operations
==========================

The operations in the following table are supported by most sequence
types, both mutable and immutable. The "collections.abc.Sequence" ABC
is provided to make it easier to correctly implement these operations
on custom sequence types.

This table lists the sequence operations sorted in ascending priority.
In the table, *s* and *t* are sequences of the same type, *n*, *i*,
*j* and *k* are integers and *x* is an arbitrary object that meets any
type and value restrictions imposed by *s*.

The "in" and "not in" operations have the same priorities as the
comparison operations. The "+" (concatenation) and "*" (repetition)
operations have the same priority as the corresponding numeric
operations. [3]

+----------------------------+----------------------------------+------------+
| Operation                  | Result                           | Notes      |
|============================|==================================|============|
| "x in s"                   | "True" if an item of *s* is      | (1)        |
|                            | equal to *x*, else "False"       |            |
+----------------------------+----------------------------------+------------+
| "x not in s"               | "False" if an item of *s* is     | (1)        |
|                            | equal to *x*, else "True"        |            |
+----------------------------+----------------------------------+------------+
| "s + t"                    | the concatenation of *s* and *t* | (6)(7)     |
+----------------------------+----------------------------------+------------+
| "s * n" or "n * s"         | equivalent to adding *s* to      | (2)(7)     |
|                            | itself *n* times                 |            |
+----------------------------+----------------------------------+------------+
| "s[i]"                     | *i*th item of *s*, origin 0      | (3)        |
+----------------------------+----------------------------------+------------+
| "s[i:j]"                   | slice of *s* from *i* to *j*     | (3)(4)     |
+----------------------------+----------------------------------+------------+
| "s[i:j:k]"                 | slice of *s* from *i* to *j*     | (3)(5)     |
|                            | with step *k*                    |            |
+----------------------------+----------------------------------+------------+
| "len(s)"                   | length of *s*                    |            |
+----------------------------+----------------------------------+------------+
| "min(s)"                   | smallest item of *s*             |            |
+----------------------------+----------------------------------+------------+
| "max(s)"                   | largest item of *s*              |            |
+----------------------------+----------------------------------+------------+
| "s.index(x[, i[, j]])"     | index of the first occurrence of | (8)        |
|                            | *x* in *s* (at or after index    |            |
|                            | *i* and before index *j*)        |            |
+----------------------------+----------------------------------+------------+
| "s.count(x)"               | total number of occurrences of   |            |
|                            | *x* in *s*                       |            |
+----------------------------+----------------------------------+------------+

Sequences of the same type also support comparisons.  In particular,
tuples and lists are compared lexicographically by comparing
corresponding elements. This means that to compare equal, every
element must compare equal and the two sequences must be of the same
type and have the same length.  (For full details see Comparisons in
the language reference.)

Notes:

1. While the "in" and "not in" operations are used only for simple
   containment testing in the general case, some specialised sequences
   (such as "str", "bytes" and "bytearray") also use them for
   subsequence testing:

      >>> "gg" in "eggs"
      True

2. Values of *n* less than "0" are treated as "0" (which yields an
   empty sequence of the same type as *s*).  Note that items in the
   sequence *s* are not copied; they are referenced multiple times.
   This often haunts new Python programmers; consider:

      >>> lists = [[]] * 3
      >>> lists
      [[], [], []]
      >>> lists[0].append(3)
      >>> lists
      [[3], [3], [3]]

   What has happened is that "[[]]" is a one-element list containing
   an empty list, so all three elements of "[[]] * 3" are references
   to this single empty list.  Modifying any of the elements of
   "lists" modifies this single list. You can create a list of
   different lists this way:

      >>> lists = [[] for i in range(3)]
      >>> lists[0].append(3)
      >>> lists[1].append(5)
      >>> lists[2].append(7)
      >>> lists
      [[3], [5], [7]]

   Further explanation is available in the FAQ entry How do I create a
   multidimensional list?.

3. If *i* or *j* is negative, the index is relative to the end of
   sequence *s*: "len(s) + i" or "len(s) + j" is substituted.  But
   note that "-0" is still "0".

4. The slice of *s* from *i* to *j* is defined as the sequence of
   items with index *k* such that "i <= k < j".  If *i* or *j* is
   greater than "len(s)", use "len(s)".  If *i* is omitted or "None",
   use "0".  If *j* is omitted or "None", use "len(s)".  If *i* is
   greater than or equal to *j*, the slice is empty.

5. The slice of *s* from *i* to *j* with step *k* is defined as the
   sequence of items with index  "x = i + n*k" such that "0 <= n <
   (j-i)/k".  In other words, the indices are "i", "i+k", "i+2*k",
   "i+3*k" and so on, stopping when *j* is reached (but never
   including *j*).  When *k* is positive, *i* and *j* are reduced to
   "len(s)" if they are greater. When *k* is negative, *i* and *j* are
   reduced to "len(s) - 1" if they are greater.  If *i* or *j* are
   omitted or "None", they become “end” values (which end depends on
   the sign of *k*).  Note, *k* cannot be zero. If *k* is "None", it
   is treated like "1".

6. Concatenating immutable sequences always results in a new object.
   This means that building up a sequence by repeated concatenation
   will have a quadratic runtime cost in the total sequence length.
   To get a linear runtime cost, you must switch to one of the
   alternatives below:

   * if concatenating "str" objects, you can build a list and use
     "str.join()" at the end or else write to an "io.StringIO"
     instance and retrieve its value when complete

   * if concatenating "bytes" objects, you can similarly use
     "bytes.join()" or "io.BytesIO", or you can do in-place
     concatenation with a "bytearray" object.  "bytearray" objects are
     mutable and have an efficient overallocation mechanism

   * if concatenating "tuple" objects, extend a "list" instead

   * for other types, investigate the relevant class documentation

7. Some sequence types (such as "range") only support item sequences
   that follow specific patterns, and hence don’t support sequence
   concatenation or repetition.

8. "index" raises "ValueError" when *x* is not found in *s*. Not all
   implementations support passing the additional arguments *i* and
   *j*. These arguments allow efficient searching of subsections of
   the sequence. Passing the extra arguments is roughly equivalent to
   using "s[i:j].index(x)", only without copying any data and with the
   returned index being relative to the start of the sequence rather
   than the start of the slice.


Immutable Sequence Types
========================

The only operation that immutable sequence types generally implement
that is not also implemented by mutable sequence types is support for
the "hash()" built-in.

This support allows immutable sequences, such as "tuple" instances, to
be used as "dict" keys and stored in "set" and "frozenset" instances.

Attempting to hash an immutable sequence that contains unhashable
values will result in "TypeError".


Mutable Sequence Types
======================

The operations in the following table are defined on mutable sequence
types. The "collections.abc.MutableSequence" ABC is provided to make
it easier to correctly implement these operations on custom sequence
types.

In the table *s* is an instance of a mutable sequence type, *t* is any
iterable object and *x* is an arbitrary object that meets any type and
value restrictions imposed by *s* (for example, "bytearray" only
accepts integers that meet the value restriction "0 <= x <= 255").

+--------------------------------+----------------------------------+-----------------------+
| Operation                      | Result                           | Notes                 |
|================================|==================================|=======================|
| "s[i] = x"                     | item *i* of *s* is replaced by   |                       |
|                                | *x*                              |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j] = t"                   | slice of *s* from *i* to *j* is  |                       |
|                                | replaced by the contents of the  |                       |
|                                | iterable *t*                     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j]"                   | same as "s[i:j] = []"            |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j:k] = t"                 | the elements of "s[i:j:k]" are   | (1)                   |
|                                | replaced by those of *t*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j:k]"                 | removes the elements of          |                       |
|                                | "s[i:j:k]" from the list         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)"                  | appends *x* to the end of the    |                       |
|                                | sequence (same as                |                       |
|                                | "s[len(s):len(s)] = [x]")        |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()"                    | removes all items from *s* (same | (5)                   |
|                                | as "del s[:]")                   |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()"                     | creates a shallow copy of *s*    | (5)                   |
|                                | (same as "s[:]")                 |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t"      | extends *s* with the contents of |                       |
|                                | *t* (for the most part the same  |                       |
|                                | as "s[len(s):len(s)] = t")       |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n"                       | updates *s* with its contents    | (6)                   |
|                                | repeated *n* times               |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)"               | inserts *x* into *s* at the      |                       |
|                                | index given by *i* (same as      |                       |
|                                | "s[i:i] = [x]")                  |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)"        | retrieves the item at *i* and    | (2)                   |
|                                | also removes it from *s*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)"                  | remove the first item from *s*   | (3)                   |
|                                | where "s[i]" is equal to *x*     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()"                  | reverses the items of *s* in     | (4)                   |
|                                | place                            |                       |
+--------------------------------+----------------------------------+-----------------------+

Notes:

1. *t* must have the same length as the slice it is replacing.

2. The optional argument *i* defaults to "-1", so that by default the
   last item is removed and returned.

3. "remove()" raises "ValueError" when *x* is not found in *s*.

4. The "reverse()" method modifies the sequence in place for economy
   of space when reversing a large sequence.  To remind users that it
   operates by side effect, it does not return the reversed sequence.

5. "clear()" and "copy()" are included for consistency with the
   interfaces of mutable containers that don’t support slicing
   operations (such as "dict" and "set"). "copy()" is not part of the
   "collections.abc.MutableSequence" ABC, but most concrete mutable
   sequence classes provide it.

   New in version 3.3: "clear()" and "copy()" methods.

6. The value *n* is an integer, or an object implementing
   "__index__()".  Zero and negative values of *n* clear the sequence.
   Items in the sequence are not copied; they are referenced multiple
   times, as explained for "s * n" under Common Sequence Operations.


Lists
=====

Lists are mutable sequences, typically used to store collections of
homogeneous items (where the precise degree of similarity will vary by
application).

class list([iterable])

   Lists may be constructed in several ways:

   * Using a pair of square brackets to denote the empty list: "[]"

   * Using square brackets, separating items with commas: "[a]", "[a,
     b, c]"

   * Using a list comprehension: "[x for x in iterable]"

   * Using the type constructor: "list()" or "list(iterable)"

   The constructor builds a list whose items are the same and in the
   same order as *iterable*’s items.  *iterable* may be either a
   sequence, a container that supports iteration, or an iterator
   object.  If *iterable* is already a list, a copy is made and
   returned, similar to "iterable[:]". For example, "list('abc')"
   returns "['a', 'b', 'c']" and "list( (1, 2, 3) )" returns "[1, 2,
   3]". If no argument is given, the constructor creates a new empty
   list, "[]".

   Many other operations also produce lists, including the "sorted()"
   built-in.

   Lists implement all of the common and mutable sequence operations.
   Lists also provide the following additional method:

   sort(*, key=None, reverse=False)

      This method sorts the list in place, using only "<" comparisons
      between items. Exceptions are not suppressed - if any comparison
      operations fail, the entire sort operation will fail (and the
      list will likely be left in a partially modified state).

      "sort()" accepts two arguments that can only be passed by
      keyword (keyword-only arguments):

      *key* specifies a function of one argument that is used to
      extract a comparison key from each list element (for example,
      "key=str.lower"). The key corresponding to each item in the list
      is calculated once and then used for the entire sorting process.
      The default value of "None" means that list items are sorted
      directly without calculating a separate key value.

      The "functools.cmp_to_key()" utility is available to convert a
      2.x style *cmp* function to a *key* function.

      *reverse* is a boolean value.  If set to "True", then the list
      elements are sorted as if each comparison were reversed.

      This method modifies the sequence in place for economy of space
      when sorting a large sequence.  To remind users that it operates
      by side effect, it does not return the sorted sequence (use
      "sorted()" to explicitly request a new sorted list instance).

      The "sort()" method is guaranteed to be stable.  A sort is
      stable if it guarantees not to change the relative order of
      elements that compare equal — this is helpful for sorting in
      multiple passes (for example, sort by department, then by salary
      grade).

      For sorting examples and a brief sorting tutorial, see Sorting
      HOW TO.

      **CPython implementation detail:** While a list is being sorted,
      the effect of attempting to mutate, or even inspect, the list is
      undefined.  The C implementation of Python makes the list appear
      empty for the duration, and raises "ValueError" if it can detect
      that the list has been mutated during a sort.


Tuples
======

Tuples are immutable sequences, typically used to store collections of
heterogeneous data (such as the 2-tuples produced by the "enumerate()"
built-in). Tuples are also used for cases where an immutable sequence
of homogeneous data is needed (such as allowing storage in a "set" or
"dict" instance).

class tuple([iterable])

   Tuples may be constructed in a number of ways:

   * Using a pair of parentheses to denote the empty tuple: "()"

   * Using a trailing comma for a singleton tuple: "a," or "(a,)"

   * Separating items with commas: "a, b, c" or "(a, b, c)"

   * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"

   The constructor builds a tuple whose items are the same and in the
   same order as *iterable*’s items.  *iterable* may be either a
   sequence, a container that supports iteration, or an iterator
   object.  If *iterable* is already a tuple, it is returned
   unchanged. For example, "tuple('abc')" returns "('a', 'b', 'c')"
   and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is
   given, the constructor creates a new empty tuple, "()".

   Note that it is actually the comma which makes a tuple, not the
   parentheses. The parentheses are optional, except in the empty
   tuple case, or when they are needed to avoid syntactic ambiguity.
   For example, "f(a, b, c)" is a function call with three arguments,
   while "f((a, b, c))" is a function call with a 3-tuple as the sole
   argument.

   Tuples implement all of the common sequence operations.

For heterogeneous collections of data where access by name is clearer
than access by index, "collections.namedtuple()" may be a more
appropriate choice than a simple tuple object.


Ranges
======

The "range" type represents an immutable sequence of numbers and is
commonly used for looping a specific number of times in "for" loops.

class range(stop)
class range(start, stop[, step])

   The arguments to the range constructor must be integers (either
   built-in "int" or any object that implements the "__index__"
   special method).  If the *step* argument is omitted, it defaults to
   "1". If the *start* argument is omitted, it defaults to "0". If
   *step* is zero, "ValueError" is raised.

   For a positive *step*, the contents of a range "r" are determined
   by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <
   stop".

   For a negative *step*, the contents of the range are still
   determined by the formula "r[i] = start + step*i", but the
   constraints are "i >= 0" and "r[i] > stop".

   A range object will be empty if "r[0]" does not meet the value
   constraint. Ranges do support negative indices, but these are
   interpreted as indexing from the end of the sequence determined by
   the positive indices.

   Ranges containing absolute values larger than "sys.maxsize" are
   permitted but some features (such as "len()") may raise
   "OverflowError".

   Range examples:

      >>> list(range(10))
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      >>> list(range(1, 11))
      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      >>> list(range(0, 30, 5))
      [0, 5, 10, 15, 20, 25]
      >>> list(range(0, 10, 3))
      [0, 3, 6, 9]
      >>> list(range(0, -10, -1))
      [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
      >>> list(range(0))
      []
      >>> list(range(1, 0))
      []

   Ranges implement all of the common sequence operations except
   concatenation and repetition (due to the fact that range objects
   can only represent sequences that follow a strict pattern and
   repetition and concatenation will usually violate that pattern).

   start

      The value of the *start* parameter (or "0" if the parameter was
      not supplied)

   stop

      The value of the *stop* parameter

   step

      The value of the *step* parameter (or "1" if the parameter was
      not supplied)

The advantage of the "range" type over a regular "list" or "tuple" is
that a "range" object will always take the same (small) amount of
memory, no matter the size of the range it represents (as it only
stores the "start", "stop" and "step" values, calculating individual
items and subranges as needed).

Range objects implement the "collections.abc.Sequence" ABC, and
provide features such as containment tests, element index lookup,
slicing and support for negative indices (see Sequence Types — list,
tuple, range):

>>> r = range(0, 20, 2)
>>> r
range(0, 20, 2)
>>> 11 in r
False
>>> 10 in r
True
>>> r.index(10)
5
>>> r[5]
10
>>> r[:5]
range(0, 10, 2)
>>> r[-1]
18

Testing range objects for equality with "==" and "!=" compares them as
sequences.  That is, two range objects are considered equal if they
represent the same sequence of values.  (Note that two range objects
that compare equal might have different "start", "stop" and "step"
attributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,
2) == range(0, 4, 2)".)

Changed in version 3.2: Implement the Sequence ABC. Support slicing
and negative indices. Test "int" objects for membership in constant
time instead of iterating through all items.

Changed in version 3.3: Define ‘==’ and ‘!=’ to compare range objects
based on the sequence of values they define (instead of comparing
based on object identity).

New in version 3.3: The "start", "stop" and "step" attributes.

See also:

  * The linspace recipe shows how to implement a lazy version of range
    suitable for floating point applications.
u�Mutable Sequence Types
**********************

The operations in the following table are defined on mutable sequence
types. The "collections.abc.MutableSequence" ABC is provided to make
it easier to correctly implement these operations on custom sequence
types.

In the table *s* is an instance of a mutable sequence type, *t* is any
iterable object and *x* is an arbitrary object that meets any type and
value restrictions imposed by *s* (for example, "bytearray" only
accepts integers that meet the value restriction "0 <= x <= 255").

+--------------------------------+----------------------------------+-----------------------+
| Operation                      | Result                           | Notes                 |
|================================|==================================|=======================|
| "s[i] = x"                     | item *i* of *s* is replaced by   |                       |
|                                | *x*                              |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j] = t"                   | slice of *s* from *i* to *j* is  |                       |
|                                | replaced by the contents of the  |                       |
|                                | iterable *t*                     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j]"                   | same as "s[i:j] = []"            |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j:k] = t"                 | the elements of "s[i:j:k]" are   | (1)                   |
|                                | replaced by those of *t*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j:k]"                 | removes the elements of          |                       |
|                                | "s[i:j:k]" from the list         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)"                  | appends *x* to the end of the    |                       |
|                                | sequence (same as                |                       |
|                                | "s[len(s):len(s)] = [x]")        |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()"                    | removes all items from *s* (same | (5)                   |
|                                | as "del s[:]")                   |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()"                     | creates a shallow copy of *s*    | (5)                   |
|                                | (same as "s[:]")                 |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t"      | extends *s* with the contents of |                       |
|                                | *t* (for the most part the same  |                       |
|                                | as "s[len(s):len(s)] = t")       |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n"                       | updates *s* with its contents    | (6)                   |
|                                | repeated *n* times               |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)"               | inserts *x* into *s* at the      |                       |
|                                | index given by *i* (same as      |                       |
|                                | "s[i:i] = [x]")                  |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)"        | retrieves the item at *i* and    | (2)                   |
|                                | also removes it from *s*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)"                  | remove the first item from *s*   | (3)                   |
|                                | where "s[i]" is equal to *x*     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()"                  | reverses the items of *s* in     | (4)                   |
|                                | place                            |                       |
+--------------------------------+----------------------------------+-----------------------+

Notes:

1. *t* must have the same length as the slice it is replacing.

2. The optional argument *i* defaults to "-1", so that by default the
   last item is removed and returned.

3. "remove()" raises "ValueError" when *x* is not found in *s*.

4. The "reverse()" method modifies the sequence in place for economy
   of space when reversing a large sequence.  To remind users that it
   operates by side effect, it does not return the reversed sequence.

5. "clear()" and "copy()" are included for consistency with the
   interfaces of mutable containers that don’t support slicing
   operations (such as "dict" and "set"). "copy()" is not part of the
   "collections.abc.MutableSequence" ABC, but most concrete mutable
   sequence classes provide it.

   New in version 3.3: "clear()" and "copy()" methods.

6. The value *n* is an integer, or an object implementing
   "__index__()".  Zero and negative values of *n* clear the sequence.
   Items in the sequence are not copied; they are referenced multiple
   times, as explained for "s * n" under Common Sequence Operations.
a~Unary arithmetic and bitwise operations
***************************************

All unary arithmetic and bitwise operations have the same priority:

   u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr

The unary "-" (minus) operator yields the negation of its numeric
argument.

The unary "+" (plus) operator yields its numeric argument unchanged.

The unary "~" (invert) operator yields the bitwise inversion of its
integer argument.  The bitwise inversion of "x" is defined as
"-(x+1)".  It only applies to integral numbers.

In all three cases, if the argument does not have the proper type, a
"TypeError" exception is raised.
u�The "while" statement
*********************

The "while" statement is used for repeated execution as long as an
expression is true:

   while_stmt ::= "while" assignment_expression ":" suite
                  ["else" ":" suite]

This repeatedly tests the expression and, if it is true, executes the
first suite; if the expression is false (which may be the first time
it is tested) the suite of the "else" clause, if present, is executed
and the loop terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and goes back
to testing the expression.
uMThe "with" statement
********************

The "with" statement is used to wrap the execution of a block with
methods defined by a context manager (see section With Statement
Context Managers). This allows common "try"…"except"…"finally" usage
patterns to be encapsulated for convenient reuse.

   with_stmt ::= "with" with_item ("," with_item)* ":" suite
   with_item ::= expression ["as" target]

The execution of the "with" statement with one “item” proceeds as
follows:

1. The context expression (the expression given in the "with_item") is
   evaluated to obtain a context manager.

2. The context manager’s "__enter__()" is loaded for later use.

3. The context manager’s "__exit__()" is loaded for later use.

4. The context manager’s "__enter__()" method is invoked.

5. If a target was included in the "with" statement, the return value
   from "__enter__()" is assigned to it.

   Note:

     The "with" statement guarantees that if the "__enter__()" method
     returns without an error, then "__exit__()" will always be
     called. Thus, if an error occurs during the assignment to the
     target list, it will be treated the same as an error occurring
     within the suite would be. See step 6 below.

6. The suite is executed.

7. The context manager’s "__exit__()" method is invoked.  If an
   exception caused the suite to be exited, its type, value, and
   traceback are passed as arguments to "__exit__()". Otherwise, three
   "None" arguments are supplied.

   If the suite was exited due to an exception, and the return value
   from the "__exit__()" method was false, the exception is reraised.
   If the return value was true, the exception is suppressed, and
   execution continues with the statement following the "with"
   statement.

   If the suite was exited for any reason other than an exception, the
   return value from "__exit__()" is ignored, and execution proceeds
   at the normal location for the kind of exit that was taken.

The following code:

   with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   enter = type(manager).__enter__
   exit = type(manager).__exit__
   value = enter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not exit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           exit(manager, None, None, None)

With more than one item, the context managers are processed as if
multiple "with" statements were nested:

   with A() as a, B() as b:
       SUITE

is semantically equivalent to:

   with A() as a:
       with B() as b:
           SUITE

Changed in version 3.1: Support for multiple context expressions.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.
a,The "yield" statement
*********************

   yield_stmt ::= yield_expression

A "yield" statement is semantically equivalent to a yield expression.
The yield statement can be used to omit the parentheses that would
otherwise be required in the equivalent yield expression statement.
For example, the yield statements

   yield <expr>
   yield from <expr>

are equivalent to the yield expression statements

   (yield <expr>)
   (yield from <expr>)

Yield expressions and statements are only used when defining a
*generator* function, and are only used in the body of the generator
function.  Using yield in a function definition is sufficient to cause
that definition to create a generator function instead of a normal
function.

For full details of "yield" semantics, refer to the Yield expressions
section.
)O�assertZ
assignment�asynczatom-identifiersz
atom-literalszattribute-accesszattribute-referencesZ	augassign�awaitZbinaryZbitwisezbltin-code-objectszbltin-ellipsis-objectzbltin-null-objectzbltin-type-objectsZbooleans�breakzcallable-typesZcalls�classZcomparisonsZcompoundzcontext-managers�continueZconversionsZ
customizationZdebugger�del�dictzdynamic-features�else�
exceptionsZ	execmodelZ	exprlistsZfloating�forZ
formatstringsZfunction�globalz
id-classesZidentifiers�ifZ	imaginary�import�inZintegers�lambdaZlistsZnaming�nonlocalZnumbersz
numeric-typesZobjectszoperator-summary�passZpower�raise�returnzsequence-typesZshiftingZslicingsZspecialattrsZspecialnameszstring-methodsZstringsZ
subscriptions�truth�try�typesZtypesfunctionsZtypesmappingZtypesmethodsZtypesmodulesZtypesseqztypesseq-mutableZunary�while�with�yieldN)Ztopics�rr�)/usr/lib64/python3.8/pydoc_data/topics.py�<module>s'}(@	X1	=`bQ>J:3MD%I
H+1&.LN3"o#p3=^ai9;K9%Hh�������������������������������������������������������������������������������������������������������������PK86�\�W�~�~topics.cpython-38.opt-2.pycnu�[���U

e5d�s
�P@s�dddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(dd)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdN�OZdOS)PauThe "assert" statement
**********************

Assert statements are a convenient way to insert debugging assertions
into a program:

   assert_stmt ::= "assert" expression ["," expression]

The simple form, "assert expression", is equivalent to

   if __debug__:
       if not expression: raise AssertionError

The extended form, "assert expression1, expression2", is equivalent to

   if __debug__:
       if not expression1: raise AssertionError(expression2)

These equivalences assume that "__debug__" and "AssertionError" refer
to the built-in variables with those names.  In the current
implementation, the built-in variable "__debug__" is "True" under
normal circumstances, "False" when optimization is requested (command
line option "-O").  The current code generator emits no code for an
assert statement when optimization is requested at compile time.  Note
that it is unnecessary to include the source code for the expression
that failed in the error message; it will be displayed as part of the
stack trace.

Assignments to "__debug__" are illegal.  The value for the built-in
variable is determined when the interpreter starts.
u�,Assignment statements
*********************

Assignment statements are used to (re)bind names to values and to
modify attributes or items of mutable objects:

   assignment_stmt ::= (target_list "=")+ (starred_expression | yield_expression)
   target_list     ::= target ("," target)* [","]
   target          ::= identifier
              | "(" [target_list] ")"
              | "[" [target_list] "]"
              | attributeref
              | subscription
              | slicing
              | "*" target

(See section Primaries for the syntax definitions for *attributeref*,
*subscription*, and *slicing*.)

An assignment statement evaluates the expression list (remember that
this can be a single expression or a comma-separated list, the latter
yielding a tuple) and assigns the single resulting object to each of
the target lists, from left to right.

Assignment is defined recursively depending on the form of the target
(list). When a target is part of a mutable object (an attribute
reference, subscription or slicing), the mutable object must
ultimately perform the assignment and decide about its validity, and
may raise an exception if the assignment is unacceptable.  The rules
observed by various types and the exceptions raised are given with the
definition of the object types (see section The standard type
hierarchy).

Assignment of an object to a target list, optionally enclosed in
parentheses or square brackets, is recursively defined as follows.

* If the target list is a single target with no trailing comma,
  optionally in parentheses, the object is assigned to that target.

* Else: The object must be an iterable with the same number of items
  as there are targets in the target list, and the items are assigned,
  from left to right, to the corresponding targets.

  * If the target list contains one target prefixed with an asterisk,
    called a “starred” target: The object must be an iterable with at
    least as many items as there are targets in the target list, minus
    one.  The first items of the iterable are assigned, from left to
    right, to the targets before the starred target.  The final items
    of the iterable are assigned to the targets after the starred
    target.  A list of the remaining items in the iterable is then
    assigned to the starred target (the list can be empty).

  * Else: The object must be an iterable with the same number of items
    as there are targets in the target list, and the items are
    assigned, from left to right, to the corresponding targets.

Assignment of an object to a single target is recursively defined as
follows.

* If the target is an identifier (name):

  * If the name does not occur in a "global" or "nonlocal" statement
    in the current code block: the name is bound to the object in the
    current local namespace.

  * Otherwise: the name is bound to the object in the global namespace
    or the outer namespace determined by "nonlocal", respectively.

  The name is rebound if it was already bound.  This may cause the
  reference count for the object previously bound to the name to reach
  zero, causing the object to be deallocated and its destructor (if it
  has one) to be called.

* If the target is an attribute reference: The primary expression in
  the reference is evaluated.  It should yield an object with
  assignable attributes; if this is not the case, "TypeError" is
  raised.  That object is then asked to assign the assigned object to
  the given attribute; if it cannot perform the assignment, it raises
  an exception (usually but not necessarily "AttributeError").

  Note: If the object is a class instance and the attribute reference
  occurs on both sides of the assignment operator, the right-hand side
  expression, "a.x" can access either an instance attribute or (if no
  instance attribute exists) a class attribute.  The left-hand side
  target "a.x" is always set as an instance attribute, creating it if
  necessary.  Thus, the two occurrences of "a.x" do not necessarily
  refer to the same attribute: if the right-hand side expression
  refers to a class attribute, the left-hand side creates a new
  instance attribute as the target of the assignment:

     class Cls:
         x = 3             # class variable
     inst = Cls()
     inst.x = inst.x + 1   # writes inst.x as 4 leaving Cls.x as 3

  This description does not necessarily apply to descriptor
  attributes, such as properties created with "property()".

* If the target is a subscription: The primary expression in the
  reference is evaluated.  It should yield either a mutable sequence
  object (such as a list) or a mapping object (such as a dictionary).
  Next, the subscript expression is evaluated.

  If the primary is a mutable sequence object (such as a list), the
  subscript must yield an integer.  If it is negative, the sequence’s
  length is added to it.  The resulting value must be a nonnegative
  integer less than the sequence’s length, and the sequence is asked
  to assign the assigned object to its item with that index.  If the
  index is out of range, "IndexError" is raised (assignment to a
  subscripted sequence cannot add new items to a list).

  If the primary is a mapping object (such as a dictionary), the
  subscript must have a type compatible with the mapping’s key type,
  and the mapping is then asked to create a key/datum pair which maps
  the subscript to the assigned object.  This can either replace an
  existing key/value pair with the same key value, or insert a new
  key/value pair (if no key with the same value existed).

  For user-defined objects, the "__setitem__()" method is called with
  appropriate arguments.

* If the target is a slicing: The primary expression in the reference
  is evaluated.  It should yield a mutable sequence object (such as a
  list).  The assigned object should be a sequence object of the same
  type.  Next, the lower and upper bound expressions are evaluated,
  insofar they are present; defaults are zero and the sequence’s
  length.  The bounds should evaluate to integers. If either bound is
  negative, the sequence’s length is added to it.  The resulting
  bounds are clipped to lie between zero and the sequence’s length,
  inclusive.  Finally, the sequence object is asked to replace the
  slice with the items of the assigned sequence.  The length of the
  slice may be different from the length of the assigned sequence,
  thus changing the length of the target sequence, if the target
  sequence allows it.

**CPython implementation detail:** In the current implementation, the
syntax for targets is taken to be the same as for expressions, and
invalid syntax is rejected during the code generation phase, causing
less detailed error messages.

Although the definition of assignment implies that overlaps between
the left-hand side and the right-hand side are ‘simultaneous’ (for
example "a, b = b, a" swaps two variables), overlaps *within* the
collection of assigned-to variables occur left-to-right, sometimes
resulting in confusion.  For instance, the following program prints
"[0, 2]":

   x = [0, 1]
   i = 0
   i, x[i] = 1, 2         # i is updated, then x[i] is updated
   print(x)

See also:

  **PEP 3132** - Extended Iterable Unpacking
     The specification for the "*target" feature.


Augmented assignment statements
===============================

Augmented assignment is the combination, in a single statement, of a
binary operation and an assignment statement:

   augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)
   augtarget                 ::= identifier | attributeref | subscription | slicing
   augop                     ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
             | ">>=" | "<<=" | "&=" | "^=" | "|="

(See section Primaries for the syntax definitions of the last three
symbols.)

An augmented assignment evaluates the target (which, unlike normal
assignment statements, cannot be an unpacking) and the expression
list, performs the binary operation specific to the type of assignment
on the two operands, and assigns the result to the original target.
The target is only evaluated once.

An augmented assignment expression like "x += 1" can be rewritten as
"x = x + 1" to achieve a similar, but not exactly equal effect. In the
augmented version, "x" is only evaluated once. Also, when possible,
the actual operation is performed *in-place*, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.

Unlike normal assignments, augmented assignments evaluate the left-
hand side *before* evaluating the right-hand side.  For example, "a[i]
+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs
the addition, and lastly, it writes the result back to "a[i]".

With the exception of assigning to tuples and multiple targets in a
single statement, the assignment done by augmented assignment
statements is handled the same way as normal assignments. Similarly,
with the exception of the possible *in-place* behavior, the binary
operation performed by augmented assignment is the same as the normal
binary operations.

For targets which are attribute references, the same caveat about
class and instance attributes applies as for regular assignments.


Annotated assignment statements
===============================

*Annotation* assignment is the combination, in a single statement, of
a variable or attribute annotation and an optional assignment
statement:

   annotated_assignment_stmt ::= augtarget ":" expression
                                 ["=" (starred_expression | yield_expression)]

The difference from normal Assignment statements is that only single
target is allowed.

For simple names as assignment targets, if in class or module scope,
the annotations are evaluated and stored in a special class or module
attribute "__annotations__" that is a dictionary mapping from variable
names (mangled if private) to evaluated annotations. This attribute is
writable and is automatically created at the start of class or module
body execution, if annotations are found statically.

For expressions as assignment targets, the annotations are evaluated
if in class or module scope, but not stored.

If a name is annotated in a function scope, then this name is local
for that scope. Annotations are never evaluated and stored in function
scopes.

If the right hand side is present, an annotated assignment performs
the actual assignment before evaluating annotations (where
applicable). If the right hand side is not present for an expression
target, then the interpreter evaluates the target except for the last
"__setitem__()" or "__setattr__()" call.

See also:

  **PEP 526** - Syntax for Variable Annotations
     The proposal that added syntax for annotating the types of
     variables (including class variables and instance variables),
     instead of expressing them through comments.

  **PEP 484** - Type hints
     The proposal that added the "typing" module to provide a standard
     syntax for type annotations that can be used in static analysis
     tools and IDEs.

Changed in version 3.8: Now annotated assignments allow same
expressions in the right hand side as the regular assignments.
Previously, some expressions (like un-parenthesized tuple expressions)
caused a syntax error.
u>
Coroutines
**********

New in version 3.5.


Coroutine function definition
=============================

   async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")"
                     ["->" expression] ":" suite

Execution of Python coroutines can be suspended and resumed at many
points (see *coroutine*).  Inside the body of a coroutine function,
"await" and "async" identifiers become reserved keywords; "await"
expressions, "async for" and "async with" can only be used in
coroutine function bodies.

Functions defined with "async def" syntax are always coroutine
functions, even if they do not contain "await" or "async" keywords.

It is a "SyntaxError" to use a "yield from" expression inside the body
of a coroutine function.

An example of a coroutine function:

   async def func(param1, param2):
       do_stuff()
       await some_coroutine()


The "async for" statement
=========================

   async_for_stmt ::= "async" for_stmt

An *asynchronous iterable* is able to call asynchronous code in its
*iter* implementation, and *asynchronous iterator* can call
asynchronous code in its *next* method.

The "async for" statement allows convenient iteration over
asynchronous iterators.

The following code:

   async for TARGET in ITER:
       SUITE
   else:
       SUITE2

Is semantically equivalent to:

   iter = (ITER)
   iter = type(iter).__aiter__(iter)
   running = True

   while running:
       try:
           TARGET = await type(iter).__anext__(iter)
       except StopAsyncIteration:
           running = False
       else:
           SUITE
   else:
       SUITE2

See also "__aiter__()" and "__anext__()" for details.

It is a "SyntaxError" to use an "async for" statement outside the body
of a coroutine function.


The "async with" statement
==========================

   async_with_stmt ::= "async" with_stmt

An *asynchronous context manager* is a *context manager* that is able
to suspend execution in its *enter* and *exit* methods.

The following code:

   async with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   aexit = type(manager).__aexit__
   aenter = type(manager).__aenter__
   value = await aenter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not await aexit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           await aexit(manager, None, None, None)

See also "__aenter__()" and "__aexit__()" for details.

It is a "SyntaxError" to use an "async with" statement outside the
body of a coroutine function.

See also:

  **PEP 492** - Coroutines with async and await syntax
     The proposal that made coroutines a proper standalone concept in
     Python, and added supporting syntax.

-[ Footnotes ]-

[1] The exception is propagated to the invocation stack unless there
    is a "finally" clause which happens to raise another exception.
    That new exception causes the old one to be lost.

[2] A string literal appearing as the first statement in the function
    body is transformed into the function’s "__doc__" attribute and
    therefore the function’s *docstring*.

[3] A string literal appearing as the first statement in the class
    body is transformed into the namespace’s "__doc__" item and
    therefore the class’s *docstring*.
a�Identifiers (Names)
*******************

An identifier occurring as an atom is a name.  See section Identifiers
and keywords for lexical definition and section Naming and binding for
documentation of naming and binding.

When the name is bound to an object, evaluation of the atom yields
that object. When a name is not bound, an attempt to evaluate it
raises a "NameError" exception.

**Private name mangling:** When an identifier that textually occurs in
a class definition begins with two or more underscore characters and
does not end in two or more underscores, it is considered a *private
name* of that class. Private names are transformed to a longer form
before code is generated for them.  The transformation inserts the
class name, with leading underscores removed and a single underscore
inserted, in front of the name.  For example, the identifier "__spam"
occurring in a class named "Ham" will be transformed to "_Ham__spam".
This transformation is independent of the syntactical context in which
the identifier is used.  If the transformed name is extremely long
(longer than 255 characters), implementation defined truncation may
happen. If the class name consists only of underscores, no
transformation is done.
u
Literals
********

Python supports string and bytes literals and various numeric
literals:

   literal ::= stringliteral | bytesliteral
               | integer | floatnumber | imagnumber

Evaluation of a literal yields an object of the given type (string,
bytes, integer, floating point number, complex number) with the given
value.  The value may be approximated in the case of floating point
and imaginary (complex) literals.  See section Literals for details.

All literals correspond to immutable data types, and hence the
object’s identity is less important than its value.  Multiple
evaluations of literals with the same value (either the same
occurrence in the program text or a different occurrence) may obtain
the same object or a different object with the same value.
uA7Customizing attribute access
****************************

The following methods can be defined to customize the meaning of
attribute access (use of, assignment to, or deletion of "x.name") for
class instances.

object.__getattr__(self, name)

   Called when the default attribute access fails with an
   "AttributeError" (either "__getattribute__()" raises an
   "AttributeError" because *name* is not an instance attribute or an
   attribute in the class tree for "self"; or "__get__()" of a *name*
   property raises "AttributeError").  This method should either
   return the (computed) attribute value or raise an "AttributeError"
   exception.

   Note that if the attribute is found through the normal mechanism,
   "__getattr__()" is not called.  (This is an intentional asymmetry
   between "__getattr__()" and "__setattr__()".) This is done both for
   efficiency reasons and because otherwise "__getattr__()" would have
   no way to access other attributes of the instance.  Note that at
   least for instance variables, you can fake total control by not
   inserting any values in the instance attribute dictionary (but
   instead inserting them in another object).  See the
   "__getattribute__()" method below for a way to actually get total
   control over attribute access.

object.__getattribute__(self, name)

   Called unconditionally to implement attribute accesses for
   instances of the class. If the class also defines "__getattr__()",
   the latter will not be called unless "__getattribute__()" either
   calls it explicitly or raises an "AttributeError". This method
   should return the (computed) attribute value or raise an
   "AttributeError" exception. In order to avoid infinite recursion in
   this method, its implementation should always call the base class
   method with the same name to access any attributes it needs, for
   example, "object.__getattribute__(self, name)".

   Note:

     This method may still be bypassed when looking up special methods
     as the result of implicit invocation via language syntax or
     built-in functions. See Special method lookup.

   For certain sensitive attribute accesses, raises an auditing event
   "object.__getattr__" with arguments "obj" and "name".

object.__setattr__(self, name, value)

   Called when an attribute assignment is attempted.  This is called
   instead of the normal mechanism (i.e. store the value in the
   instance dictionary). *name* is the attribute name, *value* is the
   value to be assigned to it.

   If "__setattr__()" wants to assign to an instance attribute, it
   should call the base class method with the same name, for example,
   "object.__setattr__(self, name, value)".

   For certain sensitive attribute assignments, raises an auditing
   event "object.__setattr__" with arguments "obj", "name", "value".

object.__delattr__(self, name)

   Like "__setattr__()" but for attribute deletion instead of
   assignment.  This should only be implemented if "del obj.name" is
   meaningful for the object.

   For certain sensitive attribute deletions, raises an auditing event
   "object.__delattr__" with arguments "obj" and "name".

object.__dir__(self)

   Called when "dir()" is called on the object. A sequence must be
   returned. "dir()" converts the returned sequence to a list and
   sorts it.


Customizing module attribute access
===================================

Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
attribute and return the computed value or raise an "AttributeError".
If an attribute is not found on a module object through the normal
lookup, i.e. "object.__getattribute__()", then "__getattr__" is
searched in the module "__dict__" before raising an "AttributeError".
If found, it is called with the attribute name and the result is
returned.

The "__dir__" function should accept no arguments, and return a
sequence of strings that represents the names accessible on module. If
present, this function overrides the standard "dir()" search on a
module.

For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:

   import sys
   from types import ModuleType

   class VerboseModule(ModuleType):
       def __repr__(self):
           return f'Verbose {self.__name__}'

       def __setattr__(self, attr, value):
           print(f'Setting {attr}...')
           super().__setattr__(attr, value)

   sys.modules[__name__].__class__ = VerboseModule

Note:

  Defining module "__getattr__" and setting module "__class__" only
  affect lookups made using the attribute access syntax – directly
  accessing the module globals (whether by code within the module, or
  via a reference to the module’s globals dictionary) is unaffected.

Changed in version 3.5: "__class__" module attribute is now writable.

New in version 3.7: "__getattr__" and "__dir__" module attributes.

See also:

  **PEP 562** - Module __getattr__ and __dir__
     Describes the "__getattr__" and "__dir__" functions on modules.


Implementing Descriptors
========================

The following methods only apply when an instance of the class
containing the method (a so-called *descriptor* class) appears in an
*owner* class (the descriptor must be in either the owner’s class
dictionary or in the class dictionary for one of its parents).  In the
examples below, “the attribute” refers to the attribute whose name is
the key of the property in the owner class’ "__dict__".

object.__get__(self, instance, owner=None)

   Called to get the attribute of the owner class (class attribute
   access) or of an instance of that class (instance attribute
   access). The optional *owner* argument is the owner class, while
   *instance* is the instance that the attribute was accessed through,
   or "None" when the attribute is accessed through the *owner*.

   This method should return the computed attribute value or raise an
   "AttributeError" exception.

   **PEP 252** specifies that "__get__()" is callable with one or two
   arguments.  Python’s own built-in descriptors support this
   specification; however, it is likely that some third-party tools
   have descriptors that require both arguments.  Python’s own
   "__getattribute__()" implementation always passes in both arguments
   whether they are required or not.

object.__set__(self, instance, value)

   Called to set the attribute on an instance *instance* of the owner
   class to a new value, *value*.

   Note, adding "__set__()" or "__delete__()" changes the kind of
   descriptor to a “data descriptor”.  See Invoking Descriptors for
   more details.

object.__delete__(self, instance)

   Called to delete the attribute on an instance *instance* of the
   owner class.

object.__set_name__(self, owner, name)

   Called at the time the owning class *owner* is created. The
   descriptor has been assigned to *name*.

   Note:

     "__set_name__()" is only called implicitly as part of the "type"
     constructor, so it will need to be called explicitly with the
     appropriate parameters when a descriptor is added to a class
     after initial creation:

        class A:
           pass
        descr = custom_descriptor()
        A.attr = descr
        descr.__set_name__(A, 'attr')

     See Creating the class object for more details.

   New in version 3.6.

The attribute "__objclass__" is interpreted by the "inspect" module as
specifying the class where this object was defined (setting this
appropriately can assist in runtime introspection of dynamic class
attributes). For callables, it may indicate that an instance of the
given type (or a subclass) is expected or required as the first
positional argument (for example, CPython sets this attribute for
unbound methods that are implemented in C).


Invoking Descriptors
====================

In general, a descriptor is an object attribute with “binding
behavior”, one whose attribute access has been overridden by methods
in the descriptor protocol:  "__get__()", "__set__()", and
"__delete__()". If any of those methods are defined for an object, it
is said to be a descriptor.

The default behavior for attribute access is to get, set, or delete
the attribute from an object’s dictionary. For instance, "a.x" has a
lookup chain starting with "a.__dict__['x']", then
"type(a).__dict__['x']", and continuing through the base classes of
"type(a)" excluding metaclasses.

However, if the looked-up value is an object defining one of the
descriptor methods, then Python may override the default behavior and
invoke the descriptor method instead.  Where this occurs in the
precedence chain depends on which descriptor methods were defined and
how they were called.

The starting point for descriptor invocation is a binding, "a.x". How
the arguments are assembled depends on "a":

Direct Call
   The simplest and least common call is when user code directly
   invokes a descriptor method:    "x.__get__(a)".

Instance Binding
   If binding to an object instance, "a.x" is transformed into the
   call: "type(a).__dict__['x'].__get__(a, type(a))".

Class Binding
   If binding to a class, "A.x" is transformed into the call:
   "A.__dict__['x'].__get__(None, A)".

Super Binding
   If "a" is an instance of "super", then the binding "super(B,
   obj).m()" searches "obj.__class__.__mro__" for the base class "A"
   immediately preceding "B" and then invokes the descriptor with the
   call: "A.__dict__['m'].__get__(obj, obj.__class__)".

For instance bindings, the precedence of descriptor invocation depends
on which descriptor methods are defined.  A descriptor can define any
combination of "__get__()", "__set__()" and "__delete__()".  If it
does not define "__get__()", then accessing the attribute will return
the descriptor object itself unless there is a value in the object’s
instance dictionary.  If the descriptor defines "__set__()" and/or
"__delete__()", it is a data descriptor; if it defines neither, it is
a non-data descriptor.  Normally, data descriptors define both
"__get__()" and "__set__()", while non-data descriptors have just the
"__get__()" method.  Data descriptors with "__set__()" and "__get__()"
defined always override a redefinition in an instance dictionary.  In
contrast, non-data descriptors can be overridden by instances.

Python methods (including "staticmethod()" and "classmethod()") are
implemented as non-data descriptors.  Accordingly, instances can
redefine and override methods.  This allows individual instances to
acquire behaviors that differ from other instances of the same class.

The "property()" function is implemented as a data descriptor.
Accordingly, instances cannot override the behavior of a property.


__slots__
=========

*__slots__* allow us to explicitly declare data members (like
properties) and deny the creation of *__dict__* and *__weakref__*
(unless explicitly declared in *__slots__* or available in a parent.)

The space saved over using *__dict__* can be significant. Attribute
lookup speed can be significantly improved as well.

object.__slots__

   This class variable can be assigned a string, iterable, or sequence
   of strings with variable names used by instances.  *__slots__*
   reserves space for the declared variables and prevents the
   automatic creation of *__dict__* and *__weakref__* for each
   instance.


Notes on using *__slots__*
--------------------------

* When inheriting from a class without *__slots__*, the *__dict__* and
  *__weakref__* attribute of the instances will always be accessible.

* Without a *__dict__* variable, instances cannot be assigned new
  variables not listed in the *__slots__* definition.  Attempts to
  assign to an unlisted variable name raises "AttributeError". If
  dynamic assignment of new variables is desired, then add
  "'__dict__'" to the sequence of strings in the *__slots__*
  declaration.

* Without a *__weakref__* variable for each instance, classes defining
  *__slots__* do not support weak references to its instances. If weak
  reference support is needed, then add "'__weakref__'" to the
  sequence of strings in the *__slots__* declaration.

* *__slots__* are implemented at the class level by creating
  descriptors (Implementing Descriptors) for each variable name.  As a
  result, class attributes cannot be used to set default values for
  instance variables defined by *__slots__*; otherwise, the class
  attribute would overwrite the descriptor assignment.

* The action of a *__slots__* declaration is not limited to the class
  where it is defined.  *__slots__* declared in parents are available
  in child classes. However, child subclasses will get a *__dict__*
  and *__weakref__* unless they also define *__slots__* (which should
  only contain names of any *additional* slots).

* If a class defines a slot also defined in a base class, the instance
  variable defined by the base class slot is inaccessible (except by
  retrieving its descriptor directly from the base class). This
  renders the meaning of the program undefined.  In the future, a
  check may be added to prevent this.

* Nonempty *__slots__* does not work for classes derived from
  “variable-length” built-in types such as "int", "bytes" and "tuple".

* Any non-string iterable may be assigned to *__slots__*. Mappings may
  also be used; however, in the future, special meaning may be
  assigned to the values corresponding to each key.

* *__class__* assignment works only if both classes have the same
  *__slots__*.

* Multiple inheritance with multiple slotted parent classes can be
  used, but only one parent is allowed to have attributes created by
  slots (the other bases must have empty slot layouts) - violations
  raise "TypeError".

* If an iterator is used for *__slots__* then a descriptor is created
  for each of the iterator’s values. However, the *__slots__*
  attribute will be an empty iterator.
a�Attribute references
********************

An attribute reference is a primary followed by a period and a name:

   attributeref ::= primary "." identifier

The primary must evaluate to an object of a type that supports
attribute references, which most objects do.  This object is then
asked to produce the attribute whose name is the identifier.  This
production can be customized by overriding the "__getattr__()" method.
If this attribute is not available, the exception "AttributeError" is
raised.  Otherwise, the type and value of the object produced is
determined by the object.  Multiple evaluations of the same attribute
reference may yield different objects.
a�Augmented assignment statements
*******************************

Augmented assignment is the combination, in a single statement, of a
binary operation and an assignment statement:

   augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)
   augtarget                 ::= identifier | attributeref | subscription | slicing
   augop                     ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
             | ">>=" | "<<=" | "&=" | "^=" | "|="

(See section Primaries for the syntax definitions of the last three
symbols.)

An augmented assignment evaluates the target (which, unlike normal
assignment statements, cannot be an unpacking) and the expression
list, performs the binary operation specific to the type of assignment
on the two operands, and assigns the result to the original target.
The target is only evaluated once.

An augmented assignment expression like "x += 1" can be rewritten as
"x = x + 1" to achieve a similar, but not exactly equal effect. In the
augmented version, "x" is only evaluated once. Also, when possible,
the actual operation is performed *in-place*, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.

Unlike normal assignments, augmented assignments evaluate the left-
hand side *before* evaluating the right-hand side.  For example, "a[i]
+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs
the addition, and lastly, it writes the result back to "a[i]".

With the exception of assigning to tuples and multiple targets in a
single statement, the assignment done by augmented assignment
statements is handled the same way as normal assignments. Similarly,
with the exception of the possible *in-place* behavior, the binary
operation performed by augmented assignment is the same as the normal
binary operations.

For targets which are attribute references, the same caveat about
class and instance attributes applies as for regular assignments.
z�Await expression
****************

Suspend the execution of *coroutine* on an *awaitable* object. Can
only be used inside a *coroutine function*.

   await_expr ::= "await" primary

New in version 3.5.
ujBinary arithmetic operations
****************************

The binary arithmetic operations have the conventional priority
levels.  Note that some of these operations also apply to certain non-
numeric types.  Apart from the power operator, there are only two
levels, one for multiplicative operators and one for additive
operators:

   m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |
              m_expr "//" u_expr | m_expr "/" u_expr |
              m_expr "%" u_expr
   a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr

The "*" (multiplication) operator yields the product of its arguments.
The arguments must either both be numbers, or one argument must be an
integer and the other must be a sequence. In the former case, the
numbers are converted to a common type and then multiplied together.
In the latter case, sequence repetition is performed; a negative
repetition factor yields an empty sequence.

The "@" (at) operator is intended to be used for matrix
multiplication.  No builtin Python types implement this operator.

New in version 3.5.

The "/" (division) and "//" (floor division) operators yield the
quotient of their arguments.  The numeric arguments are first
converted to a common type. Division of integers yields a float, while
floor division of integers results in an integer; the result is that
of mathematical division with the ‘floor’ function applied to the
result.  Division by zero raises the "ZeroDivisionError" exception.

The "%" (modulo) operator yields the remainder from the division of
the first argument by the second.  The numeric arguments are first
converted to a common type.  A zero right argument raises the
"ZeroDivisionError" exception.  The arguments may be floating point
numbers, e.g., "3.14%0.7" equals "0.34" (since "3.14" equals "4*0.7 +
0.34".)  The modulo operator always yields a result with the same sign
as its second operand (or zero); the absolute value of the result is
strictly smaller than the absolute value of the second operand [1].

The floor division and modulo operators are connected by the following
identity: "x == (x//y)*y + (x%y)".  Floor division and modulo are also
connected with the built-in function "divmod()": "divmod(x, y) ==
(x//y, x%y)". [2].

In addition to performing the modulo operation on numbers, the "%"
operator is also overloaded by string objects to perform old-style
string formatting (also known as interpolation).  The syntax for
string formatting is described in the Python Library Reference,
section printf-style String Formatting.

The floor division operator, the modulo operator, and the "divmod()"
function are not defined for complex numbers.  Instead, convert to a
floating point number using the "abs()" function if appropriate.

The "+" (addition) operator yields the sum of its arguments.  The
arguments must either both be numbers or both be sequences of the same
type.  In the former case, the numbers are converted to a common type
and then added together. In the latter case, the sequences are
concatenated.

The "-" (subtraction) operator yields the difference of its arguments.
The numeric arguments are first converted to a common type.
a$Binary bitwise operations
*************************

Each of the three bitwise operations has a different priority level:

   and_expr ::= shift_expr | and_expr "&" shift_expr
   xor_expr ::= and_expr | xor_expr "^" and_expr
   or_expr  ::= xor_expr | or_expr "|" xor_expr

The "&" operator yields the bitwise AND of its arguments, which must
be integers.

The "^" operator yields the bitwise XOR (exclusive OR) of its
arguments, which must be integers.

The "|" operator yields the bitwise (inclusive) OR of its arguments,
which must be integers.
u�Code Objects
************

Code objects are used by the implementation to represent “pseudo-
compiled” executable Python code such as a function body. They differ
from function objects because they don’t contain a reference to their
global execution environment.  Code objects are returned by the built-
in "compile()" function and can be extracted from function objects
through their "__code__" attribute. See also the "code" module.

Accessing "__code__" raises an auditing event "object.__getattr__"
with arguments "obj" and ""__code__"".

A code object can be executed or evaluated by passing it (instead of a
source string) to the "exec()" or "eval()"  built-in functions.

See The standard type hierarchy for more information.
a.The Ellipsis Object
*******************

This object is commonly used by slicing (see Slicings).  It supports
no special operations.  There is exactly one ellipsis object, named
"Ellipsis" (a built-in name).  "type(Ellipsis)()" produces the
"Ellipsis" singleton.

It is written as "Ellipsis" or "...".
uThe Null Object
***************

This object is returned by functions that don’t explicitly return a
value.  It supports no special operations.  There is exactly one null
object, named "None" (a built-in name).  "type(None)()" produces the
same singleton.

It is written as "None".
u5Type Objects
************

Type objects represent the various object types.  An object’s type is
accessed by the built-in function "type()".  There are no special
operations on types.  The standard module "types" defines names for
all standard built-in types.

Types are written like this: "<class 'int'>".
a�Boolean operations
******************

   or_test  ::= and_test | or_test "or" and_test
   and_test ::= not_test | and_test "and" not_test
   not_test ::= comparison | "not" not_test

In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are interpreted
as false: "False", "None", numeric zero of all types, and empty
strings and containers (including strings, tuples, lists,
dictionaries, sets and frozensets).  All other values are interpreted
as true.  User-defined objects can customize their truth value by
providing a "__bool__()" method.

The operator "not" yields "True" if its argument is false, "False"
otherwise.

The expression "x and y" first evaluates *x*; if *x* is false, its
value is returned; otherwise, *y* is evaluated and the resulting value
is returned.

The expression "x or y" first evaluates *x*; if *x* is true, its value
is returned; otherwise, *y* is evaluated and the resulting value is
returned.

Note that neither "and" nor "or" restrict the value and type they
return to "False" and "True", but rather return the last evaluated
argument.  This is sometimes useful, e.g., if "s" is a string that
should be replaced by a default value if it is empty, the expression
"s or 'foo'" yields the desired value.  Because "not" has to create a
new value, it returns a boolean value regardless of the type of its
argument (for example, "not 'foo'" produces "False" rather than "''".)
a$The "break" statement
*********************

   break_stmt ::= "break"

"break" may only occur syntactically nested in a "for" or "while"
loop, but not nested in a function or class definition within that
loop.

It terminates the nearest enclosing loop, skipping the optional "else"
clause if the loop has one.

If a "for" loop is terminated by "break", the loop control target
keeps its current value.

When "break" passes control out of a "try" statement with a "finally"
clause, that "finally" clause is executed before really leaving the
loop.
uEmulating callable objects
**************************

object.__call__(self[, args...])

   Called when the instance is “called” as a function; if this method
   is defined, "x(arg1, arg2, ...)" roughly translates to
   "type(x).__call__(x, arg1, ...)".
u�Calls
*****

A call calls a callable object (e.g., a *function*) with a possibly
empty series of *arguments*:

   call                 ::= primary "(" [argument_list [","] | comprehension] ")"
   argument_list        ::= positional_arguments ["," starred_and_keywords]
                       ["," keywords_arguments]
                     | starred_and_keywords ["," keywords_arguments]
                     | keywords_arguments
   positional_arguments ::= positional_item ("," positional_item)*
   positional_item      ::= assignment_expression | "*" expression
   starred_and_keywords ::= ("*" expression | keyword_item)
                            ("," "*" expression | "," keyword_item)*
   keywords_arguments   ::= (keyword_item | "**" expression)
                          ("," keyword_item | "," "**" expression)*
   keyword_item         ::= identifier "=" expression

An optional trailing comma may be present after the positional and
keyword arguments but does not affect the semantics.

The primary must evaluate to a callable object (user-defined
functions, built-in functions, methods of built-in objects, class
objects, methods of class instances, and all objects having a
"__call__()" method are callable).  All argument expressions are
evaluated before the call is attempted.  Please refer to section
Function definitions for the syntax of formal *parameter* lists.

If keyword arguments are present, they are first converted to
positional arguments, as follows.  First, a list of unfilled slots is
created for the formal parameters.  If there are N positional
arguments, they are placed in the first N slots.  Next, for each
keyword argument, the identifier is used to determine the
corresponding slot (if the identifier is the same as the first formal
parameter name, the first slot is used, and so on).  If the slot is
already filled, a "TypeError" exception is raised. Otherwise, the
value of the argument is placed in the slot, filling it (even if the
expression is "None", it fills the slot).  When all arguments have
been processed, the slots that are still unfilled are filled with the
corresponding default value from the function definition.  (Default
values are calculated, once, when the function is defined; thus, a
mutable object such as a list or dictionary used as default value will
be shared by all calls that don’t specify an argument value for the
corresponding slot; this should usually be avoided.)  If there are any
unfilled slots for which no default value is specified, a "TypeError"
exception is raised.  Otherwise, the list of filled slots is used as
the argument list for the call.

**CPython implementation detail:** An implementation may provide
built-in functions whose positional parameters do not have names, even
if they are ‘named’ for the purpose of documentation, and which
therefore cannot be supplied by keyword.  In CPython, this is the case
for functions implemented in C that use "PyArg_ParseTuple()" to parse
their arguments.

If there are more positional arguments than there are formal parameter
slots, a "TypeError" exception is raised, unless a formal parameter
using the syntax "*identifier" is present; in this case, that formal
parameter receives a tuple containing the excess positional arguments
(or an empty tuple if there were no excess positional arguments).

If any keyword argument does not correspond to a formal parameter
name, a "TypeError" exception is raised, unless a formal parameter
using the syntax "**identifier" is present; in this case, that formal
parameter receives a dictionary containing the excess keyword
arguments (using the keywords as keys and the argument values as
corresponding values), or a (new) empty dictionary if there were no
excess keyword arguments.

If the syntax "*expression" appears in the function call, "expression"
must evaluate to an *iterable*.  Elements from these iterables are
treated as if they were additional positional arguments.  For the call
"f(x1, x2, *y, x3, x4)", if *y* evaluates to a sequence *y1*, …, *yM*,
this is equivalent to a call with M+4 positional arguments *x1*, *x2*,
*y1*, …, *yM*, *x3*, *x4*.

A consequence of this is that although the "*expression" syntax may
appear *after* explicit keyword arguments, it is processed *before*
the keyword arguments (and any "**expression" arguments – see below).
So:

   >>> def f(a, b):
   ...     print(a, b)
   ...
   >>> f(b=1, *(2,))
   2 1
   >>> f(a=1, *(2,))
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: f() got multiple values for keyword argument 'a'
   >>> f(1, *(2,))
   1 2

It is unusual for both keyword arguments and the "*expression" syntax
to be used in the same call, so in practice this confusion does not
arise.

If the syntax "**expression" appears in the function call,
"expression" must evaluate to a *mapping*, the contents of which are
treated as additional keyword arguments.  If a keyword is already
present (as an explicit keyword argument, or from another unpacking),
a "TypeError" exception is raised.

Formal parameters using the syntax "*identifier" or "**identifier"
cannot be used as positional argument slots or as keyword argument
names.

Changed in version 3.5: Function calls accept any number of "*" and
"**" unpackings, positional arguments may follow iterable unpackings
("*"), and keyword arguments may follow dictionary unpackings ("**").
Originally proposed by **PEP 448**.

A call always returns some value, possibly "None", unless it raises an
exception.  How this value is computed depends on the type of the
callable object.

If it is—

a user-defined function:
   The code block for the function is executed, passing it the
   argument list.  The first thing the code block will do is bind the
   formal parameters to the arguments; this is described in section
   Function definitions.  When the code block executes a "return"
   statement, this specifies the return value of the function call.

a built-in function or method:
   The result is up to the interpreter; see Built-in Functions for the
   descriptions of built-in functions and methods.

a class object:
   A new instance of that class is returned.

a class instance method:
   The corresponding user-defined function is called, with an argument
   list that is one longer than the argument list of the call: the
   instance becomes the first argument.

a class instance:
   The class must define a "__call__()" method; the effect is then the
   same as if that method was called.
uClass definitions
*****************

A class definition defines a class object (see section The standard
type hierarchy):

   classdef    ::= [decorators] "class" classname [inheritance] ":" suite
   inheritance ::= "(" [argument_list] ")"
   classname   ::= identifier

A class definition is an executable statement.  The inheritance list
usually gives a list of base classes (see Metaclasses for more
advanced uses), so each item in the list should evaluate to a class
object which allows subclassing.  Classes without an inheritance list
inherit, by default, from the base class "object"; hence,

   class Foo:
       pass

is equivalent to

   class Foo(object):
       pass

The class’s suite is then executed in a new execution frame (see
Naming and binding), using a newly created local namespace and the
original global namespace. (Usually, the suite contains mostly
function definitions.)  When the class’s suite finishes execution, its
execution frame is discarded but its local namespace is saved. [3] A
class object is then created using the inheritance list for the base
classes and the saved local namespace for the attribute dictionary.
The class name is bound to this class object in the original local
namespace.

The order in which attributes are defined in the class body is
preserved in the new class’s "__dict__".  Note that this is reliable
only right after the class is created and only for classes that were
defined using the definition syntax.

Class creation can be customized heavily using metaclasses.

Classes can also be decorated: just like when decorating functions,

   @f1(arg)
   @f2
   class Foo: pass

is roughly equivalent to

   class Foo: pass
   Foo = f1(arg)(f2(Foo))

The evaluation rules for the decorator expressions are the same as for
function decorators.  The result is then bound to the class name.

**Programmer’s note:** Variables defined in the class definition are
class attributes; they are shared by instances.  Instance attributes
can be set in a method with "self.name = value".  Both class and
instance attributes are accessible through the notation “"self.name"”,
and an instance attribute hides a class attribute with the same name
when accessed in this way.  Class attributes can be used as defaults
for instance attributes, but using mutable values there can lead to
unexpected results.  Descriptors can be used to create instance
variables with different implementation details.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     The proposal that changed the declaration of metaclasses to the
     current syntax, and the semantics for how classes with
     metaclasses are constructed.

  **PEP 3129** - Class Decorators
     The proposal that added class decorators.  Function and method
     decorators were introduced in **PEP 318**.
u�'Comparisons
***********

Unlike C, all comparison operations in Python have the same priority,
which is lower than that of any arithmetic, shifting or bitwise
operation.  Also unlike C, expressions like "a < b < c" have the
interpretation that is conventional in mathematics:

   comparison    ::= or_expr (comp_operator or_expr)*
   comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="
                     | "is" ["not"] | ["not"] "in"

Comparisons yield boolean values: "True" or "False".

Comparisons can be chained arbitrarily, e.g., "x < y <= z" is
equivalent to "x < y and y <= z", except that "y" is evaluated only
once (but in both cases "z" is not evaluated at all when "x < y" is
found to be false).

Formally, if *a*, *b*, *c*, …, *y*, *z* are expressions and *op1*,
*op2*, …, *opN* are comparison operators, then "a op1 b op2 c ... y
opN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except
that each expression is evaluated at most once.

Note that "a op1 b op2 c" doesn’t imply any kind of comparison between
*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though
perhaps not pretty).


Value comparisons
=================

The operators "<", ">", "==", ">=", "<=", and "!=" compare the values
of two objects.  The objects do not need to have the same type.

Chapter Objects, values and types states that objects have a value (in
addition to type and identity).  The value of an object is a rather
abstract notion in Python: For example, there is no canonical access
method for an object’s value.  Also, there is no requirement that the
value of an object should be constructed in a particular way, e.g.
comprised of all its data attributes. Comparison operators implement a
particular notion of what the value of an object is.  One can think of
them as defining the value of an object indirectly, by means of their
comparison implementation.

Because all types are (direct or indirect) subtypes of "object", they
inherit the default comparison behavior from "object".  Types can
customize their comparison behavior by implementing *rich comparison
methods* like "__lt__()", described in Basic customization.

The default behavior for equality comparison ("==" and "!=") is based
on the identity of the objects.  Hence, equality comparison of
instances with the same identity results in equality, and equality
comparison of instances with different identities results in
inequality.  A motivation for this default behavior is the desire that
all objects should be reflexive (i.e. "x is y" implies "x == y").

A default order comparison ("<", ">", "<=", and ">=") is not provided;
an attempt raises "TypeError".  A motivation for this default behavior
is the lack of a similar invariant as for equality.

The behavior of the default equality comparison, that instances with
different identities are always unequal, may be in contrast to what
types will need that have a sensible definition of object value and
value-based equality.  Such types will need to customize their
comparison behavior, and in fact, a number of built-in types have done
that.

The following list describes the comparison behavior of the most
important built-in types.

* Numbers of built-in numeric types (Numeric Types — int, float,
  complex) and of the standard library types "fractions.Fraction" and
  "decimal.Decimal" can be compared within and across their types,
  with the restriction that complex numbers do not support order
  comparison.  Within the limits of the types involved, they compare
  mathematically (algorithmically) correct without loss of precision.

  The not-a-number values "float('NaN')" and "decimal.Decimal('NaN')"
  are special.  Any ordered comparison of a number to a not-a-number
  value is false. A counter-intuitive implication is that not-a-number
  values are not equal to themselves.  For example, if "x =
  float('NaN')", "3 < x", "x < 3" and "x == x" are all false, while "x
  != x" is true.  This behavior is compliant with IEEE 754.

* "None" and "NotImplemented" are singletons.  **PEP 8** advises that
  comparisons for singletons should always be done with "is" or "is
  not", never the equality operators.

* Binary sequences (instances of "bytes" or "bytearray") can be
  compared within and across their types.  They compare
  lexicographically using the numeric values of their elements.

* Strings (instances of "str") compare lexicographically using the
  numerical Unicode code points (the result of the built-in function
  "ord()") of their characters. [3]

  Strings and binary sequences cannot be directly compared.

* Sequences (instances of "tuple", "list", or "range") can be compared
  only within each of their types, with the restriction that ranges do
  not support order comparison.  Equality comparison across these
  types results in inequality, and ordering comparison across these
  types raises "TypeError".

  Sequences compare lexicographically using comparison of
  corresponding elements.  The built-in containers typically assume
  identical objects are equal to themselves.  That lets them bypass
  equality tests for identical objects to improve performance and to
  maintain their internal invariants.

  Lexicographical comparison between built-in collections works as
  follows:

  * For two collections to compare equal, they must be of the same
    type, have the same length, and each pair of corresponding
    elements must compare equal (for example, "[1,2] == (1,2)" is
    false because the type is not the same).

  * Collections that support order comparison are ordered the same as
    their first unequal elements (for example, "[1,2,x] <= [1,2,y]"
    has the same value as "x <= y").  If a corresponding element does
    not exist, the shorter collection is ordered first (for example,
    "[1,2] < [1,2,3]" is true).

* Mappings (instances of "dict") compare equal if and only if they
  have equal *(key, value)* pairs. Equality comparison of the keys and
  values enforces reflexivity.

  Order comparisons ("<", ">", "<=", and ">=") raise "TypeError".

* Sets (instances of "set" or "frozenset") can be compared within and
  across their types.

  They define order comparison operators to mean subset and superset
  tests.  Those relations do not define total orderings (for example,
  the two sets "{1,2}" and "{2,3}" are not equal, nor subsets of one
  another, nor supersets of one another).  Accordingly, sets are not
  appropriate arguments for functions which depend on total ordering
  (for example, "min()", "max()", and "sorted()" produce undefined
  results given a list of sets as inputs).

  Comparison of sets enforces reflexivity of its elements.

* Most other built-in types have no comparison methods implemented, so
  they inherit the default comparison behavior.

User-defined classes that customize their comparison behavior should
follow some consistency rules, if possible:

* Equality comparison should be reflexive. In other words, identical
  objects should compare equal:

     "x is y" implies "x == y"

* Comparison should be symmetric. In other words, the following
  expressions should have the same result:

     "x == y" and "y == x"

     "x != y" and "y != x"

     "x < y" and "y > x"

     "x <= y" and "y >= x"

* Comparison should be transitive. The following (non-exhaustive)
  examples illustrate that:

     "x > y and y > z" implies "x > z"

     "x < y and y <= z" implies "x < z"

* Inverse comparison should result in the boolean negation. In other
  words, the following expressions should have the same result:

     "x == y" and "not x != y"

     "x < y" and "not x >= y" (for total ordering)

     "x > y" and "not x <= y" (for total ordering)

  The last two expressions apply to totally ordered collections (e.g.
  to sequences, but not to sets or mappings). See also the
  "total_ordering()" decorator.

* The "hash()" result should be consistent with equality. Objects that
  are equal should either have the same hash value, or be marked as
  unhashable.

Python does not enforce these consistency rules. In fact, the
not-a-number values are an example for not following these rules.


Membership test operations
==========================

The operators "in" and "not in" test for membership.  "x in s"
evaluates to "True" if *x* is a member of *s*, and "False" otherwise.
"x not in s" returns the negation of "x in s".  All built-in sequences
and set types support this as well as dictionary, for which "in" tests
whether the dictionary has a given key. For container types such as
list, tuple, set, frozenset, dict, or collections.deque, the
expression "x in y" is equivalent to "any(x is e or x == e for e in
y)".

For the string and bytes types, "x in y" is "True" if and only if *x*
is a substring of *y*.  An equivalent test is "y.find(x) != -1".
Empty strings are always considered to be a substring of any other
string, so """ in "abc"" will return "True".

For user-defined classes which define the "__contains__()" method, "x
in y" returns "True" if "y.__contains__(x)" returns a true value, and
"False" otherwise.

For user-defined classes which do not define "__contains__()" but do
define "__iter__()", "x in y" is "True" if some value "z", for which
the expression "x is z or x == z" is true, is produced while iterating
over "y". If an exception is raised during the iteration, it is as if
"in" raised that exception.

Lastly, the old-style iteration protocol is tried: if a class defines
"__getitem__()", "x in y" is "True" if and only if there is a non-
negative integer index *i* such that "x is y[i] or x == y[i]", and no
lower integer index raises the "IndexError" exception.  (If any other
exception is raised, it is as if "in" raised that exception).

The operator "not in" is defined to have the inverse truth value of
"in".


Identity comparisons
====================

The operators "is" and "is not" test for an object’s identity: "x is
y" is true if and only if *x* and *y* are the same object.  An
Object’s identity is determined using the "id()" function.  "x is not
y" yields the inverse truth value. [4]
u�lCompound statements
*******************

Compound statements contain (groups of) other statements; they affect
or control the execution of those other statements in some way.  In
general, compound statements span multiple lines, although in simple
incarnations a whole compound statement may be contained in one line.

The "if", "while" and "for" statements implement traditional control
flow constructs.  "try" specifies exception handlers and/or cleanup
code for a group of statements, while the "with" statement allows the
execution of initialization and finalization code around a block of
code.  Function and class definitions are also syntactically compound
statements.

A compound statement consists of one or more ‘clauses.’  A clause
consists of a header and a ‘suite.’  The clause headers of a
particular compound statement are all at the same indentation level.
Each clause header begins with a uniquely identifying keyword and ends
with a colon.  A suite is a group of statements controlled by a
clause.  A suite can be one or more semicolon-separated simple
statements on the same line as the header, following the header’s
colon, or it can be one or more indented statements on subsequent
lines.  Only the latter form of a suite can contain nested compound
statements; the following is illegal, mostly because it wouldn’t be
clear to which "if" clause a following "else" clause would belong:

   if test1: if test2: print(x)

Also note that the semicolon binds tighter than the colon in this
context, so that in the following example, either all or none of the
"print()" calls are executed:

   if x < y < z: print(x); print(y); print(z)

Summarizing:

   compound_stmt ::= if_stmt
                     | while_stmt
                     | for_stmt
                     | try_stmt
                     | with_stmt
                     | funcdef
                     | classdef
                     | async_with_stmt
                     | async_for_stmt
                     | async_funcdef
   suite         ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT
   statement     ::= stmt_list NEWLINE | compound_stmt
   stmt_list     ::= simple_stmt (";" simple_stmt)* [";"]

Note that statements always end in a "NEWLINE" possibly followed by a
"DEDENT".  Also note that optional continuation clauses always begin
with a keyword that cannot start a statement, thus there are no
ambiguities (the ‘dangling "else"’ problem is solved in Python by
requiring nested "if" statements to be indented).

The formatting of the grammar rules in the following sections places
each clause on a separate line for clarity.


The "if" statement
==================

The "if" statement is used for conditional execution:

   if_stmt ::= "if" assignment_expression ":" suite
               ("elif" assignment_expression ":" suite)*
               ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section Boolean operations
for the definition of true and false); then that suite is executed
(and no other part of the "if" statement is executed or evaluated).
If all expressions are false, the suite of the "else" clause, if
present, is executed.


The "while" statement
=====================

The "while" statement is used for repeated execution as long as an
expression is true:

   while_stmt ::= "while" assignment_expression ":" suite
                  ["else" ":" suite]

This repeatedly tests the expression and, if it is true, executes the
first suite; if the expression is false (which may be the first time
it is tested) the suite of the "else" clause, if present, is executed
and the loop terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and goes back
to testing the expression.


The "for" statement
===================

The "for" statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object:

   for_stmt ::= "for" target_list "in" expression_list ":" suite
                ["else" ":" suite]

The expression list is evaluated once; it should yield an iterable
object.  An iterator is created for the result of the
"expression_list".  The suite is then executed once for each item
provided by the iterator, in the order returned by the iterator.  Each
item in turn is assigned to the target list using the standard rules
for assignments (see Assignment statements), and then the suite is
executed.  When the items are exhausted (which is immediately when the
sequence is empty or an iterator raises a "StopIteration" exception),
the suite in the "else" clause, if present, is executed, and the loop
terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and continues
with the next item, or with the "else" clause if there is no next
item.

The for-loop makes assignments to the variables in the target list.
This overwrites all previous assignments to those variables including
those made in the suite of the for-loop:

   for i in range(10):
       print(i)
       i = 5             # this will not affect the for-loop
                         # because i will be overwritten with the next
                         # index in the range

Names in the target list are not deleted when the loop is finished,
but if the sequence is empty, they will not have been assigned to at
all by the loop.  Hint: the built-in function "range()" returns an
iterator of integers suitable to emulate the effect of Pascal’s "for i
:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".

Note:

  There is a subtlety when the sequence is being modified by the loop
  (this can only occur for mutable sequences, e.g. lists).  An
  internal counter is used to keep track of which item is used next,
  and this is incremented on each iteration.  When this counter has
  reached the length of the sequence the loop terminates.  This means
  that if the suite deletes the current (or a previous) item from the
  sequence, the next item will be skipped (since it gets the index of
  the current item which has already been treated).  Likewise, if the
  suite inserts an item in the sequence before the current item, the
  current item will be treated again the next time through the loop.
  This can lead to nasty bugs that can be avoided by making a
  temporary copy using a slice of the whole sequence, e.g.,

     for x in a[:]:
         if x < 0: a.remove(x)


The "try" statement
===================

The "try" statement specifies exception handlers and/or cleanup code
for a group of statements:

   try_stmt  ::= try1_stmt | try2_stmt
   try1_stmt ::= "try" ":" suite
                 ("except" [expression ["as" identifier]] ":" suite)+
                 ["else" ":" suite]
                 ["finally" ":" suite]
   try2_stmt ::= "try" ":" suite
                 "finally" ":" suite

The "except" clause(s) specify one or more exception handlers. When no
exception occurs in the "try" clause, no exception handler is
executed. When an exception occurs in the "try" suite, a search for an
exception handler is started.  This search inspects the except clauses
in turn until one is found that matches the exception.  An expression-
less except clause, if present, must be last; it matches any
exception.  For an except clause with an expression, that expression
is evaluated, and the clause matches the exception if the resulting
object is “compatible” with the exception.  An object is compatible
with an exception if it is the class or a base class of the exception
object, or a tuple containing an item that is the class or a base
class of the exception object.

If no except clause matches the exception, the search for an exception
handler continues in the surrounding code and on the invocation stack.
[1]

If the evaluation of an expression in the header of an except clause
raises an exception, the original search for a handler is canceled and
a search starts for the new exception in the surrounding code and on
the call stack (it is treated as if the entire "try" statement raised
the exception).

When a matching except clause is found, the exception is assigned to
the target specified after the "as" keyword in that except clause, if
present, and the except clause’s suite is executed.  All except
clauses must have an executable block.  When the end of this block is
reached, execution continues normally after the entire try statement.
(This means that if two nested handlers exist for the same exception,
and the exception occurs in the try clause of the inner handler, the
outer handler will not handle the exception.)

When an exception has been assigned using "as target", it is cleared
at the end of the except clause.  This is as if

   except E as N:
       foo

was translated to

   except E as N:
       try:
           foo
       finally:
           del N

This means the exception must be assigned to a different name to be
able to refer to it after the except clause.  Exceptions are cleared
because with the traceback attached to them, they form a reference
cycle with the stack frame, keeping all locals in that frame alive
until the next garbage collection occurs.

Before an except clause’s suite is executed, details about the
exception are stored in the "sys" module and can be accessed via
"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the
exception class, the exception instance and a traceback object (see
section The standard type hierarchy) identifying the point in the
program where the exception occurred.  "sys.exc_info()" values are
restored to their previous values (before the call) when returning
from a function that handled an exception.

The optional "else" clause is executed if the control flow leaves the
"try" suite, no exception was raised, and no "return", "continue", or
"break" statement was executed.  Exceptions in the "else" clause are
not handled by the preceding "except" clauses.

If "finally" is present, it specifies a ‘cleanup’ handler.  The "try"
clause is executed, including any "except" and "else" clauses.  If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed.  If
there is a saved exception it is re-raised at the end of the "finally"
clause.  If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:

   >>> def f():
   ...     try:
   ...         1/0
   ...     finally:
   ...         return 42
   ...
   >>> f()
   42

The exception information is not available to the program during
execution of the "finally" clause.

When a "return", "break" or "continue" statement is executed in the
"try" suite of a "try"…"finally" statement, the "finally" clause is
also executed ‘on the way out.’

The return value of a function is determined by the last "return"
statement executed.  Since the "finally" clause always executes, a
"return" statement executed in the "finally" clause will always be the
last one executed:

   >>> def foo():
   ...     try:
   ...         return 'try'
   ...     finally:
   ...         return 'finally'
   ...
   >>> foo()
   'finally'

Additional information on exceptions can be found in section
Exceptions, and information on using the "raise" statement to generate
exceptions may be found in section The raise statement.

Changed in version 3.8: Prior to Python 3.8, a "continue" statement
was illegal in the "finally" clause due to a problem with the
implementation.


The "with" statement
====================

The "with" statement is used to wrap the execution of a block with
methods defined by a context manager (see section With Statement
Context Managers). This allows common "try"…"except"…"finally" usage
patterns to be encapsulated for convenient reuse.

   with_stmt ::= "with" with_item ("," with_item)* ":" suite
   with_item ::= expression ["as" target]

The execution of the "with" statement with one “item” proceeds as
follows:

1. The context expression (the expression given in the "with_item") is
   evaluated to obtain a context manager.

2. The context manager’s "__enter__()" is loaded for later use.

3. The context manager’s "__exit__()" is loaded for later use.

4. The context manager’s "__enter__()" method is invoked.

5. If a target was included in the "with" statement, the return value
   from "__enter__()" is assigned to it.

   Note:

     The "with" statement guarantees that if the "__enter__()" method
     returns without an error, then "__exit__()" will always be
     called. Thus, if an error occurs during the assignment to the
     target list, it will be treated the same as an error occurring
     within the suite would be. See step 6 below.

6. The suite is executed.

7. The context manager’s "__exit__()" method is invoked.  If an
   exception caused the suite to be exited, its type, value, and
   traceback are passed as arguments to "__exit__()". Otherwise, three
   "None" arguments are supplied.

   If the suite was exited due to an exception, and the return value
   from the "__exit__()" method was false, the exception is reraised.
   If the return value was true, the exception is suppressed, and
   execution continues with the statement following the "with"
   statement.

   If the suite was exited for any reason other than an exception, the
   return value from "__exit__()" is ignored, and execution proceeds
   at the normal location for the kind of exit that was taken.

The following code:

   with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   enter = type(manager).__enter__
   exit = type(manager).__exit__
   value = enter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not exit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           exit(manager, None, None, None)

With more than one item, the context managers are processed as if
multiple "with" statements were nested:

   with A() as a, B() as b:
       SUITE

is semantically equivalent to:

   with A() as a:
       with B() as b:
           SUITE

Changed in version 3.1: Support for multiple context expressions.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.


Function definitions
====================

A function definition defines a user-defined function object (see
section The standard type hierarchy):

   funcdef                   ::= [decorators] "def" funcname "(" [parameter_list] ")"
               ["->" expression] ":" suite
   decorators                ::= decorator+
   decorator                 ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
   dotted_name               ::= identifier ("." identifier)*
   parameter_list            ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
                        | parameter_list_no_posonly
   parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
                                 | parameter_list_starargs
   parameter_list_starargs   ::= "*" [parameter] ("," defparameter)* ["," ["**" parameter [","]]]
                               | "**" parameter [","]
   parameter                 ::= identifier [":" expression]
   defparameter              ::= parameter ["=" expression]
   funcname                  ::= identifier

A function definition is an executable statement.  Its execution binds
the function name in the current local namespace to a function object
(a wrapper around the executable code for the function).  This
function object contains a reference to the current global namespace
as the global namespace to be used when the function is called.

The function definition does not execute the function body; this gets
executed only when the function is called. [2]

A function definition may be wrapped by one or more *decorator*
expressions. Decorator expressions are evaluated when the function is
defined, in the scope that contains the function definition.  The
result must be a callable, which is invoked with the function object
as the only argument. The returned value is bound to the function name
instead of the function object.  Multiple decorators are applied in
nested fashion. For example, the following code

   @f1(arg)
   @f2
   def func(): pass

is roughly equivalent to

   def func(): pass
   func = f1(arg)(f2(func))

except that the original function is not temporarily bound to the name
"func".

When one or more *parameters* have the form *parameter* "="
*expression*, the function is said to have “default parameter values.”
For a parameter with a default value, the corresponding *argument* may
be omitted from a call, in which case the parameter’s default value is
substituted.  If a parameter has a default value, all following
parameters up until the “"*"” must also have a default value — this is
a syntactic restriction that is not expressed by the grammar.

**Default parameter values are evaluated from left to right when the
function definition is executed.** This means that the expression is
evaluated once, when the function is defined, and that the same “pre-
computed” value is used for each call.  This is especially important
to understand when a default parameter is a mutable object, such as a
list or a dictionary: if the function modifies the object (e.g. by
appending an item to a list), the default value is in effect modified.
This is generally not what was intended.  A way around this is to use
"None" as the default, and explicitly test for it in the body of the
function, e.g.:

   def whats_on_the_telly(penguin=None):
       if penguin is None:
           penguin = []
       penguin.append("property of the zoo")
       return penguin

Function call semantics are described in more detail in section Calls.
A function call always assigns values to all parameters mentioned in
the parameter list, either from positional arguments, from keyword
arguments, or from default values.  If the form “"*identifier"” is
present, it is initialized to a tuple receiving any excess positional
parameters, defaulting to the empty tuple. If the form
“"**identifier"” is present, it is initialized to a new ordered
mapping receiving any excess keyword arguments, defaulting to a new
empty mapping of the same type.  Parameters after “"*"” or
“"*identifier"” are keyword-only parameters and may only be passed by
keyword arguments.  Parameters before “"/"” are positional-only
parameters and may only be passed by positional arguments.

Changed in version 3.8: The "/" function parameter syntax may be used
to indicate positional-only parameters. See **PEP 570** for details.

Parameters may have an *annotation* of the form “": expression"”
following the parameter name.  Any parameter may have an annotation,
even those of the form "*identifier" or "**identifier".  Functions may
have “return” annotation of the form “"-> expression"” after the
parameter list.  These annotations can be any valid Python expression.
The presence of annotations does not change the semantics of a
function.  The annotation values are available as values of a
dictionary keyed by the parameters’ names in the "__annotations__"
attribute of the function object.  If the "annotations" import from
"__future__" is used, annotations are preserved as strings at runtime
which enables postponed evaluation.  Otherwise, they are evaluated
when the function definition is executed.  In this case annotations
may be evaluated in a different order than they appear in the source
code.

It is also possible to create anonymous functions (functions not bound
to a name), for immediate use in expressions.  This uses lambda
expressions, described in section Lambdas.  Note that the lambda
expression is merely a shorthand for a simplified function definition;
a function defined in a “"def"” statement can be passed around or
assigned to another name just like a function defined by a lambda
expression.  The “"def"” form is actually more powerful since it
allows the execution of multiple statements and annotations.

**Programmer’s note:** Functions are first-class objects.  A “"def"”
statement executed inside a function definition defines a local
function that can be returned or passed around.  Free variables used
in the nested function can access the local variables of the function
containing the def.  See section Naming and binding for details.

See also:

  **PEP 3107** - Function Annotations
     The original specification for function annotations.

  **PEP 484** - Type Hints
     Definition of a standard meaning for annotations: type hints.

  **PEP 526** - Syntax for Variable Annotations
     Ability to type hint variable declarations, including class
     variables and instance variables

  **PEP 563** - Postponed Evaluation of Annotations
     Support for forward references within annotations by preserving
     annotations in a string form at runtime instead of eager
     evaluation.


Class definitions
=================

A class definition defines a class object (see section The standard
type hierarchy):

   classdef    ::= [decorators] "class" classname [inheritance] ":" suite
   inheritance ::= "(" [argument_list] ")"
   classname   ::= identifier

A class definition is an executable statement.  The inheritance list
usually gives a list of base classes (see Metaclasses for more
advanced uses), so each item in the list should evaluate to a class
object which allows subclassing.  Classes without an inheritance list
inherit, by default, from the base class "object"; hence,

   class Foo:
       pass

is equivalent to

   class Foo(object):
       pass

The class’s suite is then executed in a new execution frame (see
Naming and binding), using a newly created local namespace and the
original global namespace. (Usually, the suite contains mostly
function definitions.)  When the class’s suite finishes execution, its
execution frame is discarded but its local namespace is saved. [3] A
class object is then created using the inheritance list for the base
classes and the saved local namespace for the attribute dictionary.
The class name is bound to this class object in the original local
namespace.

The order in which attributes are defined in the class body is
preserved in the new class’s "__dict__".  Note that this is reliable
only right after the class is created and only for classes that were
defined using the definition syntax.

Class creation can be customized heavily using metaclasses.

Classes can also be decorated: just like when decorating functions,

   @f1(arg)
   @f2
   class Foo: pass

is roughly equivalent to

   class Foo: pass
   Foo = f1(arg)(f2(Foo))

The evaluation rules for the decorator expressions are the same as for
function decorators.  The result is then bound to the class name.

**Programmer’s note:** Variables defined in the class definition are
class attributes; they are shared by instances.  Instance attributes
can be set in a method with "self.name = value".  Both class and
instance attributes are accessible through the notation “"self.name"”,
and an instance attribute hides a class attribute with the same name
when accessed in this way.  Class attributes can be used as defaults
for instance attributes, but using mutable values there can lead to
unexpected results.  Descriptors can be used to create instance
variables with different implementation details.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     The proposal that changed the declaration of metaclasses to the
     current syntax, and the semantics for how classes with
     metaclasses are constructed.

  **PEP 3129** - Class Decorators
     The proposal that added class decorators.  Function and method
     decorators were introduced in **PEP 318**.


Coroutines
==========

New in version 3.5.


Coroutine function definition
-----------------------------

   async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")"
                     ["->" expression] ":" suite

Execution of Python coroutines can be suspended and resumed at many
points (see *coroutine*).  Inside the body of a coroutine function,
"await" and "async" identifiers become reserved keywords; "await"
expressions, "async for" and "async with" can only be used in
coroutine function bodies.

Functions defined with "async def" syntax are always coroutine
functions, even if they do not contain "await" or "async" keywords.

It is a "SyntaxError" to use a "yield from" expression inside the body
of a coroutine function.

An example of a coroutine function:

   async def func(param1, param2):
       do_stuff()
       await some_coroutine()


The "async for" statement
-------------------------

   async_for_stmt ::= "async" for_stmt

An *asynchronous iterable* is able to call asynchronous code in its
*iter* implementation, and *asynchronous iterator* can call
asynchronous code in its *next* method.

The "async for" statement allows convenient iteration over
asynchronous iterators.

The following code:

   async for TARGET in ITER:
       SUITE
   else:
       SUITE2

Is semantically equivalent to:

   iter = (ITER)
   iter = type(iter).__aiter__(iter)
   running = True

   while running:
       try:
           TARGET = await type(iter).__anext__(iter)
       except StopAsyncIteration:
           running = False
       else:
           SUITE
   else:
       SUITE2

See also "__aiter__()" and "__anext__()" for details.

It is a "SyntaxError" to use an "async for" statement outside the body
of a coroutine function.


The "async with" statement
--------------------------

   async_with_stmt ::= "async" with_stmt

An *asynchronous context manager* is a *context manager* that is able
to suspend execution in its *enter* and *exit* methods.

The following code:

   async with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   aexit = type(manager).__aexit__
   aenter = type(manager).__aenter__
   value = await aenter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not await aexit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           await aexit(manager, None, None, None)

See also "__aenter__()" and "__aexit__()" for details.

It is a "SyntaxError" to use an "async with" statement outside the
body of a coroutine function.

See also:

  **PEP 492** - Coroutines with async and await syntax
     The proposal that made coroutines a proper standalone concept in
     Python, and added supporting syntax.

-[ Footnotes ]-

[1] The exception is propagated to the invocation stack unless there
    is a "finally" clause which happens to raise another exception.
    That new exception causes the old one to be lost.

[2] A string literal appearing as the first statement in the function
    body is transformed into the function’s "__doc__" attribute and
    therefore the function’s *docstring*.

[3] A string literal appearing as the first statement in the class
    body is transformed into the namespace’s "__doc__" item and
    therefore the class’s *docstring*.
u�With Statement Context Managers
*******************************

A *context manager* is an object that defines the runtime context to
be established when executing a "with" statement. The context manager
handles the entry into, and the exit from, the desired runtime context
for the execution of the block of code.  Context managers are normally
invoked using the "with" statement (described in section The with
statement), but can also be used by directly invoking their methods.

Typical uses of context managers include saving and restoring various
kinds of global state, locking and unlocking resources, closing opened
files, etc.

For more information on context managers, see Context Manager Types.

object.__enter__(self)

   Enter the runtime context related to this object. The "with"
   statement will bind this method’s return value to the target(s)
   specified in the "as" clause of the statement, if any.

object.__exit__(self, exc_type, exc_value, traceback)

   Exit the runtime context related to this object. The parameters
   describe the exception that caused the context to be exited. If the
   context was exited without an exception, all three arguments will
   be "None".

   If an exception is supplied, and the method wishes to suppress the
   exception (i.e., prevent it from being propagated), it should
   return a true value. Otherwise, the exception will be processed
   normally upon exit from this method.

   Note that "__exit__()" methods should not reraise the passed-in
   exception; this is the caller’s responsibility.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.
a�The "continue" statement
************************

   continue_stmt ::= "continue"

"continue" may only occur syntactically nested in a "for" or "while"
loop, but not nested in a function or class definition within that
loop.  It continues with the next cycle of the nearest enclosing loop.

When "continue" passes control out of a "try" statement with a
"finally" clause, that "finally" clause is executed before really
starting the next loop cycle.
u�Arithmetic conversions
**********************

When a description of an arithmetic operator below uses the phrase
“the numeric arguments are converted to a common type”, this means
that the operator implementation for built-in types works as follows:

* If either argument is a complex number, the other is converted to
  complex;

* otherwise, if either argument is a floating point number, the other
  is converted to floating point;

* otherwise, both must be integers and no conversion is necessary.

Some additional rules apply for certain operators (e.g., a string as a
left argument to the ‘%’ operator).  Extensions must define their own
conversion behavior.
uS5Basic customization
*******************

object.__new__(cls[, ...])

   Called to create a new instance of class *cls*.  "__new__()" is a
   static method (special-cased so you need not declare it as such)
   that takes the class of which an instance was requested as its
   first argument.  The remaining arguments are those passed to the
   object constructor expression (the call to the class).  The return
   value of "__new__()" should be the new object instance (usually an
   instance of *cls*).

   Typical implementations create a new instance of the class by
   invoking the superclass’s "__new__()" method using
   "super().__new__(cls[, ...])" with appropriate arguments and then
   modifying the newly-created instance as necessary before returning
   it.

   If "__new__()" is invoked during object construction and it returns
   an instance of *cls*, then the new instance’s "__init__()" method
   will be invoked like "__init__(self[, ...])", where *self* is the
   new instance and the remaining arguments are the same as were
   passed to the object constructor.

   If "__new__()" does not return an instance of *cls*, then the new
   instance’s "__init__()" method will not be invoked.

   "__new__()" is intended mainly to allow subclasses of immutable
   types (like int, str, or tuple) to customize instance creation.  It
   is also commonly overridden in custom metaclasses in order to
   customize class creation.

object.__init__(self[, ...])

   Called after the instance has been created (by "__new__()"), but
   before it is returned to the caller.  The arguments are those
   passed to the class constructor expression.  If a base class has an
   "__init__()" method, the derived class’s "__init__()" method, if
   any, must explicitly call it to ensure proper initialization of the
   base class part of the instance; for example:
   "super().__init__([args...])".

   Because "__new__()" and "__init__()" work together in constructing
   objects ("__new__()" to create it, and "__init__()" to customize
   it), no non-"None" value may be returned by "__init__()"; doing so
   will cause a "TypeError" to be raised at runtime.

object.__del__(self)

   Called when the instance is about to be destroyed.  This is also
   called a finalizer or (improperly) a destructor.  If a base class
   has a "__del__()" method, the derived class’s "__del__()" method,
   if any, must explicitly call it to ensure proper deletion of the
   base class part of the instance.

   It is possible (though not recommended!) for the "__del__()" method
   to postpone destruction of the instance by creating a new reference
   to it.  This is called object *resurrection*.  It is
   implementation-dependent whether "__del__()" is called a second
   time when a resurrected object is about to be destroyed; the
   current *CPython* implementation only calls it once.

   It is not guaranteed that "__del__()" methods are called for
   objects that still exist when the interpreter exits.

   Note:

     "del x" doesn’t directly call "x.__del__()" — the former
     decrements the reference count for "x" by one, and the latter is
     only called when "x"’s reference count reaches zero.

   **CPython implementation detail:** It is possible for a reference
   cycle to prevent the reference count of an object from going to
   zero.  In this case, the cycle will be later detected and deleted
   by the *cyclic garbage collector*.  A common cause of reference
   cycles is when an exception has been caught in a local variable.
   The frame’s locals then reference the exception, which references
   its own traceback, which references the locals of all frames caught
   in the traceback.

   See also: Documentation for the "gc" module.

   Warning:

     Due to the precarious circumstances under which "__del__()"
     methods are invoked, exceptions that occur during their execution
     are ignored, and a warning is printed to "sys.stderr" instead.
     In particular:

     * "__del__()" can be invoked when arbitrary code is being
       executed, including from any arbitrary thread.  If "__del__()"
       needs to take a lock or invoke any other blocking resource, it
       may deadlock as the resource may already be taken by the code
       that gets interrupted to execute "__del__()".

     * "__del__()" can be executed during interpreter shutdown.  As a
       consequence, the global variables it needs to access (including
       other modules) may already have been deleted or set to "None".
       Python guarantees that globals whose name begins with a single
       underscore are deleted from their module before other globals
       are deleted; if no other references to such globals exist, this
       may help in assuring that imported modules are still available
       at the time when the "__del__()" method is called.

object.__repr__(self)

   Called by the "repr()" built-in function to compute the “official”
   string representation of an object.  If at all possible, this
   should look like a valid Python expression that could be used to
   recreate an object with the same value (given an appropriate
   environment).  If this is not possible, a string of the form
   "<...some useful description...>" should be returned. The return
   value must be a string object. If a class defines "__repr__()" but
   not "__str__()", then "__repr__()" is also used when an “informal”
   string representation of instances of that class is required.

   This is typically used for debugging, so it is important that the
   representation is information-rich and unambiguous.

object.__str__(self)

   Called by "str(object)" and the built-in functions "format()" and
   "print()" to compute the “informal” or nicely printable string
   representation of an object.  The return value must be a string
   object.

   This method differs from "object.__repr__()" in that there is no
   expectation that "__str__()" return a valid Python expression: a
   more convenient or concise representation can be used.

   The default implementation defined by the built-in type "object"
   calls "object.__repr__()".

object.__bytes__(self)

   Called by bytes to compute a byte-string representation of an
   object. This should return a "bytes" object.

object.__format__(self, format_spec)

   Called by the "format()" built-in function, and by extension,
   evaluation of formatted string literals and the "str.format()"
   method, to produce a “formatted” string representation of an
   object. The *format_spec* argument is a string that contains a
   description of the formatting options desired. The interpretation
   of the *format_spec* argument is up to the type implementing
   "__format__()", however most classes will either delegate
   formatting to one of the built-in types, or use a similar
   formatting option syntax.

   See Format Specification Mini-Language for a description of the
   standard formatting syntax.

   The return value must be a string object.

   Changed in version 3.4: The __format__ method of "object" itself
   raises a "TypeError" if passed any non-empty string.

   Changed in version 3.7: "object.__format__(x, '')" is now
   equivalent to "str(x)" rather than "format(str(self), '')".

object.__lt__(self, other)
object.__le__(self, other)
object.__eq__(self, other)
object.__ne__(self, other)
object.__gt__(self, other)
object.__ge__(self, other)

   These are the so-called “rich comparison” methods. The
   correspondence between operator symbols and method names is as
   follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",
   "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls
   "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".

   A rich comparison method may return the singleton "NotImplemented"
   if it does not implement the operation for a given pair of
   arguments. By convention, "False" and "True" are returned for a
   successful comparison. However, these methods can return any value,
   so if the comparison operator is used in a Boolean context (e.g.,
   in the condition of an "if" statement), Python will call "bool()"
   on the value to determine if the result is true or false.

   By default, "object" implements "__eq__()" by using "is", returning
   "NotImplemented" in the case of a false comparison: "True if x is y
   else NotImplemented". For "__ne__()", by default it delegates to
   "__eq__()" and inverts the result unless it is "NotImplemented".
   There are no other implied relationships among the comparison
   operators or default implementations; for example, the truth of
   "(x<y or x==y)" does not imply "x<=y". To automatically generate
   ordering operations from a single root operation, see
   "functools.total_ordering()".

   See the paragraph on "__hash__()" for some important notes on
   creating *hashable* objects which support custom comparison
   operations and are usable as dictionary keys.

   There are no swapped-argument versions of these methods (to be used
   when the left argument does not support the operation but the right
   argument does); rather, "__lt__()" and "__gt__()" are each other’s
   reflection, "__le__()" and "__ge__()" are each other’s reflection,
   and "__eq__()" and "__ne__()" are their own reflection. If the
   operands are of different types, and right operand’s type is a
   direct or indirect subclass of the left operand’s type, the
   reflected method of the right operand has priority, otherwise the
   left operand’s method has priority.  Virtual subclassing is not
   considered.

object.__hash__(self)

   Called by built-in function "hash()" and for operations on members
   of hashed collections including "set", "frozenset", and "dict".
   "__hash__()" should return an integer. The only required property
   is that objects which compare equal have the same hash value; it is
   advised to mix together the hash values of the components of the
   object that also play a part in comparison of objects by packing
   them into a tuple and hashing the tuple. Example:

      def __hash__(self):
          return hash((self.name, self.nick, self.color))

   Note:

     "hash()" truncates the value returned from an object’s custom
     "__hash__()" method to the size of a "Py_ssize_t".  This is
     typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds.
     If an object’s   "__hash__()" must interoperate on builds of
     different bit sizes, be sure to check the width on all supported
     builds.  An easy way to do this is with "python -c "import sys;
     print(sys.hash_info.width)"".

   If a class does not define an "__eq__()" method it should not
   define a "__hash__()" operation either; if it defines "__eq__()"
   but not "__hash__()", its instances will not be usable as items in
   hashable collections.  If a class defines mutable objects and
   implements an "__eq__()" method, it should not implement
   "__hash__()", since the implementation of hashable collections
   requires that a key’s hash value is immutable (if the object’s hash
   value changes, it will be in the wrong hash bucket).

   User-defined classes have "__eq__()" and "__hash__()" methods by
   default; with them, all objects compare unequal (except with
   themselves) and "x.__hash__()" returns an appropriate value such
   that "x == y" implies both that "x is y" and "hash(x) == hash(y)".

   A class that overrides "__eq__()" and does not define "__hash__()"
   will have its "__hash__()" implicitly set to "None".  When the
   "__hash__()" method of a class is "None", instances of the class
   will raise an appropriate "TypeError" when a program attempts to
   retrieve their hash value, and will also be correctly identified as
   unhashable when checking "isinstance(obj,
   collections.abc.Hashable)".

   If a class that overrides "__eq__()" needs to retain the
   implementation of "__hash__()" from a parent class, the interpreter
   must be told this explicitly by setting "__hash__ =
   <ParentClass>.__hash__".

   If a class that does not override "__eq__()" wishes to suppress
   hash support, it should include "__hash__ = None" in the class
   definition. A class which defines its own "__hash__()" that
   explicitly raises a "TypeError" would be incorrectly identified as
   hashable by an "isinstance(obj, collections.abc.Hashable)" call.

   Note:

     By default, the "__hash__()" values of str and bytes objects are
     “salted” with an unpredictable random value.  Although they
     remain constant within an individual Python process, they are not
     predictable between repeated invocations of Python.This is
     intended to provide protection against a denial-of-service caused
     by carefully-chosen inputs that exploit the worst case
     performance of a dict insertion, O(n^2) complexity.  See
     http://www.ocert.org/advisories/ocert-2011-003.html for
     details.Changing hash values affects the iteration order of sets.
     Python has never made guarantees about this ordering (and it
     typically varies between 32-bit and 64-bit builds).See also
     "PYTHONHASHSEED".

   Changed in version 3.3: Hash randomization is enabled by default.

object.__bool__(self)

   Called to implement truth value testing and the built-in operation
   "bool()"; should return "False" or "True".  When this method is not
   defined, "__len__()" is called, if it is defined, and the object is
   considered true if its result is nonzero.  If a class defines
   neither "__len__()" nor "__bool__()", all its instances are
   considered true.
u�I"pdb" — The Python Debugger
***************************

**Source code:** Lib/pdb.py

======================================================================

The module "pdb" defines an interactive source code debugger for
Python programs.  It supports setting (conditional) breakpoints and
single stepping at the source line level, inspection of stack frames,
source code listing, and evaluation of arbitrary Python code in the
context of any stack frame.  It also supports post-mortem debugging
and can be called under program control.

The debugger is extensible – it is actually defined as the class
"Pdb". This is currently undocumented but easily understood by reading
the source.  The extension interface uses the modules "bdb" and "cmd".

The debugger’s prompt is "(Pdb)". Typical usage to run a program under
control of the debugger is:

   >>> import pdb
   >>> import mymodule
   >>> pdb.run('mymodule.test()')
   > <string>(0)?()
   (Pdb) continue
   > <string>(1)?()
   (Pdb) continue
   NameError: 'spam'
   > <string>(1)?()
   (Pdb)

Changed in version 3.3: Tab-completion via the "readline" module is
available for commands and command arguments, e.g. the current global
and local names are offered as arguments of the "p" command.

"pdb.py" can also be invoked as a script to debug other scripts.  For
example:

   python3 -m pdb myscript.py

When invoked as a script, pdb will automatically enter post-mortem
debugging if the program being debugged exits abnormally.  After post-
mortem debugging (or after normal exit of the program), pdb will
restart the program.  Automatic restarting preserves pdb’s state (such
as breakpoints) and in most cases is more useful than quitting the
debugger upon program’s exit.

New in version 3.2: "pdb.py" now accepts a "-c" option that executes
commands as if given in a ".pdbrc" file, see Debugger Commands.

New in version 3.7: "pdb.py" now accepts a "-m" option that execute
modules similar to the way "python3 -m" does. As with a script, the
debugger will pause execution just before the first line of the
module.

The typical usage to break into the debugger from a running program is
to insert

   import pdb; pdb.set_trace()

at the location you want to break into the debugger.  You can then
step through the code following this statement, and continue running
without the debugger using the "continue" command.

New in version 3.7: The built-in "breakpoint()", when called with
defaults, can be used instead of "import pdb; pdb.set_trace()".

The typical usage to inspect a crashed program is:

   >>> import pdb
   >>> import mymodule
   >>> mymodule.test()
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "./mymodule.py", line 4, in test
       test2()
     File "./mymodule.py", line 3, in test2
       print(spam)
   NameError: spam
   >>> pdb.pm()
   > ./mymodule.py(3)test2()
   -> print(spam)
   (Pdb)

The module defines the following functions; each enters the debugger
in a slightly different way:

pdb.run(statement, globals=None, locals=None)

   Execute the *statement* (given as a string or a code object) under
   debugger control.  The debugger prompt appears before any code is
   executed; you can set breakpoints and type "continue", or you can
   step through the statement using "step" or "next" (all these
   commands are explained below).  The optional *globals* and *locals*
   arguments specify the environment in which the code is executed; by
   default the dictionary of the module "__main__" is used.  (See the
   explanation of the built-in "exec()" or "eval()" functions.)

pdb.runeval(expression, globals=None, locals=None)

   Evaluate the *expression* (given as a string or a code object)
   under debugger control.  When "runeval()" returns, it returns the
   value of the expression.  Otherwise this function is similar to
   "run()".

pdb.runcall(function, *args, **kwds)

   Call the *function* (a function or method object, not a string)
   with the given arguments.  When "runcall()" returns, it returns
   whatever the function call returned.  The debugger prompt appears
   as soon as the function is entered.

pdb.set_trace(*, header=None)

   Enter the debugger at the calling stack frame.  This is useful to
   hard-code a breakpoint at a given point in a program, even if the
   code is not otherwise being debugged (e.g. when an assertion
   fails).  If given, *header* is printed to the console just before
   debugging begins.

   Changed in version 3.7: The keyword-only argument *header*.

pdb.post_mortem(traceback=None)

   Enter post-mortem debugging of the given *traceback* object.  If no
   *traceback* is given, it uses the one of the exception that is
   currently being handled (an exception must be being handled if the
   default is to be used).

pdb.pm()

   Enter post-mortem debugging of the traceback found in
   "sys.last_traceback".

The "run*" functions and "set_trace()" are aliases for instantiating
the "Pdb" class and calling the method of the same name.  If you want
to access further features, you have to do this yourself:

class pdb.Pdb(completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False, readrc=True)

   "Pdb" is the debugger class.

   The *completekey*, *stdin* and *stdout* arguments are passed to the
   underlying "cmd.Cmd" class; see the description there.

   The *skip* argument, if given, must be an iterable of glob-style
   module name patterns.  The debugger will not step into frames that
   originate in a module that matches one of these patterns. [1]

   By default, Pdb sets a handler for the SIGINT signal (which is sent
   when the user presses "Ctrl-C" on the console) when you give a
   "continue" command. This allows you to break into the debugger
   again by pressing "Ctrl-C".  If you want Pdb not to touch the
   SIGINT handler, set *nosigint* to true.

   The *readrc* argument defaults to true and controls whether Pdb
   will load .pdbrc files from the filesystem.

   Example call to enable tracing with *skip*:

      import pdb; pdb.Pdb(skip=['django.*']).set_trace()

   Raises an auditing event "pdb.Pdb" with no arguments.

   New in version 3.1: The *skip* argument.

   New in version 3.2: The *nosigint* argument.  Previously, a SIGINT
   handler was never set by Pdb.

   Changed in version 3.6: The *readrc* argument.

   run(statement, globals=None, locals=None)
   runeval(expression, globals=None, locals=None)
   runcall(function, *args, **kwds)
   set_trace()

      See the documentation for the functions explained above.


Debugger Commands
=================

The commands recognized by the debugger are listed below.  Most
commands can be abbreviated to one or two letters as indicated; e.g.
"h(elp)" means that either "h" or "help" can be used to enter the help
command (but not "he" or "hel", nor "H" or "Help" or "HELP").
Arguments to commands must be separated by whitespace (spaces or
tabs).  Optional arguments are enclosed in square brackets ("[]") in
the command syntax; the square brackets must not be typed.
Alternatives in the command syntax are separated by a vertical bar
("|").

Entering a blank line repeats the last command entered.  Exception: if
the last command was a "list" command, the next 11 lines are listed.

Commands that the debugger doesn’t recognize are assumed to be Python
statements and are executed in the context of the program being
debugged.  Python statements can also be prefixed with an exclamation
point ("!").  This is a powerful way to inspect the program being
debugged; it is even possible to change a variable or call a function.
When an exception occurs in such a statement, the exception name is
printed but the debugger’s state is not changed.

The debugger supports aliases.  Aliases can have parameters which
allows one a certain level of adaptability to the context under
examination.

Multiple commands may be entered on a single line, separated by ";;".
(A single ";" is not used as it is the separator for multiple commands
in a line that is passed to the Python parser.)  No intelligence is
applied to separating the commands; the input is split at the first
";;" pair, even if it is in the middle of a quoted string.

If a file ".pdbrc" exists in the user’s home directory or in the
current directory, it is read in and executed as if it had been typed
at the debugger prompt.  This is particularly useful for aliases.  If
both files exist, the one in the home directory is read first and
aliases defined there can be overridden by the local file.

Changed in version 3.2: ".pdbrc" can now contain commands that
continue debugging, such as "continue" or "next".  Previously, these
commands had no effect.

h(elp) [command]

   Without argument, print the list of available commands.  With a
   *command* as argument, print help about that command.  "help pdb"
   displays the full documentation (the docstring of the "pdb"
   module).  Since the *command* argument must be an identifier, "help
   exec" must be entered to get help on the "!" command.

w(here)

   Print a stack trace, with the most recent frame at the bottom.  An
   arrow indicates the current frame, which determines the context of
   most commands.

d(own) [count]

   Move the current frame *count* (default one) levels down in the
   stack trace (to a newer frame).

u(p) [count]

   Move the current frame *count* (default one) levels up in the stack
   trace (to an older frame).

b(reak) [([filename:]lineno | function) [, condition]]

   With a *lineno* argument, set a break there in the current file.
   With a *function* argument, set a break at the first executable
   statement within that function.  The line number may be prefixed
   with a filename and a colon, to specify a breakpoint in another
   file (probably one that hasn’t been loaded yet).  The file is
   searched on "sys.path".  Note that each breakpoint is assigned a
   number to which all the other breakpoint commands refer.

   If a second argument is present, it is an expression which must
   evaluate to true before the breakpoint is honored.

   Without argument, list all breaks, including for each breakpoint,
   the number of times that breakpoint has been hit, the current
   ignore count, and the associated condition if any.

tbreak [([filename:]lineno | function) [, condition]]

   Temporary breakpoint, which is removed automatically when it is
   first hit. The arguments are the same as for "break".

cl(ear) [filename:lineno | bpnumber [bpnumber ...]]

   With a *filename:lineno* argument, clear all the breakpoints at
   this line. With a space separated list of breakpoint numbers, clear
   those breakpoints. Without argument, clear all breaks (but first
   ask confirmation).

disable [bpnumber [bpnumber ...]]

   Disable the breakpoints given as a space separated list of
   breakpoint numbers.  Disabling a breakpoint means it cannot cause
   the program to stop execution, but unlike clearing a breakpoint, it
   remains in the list of breakpoints and can be (re-)enabled.

enable [bpnumber [bpnumber ...]]

   Enable the breakpoints specified.

ignore bpnumber [count]

   Set the ignore count for the given breakpoint number.  If count is
   omitted, the ignore count is set to 0.  A breakpoint becomes active
   when the ignore count is zero.  When non-zero, the count is
   decremented each time the breakpoint is reached and the breakpoint
   is not disabled and any associated condition evaluates to true.

condition bpnumber [condition]

   Set a new *condition* for the breakpoint, an expression which must
   evaluate to true before the breakpoint is honored.  If *condition*
   is absent, any existing condition is removed; i.e., the breakpoint
   is made unconditional.

commands [bpnumber]

   Specify a list of commands for breakpoint number *bpnumber*.  The
   commands themselves appear on the following lines.  Type a line
   containing just "end" to terminate the commands. An example:

      (Pdb) commands 1
      (com) p some_variable
      (com) end
      (Pdb)

   To remove all commands from a breakpoint, type "commands" and
   follow it immediately with "end"; that is, give no commands.

   With no *bpnumber* argument, "commands" refers to the last
   breakpoint set.

   You can use breakpoint commands to start your program up again.
   Simply use the "continue" command, or "step", or any other command
   that resumes execution.

   Specifying any command resuming execution (currently "continue",
   "step", "next", "return", "jump", "quit" and their abbreviations)
   terminates the command list (as if that command was immediately
   followed by end). This is because any time you resume execution
   (even with a simple next or step), you may encounter another
   breakpoint—which could have its own command list, leading to
   ambiguities about which list to execute.

   If you use the ‘silent’ command in the command list, the usual
   message about stopping at a breakpoint is not printed.  This may be
   desirable for breakpoints that are to print a specific message and
   then continue.  If none of the other commands print anything, you
   see no sign that the breakpoint was reached.

s(tep)

   Execute the current line, stop at the first possible occasion
   (either in a function that is called or on the next line in the
   current function).

n(ext)

   Continue execution until the next line in the current function is
   reached or it returns.  (The difference between "next" and "step"
   is that "step" stops inside a called function, while "next"
   executes called functions at (nearly) full speed, only stopping at
   the next line in the current function.)

unt(il) [lineno]

   Without argument, continue execution until the line with a number
   greater than the current one is reached.

   With a line number, continue execution until a line with a number
   greater or equal to that is reached.  In both cases, also stop when
   the current frame returns.

   Changed in version 3.2: Allow giving an explicit line number.

r(eturn)

   Continue execution until the current function returns.

c(ont(inue))

   Continue execution, only stop when a breakpoint is encountered.

j(ump) lineno

   Set the next line that will be executed.  Only available in the
   bottom-most frame.  This lets you jump back and execute code again,
   or jump forward to skip code that you don’t want to run.

   It should be noted that not all jumps are allowed – for instance it
   is not possible to jump into the middle of a "for" loop or out of a
   "finally" clause.

l(ist) [first[, last]]

   List source code for the current file.  Without arguments, list 11
   lines around the current line or continue the previous listing.
   With "." as argument, list 11 lines around the current line.  With
   one argument, list 11 lines around at that line.  With two
   arguments, list the given range; if the second argument is less
   than the first, it is interpreted as a count.

   The current line in the current frame is indicated by "->".  If an
   exception is being debugged, the line where the exception was
   originally raised or propagated is indicated by ">>", if it differs
   from the current line.

   New in version 3.2: The ">>" marker.

ll | longlist

   List all source code for the current function or frame.
   Interesting lines are marked as for "list".

   New in version 3.2.

a(rgs)

   Print the argument list of the current function.

p expression

   Evaluate the *expression* in the current context and print its
   value.

   Note:

     "print()" can also be used, but is not a debugger command — this
     executes the Python "print()" function.

pp expression

   Like the "p" command, except the value of the expression is pretty-
   printed using the "pprint" module.

whatis expression

   Print the type of the *expression*.

source expression

   Try to get source code for the given object and display it.

   New in version 3.2.

display [expression]

   Display the value of the expression if it changed, each time
   execution stops in the current frame.

   Without expression, list all display expressions for the current
   frame.

   New in version 3.2.

undisplay [expression]

   Do not display the expression any more in the current frame.
   Without expression, clear all display expressions for the current
   frame.

   New in version 3.2.

interact

   Start an interactive interpreter (using the "code" module) whose
   global namespace contains all the (global and local) names found in
   the current scope.

   New in version 3.2.

alias [name [command]]

   Create an alias called *name* that executes *command*.  The command
   must *not* be enclosed in quotes.  Replaceable parameters can be
   indicated by "%1", "%2", and so on, while "%*" is replaced by all
   the parameters. If no command is given, the current alias for
   *name* is shown. If no arguments are given, all aliases are listed.

   Aliases may be nested and can contain anything that can be legally
   typed at the pdb prompt.  Note that internal pdb commands *can* be
   overridden by aliases.  Such a command is then hidden until the
   alias is removed.  Aliasing is recursively applied to the first
   word of the command line; all other words in the line are left
   alone.

   As an example, here are two useful aliases (especially when placed
   in the ".pdbrc" file):

      # Print instance variables (usage "pi classInst")
      alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])
      # Print instance variables in self
      alias ps pi self

unalias name

   Delete the specified alias.

! statement

   Execute the (one-line) *statement* in the context of the current
   stack frame. The exclamation point can be omitted unless the first
   word of the statement resembles a debugger command.  To set a
   global variable, you can prefix the assignment command with a
   "global" statement on the same line, e.g.:

      (Pdb) global list_options; list_options = ['-l']
      (Pdb)

run [args ...]
restart [args ...]

   Restart the debugged Python program.  If an argument is supplied,
   it is split with "shlex" and the result is used as the new
   "sys.argv". History, breakpoints, actions and debugger options are
   preserved. "restart" is an alias for "run".

q(uit)

   Quit from the debugger.  The program being executed is aborted.

debug code

   Enter a recursive debugger that steps through the code argument
   (which is an arbitrary expression or statement to be executed in
   the current environment).

retval

   Print the return value for the last return of a function.

-[ Footnotes ]-

[1] Whether a frame is considered to originate in a certain module is
    determined by the "__name__" in the frame globals.
a�The "del" statement
*******************

   del_stmt ::= "del" target_list

Deletion is recursively defined very similar to the way assignment is
defined. Rather than spelling it out in full details, here are some
hints.

Deletion of a target list recursively deletes each target, from left
to right.

Deletion of a name removes the binding of that name from the local or
global namespace, depending on whether the name occurs in a "global"
statement in the same code block.  If the name is unbound, a
"NameError" exception will be raised.

Deletion of attribute references, subscriptions and slicings is passed
to the primary object involved; deletion of a slicing is in general
equivalent to assignment of an empty slice of the right type (but even
this is determined by the sliced object).

Changed in version 3.2: Previously it was illegal to delete a name
from the local namespace if it occurs as a free variable in a nested
block.
uDictionary displays
*******************

A dictionary display is a possibly empty series of key/datum pairs
enclosed in curly braces:

   dict_display       ::= "{" [key_datum_list | dict_comprehension] "}"
   key_datum_list     ::= key_datum ("," key_datum)* [","]
   key_datum          ::= expression ":" expression | "**" or_expr
   dict_comprehension ::= expression ":" expression comp_for

A dictionary display yields a new dictionary object.

If a comma-separated sequence of key/datum pairs is given, they are
evaluated from left to right to define the entries of the dictionary:
each key object is used as a key into the dictionary to store the
corresponding datum.  This means that you can specify the same key
multiple times in the key/datum list, and the final dictionary’s value
for that key will be the last one given.

A double asterisk "**" denotes *dictionary unpacking*. Its operand
must be a *mapping*.  Each mapping item is added to the new
dictionary.  Later values replace values already set by earlier
key/datum pairs and earlier dictionary unpackings.

New in version 3.5: Unpacking into dictionary displays, originally
proposed by **PEP 448**.

A dict comprehension, in contrast to list and set comprehensions,
needs two expressions separated with a colon followed by the usual
“for” and “if” clauses. When the comprehension is run, the resulting
key and value elements are inserted in the new dictionary in the order
they are produced.

Restrictions on the types of the key values are listed earlier in
section The standard type hierarchy.  (To summarize, the key type
should be *hashable*, which excludes all mutable objects.)  Clashes
between duplicate keys are not detected; the last datum (textually
rightmost in the display) stored for a given key value prevails.

Changed in version 3.8: Prior to Python 3.8, in dict comprehensions,
the evaluation order of key and value was not well-defined.  In
CPython, the value was evaluated before the key.  Starting with 3.8,
the key is evaluated before the value, as proposed by **PEP 572**.
a�Interaction with dynamic features
*********************************

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.
aXThe "if" statement
******************

The "if" statement is used for conditional execution:

   if_stmt ::= "if" assignment_expression ":" suite
               ("elif" assignment_expression ":" suite)*
               ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section Boolean operations
for the definition of true and false); then that suite is executed
(and no other part of the "if" statement is executed or evaluated).
If all expressions are false, the suite of the "else" clause, if
present, is executed.
u�Exceptions
**********

Exceptions are a means of breaking out of the normal flow of control
of a code block in order to handle errors or other exceptional
conditions.  An exception is *raised* at the point where the error is
detected; it may be *handled* by the surrounding code block or by any
code block that directly or indirectly invoked the code block where
the error occurred.

The Python interpreter raises an exception when it detects a run-time
error (such as division by zero).  A Python program can also
explicitly raise an exception with the "raise" statement. Exception
handlers are specified with the "try" … "except" statement.  The
"finally" clause of such a statement can be used to specify cleanup
code which does not handle the exception, but is executed whether an
exception occurred or not in the preceding code.

Python uses the “termination” model of error handling: an exception
handler can find out what happened and continue execution at an outer
level, but it cannot repair the cause of the error and retry the
failing operation (except by re-entering the offending piece of code
from the top).

When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.  In
either case, it prints a stack traceback, except when the exception is
"SystemExit".

Exceptions are identified by class instances.  The "except" clause is
selected depending on the class of the instance: it must reference the
class of the instance or a base class thereof.  The instance can be
received by the handler and can carry additional information about the
exceptional condition.

Note:

  Exception messages are not part of the Python API.  Their contents
  may change from one version of Python to the next without warning
  and should not be relied on by code which will run under multiple
  versions of the interpreter.

See also the description of the "try" statement in section The try
statement and "raise" statement in section The raise statement.

-[ Footnotes ]-

[1] This limitation occurs because the code that is executed by these
    operations is not available at the time the module is compiled.
u$Execution model
***************


Structure of a program
======================

A Python program is constructed from code blocks. A *block* is a piece
of Python program text that is executed as a unit. The following are
blocks: a module, a function body, and a class definition. Each
command typed interactively is a block.  A script file (a file given
as standard input to the interpreter or specified as a command line
argument to the interpreter) is a code block.  A script command (a
command specified on the interpreter command line with the "-c"
option) is a code block.  The string argument passed to the built-in
functions "eval()" and "exec()" is a code block.

A code block is executed in an *execution frame*.  A frame contains
some administrative information (used for debugging) and determines
where and how execution continues after the code block’s execution has
completed.


Naming and binding
==================


Binding of names
----------------

*Names* refer to objects.  Names are introduced by name binding
operations.

The following constructs bind names: formal parameters to functions,
"import" statements, class and function definitions (these bind the
class or function name in the defining block), and targets that are
identifiers if occurring in an assignment, "for" loop header, or after
"as" in a "with" statement or "except" clause. The "import" statement
of the form "from ... import *" binds all names defined in the
imported module, except those beginning with an underscore.  This form
may only be used at the module level.

A target occurring in a "del" statement is also considered bound for
this purpose (though the actual semantics are to unbind the name).

Each assignment or import statement occurs within a block defined by a
class or function definition or at the module level (the top-level
code block).

If a name is bound in a block, it is a local variable of that block,
unless declared as "nonlocal" or "global".  If a name is bound at the
module level, it is a global variable.  (The variables of the module
code block are local and global.)  If a variable is used in a code
block but not defined there, it is a *free variable*.

Each occurrence of a name in the program text refers to the *binding*
of that name established by the following name resolution rules.


Resolution of names
-------------------

A *scope* defines the visibility of a name within a block.  If a local
variable is defined in a block, its scope includes that block.  If the
definition occurs in a function block, the scope extends to any blocks
contained within the defining one, unless a contained block introduces
a different binding for the name.

When a name is used in a code block, it is resolved using the nearest
enclosing scope.  The set of all such scopes visible to a code block
is called the block’s *environment*.

When a name is not found at all, a "NameError" exception is raised. If
the current scope is a function scope, and the name refers to a local
variable that has not yet been bound to a value at the point where the
name is used, an "UnboundLocalError" exception is raised.
"UnboundLocalError" is a subclass of "NameError".

If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block.  This can lead to errors when a name is used within a
block before it is bound.  This rule is subtle.  Python lacks
declarations and allows name binding operations to occur anywhere
within a code block.  The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.

If the "global" statement occurs within a block, all uses of the name
specified in the statement refer to the binding of that name in the
top-level namespace.  Names are resolved in the top-level namespace by
searching the global namespace, i.e. the namespace of the module
containing the code block, and the builtins namespace, the namespace
of the module "builtins".  The global namespace is searched first.  If
the name is not found there, the builtins namespace is searched.  The
"global" statement must precede all uses of the name.

The "global" statement has the same scope as a name binding operation
in the same block.  If the nearest enclosing scope for a free variable
contains a global statement, the free variable is treated as a global.

The "nonlocal" statement causes corresponding names to refer to
previously bound variables in the nearest enclosing function scope.
"SyntaxError" is raised at compile time if the given name does not
exist in any enclosing function scope.

The namespace for a module is automatically created the first time a
module is imported.  The main module for a script is always called
"__main__".

Class definition blocks and arguments to "exec()" and "eval()" are
special in the context of name resolution. A class definition is an
executable statement that may use and define names. These references
follow the normal rules for name resolution with an exception that
unbound local variables are looked up in the global namespace. The
namespace of the class definition becomes the attribute dictionary of
the class. The scope of names defined in a class block is limited to
the class block; it does not extend to the code blocks of methods –
this includes comprehensions and generator expressions since they are
implemented using a function scope.  This means that the following
will fail:

   class A:
       a = 42
       b = list(a + i for i in range(10))


Builtins and restricted execution
---------------------------------

**CPython implementation detail:** Users should not touch
"__builtins__"; it is strictly an implementation detail.  Users
wanting to override values in the builtins namespace should "import"
the "builtins" module and modify its attributes appropriately.

The builtins namespace associated with the execution of a code block
is actually found by looking up the name "__builtins__" in its global
namespace; this should be a dictionary or a module (in the latter case
the module’s dictionary is used).  By default, when in the "__main__"
module, "__builtins__" is the built-in module "builtins"; when in any
other module, "__builtins__" is an alias for the dictionary of the
"builtins" module itself.


Interaction with dynamic features
---------------------------------

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.


Exceptions
==========

Exceptions are a means of breaking out of the normal flow of control
of a code block in order to handle errors or other exceptional
conditions.  An exception is *raised* at the point where the error is
detected; it may be *handled* by the surrounding code block or by any
code block that directly or indirectly invoked the code block where
the error occurred.

The Python interpreter raises an exception when it detects a run-time
error (such as division by zero).  A Python program can also
explicitly raise an exception with the "raise" statement. Exception
handlers are specified with the "try" … "except" statement.  The
"finally" clause of such a statement can be used to specify cleanup
code which does not handle the exception, but is executed whether an
exception occurred or not in the preceding code.

Python uses the “termination” model of error handling: an exception
handler can find out what happened and continue execution at an outer
level, but it cannot repair the cause of the error and retry the
failing operation (except by re-entering the offending piece of code
from the top).

When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.  In
either case, it prints a stack traceback, except when the exception is
"SystemExit".

Exceptions are identified by class instances.  The "except" clause is
selected depending on the class of the instance: it must reference the
class of the instance or a base class thereof.  The instance can be
received by the handler and can carry additional information about the
exceptional condition.

Note:

  Exception messages are not part of the Python API.  Their contents
  may change from one version of Python to the next without warning
  and should not be relied on by code which will run under multiple
  versions of the interpreter.

See also the description of the "try" statement in section The try
statement and "raise" statement in section The raise statement.

-[ Footnotes ]-

[1] This limitation occurs because the code that is executed by these
    operations is not available at the time the module is compiled.
uzExpression lists
****************

   expression_list    ::= expression ("," expression)* [","]
   starred_list       ::= starred_item ("," starred_item)* [","]
   starred_expression ::= expression | (starred_item ",")* [starred_item]
   starred_item       ::= assignment_expression | "*" or_expr

Except when part of a list or set display, an expression list
containing at least one comma yields a tuple.  The length of the tuple
is the number of expressions in the list.  The expressions are
evaluated from left to right.

An asterisk "*" denotes *iterable unpacking*.  Its operand must be an
*iterable*.  The iterable is expanded into a sequence of items, which
are included in the new tuple, list, or set, at the site of the
unpacking.

New in version 3.5: Iterable unpacking in expression lists, originally
proposed by **PEP 448**.

The trailing comma is required only to create a single tuple (a.k.a. a
*singleton*); it is optional in all other cases.  A single expression
without a trailing comma doesn’t create a tuple, but rather yields the
value of that expression. (To create an empty tuple, use an empty pair
of parentheses: "()".)
a�Floating point literals
***********************

Floating point literals are described by the following lexical
definitions:

   floatnumber   ::= pointfloat | exponentfloat
   pointfloat    ::= [digitpart] fraction | digitpart "."
   exponentfloat ::= (digitpart | pointfloat) exponent
   digitpart     ::= digit (["_"] digit)*
   fraction      ::= "." digitpart
   exponent      ::= ("e" | "E") ["+" | "-"] digitpart

Note that the integer and exponent parts are always interpreted using
radix 10. For example, "077e010" is legal, and denotes the same number
as "77e10". The allowed range of floating point literals is
implementation-dependent.  As in integer literals, underscores are
supported for digit grouping.

Some examples of floating point literals:

   3.14    10.    .001    1e100    3.14e-10    0e0    3.14_15_93

Changed in version 3.6: Underscores are now allowed for grouping
purposes in literals.
u�
The "for" statement
*******************

The "for" statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object:

   for_stmt ::= "for" target_list "in" expression_list ":" suite
                ["else" ":" suite]

The expression list is evaluated once; it should yield an iterable
object.  An iterator is created for the result of the
"expression_list".  The suite is then executed once for each item
provided by the iterator, in the order returned by the iterator.  Each
item in turn is assigned to the target list using the standard rules
for assignments (see Assignment statements), and then the suite is
executed.  When the items are exhausted (which is immediately when the
sequence is empty or an iterator raises a "StopIteration" exception),
the suite in the "else" clause, if present, is executed, and the loop
terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and continues
with the next item, or with the "else" clause if there is no next
item.

The for-loop makes assignments to the variables in the target list.
This overwrites all previous assignments to those variables including
those made in the suite of the for-loop:

   for i in range(10):
       print(i)
       i = 5             # this will not affect the for-loop
                         # because i will be overwritten with the next
                         # index in the range

Names in the target list are not deleted when the loop is finished,
but if the sequence is empty, they will not have been assigned to at
all by the loop.  Hint: the built-in function "range()" returns an
iterator of integers suitable to emulate the effect of Pascal’s "for i
:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".

Note:

  There is a subtlety when the sequence is being modified by the loop
  (this can only occur for mutable sequences, e.g. lists).  An
  internal counter is used to keep track of which item is used next,
  and this is incremented on each iteration.  When this counter has
  reached the length of the sequence the loop terminates.  This means
  that if the suite deletes the current (or a previous) item from the
  sequence, the next item will be skipped (since it gets the index of
  the current item which has already been treated).  Likewise, if the
  suite inserts an item in the sequence before the current item, the
  current item will be treated again the next time through the loop.
  This can lead to nasty bugs that can be avoided by making a
  temporary copy using a slice of the whole sequence, e.g.,

     for x in a[:]:
         if x < 0: a.remove(x)
u�`Format String Syntax
********************

The "str.format()" method and the "Formatter" class share the same
syntax for format strings (although in the case of "Formatter",
subclasses can define their own format string syntax).  The syntax is
related to that of formatted string literals, but it is less
sophisticated and, in particular, does not support arbitrary
expressions.

Format strings contain “replacement fields” surrounded by curly braces
"{}". Anything that is not contained in braces is considered literal
text, which is copied unchanged to the output.  If you need to include
a brace character in the literal text, it can be escaped by doubling:
"{{" and "}}".

The grammar for a replacement field is as follows:

      replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"
      field_name        ::= arg_name ("." attribute_name | "[" element_index "]")*
      arg_name          ::= [identifier | digit+]
      attribute_name    ::= identifier
      element_index     ::= digit+ | index_string
      index_string      ::= <any source character except "]"> +
      conversion        ::= "r" | "s" | "a"
      format_spec       ::= <described in the next section>

In less formal terms, the replacement field can start with a
*field_name* that specifies the object whose value is to be formatted
and inserted into the output instead of the replacement field. The
*field_name* is optionally followed by a  *conversion* field, which is
preceded by an exclamation point "'!'", and a *format_spec*, which is
preceded by a colon "':'".  These specify a non-default format for the
replacement value.

See also the Format Specification Mini-Language section.

The *field_name* itself begins with an *arg_name* that is either a
number or a keyword.  If it’s a number, it refers to a positional
argument, and if it’s a keyword, it refers to a named keyword
argument.  If the numerical arg_names in a format string are 0, 1, 2,
… in sequence, they can all be omitted (not just some) and the numbers
0, 1, 2, … will be automatically inserted in that order. Because
*arg_name* is not quote-delimited, it is not possible to specify
arbitrary dictionary keys (e.g., the strings "'10'" or "':-]'") within
a format string. The *arg_name* can be followed by any number of index
or attribute expressions. An expression of the form "'.name'" selects
the named attribute using "getattr()", while an expression of the form
"'[index]'" does an index lookup using "__getitem__()".

Changed in version 3.1: The positional argument specifiers can be
omitted for "str.format()", so "'{} {}'.format(a, b)" is equivalent to
"'{0} {1}'.format(a, b)".

Changed in version 3.4: The positional argument specifiers can be
omitted for "Formatter".

Some simple format string examples:

   "First, thou shalt count to {0}"  # References first positional argument
   "Bring me a {}"                   # Implicitly references the first positional argument
   "From {} to {}"                   # Same as "From {0} to {1}"
   "My quest is {name}"              # References keyword argument 'name'
   "Weight in tons {0.weight}"       # 'weight' attribute of first positional arg
   "Units destroyed: {players[0]}"   # First element of keyword argument 'players'.

The *conversion* field causes a type coercion before formatting.
Normally, the job of formatting a value is done by the "__format__()"
method of the value itself.  However, in some cases it is desirable to
force a type to be formatted as a string, overriding its own
definition of formatting.  By converting the value to a string before
calling "__format__()", the normal formatting logic is bypassed.

Three conversion flags are currently supported: "'!s'" which calls
"str()" on the value, "'!r'" which calls "repr()" and "'!a'" which
calls "ascii()".

Some examples:

   "Harold's a clever {0!s}"        # Calls str() on the argument first
   "Bring out the holy {name!r}"    # Calls repr() on the argument first
   "More {!a}"                      # Calls ascii() on the argument first

The *format_spec* field contains a specification of how the value
should be presented, including such details as field width, alignment,
padding, decimal precision and so on.  Each value type can define its
own “formatting mini-language” or interpretation of the *format_spec*.

Most built-in types support a common formatting mini-language, which
is described in the next section.

A *format_spec* field can also include nested replacement fields
within it. These nested replacement fields may contain a field name,
conversion flag and format specification, but deeper nesting is not
allowed.  The replacement fields within the format_spec are
substituted before the *format_spec* string is interpreted. This
allows the formatting of a value to be dynamically specified.

See the Format examples section for some examples.


Format Specification Mini-Language
==================================

“Format specifications” are used within replacement fields contained
within a format string to define how individual values are presented
(see Format String Syntax and Formatted string literals). They can
also be passed directly to the built-in "format()" function.  Each
formattable type may define how the format specification is to be
interpreted.

Most built-in types implement the following options for format
specifications, although some of the formatting options are only
supported by the numeric types.

A general convention is that an empty format specification produces
the same result as if you had called "str()" on the value. A non-empty
format specification typically modifies the result.

The general form of a *standard format specifier* is:

   format_spec     ::= [[fill]align][sign][#][0][width][grouping_option][.precision][type]
   fill            ::= <any character>
   align           ::= "<" | ">" | "=" | "^"
   sign            ::= "+" | "-" | " "
   width           ::= digit+
   grouping_option ::= "_" | ","
   precision       ::= digit+
   type            ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"

If a valid *align* value is specified, it can be preceded by a *fill*
character that can be any character and defaults to a space if
omitted. It is not possible to use a literal curly brace (”"{"” or
“"}"”) as the *fill* character in a formatted string literal or when
using the "str.format()" method.  However, it is possible to insert a
curly brace with a nested replacement field.  This limitation doesn’t
affect the "format()" function.

The meaning of the various alignment options is as follows:

   +-----------+------------------------------------------------------------+
   | Option    | Meaning                                                    |
   |===========|============================================================|
   | "'<'"     | Forces the field to be left-aligned within the available   |
   |           | space (this is the default for most objects).              |
   +-----------+------------------------------------------------------------+
   | "'>'"     | Forces the field to be right-aligned within the available  |
   |           | space (this is the default for numbers).                   |
   +-----------+------------------------------------------------------------+
   | "'='"     | Forces the padding to be placed after the sign (if any)    |
   |           | but before the digits.  This is used for printing fields   |
   |           | in the form ‘+000000120’. This alignment option is only    |
   |           | valid for numeric types.  It becomes the default when ‘0’  |
   |           | immediately precedes the field width.                      |
   +-----------+------------------------------------------------------------+
   | "'^'"     | Forces the field to be centered within the available       |
   |           | space.                                                     |
   +-----------+------------------------------------------------------------+

Note that unless a minimum field width is defined, the field width
will always be the same size as the data to fill it, so that the
alignment option has no meaning in this case.

The *sign* option is only valid for number types, and can be one of
the following:

   +-----------+------------------------------------------------------------+
   | Option    | Meaning                                                    |
   |===========|============================================================|
   | "'+'"     | indicates that a sign should be used for both positive as  |
   |           | well as negative numbers.                                  |
   +-----------+------------------------------------------------------------+
   | "'-'"     | indicates that a sign should be used only for negative     |
   |           | numbers (this is the default behavior).                    |
   +-----------+------------------------------------------------------------+
   | space     | indicates that a leading space should be used on positive  |
   |           | numbers, and a minus sign on negative numbers.             |
   +-----------+------------------------------------------------------------+

The "'#'" option causes the “alternate form” to be used for the
conversion.  The alternate form is defined differently for different
types.  This option is only valid for integer, float and complex
types. For integers, when binary, octal, or hexadecimal output is
used, this option adds the prefix respective "'0b'", "'0o'", or "'0x'"
to the output value. For float and complex the alternate form causes
the result of the conversion to always contain a decimal-point
character, even if no digits follow it. Normally, a decimal-point
character appears in the result of these conversions only if a digit
follows it. In addition, for "'g'" and "'G'" conversions, trailing
zeros are not removed from the result.

The "','" option signals the use of a comma for a thousands separator.
For a locale aware separator, use the "'n'" integer presentation type
instead.

Changed in version 3.1: Added the "','" option (see also **PEP 378**).

The "'_'" option signals the use of an underscore for a thousands
separator for floating point presentation types and for integer
presentation type "'d'".  For integer presentation types "'b'", "'o'",
"'x'", and "'X'", underscores will be inserted every 4 digits.  For
other presentation types, specifying this option is an error.

Changed in version 3.6: Added the "'_'" option (see also **PEP 515**).

*width* is a decimal integer defining the minimum total field width,
including any prefixes, separators, and other formatting characters.
If not specified, then the field width will be determined by the
content.

When no explicit alignment is given, preceding the *width* field by a
zero ("'0'") character enables sign-aware zero-padding for numeric
types.  This is equivalent to a *fill* character of "'0'" with an
*alignment* type of "'='".

The *precision* is a decimal number indicating how many digits should
be displayed after the decimal point for a floating point value
formatted with "'f'" and "'F'", or before and after the decimal point
for a floating point value formatted with "'g'" or "'G'".  For non-
number types the field indicates the maximum field size - in other
words, how many characters will be used from the field content. The
*precision* is not allowed for integer values.

Finally, the *type* determines how the data should be presented.

The available string presentation types are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'s'"     | String format. This is the default type for strings and    |
   |           | may be omitted.                                            |
   +-----------+------------------------------------------------------------+
   | None      | The same as "'s'".                                         |
   +-----------+------------------------------------------------------------+

The available integer presentation types are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'b'"     | Binary format. Outputs the number in base 2.               |
   +-----------+------------------------------------------------------------+
   | "'c'"     | Character. Converts the integer to the corresponding       |
   |           | unicode character before printing.                         |
   +-----------+------------------------------------------------------------+
   | "'d'"     | Decimal Integer. Outputs the number in base 10.            |
   +-----------+------------------------------------------------------------+
   | "'o'"     | Octal format. Outputs the number in base 8.                |
   +-----------+------------------------------------------------------------+
   | "'x'"     | Hex format. Outputs the number in base 16, using lower-    |
   |           | case letters for the digits above 9.                       |
   +-----------+------------------------------------------------------------+
   | "'X'"     | Hex format. Outputs the number in base 16, using upper-    |
   |           | case letters for the digits above 9.                       |
   +-----------+------------------------------------------------------------+
   | "'n'"     | Number. This is the same as "'d'", except that it uses the |
   |           | current locale setting to insert the appropriate number    |
   |           | separator characters.                                      |
   +-----------+------------------------------------------------------------+
   | None      | The same as "'d'".                                         |
   +-----------+------------------------------------------------------------+

In addition to the above presentation types, integers can be formatted
with the floating point presentation types listed below (except "'n'"
and "None"). When doing so, "float()" is used to convert the integer
to a floating point number before formatting.

The available presentation types for "float" and "Decimal" values are:

   +-----------+------------------------------------------------------------+
   | Type      | Meaning                                                    |
   |===========|============================================================|
   | "'e'"     | Scientific notation. For a given precision "p", formats    |
   |           | the number in scientific notation with the letter ‘e’      |
   |           | separating the coefficient from the exponent. The          |
   |           | coefficient has one digit before and "p" digits after the  |
   |           | decimal point, for a total of "p + 1" significant digits.  |
   |           | With no precision given, uses a precision of "6" digits    |
   |           | after the decimal point for "float", and shows all         |
   |           | coefficient digits for "Decimal". If no digits follow the  |
   |           | decimal point, the decimal point is also removed unless    |
   |           | the "#" option is used.                                    |
   +-----------+------------------------------------------------------------+
   | "'E'"     | Scientific notation. Same as "'e'" except it uses an upper |
   |           | case ‘E’ as the separator character.                       |
   +-----------+------------------------------------------------------------+
   | "'f'"     | Fixed-point notation. For a given precision "p", formats   |
   |           | the number as a decimal number with exactly "p" digits     |
   |           | following the decimal point. With no precision given, uses |
   |           | a precision of "6" digits after the decimal point for      |
   |           | "float", and uses a precision large enough to show all     |
   |           | coefficient digits for "Decimal". If no digits follow the  |
   |           | decimal point, the decimal point is also removed unless    |
   |           | the "#" option is used.                                    |
   +-----------+------------------------------------------------------------+
   | "'F'"     | Fixed-point notation. Same as "'f'", but converts "nan" to |
   |           | "NAN" and "inf" to "INF".                                  |
   +-----------+------------------------------------------------------------+
   | "'g'"     | General format.  For a given precision "p >= 1", this      |
   |           | rounds the number to "p" significant digits and then       |
   |           | formats the result in either fixed-point format or in      |
   |           | scientific notation, depending on its magnitude. A         |
   |           | precision of "0" is treated as equivalent to a precision   |
   |           | of "1".  The precise rules are as follows: suppose that    |
   |           | the result formatted with presentation type "'e'" and      |
   |           | precision "p-1" would have exponent "exp".  Then, if "m <= |
   |           | exp < p", where "m" is -4 for floats and -6 for            |
   |           | "Decimals", the number is formatted with presentation type |
   |           | "'f'" and precision "p-1-exp".  Otherwise, the number is   |
   |           | formatted with presentation type "'e'" and precision       |
   |           | "p-1". In both cases insignificant trailing zeros are      |
   |           | removed from the significand, and the decimal point is     |
   |           | also removed if there are no remaining digits following    |
   |           | it, unless the "'#'" option is used.  With no precision    |
   |           | given, uses a precision of "6" significant digits for      |
   |           | "float". For "Decimal", the coefficient of the result is   |
   |           | formed from the coefficient digits of the value;           |
   |           | scientific notation is used for values smaller than "1e-6" |
   |           | in absolute value and values where the place value of the  |
   |           | least significant digit is larger than 1, and fixed-point  |
   |           | notation is used otherwise.  Positive and negative         |
   |           | infinity, positive and negative zero, and nans, are        |
   |           | formatted as "inf", "-inf", "0", "-0" and "nan"            |
   |           | respectively, regardless of the precision.                 |
   +-----------+------------------------------------------------------------+
   | "'G'"     | General format. Same as "'g'" except switches to "'E'" if  |
   |           | the number gets too large. The representations of infinity |
   |           | and NaN are uppercased, too.                               |
   +-----------+------------------------------------------------------------+
   | "'n'"     | Number. This is the same as "'g'", except that it uses the |
   |           | current locale setting to insert the appropriate number    |
   |           | separator characters.                                      |
   +-----------+------------------------------------------------------------+
   | "'%'"     | Percentage. Multiplies the number by 100 and displays in   |
   |           | fixed ("'f'") format, followed by a percent sign.          |
   +-----------+------------------------------------------------------------+
   | None      | For "float" this is the same as "'g'", except that when    |
   |           | fixed-point notation is used to format the result, it      |
   |           | always includes at least one digit past the decimal point. |
   |           | The precision used is as large as needed to represent the  |
   |           | given value faithfully.  For "Decimal", this is the same   |
   |           | as either "'g'" or "'G'" depending on the value of         |
   |           | "context.capitals" for the current decimal context.  The   |
   |           | overall effect is to match the output of "str()" as        |
   |           | altered by the other format modifiers.                     |
   +-----------+------------------------------------------------------------+


Format examples
===============

This section contains examples of the "str.format()" syntax and
comparison with the old "%"-formatting.

In most of the cases the syntax is similar to the old "%"-formatting,
with the addition of the "{}" and with ":" used instead of "%". For
example, "'%03.2f'" can be translated to "'{:03.2f}'".

The new format syntax also supports new and different options, shown
in the following examples.

Accessing arguments by position:

   >>> '{0}, {1}, {2}'.format('a', 'b', 'c')
   'a, b, c'
   >>> '{}, {}, {}'.format('a', 'b', 'c')  # 3.1+ only
   'a, b, c'
   >>> '{2}, {1}, {0}'.format('a', 'b', 'c')
   'c, b, a'
   >>> '{2}, {1}, {0}'.format(*'abc')      # unpacking argument sequence
   'c, b, a'
   >>> '{0}{1}{0}'.format('abra', 'cad')   # arguments' indices can be repeated
   'abracadabra'

Accessing arguments by name:

   >>> 'Coordinates: {latitude}, {longitude}'.format(latitude='37.24N', longitude='-115.81W')
   'Coordinates: 37.24N, -115.81W'
   >>> coord = {'latitude': '37.24N', 'longitude': '-115.81W'}
   >>> 'Coordinates: {latitude}, {longitude}'.format(**coord)
   'Coordinates: 37.24N, -115.81W'

Accessing arguments’ attributes:

   >>> c = 3-5j
   >>> ('The complex number {0} is formed from the real part {0.real} '
   ...  'and the imaginary part {0.imag}.').format(c)
   'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.'
   >>> class Point:
   ...     def __init__(self, x, y):
   ...         self.x, self.y = x, y
   ...     def __str__(self):
   ...         return 'Point({self.x}, {self.y})'.format(self=self)
   ...
   >>> str(Point(4, 2))
   'Point(4, 2)'

Accessing arguments’ items:

   >>> coord = (3, 5)
   >>> 'X: {0[0]};  Y: {0[1]}'.format(coord)
   'X: 3;  Y: 5'

Replacing "%s" and "%r":

   >>> "repr() shows quotes: {!r}; str() doesn't: {!s}".format('test1', 'test2')
   "repr() shows quotes: 'test1'; str() doesn't: test2"

Aligning the text and specifying a width:

   >>> '{:<30}'.format('left aligned')
   'left aligned                  '
   >>> '{:>30}'.format('right aligned')
   '                 right aligned'
   >>> '{:^30}'.format('centered')
   '           centered           '
   >>> '{:*^30}'.format('centered')  # use '*' as a fill char
   '***********centered***********'

Replacing "%+f", "%-f", and "% f" and specifying a sign:

   >>> '{:+f}; {:+f}'.format(3.14, -3.14)  # show it always
   '+3.140000; -3.140000'
   >>> '{: f}; {: f}'.format(3.14, -3.14)  # show a space for positive numbers
   ' 3.140000; -3.140000'
   >>> '{:-f}; {:-f}'.format(3.14, -3.14)  # show only the minus -- same as '{:f}; {:f}'
   '3.140000; -3.140000'

Replacing "%x" and "%o" and converting the value to different bases:

   >>> # format also supports binary numbers
   >>> "int: {0:d};  hex: {0:x};  oct: {0:o};  bin: {0:b}".format(42)
   'int: 42;  hex: 2a;  oct: 52;  bin: 101010'
   >>> # with 0x, 0o, or 0b as prefix:
   >>> "int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}".format(42)
   'int: 42;  hex: 0x2a;  oct: 0o52;  bin: 0b101010'

Using the comma as a thousands separator:

   >>> '{:,}'.format(1234567890)
   '1,234,567,890'

Expressing a percentage:

   >>> points = 19
   >>> total = 22
   >>> 'Correct answers: {:.2%}'.format(points/total)
   'Correct answers: 86.36%'

Using type-specific formatting:

   >>> import datetime
   >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
   >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
   '2010-07-04 12:15:58'

Nesting arguments and more complex examples:

   >>> for align, text in zip('<^>', ['left', 'center', 'right']):
   ...     '{0:{fill}{align}16}'.format(text, fill=align, align=align)
   ...
   'left<<<<<<<<<<<<'
   '^^^^^center^^^^^'
   '>>>>>>>>>>>right'
   >>>
   >>> octets = [192, 168, 0, 1]
   >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)
   'C0A80001'
   >>> int(_, 16)
   3232235521
   >>>
   >>> width = 5
   >>> for num in range(5,12): 
   ...     for base in 'dXob':
   ...         print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ')
   ...     print()
   ...
       5     5     5   101
       6     6     6   110
       7     7     7   111
       8     8    10  1000
       9     9    11  1001
      10     A    12  1010
      11     B    13  1011
u|Function definitions
********************

A function definition defines a user-defined function object (see
section The standard type hierarchy):

   funcdef                   ::= [decorators] "def" funcname "(" [parameter_list] ")"
               ["->" expression] ":" suite
   decorators                ::= decorator+
   decorator                 ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
   dotted_name               ::= identifier ("." identifier)*
   parameter_list            ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
                        | parameter_list_no_posonly
   parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
                                 | parameter_list_starargs
   parameter_list_starargs   ::= "*" [parameter] ("," defparameter)* ["," ["**" parameter [","]]]
                               | "**" parameter [","]
   parameter                 ::= identifier [":" expression]
   defparameter              ::= parameter ["=" expression]
   funcname                  ::= identifier

A function definition is an executable statement.  Its execution binds
the function name in the current local namespace to a function object
(a wrapper around the executable code for the function).  This
function object contains a reference to the current global namespace
as the global namespace to be used when the function is called.

The function definition does not execute the function body; this gets
executed only when the function is called. [2]

A function definition may be wrapped by one or more *decorator*
expressions. Decorator expressions are evaluated when the function is
defined, in the scope that contains the function definition.  The
result must be a callable, which is invoked with the function object
as the only argument. The returned value is bound to the function name
instead of the function object.  Multiple decorators are applied in
nested fashion. For example, the following code

   @f1(arg)
   @f2
   def func(): pass

is roughly equivalent to

   def func(): pass
   func = f1(arg)(f2(func))

except that the original function is not temporarily bound to the name
"func".

When one or more *parameters* have the form *parameter* "="
*expression*, the function is said to have “default parameter values.”
For a parameter with a default value, the corresponding *argument* may
be omitted from a call, in which case the parameter’s default value is
substituted.  If a parameter has a default value, all following
parameters up until the “"*"” must also have a default value — this is
a syntactic restriction that is not expressed by the grammar.

**Default parameter values are evaluated from left to right when the
function definition is executed.** This means that the expression is
evaluated once, when the function is defined, and that the same “pre-
computed” value is used for each call.  This is especially important
to understand when a default parameter is a mutable object, such as a
list or a dictionary: if the function modifies the object (e.g. by
appending an item to a list), the default value is in effect modified.
This is generally not what was intended.  A way around this is to use
"None" as the default, and explicitly test for it in the body of the
function, e.g.:

   def whats_on_the_telly(penguin=None):
       if penguin is None:
           penguin = []
       penguin.append("property of the zoo")
       return penguin

Function call semantics are described in more detail in section Calls.
A function call always assigns values to all parameters mentioned in
the parameter list, either from positional arguments, from keyword
arguments, or from default values.  If the form “"*identifier"” is
present, it is initialized to a tuple receiving any excess positional
parameters, defaulting to the empty tuple. If the form
“"**identifier"” is present, it is initialized to a new ordered
mapping receiving any excess keyword arguments, defaulting to a new
empty mapping of the same type.  Parameters after “"*"” or
“"*identifier"” are keyword-only parameters and may only be passed by
keyword arguments.  Parameters before “"/"” are positional-only
parameters and may only be passed by positional arguments.

Changed in version 3.8: The "/" function parameter syntax may be used
to indicate positional-only parameters. See **PEP 570** for details.

Parameters may have an *annotation* of the form “": expression"”
following the parameter name.  Any parameter may have an annotation,
even those of the form "*identifier" or "**identifier".  Functions may
have “return” annotation of the form “"-> expression"” after the
parameter list.  These annotations can be any valid Python expression.
The presence of annotations does not change the semantics of a
function.  The annotation values are available as values of a
dictionary keyed by the parameters’ names in the "__annotations__"
attribute of the function object.  If the "annotations" import from
"__future__" is used, annotations are preserved as strings at runtime
which enables postponed evaluation.  Otherwise, they are evaluated
when the function definition is executed.  In this case annotations
may be evaluated in a different order than they appear in the source
code.

It is also possible to create anonymous functions (functions not bound
to a name), for immediate use in expressions.  This uses lambda
expressions, described in section Lambdas.  Note that the lambda
expression is merely a shorthand for a simplified function definition;
a function defined in a “"def"” statement can be passed around or
assigned to another name just like a function defined by a lambda
expression.  The “"def"” form is actually more powerful since it
allows the execution of multiple statements and annotations.

**Programmer’s note:** Functions are first-class objects.  A “"def"”
statement executed inside a function definition defines a local
function that can be returned or passed around.  Free variables used
in the nested function can access the local variables of the function
containing the def.  See section Naming and binding for details.

See also:

  **PEP 3107** - Function Annotations
     The original specification for function annotations.

  **PEP 484** - Type Hints
     Definition of a standard meaning for annotations: type hints.

  **PEP 526** - Syntax for Variable Annotations
     Ability to type hint variable declarations, including class
     variables and instance variables

  **PEP 563** - Postponed Evaluation of Annotations
     Support for forward references within annotations by preserving
     annotations in a string form at runtime instead of eager
     evaluation.
u�The "global" statement
**********************

   global_stmt ::= "global" identifier ("," identifier)*

The "global" statement is a declaration which holds for the entire
current code block.  It means that the listed identifiers are to be
interpreted as globals.  It would be impossible to assign to a global
variable without "global", although free variables may refer to
globals without being declared global.

Names listed in a "global" statement must not be used in the same code
block textually preceding that "global" statement.

Names listed in a "global" statement must not be defined as formal
parameters or in a "for" loop control target, "class" definition,
function definition, "import" statement, or variable annotation.

**CPython implementation detail:** The current implementation does not
enforce some of these restrictions, but programs should not abuse this
freedom, as future implementations may enforce them or silently change
the meaning of the program.

**Programmer’s note:** "global" is a directive to the parser.  It
applies only to code parsed at the same time as the "global"
statement. In particular, a "global" statement contained in a string
or code object supplied to the built-in "exec()" function does not
affect the code block *containing* the function call, and code
contained in such a string is unaffected by "global" statements in the
code containing the function call.  The same applies to the "eval()"
and "compile()" functions.
u�Reserved classes of identifiers
*******************************

Certain classes of identifiers (besides keywords) have special
meanings.  These classes are identified by the patterns of leading and
trailing underscore characters:

"_*"
   Not imported by "from module import *".  The special identifier "_"
   is used in the interactive interpreter to store the result of the
   last evaluation; it is stored in the "builtins" module.  When not
   in interactive mode, "_" has no special meaning and is not defined.
   See section The import statement.

   Note:

     The name "_" is often used in conjunction with
     internationalization; refer to the documentation for the
     "gettext" module for more information on this convention.

"__*__"
   System-defined names, informally known as “dunder” names. These
   names are defined by the interpreter and its implementation
   (including the standard library). Current system names are
   discussed in the Special method names section and elsewhere. More
   will likely be defined in future versions of Python.  *Any* use of
   "__*__" names, in any context, that does not follow explicitly
   documented use, is subject to breakage without warning.

"__*"
   Class-private names.  Names in this category, when used within the
   context of a class definition, are re-written to use a mangled form
   to help avoid name clashes between “private” attributes of base and
   derived classes. See section Identifiers (Names).
umIdentifiers and keywords
************************

Identifiers (also referred to as *names*) are described by the
following lexical definitions.

The syntax of identifiers in Python is based on the Unicode standard
annex UAX-31, with elaboration and changes as defined below; see also
**PEP 3131** for further details.

Within the ASCII range (U+0001..U+007F), the valid characters for
identifiers are the same as in Python 2.x: the uppercase and lowercase
letters "A" through "Z", the underscore "_" and, except for the first
character, the digits "0" through "9".

Python 3.0 introduces additional characters from outside the ASCII
range (see **PEP 3131**).  For these characters, the classification
uses the version of the Unicode Character Database as included in the
"unicodedata" module.

Identifiers are unlimited in length.  Case is significant.

   identifier   ::= xid_start xid_continue*
   id_start     ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
   id_continue  ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
   xid_start    ::= <all characters in id_start whose NFKC normalization is in "id_start xid_continue*">
   xid_continue ::= <all characters in id_continue whose NFKC normalization is in "id_continue*">

The Unicode category codes mentioned above stand for:

* *Lu* - uppercase letters

* *Ll* - lowercase letters

* *Lt* - titlecase letters

* *Lm* - modifier letters

* *Lo* - other letters

* *Nl* - letter numbers

* *Mn* - nonspacing marks

* *Mc* - spacing combining marks

* *Nd* - decimal numbers

* *Pc* - connector punctuations

* *Other_ID_Start* - explicit list of characters in PropList.txt to
  support backwards compatibility

* *Other_ID_Continue* - likewise

All identifiers are converted into the normal form NFKC while parsing;
comparison of identifiers is based on NFKC.

A non-normative HTML file listing all valid identifier characters for
Unicode 4.1 can be found at
https://www.unicode.org/Public/13.0.0/ucd/DerivedCoreProperties.txt


Keywords
========

The following identifiers are used as reserved words, or *keywords* of
the language, and cannot be used as ordinary identifiers.  They must
be spelled exactly as written here:

   False      await      else       import     pass
   None       break      except     in         raise
   True       class      finally    is         return
   and        continue   for        lambda     try
   as         def        from       nonlocal   while
   assert     del        global     not        with
   async      elif       if         or         yield


Reserved classes of identifiers
===============================

Certain classes of identifiers (besides keywords) have special
meanings.  These classes are identified by the patterns of leading and
trailing underscore characters:

"_*"
   Not imported by "from module import *".  The special identifier "_"
   is used in the interactive interpreter to store the result of the
   last evaluation; it is stored in the "builtins" module.  When not
   in interactive mode, "_" has no special meaning and is not defined.
   See section The import statement.

   Note:

     The name "_" is often used in conjunction with
     internationalization; refer to the documentation for the
     "gettext" module for more information on this convention.

"__*__"
   System-defined names, informally known as “dunder” names. These
   names are defined by the interpreter and its implementation
   (including the standard library). Current system names are
   discussed in the Special method names section and elsewhere. More
   will likely be defined in future versions of Python.  *Any* use of
   "__*__" names, in any context, that does not follow explicitly
   documented use, is subject to breakage without warning.

"__*"
   Class-private names.  Names in this category, when used within the
   context of a class definition, are re-written to use a mangled form
   to help avoid name clashes between “private” attributes of base and
   derived classes. See section Identifiers (Names).
a5Imaginary literals
******************

Imaginary literals are described by the following lexical definitions:

   imagnumber ::= (floatnumber | digitpart) ("j" | "J")

An imaginary literal yields a complex number with a real part of 0.0.
Complex numbers are represented as a pair of floating point numbers
and have the same restrictions on their range.  To create a complex
number with a nonzero real part, add a floating point number to it,
e.g., "(3+4j)".  Some examples of imaginary literals:

   3.14j   10.j    10j     .001j   1e100j   3.14e-10j   3.14_15_93j
u8"The "import" statement
**********************

   import_stmt     ::= "import" module ["as" identifier] ("," module ["as" identifier])*
                   | "from" relative_module "import" identifier ["as" identifier]
                   ("," identifier ["as" identifier])*
                   | "from" relative_module "import" "(" identifier ["as" identifier]
                   ("," identifier ["as" identifier])* [","] ")"
                   | "from" module "import" "*"
   module          ::= (identifier ".")* identifier
   relative_module ::= "."* module | "."+

The basic import statement (no "from" clause) is executed in two
steps:

1. find a module, loading and initializing it if necessary

2. define a name or names in the local namespace for the scope where
   the "import" statement occurs.

When the statement contains multiple clauses (separated by commas) the
two steps are carried out separately for each clause, just as though
the clauses had been separated out into individual import statements.

The details of the first step, finding and loading modules are
described in greater detail in the section on the import system, which
also describes the various types of packages and modules that can be
imported, as well as all the hooks that can be used to customize the
import system. Note that failures in this step may indicate either
that the module could not be located, *or* that an error occurred
while initializing the module, which includes execution of the
module’s code.

If the requested module is retrieved successfully, it will be made
available in the local namespace in one of three ways:

* If the module name is followed by "as", then the name following "as"
  is bound directly to the imported module.

* If no other name is specified, and the module being imported is a
  top level module, the module’s name is bound in the local namespace
  as a reference to the imported module

* If the module being imported is *not* a top level module, then the
  name of the top level package that contains the module is bound in
  the local namespace as a reference to the top level package. The
  imported module must be accessed using its full qualified name
  rather than directly

The "from" form uses a slightly more complex process:

1. find the module specified in the "from" clause, loading and
   initializing it if necessary;

2. for each of the identifiers specified in the "import" clauses:

   1. check if the imported module has an attribute by that name

   2. if not, attempt to import a submodule with that name and then
      check the imported module again for that attribute

   3. if the attribute is not found, "ImportError" is raised.

   4. otherwise, a reference to that value is stored in the local
      namespace, using the name in the "as" clause if it is present,
      otherwise using the attribute name

Examples:

   import foo                 # foo imported and bound locally
   import foo.bar.baz         # foo.bar.baz imported, foo bound locally
   import foo.bar.baz as fbb  # foo.bar.baz imported and bound as fbb
   from foo.bar import baz    # foo.bar.baz imported and bound as baz
   from foo import attr       # foo imported and foo.attr bound as attr

If the list of identifiers is replaced by a star ("'*'"), all public
names defined in the module are bound in the local namespace for the
scope where the "import" statement occurs.

The *public names* defined by a module are determined by checking the
module’s namespace for a variable named "__all__"; if defined, it must
be a sequence of strings which are names defined or imported by that
module.  The names given in "__all__" are all considered public and
are required to exist.  If "__all__" is not defined, the set of public
names includes all names found in the module’s namespace which do not
begin with an underscore character ("'_'").  "__all__" should contain
the entire public API. It is intended to avoid accidentally exporting
items that are not part of the API (such as library modules which were
imported and used within the module).

The wild card form of import — "from module import *" — is only
allowed at the module level.  Attempting to use it in class or
function definitions will raise a "SyntaxError".

When specifying what module to import you do not have to specify the
absolute name of the module. When a module or package is contained
within another package it is possible to make a relative import within
the same top package without having to mention the package name. By
using leading dots in the specified module or package after "from" you
can specify how high to traverse up the current package hierarchy
without specifying exact names. One leading dot means the current
package where the module making the import exists. Two dots means up
one package level. Three dots is up two levels, etc. So if you execute
"from . import mod" from a module in the "pkg" package then you will
end up importing "pkg.mod". If you execute "from ..subpkg2 import mod"
from within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The
specification for relative imports is contained in the Package
Relative Imports section.

"importlib.import_module()" is provided to support applications that
determine dynamically the modules to be loaded.

Raises an auditing event "import" with arguments "module", "filename",
"sys.path", "sys.meta_path", "sys.path_hooks".


Future statements
=================

A *future statement* is a directive to the compiler that a particular
module should be compiled using syntax or semantics that will be
available in a specified future release of Python where the feature
becomes standard.

The future statement is intended to ease migration to future versions
of Python that introduce incompatible changes to the language.  It
allows use of the new features on a per-module basis before the
release in which the feature becomes standard.

   future_stmt ::= "from" "__future__" "import" feature ["as" identifier]
                   ("," feature ["as" identifier])*
                   | "from" "__future__" "import" "(" feature ["as" identifier]
                   ("," feature ["as" identifier])* [","] ")"
   feature     ::= identifier

A future statement must appear near the top of the module.  The only
lines that can appear before a future statement are:

* the module docstring (if any),

* comments,

* blank lines, and

* other future statements.

The only feature that requires using the future statement is
"annotations" (see **PEP 563**).

All historical features enabled by the future statement are still
recognized by Python 3.  The list includes "absolute_import",
"division", "generators", "generator_stop", "unicode_literals",
"print_function", "nested_scopes" and "with_statement".  They are all
redundant because they are always enabled, and only kept for backwards
compatibility.

A future statement is recognized and treated specially at compile
time: Changes to the semantics of core constructs are often
implemented by generating different code.  It may even be the case
that a new feature introduces new incompatible syntax (such as a new
reserved word), in which case the compiler may need to parse the
module differently.  Such decisions cannot be pushed off until
runtime.

For any given release, the compiler knows which feature names have
been defined, and raises a compile-time error if a future statement
contains a feature not known to it.

The direct runtime semantics are the same as for any import statement:
there is a standard module "__future__", described later, and it will
be imported in the usual way at the time the future statement is
executed.

The interesting runtime semantics depend on the specific feature
enabled by the future statement.

Note that there is nothing special about the statement:

   import __future__ [as name]

That is not a future statement; it’s an ordinary import statement with
no special semantics or syntax restrictions.

Code compiled by calls to the built-in functions "exec()" and
"compile()" that occur in a module "M" containing a future statement
will, by default, use the new syntax or semantics associated with the
future statement.  This can be controlled by optional arguments to
"compile()" — see the documentation of that function for details.

A future statement typed at an interactive interpreter prompt will
take effect for the rest of the interpreter session.  If an
interpreter is started with the "-i" option, is passed a script name
to execute, and the script includes a future statement, it will be in
effect in the interactive session started after the script is
executed.

See also:

  **PEP 236** - Back to the __future__
     The original proposal for the __future__ mechanism.
aMembership test operations
**************************

The operators "in" and "not in" test for membership.  "x in s"
evaluates to "True" if *x* is a member of *s*, and "False" otherwise.
"x not in s" returns the negation of "x in s".  All built-in sequences
and set types support this as well as dictionary, for which "in" tests
whether the dictionary has a given key. For container types such as
list, tuple, set, frozenset, dict, or collections.deque, the
expression "x in y" is equivalent to "any(x is e or x == e for e in
y)".

For the string and bytes types, "x in y" is "True" if and only if *x*
is a substring of *y*.  An equivalent test is "y.find(x) != -1".
Empty strings are always considered to be a substring of any other
string, so """ in "abc"" will return "True".

For user-defined classes which define the "__contains__()" method, "x
in y" returns "True" if "y.__contains__(x)" returns a true value, and
"False" otherwise.

For user-defined classes which do not define "__contains__()" but do
define "__iter__()", "x in y" is "True" if some value "z", for which
the expression "x is z or x == z" is true, is produced while iterating
over "y". If an exception is raised during the iteration, it is as if
"in" raised that exception.

Lastly, the old-style iteration protocol is tried: if a class defines
"__getitem__()", "x in y" is "True" if and only if there is a non-
negative integer index *i* such that "x is y[i] or x == y[i]", and no
lower integer index raises the "IndexError" exception.  (If any other
exception is raised, it is as if "in" raised that exception).

The operator "not in" is defined to have the inverse truth value of
"in".
aVInteger literals
****************

Integer literals are described by the following lexical definitions:

   integer      ::= decinteger | bininteger | octinteger | hexinteger
   decinteger   ::= nonzerodigit (["_"] digit)* | "0"+ (["_"] "0")*
   bininteger   ::= "0" ("b" | "B") (["_"] bindigit)+
   octinteger   ::= "0" ("o" | "O") (["_"] octdigit)+
   hexinteger   ::= "0" ("x" | "X") (["_"] hexdigit)+
   nonzerodigit ::= "1"..."9"
   digit        ::= "0"..."9"
   bindigit     ::= "0" | "1"
   octdigit     ::= "0"..."7"
   hexdigit     ::= digit | "a"..."f" | "A"..."F"

There is no limit for the length of integer literals apart from what
can be stored in available memory.

Underscores are ignored for determining the numeric value of the
literal.  They can be used to group digits for enhanced readability.
One underscore can occur between digits, and after base specifiers
like "0x".

Note that leading zeros in a non-zero decimal number are not allowed.
This is for disambiguation with C-style octal literals, which Python
used before version 3.0.

Some examples of integer literals:

   7     2147483647                        0o177    0b100110111
   3     79228162514264337593543950336     0o377    0xdeadbeef
         100_000_000_000                   0b_1110_0101

Changed in version 3.6: Underscores are now allowed for grouping
purposes in literals.
a^Lambdas
*******

   lambda_expr        ::= "lambda" [parameter_list] ":" expression
   lambda_expr_nocond ::= "lambda" [parameter_list] ":" expression_nocond

Lambda expressions (sometimes called lambda forms) are used to create
anonymous functions. The expression "lambda parameters: expression"
yields a function object.  The unnamed object behaves like a function
object defined with:

   def <lambda>(parameters):
       return expression

See section Function definitions for the syntax of parameter lists.
Note that functions created with lambda expressions cannot contain
statements or annotations.
a/List displays
*************

A list display is a possibly empty series of expressions enclosed in
square brackets:

   list_display ::= "[" [starred_list | comprehension] "]"

A list display yields a new list object, the contents being specified
by either a list of expressions or a comprehension.  When a comma-
separated list of expressions is supplied, its elements are evaluated
from left to right and placed into the list object in that order.
When a comprehension is supplied, the list is constructed from the
elements resulting from the comprehension.
u�Naming and binding
******************


Binding of names
================

*Names* refer to objects.  Names are introduced by name binding
operations.

The following constructs bind names: formal parameters to functions,
"import" statements, class and function definitions (these bind the
class or function name in the defining block), and targets that are
identifiers if occurring in an assignment, "for" loop header, or after
"as" in a "with" statement or "except" clause. The "import" statement
of the form "from ... import *" binds all names defined in the
imported module, except those beginning with an underscore.  This form
may only be used at the module level.

A target occurring in a "del" statement is also considered bound for
this purpose (though the actual semantics are to unbind the name).

Each assignment or import statement occurs within a block defined by a
class or function definition or at the module level (the top-level
code block).

If a name is bound in a block, it is a local variable of that block,
unless declared as "nonlocal" or "global".  If a name is bound at the
module level, it is a global variable.  (The variables of the module
code block are local and global.)  If a variable is used in a code
block but not defined there, it is a *free variable*.

Each occurrence of a name in the program text refers to the *binding*
of that name established by the following name resolution rules.


Resolution of names
===================

A *scope* defines the visibility of a name within a block.  If a local
variable is defined in a block, its scope includes that block.  If the
definition occurs in a function block, the scope extends to any blocks
contained within the defining one, unless a contained block introduces
a different binding for the name.

When a name is used in a code block, it is resolved using the nearest
enclosing scope.  The set of all such scopes visible to a code block
is called the block’s *environment*.

When a name is not found at all, a "NameError" exception is raised. If
the current scope is a function scope, and the name refers to a local
variable that has not yet been bound to a value at the point where the
name is used, an "UnboundLocalError" exception is raised.
"UnboundLocalError" is a subclass of "NameError".

If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block.  This can lead to errors when a name is used within a
block before it is bound.  This rule is subtle.  Python lacks
declarations and allows name binding operations to occur anywhere
within a code block.  The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.

If the "global" statement occurs within a block, all uses of the name
specified in the statement refer to the binding of that name in the
top-level namespace.  Names are resolved in the top-level namespace by
searching the global namespace, i.e. the namespace of the module
containing the code block, and the builtins namespace, the namespace
of the module "builtins".  The global namespace is searched first.  If
the name is not found there, the builtins namespace is searched.  The
"global" statement must precede all uses of the name.

The "global" statement has the same scope as a name binding operation
in the same block.  If the nearest enclosing scope for a free variable
contains a global statement, the free variable is treated as a global.

The "nonlocal" statement causes corresponding names to refer to
previously bound variables in the nearest enclosing function scope.
"SyntaxError" is raised at compile time if the given name does not
exist in any enclosing function scope.

The namespace for a module is automatically created the first time a
module is imported.  The main module for a script is always called
"__main__".

Class definition blocks and arguments to "exec()" and "eval()" are
special in the context of name resolution. A class definition is an
executable statement that may use and define names. These references
follow the normal rules for name resolution with an exception that
unbound local variables are looked up in the global namespace. The
namespace of the class definition becomes the attribute dictionary of
the class. The scope of names defined in a class block is limited to
the class block; it does not extend to the code blocks of methods –
this includes comprehensions and generator expressions since they are
implemented using a function scope.  This means that the following
will fail:

   class A:
       a = 42
       b = list(a + i for i in range(10))


Builtins and restricted execution
=================================

**CPython implementation detail:** Users should not touch
"__builtins__"; it is strictly an implementation detail.  Users
wanting to override values in the builtins namespace should "import"
the "builtins" module and modify its attributes appropriately.

The builtins namespace associated with the execution of a code block
is actually found by looking up the name "__builtins__" in its global
namespace; this should be a dictionary or a module (in the latter case
the module’s dictionary is used).  By default, when in the "__main__"
module, "__builtins__" is the built-in module "builtins"; when in any
other module, "__builtins__" is an alias for the dictionary of the
"builtins" module itself.


Interaction with dynamic features
=================================

Name resolution of free variables occurs at runtime, not at compile
time. This means that the following code will print 42:

   i = 10
   def f():
       print(i)
   i = 42
   f()

The "eval()" and "exec()" functions do not have access to the full
environment for resolving names.  Names may be resolved in the local
and global namespaces of the caller.  Free variables are not resolved
in the nearest enclosing namespace, but in the global namespace.  [1]
The "exec()" and "eval()" functions have optional arguments to
override the global and local namespace.  If only one namespace is
specified, it is used for both.
a�The "nonlocal" statement
************************

   nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*

The "nonlocal" statement causes the listed identifiers to refer to
previously bound variables in the nearest enclosing scope excluding
globals. This is important because the default behavior for binding is
to search the local namespace first.  The statement allows
encapsulated code to rebind variables outside of the local scope
besides the global (module) scope.

Names listed in a "nonlocal" statement, unlike those listed in a
"global" statement, must refer to pre-existing bindings in an
enclosing scope (the scope in which a new binding should be created
cannot be determined unambiguously).

Names listed in a "nonlocal" statement must not collide with pre-
existing bindings in the local scope.

See also:

  **PEP 3104** - Access to Names in Outer Scopes
     The specification for the "nonlocal" statement.
u�Numeric literals
****************

There are three types of numeric literals: integers, floating point
numbers, and imaginary numbers.  There are no complex literals
(complex numbers can be formed by adding a real number and an
imaginary number).

Note that numeric literals do not include a sign; a phrase like "-1"
is actually an expression composed of the unary operator ‘"-"’ and the
literal "1".
uEmulating numeric types
***********************

The following methods can be defined to emulate numeric objects.
Methods corresponding to operations that are not supported by the
particular kind of number implemented (e.g., bitwise operations for
non-integral numbers) should be left undefined.

object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
object.__matmul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
object.__divmod__(self, other)
object.__pow__(self, other[, modulo])
object.__lshift__(self, other)
object.__rshift__(self, other)
object.__and__(self, other)
object.__xor__(self, other)
object.__or__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|").  For instance, to
   evaluate the expression "x + y", where *x* is an instance of a
   class that has an "__add__()" method, "x.__add__(y)" is called.
   The "__divmod__()" method should be the equivalent to using
   "__floordiv__()" and "__mod__()"; it should not be related to
   "__truediv__()".  Note that "__pow__()" should be defined to accept
   an optional third argument if the ternary version of the built-in
   "pow()" function is to be supported.

   If one of those methods does not support the operation with the
   supplied arguments, it should return "NotImplemented".

object.__radd__(self, other)
object.__rsub__(self, other)
object.__rmul__(self, other)
object.__rmatmul__(self, other)
object.__rtruediv__(self, other)
object.__rfloordiv__(self, other)
object.__rmod__(self, other)
object.__rdivmod__(self, other)
object.__rpow__(self, other[, modulo])
object.__rlshift__(self, other)
object.__rrshift__(self, other)
object.__rand__(self, other)
object.__rxor__(self, other)
object.__ror__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)
   operands.  These functions are only called if the left operand does
   not support the corresponding operation [3] and the operands are of
   different types. [4] For instance, to evaluate the expression "x -
   y", where *y* is an instance of a class that has an "__rsub__()"
   method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns
   *NotImplemented*.

   Note that ternary "pow()" will not try calling "__rpow__()" (the
   coercion rules would become too complicated).

   Note:

     If the right operand’s type is a subclass of the left operand’s
     type and that subclass provides a different implementation of the
     reflected method for the operation, this method will be called
     before the left operand’s non-reflected method. This behavior
     allows subclasses to override their ancestors’ operations.

object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
object.__imatmul__(self, other)
object.__itruediv__(self, other)
object.__ifloordiv__(self, other)
object.__imod__(self, other)
object.__ipow__(self, other[, modulo])
object.__ilshift__(self, other)
object.__irshift__(self, other)
object.__iand__(self, other)
object.__ixor__(self, other)
object.__ior__(self, other)

   These methods are called to implement the augmented arithmetic
   assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",
   "<<=", ">>=", "&=", "^=", "|=").  These methods should attempt to
   do the operation in-place (modifying *self*) and return the result
   (which could be, but does not have to be, *self*).  If a specific
   method is not defined, the augmented assignment falls back to the
   normal methods.  For instance, if *x* is an instance of a class
   with an "__iadd__()" method, "x += y" is equivalent to "x =
   x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are
   considered, as with the evaluation of "x + y". In certain
   situations, augmented assignment can result in unexpected errors
   (see Why does a_tuple[i] += [‘item’] raise an exception when the
   addition works?), but this behavior is in fact part of the data
   model.

   Note:

     Due to a bug in the dispatching mechanism for "**=", a class that
     defines "__ipow__()" but returns "NotImplemented" would fail to
     fall back to "x.__pow__(y)" and "y.__rpow__(x)". This bug is
     fixed in Python 3.10.

object.__neg__(self)
object.__pos__(self)
object.__abs__(self)
object.__invert__(self)

   Called to implement the unary arithmetic operations ("-", "+",
   "abs()" and "~").

object.__complex__(self)
object.__int__(self)
object.__float__(self)

   Called to implement the built-in functions "complex()", "int()" and
   "float()".  Should return a value of the appropriate type.

object.__index__(self)

   Called to implement "operator.index()", and whenever Python needs
   to losslessly convert the numeric object to an integer object (such
   as in slicing, or in the built-in "bin()", "hex()" and "oct()"
   functions). Presence of this method indicates that the numeric
   object is an integer type.  Must return an integer.

   If "__int__()", "__float__()" and "__complex__()" are not defined
   then corresponding built-in functions "int()", "float()" and
   "complex()" fall back to "__index__()".

object.__round__(self[, ndigits])
object.__trunc__(self)
object.__floor__(self)
object.__ceil__(self)

   Called to implement the built-in function "round()" and "math"
   functions "trunc()", "floor()" and "ceil()". Unless *ndigits* is
   passed to "__round__()" all these methods should return the value
   of the object truncated to an "Integral" (typically an "int").

   The built-in function "int()" falls back to "__trunc__()" if
   neither "__int__()" nor "__index__()" is defined.
uObjects, values and types
*************************

*Objects* are Python’s abstraction for data.  All data in a Python
program is represented by objects or by relations between objects. (In
a sense, and in conformance to Von Neumann’s model of a “stored
program computer”, code is also represented by objects.)

Every object has an identity, a type and a value.  An object’s
*identity* never changes once it has been created; you may think of it
as the object’s address in memory.  The ‘"is"’ operator compares the
identity of two objects; the "id()" function returns an integer
representing its identity.

**CPython implementation detail:** For CPython, "id(x)" is the memory
address where "x" is stored.

An object’s type determines the operations that the object supports
(e.g., “does it have a length?”) and also defines the possible values
for objects of that type.  The "type()" function returns an object’s
type (which is an object itself).  Like its identity, an object’s
*type* is also unchangeable. [1]

The *value* of some objects can change.  Objects whose value can
change are said to be *mutable*; objects whose value is unchangeable
once they are created are called *immutable*. (The value of an
immutable container object that contains a reference to a mutable
object can change when the latter’s value is changed; however the
container is still considered immutable, because the collection of
objects it contains cannot be changed.  So, immutability is not
strictly the same as having an unchangeable value, it is more subtle.)
An object’s mutability is determined by its type; for instance,
numbers, strings and tuples are immutable, while dictionaries and
lists are mutable.

Objects are never explicitly destroyed; however, when they become
unreachable they may be garbage-collected.  An implementation is
allowed to postpone garbage collection or omit it altogether — it is a
matter of implementation quality how garbage collection is
implemented, as long as no objects are collected that are still
reachable.

**CPython implementation detail:** CPython currently uses a reference-
counting scheme with (optional) delayed detection of cyclically linked
garbage, which collects most objects as soon as they become
unreachable, but is not guaranteed to collect garbage containing
circular references.  See the documentation of the "gc" module for
information on controlling the collection of cyclic garbage. Other
implementations act differently and CPython may change. Do not depend
on immediate finalization of objects when they become unreachable (so
you should always close files explicitly).

Note that the use of the implementation’s tracing or debugging
facilities may keep objects alive that would normally be collectable.
Also note that catching an exception with a ‘"try"…"except"’ statement
may keep objects alive.

Some objects contain references to “external” resources such as open
files or windows.  It is understood that these resources are freed
when the object is garbage-collected, but since garbage collection is
not guaranteed to happen, such objects also provide an explicit way to
release the external resource, usually a "close()" method. Programs
are strongly recommended to explicitly close such objects.  The
‘"try"…"finally"’ statement and the ‘"with"’ statement provide
convenient ways to do this.

Some objects contain references to other objects; these are called
*containers*. Examples of containers are tuples, lists and
dictionaries.  The references are part of a container’s value.  In
most cases, when we talk about the value of a container, we imply the
values, not the identities of the contained objects; however, when we
talk about the mutability of a container, only the identities of the
immediately contained objects are implied.  So, if an immutable
container (like a tuple) contains a reference to a mutable object, its
value changes if that mutable object is changed.

Types affect almost all aspects of object behavior.  Even the
importance of object identity is affected in some sense: for immutable
types, operations that compute new values may actually return a
reference to any existing object with the same type and value, while
for mutable objects this is not allowed.  E.g., after "a = 1; b = 1",
"a" and "b" may or may not refer to the same object with the value
one, depending on the implementation, but after "c = []; d = []", "c"
and "d" are guaranteed to refer to two different, unique, newly
created empty lists. (Note that "c = d = []" assigns the same object
to both "c" and "d".)
u�Operator precedence
*******************

The following table summarizes the operator precedence in Python, from
lowest precedence (least binding) to highest precedence (most
binding).  Operators in the same box have the same precedence.  Unless
the syntax is explicitly given, operators are binary.  Operators in
the same box group left to right (except for exponentiation, which
groups from right to left).

Note that comparisons, membership tests, and identity tests, all have
the same precedence and have a left-to-right chaining feature as
described in the Comparisons section.

+-------------------------------------------------+---------------------------------------+
| Operator                                        | Description                           |
|=================================================|=======================================|
| ":="                                            | Assignment expression                 |
+-------------------------------------------------+---------------------------------------+
| "lambda"                                        | Lambda expression                     |
+-------------------------------------------------+---------------------------------------+
| "if" – "else"                                   | Conditional expression                |
+-------------------------------------------------+---------------------------------------+
| "or"                                            | Boolean OR                            |
+-------------------------------------------------+---------------------------------------+
| "and"                                           | Boolean AND                           |
+-------------------------------------------------+---------------------------------------+
| "not" "x"                                       | Boolean NOT                           |
+-------------------------------------------------+---------------------------------------+
| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership     |
| ">=", "!=", "=="                                | tests and identity tests              |
+-------------------------------------------------+---------------------------------------+
| "|"                                             | Bitwise OR                            |
+-------------------------------------------------+---------------------------------------+
| "^"                                             | Bitwise XOR                           |
+-------------------------------------------------+---------------------------------------+
| "&"                                             | Bitwise AND                           |
+-------------------------------------------------+---------------------------------------+
| "<<", ">>"                                      | Shifts                                |
+-------------------------------------------------+---------------------------------------+
| "+", "-"                                        | Addition and subtraction              |
+-------------------------------------------------+---------------------------------------+
| "*", "@", "/", "//", "%"                        | Multiplication, matrix                |
|                                                 | multiplication, division, floor       |
|                                                 | division, remainder [5]               |
+-------------------------------------------------+---------------------------------------+
| "+x", "-x", "~x"                                | Positive, negative, bitwise NOT       |
+-------------------------------------------------+---------------------------------------+
| "**"                                            | Exponentiation [6]                    |
+-------------------------------------------------+---------------------------------------+
| "await" "x"                                     | Await expression                      |
+-------------------------------------------------+---------------------------------------+
| "x[index]", "x[index:index]",                   | Subscription, slicing, call,          |
| "x(arguments...)", "x.attribute"                | attribute reference                   |
+-------------------------------------------------+---------------------------------------+
| "(expressions...)",  "[expressions...]", "{key: | Binding or parenthesized expression,  |
| value...}", "{expressions...}"                  | list display, dictionary display, set |
|                                                 | display                               |
+-------------------------------------------------+---------------------------------------+

-[ Footnotes ]-

[1] While "abs(x%y) < abs(y)" is true mathematically, for floats it
    may not be true numerically due to roundoff.  For example, and
    assuming a platform on which a Python float is an IEEE 754 double-
    precision number, in order that "-1e-100 % 1e100" have the same
    sign as "1e100", the computed result is "-1e-100 + 1e100", which
    is numerically exactly equal to "1e100".  The function
    "math.fmod()" returns a result whose sign matches the sign of the
    first argument instead, and so returns "-1e-100" in this case.
    Which approach is more appropriate depends on the application.

[2] If x is very close to an exact integer multiple of y, it’s
    possible for "x//y" to be one larger than "(x-x%y)//y" due to
    rounding.  In such cases, Python returns the latter result, in
    order to preserve that "divmod(x,y)[0] * y + x % y" be very close
    to "x".

[3] The Unicode standard distinguishes between *code points* (e.g.
    U+0041) and *abstract characters* (e.g. “LATIN CAPITAL LETTER A”).
    While most abstract characters in Unicode are only represented
    using one code point, there is a number of abstract characters
    that can in addition be represented using a sequence of more than
    one code point.  For example, the abstract character “LATIN
    CAPITAL LETTER C WITH CEDILLA” can be represented as a single
    *precomposed character* at code position U+00C7, or as a sequence
    of a *base character* at code position U+0043 (LATIN CAPITAL
    LETTER C), followed by a *combining character* at code position
    U+0327 (COMBINING CEDILLA).

    The comparison operators on strings compare at the level of
    Unicode code points. This may be counter-intuitive to humans.  For
    example, ""\u00C7" == "\u0043\u0327"" is "False", even though both
    strings represent the same abstract character “LATIN CAPITAL
    LETTER C WITH CEDILLA”.

    To compare strings at the level of abstract characters (that is,
    in a way intuitive to humans), use "unicodedata.normalize()".

[4] Due to automatic garbage-collection, free lists, and the dynamic
    nature of descriptors, you may notice seemingly unusual behaviour
    in certain uses of the "is" operator, like those involving
    comparisons between instance methods, or constants.  Check their
    documentation for more info.

[5] The "%" operator is also used for string formatting; the same
    precedence applies.

[6] The power operator "**" binds less tightly than an arithmetic or
    bitwise unary operator on its right, that is, "2**-1" is "0.5".
uwThe "pass" statement
********************

   pass_stmt ::= "pass"

"pass" is a null operation — when it is executed, nothing happens. It
is useful as a placeholder when a statement is required syntactically,
but no code needs to be executed, for example:

   def f(arg): pass    # a function that does nothing (yet)

   class C: pass       # a class with no methods (yet)
a�The power operator
******************

The power operator binds more tightly than unary operators on its
left; it binds less tightly than unary operators on its right.  The
syntax is:

   power ::= (await_expr | primary) ["**" u_expr]

Thus, in an unparenthesized sequence of power and unary operators, the
operators are evaluated from right to left (this does not constrain
the evaluation order for the operands): "-1**2" results in "-1".

The power operator has the same semantics as the built-in "pow()"
function, when called with two arguments: it yields its left argument
raised to the power of its right argument.  The numeric arguments are
first converted to a common type, and the result is of that type.

For int operands, the result has the same type as the operands unless
the second argument is negative; in that case, all arguments are
converted to float and a float result is delivered. For example,
"10**2" returns "100", but "10**-2" returns "0.01".

Raising "0.0" to a negative power results in a "ZeroDivisionError".
Raising a negative number to a fractional power results in a "complex"
number. (In earlier versions it raised a "ValueError".)
uJ
The "raise" statement
*********************

   raise_stmt ::= "raise" [expression ["from" expression]]

If no expressions are present, "raise" re-raises the last exception
that was active in the current scope.  If no exception is active in
the current scope, a "RuntimeError" exception is raised indicating
that this is an error.

Otherwise, "raise" evaluates the first expression as the exception
object.  It must be either a subclass or an instance of
"BaseException". If it is a class, the exception instance will be
obtained when needed by instantiating the class with no arguments.

The *type* of the exception is the exception instance’s class, the
*value* is the instance itself.

A traceback object is normally created automatically when an exception
is raised and attached to it as the "__traceback__" attribute, which
is writable. You can create an exception and set your own traceback in
one step using the "with_traceback()" exception method (which returns
the same exception instance, with its traceback set to its argument),
like so:

   raise Exception("foo occurred").with_traceback(tracebackobj)

The "from" clause is used for exception chaining: if given, the second
*expression* must be another exception class or instance. If the
second expression is an exception instance, it will be attached to the
raised exception as the "__cause__" attribute (which is writable). If
the expression is an exception class, the class will be instantiated
and the resulting exception instance will be attached to the raised
exception as the "__cause__" attribute. If the raised exception is not
handled, both exceptions will be printed:

   >>> try:
   ...     print(1 / 0)
   ... except Exception as exc:
   ...     raise RuntimeError("Something bad happened") from exc
   ...
   Traceback (most recent call last):
     File "<stdin>", line 2, in <module>
   ZeroDivisionError: division by zero

   The above exception was the direct cause of the following exception:

   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

A similar mechanism works implicitly if an exception is raised inside
an exception handler or a "finally" clause: the previous exception is
then attached as the new exception’s "__context__" attribute:

   >>> try:
   ...     print(1 / 0)
   ... except:
   ...     raise RuntimeError("Something bad happened")
   ...
   Traceback (most recent call last):
     File "<stdin>", line 2, in <module>
   ZeroDivisionError: division by zero

   During handling of the above exception, another exception occurred:

   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

Exception chaining can be explicitly suppressed by specifying "None"
in the "from" clause:

   >>> try:
   ...     print(1 / 0)
   ... except:
   ...     raise RuntimeError("Something bad happened") from None
   ...
   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
   RuntimeError: Something bad happened

Additional information on exceptions can be found in section
Exceptions, and information about handling exceptions is in section
The try statement.

Changed in version 3.3: "None" is now permitted as "Y" in "raise X
from Y".

New in version 3.3: The "__suppress_context__" attribute to suppress
automatic display of the exception context.
aThe "return" statement
**********************

   return_stmt ::= "return" [expression_list]

"return" may only occur syntactically nested in a function definition,
not within a nested class definition.

If an expression list is present, it is evaluated, else "None" is
substituted.

"return" leaves the current function call with the expression list (or
"None") as return value.

When "return" passes control out of a "try" statement with a "finally"
clause, that "finally" clause is executed before really leaving the
function.

In a generator function, the "return" statement indicates that the
generator is done and will cause "StopIteration" to be raised. The
returned value (if any) is used as an argument to construct
"StopIteration" and becomes the "StopIteration.value" attribute.

In an asynchronous generator function, an empty "return" statement
indicates that the asynchronous generator is done and will cause
"StopAsyncIteration" to be raised.  A non-empty "return" statement is
a syntax error in an asynchronous generator function.
u�Emulating container types
*************************

The following methods can be defined to implement container objects.
Containers usually are sequences (such as lists or tuples) or mappings
(like dictionaries), but can represent other containers as well.  The
first set of methods is used either to emulate a sequence or to
emulate a mapping; the difference is that for a sequence, the
allowable keys should be the integers *k* for which "0 <= k < N" where
*N* is the length of the sequence, or slice objects, which define a
range of items.  It is also recommended that mappings provide the
methods "keys()", "values()", "items()", "get()", "clear()",
"setdefault()", "pop()", "popitem()", "copy()", and "update()"
behaving similar to those for Python’s standard dictionary objects.
The "collections.abc" module provides a "MutableMapping" abstract base
class to help create those methods from a base set of "__getitem__()",
"__setitem__()", "__delitem__()", and "keys()". Mutable sequences
should provide methods "append()", "count()", "index()", "extend()",
"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python
standard list objects.  Finally, sequence types should implement
addition (meaning concatenation) and multiplication (meaning
repetition) by defining the methods "__add__()", "__radd__()",
"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described
below; they should not define other numerical operators.  It is
recommended that both mappings and sequences implement the
"__contains__()" method to allow efficient use of the "in" operator;
for mappings, "in" should search the mapping’s keys; for sequences, it
should search through the values.  It is further recommended that both
mappings and sequences implement the "__iter__()" method to allow
efficient iteration through the container; for mappings, "__iter__()"
should iterate through the object’s keys; for sequences, it should
iterate through the values.

object.__len__(self)

   Called to implement the built-in function "len()".  Should return
   the length of the object, an integer ">=" 0.  Also, an object that
   doesn’t define a "__bool__()" method and whose "__len__()" method
   returns zero is considered to be false in a Boolean context.

   **CPython implementation detail:** In CPython, the length is
   required to be at most "sys.maxsize". If the length is larger than
   "sys.maxsize" some features (such as "len()") may raise
   "OverflowError".  To prevent raising "OverflowError" by truth value
   testing, an object must define a "__bool__()" method.

object.__length_hint__(self)

   Called to implement "operator.length_hint()". Should return an
   estimated length for the object (which may be greater or less than
   the actual length). The length must be an integer ">=" 0. The
   return value may also be "NotImplemented", which is treated the
   same as if the "__length_hint__" method didn’t exist at all. This
   method is purely an optimization and is never required for
   correctness.

   New in version 3.4.

Note:

  Slicing is done exclusively with the following three methods.  A
  call like

     a[1:2] = b

  is translated to

     a[slice(1, 2, None)] = b

  and so forth.  Missing slice items are always filled in with "None".

object.__getitem__(self, key)

   Called to implement evaluation of "self[key]". For sequence types,
   the accepted keys should be integers and slice objects.  Note that
   the special interpretation of negative indexes (if the class wishes
   to emulate a sequence type) is up to the "__getitem__()" method. If
   *key* is of an inappropriate type, "TypeError" may be raised; if of
   a value outside the set of indexes for the sequence (after any
   special interpretation of negative values), "IndexError" should be
   raised. For mapping types, if *key* is missing (not in the
   container), "KeyError" should be raised.

   Note:

     "for" loops expect that an "IndexError" will be raised for
     illegal indexes to allow proper detection of the end of the
     sequence.

object.__setitem__(self, key, value)

   Called to implement assignment to "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support changes to the values for keys, or if new keys
   can be added, or for sequences if elements can be replaced.  The
   same exceptions should be raised for improper *key* values as for
   the "__getitem__()" method.

object.__delitem__(self, key)

   Called to implement deletion of "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support removal of keys, or for sequences if elements
   can be removed from the sequence.  The same exceptions should be
   raised for improper *key* values as for the "__getitem__()" method.

object.__missing__(self, key)

   Called by "dict"."__getitem__()" to implement "self[key]" for dict
   subclasses when key is not in the dictionary.

object.__iter__(self)

   This method is called when an iterator is required for a container.
   This method should return a new iterator object that can iterate
   over all the objects in the container.  For mappings, it should
   iterate over the keys of the container.

   Iterator objects also need to implement this method; they are
   required to return themselves.  For more information on iterator
   objects, see Iterator Types.

object.__reversed__(self)

   Called (if present) by the "reversed()" built-in to implement
   reverse iteration.  It should return a new iterator object that
   iterates over all the objects in the container in reverse order.

   If the "__reversed__()" method is not provided, the "reversed()"
   built-in will fall back to using the sequence protocol ("__len__()"
   and "__getitem__()").  Objects that support the sequence protocol
   should only provide "__reversed__()" if they can provide an
   implementation that is more efficient than the one provided by
   "reversed()".

The membership test operators ("in" and "not in") are normally
implemented as an iteration through a container. However, container
objects can supply the following special method with a more efficient
implementation, which also does not require the object be iterable.

object.__contains__(self, item)

   Called to implement membership test operators.  Should return true
   if *item* is in *self*, false otherwise.  For mapping objects, this
   should consider the keys of the mapping rather than the values or
   the key-item pairs.

   For objects that don’t define "__contains__()", the membership test
   first tries iteration via "__iter__()", then the old sequence
   iteration protocol via "__getitem__()", see this section in the
   language reference.
a�Shifting operations
*******************

The shifting operations have lower priority than the arithmetic
operations:

   shift_expr ::= a_expr | shift_expr ("<<" | ">>") a_expr

These operators accept integers as arguments.  They shift the first
argument to the left or right by the number of bits given by the
second argument.

A right shift by *n* bits is defined as floor division by "pow(2,n)".
A left shift by *n* bits is defined as multiplication with "pow(2,n)".
a�Slicings
********

A slicing selects a range of items in a sequence object (e.g., a
string, tuple or list).  Slicings may be used as expressions or as
targets in assignment or "del" statements.  The syntax for a slicing:

   slicing      ::= primary "[" slice_list "]"
   slice_list   ::= slice_item ("," slice_item)* [","]
   slice_item   ::= expression | proper_slice
   proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]
   lower_bound  ::= expression
   upper_bound  ::= expression
   stride       ::= expression

There is ambiguity in the formal syntax here: anything that looks like
an expression list also looks like a slice list, so any subscription
can be interpreted as a slicing.  Rather than further complicating the
syntax, this is disambiguated by defining that in this case the
interpretation as a subscription takes priority over the
interpretation as a slicing (this is the case if the slice list
contains no proper slice).

The semantics for a slicing are as follows.  The primary is indexed
(using the same "__getitem__()" method as normal subscription) with a
key that is constructed from the slice list, as follows.  If the slice
list contains at least one comma, the key is a tuple containing the
conversion of the slice items; otherwise, the conversion of the lone
slice item is the key.  The conversion of a slice item that is an
expression is that expression.  The conversion of a proper slice is a
slice object (see section The standard type hierarchy) whose "start",
"stop" and "step" attributes are the values of the expressions given
as lower bound, upper bound and stride, respectively, substituting
"None" for missing expressions.
uSpecial Attributes
******************

The implementation adds a few special read-only attributes to several
object types, where they are relevant.  Some of these are not reported
by the "dir()" built-in function.

object.__dict__

   A dictionary or other mapping object used to store an object’s
   (writable) attributes.

instance.__class__

   The class to which a class instance belongs.

class.__bases__

   The tuple of base classes of a class object.

definition.__name__

   The name of the class, function, method, descriptor, or generator
   instance.

definition.__qualname__

   The *qualified name* of the class, function, method, descriptor, or
   generator instance.

   New in version 3.3.

class.__mro__

   This attribute is a tuple of classes that are considered when
   looking for base classes during method resolution.

class.mro()

   This method can be overridden by a metaclass to customize the
   method resolution order for its instances.  It is called at class
   instantiation, and its result is stored in "__mro__".

class.__subclasses__()

   Each class keeps a list of weak references to its immediate
   subclasses.  This method returns a list of all those references
   still alive. Example:

      >>> int.__subclasses__()
      [<class 'bool'>]
u��Special method names
********************

A class can implement certain operations that are invoked by special
syntax (such as arithmetic operations or subscripting and slicing) by
defining methods with special names. This is Python’s approach to
*operator overloading*, allowing classes to define their own behavior
with respect to language operators.  For instance, if a class defines
a method named "__getitem__()", and "x" is an instance of this class,
then "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".
Except where mentioned, attempts to execute an operation raise an
exception when no appropriate method is defined (typically
"AttributeError" or "TypeError").

Setting a special method to "None" indicates that the corresponding
operation is not available.  For example, if a class sets "__iter__()"
to "None", the class is not iterable, so calling "iter()" on its
instances will raise a "TypeError" (without falling back to
"__getitem__()"). [2]

When implementing a class that emulates any built-in type, it is
important that the emulation only be implemented to the degree that it
makes sense for the object being modelled.  For example, some
sequences may work well with retrieval of individual elements, but
extracting a slice may not make sense.  (One example of this is the
"NodeList" interface in the W3C’s Document Object Model.)


Basic customization
===================

object.__new__(cls[, ...])

   Called to create a new instance of class *cls*.  "__new__()" is a
   static method (special-cased so you need not declare it as such)
   that takes the class of which an instance was requested as its
   first argument.  The remaining arguments are those passed to the
   object constructor expression (the call to the class).  The return
   value of "__new__()" should be the new object instance (usually an
   instance of *cls*).

   Typical implementations create a new instance of the class by
   invoking the superclass’s "__new__()" method using
   "super().__new__(cls[, ...])" with appropriate arguments and then
   modifying the newly-created instance as necessary before returning
   it.

   If "__new__()" is invoked during object construction and it returns
   an instance of *cls*, then the new instance’s "__init__()" method
   will be invoked like "__init__(self[, ...])", where *self* is the
   new instance and the remaining arguments are the same as were
   passed to the object constructor.

   If "__new__()" does not return an instance of *cls*, then the new
   instance’s "__init__()" method will not be invoked.

   "__new__()" is intended mainly to allow subclasses of immutable
   types (like int, str, or tuple) to customize instance creation.  It
   is also commonly overridden in custom metaclasses in order to
   customize class creation.

object.__init__(self[, ...])

   Called after the instance has been created (by "__new__()"), but
   before it is returned to the caller.  The arguments are those
   passed to the class constructor expression.  If a base class has an
   "__init__()" method, the derived class’s "__init__()" method, if
   any, must explicitly call it to ensure proper initialization of the
   base class part of the instance; for example:
   "super().__init__([args...])".

   Because "__new__()" and "__init__()" work together in constructing
   objects ("__new__()" to create it, and "__init__()" to customize
   it), no non-"None" value may be returned by "__init__()"; doing so
   will cause a "TypeError" to be raised at runtime.

object.__del__(self)

   Called when the instance is about to be destroyed.  This is also
   called a finalizer or (improperly) a destructor.  If a base class
   has a "__del__()" method, the derived class’s "__del__()" method,
   if any, must explicitly call it to ensure proper deletion of the
   base class part of the instance.

   It is possible (though not recommended!) for the "__del__()" method
   to postpone destruction of the instance by creating a new reference
   to it.  This is called object *resurrection*.  It is
   implementation-dependent whether "__del__()" is called a second
   time when a resurrected object is about to be destroyed; the
   current *CPython* implementation only calls it once.

   It is not guaranteed that "__del__()" methods are called for
   objects that still exist when the interpreter exits.

   Note:

     "del x" doesn’t directly call "x.__del__()" — the former
     decrements the reference count for "x" by one, and the latter is
     only called when "x"’s reference count reaches zero.

   **CPython implementation detail:** It is possible for a reference
   cycle to prevent the reference count of an object from going to
   zero.  In this case, the cycle will be later detected and deleted
   by the *cyclic garbage collector*.  A common cause of reference
   cycles is when an exception has been caught in a local variable.
   The frame’s locals then reference the exception, which references
   its own traceback, which references the locals of all frames caught
   in the traceback.

   See also: Documentation for the "gc" module.

   Warning:

     Due to the precarious circumstances under which "__del__()"
     methods are invoked, exceptions that occur during their execution
     are ignored, and a warning is printed to "sys.stderr" instead.
     In particular:

     * "__del__()" can be invoked when arbitrary code is being
       executed, including from any arbitrary thread.  If "__del__()"
       needs to take a lock or invoke any other blocking resource, it
       may deadlock as the resource may already be taken by the code
       that gets interrupted to execute "__del__()".

     * "__del__()" can be executed during interpreter shutdown.  As a
       consequence, the global variables it needs to access (including
       other modules) may already have been deleted or set to "None".
       Python guarantees that globals whose name begins with a single
       underscore are deleted from their module before other globals
       are deleted; if no other references to such globals exist, this
       may help in assuring that imported modules are still available
       at the time when the "__del__()" method is called.

object.__repr__(self)

   Called by the "repr()" built-in function to compute the “official”
   string representation of an object.  If at all possible, this
   should look like a valid Python expression that could be used to
   recreate an object with the same value (given an appropriate
   environment).  If this is not possible, a string of the form
   "<...some useful description...>" should be returned. The return
   value must be a string object. If a class defines "__repr__()" but
   not "__str__()", then "__repr__()" is also used when an “informal”
   string representation of instances of that class is required.

   This is typically used for debugging, so it is important that the
   representation is information-rich and unambiguous.

object.__str__(self)

   Called by "str(object)" and the built-in functions "format()" and
   "print()" to compute the “informal” or nicely printable string
   representation of an object.  The return value must be a string
   object.

   This method differs from "object.__repr__()" in that there is no
   expectation that "__str__()" return a valid Python expression: a
   more convenient or concise representation can be used.

   The default implementation defined by the built-in type "object"
   calls "object.__repr__()".

object.__bytes__(self)

   Called by bytes to compute a byte-string representation of an
   object. This should return a "bytes" object.

object.__format__(self, format_spec)

   Called by the "format()" built-in function, and by extension,
   evaluation of formatted string literals and the "str.format()"
   method, to produce a “formatted” string representation of an
   object. The *format_spec* argument is a string that contains a
   description of the formatting options desired. The interpretation
   of the *format_spec* argument is up to the type implementing
   "__format__()", however most classes will either delegate
   formatting to one of the built-in types, or use a similar
   formatting option syntax.

   See Format Specification Mini-Language for a description of the
   standard formatting syntax.

   The return value must be a string object.

   Changed in version 3.4: The __format__ method of "object" itself
   raises a "TypeError" if passed any non-empty string.

   Changed in version 3.7: "object.__format__(x, '')" is now
   equivalent to "str(x)" rather than "format(str(self), '')".

object.__lt__(self, other)
object.__le__(self, other)
object.__eq__(self, other)
object.__ne__(self, other)
object.__gt__(self, other)
object.__ge__(self, other)

   These are the so-called “rich comparison” methods. The
   correspondence between operator symbols and method names is as
   follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",
   "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls
   "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".

   A rich comparison method may return the singleton "NotImplemented"
   if it does not implement the operation for a given pair of
   arguments. By convention, "False" and "True" are returned for a
   successful comparison. However, these methods can return any value,
   so if the comparison operator is used in a Boolean context (e.g.,
   in the condition of an "if" statement), Python will call "bool()"
   on the value to determine if the result is true or false.

   By default, "object" implements "__eq__()" by using "is", returning
   "NotImplemented" in the case of a false comparison: "True if x is y
   else NotImplemented". For "__ne__()", by default it delegates to
   "__eq__()" and inverts the result unless it is "NotImplemented".
   There are no other implied relationships among the comparison
   operators or default implementations; for example, the truth of
   "(x<y or x==y)" does not imply "x<=y". To automatically generate
   ordering operations from a single root operation, see
   "functools.total_ordering()".

   See the paragraph on "__hash__()" for some important notes on
   creating *hashable* objects which support custom comparison
   operations and are usable as dictionary keys.

   There are no swapped-argument versions of these methods (to be used
   when the left argument does not support the operation but the right
   argument does); rather, "__lt__()" and "__gt__()" are each other’s
   reflection, "__le__()" and "__ge__()" are each other’s reflection,
   and "__eq__()" and "__ne__()" are their own reflection. If the
   operands are of different types, and right operand’s type is a
   direct or indirect subclass of the left operand’s type, the
   reflected method of the right operand has priority, otherwise the
   left operand’s method has priority.  Virtual subclassing is not
   considered.

object.__hash__(self)

   Called by built-in function "hash()" and for operations on members
   of hashed collections including "set", "frozenset", and "dict".
   "__hash__()" should return an integer. The only required property
   is that objects which compare equal have the same hash value; it is
   advised to mix together the hash values of the components of the
   object that also play a part in comparison of objects by packing
   them into a tuple and hashing the tuple. Example:

      def __hash__(self):
          return hash((self.name, self.nick, self.color))

   Note:

     "hash()" truncates the value returned from an object’s custom
     "__hash__()" method to the size of a "Py_ssize_t".  This is
     typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds.
     If an object’s   "__hash__()" must interoperate on builds of
     different bit sizes, be sure to check the width on all supported
     builds.  An easy way to do this is with "python -c "import sys;
     print(sys.hash_info.width)"".

   If a class does not define an "__eq__()" method it should not
   define a "__hash__()" operation either; if it defines "__eq__()"
   but not "__hash__()", its instances will not be usable as items in
   hashable collections.  If a class defines mutable objects and
   implements an "__eq__()" method, it should not implement
   "__hash__()", since the implementation of hashable collections
   requires that a key’s hash value is immutable (if the object’s hash
   value changes, it will be in the wrong hash bucket).

   User-defined classes have "__eq__()" and "__hash__()" methods by
   default; with them, all objects compare unequal (except with
   themselves) and "x.__hash__()" returns an appropriate value such
   that "x == y" implies both that "x is y" and "hash(x) == hash(y)".

   A class that overrides "__eq__()" and does not define "__hash__()"
   will have its "__hash__()" implicitly set to "None".  When the
   "__hash__()" method of a class is "None", instances of the class
   will raise an appropriate "TypeError" when a program attempts to
   retrieve their hash value, and will also be correctly identified as
   unhashable when checking "isinstance(obj,
   collections.abc.Hashable)".

   If a class that overrides "__eq__()" needs to retain the
   implementation of "__hash__()" from a parent class, the interpreter
   must be told this explicitly by setting "__hash__ =
   <ParentClass>.__hash__".

   If a class that does not override "__eq__()" wishes to suppress
   hash support, it should include "__hash__ = None" in the class
   definition. A class which defines its own "__hash__()" that
   explicitly raises a "TypeError" would be incorrectly identified as
   hashable by an "isinstance(obj, collections.abc.Hashable)" call.

   Note:

     By default, the "__hash__()" values of str and bytes objects are
     “salted” with an unpredictable random value.  Although they
     remain constant within an individual Python process, they are not
     predictable between repeated invocations of Python.This is
     intended to provide protection against a denial-of-service caused
     by carefully-chosen inputs that exploit the worst case
     performance of a dict insertion, O(n^2) complexity.  See
     http://www.ocert.org/advisories/ocert-2011-003.html for
     details.Changing hash values affects the iteration order of sets.
     Python has never made guarantees about this ordering (and it
     typically varies between 32-bit and 64-bit builds).See also
     "PYTHONHASHSEED".

   Changed in version 3.3: Hash randomization is enabled by default.

object.__bool__(self)

   Called to implement truth value testing and the built-in operation
   "bool()"; should return "False" or "True".  When this method is not
   defined, "__len__()" is called, if it is defined, and the object is
   considered true if its result is nonzero.  If a class defines
   neither "__len__()" nor "__bool__()", all its instances are
   considered true.


Customizing attribute access
============================

The following methods can be defined to customize the meaning of
attribute access (use of, assignment to, or deletion of "x.name") for
class instances.

object.__getattr__(self, name)

   Called when the default attribute access fails with an
   "AttributeError" (either "__getattribute__()" raises an
   "AttributeError" because *name* is not an instance attribute or an
   attribute in the class tree for "self"; or "__get__()" of a *name*
   property raises "AttributeError").  This method should either
   return the (computed) attribute value or raise an "AttributeError"
   exception.

   Note that if the attribute is found through the normal mechanism,
   "__getattr__()" is not called.  (This is an intentional asymmetry
   between "__getattr__()" and "__setattr__()".) This is done both for
   efficiency reasons and because otherwise "__getattr__()" would have
   no way to access other attributes of the instance.  Note that at
   least for instance variables, you can fake total control by not
   inserting any values in the instance attribute dictionary (but
   instead inserting them in another object).  See the
   "__getattribute__()" method below for a way to actually get total
   control over attribute access.

object.__getattribute__(self, name)

   Called unconditionally to implement attribute accesses for
   instances of the class. If the class also defines "__getattr__()",
   the latter will not be called unless "__getattribute__()" either
   calls it explicitly or raises an "AttributeError". This method
   should return the (computed) attribute value or raise an
   "AttributeError" exception. In order to avoid infinite recursion in
   this method, its implementation should always call the base class
   method with the same name to access any attributes it needs, for
   example, "object.__getattribute__(self, name)".

   Note:

     This method may still be bypassed when looking up special methods
     as the result of implicit invocation via language syntax or
     built-in functions. See Special method lookup.

   For certain sensitive attribute accesses, raises an auditing event
   "object.__getattr__" with arguments "obj" and "name".

object.__setattr__(self, name, value)

   Called when an attribute assignment is attempted.  This is called
   instead of the normal mechanism (i.e. store the value in the
   instance dictionary). *name* is the attribute name, *value* is the
   value to be assigned to it.

   If "__setattr__()" wants to assign to an instance attribute, it
   should call the base class method with the same name, for example,
   "object.__setattr__(self, name, value)".

   For certain sensitive attribute assignments, raises an auditing
   event "object.__setattr__" with arguments "obj", "name", "value".

object.__delattr__(self, name)

   Like "__setattr__()" but for attribute deletion instead of
   assignment.  This should only be implemented if "del obj.name" is
   meaningful for the object.

   For certain sensitive attribute deletions, raises an auditing event
   "object.__delattr__" with arguments "obj" and "name".

object.__dir__(self)

   Called when "dir()" is called on the object. A sequence must be
   returned. "dir()" converts the returned sequence to a list and
   sorts it.


Customizing module attribute access
-----------------------------------

Special names "__getattr__" and "__dir__" can be also used to
customize access to module attributes. The "__getattr__" function at
the module level should accept one argument which is the name of an
attribute and return the computed value or raise an "AttributeError".
If an attribute is not found on a module object through the normal
lookup, i.e. "object.__getattribute__()", then "__getattr__" is
searched in the module "__dict__" before raising an "AttributeError".
If found, it is called with the attribute name and the result is
returned.

The "__dir__" function should accept no arguments, and return a
sequence of strings that represents the names accessible on module. If
present, this function overrides the standard "dir()" search on a
module.

For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the "__class__" attribute
of a module object to a subclass of "types.ModuleType". For example:

   import sys
   from types import ModuleType

   class VerboseModule(ModuleType):
       def __repr__(self):
           return f'Verbose {self.__name__}'

       def __setattr__(self, attr, value):
           print(f'Setting {attr}...')
           super().__setattr__(attr, value)

   sys.modules[__name__].__class__ = VerboseModule

Note:

  Defining module "__getattr__" and setting module "__class__" only
  affect lookups made using the attribute access syntax – directly
  accessing the module globals (whether by code within the module, or
  via a reference to the module’s globals dictionary) is unaffected.

Changed in version 3.5: "__class__" module attribute is now writable.

New in version 3.7: "__getattr__" and "__dir__" module attributes.

See also:

  **PEP 562** - Module __getattr__ and __dir__
     Describes the "__getattr__" and "__dir__" functions on modules.


Implementing Descriptors
------------------------

The following methods only apply when an instance of the class
containing the method (a so-called *descriptor* class) appears in an
*owner* class (the descriptor must be in either the owner’s class
dictionary or in the class dictionary for one of its parents).  In the
examples below, “the attribute” refers to the attribute whose name is
the key of the property in the owner class’ "__dict__".

object.__get__(self, instance, owner=None)

   Called to get the attribute of the owner class (class attribute
   access) or of an instance of that class (instance attribute
   access). The optional *owner* argument is the owner class, while
   *instance* is the instance that the attribute was accessed through,
   or "None" when the attribute is accessed through the *owner*.

   This method should return the computed attribute value or raise an
   "AttributeError" exception.

   **PEP 252** specifies that "__get__()" is callable with one or two
   arguments.  Python’s own built-in descriptors support this
   specification; however, it is likely that some third-party tools
   have descriptors that require both arguments.  Python’s own
   "__getattribute__()" implementation always passes in both arguments
   whether they are required or not.

object.__set__(self, instance, value)

   Called to set the attribute on an instance *instance* of the owner
   class to a new value, *value*.

   Note, adding "__set__()" or "__delete__()" changes the kind of
   descriptor to a “data descriptor”.  See Invoking Descriptors for
   more details.

object.__delete__(self, instance)

   Called to delete the attribute on an instance *instance* of the
   owner class.

object.__set_name__(self, owner, name)

   Called at the time the owning class *owner* is created. The
   descriptor has been assigned to *name*.

   Note:

     "__set_name__()" is only called implicitly as part of the "type"
     constructor, so it will need to be called explicitly with the
     appropriate parameters when a descriptor is added to a class
     after initial creation:

        class A:
           pass
        descr = custom_descriptor()
        A.attr = descr
        descr.__set_name__(A, 'attr')

     See Creating the class object for more details.

   New in version 3.6.

The attribute "__objclass__" is interpreted by the "inspect" module as
specifying the class where this object was defined (setting this
appropriately can assist in runtime introspection of dynamic class
attributes). For callables, it may indicate that an instance of the
given type (or a subclass) is expected or required as the first
positional argument (for example, CPython sets this attribute for
unbound methods that are implemented in C).


Invoking Descriptors
--------------------

In general, a descriptor is an object attribute with “binding
behavior”, one whose attribute access has been overridden by methods
in the descriptor protocol:  "__get__()", "__set__()", and
"__delete__()". If any of those methods are defined for an object, it
is said to be a descriptor.

The default behavior for attribute access is to get, set, or delete
the attribute from an object’s dictionary. For instance, "a.x" has a
lookup chain starting with "a.__dict__['x']", then
"type(a).__dict__['x']", and continuing through the base classes of
"type(a)" excluding metaclasses.

However, if the looked-up value is an object defining one of the
descriptor methods, then Python may override the default behavior and
invoke the descriptor method instead.  Where this occurs in the
precedence chain depends on which descriptor methods were defined and
how they were called.

The starting point for descriptor invocation is a binding, "a.x". How
the arguments are assembled depends on "a":

Direct Call
   The simplest and least common call is when user code directly
   invokes a descriptor method:    "x.__get__(a)".

Instance Binding
   If binding to an object instance, "a.x" is transformed into the
   call: "type(a).__dict__['x'].__get__(a, type(a))".

Class Binding
   If binding to a class, "A.x" is transformed into the call:
   "A.__dict__['x'].__get__(None, A)".

Super Binding
   If "a" is an instance of "super", then the binding "super(B,
   obj).m()" searches "obj.__class__.__mro__" for the base class "A"
   immediately preceding "B" and then invokes the descriptor with the
   call: "A.__dict__['m'].__get__(obj, obj.__class__)".

For instance bindings, the precedence of descriptor invocation depends
on which descriptor methods are defined.  A descriptor can define any
combination of "__get__()", "__set__()" and "__delete__()".  If it
does not define "__get__()", then accessing the attribute will return
the descriptor object itself unless there is a value in the object’s
instance dictionary.  If the descriptor defines "__set__()" and/or
"__delete__()", it is a data descriptor; if it defines neither, it is
a non-data descriptor.  Normally, data descriptors define both
"__get__()" and "__set__()", while non-data descriptors have just the
"__get__()" method.  Data descriptors with "__set__()" and "__get__()"
defined always override a redefinition in an instance dictionary.  In
contrast, non-data descriptors can be overridden by instances.

Python methods (including "staticmethod()" and "classmethod()") are
implemented as non-data descriptors.  Accordingly, instances can
redefine and override methods.  This allows individual instances to
acquire behaviors that differ from other instances of the same class.

The "property()" function is implemented as a data descriptor.
Accordingly, instances cannot override the behavior of a property.


__slots__
---------

*__slots__* allow us to explicitly declare data members (like
properties) and deny the creation of *__dict__* and *__weakref__*
(unless explicitly declared in *__slots__* or available in a parent.)

The space saved over using *__dict__* can be significant. Attribute
lookup speed can be significantly improved as well.

object.__slots__

   This class variable can be assigned a string, iterable, or sequence
   of strings with variable names used by instances.  *__slots__*
   reserves space for the declared variables and prevents the
   automatic creation of *__dict__* and *__weakref__* for each
   instance.


Notes on using *__slots__*
~~~~~~~~~~~~~~~~~~~~~~~~~~

* When inheriting from a class without *__slots__*, the *__dict__* and
  *__weakref__* attribute of the instances will always be accessible.

* Without a *__dict__* variable, instances cannot be assigned new
  variables not listed in the *__slots__* definition.  Attempts to
  assign to an unlisted variable name raises "AttributeError". If
  dynamic assignment of new variables is desired, then add
  "'__dict__'" to the sequence of strings in the *__slots__*
  declaration.

* Without a *__weakref__* variable for each instance, classes defining
  *__slots__* do not support weak references to its instances. If weak
  reference support is needed, then add "'__weakref__'" to the
  sequence of strings in the *__slots__* declaration.

* *__slots__* are implemented at the class level by creating
  descriptors (Implementing Descriptors) for each variable name.  As a
  result, class attributes cannot be used to set default values for
  instance variables defined by *__slots__*; otherwise, the class
  attribute would overwrite the descriptor assignment.

* The action of a *__slots__* declaration is not limited to the class
  where it is defined.  *__slots__* declared in parents are available
  in child classes. However, child subclasses will get a *__dict__*
  and *__weakref__* unless they also define *__slots__* (which should
  only contain names of any *additional* slots).

* If a class defines a slot also defined in a base class, the instance
  variable defined by the base class slot is inaccessible (except by
  retrieving its descriptor directly from the base class). This
  renders the meaning of the program undefined.  In the future, a
  check may be added to prevent this.

* Nonempty *__slots__* does not work for classes derived from
  “variable-length” built-in types such as "int", "bytes" and "tuple".

* Any non-string iterable may be assigned to *__slots__*. Mappings may
  also be used; however, in the future, special meaning may be
  assigned to the values corresponding to each key.

* *__class__* assignment works only if both classes have the same
  *__slots__*.

* Multiple inheritance with multiple slotted parent classes can be
  used, but only one parent is allowed to have attributes created by
  slots (the other bases must have empty slot layouts) - violations
  raise "TypeError".

* If an iterator is used for *__slots__* then a descriptor is created
  for each of the iterator’s values. However, the *__slots__*
  attribute will be an empty iterator.


Customizing class creation
==========================

Whenever a class inherits from another class, *__init_subclass__* is
called on that class. This way, it is possible to write classes which
change the behavior of subclasses. This is closely related to class
decorators, but where class decorators only affect the specific class
they’re applied to, "__init_subclass__" solely applies to future
subclasses of the class defining the method.

classmethod object.__init_subclass__(cls)

   This method is called whenever the containing class is subclassed.
   *cls* is then the new subclass. If defined as a normal instance
   method, this method is implicitly converted to a class method.

   Keyword arguments which are given to a new class are passed to the
   parent’s class "__init_subclass__". For compatibility with other
   classes using "__init_subclass__", one should take out the needed
   keyword arguments and pass the others over to the base class, as
   in:

      class Philosopher:
          def __init_subclass__(cls, /, default_name, **kwargs):
              super().__init_subclass__(**kwargs)
              cls.default_name = default_name

      class AustralianPhilosopher(Philosopher, default_name="Bruce"):
          pass

   The default implementation "object.__init_subclass__" does nothing,
   but raises an error if it is called with any arguments.

   Note:

     The metaclass hint "metaclass" is consumed by the rest of the
     type machinery, and is never passed to "__init_subclass__"
     implementations. The actual metaclass (rather than the explicit
     hint) can be accessed as "type(cls)".

   New in version 3.6.


Metaclasses
-----------

By default, classes are constructed using "type()". The class body is
executed in a new namespace and the class name is bound locally to the
result of "type(name, bases, namespace)".

The class creation process can be customized by passing the
"metaclass" keyword argument in the class definition line, or by
inheriting from an existing class that included such an argument. In
the following example, both "MyClass" and "MySubclass" are instances
of "Meta":

   class Meta(type):
       pass

   class MyClass(metaclass=Meta):
       pass

   class MySubclass(MyClass):
       pass

Any other keyword arguments that are specified in the class definition
are passed through to all metaclass operations described below.

When a class definition is executed, the following steps occur:

* MRO entries are resolved;

* the appropriate metaclass is determined;

* the class namespace is prepared;

* the class body is executed;

* the class object is created.


Resolving MRO entries
---------------------

If a base that appears in class definition is not an instance of
"type", then an "__mro_entries__" method is searched on it. If found,
it is called with the original bases tuple. This method must return a
tuple of classes that will be used instead of this base. The tuple may
be empty, in such case the original base is ignored.

See also:

  **PEP 560** - Core support for typing module and generic types


Determining the appropriate metaclass
-------------------------------------

The appropriate metaclass for a class definition is determined as
follows:

* if no bases and no explicit metaclass are given, then "type()" is
  used;

* if an explicit metaclass is given and it is *not* an instance of
  "type()", then it is used directly as the metaclass;

* if an instance of "type()" is given as the explicit metaclass, or
  bases are defined, then the most derived metaclass is used.

The most derived metaclass is selected from the explicitly specified
metaclass (if any) and the metaclasses (i.e. "type(cls)") of all
specified base classes. The most derived metaclass is one which is a
subtype of *all* of these candidate metaclasses. If none of the
candidate metaclasses meets that criterion, then the class definition
will fail with "TypeError".


Preparing the class namespace
-----------------------------

Once the appropriate metaclass has been identified, then the class
namespace is prepared. If the metaclass has a "__prepare__" attribute,
it is called as "namespace = metaclass.__prepare__(name, bases,
**kwds)" (where the additional keyword arguments, if any, come from
the class definition). The "__prepare__" method should be implemented
as a "classmethod()". The namespace returned by "__prepare__" is
passed in to "__new__", but when the final class object is created the
namespace is copied into a new "dict".

If the metaclass has no "__prepare__" attribute, then the class
namespace is initialised as an empty ordered mapping.

See also:

  **PEP 3115** - Metaclasses in Python 3000
     Introduced the "__prepare__" namespace hook


Executing the class body
------------------------

The class body is executed (approximately) as "exec(body, globals(),
namespace)". The key difference from a normal call to "exec()" is that
lexical scoping allows the class body (including any methods) to
reference names from the current and outer scopes when the class
definition occurs inside a function.

However, even when the class definition occurs inside the function,
methods defined inside the class still cannot see names defined at the
class scope. Class variables must be accessed through the first
parameter of instance or class methods, or through the implicit
lexically scoped "__class__" reference described in the next section.


Creating the class object
-------------------------

Once the class namespace has been populated by executing the class
body, the class object is created by calling "metaclass(name, bases,
namespace, **kwds)" (the additional keywords passed here are the same
as those passed to "__prepare__").

This class object is the one that will be referenced by the zero-
argument form of "super()". "__class__" is an implicit closure
reference created by the compiler if any methods in a class body refer
to either "__class__" or "super". This allows the zero argument form
of "super()" to correctly identify the class being defined based on
lexical scoping, while the class or instance that was used to make the
current call is identified based on the first argument passed to the
method.

**CPython implementation detail:** In CPython 3.6 and later, the
"__class__" cell is passed to the metaclass as a "__classcell__" entry
in the class namespace. If present, this must be propagated up to the
"type.__new__" call in order for the class to be initialised
correctly. Failing to do so will result in a "RuntimeError" in Python
3.8.

When using the default metaclass "type", or any metaclass that
ultimately calls "type.__new__", the following additional
customisation steps are invoked after creating the class object:

* first, "type.__new__" collects all of the descriptors in the class
  namespace that define a "__set_name__()" method;

* second, all of these "__set_name__" methods are called with the
  class being defined and the assigned name of that particular
  descriptor;

* finally, the "__init_subclass__()" hook is called on the immediate
  parent of the new class in its method resolution order.

After the class object is created, it is passed to the class
decorators included in the class definition (if any) and the resulting
object is bound in the local namespace as the defined class.

When a new class is created by "type.__new__", the object provided as
the namespace parameter is copied to a new ordered mapping and the
original object is discarded. The new copy is wrapped in a read-only
proxy, which becomes the "__dict__" attribute of the class object.

See also:

  **PEP 3135** - New super
     Describes the implicit "__class__" closure reference


Uses for metaclasses
--------------------

The potential uses for metaclasses are boundless. Some ideas that have
been explored include enum, logging, interface checking, automatic
delegation, automatic property creation, proxies, frameworks, and
automatic resource locking/synchronization.


Customizing instance and subclass checks
========================================

The following methods are used to override the default behavior of the
"isinstance()" and "issubclass()" built-in functions.

In particular, the metaclass "abc.ABCMeta" implements these methods in
order to allow the addition of Abstract Base Classes (ABCs) as
“virtual base classes” to any class or type (including built-in
types), including other ABCs.

class.__instancecheck__(self, instance)

   Return true if *instance* should be considered a (direct or
   indirect) instance of *class*. If defined, called to implement
   "isinstance(instance, class)".

class.__subclasscheck__(self, subclass)

   Return true if *subclass* should be considered a (direct or
   indirect) subclass of *class*.  If defined, called to implement
   "issubclass(subclass, class)".

Note that these methods are looked up on the type (metaclass) of a
class.  They cannot be defined as class methods in the actual class.
This is consistent with the lookup of special methods that are called
on instances, only in this case the instance is itself a class.

See also:

  **PEP 3119** - Introducing Abstract Base Classes
     Includes the specification for customizing "isinstance()" and
     "issubclass()" behavior through "__instancecheck__()" and
     "__subclasscheck__()", with motivation for this functionality in
     the context of adding Abstract Base Classes (see the "abc"
     module) to the language.


Emulating generic types
=======================

One can implement the generic class syntax as specified by **PEP 484**
(for example "List[int]") by defining a special method:

classmethod object.__class_getitem__(cls, key)

   Return an object representing the specialization of a generic class
   by type arguments found in *key*.

This method is looked up on the class object itself, and when defined
in the class body, this method is implicitly a class method.  Note,
this mechanism is primarily reserved for use with static type hints,
other usage is discouraged.

See also:

  **PEP 560** - Core support for typing module and generic types


Emulating callable objects
==========================

object.__call__(self[, args...])

   Called when the instance is “called” as a function; if this method
   is defined, "x(arg1, arg2, ...)" roughly translates to
   "type(x).__call__(x, arg1, ...)".


Emulating container types
=========================

The following methods can be defined to implement container objects.
Containers usually are sequences (such as lists or tuples) or mappings
(like dictionaries), but can represent other containers as well.  The
first set of methods is used either to emulate a sequence or to
emulate a mapping; the difference is that for a sequence, the
allowable keys should be the integers *k* for which "0 <= k < N" where
*N* is the length of the sequence, or slice objects, which define a
range of items.  It is also recommended that mappings provide the
methods "keys()", "values()", "items()", "get()", "clear()",
"setdefault()", "pop()", "popitem()", "copy()", and "update()"
behaving similar to those for Python’s standard dictionary objects.
The "collections.abc" module provides a "MutableMapping" abstract base
class to help create those methods from a base set of "__getitem__()",
"__setitem__()", "__delitem__()", and "keys()". Mutable sequences
should provide methods "append()", "count()", "index()", "extend()",
"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python
standard list objects.  Finally, sequence types should implement
addition (meaning concatenation) and multiplication (meaning
repetition) by defining the methods "__add__()", "__radd__()",
"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described
below; they should not define other numerical operators.  It is
recommended that both mappings and sequences implement the
"__contains__()" method to allow efficient use of the "in" operator;
for mappings, "in" should search the mapping’s keys; for sequences, it
should search through the values.  It is further recommended that both
mappings and sequences implement the "__iter__()" method to allow
efficient iteration through the container; for mappings, "__iter__()"
should iterate through the object’s keys; for sequences, it should
iterate through the values.

object.__len__(self)

   Called to implement the built-in function "len()".  Should return
   the length of the object, an integer ">=" 0.  Also, an object that
   doesn’t define a "__bool__()" method and whose "__len__()" method
   returns zero is considered to be false in a Boolean context.

   **CPython implementation detail:** In CPython, the length is
   required to be at most "sys.maxsize". If the length is larger than
   "sys.maxsize" some features (such as "len()") may raise
   "OverflowError".  To prevent raising "OverflowError" by truth value
   testing, an object must define a "__bool__()" method.

object.__length_hint__(self)

   Called to implement "operator.length_hint()". Should return an
   estimated length for the object (which may be greater or less than
   the actual length). The length must be an integer ">=" 0. The
   return value may also be "NotImplemented", which is treated the
   same as if the "__length_hint__" method didn’t exist at all. This
   method is purely an optimization and is never required for
   correctness.

   New in version 3.4.

Note:

  Slicing is done exclusively with the following three methods.  A
  call like

     a[1:2] = b

  is translated to

     a[slice(1, 2, None)] = b

  and so forth.  Missing slice items are always filled in with "None".

object.__getitem__(self, key)

   Called to implement evaluation of "self[key]". For sequence types,
   the accepted keys should be integers and slice objects.  Note that
   the special interpretation of negative indexes (if the class wishes
   to emulate a sequence type) is up to the "__getitem__()" method. If
   *key* is of an inappropriate type, "TypeError" may be raised; if of
   a value outside the set of indexes for the sequence (after any
   special interpretation of negative values), "IndexError" should be
   raised. For mapping types, if *key* is missing (not in the
   container), "KeyError" should be raised.

   Note:

     "for" loops expect that an "IndexError" will be raised for
     illegal indexes to allow proper detection of the end of the
     sequence.

object.__setitem__(self, key, value)

   Called to implement assignment to "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support changes to the values for keys, or if new keys
   can be added, or for sequences if elements can be replaced.  The
   same exceptions should be raised for improper *key* values as for
   the "__getitem__()" method.

object.__delitem__(self, key)

   Called to implement deletion of "self[key]".  Same note as for
   "__getitem__()".  This should only be implemented for mappings if
   the objects support removal of keys, or for sequences if elements
   can be removed from the sequence.  The same exceptions should be
   raised for improper *key* values as for the "__getitem__()" method.

object.__missing__(self, key)

   Called by "dict"."__getitem__()" to implement "self[key]" for dict
   subclasses when key is not in the dictionary.

object.__iter__(self)

   This method is called when an iterator is required for a container.
   This method should return a new iterator object that can iterate
   over all the objects in the container.  For mappings, it should
   iterate over the keys of the container.

   Iterator objects also need to implement this method; they are
   required to return themselves.  For more information on iterator
   objects, see Iterator Types.

object.__reversed__(self)

   Called (if present) by the "reversed()" built-in to implement
   reverse iteration.  It should return a new iterator object that
   iterates over all the objects in the container in reverse order.

   If the "__reversed__()" method is not provided, the "reversed()"
   built-in will fall back to using the sequence protocol ("__len__()"
   and "__getitem__()").  Objects that support the sequence protocol
   should only provide "__reversed__()" if they can provide an
   implementation that is more efficient than the one provided by
   "reversed()".

The membership test operators ("in" and "not in") are normally
implemented as an iteration through a container. However, container
objects can supply the following special method with a more efficient
implementation, which also does not require the object be iterable.

object.__contains__(self, item)

   Called to implement membership test operators.  Should return true
   if *item* is in *self*, false otherwise.  For mapping objects, this
   should consider the keys of the mapping rather than the values or
   the key-item pairs.

   For objects that don’t define "__contains__()", the membership test
   first tries iteration via "__iter__()", then the old sequence
   iteration protocol via "__getitem__()", see this section in the
   language reference.


Emulating numeric types
=======================

The following methods can be defined to emulate numeric objects.
Methods corresponding to operations that are not supported by the
particular kind of number implemented (e.g., bitwise operations for
non-integral numbers) should be left undefined.

object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
object.__matmul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
object.__divmod__(self, other)
object.__pow__(self, other[, modulo])
object.__lshift__(self, other)
object.__rshift__(self, other)
object.__and__(self, other)
object.__xor__(self, other)
object.__or__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|").  For instance, to
   evaluate the expression "x + y", where *x* is an instance of a
   class that has an "__add__()" method, "x.__add__(y)" is called.
   The "__divmod__()" method should be the equivalent to using
   "__floordiv__()" and "__mod__()"; it should not be related to
   "__truediv__()".  Note that "__pow__()" should be defined to accept
   an optional third argument if the ternary version of the built-in
   "pow()" function is to be supported.

   If one of those methods does not support the operation with the
   supplied arguments, it should return "NotImplemented".

object.__radd__(self, other)
object.__rsub__(self, other)
object.__rmul__(self, other)
object.__rmatmul__(self, other)
object.__rtruediv__(self, other)
object.__rfloordiv__(self, other)
object.__rmod__(self, other)
object.__rdivmod__(self, other)
object.__rpow__(self, other[, modulo])
object.__rlshift__(self, other)
object.__rrshift__(self, other)
object.__rand__(self, other)
object.__rxor__(self, other)
object.__ror__(self, other)

   These methods are called to implement the binary arithmetic
   operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",
   "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)
   operands.  These functions are only called if the left operand does
   not support the corresponding operation [3] and the operands are of
   different types. [4] For instance, to evaluate the expression "x -
   y", where *y* is an instance of a class that has an "__rsub__()"
   method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns
   *NotImplemented*.

   Note that ternary "pow()" will not try calling "__rpow__()" (the
   coercion rules would become too complicated).

   Note:

     If the right operand’s type is a subclass of the left operand’s
     type and that subclass provides a different implementation of the
     reflected method for the operation, this method will be called
     before the left operand’s non-reflected method. This behavior
     allows subclasses to override their ancestors’ operations.

object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
object.__imatmul__(self, other)
object.__itruediv__(self, other)
object.__ifloordiv__(self, other)
object.__imod__(self, other)
object.__ipow__(self, other[, modulo])
object.__ilshift__(self, other)
object.__irshift__(self, other)
object.__iand__(self, other)
object.__ixor__(self, other)
object.__ior__(self, other)

   These methods are called to implement the augmented arithmetic
   assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",
   "<<=", ">>=", "&=", "^=", "|=").  These methods should attempt to
   do the operation in-place (modifying *self*) and return the result
   (which could be, but does not have to be, *self*).  If a specific
   method is not defined, the augmented assignment falls back to the
   normal methods.  For instance, if *x* is an instance of a class
   with an "__iadd__()" method, "x += y" is equivalent to "x =
   x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are
   considered, as with the evaluation of "x + y". In certain
   situations, augmented assignment can result in unexpected errors
   (see Why does a_tuple[i] += [‘item’] raise an exception when the
   addition works?), but this behavior is in fact part of the data
   model.

   Note:

     Due to a bug in the dispatching mechanism for "**=", a class that
     defines "__ipow__()" but returns "NotImplemented" would fail to
     fall back to "x.__pow__(y)" and "y.__rpow__(x)". This bug is
     fixed in Python 3.10.

object.__neg__(self)
object.__pos__(self)
object.__abs__(self)
object.__invert__(self)

   Called to implement the unary arithmetic operations ("-", "+",
   "abs()" and "~").

object.__complex__(self)
object.__int__(self)
object.__float__(self)

   Called to implement the built-in functions "complex()", "int()" and
   "float()".  Should return a value of the appropriate type.

object.__index__(self)

   Called to implement "operator.index()", and whenever Python needs
   to losslessly convert the numeric object to an integer object (such
   as in slicing, or in the built-in "bin()", "hex()" and "oct()"
   functions). Presence of this method indicates that the numeric
   object is an integer type.  Must return an integer.

   If "__int__()", "__float__()" and "__complex__()" are not defined
   then corresponding built-in functions "int()", "float()" and
   "complex()" fall back to "__index__()".

object.__round__(self[, ndigits])
object.__trunc__(self)
object.__floor__(self)
object.__ceil__(self)

   Called to implement the built-in function "round()" and "math"
   functions "trunc()", "floor()" and "ceil()". Unless *ndigits* is
   passed to "__round__()" all these methods should return the value
   of the object truncated to an "Integral" (typically an "int").

   The built-in function "int()" falls back to "__trunc__()" if
   neither "__int__()" nor "__index__()" is defined.


With Statement Context Managers
===============================

A *context manager* is an object that defines the runtime context to
be established when executing a "with" statement. The context manager
handles the entry into, and the exit from, the desired runtime context
for the execution of the block of code.  Context managers are normally
invoked using the "with" statement (described in section The with
statement), but can also be used by directly invoking their methods.

Typical uses of context managers include saving and restoring various
kinds of global state, locking and unlocking resources, closing opened
files, etc.

For more information on context managers, see Context Manager Types.

object.__enter__(self)

   Enter the runtime context related to this object. The "with"
   statement will bind this method’s return value to the target(s)
   specified in the "as" clause of the statement, if any.

object.__exit__(self, exc_type, exc_value, traceback)

   Exit the runtime context related to this object. The parameters
   describe the exception that caused the context to be exited. If the
   context was exited without an exception, all three arguments will
   be "None".

   If an exception is supplied, and the method wishes to suppress the
   exception (i.e., prevent it from being propagated), it should
   return a true value. Otherwise, the exception will be processed
   normally upon exit from this method.

   Note that "__exit__()" methods should not reraise the passed-in
   exception; this is the caller’s responsibility.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.


Special method lookup
=====================

For custom classes, implicit invocations of special methods are only
guaranteed to work correctly if defined on an object’s type, not in
the object’s instance dictionary.  That behaviour is the reason why
the following code raises an exception:

   >>> class C:
   ...     pass
   ...
   >>> c = C()
   >>> c.__len__ = lambda: 5
   >>> len(c)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: object of type 'C' has no len()

The rationale behind this behaviour lies with a number of special
methods such as "__hash__()" and "__repr__()" that are implemented by
all objects, including type objects. If the implicit lookup of these
methods used the conventional lookup process, they would fail when
invoked on the type object itself:

   >>> 1 .__hash__() == hash(1)
   True
   >>> int.__hash__() == hash(int)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: descriptor '__hash__' of 'int' object needs an argument

Incorrectly attempting to invoke an unbound method of a class in this
way is sometimes referred to as ‘metaclass confusion’, and is avoided
by bypassing the instance when looking up special methods:

   >>> type(1).__hash__(1) == hash(1)
   True
   >>> type(int).__hash__(int) == hash(int)
   True

In addition to bypassing any instance attributes in the interest of
correctness, implicit special method lookup generally also bypasses
the "__getattribute__()" method even of the object’s metaclass:

   >>> class Meta(type):
   ...     def __getattribute__(*args):
   ...         print("Metaclass getattribute invoked")
   ...         return type.__getattribute__(*args)
   ...
   >>> class C(object, metaclass=Meta):
   ...     def __len__(self):
   ...         return 10
   ...     def __getattribute__(*args):
   ...         print("Class getattribute invoked")
   ...         return object.__getattribute__(*args)
   ...
   >>> c = C()
   >>> c.__len__()                 # Explicit lookup via instance
   Class getattribute invoked
   10
   >>> type(c).__len__(c)          # Explicit lookup via type
   Metaclass getattribute invoked
   10
   >>> len(c)                      # Implicit lookup
   10

Bypassing the "__getattribute__()" machinery in this fashion provides
significant scope for speed optimisations within the interpreter, at
the cost of some flexibility in the handling of special methods (the
special method *must* be set on the class object itself in order to be
consistently invoked by the interpreter).
u�YString Methods
**************

Strings implement all of the common sequence operations, along with
the additional methods described below.

Strings also support two styles of string formatting, one providing a
large degree of flexibility and customization (see "str.format()",
Format String Syntax and Custom String Formatting) and the other based
on C "printf" style formatting that handles a narrower range of types
and is slightly harder to use correctly, but is often faster for the
cases it can handle (printf-style String Formatting).

The Text Processing Services section of the standard library covers a
number of other modules that provide various text related utilities
(including regular expression support in the "re" module).

str.capitalize()

   Return a copy of the string with its first character capitalized
   and the rest lowercased.

   Changed in version 3.8: The first character is now put into
   titlecase rather than uppercase. This means that characters like
   digraphs will only have their first letter capitalized, instead of
   the full character.

str.casefold()

   Return a casefolded copy of the string. Casefolded strings may be
   used for caseless matching.

   Casefolding is similar to lowercasing but more aggressive because
   it is intended to remove all case distinctions in a string. For
   example, the German lowercase letter "'ß'" is equivalent to ""ss"".
   Since it is already lowercase, "lower()" would do nothing to "'ß'";
   "casefold()" converts it to ""ss"".

   The casefolding algorithm is described in section 3.13 of the
   Unicode Standard.

   New in version 3.3.

str.center(width[, fillchar])

   Return centered in a string of length *width*. Padding is done
   using the specified *fillchar* (default is an ASCII space). The
   original string is returned if *width* is less than or equal to
   "len(s)".

str.count(sub[, start[, end]])

   Return the number of non-overlapping occurrences of substring *sub*
   in the range [*start*, *end*].  Optional arguments *start* and
   *end* are interpreted as in slice notation.

str.encode(encoding="utf-8", errors="strict")

   Return an encoded version of the string as a bytes object. Default
   encoding is "'utf-8'". *errors* may be given to set a different
   error handling scheme. The default for *errors* is "'strict'",
   meaning that encoding errors raise a "UnicodeError". Other possible
   values are "'ignore'", "'replace'", "'xmlcharrefreplace'",
   "'backslashreplace'" and any other name registered via
   "codecs.register_error()", see section Error Handlers. For a list
   of possible encodings, see section Standard Encodings.

   Changed in version 3.1: Support for keyword arguments added.

str.endswith(suffix[, start[, end]])

   Return "True" if the string ends with the specified *suffix*,
   otherwise return "False".  *suffix* can also be a tuple of suffixes
   to look for.  With optional *start*, test beginning at that
   position.  With optional *end*, stop comparing at that position.

str.expandtabs(tabsize=8)

   Return a copy of the string where all tab characters are replaced
   by one or more spaces, depending on the current column and the
   given tab size.  Tab positions occur every *tabsize* characters
   (default is 8, giving tab positions at columns 0, 8, 16 and so on).
   To expand the string, the current column is set to zero and the
   string is examined character by character.  If the character is a
   tab ("\t"), one or more space characters are inserted in the result
   until the current column is equal to the next tab position. (The
   tab character itself is not copied.)  If the character is a newline
   ("\n") or return ("\r"), it is copied and the current column is
   reset to zero.  Any other character is copied unchanged and the
   current column is incremented by one regardless of how the
   character is represented when printed.

   >>> '01\t012\t0123\t01234'.expandtabs()
   '01      012     0123    01234'
   >>> '01\t012\t0123\t01234'.expandtabs(4)
   '01  012 0123    01234'

str.find(sub[, start[, end]])

   Return the lowest index in the string where substring *sub* is
   found within the slice "s[start:end]".  Optional arguments *start*
   and *end* are interpreted as in slice notation.  Return "-1" if
   *sub* is not found.

   Note:

     The "find()" method should be used only if you need to know the
     position of *sub*.  To check if *sub* is a substring or not, use
     the "in" operator:

        >>> 'Py' in 'Python'
        True

str.format(*args, **kwargs)

   Perform a string formatting operation.  The string on which this
   method is called can contain literal text or replacement fields
   delimited by braces "{}".  Each replacement field contains either
   the numeric index of a positional argument, or the name of a
   keyword argument.  Returns a copy of the string where each
   replacement field is replaced with the string value of the
   corresponding argument.

   >>> "The sum of 1 + 2 is {0}".format(1+2)
   'The sum of 1 + 2 is 3'

   See Format String Syntax for a description of the various
   formatting options that can be specified in format strings.

   Note:

     When formatting a number ("int", "float", "complex",
     "decimal.Decimal" and subclasses) with the "n" type (ex:
     "'{:n}'.format(1234)"), the function temporarily sets the
     "LC_CTYPE" locale to the "LC_NUMERIC" locale to decode
     "decimal_point" and "thousands_sep" fields of "localeconv()" if
     they are non-ASCII or longer than 1 byte, and the "LC_NUMERIC"
     locale is different than the "LC_CTYPE" locale.  This temporary
     change affects other threads.

   Changed in version 3.7: When formatting a number with the "n" type,
   the function sets temporarily the "LC_CTYPE" locale to the
   "LC_NUMERIC" locale in some cases.

str.format_map(mapping)

   Similar to "str.format(**mapping)", except that "mapping" is used
   directly and not copied to a "dict".  This is useful if for example
   "mapping" is a dict subclass:

   >>> class Default(dict):
   ...     def __missing__(self, key):
   ...         return key
   ...
   >>> '{name} was born in {country}'.format_map(Default(name='Guido'))
   'Guido was born in country'

   New in version 3.2.

str.index(sub[, start[, end]])

   Like "find()", but raise "ValueError" when the substring is not
   found.

str.isalnum()

   Return "True" if all characters in the string are alphanumeric and
   there is at least one character, "False" otherwise.  A character
   "c" is alphanumeric if one of the following returns "True":
   "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".

str.isalpha()

   Return "True" if all characters in the string are alphabetic and
   there is at least one character, "False" otherwise.  Alphabetic
   characters are those characters defined in the Unicode character
   database as “Letter”, i.e., those with general category property
   being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”.  Note that this is
   different from the “Alphabetic” property defined in the Unicode
   Standard.

str.isascii()

   Return "True" if the string is empty or all characters in the
   string are ASCII, "False" otherwise. ASCII characters have code
   points in the range U+0000-U+007F.

   New in version 3.7.

str.isdecimal()

   Return "True" if all characters in the string are decimal
   characters and there is at least one character, "False" otherwise.
   Decimal characters are those that can be used to form numbers in
   base 10, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.  Formally a decimal
   character is a character in the Unicode General Category “Nd”.

str.isdigit()

   Return "True" if all characters in the string are digits and there
   is at least one character, "False" otherwise.  Digits include
   decimal characters and digits that need special handling, such as
   the compatibility superscript digits. This covers digits which
   cannot be used to form numbers in base 10, like the Kharosthi
   numbers.  Formally, a digit is a character that has the property
   value Numeric_Type=Digit or Numeric_Type=Decimal.

str.isidentifier()

   Return "True" if the string is a valid identifier according to the
   language definition, section Identifiers and keywords.

   Call "keyword.iskeyword()" to test whether string "s" is a reserved
   identifier, such as "def" and "class".

   Example:

      >>> from keyword import iskeyword

      >>> 'hello'.isidentifier(), iskeyword('hello')
      True, False
      >>> 'def'.isidentifier(), iskeyword('def')
      True, True

str.islower()

   Return "True" if all cased characters [4] in the string are
   lowercase and there is at least one cased character, "False"
   otherwise.

str.isnumeric()

   Return "True" if all characters in the string are numeric
   characters, and there is at least one character, "False" otherwise.
   Numeric characters include digit characters, and all characters
   that have the Unicode numeric value property, e.g. U+2155, VULGAR
   FRACTION ONE FIFTH.  Formally, numeric characters are those with
   the property value Numeric_Type=Digit, Numeric_Type=Decimal or
   Numeric_Type=Numeric.

str.isprintable()

   Return "True" if all characters in the string are printable or the
   string is empty, "False" otherwise.  Nonprintable characters are
   those characters defined in the Unicode character database as
   “Other” or “Separator”, excepting the ASCII space (0x20) which is
   considered printable.  (Note that printable characters in this
   context are those which should not be escaped when "repr()" is
   invoked on a string.  It has no bearing on the handling of strings
   written to "sys.stdout" or "sys.stderr".)

str.isspace()

   Return "True" if there are only whitespace characters in the string
   and there is at least one character, "False" otherwise.

   A character is *whitespace* if in the Unicode character database
   (see "unicodedata"), either its general category is "Zs"
   (“Separator, space”), or its bidirectional class is one of "WS",
   "B", or "S".

str.istitle()

   Return "True" if the string is a titlecased string and there is at
   least one character, for example uppercase characters may only
   follow uncased characters and lowercase characters only cased ones.
   Return "False" otherwise.

str.isupper()

   Return "True" if all cased characters [4] in the string are
   uppercase and there is at least one cased character, "False"
   otherwise.

str.join(iterable)

   Return a string which is the concatenation of the strings in
   *iterable*. A "TypeError" will be raised if there are any non-
   string values in *iterable*, including "bytes" objects.  The
   separator between elements is the string providing this method.

str.ljust(width[, fillchar])

   Return the string left justified in a string of length *width*.
   Padding is done using the specified *fillchar* (default is an ASCII
   space). The original string is returned if *width* is less than or
   equal to "len(s)".

str.lower()

   Return a copy of the string with all the cased characters [4]
   converted to lowercase.

   The lowercasing algorithm used is described in section 3.13 of the
   Unicode Standard.

str.lstrip([chars])

   Return a copy of the string with leading characters removed.  The
   *chars* argument is a string specifying the set of characters to be
   removed.  If omitted or "None", the *chars* argument defaults to
   removing whitespace.  The *chars* argument is not a prefix; rather,
   all combinations of its values are stripped:

      >>> '   spacious   '.lstrip()
      'spacious   '
      >>> 'www.example.com'.lstrip('cmowz.')
      'example.com'

static str.maketrans(x[, y[, z]])

   This static method returns a translation table usable for
   "str.translate()".

   If there is only one argument, it must be a dictionary mapping
   Unicode ordinals (integers) or characters (strings of length 1) to
   Unicode ordinals, strings (of arbitrary lengths) or "None".
   Character keys will then be converted to ordinals.

   If there are two arguments, they must be strings of equal length,
   and in the resulting dictionary, each character in x will be mapped
   to the character at the same position in y.  If there is a third
   argument, it must be a string, whose characters will be mapped to
   "None" in the result.

str.partition(sep)

   Split the string at the first occurrence of *sep*, and return a
   3-tuple containing the part before the separator, the separator
   itself, and the part after the separator.  If the separator is not
   found, return a 3-tuple containing the string itself, followed by
   two empty strings.

str.replace(old, new[, count])

   Return a copy of the string with all occurrences of substring *old*
   replaced by *new*.  If the optional argument *count* is given, only
   the first *count* occurrences are replaced.

str.rfind(sub[, start[, end]])

   Return the highest index in the string where substring *sub* is
   found, such that *sub* is contained within "s[start:end]".
   Optional arguments *start* and *end* are interpreted as in slice
   notation.  Return "-1" on failure.

str.rindex(sub[, start[, end]])

   Like "rfind()" but raises "ValueError" when the substring *sub* is
   not found.

str.rjust(width[, fillchar])

   Return the string right justified in a string of length *width*.
   Padding is done using the specified *fillchar* (default is an ASCII
   space). The original string is returned if *width* is less than or
   equal to "len(s)".

str.rpartition(sep)

   Split the string at the last occurrence of *sep*, and return a
   3-tuple containing the part before the separator, the separator
   itself, and the part after the separator.  If the separator is not
   found, return a 3-tuple containing two empty strings, followed by
   the string itself.

str.rsplit(sep=None, maxsplit=-1)

   Return a list of the words in the string, using *sep* as the
   delimiter string. If *maxsplit* is given, at most *maxsplit* splits
   are done, the *rightmost* ones.  If *sep* is not specified or
   "None", any whitespace string is a separator.  Except for splitting
   from the right, "rsplit()" behaves like "split()" which is
   described in detail below.

str.rstrip([chars])

   Return a copy of the string with trailing characters removed.  The
   *chars* argument is a string specifying the set of characters to be
   removed.  If omitted or "None", the *chars* argument defaults to
   removing whitespace.  The *chars* argument is not a suffix; rather,
   all combinations of its values are stripped:

      >>> '   spacious   '.rstrip()
      '   spacious'
      >>> 'mississippi'.rstrip('ipz')
      'mississ'

str.split(sep=None, maxsplit=-1)

   Return a list of the words in the string, using *sep* as the
   delimiter string.  If *maxsplit* is given, at most *maxsplit*
   splits are done (thus, the list will have at most "maxsplit+1"
   elements).  If *maxsplit* is not specified or "-1", then there is
   no limit on the number of splits (all possible splits are made).

   If *sep* is given, consecutive delimiters are not grouped together
   and are deemed to delimit empty strings (for example,
   "'1,,2'.split(',')" returns "['1', '', '2']").  The *sep* argument
   may consist of multiple characters (for example,
   "'1<>2<>3'.split('<>')" returns "['1', '2', '3']"). Splitting an
   empty string with a specified separator returns "['']".

   For example:

      >>> '1,2,3'.split(',')
      ['1', '2', '3']
      >>> '1,2,3'.split(',', maxsplit=1)
      ['1', '2,3']
      >>> '1,2,,3,'.split(',')
      ['1', '2', '', '3', '']

   If *sep* is not specified or is "None", a different splitting
   algorithm is applied: runs of consecutive whitespace are regarded
   as a single separator, and the result will contain no empty strings
   at the start or end if the string has leading or trailing
   whitespace.  Consequently, splitting an empty string or a string
   consisting of just whitespace with a "None" separator returns "[]".

   For example:

      >>> '1 2 3'.split()
      ['1', '2', '3']
      >>> '1 2 3'.split(maxsplit=1)
      ['1', '2 3']
      >>> '   1   2   3   '.split()
      ['1', '2', '3']

str.splitlines([keepends])

   Return a list of the lines in the string, breaking at line
   boundaries.  Line breaks are not included in the resulting list
   unless *keepends* is given and true.

   This method splits on the following line boundaries.  In
   particular, the boundaries are a superset of *universal newlines*.

   +-------------------------+-------------------------------+
   | Representation          | Description                   |
   |=========================|===============================|
   | "\n"                    | Line Feed                     |
   +-------------------------+-------------------------------+
   | "\r"                    | Carriage Return               |
   +-------------------------+-------------------------------+
   | "\r\n"                  | Carriage Return + Line Feed   |
   +-------------------------+-------------------------------+
   | "\v" or "\x0b"          | Line Tabulation               |
   +-------------------------+-------------------------------+
   | "\f" or "\x0c"          | Form Feed                     |
   +-------------------------+-------------------------------+
   | "\x1c"                  | File Separator                |
   +-------------------------+-------------------------------+
   | "\x1d"                  | Group Separator               |
   +-------------------------+-------------------------------+
   | "\x1e"                  | Record Separator              |
   +-------------------------+-------------------------------+
   | "\x85"                  | Next Line (C1 Control Code)   |
   +-------------------------+-------------------------------+
   | "\u2028"                | Line Separator                |
   +-------------------------+-------------------------------+
   | "\u2029"                | Paragraph Separator           |
   +-------------------------+-------------------------------+

   Changed in version 3.2: "\v" and "\f" added to list of line
   boundaries.

   For example:

      >>> 'ab c\n\nde fg\rkl\r\n'.splitlines()
      ['ab c', '', 'de fg', 'kl']
      >>> 'ab c\n\nde fg\rkl\r\n'.splitlines(keepends=True)
      ['ab c\n', '\n', 'de fg\r', 'kl\r\n']

   Unlike "split()" when a delimiter string *sep* is given, this
   method returns an empty list for the empty string, and a terminal
   line break does not result in an extra line:

      >>> "".splitlines()
      []
      >>> "One line\n".splitlines()
      ['One line']

   For comparison, "split('\n')" gives:

      >>> ''.split('\n')
      ['']
      >>> 'Two lines\n'.split('\n')
      ['Two lines', '']

str.startswith(prefix[, start[, end]])

   Return "True" if string starts with the *prefix*, otherwise return
   "False". *prefix* can also be a tuple of prefixes to look for.
   With optional *start*, test string beginning at that position.
   With optional *end*, stop comparing string at that position.

str.strip([chars])

   Return a copy of the string with the leading and trailing
   characters removed. The *chars* argument is a string specifying the
   set of characters to be removed. If omitted or "None", the *chars*
   argument defaults to removing whitespace. The *chars* argument is
   not a prefix or suffix; rather, all combinations of its values are
   stripped:

      >>> '   spacious   '.strip()
      'spacious'
      >>> 'www.example.com'.strip('cmowz.')
      'example'

   The outermost leading and trailing *chars* argument values are
   stripped from the string. Characters are removed from the leading
   end until reaching a string character that is not contained in the
   set of characters in *chars*. A similar action takes place on the
   trailing end. For example:

      >>> comment_string = '#....... Section 3.2.1 Issue #32 .......'
      >>> comment_string.strip('.#! ')
      'Section 3.2.1 Issue #32'

str.swapcase()

   Return a copy of the string with uppercase characters converted to
   lowercase and vice versa. Note that it is not necessarily true that
   "s.swapcase().swapcase() == s".

str.title()

   Return a titlecased version of the string where words start with an
   uppercase character and the remaining characters are lowercase.

   For example:

      >>> 'Hello world'.title()
      'Hello World'

   The algorithm uses a simple language-independent definition of a
   word as groups of consecutive letters.  The definition works in
   many contexts but it means that apostrophes in contractions and
   possessives form word boundaries, which may not be the desired
   result:

      >>> "they're bill's friends from the UK".title()
      "They'Re Bill'S Friends From The Uk"

   A workaround for apostrophes can be constructed using regular
   expressions:

      >>> import re
      >>> def titlecase(s):
      ...     return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
      ...                   lambda mo: mo.group(0).capitalize(),
      ...                   s)
      ...
      >>> titlecase("they're bill's friends.")
      "They're Bill's Friends."

str.translate(table)

   Return a copy of the string in which each character has been mapped
   through the given translation table.  The table must be an object
   that implements indexing via "__getitem__()", typically a *mapping*
   or *sequence*.  When indexed by a Unicode ordinal (an integer), the
   table object can do any of the following: return a Unicode ordinal
   or a string, to map the character to one or more other characters;
   return "None", to delete the character from the return string; or
   raise a "LookupError" exception, to map the character to itself.

   You can use "str.maketrans()" to create a translation map from
   character-to-character mappings in different formats.

   See also the "codecs" module for a more flexible approach to custom
   character mappings.

str.upper()

   Return a copy of the string with all the cased characters [4]
   converted to uppercase.  Note that "s.upper().isupper()" might be
   "False" if "s" contains uncased characters or if the Unicode
   category of the resulting character(s) is not “Lu” (Letter,
   uppercase), but e.g. “Lt” (Letter, titlecase).

   The uppercasing algorithm used is described in section 3.13 of the
   Unicode Standard.

str.zfill(width)

   Return a copy of the string left filled with ASCII "'0'" digits to
   make a string of length *width*. A leading sign prefix
   ("'+'"/"'-'") is handled by inserting the padding *after* the sign
   character rather than before. The original string is returned if
   *width* is less than or equal to "len(s)".

   For example:

      >>> "42".zfill(5)
      '00042'
      >>> "-42".zfill(5)
      '-0042'
u� String and Bytes literals
*************************

String literals are described by the following lexical definitions:

   stringliteral   ::= [stringprefix](shortstring | longstring)
   stringprefix    ::= "r" | "u" | "R" | "U" | "f" | "F"
                    | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
   shortstring     ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
   longstring      ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
   shortstringitem ::= shortstringchar | stringescapeseq
   longstringitem  ::= longstringchar | stringescapeseq
   shortstringchar ::= <any source character except "\" or newline or the quote>
   longstringchar  ::= <any source character except "\">
   stringescapeseq ::= "\" <any source character>

   bytesliteral   ::= bytesprefix(shortbytes | longbytes)
   bytesprefix    ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"
   shortbytes     ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
   longbytes      ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
   shortbytesitem ::= shortbyteschar | bytesescapeseq
   longbytesitem  ::= longbyteschar | bytesescapeseq
   shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
   longbyteschar  ::= <any ASCII character except "\">
   bytesescapeseq ::= "\" <any ASCII character>

One syntactic restriction not indicated by these productions is that
whitespace is not allowed between the "stringprefix" or "bytesprefix"
and the rest of the literal. The source character set is defined by
the encoding declaration; it is UTF-8 if no encoding declaration is
given in the source file; see section Encoding declarations.

In plain English: Both types of literals can be enclosed in matching
single quotes ("'") or double quotes (""").  They can also be enclosed
in matching groups of three single or double quotes (these are
generally referred to as *triple-quoted strings*).  The backslash
("\") character is used to escape characters that otherwise have a
special meaning, such as newline, backslash itself, or the quote
character.

Bytes literals are always prefixed with "'b'" or "'B'"; they produce
an instance of the "bytes" type instead of the "str" type.  They may
only contain ASCII characters; bytes with a numeric value of 128 or
greater must be expressed with escapes.

Both string and bytes literals may optionally be prefixed with a
letter "'r'" or "'R'"; such strings are called *raw strings* and treat
backslashes as literal characters.  As a result, in string literals,
"'\U'" and "'\u'" escapes in raw strings are not treated specially.
Given that Python 2.x’s raw unicode literals behave differently than
Python 3.x’s the "'ur'" syntax is not supported.

New in version 3.3: The "'rb'" prefix of raw bytes literals has been
added as a synonym of "'br'".

New in version 3.3: Support for the unicode legacy literal
("u'value'") was reintroduced to simplify the maintenance of dual
Python 2.x and 3.x codebases. See **PEP 414** for more information.

A string literal with "'f'" or "'F'" in its prefix is a *formatted
string literal*; see Formatted string literals.  The "'f'" may be
combined with "'r'", but not with "'b'" or "'u'", therefore raw
formatted strings are possible, but formatted bytes literals are not.

In triple-quoted literals, unescaped newlines and quotes are allowed
(and are retained), except that three unescaped quotes in a row
terminate the literal.  (A “quote” is the character used to open the
literal, i.e. either "'" or """.)

Unless an "'r'" or "'R'" prefix is present, escape sequences in string
and bytes literals are interpreted according to rules similar to those
used by Standard C.  The recognized escape sequences are:

+-------------------+-----------------------------------+---------+
| Escape Sequence   | Meaning                           | Notes   |
|===================|===================================|=========|
| "\newline"        | Backslash and newline ignored     |         |
+-------------------+-----------------------------------+---------+
| "\\"              | Backslash ("\")                   |         |
+-------------------+-----------------------------------+---------+
| "\'"              | Single quote ("'")                |         |
+-------------------+-----------------------------------+---------+
| "\""              | Double quote (""")                |         |
+-------------------+-----------------------------------+---------+
| "\a"              | ASCII Bell (BEL)                  |         |
+-------------------+-----------------------------------+---------+
| "\b"              | ASCII Backspace (BS)              |         |
+-------------------+-----------------------------------+---------+
| "\f"              | ASCII Formfeed (FF)               |         |
+-------------------+-----------------------------------+---------+
| "\n"              | ASCII Linefeed (LF)               |         |
+-------------------+-----------------------------------+---------+
| "\r"              | ASCII Carriage Return (CR)        |         |
+-------------------+-----------------------------------+---------+
| "\t"              | ASCII Horizontal Tab (TAB)        |         |
+-------------------+-----------------------------------+---------+
| "\v"              | ASCII Vertical Tab (VT)           |         |
+-------------------+-----------------------------------+---------+
| "\ooo"            | Character with octal value *ooo*  | (1,3)   |
+-------------------+-----------------------------------+---------+
| "\xhh"            | Character with hex value *hh*     | (2,3)   |
+-------------------+-----------------------------------+---------+

Escape sequences only recognized in string literals are:

+-------------------+-----------------------------------+---------+
| Escape Sequence   | Meaning                           | Notes   |
|===================|===================================|=========|
| "\N{name}"        | Character named *name* in the     | (4)     |
|                   | Unicode database                  |         |
+-------------------+-----------------------------------+---------+
| "\uxxxx"          | Character with 16-bit hex value   | (5)     |
|                   | *xxxx*                            |         |
+-------------------+-----------------------------------+---------+
| "\Uxxxxxxxx"      | Character with 32-bit hex value   | (6)     |
|                   | *xxxxxxxx*                        |         |
+-------------------+-----------------------------------+---------+

Notes:

1. As in Standard C, up to three octal digits are accepted.

2. Unlike in Standard C, exactly two hex digits are required.

3. In a bytes literal, hexadecimal and octal escapes denote the byte
   with the given value. In a string literal, these escapes denote a
   Unicode character with the given value.

4. Changed in version 3.3: Support for name aliases [1] has been
   added.

5. Exactly four hex digits are required.

6. Any Unicode character can be encoded this way.  Exactly eight hex
   digits are required.

Unlike Standard C, all unrecognized escape sequences are left in the
string unchanged, i.e., *the backslash is left in the result*.  (This
behavior is useful when debugging: if an escape sequence is mistyped,
the resulting output is more easily recognized as broken.)  It is also
important to note that the escape sequences only recognized in string
literals fall into the category of unrecognized escapes for bytes
literals.

   Changed in version 3.6: Unrecognized escape sequences produce a
   "DeprecationWarning".  In a future Python version they will be a
   "SyntaxWarning" and eventually a "SyntaxError".

Even in a raw literal, quotes can be escaped with a backslash, but the
backslash remains in the result; for example, "r"\""" is a valid
string literal consisting of two characters: a backslash and a double
quote; "r"\"" is not a valid string literal (even a raw string cannot
end in an odd number of backslashes).  Specifically, *a raw literal
cannot end in a single backslash* (since the backslash would escape
the following quote character).  Note also that a single backslash
followed by a newline is interpreted as those two characters as part
of the literal, *not* as a line continuation.
uMSubscriptions
*************

A subscription selects an item of a sequence (string, tuple or list)
or mapping (dictionary) object:

   subscription ::= primary "[" expression_list "]"

The primary must evaluate to an object that supports subscription
(lists or dictionaries for example).  User-defined objects can support
subscription by defining a "__getitem__()" method.

For built-in objects, there are two types of objects that support
subscription:

If the primary is a mapping, the expression list must evaluate to an
object whose value is one of the keys of the mapping, and the
subscription selects the value in the mapping that corresponds to that
key.  (The expression list is a tuple except if it has exactly one
item.)

If the primary is a sequence, the expression list must evaluate to an
integer or a slice (as discussed in the following section).

The formal syntax makes no special provision for negative indices in
sequences; however, built-in sequences all provide a "__getitem__()"
method that interprets negative indices by adding the length of the
sequence to the index (so that "x[-1]" selects the last item of "x").
The resulting value must be a nonnegative integer less than the number
of items in the sequence, and the subscription selects the item whose
index is that value (counting from zero). Since the support for
negative indices and slicing occurs in the object’s "__getitem__()"
method, subclasses overriding this method will need to explicitly add
that support.

A string’s items are characters.  A character is not a separate data
type but a string of exactly one character.
axTruth Value Testing
*******************

Any object can be tested for truth value, for use in an "if" or
"while" condition or as operand of the Boolean operations below.

By default, an object is considered true unless its class defines
either a "__bool__()" method that returns "False" or a "__len__()"
method that returns zero, when called with the object. [1]  Here are
most of the built-in objects considered false:

* constants defined to be false: "None" and "False".

* zero of any numeric type: "0", "0.0", "0j", "Decimal(0)",
  "Fraction(0, 1)"

* empty sequences and collections: "''", "()", "[]", "{}", "set()",
  "range(0)"

Operations and built-in functions that have a Boolean result always
return "0" or "False" for false and "1" or "True" for true, unless
otherwise stated. (Important exception: the Boolean operations "or"
and "and" always return one of their operands.)
uRThe "try" statement
*******************

The "try" statement specifies exception handlers and/or cleanup code
for a group of statements:

   try_stmt  ::= try1_stmt | try2_stmt
   try1_stmt ::= "try" ":" suite
                 ("except" [expression ["as" identifier]] ":" suite)+
                 ["else" ":" suite]
                 ["finally" ":" suite]
   try2_stmt ::= "try" ":" suite
                 "finally" ":" suite

The "except" clause(s) specify one or more exception handlers. When no
exception occurs in the "try" clause, no exception handler is
executed. When an exception occurs in the "try" suite, a search for an
exception handler is started.  This search inspects the except clauses
in turn until one is found that matches the exception.  An expression-
less except clause, if present, must be last; it matches any
exception.  For an except clause with an expression, that expression
is evaluated, and the clause matches the exception if the resulting
object is “compatible” with the exception.  An object is compatible
with an exception if it is the class or a base class of the exception
object, or a tuple containing an item that is the class or a base
class of the exception object.

If no except clause matches the exception, the search for an exception
handler continues in the surrounding code and on the invocation stack.
[1]

If the evaluation of an expression in the header of an except clause
raises an exception, the original search for a handler is canceled and
a search starts for the new exception in the surrounding code and on
the call stack (it is treated as if the entire "try" statement raised
the exception).

When a matching except clause is found, the exception is assigned to
the target specified after the "as" keyword in that except clause, if
present, and the except clause’s suite is executed.  All except
clauses must have an executable block.  When the end of this block is
reached, execution continues normally after the entire try statement.
(This means that if two nested handlers exist for the same exception,
and the exception occurs in the try clause of the inner handler, the
outer handler will not handle the exception.)

When an exception has been assigned using "as target", it is cleared
at the end of the except clause.  This is as if

   except E as N:
       foo

was translated to

   except E as N:
       try:
           foo
       finally:
           del N

This means the exception must be assigned to a different name to be
able to refer to it after the except clause.  Exceptions are cleared
because with the traceback attached to them, they form a reference
cycle with the stack frame, keeping all locals in that frame alive
until the next garbage collection occurs.

Before an except clause’s suite is executed, details about the
exception are stored in the "sys" module and can be accessed via
"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the
exception class, the exception instance and a traceback object (see
section The standard type hierarchy) identifying the point in the
program where the exception occurred.  "sys.exc_info()" values are
restored to their previous values (before the call) when returning
from a function that handled an exception.

The optional "else" clause is executed if the control flow leaves the
"try" suite, no exception was raised, and no "return", "continue", or
"break" statement was executed.  Exceptions in the "else" clause are
not handled by the preceding "except" clauses.

If "finally" is present, it specifies a ‘cleanup’ handler.  The "try"
clause is executed, including any "except" and "else" clauses.  If an
exception occurs in any of the clauses and is not handled, the
exception is temporarily saved. The "finally" clause is executed.  If
there is a saved exception it is re-raised at the end of the "finally"
clause.  If the "finally" clause raises another exception, the saved
exception is set as the context of the new exception. If the "finally"
clause executes a "return", "break" or "continue" statement, the saved
exception is discarded:

   >>> def f():
   ...     try:
   ...         1/0
   ...     finally:
   ...         return 42
   ...
   >>> f()
   42

The exception information is not available to the program during
execution of the "finally" clause.

When a "return", "break" or "continue" statement is executed in the
"try" suite of a "try"…"finally" statement, the "finally" clause is
also executed ‘on the way out.’

The return value of a function is determined by the last "return"
statement executed.  Since the "finally" clause always executes, a
"return" statement executed in the "finally" clause will always be the
last one executed:

   >>> def foo():
   ...     try:
   ...         return 'try'
   ...     finally:
   ...         return 'finally'
   ...
   >>> foo()
   'finally'

Additional information on exceptions can be found in section
Exceptions, and information on using the "raise" statement to generate
exceptions may be found in section The raise statement.

Changed in version 3.8: Prior to Python 3.8, a "continue" statement
was illegal in the "finally" clause due to a problem with the
implementation.
ux�The standard type hierarchy
***************************

Below is a list of the types that are built into Python.  Extension
modules (written in C, Java, or other languages, depending on the
implementation) can define additional types.  Future versions of
Python may add types to the type hierarchy (e.g., rational numbers,
efficiently stored arrays of integers, etc.), although such additions
will often be provided via the standard library instead.

Some of the type descriptions below contain a paragraph listing
‘special attributes.’  These are attributes that provide access to the
implementation and are not intended for general use.  Their definition
may change in the future.

None
   This type has a single value.  There is a single object with this
   value. This object is accessed through the built-in name "None". It
   is used to signify the absence of a value in many situations, e.g.,
   it is returned from functions that don’t explicitly return
   anything. Its truth value is false.

NotImplemented
   This type has a single value.  There is a single object with this
   value. This object is accessed through the built-in name
   "NotImplemented". Numeric methods and rich comparison methods
   should return this value if they do not implement the operation for
   the operands provided.  (The interpreter will then try the
   reflected operation, or some other fallback, depending on the
   operator.)  Its truth value is true.

   See Implementing the arithmetic operations for more details.

Ellipsis
   This type has a single value.  There is a single object with this
   value. This object is accessed through the literal "..." or the
   built-in name "Ellipsis".  Its truth value is true.

"numbers.Number"
   These are created by numeric literals and returned as results by
   arithmetic operators and arithmetic built-in functions.  Numeric
   objects are immutable; once created their value never changes.
   Python numbers are of course strongly related to mathematical
   numbers, but subject to the limitations of numerical representation
   in computers.

   The string representations of the numeric classes, computed by
   "__repr__()" and "__str__()", have the following properties:

   * They are valid numeric literals which, when passed to their class
     constructor, produce an object having the value of the original
     numeric.

   * The representation is in base 10, when possible.

   * Leading zeros, possibly excepting a single zero before a decimal
     point, are not shown.

   * Trailing zeros, possibly excepting a single zero after a decimal
     point, are not shown.

   * A sign is shown only when the number is negative.

   Python distinguishes between integers, floating point numbers, and
   complex numbers:

   "numbers.Integral"
      These represent elements from the mathematical set of integers
      (positive and negative).

      There are two types of integers:

      Integers ("int")
         These represent numbers in an unlimited range, subject to
         available (virtual) memory only.  For the purpose of shift
         and mask operations, a binary representation is assumed, and
         negative numbers are represented in a variant of 2’s
         complement which gives the illusion of an infinite string of
         sign bits extending to the left.

      Booleans ("bool")
         These represent the truth values False and True.  The two
         objects representing the values "False" and "True" are the
         only Boolean objects. The Boolean type is a subtype of the
         integer type, and Boolean values behave like the values 0 and
         1, respectively, in almost all contexts, the exception being
         that when converted to a string, the strings ""False"" or
         ""True"" are returned, respectively.

      The rules for integer representation are intended to give the
      most meaningful interpretation of shift and mask operations
      involving negative integers.

   "numbers.Real" ("float")
      These represent machine-level double precision floating point
      numbers. You are at the mercy of the underlying machine
      architecture (and C or Java implementation) for the accepted
      range and handling of overflow. Python does not support single-
      precision floating point numbers; the savings in processor and
      memory usage that are usually the reason for using these are
      dwarfed by the overhead of using objects in Python, so there is
      no reason to complicate the language with two kinds of floating
      point numbers.

   "numbers.Complex" ("complex")
      These represent complex numbers as a pair of machine-level
      double precision floating point numbers.  The same caveats apply
      as for floating point numbers. The real and imaginary parts of a
      complex number "z" can be retrieved through the read-only
      attributes "z.real" and "z.imag".

Sequences
   These represent finite ordered sets indexed by non-negative
   numbers. The built-in function "len()" returns the number of items
   of a sequence. When the length of a sequence is *n*, the index set
   contains the numbers 0, 1, …, *n*-1.  Item *i* of sequence *a* is
   selected by "a[i]".

   Sequences also support slicing: "a[i:j]" selects all items with
   index *k* such that *i* "<=" *k* "<" *j*.  When used as an
   expression, a slice is a sequence of the same type.  This implies
   that the index set is renumbered so that it starts at 0.

   Some sequences also support “extended slicing” with a third “step”
   parameter: "a[i:j:k]" selects all items of *a* with index *x* where
   "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.

   Sequences are distinguished according to their mutability:

   Immutable sequences
      An object of an immutable sequence type cannot change once it is
      created.  (If the object contains references to other objects,
      these other objects may be mutable and may be changed; however,
      the collection of objects directly referenced by an immutable
      object cannot change.)

      The following types are immutable sequences:

      Strings
         A string is a sequence of values that represent Unicode code
         points. All the code points in the range "U+0000 - U+10FFFF"
         can be represented in a string.  Python doesn’t have a "char"
         type; instead, every code point in the string is represented
         as a string object with length "1".  The built-in function
         "ord()" converts a code point from its string form to an
         integer in the range "0 - 10FFFF"; "chr()" converts an
         integer in the range "0 - 10FFFF" to the corresponding length
         "1" string object. "str.encode()" can be used to convert a
         "str" to "bytes" using the given text encoding, and
         "bytes.decode()" can be used to achieve the opposite.

      Tuples
         The items of a tuple are arbitrary Python objects. Tuples of
         two or more items are formed by comma-separated lists of
         expressions.  A tuple of one item (a ‘singleton’) can be
         formed by affixing a comma to an expression (an expression by
         itself does not create a tuple, since parentheses must be
         usable for grouping of expressions).  An empty tuple can be
         formed by an empty pair of parentheses.

      Bytes
         A bytes object is an immutable array.  The items are 8-bit
         bytes, represented by integers in the range 0 <= x < 256.
         Bytes literals (like "b'abc'") and the built-in "bytes()"
         constructor can be used to create bytes objects.  Also, bytes
         objects can be decoded to strings via the "decode()" method.

   Mutable sequences
      Mutable sequences can be changed after they are created.  The
      subscription and slicing notations can be used as the target of
      assignment and "del" (delete) statements.

      There are currently two intrinsic mutable sequence types:

      Lists
         The items of a list are arbitrary Python objects.  Lists are
         formed by placing a comma-separated list of expressions in
         square brackets. (Note that there are no special cases needed
         to form lists of length 0 or 1.)

      Byte Arrays
         A bytearray object is a mutable array. They are created by
         the built-in "bytearray()" constructor.  Aside from being
         mutable (and hence unhashable), byte arrays otherwise provide
         the same interface and functionality as immutable "bytes"
         objects.

      The extension module "array" provides an additional example of a
      mutable sequence type, as does the "collections" module.

Set types
   These represent unordered, finite sets of unique, immutable
   objects. As such, they cannot be indexed by any subscript. However,
   they can be iterated over, and the built-in function "len()"
   returns the number of items in a set. Common uses for sets are fast
   membership testing, removing duplicates from a sequence, and
   computing mathematical operations such as intersection, union,
   difference, and symmetric difference.

   For set elements, the same immutability rules apply as for
   dictionary keys. Note that numeric types obey the normal rules for
   numeric comparison: if two numbers compare equal (e.g., "1" and
   "1.0"), only one of them can be contained in a set.

   There are currently two intrinsic set types:

   Sets
      These represent a mutable set. They are created by the built-in
      "set()" constructor and can be modified afterwards by several
      methods, such as "add()".

   Frozen sets
      These represent an immutable set.  They are created by the
      built-in "frozenset()" constructor.  As a frozenset is immutable
      and *hashable*, it can be used again as an element of another
      set, or as a dictionary key.

Mappings
   These represent finite sets of objects indexed by arbitrary index
   sets. The subscript notation "a[k]" selects the item indexed by "k"
   from the mapping "a"; this can be used in expressions and as the
   target of assignments or "del" statements. The built-in function
   "len()" returns the number of items in a mapping.

   There is currently a single intrinsic mapping type:

   Dictionaries
      These represent finite sets of objects indexed by nearly
      arbitrary values.  The only types of values not acceptable as
      keys are values containing lists or dictionaries or other
      mutable types that are compared by value rather than by object
      identity, the reason being that the efficient implementation of
      dictionaries requires a key’s hash value to remain constant.
      Numeric types used for keys obey the normal rules for numeric
      comparison: if two numbers compare equal (e.g., "1" and "1.0")
      then they can be used interchangeably to index the same
      dictionary entry.

      Dictionaries preserve insertion order, meaning that keys will be
      produced in the same order they were added sequentially over the
      dictionary. Replacing an existing key does not change the order,
      however removing a key and re-inserting it will add it to the
      end instead of keeping its old place.

      Dictionaries are mutable; they can be created by the "{...}"
      notation (see section Dictionary displays).

      The extension modules "dbm.ndbm" and "dbm.gnu" provide
      additional examples of mapping types, as does the "collections"
      module.

      Changed in version 3.7: Dictionaries did not preserve insertion
      order in versions of Python before 3.6. In CPython 3.6,
      insertion order was preserved, but it was considered an
      implementation detail at that time rather than a language
      guarantee.

Callable types
   These are the types to which the function call operation (see
   section Calls) can be applied:

   User-defined functions
      A user-defined function object is created by a function
      definition (see section Function definitions).  It should be
      called with an argument list containing the same number of items
      as the function’s formal parameter list.

      Special attributes:

      +---------------------------+---------------------------------+-------------+
      | Attribute                 | Meaning                         |             |
      |===========================|=================================|=============|
      | "__doc__"                 | The function’s documentation    | Writable    |
      |                           | string, or "None" if            |             |
      |                           | unavailable; not inherited by   |             |
      |                           | subclasses.                     |             |
      +---------------------------+---------------------------------+-------------+
      | "__name__"                | The function’s name.            | Writable    |
      +---------------------------+---------------------------------+-------------+
      | "__qualname__"            | The function’s *qualified       | Writable    |
      |                           | name*.  New in version 3.3.     |             |
      +---------------------------+---------------------------------+-------------+
      | "__module__"              | The name of the module the      | Writable    |
      |                           | function was defined in, or     |             |
      |                           | "None" if unavailable.          |             |
      +---------------------------+---------------------------------+-------------+
      | "__defaults__"            | A tuple containing default      | Writable    |
      |                           | argument values for those       |             |
      |                           | arguments that have defaults,   |             |
      |                           | or "None" if no arguments have  |             |
      |                           | a default value.                |             |
      +---------------------------+---------------------------------+-------------+
      | "__code__"                | The code object representing    | Writable    |
      |                           | the compiled function body.     |             |
      +---------------------------+---------------------------------+-------------+
      | "__globals__"             | A reference to the dictionary   | Read-only   |
      |                           | that holds the function’s       |             |
      |                           | global variables — the global   |             |
      |                           | namespace of the module in      |             |
      |                           | which the function was defined. |             |
      +---------------------------+---------------------------------+-------------+
      | "__dict__"                | The namespace supporting        | Writable    |
      |                           | arbitrary function attributes.  |             |
      +---------------------------+---------------------------------+-------------+
      | "__closure__"             | "None" or a tuple of cells that | Read-only   |
      |                           | contain bindings for the        |             |
      |                           | function’s free variables. See  |             |
      |                           | below for information on the    |             |
      |                           | "cell_contents" attribute.      |             |
      +---------------------------+---------------------------------+-------------+
      | "__annotations__"         | A dict containing annotations   | Writable    |
      |                           | of parameters.  The keys of the |             |
      |                           | dict are the parameter names,   |             |
      |                           | and "'return'" for the return   |             |
      |                           | annotation, if provided.        |             |
      +---------------------------+---------------------------------+-------------+
      | "__kwdefaults__"          | A dict containing defaults for  | Writable    |
      |                           | keyword-only parameters.        |             |
      +---------------------------+---------------------------------+-------------+

      Most of the attributes labelled “Writable” check the type of the
      assigned value.

      Function objects also support getting and setting arbitrary
      attributes, which can be used, for example, to attach metadata
      to functions.  Regular attribute dot-notation is used to get and
      set such attributes. *Note that the current implementation only
      supports function attributes on user-defined functions. Function
      attributes on built-in functions may be supported in the
      future.*

      A cell object has the attribute "cell_contents". This can be
      used to get the value of the cell, as well as set the value.

      Additional information about a function’s definition can be
      retrieved from its code object; see the description of internal
      types below. The "cell" type can be accessed in the "types"
      module.

   Instance methods
      An instance method object combines a class, a class instance and
      any callable object (normally a user-defined function).

      Special read-only attributes: "__self__" is the class instance
      object, "__func__" is the function object; "__doc__" is the
      method’s documentation (same as "__func__.__doc__"); "__name__"
      is the method name (same as "__func__.__name__"); "__module__"
      is the name of the module the method was defined in, or "None"
      if unavailable.

      Methods also support accessing (but not setting) the arbitrary
      function attributes on the underlying function object.

      User-defined method objects may be created when getting an
      attribute of a class (perhaps via an instance of that class), if
      that attribute is a user-defined function object or a class
      method object.

      When an instance method object is created by retrieving a user-
      defined function object from a class via one of its instances,
      its "__self__" attribute is the instance, and the method object
      is said to be bound.  The new method’s "__func__" attribute is
      the original function object.

      When an instance method object is created by retrieving a class
      method object from a class or instance, its "__self__" attribute
      is the class itself, and its "__func__" attribute is the
      function object underlying the class method.

      When an instance method object is called, the underlying
      function ("__func__") is called, inserting the class instance
      ("__self__") in front of the argument list.  For instance, when
      "C" is a class which contains a definition for a function "f()",
      and "x" is an instance of "C", calling "x.f(1)" is equivalent to
      calling "C.f(x, 1)".

      When an instance method object is derived from a class method
      object, the “class instance” stored in "__self__" will actually
      be the class itself, so that calling either "x.f(1)" or "C.f(1)"
      is equivalent to calling "f(C,1)" where "f" is the underlying
      function.

      Note that the transformation from function object to instance
      method object happens each time the attribute is retrieved from
      the instance.  In some cases, a fruitful optimization is to
      assign the attribute to a local variable and call that local
      variable. Also notice that this transformation only happens for
      user-defined functions; other callable objects (and all non-
      callable objects) are retrieved without transformation.  It is
      also important to note that user-defined functions which are
      attributes of a class instance are not converted to bound
      methods; this *only* happens when the function is an attribute
      of the class.

   Generator functions
      A function or method which uses the "yield" statement (see
      section The yield statement) is called a *generator function*.
      Such a function, when called, always returns an iterator object
      which can be used to execute the body of the function:  calling
      the iterator’s "iterator.__next__()" method will cause the
      function to execute until it provides a value using the "yield"
      statement.  When the function executes a "return" statement or
      falls off the end, a "StopIteration" exception is raised and the
      iterator will have reached the end of the set of values to be
      returned.

   Coroutine functions
      A function or method which is defined using "async def" is
      called a *coroutine function*.  Such a function, when called,
      returns a *coroutine* object.  It may contain "await"
      expressions, as well as "async with" and "async for" statements.
      See also the Coroutine Objects section.

   Asynchronous generator functions
      A function or method which is defined using "async def" and
      which uses the "yield" statement is called a *asynchronous
      generator function*.  Such a function, when called, returns an
      asynchronous iterator object which can be used in an "async for"
      statement to execute the body of the function.

      Calling the asynchronous iterator’s "aiterator.__anext__()"
      method will return an *awaitable* which when awaited will
      execute until it provides a value using the "yield" expression.
      When the function executes an empty "return" statement or falls
      off the end, a "StopAsyncIteration" exception is raised and the
      asynchronous iterator will have reached the end of the set of
      values to be yielded.

   Built-in functions
      A built-in function object is a wrapper around a C function.
      Examples of built-in functions are "len()" and "math.sin()"
      ("math" is a standard built-in module). The number and type of
      the arguments are determined by the C function. Special read-
      only attributes: "__doc__" is the function’s documentation
      string, or "None" if unavailable; "__name__" is the function’s
      name; "__self__" is set to "None" (but see the next item);
      "__module__" is the name of the module the function was defined
      in or "None" if unavailable.

   Built-in methods
      This is really a different disguise of a built-in function, this
      time containing an object passed to the C function as an
      implicit extra argument.  An example of a built-in method is
      "alist.append()", assuming *alist* is a list object. In this
      case, the special read-only attribute "__self__" is set to the
      object denoted by *alist*.

   Classes
      Classes are callable.  These objects normally act as factories
      for new instances of themselves, but variations are possible for
      class types that override "__new__()".  The arguments of the
      call are passed to "__new__()" and, in the typical case, to
      "__init__()" to initialize the new instance.

   Class Instances
      Instances of arbitrary classes can be made callable by defining
      a "__call__()" method in their class.

Modules
   Modules are a basic organizational unit of Python code, and are
   created by the import system as invoked either by the "import"
   statement, or by calling functions such as
   "importlib.import_module()" and built-in "__import__()".  A module
   object has a namespace implemented by a dictionary object (this is
   the dictionary referenced by the "__globals__" attribute of
   functions defined in the module).  Attribute references are
   translated to lookups in this dictionary, e.g., "m.x" is equivalent
   to "m.__dict__["x"]". A module object does not contain the code
   object used to initialize the module (since it isn’t needed once
   the initialization is done).

   Attribute assignment updates the module’s namespace dictionary,
   e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".

   Predefined (writable) attributes: "__name__" is the module’s name;
   "__doc__" is the module’s documentation string, or "None" if
   unavailable; "__annotations__" (optional) is a dictionary
   containing *variable annotations* collected during module body
   execution; "__file__" is the pathname of the file from which the
   module was loaded, if it was loaded from a file. The "__file__"
   attribute may be missing for certain types of modules, such as C
   modules that are statically linked into the interpreter; for
   extension modules loaded dynamically from a shared library, it is
   the pathname of the shared library file.

   Special read-only attribute: "__dict__" is the module’s namespace
   as a dictionary object.

   **CPython implementation detail:** Because of the way CPython
   clears module dictionaries, the module dictionary will be cleared
   when the module falls out of scope even if the dictionary still has
   live references.  To avoid this, copy the dictionary or keep the
   module around while using its dictionary directly.

Custom classes
   Custom class types are typically created by class definitions (see
   section Class definitions).  A class has a namespace implemented by
   a dictionary object. Class attribute references are translated to
   lookups in this dictionary, e.g., "C.x" is translated to
   "C.__dict__["x"]" (although there are a number of hooks which allow
   for other means of locating attributes). When the attribute name is
   not found there, the attribute search continues in the base
   classes. This search of the base classes uses the C3 method
   resolution order which behaves correctly even in the presence of
   ‘diamond’ inheritance structures where there are multiple
   inheritance paths leading back to a common ancestor. Additional
   details on the C3 MRO used by Python can be found in the
   documentation accompanying the 2.3 release at
   https://www.python.org/download/releases/2.3/mro/.

   When a class attribute reference (for class "C", say) would yield a
   class method object, it is transformed into an instance method
   object whose "__self__" attribute is "C".  When it would yield a
   static method object, it is transformed into the object wrapped by
   the static method object. See section Implementing Descriptors for
   another way in which attributes retrieved from a class may differ
   from those actually contained in its "__dict__".

   Class attribute assignments update the class’s dictionary, never
   the dictionary of a base class.

   A class object can be called (see above) to yield a class instance
   (see below).

   Special attributes: "__name__" is the class name; "__module__" is
   the module name in which the class was defined; "__dict__" is the
   dictionary containing the class’s namespace; "__bases__" is a tuple
   containing the base classes, in the order of their occurrence in
   the base class list; "__doc__" is the class’s documentation string,
   or "None" if undefined; "__annotations__" (optional) is a
   dictionary containing *variable annotations* collected during class
   body execution.

Class instances
   A class instance is created by calling a class object (see above).
   A class instance has a namespace implemented as a dictionary which
   is the first place in which attribute references are searched.
   When an attribute is not found there, and the instance’s class has
   an attribute by that name, the search continues with the class
   attributes.  If a class attribute is found that is a user-defined
   function object, it is transformed into an instance method object
   whose "__self__" attribute is the instance.  Static method and
   class method objects are also transformed; see above under
   “Classes”.  See section Implementing Descriptors for another way in
   which attributes of a class retrieved via its instances may differ
   from the objects actually stored in the class’s "__dict__".  If no
   class attribute is found, and the object’s class has a
   "__getattr__()" method, that is called to satisfy the lookup.

   Attribute assignments and deletions update the instance’s
   dictionary, never a class’s dictionary.  If the class has a
   "__setattr__()" or "__delattr__()" method, this is called instead
   of updating the instance dictionary directly.

   Class instances can pretend to be numbers, sequences, or mappings
   if they have methods with certain special names.  See section
   Special method names.

   Special attributes: "__dict__" is the attribute dictionary;
   "__class__" is the instance’s class.

I/O objects (also known as file objects)
   A *file object* represents an open file.  Various shortcuts are
   available to create file objects: the "open()" built-in function,
   and also "os.popen()", "os.fdopen()", and the "makefile()" method
   of socket objects (and perhaps by other functions or methods
   provided by extension modules).

   The objects "sys.stdin", "sys.stdout" and "sys.stderr" are
   initialized to file objects corresponding to the interpreter’s
   standard input, output and error streams; they are all open in text
   mode and therefore follow the interface defined by the
   "io.TextIOBase" abstract class.

Internal types
   A few types used internally by the interpreter are exposed to the
   user. Their definitions may change with future versions of the
   interpreter, but they are mentioned here for completeness.

   Code objects
      Code objects represent *byte-compiled* executable Python code,
      or *bytecode*. The difference between a code object and a
      function object is that the function object contains an explicit
      reference to the function’s globals (the module in which it was
      defined), while a code object contains no context; also the
      default argument values are stored in the function object, not
      in the code object (because they represent values calculated at
      run-time).  Unlike function objects, code objects are immutable
      and contain no references (directly or indirectly) to mutable
      objects.

      Special read-only attributes: "co_name" gives the function name;
      "co_argcount" is the total number of positional arguments
      (including positional-only arguments and arguments with default
      values); "co_posonlyargcount" is the number of positional-only
      arguments (including arguments with default values);
      "co_kwonlyargcount" is the number of keyword-only arguments
      (including arguments with default values); "co_nlocals" is the
      number of local variables used by the function (including
      arguments); "co_varnames" is a tuple containing the names of the
      local variables (starting with the argument names);
      "co_cellvars" is a tuple containing the names of local variables
      that are referenced by nested functions; "co_freevars" is a
      tuple containing the names of free variables; "co_code" is a
      string representing the sequence of bytecode instructions;
      "co_consts" is a tuple containing the literals used by the
      bytecode; "co_names" is a tuple containing the names used by the
      bytecode; "co_filename" is the filename from which the code was
      compiled; "co_firstlineno" is the first line number of the
      function; "co_lnotab" is a string encoding the mapping from
      bytecode offsets to line numbers (for details see the source
      code of the interpreter); "co_stacksize" is the required stack
      size; "co_flags" is an integer encoding a number of flags for
      the interpreter.

      The following flag bits are defined for "co_flags": bit "0x04"
      is set if the function uses the "*arguments" syntax to accept an
      arbitrary number of positional arguments; bit "0x08" is set if
      the function uses the "**keywords" syntax to accept arbitrary
      keyword arguments; bit "0x20" is set if the function is a
      generator.

      Future feature declarations ("from __future__ import division")
      also use bits in "co_flags" to indicate whether a code object
      was compiled with a particular feature enabled: bit "0x2000" is
      set if the function was compiled with future division enabled;
      bits "0x10" and "0x1000" were used in earlier versions of
      Python.

      Other bits in "co_flags" are reserved for internal use.

      If a code object represents a function, the first item in
      "co_consts" is the documentation string of the function, or
      "None" if undefined.

   Frame objects
      Frame objects represent execution frames.  They may occur in
      traceback objects (see below), and are also passed to registered
      trace functions.

      Special read-only attributes: "f_back" is to the previous stack
      frame (towards the caller), or "None" if this is the bottom
      stack frame; "f_code" is the code object being executed in this
      frame; "f_locals" is the dictionary used to look up local
      variables; "f_globals" is used for global variables;
      "f_builtins" is used for built-in (intrinsic) names; "f_lasti"
      gives the precise instruction (this is an index into the
      bytecode string of the code object).

      Accessing "f_code" raises an auditing event "object.__getattr__"
      with arguments "obj" and ""f_code"".

      Special writable attributes: "f_trace", if not "None", is a
      function called for various events during code execution (this
      is used by the debugger). Normally an event is triggered for
      each new source line - this can be disabled by setting
      "f_trace_lines" to "False".

      Implementations *may* allow per-opcode events to be requested by
      setting "f_trace_opcodes" to "True". Note that this may lead to
      undefined interpreter behaviour if exceptions raised by the
      trace function escape to the function being traced.

      "f_lineno" is the current line number of the frame — writing to
      this from within a trace function jumps to the given line (only
      for the bottom-most frame).  A debugger can implement a Jump
      command (aka Set Next Statement) by writing to f_lineno.

      Frame objects support one method:

      frame.clear()

         This method clears all references to local variables held by
         the frame.  Also, if the frame belonged to a generator, the
         generator is finalized.  This helps break reference cycles
         involving frame objects (for example when catching an
         exception and storing its traceback for later use).

         "RuntimeError" is raised if the frame is currently executing.

         New in version 3.4.

   Traceback objects
      Traceback objects represent a stack trace of an exception.  A
      traceback object is implicitly created when an exception occurs,
      and may also be explicitly created by calling
      "types.TracebackType".

      For implicitly created tracebacks, when the search for an
      exception handler unwinds the execution stack, at each unwound
      level a traceback object is inserted in front of the current
      traceback.  When an exception handler is entered, the stack
      trace is made available to the program. (See section The try
      statement.) It is accessible as the third item of the tuple
      returned by "sys.exc_info()", and as the "__traceback__"
      attribute of the caught exception.

      When the program contains no suitable handler, the stack trace
      is written (nicely formatted) to the standard error stream; if
      the interpreter is interactive, it is also made available to the
      user as "sys.last_traceback".

      For explicitly created tracebacks, it is up to the creator of
      the traceback to determine how the "tb_next" attributes should
      be linked to form a full stack trace.

      Special read-only attributes: "tb_frame" points to the execution
      frame of the current level; "tb_lineno" gives the line number
      where the exception occurred; "tb_lasti" indicates the precise
      instruction. The line number and last instruction in the
      traceback may differ from the line number of its frame object if
      the exception occurred in a "try" statement with no matching
      except clause or with a finally clause.

      Accessing "tb_frame" raises an auditing event
      "object.__getattr__" with arguments "obj" and ""tb_frame"".

      Special writable attribute: "tb_next" is the next level in the
      stack trace (towards the frame where the exception occurred), or
      "None" if there is no next level.

      Changed in version 3.7: Traceback objects can now be explicitly
      instantiated from Python code, and the "tb_next" attribute of
      existing instances can be updated.

   Slice objects
      Slice objects are used to represent slices for "__getitem__()"
      methods.  They are also created by the built-in "slice()"
      function.

      Special read-only attributes: "start" is the lower bound; "stop"
      is the upper bound; "step" is the step value; each is "None" if
      omitted.  These attributes can have any type.

      Slice objects support one method:

      slice.indices(self, length)

         This method takes a single integer argument *length* and
         computes information about the slice that the slice object
         would describe if applied to a sequence of *length* items.
         It returns a tuple of three integers; respectively these are
         the *start* and *stop* indices and the *step* or stride
         length of the slice. Missing or out-of-bounds indices are
         handled in a manner consistent with regular slices.

   Static method objects
      Static method objects provide a way of defeating the
      transformation of function objects to method objects described
      above. A static method object is a wrapper around any other
      object, usually a user-defined method object. When a static
      method object is retrieved from a class or a class instance, the
      object actually returned is the wrapped object, which is not
      subject to any further transformation. Static method objects are
      not themselves callable, although the objects they wrap usually
      are. Static method objects are created by the built-in
      "staticmethod()" constructor.

   Class method objects
      A class method object, like a static method object, is a wrapper
      around another object that alters the way in which that object
      is retrieved from classes and class instances. The behaviour of
      class method objects upon such retrieval is described above,
      under “User-defined methods”. Class method objects are created
      by the built-in "classmethod()" constructor.
a�Functions
*********

Function objects are created by function definitions.  The only
operation on a function object is to call it: "func(argument-list)".

There are really two flavors of function objects: built-in functions
and user-defined functions.  Both support the same operation (to call
the function), but the implementation is different, hence the
different object types.

See Function definitions for more information.
u(.Mapping Types — "dict"
**********************

A *mapping* object maps *hashable* values to arbitrary objects.
Mappings are mutable objects.  There is currently only one standard
mapping type, the *dictionary*.  (For other containers see the built-
in "list", "set", and "tuple" classes, and the "collections" module.)

A dictionary’s keys are *almost* arbitrary values.  Values that are
not *hashable*, that is, values containing lists, dictionaries or
other mutable types (that are compared by value rather than by object
identity) may not be used as keys.  Numeric types used for keys obey
the normal rules for numeric comparison: if two numbers compare equal
(such as "1" and "1.0") then they can be used interchangeably to index
the same dictionary entry.  (Note however, that since computers store
floating-point numbers as approximations it is usually unwise to use
them as dictionary keys.)

Dictionaries can be created by placing a comma-separated list of "key:
value" pairs within braces, for example: "{'jack': 4098, 'sjoerd':
4127}" or "{4098: 'jack', 4127: 'sjoerd'}", or by the "dict"
constructor.

class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)

   Return a new dictionary initialized from an optional positional
   argument and a possibly empty set of keyword arguments.

   Dictionaries can be created by several means:

   * Use a comma-separated list of "key: value" pairs within braces:
     "{'jack': 4098, 'sjoerd': 4127}" or "{4098: 'jack', 4127:
     'sjoerd'}"

   * Use a dict comprehension: "{}", "{x: x ** 2 for x in range(10)}"

   * Use the type constructor: "dict()", "dict([('foo', 100), ('bar',
     200)])", "dict(foo=100, bar=200)"

   If no positional argument is given, an empty dictionary is created.
   If a positional argument is given and it is a mapping object, a
   dictionary is created with the same key-value pairs as the mapping
   object.  Otherwise, the positional argument must be an *iterable*
   object.  Each item in the iterable must itself be an iterable with
   exactly two objects.  The first object of each item becomes a key
   in the new dictionary, and the second object the corresponding
   value.  If a key occurs more than once, the last value for that key
   becomes the corresponding value in the new dictionary.

   If keyword arguments are given, the keyword arguments and their
   values are added to the dictionary created from the positional
   argument.  If a key being added is already present, the value from
   the keyword argument replaces the value from the positional
   argument.

   To illustrate, the following examples all return a dictionary equal
   to "{"one": 1, "two": 2, "three": 3}":

      >>> a = dict(one=1, two=2, three=3)
      >>> b = {'one': 1, 'two': 2, 'three': 3}
      >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
      >>> d = dict([('two', 2), ('one', 1), ('three', 3)])
      >>> e = dict({'three': 3, 'one': 1, 'two': 2})
      >>> a == b == c == d == e
      True

   Providing keyword arguments as in the first example only works for
   keys that are valid Python identifiers.  Otherwise, any valid keys
   can be used.

   These are the operations that dictionaries support (and therefore,
   custom mapping types should support too):

   list(d)

      Return a list of all the keys used in the dictionary *d*.

   len(d)

      Return the number of items in the dictionary *d*.

   d[key]

      Return the item of *d* with key *key*.  Raises a "KeyError" if
      *key* is not in the map.

      If a subclass of dict defines a method "__missing__()" and *key*
      is not present, the "d[key]" operation calls that method with
      the key *key* as argument.  The "d[key]" operation then returns
      or raises whatever is returned or raised by the
      "__missing__(key)" call. No other operations or methods invoke
      "__missing__()". If "__missing__()" is not defined, "KeyError"
      is raised. "__missing__()" must be a method; it cannot be an
      instance variable:

         >>> class Counter(dict):
         ...     def __missing__(self, key):
         ...         return 0
         >>> c = Counter()
         >>> c['red']
         0
         >>> c['red'] += 1
         >>> c['red']
         1

      The example above shows part of the implementation of
      "collections.Counter".  A different "__missing__" method is used
      by "collections.defaultdict".

   d[key] = value

      Set "d[key]" to *value*.

   del d[key]

      Remove "d[key]" from *d*.  Raises a "KeyError" if *key* is not
      in the map.

   key in d

      Return "True" if *d* has a key *key*, else "False".

   key not in d

      Equivalent to "not key in d".

   iter(d)

      Return an iterator over the keys of the dictionary.  This is a
      shortcut for "iter(d.keys())".

   clear()

      Remove all items from the dictionary.

   copy()

      Return a shallow copy of the dictionary.

   classmethod fromkeys(iterable[, value])

      Create a new dictionary with keys from *iterable* and values set
      to *value*.

      "fromkeys()" is a class method that returns a new dictionary.
      *value* defaults to "None".  All of the values refer to just a
      single instance, so it generally doesn’t make sense for *value*
      to be a mutable object such as an empty list.  To get distinct
      values, use a dict comprehension instead.

   get(key[, default])

      Return the value for *key* if *key* is in the dictionary, else
      *default*. If *default* is not given, it defaults to "None", so
      that this method never raises a "KeyError".

   items()

      Return a new view of the dictionary’s items ("(key, value)"
      pairs). See the documentation of view objects.

   keys()

      Return a new view of the dictionary’s keys.  See the
      documentation of view objects.

   pop(key[, default])

      If *key* is in the dictionary, remove it and return its value,
      else return *default*.  If *default* is not given and *key* is
      not in the dictionary, a "KeyError" is raised.

   popitem()

      Remove and return a "(key, value)" pair from the dictionary.
      Pairs are returned in LIFO (last-in, first-out) order.

      "popitem()" is useful to destructively iterate over a
      dictionary, as often used in set algorithms.  If the dictionary
      is empty, calling "popitem()" raises a "KeyError".

      Changed in version 3.7: LIFO order is now guaranteed. In prior
      versions, "popitem()" would return an arbitrary key/value pair.

   reversed(d)

      Return a reverse iterator over the keys of the dictionary. This
      is a shortcut for "reversed(d.keys())".

      New in version 3.8.

   setdefault(key[, default])

      If *key* is in the dictionary, return its value.  If not, insert
      *key* with a value of *default* and return *default*.  *default*
      defaults to "None".

   update([other])

      Update the dictionary with the key/value pairs from *other*,
      overwriting existing keys.  Return "None".

      "update()" accepts either another dictionary object or an
      iterable of key/value pairs (as tuples or other iterables of
      length two).  If keyword arguments are specified, the dictionary
      is then updated with those key/value pairs: "d.update(red=1,
      blue=2)".

   values()

      Return a new view of the dictionary’s values.  See the
      documentation of view objects.

      An equality comparison between one "dict.values()" view and
      another will always return "False". This also applies when
      comparing "dict.values()" to itself:

         >>> d = {'a': 1}
         >>> d.values() == d.values()
         False

   Dictionaries compare equal if and only if they have the same "(key,
   value)" pairs (regardless of ordering). Order comparisons (‘<’,
   ‘<=’, ‘>=’, ‘>’) raise "TypeError".

   Dictionaries preserve insertion order.  Note that updating a key
   does not affect the order.  Keys added after deletion are inserted
   at the end.

      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
      >>> d
      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
      >>> list(d)
      ['one', 'two', 'three', 'four']
      >>> list(d.values())
      [1, 2, 3, 4]
      >>> d["one"] = 42
      >>> d
      {'one': 42, 'two': 2, 'three': 3, 'four': 4}
      >>> del d["two"]
      >>> d["two"] = None
      >>> d
      {'one': 42, 'three': 3, 'four': 4, 'two': None}

   Changed in version 3.7: Dictionary order is guaranteed to be
   insertion order.  This behavior was an implementation detail of
   CPython from 3.6.

   Dictionaries and dictionary views are reversible.

      >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
      >>> d
      {'one': 1, 'two': 2, 'three': 3, 'four': 4}
      >>> list(reversed(d))
      ['four', 'three', 'two', 'one']
      >>> list(reversed(d.values()))
      [4, 3, 2, 1]
      >>> list(reversed(d.items()))
      [('four', 4), ('three', 3), ('two', 2), ('one', 1)]

   Changed in version 3.8: Dictionaries are now reversible.

See also:

  "types.MappingProxyType" can be used to create a read-only view of a
  "dict".


Dictionary view objects
=======================

The objects returned by "dict.keys()", "dict.values()" and
"dict.items()" are *view objects*.  They provide a dynamic view on the
dictionary’s entries, which means that when the dictionary changes,
the view reflects these changes.

Dictionary views can be iterated over to yield their respective data,
and support membership tests:

len(dictview)

   Return the number of entries in the dictionary.

iter(dictview)

   Return an iterator over the keys, values or items (represented as
   tuples of "(key, value)") in the dictionary.

   Keys and values are iterated over in insertion order. This allows
   the creation of "(value, key)" pairs using "zip()": "pairs =
   zip(d.values(), d.keys())".  Another way to create the same list is
   "pairs = [(v, k) for (k, v) in d.items()]".

   Iterating views while adding or deleting entries in the dictionary
   may raise a "RuntimeError" or fail to iterate over all entries.

   Changed in version 3.7: Dictionary order is guaranteed to be
   insertion order.

x in dictview

   Return "True" if *x* is in the underlying dictionary’s keys, values
   or items (in the latter case, *x* should be a "(key, value)"
   tuple).

reversed(dictview)

   Return a reverse iterator over the keys, values or items of the
   dictionary. The view will be iterated in reverse order of the
   insertion.

   Changed in version 3.8: Dictionary views are now reversible.

Keys views are set-like since their entries are unique and hashable.
If all values are hashable, so that "(key, value)" pairs are unique
and hashable, then the items view is also set-like.  (Values views are
not treated as set-like since the entries are generally not unique.)
For set-like views, all of the operations defined for the abstract
base class "collections.abc.Set" are available (for example, "==",
"<", or "^").

An example of dictionary view usage:

   >>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
   >>> keys = dishes.keys()
   >>> values = dishes.values()

   >>> # iteration
   >>> n = 0
   >>> for val in values:
   ...     n += val
   >>> print(n)
   504

   >>> # keys and values are iterated over in the same order (insertion order)
   >>> list(keys)
   ['eggs', 'sausage', 'bacon', 'spam']
   >>> list(values)
   [2, 1, 1, 500]

   >>> # view objects are dynamic and reflect dict changes
   >>> del dishes['eggs']
   >>> del dishes['sausage']
   >>> list(keys)
   ['bacon', 'spam']

   >>> # set operations
   >>> keys & {'eggs', 'bacon', 'salad'}
   {'bacon'}
   >>> keys ^ {'sausage', 'juice'}
   {'juice', 'sausage', 'bacon', 'spam'}
a�Methods
*******

Methods are functions that are called using the attribute notation.
There are two flavors: built-in methods (such as "append()" on lists)
and class instance methods.  Built-in methods are described with the
types that support them.

If you access a method (a function defined in a class namespace)
through an instance, you get a special object: a *bound method* (also
called *instance method*) object. When called, it will add the "self"
argument to the argument list.  Bound methods have two special read-
only attributes: "m.__self__" is the object on which the method
operates, and "m.__func__" is the function implementing the method.
Calling "m(arg-1, arg-2, ..., arg-n)" is completely equivalent to
calling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".

Like function objects, bound method objects support getting arbitrary
attributes.  However, since method attributes are actually stored on
the underlying function object ("meth.__func__"), setting method
attributes on bound methods is disallowed.  Attempting to set an
attribute on a method results in an "AttributeError" being raised.  In
order to set a method attribute, you need to explicitly set it on the
underlying function object:

   >>> class C:
   ...     def method(self):
   ...         pass
   ...
   >>> c = C()
   >>> c.method.whoami = 'my name is method'  # can't set on the method
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   AttributeError: 'method' object has no attribute 'whoami'
   >>> c.method.__func__.whoami = 'my name is method'
   >>> c.method.whoami
   'my name is method'

See The standard type hierarchy for more information.
u$Modules
*******

The only special operation on a module is attribute access: "m.name",
where *m* is a module and *name* accesses a name defined in *m*’s
symbol table. Module attributes can be assigned to.  (Note that the
"import" statement is not, strictly speaking, an operation on a module
object; "import foo" does not require a module object named *foo* to
exist, rather it requires an (external) *definition* for a module
named *foo* somewhere.)

A special attribute of every module is "__dict__". This is the
dictionary containing the module’s symbol table. Modifying this
dictionary will actually change the module’s symbol table, but direct
assignment to the "__dict__" attribute is not possible (you can write
"m.__dict__['a'] = 1", which defines "m.a" to be "1", but you can’t
write "m.__dict__ = {}").  Modifying "__dict__" directly is not
recommended.

Modules built into the interpreter are written like this: "<module
'sys' (built-in)>".  If loaded from a file, they are written as
"<module 'os' from '/usr/local/lib/pythonX.Y/os.pyc'>".
u�ZSequence Types — "list", "tuple", "range"
*****************************************

There are three basic sequence types: lists, tuples, and range
objects. Additional sequence types tailored for processing of binary
data and text strings are described in dedicated sections.


Common Sequence Operations
==========================

The operations in the following table are supported by most sequence
types, both mutable and immutable. The "collections.abc.Sequence" ABC
is provided to make it easier to correctly implement these operations
on custom sequence types.

This table lists the sequence operations sorted in ascending priority.
In the table, *s* and *t* are sequences of the same type, *n*, *i*,
*j* and *k* are integers and *x* is an arbitrary object that meets any
type and value restrictions imposed by *s*.

The "in" and "not in" operations have the same priorities as the
comparison operations. The "+" (concatenation) and "*" (repetition)
operations have the same priority as the corresponding numeric
operations. [3]

+----------------------------+----------------------------------+------------+
| Operation                  | Result                           | Notes      |
|============================|==================================|============|
| "x in s"                   | "True" if an item of *s* is      | (1)        |
|                            | equal to *x*, else "False"       |            |
+----------------------------+----------------------------------+------------+
| "x not in s"               | "False" if an item of *s* is     | (1)        |
|                            | equal to *x*, else "True"        |            |
+----------------------------+----------------------------------+------------+
| "s + t"                    | the concatenation of *s* and *t* | (6)(7)     |
+----------------------------+----------------------------------+------------+
| "s * n" or "n * s"         | equivalent to adding *s* to      | (2)(7)     |
|                            | itself *n* times                 |            |
+----------------------------+----------------------------------+------------+
| "s[i]"                     | *i*th item of *s*, origin 0      | (3)        |
+----------------------------+----------------------------------+------------+
| "s[i:j]"                   | slice of *s* from *i* to *j*     | (3)(4)     |
+----------------------------+----------------------------------+------------+
| "s[i:j:k]"                 | slice of *s* from *i* to *j*     | (3)(5)     |
|                            | with step *k*                    |            |
+----------------------------+----------------------------------+------------+
| "len(s)"                   | length of *s*                    |            |
+----------------------------+----------------------------------+------------+
| "min(s)"                   | smallest item of *s*             |            |
+----------------------------+----------------------------------+------------+
| "max(s)"                   | largest item of *s*              |            |
+----------------------------+----------------------------------+------------+
| "s.index(x[, i[, j]])"     | index of the first occurrence of | (8)        |
|                            | *x* in *s* (at or after index    |            |
|                            | *i* and before index *j*)        |            |
+----------------------------+----------------------------------+------------+
| "s.count(x)"               | total number of occurrences of   |            |
|                            | *x* in *s*                       |            |
+----------------------------+----------------------------------+------------+

Sequences of the same type also support comparisons.  In particular,
tuples and lists are compared lexicographically by comparing
corresponding elements. This means that to compare equal, every
element must compare equal and the two sequences must be of the same
type and have the same length.  (For full details see Comparisons in
the language reference.)

Notes:

1. While the "in" and "not in" operations are used only for simple
   containment testing in the general case, some specialised sequences
   (such as "str", "bytes" and "bytearray") also use them for
   subsequence testing:

      >>> "gg" in "eggs"
      True

2. Values of *n* less than "0" are treated as "0" (which yields an
   empty sequence of the same type as *s*).  Note that items in the
   sequence *s* are not copied; they are referenced multiple times.
   This often haunts new Python programmers; consider:

      >>> lists = [[]] * 3
      >>> lists
      [[], [], []]
      >>> lists[0].append(3)
      >>> lists
      [[3], [3], [3]]

   What has happened is that "[[]]" is a one-element list containing
   an empty list, so all three elements of "[[]] * 3" are references
   to this single empty list.  Modifying any of the elements of
   "lists" modifies this single list. You can create a list of
   different lists this way:

      >>> lists = [[] for i in range(3)]
      >>> lists[0].append(3)
      >>> lists[1].append(5)
      >>> lists[2].append(7)
      >>> lists
      [[3], [5], [7]]

   Further explanation is available in the FAQ entry How do I create a
   multidimensional list?.

3. If *i* or *j* is negative, the index is relative to the end of
   sequence *s*: "len(s) + i" or "len(s) + j" is substituted.  But
   note that "-0" is still "0".

4. The slice of *s* from *i* to *j* is defined as the sequence of
   items with index *k* such that "i <= k < j".  If *i* or *j* is
   greater than "len(s)", use "len(s)".  If *i* is omitted or "None",
   use "0".  If *j* is omitted or "None", use "len(s)".  If *i* is
   greater than or equal to *j*, the slice is empty.

5. The slice of *s* from *i* to *j* with step *k* is defined as the
   sequence of items with index  "x = i + n*k" such that "0 <= n <
   (j-i)/k".  In other words, the indices are "i", "i+k", "i+2*k",
   "i+3*k" and so on, stopping when *j* is reached (but never
   including *j*).  When *k* is positive, *i* and *j* are reduced to
   "len(s)" if they are greater. When *k* is negative, *i* and *j* are
   reduced to "len(s) - 1" if they are greater.  If *i* or *j* are
   omitted or "None", they become “end” values (which end depends on
   the sign of *k*).  Note, *k* cannot be zero. If *k* is "None", it
   is treated like "1".

6. Concatenating immutable sequences always results in a new object.
   This means that building up a sequence by repeated concatenation
   will have a quadratic runtime cost in the total sequence length.
   To get a linear runtime cost, you must switch to one of the
   alternatives below:

   * if concatenating "str" objects, you can build a list and use
     "str.join()" at the end or else write to an "io.StringIO"
     instance and retrieve its value when complete

   * if concatenating "bytes" objects, you can similarly use
     "bytes.join()" or "io.BytesIO", or you can do in-place
     concatenation with a "bytearray" object.  "bytearray" objects are
     mutable and have an efficient overallocation mechanism

   * if concatenating "tuple" objects, extend a "list" instead

   * for other types, investigate the relevant class documentation

7. Some sequence types (such as "range") only support item sequences
   that follow specific patterns, and hence don’t support sequence
   concatenation or repetition.

8. "index" raises "ValueError" when *x* is not found in *s*. Not all
   implementations support passing the additional arguments *i* and
   *j*. These arguments allow efficient searching of subsections of
   the sequence. Passing the extra arguments is roughly equivalent to
   using "s[i:j].index(x)", only without copying any data and with the
   returned index being relative to the start of the sequence rather
   than the start of the slice.


Immutable Sequence Types
========================

The only operation that immutable sequence types generally implement
that is not also implemented by mutable sequence types is support for
the "hash()" built-in.

This support allows immutable sequences, such as "tuple" instances, to
be used as "dict" keys and stored in "set" and "frozenset" instances.

Attempting to hash an immutable sequence that contains unhashable
values will result in "TypeError".


Mutable Sequence Types
======================

The operations in the following table are defined on mutable sequence
types. The "collections.abc.MutableSequence" ABC is provided to make
it easier to correctly implement these operations on custom sequence
types.

In the table *s* is an instance of a mutable sequence type, *t* is any
iterable object and *x* is an arbitrary object that meets any type and
value restrictions imposed by *s* (for example, "bytearray" only
accepts integers that meet the value restriction "0 <= x <= 255").

+--------------------------------+----------------------------------+-----------------------+
| Operation                      | Result                           | Notes                 |
|================================|==================================|=======================|
| "s[i] = x"                     | item *i* of *s* is replaced by   |                       |
|                                | *x*                              |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j] = t"                   | slice of *s* from *i* to *j* is  |                       |
|                                | replaced by the contents of the  |                       |
|                                | iterable *t*                     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j]"                   | same as "s[i:j] = []"            |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j:k] = t"                 | the elements of "s[i:j:k]" are   | (1)                   |
|                                | replaced by those of *t*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j:k]"                 | removes the elements of          |                       |
|                                | "s[i:j:k]" from the list         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)"                  | appends *x* to the end of the    |                       |
|                                | sequence (same as                |                       |
|                                | "s[len(s):len(s)] = [x]")        |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()"                    | removes all items from *s* (same | (5)                   |
|                                | as "del s[:]")                   |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()"                     | creates a shallow copy of *s*    | (5)                   |
|                                | (same as "s[:]")                 |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t"      | extends *s* with the contents of |                       |
|                                | *t* (for the most part the same  |                       |
|                                | as "s[len(s):len(s)] = t")       |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n"                       | updates *s* with its contents    | (6)                   |
|                                | repeated *n* times               |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)"               | inserts *x* into *s* at the      |                       |
|                                | index given by *i* (same as      |                       |
|                                | "s[i:i] = [x]")                  |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)"        | retrieves the item at *i* and    | (2)                   |
|                                | also removes it from *s*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)"                  | remove the first item from *s*   | (3)                   |
|                                | where "s[i]" is equal to *x*     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()"                  | reverses the items of *s* in     | (4)                   |
|                                | place                            |                       |
+--------------------------------+----------------------------------+-----------------------+

Notes:

1. *t* must have the same length as the slice it is replacing.

2. The optional argument *i* defaults to "-1", so that by default the
   last item is removed and returned.

3. "remove()" raises "ValueError" when *x* is not found in *s*.

4. The "reverse()" method modifies the sequence in place for economy
   of space when reversing a large sequence.  To remind users that it
   operates by side effect, it does not return the reversed sequence.

5. "clear()" and "copy()" are included for consistency with the
   interfaces of mutable containers that don’t support slicing
   operations (such as "dict" and "set"). "copy()" is not part of the
   "collections.abc.MutableSequence" ABC, but most concrete mutable
   sequence classes provide it.

   New in version 3.3: "clear()" and "copy()" methods.

6. The value *n* is an integer, or an object implementing
   "__index__()".  Zero and negative values of *n* clear the sequence.
   Items in the sequence are not copied; they are referenced multiple
   times, as explained for "s * n" under Common Sequence Operations.


Lists
=====

Lists are mutable sequences, typically used to store collections of
homogeneous items (where the precise degree of similarity will vary by
application).

class list([iterable])

   Lists may be constructed in several ways:

   * Using a pair of square brackets to denote the empty list: "[]"

   * Using square brackets, separating items with commas: "[a]", "[a,
     b, c]"

   * Using a list comprehension: "[x for x in iterable]"

   * Using the type constructor: "list()" or "list(iterable)"

   The constructor builds a list whose items are the same and in the
   same order as *iterable*’s items.  *iterable* may be either a
   sequence, a container that supports iteration, or an iterator
   object.  If *iterable* is already a list, a copy is made and
   returned, similar to "iterable[:]". For example, "list('abc')"
   returns "['a', 'b', 'c']" and "list( (1, 2, 3) )" returns "[1, 2,
   3]". If no argument is given, the constructor creates a new empty
   list, "[]".

   Many other operations also produce lists, including the "sorted()"
   built-in.

   Lists implement all of the common and mutable sequence operations.
   Lists also provide the following additional method:

   sort(*, key=None, reverse=False)

      This method sorts the list in place, using only "<" comparisons
      between items. Exceptions are not suppressed - if any comparison
      operations fail, the entire sort operation will fail (and the
      list will likely be left in a partially modified state).

      "sort()" accepts two arguments that can only be passed by
      keyword (keyword-only arguments):

      *key* specifies a function of one argument that is used to
      extract a comparison key from each list element (for example,
      "key=str.lower"). The key corresponding to each item in the list
      is calculated once and then used for the entire sorting process.
      The default value of "None" means that list items are sorted
      directly without calculating a separate key value.

      The "functools.cmp_to_key()" utility is available to convert a
      2.x style *cmp* function to a *key* function.

      *reverse* is a boolean value.  If set to "True", then the list
      elements are sorted as if each comparison were reversed.

      This method modifies the sequence in place for economy of space
      when sorting a large sequence.  To remind users that it operates
      by side effect, it does not return the sorted sequence (use
      "sorted()" to explicitly request a new sorted list instance).

      The "sort()" method is guaranteed to be stable.  A sort is
      stable if it guarantees not to change the relative order of
      elements that compare equal — this is helpful for sorting in
      multiple passes (for example, sort by department, then by salary
      grade).

      For sorting examples and a brief sorting tutorial, see Sorting
      HOW TO.

      **CPython implementation detail:** While a list is being sorted,
      the effect of attempting to mutate, or even inspect, the list is
      undefined.  The C implementation of Python makes the list appear
      empty for the duration, and raises "ValueError" if it can detect
      that the list has been mutated during a sort.


Tuples
======

Tuples are immutable sequences, typically used to store collections of
heterogeneous data (such as the 2-tuples produced by the "enumerate()"
built-in). Tuples are also used for cases where an immutable sequence
of homogeneous data is needed (such as allowing storage in a "set" or
"dict" instance).

class tuple([iterable])

   Tuples may be constructed in a number of ways:

   * Using a pair of parentheses to denote the empty tuple: "()"

   * Using a trailing comma for a singleton tuple: "a," or "(a,)"

   * Separating items with commas: "a, b, c" or "(a, b, c)"

   * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"

   The constructor builds a tuple whose items are the same and in the
   same order as *iterable*’s items.  *iterable* may be either a
   sequence, a container that supports iteration, or an iterator
   object.  If *iterable* is already a tuple, it is returned
   unchanged. For example, "tuple('abc')" returns "('a', 'b', 'c')"
   and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is
   given, the constructor creates a new empty tuple, "()".

   Note that it is actually the comma which makes a tuple, not the
   parentheses. The parentheses are optional, except in the empty
   tuple case, or when they are needed to avoid syntactic ambiguity.
   For example, "f(a, b, c)" is a function call with three arguments,
   while "f((a, b, c))" is a function call with a 3-tuple as the sole
   argument.

   Tuples implement all of the common sequence operations.

For heterogeneous collections of data where access by name is clearer
than access by index, "collections.namedtuple()" may be a more
appropriate choice than a simple tuple object.


Ranges
======

The "range" type represents an immutable sequence of numbers and is
commonly used for looping a specific number of times in "for" loops.

class range(stop)
class range(start, stop[, step])

   The arguments to the range constructor must be integers (either
   built-in "int" or any object that implements the "__index__"
   special method).  If the *step* argument is omitted, it defaults to
   "1". If the *start* argument is omitted, it defaults to "0". If
   *step* is zero, "ValueError" is raised.

   For a positive *step*, the contents of a range "r" are determined
   by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <
   stop".

   For a negative *step*, the contents of the range are still
   determined by the formula "r[i] = start + step*i", but the
   constraints are "i >= 0" and "r[i] > stop".

   A range object will be empty if "r[0]" does not meet the value
   constraint. Ranges do support negative indices, but these are
   interpreted as indexing from the end of the sequence determined by
   the positive indices.

   Ranges containing absolute values larger than "sys.maxsize" are
   permitted but some features (such as "len()") may raise
   "OverflowError".

   Range examples:

      >>> list(range(10))
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      >>> list(range(1, 11))
      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      >>> list(range(0, 30, 5))
      [0, 5, 10, 15, 20, 25]
      >>> list(range(0, 10, 3))
      [0, 3, 6, 9]
      >>> list(range(0, -10, -1))
      [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
      >>> list(range(0))
      []
      >>> list(range(1, 0))
      []

   Ranges implement all of the common sequence operations except
   concatenation and repetition (due to the fact that range objects
   can only represent sequences that follow a strict pattern and
   repetition and concatenation will usually violate that pattern).

   start

      The value of the *start* parameter (or "0" if the parameter was
      not supplied)

   stop

      The value of the *stop* parameter

   step

      The value of the *step* parameter (or "1" if the parameter was
      not supplied)

The advantage of the "range" type over a regular "list" or "tuple" is
that a "range" object will always take the same (small) amount of
memory, no matter the size of the range it represents (as it only
stores the "start", "stop" and "step" values, calculating individual
items and subranges as needed).

Range objects implement the "collections.abc.Sequence" ABC, and
provide features such as containment tests, element index lookup,
slicing and support for negative indices (see Sequence Types — list,
tuple, range):

>>> r = range(0, 20, 2)
>>> r
range(0, 20, 2)
>>> 11 in r
False
>>> 10 in r
True
>>> r.index(10)
5
>>> r[5]
10
>>> r[:5]
range(0, 10, 2)
>>> r[-1]
18

Testing range objects for equality with "==" and "!=" compares them as
sequences.  That is, two range objects are considered equal if they
represent the same sequence of values.  (Note that two range objects
that compare equal might have different "start", "stop" and "step"
attributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,
2) == range(0, 4, 2)".)

Changed in version 3.2: Implement the Sequence ABC. Support slicing
and negative indices. Test "int" objects for membership in constant
time instead of iterating through all items.

Changed in version 3.3: Define ‘==’ and ‘!=’ to compare range objects
based on the sequence of values they define (instead of comparing
based on object identity).

New in version 3.3: The "start", "stop" and "step" attributes.

See also:

  * The linspace recipe shows how to implement a lazy version of range
    suitable for floating point applications.
u�Mutable Sequence Types
**********************

The operations in the following table are defined on mutable sequence
types. The "collections.abc.MutableSequence" ABC is provided to make
it easier to correctly implement these operations on custom sequence
types.

In the table *s* is an instance of a mutable sequence type, *t* is any
iterable object and *x* is an arbitrary object that meets any type and
value restrictions imposed by *s* (for example, "bytearray" only
accepts integers that meet the value restriction "0 <= x <= 255").

+--------------------------------+----------------------------------+-----------------------+
| Operation                      | Result                           | Notes                 |
|================================|==================================|=======================|
| "s[i] = x"                     | item *i* of *s* is replaced by   |                       |
|                                | *x*                              |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j] = t"                   | slice of *s* from *i* to *j* is  |                       |
|                                | replaced by the contents of the  |                       |
|                                | iterable *t*                     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j]"                   | same as "s[i:j] = []"            |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s[i:j:k] = t"                 | the elements of "s[i:j:k]" are   | (1)                   |
|                                | replaced by those of *t*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "del s[i:j:k]"                 | removes the elements of          |                       |
|                                | "s[i:j:k]" from the list         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.append(x)"                  | appends *x* to the end of the    |                       |
|                                | sequence (same as                |                       |
|                                | "s[len(s):len(s)] = [x]")        |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.clear()"                    | removes all items from *s* (same | (5)                   |
|                                | as "del s[:]")                   |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.copy()"                     | creates a shallow copy of *s*    | (5)                   |
|                                | (same as "s[:]")                 |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.extend(t)" or "s += t"      | extends *s* with the contents of |                       |
|                                | *t* (for the most part the same  |                       |
|                                | as "s[len(s):len(s)] = t")       |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s *= n"                       | updates *s* with its contents    | (6)                   |
|                                | repeated *n* times               |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.insert(i, x)"               | inserts *x* into *s* at the      |                       |
|                                | index given by *i* (same as      |                       |
|                                | "s[i:i] = [x]")                  |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.pop()" or "s.pop(i)"        | retrieves the item at *i* and    | (2)                   |
|                                | also removes it from *s*         |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.remove(x)"                  | remove the first item from *s*   | (3)                   |
|                                | where "s[i]" is equal to *x*     |                       |
+--------------------------------+----------------------------------+-----------------------+
| "s.reverse()"                  | reverses the items of *s* in     | (4)                   |
|                                | place                            |                       |
+--------------------------------+----------------------------------+-----------------------+

Notes:

1. *t* must have the same length as the slice it is replacing.

2. The optional argument *i* defaults to "-1", so that by default the
   last item is removed and returned.

3. "remove()" raises "ValueError" when *x* is not found in *s*.

4. The "reverse()" method modifies the sequence in place for economy
   of space when reversing a large sequence.  To remind users that it
   operates by side effect, it does not return the reversed sequence.

5. "clear()" and "copy()" are included for consistency with the
   interfaces of mutable containers that don’t support slicing
   operations (such as "dict" and "set"). "copy()" is not part of the
   "collections.abc.MutableSequence" ABC, but most concrete mutable
   sequence classes provide it.

   New in version 3.3: "clear()" and "copy()" methods.

6. The value *n* is an integer, or an object implementing
   "__index__()".  Zero and negative values of *n* clear the sequence.
   Items in the sequence are not copied; they are referenced multiple
   times, as explained for "s * n" under Common Sequence Operations.
a~Unary arithmetic and bitwise operations
***************************************

All unary arithmetic and bitwise operations have the same priority:

   u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr

The unary "-" (minus) operator yields the negation of its numeric
argument.

The unary "+" (plus) operator yields its numeric argument unchanged.

The unary "~" (invert) operator yields the bitwise inversion of its
integer argument.  The bitwise inversion of "x" is defined as
"-(x+1)".  It only applies to integral numbers.

In all three cases, if the argument does not have the proper type, a
"TypeError" exception is raised.
u�The "while" statement
*********************

The "while" statement is used for repeated execution as long as an
expression is true:

   while_stmt ::= "while" assignment_expression ":" suite
                  ["else" ":" suite]

This repeatedly tests the expression and, if it is true, executes the
first suite; if the expression is false (which may be the first time
it is tested) the suite of the "else" clause, if present, is executed
and the loop terminates.

A "break" statement executed in the first suite terminates the loop
without executing the "else" clause’s suite.  A "continue" statement
executed in the first suite skips the rest of the suite and goes back
to testing the expression.
uMThe "with" statement
********************

The "with" statement is used to wrap the execution of a block with
methods defined by a context manager (see section With Statement
Context Managers). This allows common "try"…"except"…"finally" usage
patterns to be encapsulated for convenient reuse.

   with_stmt ::= "with" with_item ("," with_item)* ":" suite
   with_item ::= expression ["as" target]

The execution of the "with" statement with one “item” proceeds as
follows:

1. The context expression (the expression given in the "with_item") is
   evaluated to obtain a context manager.

2. The context manager’s "__enter__()" is loaded for later use.

3. The context manager’s "__exit__()" is loaded for later use.

4. The context manager’s "__enter__()" method is invoked.

5. If a target was included in the "with" statement, the return value
   from "__enter__()" is assigned to it.

   Note:

     The "with" statement guarantees that if the "__enter__()" method
     returns without an error, then "__exit__()" will always be
     called. Thus, if an error occurs during the assignment to the
     target list, it will be treated the same as an error occurring
     within the suite would be. See step 6 below.

6. The suite is executed.

7. The context manager’s "__exit__()" method is invoked.  If an
   exception caused the suite to be exited, its type, value, and
   traceback are passed as arguments to "__exit__()". Otherwise, three
   "None" arguments are supplied.

   If the suite was exited due to an exception, and the return value
   from the "__exit__()" method was false, the exception is reraised.
   If the return value was true, the exception is suppressed, and
   execution continues with the statement following the "with"
   statement.

   If the suite was exited for any reason other than an exception, the
   return value from "__exit__()" is ignored, and execution proceeds
   at the normal location for the kind of exit that was taken.

The following code:

   with EXPRESSION as TARGET:
       SUITE

is semantically equivalent to:

   manager = (EXPRESSION)
   enter = type(manager).__enter__
   exit = type(manager).__exit__
   value = enter(manager)
   hit_except = False

   try:
       TARGET = value
       SUITE
   except:
       hit_except = True
       if not exit(manager, *sys.exc_info()):
           raise
   finally:
       if not hit_except:
           exit(manager, None, None, None)

With more than one item, the context managers are processed as if
multiple "with" statements were nested:

   with A() as a, B() as b:
       SUITE

is semantically equivalent to:

   with A() as a:
       with B() as b:
           SUITE

Changed in version 3.1: Support for multiple context expressions.

See also:

  **PEP 343** - The “with” statement
     The specification, background, and examples for the Python "with"
     statement.
a,The "yield" statement
*********************

   yield_stmt ::= yield_expression

A "yield" statement is semantically equivalent to a yield expression.
The yield statement can be used to omit the parentheses that would
otherwise be required in the equivalent yield expression statement.
For example, the yield statements

   yield <expr>
   yield from <expr>

are equivalent to the yield expression statements

   (yield <expr>)
   (yield from <expr>)

Yield expressions and statements are only used when defining a
*generator* function, and are only used in the body of the generator
function.  Using yield in a function definition is sufficient to cause
that definition to create a generator function instead of a normal
function.

For full details of "yield" semantics, refer to the Yield expressions
section.
)O�assertZ
assignment�asynczatom-identifiersz
atom-literalszattribute-accesszattribute-referencesZ	augassign�awaitZbinaryZbitwisezbltin-code-objectszbltin-ellipsis-objectzbltin-null-objectzbltin-type-objectsZbooleans�breakzcallable-typesZcalls�classZcomparisonsZcompoundzcontext-managers�continueZconversionsZ
customizationZdebugger�del�dictzdynamic-features�else�
exceptionsZ	execmodelZ	exprlistsZfloating�forZ
formatstringsZfunction�globalz
id-classesZidentifiers�ifZ	imaginary�import�inZintegers�lambdaZlistsZnaming�nonlocalZnumbersz
numeric-typesZobjectszoperator-summary�passZpower�raise�returnzsequence-typesZshiftingZslicingsZspecialattrsZspecialnameszstring-methodsZstringsZ
subscriptions�truth�try�typesZtypesfunctionsZtypesmappingZtypesmethodsZtypesmodulesZtypesseqztypesseq-mutableZunary�while�with�yieldN)Ztopics�rr�)/usr/lib64/python3.8/pydoc_data/topics.py�<module>s'}(@	X1	=`bQ>J:3MD%I
H+1&.LN3"o#p3=^ai9;K9%Hh�������������������������������������������������������������������������������������������������������������PK�@�\��P2��response.cpython-36.opt-1.pycnu�[���3


 \��@s^dZddlZddddgZGdd�dej�ZGdd�de�ZGd	d�de�ZGd
d�de�ZdS)aResponse classes used by urllib.

The base class, addbase, defines a minimal file-like interface,
including read() and readline().  The typical response object is an
addinfourl instance, which defines an info() method that returns
headers and a geturl() method that returns the url.
�N�addbase�addclosehook�addinfo�
addinfourlcs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
rzOBase class for addinfo and addclosehook. Is a good idea for garbage collection.cs tt|�j|ddd�||_dS)Nz<urllib response>F)�delete)�superr�__init__�fp)�selfr	)�	__class__��'/usr/lib64/python3.6/urllib/response.pyrszaddbase.__init__cCsd|jjt|�|jfS)Nz<%s at %r whose fp = %r>)r�__name__�id�file)r
rrr
�__repr__szaddbase.__repr__cCs|jjrtd��|S)NzI/O operation on closed file)r	�closed�
ValueError)r
rrr
�	__enter__szaddbase.__enter__cCs|j�dS)N)�close)r
�type�value�	tracebackrrr
�__exit__!szaddbase.__exit__)	r�
__module__�__qualname__�__doc__rrrr�
__classcell__rr)rr
rs
cs,eZdZdZ�fdd�Z�fdd�Z�ZS)rz*Class to add a close hook to an open file.cs tt|�j|�||_||_dS)N)rrr�	closehook�hookargs)r
r	rr)rrr
r(szaddclosehook.__init__cs>z(|j}|j}|r&d|_d|_||�Wdtt|�j�XdS)N)rrrrr)r
rr)rrr
r-szaddclosehook.close)rrrrrrrrr)rr
r%scs(eZdZdZ�fdd�Zdd�Z�ZS)rz.class to add an info() method to an open file.cstt|�j|�||_dS)N)rrr�headers)r
r	r )rrr
r<szaddinfo.__init__cCs|jS)N)r )r
rrr
�info@szaddinfo.info)rrrrrr!rrr)rr
r9scs2eZdZdZd	�fdd�	Zdd�Zdd�Z�ZS)
rz9class to add info() and geturl() methods to an open file.Ncs"tt|�j||�||_||_dS)N)rrr�url�code)r
r	r r"r#)rrr
rGszaddinfourl.__init__cCs|jS)N)r#)r
rrr
�getcodeLszaddinfourl.getcodecCs|jS)N)r")r
rrr
�geturlOszaddinfourl.geturl)N)rrrrrr$r%rrr)rr
rDs)rZtempfile�__all__Z_TemporaryFileWrapperrrrrrrrr
�<module>sPK�@�\��d��
�
error.cpython-36.opt-1.pycnu�[���3


 \Q
�@sPdZddlZdddgZGdd�de�ZGdd�deejj�ZGdd�de�Z	dS)	a�Exception classes raised by urllib.

The base exception class is URLError, which inherits from OSError.  It
doesn't define any behavior of its own, but is the base class for all
exceptions defined in this package.

HTTPError is an exception class that is also a valid HTTP response
instance.  It behaves this way because HTTP protocol errors are valid
responses, with a status code, headers, and a body.  In some contexts,
an application may want to handle an exception like a regular
response.
�N�URLError�	HTTPError�ContentTooShortErrorc@seZdZddd�Zdd�ZdS)rNcCs |f|_||_|dk	r||_dS)N)�args�reason�filename)�selfrr�r	�$/usr/lib64/python3.6/urllib/error.py�__init__szURLError.__init__cCs
d|jS)Nz<urlopen error %s>)r)rr	r	r
�__str__szURLError.__str__)N)�__name__�
__module__�__qualname__rrr	r	r	r
rs
c@sXeZdZdZejjjZdd�Zdd�Z	dd�Z
edd	��Zed
d��Z
e
jdd��Z
d
S)rzBRaised when HTTP error occurs, but also acts like non-error returncCs:||_||_||_||_||_|dk	r6|j||||�dS)N)�code�msg�hdrs�fpr�_HTTPError__super_init)rZurlrrrrr	r	r
r'szHTTPError.__init__cCsd|j|jfS)NzHTTP Error %s: %s)rr)rr	r	r
r4szHTTPError.__str__cCsd|j|jfS)Nz<HTTPError %s: %r>)rr)rr	r	r
�__repr__7szHTTPError.__repr__cCs|jS)N)r)rr	r	r
r<szHTTPError.reasoncCs|jS)N)r)rr	r	r
�headers@szHTTPError.headerscCs
||_dS)N)r)rrr	r	r
rDsN)r
rr�__doc__�urllib�response�
addinfourlrrrr�propertyrr�setterr	r	r	r
r#s

c@seZdZdZdd�ZdS)rzDException raised when downloaded size does not match content-length.cCstj||�||_dS)N)rr�content)r�messagerr	r	r
rKszContentTooShortError.__init__N)r
rrrrr	r	r	r
rIs)
rZurllib.responser�__all__�OSErrorrrrrrr	r	r	r
�<module>s

&PK�@�\3<�Z
Z
response.cpython-36.opt-2.pycnu�[���3


 \��@sZddlZddddgZGdd�dej�ZGdd�de�ZGdd�de�ZGd	d�de�ZdS)
�N�addbase�addclosehook�addinfo�
addinfourlcs4eZdZ�fdd�Zdd�Zdd�Zdd�Z�ZS)	rcs tt|�j|ddd�||_dS)Nz<urllib response>F)�delete)�superr�__init__�fp)�selfr	)�	__class__��'/usr/lib64/python3.6/urllib/response.pyrszaddbase.__init__cCsd|jjt|�|jfS)Nz<%s at %r whose fp = %r>)r�__name__�id�file)r
rrr
�__repr__szaddbase.__repr__cCs|jjrtd��|S)NzI/O operation on closed file)r	�closed�
ValueError)r
rrr
�	__enter__szaddbase.__enter__cCs|j�dS)N)�close)r
�type�value�	tracebackrrr
�__exit__!szaddbase.__exit__)r�
__module__�__qualname__rrrr�
__classcell__rr)rr
rscs(eZdZ�fdd�Z�fdd�Z�ZS)rcs tt|�j|�||_||_dS)N)rrr�	closehook�hookargs)r
r	rr)rrr
r(szaddclosehook.__init__cs>z(|j}|j}|r&d|_d|_||�Wdtt|�j�XdS)N)rrrrr)r
rr)rrr
r-szaddclosehook.close)rrrrrrrr)rr
r%scs$eZdZ�fdd�Zdd�Z�ZS)rcstt|�j|�||_dS)N)rrr�headers)r
r	r)rrr
r<szaddinfo.__init__cCs|jS)N)r)r
rrr
�info@szaddinfo.info)rrrrr rrr)rr
r9scs.eZdZd�fdd�	Zdd�Zdd�Z�ZS)	rNcs"tt|�j||�||_||_dS)N)rrr�url�code)r
r	rr!r")rrr
rGszaddinfourl.__init__cCs|jS)N)r")r
rrr
�getcodeLszaddinfourl.getcodecCs|jS)N)r!)r
rrr
�geturlOszaddinfourl.geturl)N)rrrrr#r$rrr)rr
rDs)Ztempfile�__all__Z_TemporaryFileWrapperrrrrrrrr
�<module>	s
PK�@�\pl�	2�2�request.cpython-36.opt-2.pycnu�[���3

���i~��)@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+yddl,Z,Wne-k
�r"dZ.YnXdZ.ddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'g!Z/d(ej0dd)�Z1da2de
j3fddddd*�d+d�Z4d,d�Z5gZ6d}d-d$�Z7d.d%�Z8e	j9d/e	j:�Z;d0d1�Z<Gd2d�d�Z=Gd3d�d�Z>d4d �Z?Gd5d	�d	�Z@Gd6d�de@�ZAGd7d
�d
e@�ZBGd8d�de@�ZCd9d:�ZDGd;d
�d
e@�ZEGd<d�d�ZFGd=d�deF�ZGGd>d�deG�ZHGd?d�d�ZIGd@d�deIe@�ZJGdAd�deIe@�ZKejLZMGdBd�d�ZNGdCd�de@eN�ZOGdDd�de@eN�ZPGdEdF�dFe@�ZQGdGd�deQ�ZReSejTdH��r.GdIdJ�dJeQ�ZUe/jVdJ�GdKd�de@�ZWGdLd�de@�ZXdMdN�ZYdOdP�ZZGdQd�de@�Z[dRdS�Z\GdTd�de@�Z]GdUd�de]�Z^GdVd�de@�Z_dWZ`ejadXk�r�ddYlbmcZcmdZdndZd"�Zcd[d!�ZdiZeGd\d&�d&�ZfGd]d'�d'ef�Zgdahd^d_�Zidajd`da�Zkdaldbdc�Zmdanddde�ZoGdfdg�dg�Zpdhdi�Zqd~djdk�Zrdldm�Zsejtdnk�r�ddolumvZvmwZwdpdq�Zxdrds�Zydtdu�Zzdvd#�Z{n6ejadXk�r�dwdx�Z|dyd#�Z{dzd{�Z}d|du�ZzneqZ{erZzdS)�N)�URLError�	HTTPError�ContentTooShortError)�urlparse�urlsplit�urljoin�unwrap�quote�unquote�	splittype�	splithost�	splitport�	splituser�splitpasswd�	splitattr�
splitquery�
splitvalue�splittag�to_bytes�unquote_to_bytes�
urlunparse)�
addinfourl�addclosehookFT�Request�OpenerDirector�BaseHandler�HTTPDefaultErrorHandler�HTTPRedirectHandler�HTTPCookieProcessor�ProxyHandler�HTTPPasswordMgr�HTTPPasswordMgrWithDefaultRealm�HTTPPasswordMgrWithPriorAuth�AbstractBasicAuthHandler�HTTPBasicAuthHandler�ProxyBasicAuthHandler�AbstractDigestAuthHandler�HTTPDigestAuthHandler�ProxyDigestAuthHandler�HTTPHandler�FileHandler�
FTPHandler�CacheFTPHandler�DataHandler�UnknownHandler�HTTPErrorProcessor�urlopen�install_opener�build_opener�pathname2url�url2pathname�
getproxies�urlretrieve�
urlcleanup�	URLopener�FancyURLopenerz%d.%d�)�cafile�capath�	cadefault�contextc
Cs�|s|s|rfddl}|jdtd�|dk	r2td��ts>td��tjtjj||d�}t	|d�}t
|�}	n0|r~t	|d�}t
|�}	ntdkr�t
�a}	nt}	|	j|||�S)NrzJcafile, capath and cadefault are deprecated, use a custom context instead.r:zDYou can't pass both context and any of cafile, capath, and cadefaultzSSL support not available)r;r<)r>)
�warnings�warn�DeprecationWarning�
ValueError�	_have_ssl�sslZcreate_default_contextZPurposeZSERVER_AUTH�HTTPSHandlerr2�_opener�open)
�url�data�timeoutr;r<r=r>r?Z
https_handler�opener�rL�&/usr/lib64/python3.6/urllib/request.pyr0�s*<




cCs|adS)N)rF)rKrLrLrMr1�scCs4t|�\}}tjt||����}|j�}|dkrD|rDtjj|�|fS|rTt|d�}nt	j
dd�}|j}tj
|�|��||f}	d}
d
}d}d}
d	|kr�t|d
�}|r�||
|
|�xB|j|
�}|s�P|t|�7}|j|�|
d7}
|r�||
|
|�q�WWdQRXWdQRX|dk�r0||k�r0td||f|	��|	S)N�file�wbF)�deletei��rzcontent-lengthzContent-Lengthz1retrieval incomplete: got only %i out of %i bytesi ���)r�
contextlib�closingr0�info�os�path�normpathrG�tempfileZNamedTemporaryFile�name�_url_tempfiles�append�int�read�len�writer)rH�filename�
reporthookrIZurl_typerX�fp�headers�tfp�result�bs�sizer_�blocknum�blockrLrLrMr6�sD


$cCsHx0tD](}ytj|�Wqtk
r,YqXqWtdd�=trDdadS)N)r\rW�unlink�OSErrorrF)Z	temp_filerLrLrMr7%s


z:\d+$cCs<|j}t|�d}|dkr&|jdd�}tjd|d�}|j�S)NrR��Host)�full_urlr�
get_header�_cut_port_re�sub�lower)�requestrH�hostrLrLrM�request_host4srwc@s�eZdZdidddfdd�Zedd��Zejdd��Zejdd��Zed	d
��Zejdd
��Zejdd
��Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd#dd�Zdd �Zd!d"�ZdS)$rNFc	Csp||_i|_i|_d|_||_d|_x |j�D]\}}|j||�q.W|dkrVt|�}||_	||_
|rl||_dS)N)rpre�unredirected_hdrs�_datarI�_tunnel_host�items�
add_headerrw�origin_req_host�unverifiable�method)	�selfrHrIrer}r~r�key�valuerLrLrM�__init__FszRequest.__init__cCs|jrdj|j|j�S|jS)Nz{}#{})�fragment�format�	_full_url)r�rLrLrMrpXszRequest.full_urlcCs(t|�|_t|j�\|_|_|j�dS)N)rr�rr��_parse)r�rHrLrLrMrp^s
cCsd|_d|_d|_dS)Nrn)r�r��selector)r�rLrLrMrpescCs|jS)N)ry)r�rLrLrMrIkszRequest.datacCs(||jkr$||_|jd�r$|jd�dS)NzContent-length)ry�
has_header�
remove_header)r�rIrLrLrMrIos

cCs
d|_dS)N)rI)r�rLrLrMrIyscCsNt|j�\|_}|jdkr(td|j��t|�\|_|_|jrJt|j�|_dS)Nzunknown url type: %r)	rr��typerBrprrvr�r
)r��restrLrLrMr�}s
zRequest._parsecCs|jdk	rdnd}t|d|�S)N�POST�GETr)rI�getattr)r�Zdefault_methodrLrLrM�
get_method�szRequest.get_methodcCs|jS)N)rp)r�rLrLrM�get_full_url�szRequest.get_full_urlcCs4|jdkr|jr|j|_n||_|j|_||_dS)N�https)r�rzrvrpr�)r�rvr�rLrLrM�	set_proxy�s

zRequest.set_proxycCs|j|jkS)N)r�rp)r�rLrLrM�	has_proxy�szRequest.has_proxycCs||j|j�<dS)N)re�
capitalize)r�r��valrLrLrMr|�szRequest.add_headercCs||j|j�<dS)N)rxr�)r�r�r�rLrLrM�add_unredirected_header�szRequest.add_unredirected_headercCs||jkp||jkS)N)rerx)r��header_namerLrLrMr��s
zRequest.has_headercCs|jj||jj||��S)N)re�getrx)r�r��defaultrLrLrMrq�szRequest.get_headercCs |jj|d�|jj|d�dS)N)re�poprx)r�r�rLrLrMr��szRequest.remove_headercCs"|jj�}|j|j�t|j��S)N)rx�copy�updatere�listr{)r��hdrsrLrLrM�header_items�s
zRequest.header_items)N)�__name__�
__module__�__qualname__r��propertyrp�setter�deleterrIr�r�r�r�r�r|r�r�rqr�r�rLrLrLrMrDs(

c@sNeZdZdd�Zdd�Zdd�Zdd�Zd	ejfd
d�Z	ddd
�Z
dd�Zd	S)rcCs6dt}d|fg|_g|_i|_i|_i|_i|_dS)NzPython-urllib/%sz
User-agent)�__version__�
addheaders�handlers�handle_open�handle_error�process_response�process_request)r�Zclient_versionrLrLrMr��szOpenerDirector.__init__cCsZt|d�stdt|���d}�xt|�D�]}|dkr:q*|jd�}|d|�}||dd�}|jd	�r�|jd�|d}||dd�}yt|�}Wntk
r�YnX|jj	|i�}	|	|j|<n>|d
kr�|}|j
}	n*|dkr�|}|j}	n|dkr*|}|j}	nq*|	j
|g�}
|
�r&tj|
|�n
|
j|�d
}q*W|�rVtj|j|�|j|�dS)N�
add_parentz%expected BaseHandler instance, got %rF�redirect_request�do_open�
proxy_open�_rR�errorrG�responseruT)r�r�r�)�hasattr�	TypeErrorr��dir�find�
startswithr^rBr�r�r�r�r��
setdefault�bisectZinsortr]r�r�)r��handlerZadded�meth�i�protocolZ	condition�j�kind�lookupr�rLrLrM�add_handler�sJ



zOpenerDirector.add_handlercCsdS)NrL)r�rLrLrM�close�szOpenerDirector.closec	Gs<|j|f�}x*|D]"}t||�}||�}|dk	r|SqWdS)N)r�r�)	r��chainr��	meth_name�argsr�r��funcrgrLrLrM�_call_chain�s

zOpenerDirector._call_chainNc
Cs�t|t�rt||�}n|}|dk	r(||_||_|j}|d}x(|jj|g�D]}t||�}||�}qLW|j	||�}	|d}x*|j
j|g�D]}t||�}|||	�}	q�W|	S)NZ_requestZ	_response)�
isinstance�strrrIrJr�r�r�r��_openr�)
r��fullurlrIrJ�reqr�r�Z	processorr�r�rLrLrMrG�s"


zOpenerDirector.opencCsP|j|jdd|�}|r|S|j}|j|j||d|�}|r>|S|j|jdd|�S)Nr�Zdefault_openr��unknown�unknown_open)r�r�r�)r�r�rIrgr�rLrLrMr�s


zOpenerDirector._opencGs~|d
kr,|jd}|d}d|}d}|}n|j}|d}d}|||f|}|j|�}|r^|S|rz|dd	f|}|j|�SdS)N�httpr�r:z
http_error_%srRZ_errorrr��http_error_default)r�r�)r�r�)r��protor��dictr�Zhttp_errZ	orig_argsrgrLrLrMr�'s 

zOpenerDirector.error)N)r�r�r�r�r�r�r��socket�_GLOBAL_DEFAULT_TIMEOUTrGr�r�rLrLrLrMr�s/
c	Gs�t�}ttttttttt	g	}t
tjd�r2|j
t�t�}xN|D]F}x@|D]8}t|t�rlt||�r�|j|�qHt||�rH|j|�qHWq>Wx|D]}|j|�q�Wx|D]}|j|��q�Wx&|D]}t|t�r�|�}|j|�q�W|S)N�HTTPSConnection)rrr.r)rrr+r*r/r-r�r��clientr]rE�setr�r��
issubclass�add�remover�)r�rKZdefault_classes�skip�klassZcheck�hrLrLrMr2@s0	









c@s(eZdZdZdd�Zdd�Zdd�ZdS)	ri�cCs
||_dS)N)�parent)r�r�rLrLrMr�gszBaseHandler.add_parentcCsdS)NrL)r�rLrLrMr�jszBaseHandler.closecCst|d�sdS|j|jkS)N�
handler_orderT)r�r�)r��otherrLrLrM�__lt__ns
zBaseHandler.__lt__N)r�r�r�r�r�r�r�rLrLrLrMrdsc@seZdZdZdd�ZeZdS)r/i�cCsJ|j|j|j�}}}d|ko*dknsF|jjd|||||�}|S)N��i,r�)�code�msgrVr�r�)r�rur�r�r�r�rLrLrM�
http_response{s
z HTTPErrorProcessor.http_responseN)r�r�r�r�r��https_responserLrLrLrMr/wsc@seZdZdd�ZdS)rcCst|j||||��dS)N)rrp)r�r�rdr�r�r�rLrLrMr��sz*HTTPDefaultErrorHandler.http_error_defaultN)r�r�r�r�rLrLrLrMr�sc@s4eZdZdZdZdd�Zdd�ZeZZZ	dZ
dS)	r��
c	sx|j�}|dkr|dkp&|dko&|dks:t|j||||��|jdd	�}d�t�fdd
�|jj�D��}t|||jdd�S)N�-�.�/�3r��HEADr�� z%20�content-length�content-typec3s&|]\}}|j��kr||fVqdS)N)rt)�.0�k�v)�CONTENT_HEADERSrLrM�	<genexpr>�sz7HTTPRedirectHandler.redirect_request.<locals>.<genexpr>T)rer}r~)r�r�r�r�)r�r�)r�r�r�)r�r�)	r�rrp�replacer�rer{rr})	r�r�rdr�r�re�newurl�mZ
newheadersrL)r�rMr��s
z$HTTPRedirectHandler.redirect_requestc
CsNd|kr|d}nd|kr$|d}ndSt|�}|jdkrRt||d||f||��|jrp|jrpt|�}d|d	<t|�}t|d
tj	d�}t
|j|�}|j||||||�}|dkr�dSt
|d��r|j}	|_|	j|d
�|jks�t|	�|jk�rt|j||j|||��ni}	|_|_|	j|d
�d|	|<|j�|j�|jj||jd�S)N�location�urir�r��ftprnz+%s - Redirection to url '%s' is not allowed�/r:z
iso-8859-1)�encoding�safe�
redirect_dictrrR)rJ)r�r�r�rn)r�schemerrXZnetlocr�rr	�stringZpunctuationrrpr�r�rr��max_repeatsr`�max_redirections�inf_msgr_r�r�rGrJ)
r�r�rdr�r�rer��urlparts�newZvisitedrLrLrM�http_error_302�s@



z"HTTPRedirectHandler.http_error_302zoThe HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
N)r�r�r�rrr�r	�http_error_301�http_error_303�http_error_307rrLrLrLrMr�s&<c	Cs�t|�\}}|jd�s d}|}n:|jd�s6td|��|jdd�}|dkrNd}|d|�}t|�\}}|dk	r|t|�\}}nd}}||||fS)Nr�z//zproxy URL with no authority: %rr:rRrS)rr�rBr�rr)	�proxyrZr_scheme�	authority�endZuserinfo�hostport�user�passwordrLrLrM�_parse_proxy�s

rc@s"eZdZdZddd�Zdd�ZdS)r�dNcCsL|dkrt�}||_x2|j�D]&\}}t|d||||jfdd��qWdS)Nz%s_opencSs||||�S)NrL)�rr
r�r�rLrLrM�<lambda>%sz'ProxyHandler.__init__.<locals>.<lambda>)r5�proxiesr{�setattrr�)r�rr�rHrLrLrMr�s
zProxyHandler.__init__cCs�|j}t|�\}}}}|dkr"|}|jr6t|j�r6dS|rv|rvdt|�t|�f}	tj|	j��jd�}
|j	dd|
�t|�}|j
||�||ks�|dkr�dS|jj||j
d�SdS)Nz%s:%s�asciizProxy-authorizationzBasic r�)rJ)r�rrv�proxy_bypassr
�base64�	b64encode�encode�decoder|r�r�rGrJ)r�r�r
r�Z	orig_typeZ
proxy_typerrrZ	user_passZcredsrLrLrMr�(s zProxyHandler.proxy_open)N)r�r�r�r�r�r�rLrLrLrMrs

c@s6eZdZdd�Zdd�Zdd�Zd
dd	�Zd
d�ZdS)r cCs
i|_dS)N)�passwd)r�rLrLrMr�FszHTTPPasswordMgr.__init__cs`t|t�r|g}|�jkr$i�j|<x6dD].�t��fdd�|D��}||f�j||<q*WdS)NTFcsg|]}�j|���qSrL)�
reduce_uri)r��u)�default_portr�rLrM�
<listcomp>Qsz0HTTPPasswordMgr.add_password.<locals>.<listcomp>)TF)r�r�r�tuple)r��realmr�rr�reduced_urirL)r"r�rM�add_passwordIs



zHTTPPasswordMgr.add_passwordc	Cs`|jj|i�}xLdD]D}|j||�}x2|j�D]&\}}x|D]}|j||�r<|Sq<Wq.WqWdS)NTF)TF)NN)rr�r r{�	is_suburi)	r�r%�authuriZdomainsr"�reduced_authuriZurisZauthinfor�rLrLrM�find_user_passwordTs

z"HTTPPasswordMgr.find_user_passwordTc
Cs�t|�}|dr.|d}|d}|dp*d}nd}|}d}t|�\}}|r~|dkr~|dk	r~ddd�j|�}	|	dk	r~d||	f}||fS)	NrRrr:r��Pi�)r�r�z%s:%d)rr
r�)
r�r�r"�partsrrrXrv�portZdportrLrLrMr ^s zHTTPPasswordMgr.reduce_uricCsR||krdS|d|dkr dStj|d|df�}t|�t|d�krNdSdS)NTrFrR)�	posixpath�commonprefixr`)r��base�test�commonrLrLrMr(uszHTTPPasswordMgr.is_suburiN)T)r�r�r�r�r'r+r r(rLrLrLrMr Ds


c@seZdZdd�ZdS)r!cCs0tj|||�\}}|dk	r"||fStj|d|�S)N)r r+)r�r%r)rrrLrLrMr+�s

z2HTTPPasswordMgrWithDefaultRealm.find_user_passwordN)r�r�r�r+rLrLrLrMr!�scs<eZdZ�fdd�Zd
�fdd�	Zddd�Zdd	�Z�ZS)r"csi|_t�j||�dS)N)�
authenticated�superr�)r�r��kwargs)�	__class__rLrMr��sz%HTTPPasswordMgrWithPriorAuth.__init__Fcs<|j||�|dk	r&t�jd|||�t�j||||�dS)N)�update_authenticatedr5r')r�r%r�rr�is_authenticated)r7rLrMr'�sz)HTTPPasswordMgrWithPriorAuth.add_passwordcCsFt|t�r|g}x0dD](}x"|D]}|j||�}||j|<q WqWdS)NTF)TF)r�r�r r4)r�r�r9r"r!r&rLrLrMr8�s


z1HTTPPasswordMgrWithPriorAuth.update_authenticatedcCsDx>dD]6}|j||�}x$|jD]}|j||�r|j|SqWqWdS)NTF)TF)r r4r()r�r)r"r*r�rLrLrMr9�s

z-HTTPPasswordMgrWithPriorAuth.is_authenticated)F)F)r�r�r�r�r'r8r9�
__classcell__rLrL)r7rMr"�s

c@sTeZdZejdej�Zddd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZeZ
eZdS)r#z1(?:^|,)[ 	]*([^ 	,]+)[ 	]+realm=(["']?)([^"']*)\2NcCs"|dkrt�}||_|jj|_dS)N)r rr')r�Zpassword_mgrrLrLrMr��sz!AbstractBasicAuthHandler.__init__ccstd}xFtjj|�D]6}|j�\}}}|d	kr:tjdtd�||fVd}qW|sp|rb|j�d}nd}|dfVdS)
NF�"�'zBasic Auth Realm was unquoted�Trrn)r;r<)r#�rx�finditer�groupsr?r@�UserWarning�split)r��headerZfound_challengeZmorr	r%rLrLrM�_parse_realm�s
z%AbstractBasicAuthHandler._parse_realmc	Cs~|j|�}|sdSd}xL|D]D}x>|j|�D]0\}}|j�dkrF|}q,|dk	r,|j|||�Sq,WqW|dk	rztd|f��dS)N�basiczBAbstractBasicAuthHandler does not support the following scheme: %r)Zget_allrDrt�retry_http_basic_authrB)	r��authreqrvr�reZunsupportedrCrr%rLrLrM�http_error_auth_reqed�s

z.AbstractBasicAuthHandler.http_error_auth_reqedcCs||jj||�\}}|dk	rtd||f}dtj|j��jd�}|j|jd�|krTdS|j|j|�|j	j
||jd�SdSdS)Nz%s:%szBasic r)rJ)rr+rrrrrq�auth_headerr�r�rGrJ)r�rvr�r%r�pw�raw�authrLrLrMrF�sz.AbstractBasicAuthHandler.retry_http_basic_authcCsxt|jd�s|jj|j�r"|S|jd�st|jjd|j�\}}dj||�j�}tj	|�j
�}|jddj|j���|S)Nr9�
Authorizationz{0}:{1}zBasic {})
r�rr9rpr�r+r�rrZstandard_b64encoderr��strip)r�r�rrZcredentialsZauth_strrLrLrM�http_requests
z%AbstractBasicAuthHandler.http_requestcCsLt|jd�rHd|jko dknr8|jj|jd�n|jj|jd�|S)Nr9r�i,TF)r�rr�r8rp)r�r�r�rLrLrMr�s
z&AbstractBasicAuthHandler.http_response)N)r�r�r��re�compile�Ir>r�rDrHrFrOr��
https_requestr�rLrLrLrMr#�s

c@seZdZdZdd�ZdS)r$rMcCs|j}|jd|||�}|S)Nzwww-authenticate)rprH)r�r�rdr�r�rerHr�rLrLrM�http_error_401 s
z#HTTPBasicAuthHandler.http_error_401N)r�r�r�rIrTrLrLrLrMr$sc@seZdZdZdd�ZdS)r%zProxy-authorizationcCs|j}|jd|||�}|S)Nzproxy-authenticate)rvrH)r�r�rdr�r�rerr�rLrLrM�http_error_407+s
z$ProxyBasicAuthHandler.http_error_407N)r�r�r�rIrUrLrLrLrMr%'sc@sNeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)r&NcCs4|dkrt�}||_|jj|_d|_d|_d|_dS)Nr)r rr'�retried�nonce_count�
last_nonce)r�rrLrLrMr�Es
z"AbstractDigestAuthHandler.__init__cCs
d|_dS)Nr)rV)r�rLrLrM�reset_retry_countNsz+AbstractDigestAuthHandler.reset_retry_countcCs||j|d�}|jdkr*t|jdd|d��n|jd7_|rx|j�d}|j�dkr`|j||�S|j�dkrxtd|��dS)	N�i�zdigest auth failedrRrZdigestrEzEAbstractDigestAuthHandler does not support the following scheme: '%s')r�rVrrprBrt�retry_http_digest_authrB)r�rIrvr�rerGrrLrLrMrHQs


z/AbstractDigestAuthHandler.http_error_auth_reqedcCsz|jdd�\}}ttdt|���}|j||�}|rvd|}|jj|jd�|krRdS|j|j|�|j	j
||jd�}|SdS)Nr�rRz	Digest %s)rJ)rB�parse_keqv_list�filter�parse_http_list�get_authorizationrer�rIr�r�rGrJ)r�r�rL�tokenZ	challenge�chalZauth_valZresprLrLrMr[esz0AbstractDigestAuthHandler.retry_http_digest_authcCs@d|j|tj�f}|jd�td�}tj|�j�}|dd�S)Nz	%s:%s:%s:rrQ�)rW�timeZctimer�_randombytes�hashlib�sha1�	hexdigest)r��nonce�s�b�digrLrLrM�
get_cnonceqsz$AbstractDigestAuthHandler.get_cnoncecCs�y6|d}|d}|jd�}|jdd�}|jdd�}Wntk
rJdSX|j|�\}}	|dkrfdS|jj||j�\}
}|
dkr�dS|jdk	r�|j|j|�}nd}d|
||f}
d|j�|j	f}|d	k�r.||j
kr�|jd
7_nd
|_||_
d|j}|j|�}d||||||�f}|	||
�|�}n2|dk�rT|	||
�d|||�f�}nt
d
|��d|
|||j	|f}|�r�|d|7}|�r�|d|7}|d|7}|�r�|d||f7}|S)Nr%rh�qop�	algorithm�MD5�opaquez%s:%s:%sz%s:%srLrRz%08xz%s:%s:%s:%s:%szqop '%s' is not supported.z>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z
, digest="%s"z, algorithm="%s"z, qop=auth, nc=%s, cnonce="%s")r��KeyError�get_algorithm_implsrr+rprI�get_entity_digestr�r�rXrWrlr)r�r�rar%rhrmrnrp�H�KDrrJZentdigZA1ZA2ZncvalueZcnonceZnoncebitZrespdigr1rLrLrMr_|sV








z+AbstractDigestAuthHandler.get_authorizationcsD|dkrdd��n|dkr$dd��ntd|���fdd�}�|fS)NrocSstj|jd��j�S)Nr)reZmd5rrg)�xrLrLrMr�sz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>ZSHAcSstj|jd��j�S)Nr)rerfrrg)rvrLrLrMr�sz.Unsupported digest authentication algorithm %rcs�d||f�S)Nz%s:%srL)ri�d)rtrLrMr�s)rB)r�rnrurL)rtrMrr�s

z-AbstractDigestAuthHandler.get_algorithm_implscCsdS)NrL)r�rIrarLrLrMrs�sz+AbstractDigestAuthHandler.get_entity_digest)N)r�r�r�r�rYrHr[rlr_rrrsrLrLrLrMr&:s
	<
c@seZdZdZdZdd�ZdS)r'rMi�cCs*t|j�d}|jd|||�}|j�|S)NrRzwww-authenticate)rrprHrY)r�r�rdr�r�rerv�retryrLrLrMrT�s

z$HTTPDigestAuthHandler.http_error_401N)r�r�r�rIr�rTrLrLrLrMr'�sc@seZdZdZdZdd�ZdS)r(zProxy-Authorizationi�cCs"|j}|jd|||�}|j�|S)Nzproxy-authenticate)rvrHrY)r�r�rdr�r�rervrxrLrLrMrU�s

z%ProxyDigestAuthHandler.http_error_407N)r�r�r�rIr�rUrLrLrLrMr(�sc@s6eZdZd
dd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�AbstractHTTPHandlerrcCs
||_dS)N)�_debuglevel)r��
debuglevelrLrLrMr��szAbstractHTTPHandler.__init__cCs
||_dS)N)rz)r��levelrLrLrM�set_http_debuglevel�sz'AbstractHTTPHandler.set_http_debuglevelcCstjjj|j|j��S)N)r�r��HTTPConnection�_get_content_lengthrIr�)r�rurLrLrMr�sz'AbstractHTTPHandler._get_content_lengthcCs
|j}|std��|jdk	r�|j}t|t�r8d}t|��|jd�sN|jdd�|jd�r�|jd�r�|j|�}|dk	r�|jdt|��n|jdd�|}|j	�r�t
|j�\}}t|�\}}	|jd�s�|jd|�x2|j
jD]&\}
}|
j�}
|j|
�s�|j|
|�q�W|S)	Nz
no host givenz\POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.zContent-typez!application/x-www-form-urlencodedzContent-lengthzTransfer-encodingZchunkedro)rvrrIr�r�r�r�r�rr�rr�rr�r�r�)r�rurvrIr�Zcontent_lengthZsel_hostrZselZsel_pathr[r�rLrLrM�do_request_�s>





zAbstractHTTPHandler.do_request_c
s\|j}|std��||fd|ji|��}|j|j�t|j���jt�fdd�|jj	�D���d�d<tdd��j	�D���|j
r�i}d}|�kr��|||<�|=|j|j
|d	�y`y&|j|j
�|j|j�|jd
�d�Wn,tk
�r
}zt|��WYdd}~XnX|j�}	Wn|j��YnX|j�rF|jj�d|_|j�|	_|	j|	_|	S)Nz
no host givenrJc3s"|]\}}|�kr||fVqdS)NrL)r�r�r�)rerLrMr�)sz.AbstractHTTPHandler.do_open.<locals>.<genexpr>r��
Connectioncss|]\}}|j�|fVqdS)N)�title)r�r[r�rLrLrMr�6szProxy-Authorization)rezTransfer-encoding)Zencode_chunked)rvrrJZset_debuglevelrzr�rxr�rer{rzZ
set_tunnelrur�r�rIr�rm�getresponser�Zsockr�rH�reasonr�)
r�Z
http_classr�Zhttp_conn_argsrvr�Ztunnel_headersZproxy_auth_hdr�errrrL)rerMr�s@
"

zAbstractHTTPHandler.do_openN)r)r�r�r�r�r}rr�r�rLrLrLrMry�s

&ryc@seZdZdd�ZejZdS)r)cCs|jtjj|�S)N)r�r�r�r~)r�r�rLrLrM�	http_open`szHTTPHandler.http_openN)r�r�r�r�ryr�rOrLrLrLrMr)^sr�c@s$eZdZddd�Zdd�ZejZdS)rErNcCstj||�||_||_dS)N)ryr��_context�_check_hostname)r�r{r>�check_hostnamerLrLrMr�iszHTTPSHandler.__init__cCs|jtjj||j|jd�S)N)r>r�)r�r�r�r�r�r�)r�r�rLrLrM�
https_opennszHTTPSHandler.https_open)rNN)r�r�r�r�r�ryr�rSrLrLrLrMrEgs
rEc@s.eZdZddd�Zdd�Zdd�ZeZeZdS)	rNcCs$ddl}|dkr|jj�}||_dS)Nr)Zhttp.cookiejar�	cookiejarZ	CookieJar)r�r�r�rLrLrMr�ws
zHTTPCookieProcessor.__init__cCs|jj|�|S)N)r�Zadd_cookie_header)r�rurLrLrMrO}sz HTTPCookieProcessor.http_requestcCs|jj||�|S)N)r�Zextract_cookies)r�rur�rLrLrMr��sz!HTTPCookieProcessor.http_response)N)r�r�r�r�rOr�rSr�rLrLrLrMrvs

c@seZdZdd�ZdS)r.cCs|j}td|��dS)Nzunknown url type: %s)r�r)r�r�r�rLrLrMr��szUnknownHandler.unknown_openN)r�r�r�r�rLrLrLrMr.�scCsRi}xH|D]@}|jdd�\}}|ddkrB|ddkrB|dd�}|||<q
W|S)N�=rRrr;rSrS)rB)�lZparsedZeltr�r�rLrLrMr\�s
r\cCs�g}d}d}}xt|D]l}|r,||7}d}q|rV|dkr@d}qn|dkrLd}||7}q|dkrn|j|�d}q|dkrzd}||7}qW|r�|j|�dd�|D�S)	NrnF�\Tr;�,cSsg|]}|j��qSrL)rN)r��partrLrLrMr#�sz#parse_http_list.<locals>.<listcomp>)r])ri�resr��escaper	ZcurrLrLrMr^�s4	


r^c@s(eZdZdd�ZdZdd�Zdd�ZdS)r*cCs\|j}|dd�dkrN|dd�dkrN|jrN|jdkrN|j|j�krXtd��n
|j|�SdS)Nr:z//r=r��	localhostz-file:// scheme is supported only on localhost)r�rv�	get_namesr�open_local_file)r�r�rHrLrLrM�	file_open�s&

zFileHandler.file_openNcCs`tjdkrZy*ttjd�dtjtj��d�t_Wn$tjk
rXtjd�ft_YnXtjS)Nr�r:)r*�namesr$r��gethostbyname_ex�gethostname�gaierror�
gethostbyname)r�rLrLrMr��s
zFileHandler.get_namescCsddl}ddl}|j}|j}t|�}y�tj|�}|j}|jj	|j
dd�}	|j|�d}
|jd|
pbd||	f�}|r~t
|�\}}|s�|r�t|�|j�kr�|r�d||}
nd|}
tt|d�||
�SWn*tk
r�}zt|��WYdd}~XnXtd��dS)	NrT)�usegmtz6Content-type: %s
Content-length: %d
Last-modified: %s
z
text/plainzfile://�rbzfile not on local host)�email.utils�	mimetypesrvr�r4rW�stat�st_size�utils�
formatdate�st_mtime�
guess_type�message_from_stringr
�_safe_gethostbynamer�rrGrmr)r�r��emailr�rvrbZ	localfile�statsri�modified�mtyperer.Zorigurl�exprLrLrMr��s0
zFileHandler.open_local_file)r�r�r�r�r�r�r�rLrLrLrMr*�s
cCs&y
tj|�Stjk
r dSXdS)N)r�r�r�)rvrLrLrMr��s
r�c@seZdZdd�Zdd�ZdS)r+cCs.ddl}ddl}|j}|s"td��t|�\}}|dkr>|j}nt|�}t|�\}}|rdt|�\}}nd}t	|�}|pvd}|p~d}yt
j|�}Wn*tk
r�}zt|��WYdd}~XnXt
|j�\}	}
|	jd�}ttt	|��}|dd�|d}}|�r|d�r|dd�}y�|j||||||j�}
|�r8d�p:d}x:|
D]2}t|�\}}|j�dk�rB|dk�rB|j�}�qBW|
j||�\}}d}|j|j�d}|�r�|d
|7}|dk	�r�|dk�r�|d|7}tj|�}t|||j�S|jk
�r(}z$td|�}|jtj �d��WYdd}~XnXdS)Nrzftp error: no host givenrnr�rRrR�Dr��a�Ar�rwzContent-type: %s
zContent-length: %d
z
ftp error: %rr:rSrS)r�r�r�rRrwr�)!�ftplibr�rvrr
�FTP_PORTr^rrr
r�r�rmrr�rBr��map�connect_ftprJrrt�upper�retrfiler�rpr�r�r�
all_errors�with_traceback�sys�exc_info)r�r�r�r�rvr.rrr�rX�attrs�dirsrN�fwr��attrr�rd�retrlenrer�r��excrLrLrM�ftp_open�s\



zFTPHandler.ftp_openc	Cst||||||dd�S)NF)�
persistent)�
ftpwrapper)r�rrrvr.r�rJrLrLrMr�1szFTPHandler.connect_ftpN)r�r�r�r�r�rLrLrLrMr+�s5c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r,cCs"i|_i|_d|_d|_d|_dS)Nr�<rb)�cacherJ�soonest�delay�	max_conns)r�rLrLrMr�8s
zCacheFTPHandler.__init__cCs
||_dS)N)r�)r��trLrLrM�
setTimeout?szCacheFTPHandler.setTimeoutcCs
||_dS)N)r�)r�r�rLrLrM�setMaxConnsBszCacheFTPHandler.setMaxConnscCsr|||dj|�|f}||jkr4tj�|j|j|<n,t||||||�|j|<tj�|j|j|<|j�|j|S)Nr�)�joinr�rcr�rJr��check_cache)r�rrrvr.r�rJr�rLrLrMr�Es

zCacheFTPHandler.connect_ftpcCs�tj�}|j|krTx@t|jj��D].\}}||kr"|j|j�|j|=|j|=q"Wtt|jj���|_t	|j�|j
kr�x6t|jj��D]$\}}||jkr�|j|=|j|=Pq�Wtt|jj���|_dS)N)rcr�r�rJr{r�r��min�valuesr`r�)r�r�r�r�rLrLrMr�Ps

zCacheFTPHandler.check_cachecCs4x|jj�D]}|j�qW|jj�|jj�dS)N)r�r�r��clearrJ)r��connrLrLrM�clear_cacheds
zCacheFTPHandler.clear_cacheN)	r�r�r�r�r�r�r�r�r�rLrLrLrMr,5sc@seZdZdd�ZdS)r-cCs~|j}|jdd�\}}|jdd�\}}t|�}|jd�rNtj|�}|dd�}|sVd}tjd|t|�f�}t	t
j|�||�S)	N�:rRr�z;base64�ztext/plain;charset=US-ASCIIz$Content-type: %s
Content-length: %d
i����)rprBr�endswithr�decodebytesr�r�r`r�io�BytesIO)r�r�rHrrIZ	mediatypererLrLrM�	data_openks


zDataHandler.data_openN)r�r�r�r�rLrLrLrMr-jsr��nt)r4r3cCst|�S)N)r
)�pathnamerLrLrMr4�scCst|�S)N)r	)r�rLrLrMr3�sc@s�eZdZdZdeZd)dd�Zdd�Zdd�Zd	d
�Z	dd�Z
d*d
d�Zd+dd�Zd,dd�Z
d-dd�Zdd�Zd.dd�Zd/dd�Zdd�Zer�dd�Zd0dd �Zd!d"�Zd#d$�Zd%d&�Zd1d'd(�ZdS)2r8NzPython-urllib/%scKszdd|jji}tj|tdd�|dkr.t�}||_|jd�|_|jd�|_	d|j
fd
g|_g|_t
j|_d|_t|_dS)NzW%(class)s style of invoking requests is deprecated. Use newer urlopen functions/methods�classr=)�
stacklevel�key_file�	cert_filez
User-Agent�Accept�*/*)r�r�)r7r�r?r@rAr5rr�r�r��versionr��_URLopener__tempfilesrWrl�_URLopener__unlink�	tempcache�ftpcache)r�rZx509r�rLrLrMr��szURLopener.__init__cCs|j�dS)N)r�)r�rLrLrM�__del__�szURLopener.__del__cCs|j�dS)N)�cleanup)r�rLrLrMr��szURLopener.closecCsZ|jrFx2|jD](}y|j|�Wqtk
r4YqXqW|jdd�=|jrV|jj�dS)N)r�r�rmr�r�)r�rNrLrLrMr��s
zURLopener.cleanupcGs|jj|�dS)N)r�r])r�r�rLrLrM�	addheader�szURLopener.addheadercCsntt|��}t|dd�}|jrL||jkrL|j|\}}t|d�}t|||�St|�\}}|s`d}||jkr�|j|}t|�\}}	t|	�\}
}|
|f}nd}d|}||_	|j
dd�}t||�s�|dkr�|r�|j|||�S|j
||�Sy,|dk�rt||�|�St||�||�SWnVttfk
�r.�Yn<tk
�rh}
ztd	|
�jtj�d
��WYdd}
~
XnXdS)Nz%/:=&?~#+!$,;'@()*[]|)rr�rNZopen_�-r�r�zsocket errorr:)rrr	r�rGrrrrr�r�r��open_unknown_proxy�open_unknownr�rrrmr�r�r�)r�r�rIrbrerd�urltyperHr
�	proxyhostrvr�r[r�rLrLrMrG�s<




zURLopener.opencCst|�\}}tdd|��dS)Nz	url errorzunknown url type)rrm)r�r�rIr�rHrLrLrMr�szURLopener.open_unknowncCs t|�\}}tdd||��dS)Nz	url errorzinvalid proxy for %s)rrm)r�r
r�rIr�rHrLrLrMr�	szURLopener.open_unknown_proxyc Cs&tt|��}|jr&||jkr&|j|St|�\}}|dkr�|sH|dkr�y.|j|�}|j�}|j�tt|�d�|fSt	k
r�}	zWYdd}	~	XnX|j
||�}�zH|j�}
|r�t
|d�}n|ddl}t|�\}
}t|p�d�\}
}t|p�d�\}}
t
|�pd�\}}
tjj|�d}|j|�\}}|jj|�tj|d�}z�||
f}|jdk	�r^||j|<d}d}d}d}d|
k�r�t|
d	�}|�r�||||�xH|j|�}|�s�P|t|�7}|j|�|d7}|�r�||||��q�WWd|j�XWd|j�X|dk�r"||k�r"td
||f|��|S)
NrNrRrOrrnirQzcontent-lengthzContent-Lengthz1retrieval incomplete: got only %i out of %i bytesi rS)rrr�rr�rVr�r4rrmrGrZrrrWrX�splitextZmkstempr�r]�fdopenr^r_r`rar)r�rHrbrcrIr�Zurl1rdr�r�rerfrZZgarbagerX�suffix�fdrgrhrir_rjrkrLrLrM�retrievesl






zURLopener.retrievecCs(d}d}t|t�r<t|�\}}|r6t|�\}}t|�}|}nt|\}}t|�\}}t|�\}	}
|
}d}|	j�dkrvd}n:t|
�\}}
|r�t|�\}}|r�d|	||
f}t|�r�|}|s�tdd��|r�t|�}t	j
|j��jd�}nd}|�rt|�}t	j
|j��jd�}nd}||�}
i}|�r*d||d<|�r<d||d<|�rJ||d	<d
|d<x|j
D]\}}|||<�qZW|dk	�r�d|d
<|
jd|||�n|
jd||d�y|
j�}Wn"tjjk
�r�td��YnXd|jk�o�dkn�rt||jd||j�S|j||j|j|j|j|�SdS)Nr�z	%s://%s%sz
http errorz
no host givenrzBasic %szProxy-AuthorizationrMror�r�z!application/x-www-form-urlencodedzContent-Typer�r�)rez$http protocol error: bad status liner�i,zhttp:)r�r�rrr
rrtrrmrrrrr�rur�r�r�Z
BadStatusLinerZstatusrr��
http_errorrdr�)r�Zconnection_factoryrHrIZuser_passwdZproxy_passwdrvr�Zrealhostr�r�Z
proxy_authrLZ	http_connrerCr�r�rLrLrM�_open_generic_httpQsr



zURLopener._open_generic_httpcCs|jtjj||�S)N)r�r�r�r~)r�rHrIrLrLrM�	open_http�szURLopener.open_httpc
Csbd|}t||�rPt||�}|dkr6||||||�}	n|||||||�}	|	rP|	S|j|||||�S)Nz
http_error_%d)r�r�r�)
r�rHrd�errcode�errmsgrerIr[rrgrLrLrMr��s

zURLopener.http_errorcCs|j�t||||d��dS)N)r�r)r�rHrdr�r�rerLrLrMr��szURLopener.http_error_defaultcCstjj||j|jd�S)N)r�r�)r�r�r�r�r�)r�rvrLrLrM�_https_connection�szURLopener._https_connectioncCs|j|j||�S)N)r�r�)r�rHrIrLrLrM�
open_https�szURLopener.open_httpscCs^t|t�std��|dd�dkrP|dd�dkrP|dd�j�dkrPtd��n
|j|�SdS)	NzEfile error: proxy support for file protocol currently not implementedr:z//r=r��z
localhost/z-file:// scheme is supported only on localhost)r�r�rrtrBr�)r�rHrLrLrM�	open_file�s

4
zURLopener.open_filecCs\ddl}ddl}t|�\}}t|�}ytj|�}Wn0tk
rb}zt|j|j	��WYdd}~XnX|j
}	|jj|j
dd�}
|j|�d}|jd|p�d|	|
f�}|s�|}
|dd�dkr�d|}
tt|d	�||
�St|�\}}|o�tj|�t�ft�k�rP|}
|dd�dk�r d|}
n|dd
�dk�r>td|��tt|d	�||
�Std
��dS)NrT)r�z6Content-Type: %s
Content-Length: %d
Last-modified: %s
z
text/plainrRr�zfile://r�r:z./zAlocal file url may start with / or file:. Unknown url of type: %sz#local file error: not on local host)r�r�rr4rWr�rmr�strerrorrbr�r�r�r�r�r�rrGr
r�r�r��thishostrB)r�rHr�r�rvrNZ	localnamer��erir�r�reZurlfiler.rLrLrMr��s: 
zURLopener.open_local_filecCs�t|t�std��ddl}t|�\}}|s2td��t|�\}}t|�\}}|r\t|�\}}nd}t|�}t|ppd�}t|p|d�}t	j
|�}|s�ddl}|j}nt
|�}t|�\}}	t|�}|jd�}
|
dd�|
d}
}|
o�|
d�r�|
dd�}
|
�r|
d�rd|
d<|||dj|
�f}t|j�tk�rlx8t|j�D]*}
|
|k�r>|j|
}|j|
=|j��q>Wy�||jk�r�t|||||
�|j|<|�s�d}nd}x:|	D]2}t|�\}}|j�d	k�r�|dk�r�|j�}�q�W|j|j||�\}}|jd|�d}d}|�r|d|7}|dk	�r:|dk�r:|d|7}tj|�}t||d|�St�k
�r�}z td|�j t!j"�d��WYdd}~XnXdS)NzCftp error: proxy support for ftp protocol currently not implementedrzftp error: no host givenrnr�rRr�rRr�r�r�r�rwzftp:zContent-Type: %s
zContent-Length: %d
zftp error %rr:rSrS)r�r�r�rRrwr�)#r�r�rr�rr
rrr
r�r�r�r�r^rrBr�r`r��MAXFTPCACHEr�r�r�rrtr�r�r�r�r�r�	ftperrorsr�r�r�)r�rHr�rvrXr.rrr�r�r�rNr�r�r�r�r�r�rdr�r�rer�rLrLrM�open_ftp�sp







zURLopener.open_ftpc	Cs<t|t�std��y|jdd�\}}Wntk
rDtdd��YnX|sNd}|jd�}|dkr�d	||d�kr�||dd�}|d|�}nd
}g}|jdtj	dtj
tj����|jd
|�|dkr�tj|j
d��jd�}nt|�}|jdt|��|jd
�|j|�dj|�}tj|�}tj|�}t|||�S)NzEdata error: proxy support for data protocol currently not implementedr�rRz
data errorzbad data URLztext/plain;charset=US-ASCII�;rr�rnzDate: %sz%a, %d %b %Y %H:%M:%S GMTzContent-type: %srrzlatin-1zContent-Length: %d�
)r�r�rrBrBrm�rfindr]rcZstrftimeZgmtimerr�rrr
r`r�r�r�r��StringIOr)	r�rHrIr�Zsemir�r�re�frLrLrM�	open_data3s6






zURLopener.open_data)N)N)N)N)NNN)N)N)N)N)r�r�r�r�r�r�r�r�r�r�r�rGr�r�r�r�r�r�r�rCr�r�r�r�rrrLrLrLrMr8�s,

$


B\


	 :c@s�eZdZdd�Zdd�Zd"dd�Zdd	�Zd#d
d�Zd$dd
�Zd%dd�Z	d&dd�Z
d'dd�Zd(dd�Zd)dd�Z
d*dd�Zd+dd�Zd,dd�Zd d!�ZdS)-r9cOs(tj|f|�|�i|_d|_d|_dS)Nrr�)r8r��
auth_cache�tries�maxtries)r�r�r6rLrLrMr�`szFancyURLopener.__init__cCst||d||�S)Nzhttp:)r)r�rHrdr�r�rerLrLrMr�fsz!FancyURLopener.http_error_defaultNc	
Csn|jd7_zR|jrJ|j|jkrJt|d�r4|j}n|j}|||dd|�S|j||||||�}|Sd|_XdS)NrR�http_error_500i�z)Internal Server Error: Redirect Recursionr)r	r
r�rr��redirect_internal)	r�rHrdr�r�rerIr�rgrLrLrMr	js
zFancyURLopener.http_error_302c	Csxd|kr|d}nd|kr$|d}ndS|j�t|jd||�}t|�}|jd	krnt|||d|||��|j|�S)
Nr�r�r�r�r�r�rnz( Redirection to url '%s' is not allowed.)r�r�r�rn)r�rr�rrrrG)	r�rHrdr�r�rerIr�rrLrLrMr|s


z FancyURLopener.redirect_internalcCs|j||||||�S)N)r	)r�rHrdr�r�rerIrLrLrMr
�szFancyURLopener.http_error_301cCs|j||||||�S)N)r	)r�rHrdr�r�rerIrLrLrMr�szFancyURLopener.http_error_303cCs2|dkr|j||||||�S|j|||||�SdS)N)r	r�)r�rHrdr�r�rerIrLrLrMr�szFancyURLopener.http_error_307Fc
Cs�d|krtj||||||�|d}tjd|�}	|	sHtj||||||�|	j�\}
}|
j�dkrttj||||||�|s�tj||||||�d|jd}|dkr�t||�||�St||�|||�SdS)Nzwww-authenticatez![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"rEZretry_�_basic_auth)r8r�rP�matchr@rtr�r�)
r�rHrdr�r�rerIrx�stuffrrr%r[rLrLrMrT�s&





zFancyURLopener.http_error_401c
Cs�d|krtj||||||�|d}tjd|�}	|	sHtj||||||�|	j�\}
}|
j�dkrttj||||||�|s�tj||||||�d|jd}|dkr�t||�||�St||�|||�SdS)Nzproxy-authenticatez![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"rEZretry_proxy_r
)r8r�rPrr@rtr�r�)
r�rHrdr�r�rerIrxrrrr%r[rLrLrMrU�s&





zFancyURLopener.http_error_407cCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|d�}	|j|	||�\}}
|pl|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|j|�S|j||�SdS)Nzhttp://r��@rRz%s:%s@%srn)r)rrrr��get_user_passwdr	rG)r�rHr%rIrvr�r�r
r�r��
proxyselectorr�rrrLrLrM�retry_proxy_http_basic_auth�s 

z*FancyURLopener.retry_proxy_http_basic_authcCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|d�}	|j|	||�\}}
|pl|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|j|�S|j||�SdS)Nzhttps://r�rrRz%s:%s@%srn)r)rrrr�rr	rG)r�rHr%rIrvr�r�r
r�r�rr�rrrLrLrM�retry_proxy_https_basic_auth�s 

z+FancyURLopener.retry_proxy_https_basic_authc
Cs�t|�\}}|jd�d}||d�}|j|||�\}}|p>|sDdSdt|dd�t|dd�|f}d||}	|dkr�|j|	�S|j|	|�SdS)NrrRz%s:%s@%srn)rzhttp://)rr�rr	rG)
r�rHr%rIrvr�r�rrr�rLrLrMrF�s
z$FancyURLopener.retry_http_basic_authc
Cs�t|�\}}|jd�d}||d�}|j|||�\}}|p>|sDdSdt|dd�t|dd�|f}d||}	|dkr�|j|	�S|j|	|�SdS)NrrRz%s:%s@%srn)rzhttps://)rr�rr	rG)
r�rHr%rIrvr�r�rrr�rLrLrM�retry_https_basic_auth	s
z%FancyURLopener.retry_https_basic_authrcCs`|d|j�}||jkr2|r(|j|=n
|j|S|j||�\}}|sJ|rX||f|j|<||fS)Nr)rtr�prompt_user_passwd)r�rvr%r�r�rrrLrLrMr	s


zFancyURLopener.get_user_passwdcCsTddl}y,td||f�}|jd|||f�}||fStk
rNt�dSXdS)NrzEnter username for %s at %s: z#Enter password for %s in %s at %s: )NN)�getpass�input�KeyboardInterrupt�print)r�rvr%rrrrLrLrMr$	sz!FancyURLopener.prompt_user_passwd)N)N)N)N)NF)NF)N)N)N)N)r)r�r�r�r�r�r	rr
rrrTrUrrrFrrrrLrLrLrMr9]s"










cCstdkrtjd�atS)Nr�)�
_localhostr�r�rLrLrLrMr�4	s
r�cCsPtdkrLyttjtj��d�aWn(tjk
rJttjd�d�aYnXtS)Nr:r�)�	_thishostr$r�r�r�r�rLrLrLrMr�<	sr�cCstdkrddl}|jatS)Nr)�
_ftperrorsr�r�)r�rLrLrMrG	srcCstdkrtjd�atS)Nrn)�
_noheadersr�r�rLrLrLrM�	noheadersP	s
rc@sFeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)r�NTc	CsX||_||_||_||_||_||_d|_||_y|j�Wn|j	��YnXdS)Nr)
rrrvr.r�rJ�refcount�	keepalive�initr�)r�rrrvr.r�rJr�rLrLrMr�]	szftpwrapper.__init__cCs\ddl}d|_|j�|_|jj|j|j|j�|jj|j	|j
�dj|j�}|jj
|�dS)Nrr�)r��busyZFTPr�Zconnectrvr.rJZloginrrr�r��cwd)r�r�Z_targetrLrLrMr"m	s
zftpwrapper.initc-Cs�ddl}|j�|dkr"d}d}nd|}d}y|jj|�Wn*|jk
rh|j�|jj|�YnXd}|r�|r�yd|}|jj|�\}}WnR|jk
r�}z4t|�dd�d	kr�t	d
|�j
tj�d��WYdd}~XnX|�s�|jjd�|�rn|jj
�}	zJy|jj|�Wn4|jk
�rP}zt	d
|�|�WYdd}~XnXWd|jj|	�Xd|}nd
}|jj|�\}}d|_t|jd�|j�}
|jd7_|j�|
|fS)Nrrwr�zTYPE ArRzTYPE zRETR r=Z550z
ftp error: %rr:zLIST ZLISTr�)rwr�)r��endtransferr�Zvoidcmdr�r"ZntransfercmdZ
error_permr�rr�r�r��pwdr$r#r�makefile�
file_closer r�)r�rNr�r��cmd�isdirr�r�r�r&ZftpobjrLrLrMr�v	sN
 
$
zftpwrapper.retrfilecCs
d|_dS)Nr)r#)r�rLrLrMr%�	szftpwrapper.endtransfercCsd|_|jdkr|j�dS)NFr)r!r �
real_close)r�rLrLrMr��	s
zftpwrapper.closecCs4|j�|jd8_|jdkr0|jr0|j�dS)NrRr)r%r r!r+)r�rLrLrMr(�	szftpwrapper.file_closecCs2|j�y|jj�Wnt�k
r,YnXdS)N)r%r�r�r)r�rLrLrMr+�	s
zftpwrapper.real_close)NT)
r�r�r�r�r"r�r%r�r(r+rLrLrLrMr�Z	s
	-r�cCs�i}xBtjj�D]4\}}|j�}|r|dd�dkr|||dd�<qWdtjkr^|jdd�xXtjj�D]J\}}|dd�dkrj|j�}|r�|||dd�<qj|j|dd	�d�qjW|S)
N��_proxyZREQUEST_METHODr�i����i����i����i����i����)rW�environr{rtr�)rr[r�rLrLrM�getproxies_environment�	s	
r/c
Cs�|dkrt�}y|d}Wntk
r.dSX|dkr<dSt|�\}}dd�|jd�D�}xP|D]H}|rb|jd�}tj|�}d	|}tj||tj�s�tj||tj�rbdSqbWdS)
N�nor�*rRcSsg|]}|j��qSrL)rN)r�r
rLrLrMr#�	sz,proxy_bypass_environment.<locals>.<listcomp>r��.z
(.+\.)?%s$)	r/rqr
rB�lstriprPr�rrR)rvrZno_proxy�hostonlyr.Z
no_proxy_listr[�patternrLrLrM�proxy_bypass_environment�	s&


r6c
Csddlm}t|�\}}dd�}d|kr4|dr4dSd}x�|jdf�D]�}|sPqFtjd	|�}|dk	�r|dkr�ytj|�}||�}Wntk
r�wFYnX||jd
��}	|jd�}
|
dkr�d|jd
�j	d�d
}
nt
|
d
d��}
d
|
}
||
?|	|
?k�rdSqF|||�rFdSqFWdS)Nr)�fnmatchcSsh|jd�}ttt|��}t|�dkr<|ddddgdd�}|dd>|dd>B|dd>B|d	BS)
Nr2r�r�rRrbr:rQr=)rBr�r�r^r`)ZipAddrr-rLrLrM�ip2num
s

z,_proxy_bypass_macosx_sysconf.<locals>.ip2numr2Zexclude_simpleT�
exceptionsz(\d+(?:\.\d+)*)(/\d+)?rRr:rQ� F)r7r
r�rPrr�r�rm�group�countr^)rv�proxy_settingsr7r4r.r9ZhostIPr�r�r1�maskrLrLrM�_proxy_bypass_macosx_sysconf�	s:



r@�darwin)�_get_proxy_settings�_get_proxiescCst�}t||�S)N)rBr@)rvr>rLrLrM�proxy_bypass_macosx_sysconf:
srDcCst�S)N)rCrLrLrLrM�getproxies_macosx_sysconf>
srEcCs t�}|rt||�St|�SdS)N)r/r6rD)rvrrLrLrMrH
s
rcCst�p
t�S)N)r/rErLrLrLrMr5U
scCsi}yddl}Wntk
r$|SXy�|j|jd�}|j|d�d}|r�t|j|d�d�}d|kr�x�|jd�D]4}|jdd�\}}tjd|�s�d	||f}|||<qrWn>|dd
�dkr�||d<n$d
||d<d||d<d||d<|j	�Wnt
ttfk
�rYnX|S)Nrz;Software\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyEnableZProxyServerr�rrRz^([^/:]+)://z%s://%srZzhttp:r�z	http://%sz
https://%sr�zftp://%sr�)
�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�QueryValueExr�rBrPrZClosermrBr�)rrG�internetSettings�proxyEnableZproxyServer�pr�ZaddressrLrLrM�getproxies_registryZ
s8

rOcCst�p
t�S)N)r/rOrLrLrLrMr5�
sc&Cs~yddl}Wntk
r dSXy6|j|jd�}|j|d�d}t|j|d�d�}Wntk
rldSX|sz|r~dSt|�\}}|g}y tj	|�}||kr�|j
|�Wntk
r�YnXy tj|�}||kr�|j
|�Wntk
�r�YnX|jd�}xp|D]h}	|	dk�r*d|k�r*dS|	j
dd	�}	|	j
d
d�}	|	j
dd�}	x$|D]}
tj|	|
tj��rTdS�qTW�qWdS)
Nrz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsrFZ
ProxyOverriderz<local>r2rRz\.r1z.*�?)rGrHrIrJrKr�rmr
r�r�r]ZgetfqdnrBr�rPrrR)rvrGrLrMZ
proxyOverrideZrawHostr.ZaddrZfqdnr2r�rLrLrM�proxy_bypass_registry�
sR







rQcCs t�}|rt||�St|�SdS)N)r/r6rQ)rvrrLrLrMr�
s
)NNN)N)~rr�r�reZhttp.clientr�r�rWr/rPr�rr�rc�collectionsrZrTr?Zurllib.errorrrrZurllib.parserrrrr	r
rrr
rrrrrrrrrZurllib.responserrrDrHrC�__all__�version_infor�rFr�r0r1r\r6r7rQ�ASCIIrrrwrrr2rr/rrrrr r!r"r#r$r%�urandomrdr&r'r(ryr)r�r�rEr]rr.r\r^r*r�r+r,r-r�r[Z
nturl2pathr4r3r�r8r9rr�rr�rrrrr�r/r6r@�platformZ_scproxyrBrCrDrErr5rOrQrLrLrLrM�<module>Ts�P
T
?n$q*@
ov

+3:5!AW

_
#<

-	2
PK�@�\�
���robotparser.cpython-36.pycnu�[���3


 \�"�@s\dZddlZddlZddlZdgZejdd�ZGdd�d�ZGdd�d�Z	Gd	d
�d
�Z
dS)a% robotparser.py

    Copyright (C) 2000  Bastian Kleineidam

    You can choose between two licenses when using this package:
    1) GNU GPLv2
    2) PSF license for Python 2.2

    The robots.txt Exclusion Protocol is implemented as specified in
    http://www.robotstxt.org/norobots-rfc.txt
�N�RobotFileParser�RequestRatezrequests secondsc@sjeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rzs This class provides a set of methods to read, parse and answer
    questions about a single robots.txt file.

    �cCs,g|_d|_d|_d|_|j|�d|_dS)NFr)�entries�
default_entry�disallow_all�	allow_all�set_url�last_checked)�self�url�r
�*/usr/lib64/python3.6/urllib/robotparser.py�__init__s
zRobotFileParser.__init__cCs|jS)z�Returns the time the robots.txt file was last fetched.

        This is useful for long-running web spiders that need to
        check for new robots.txt files periodically.

        )r
)rr
r
r�mtime$szRobotFileParser.mtimecCsddl}|j�|_dS)zYSets the time the robots.txt file was last fetched to the
        current time.

        rN)�timer
)rrr
r
r�modified-szRobotFileParser.modifiedcCs&||_tjj|�dd�\|_|_dS)z,Sets the URL referring to a robots.txt file.��N)r�urllib�parse�urlparse�host�path)rrr
r
rr	5szRobotFileParser.set_urlcCs�ytjj|j�}WnRtjjk
rd}z2|jdkr:d|_n|jdkrT|jdkrTd|_WYdd}~XnX|j	�}|j
|jd�j��dS)	z4Reads the robots.txt URL and feeds it to the parser.��Ti�i�Nzutf-8)rr)
rZrequestZurlopenr�errorZ	HTTPError�coderr�readr�decode�
splitlines)r�f�err�rawr
r
rr:s
zRobotFileParser.readcCs,d|jkr|jdkr(||_n|jj|�dS)N�*)�
useragentsrr�append)r�entryr
r
r�
_add_entryGs

zRobotFileParser._add_entrycCs6d}t�}|j��x|D�]�}|sT|dkr8t�}d}n|dkrT|j|�t�}d}|jd�}|dkrr|d|�}|j�}|s�q|jdd�}t|�dkr|dj�j�|d<tj	j
|dj��|d<|ddk�r|dkr�|j|�t�}|jj|d�d}q|ddk�r4|dk�r|j
jt|dd	��d}q|dd
k�rh|dk�r|j
jt|dd��d}q|ddk�r�|dk�r|dj�j��r�t|d�|_d}q|dd
kr|dkr|djd�}t|�dk�r|dj�j��r|dj�j��rtt|d�t|d��|_d}qW|dk�r2|j|�dS)z�Parse the input lines from a robots.txt file.

        We allow that a user-agent: line is not preceded by
        one or more blank lines.
        rr��#N�:z
user-agentZdisallowFZallowTzcrawl-delayzrequest-rate�/)�Entryrr(�find�strip�split�len�lowerrr�unquoter%r&�	rulelines�RuleLine�isdigit�int�delayr�req_rate)r�lines�stater'�line�iZnumbersr
r
rrPsd






 
zRobotFileParser.parsecCs�|jr
dS|jrdS|jsdStjjtjj|��}tjjdd|j|j	|j
|jf�}tjj|�}|sfd}x"|j
D]}|j|�rn|j|�SqnW|jr�|jj|�SdS)z=using the parsed robots.txt decide if useragent can fetch urlFTrr,)rrr
rrrr3�
urlunparserZparamsZqueryZfragment�quoter�
applies_to�	allowancer)r�	useragentrZ
parsed_urlr'r
r
r�	can_fetch�s$
zRobotFileParser.can_fetchcCs4|j�sdSx|jD]}|j|�r|jSqW|jjS)N)rrr@r8r)rrBr'r
r
r�crawl_delay�s

zRobotFileParser.crawl_delaycCs4|j�sdSx|jD]}|j|�r|jSqW|jjS)N)rrr@r9r)rrBr'r
r
r�request_rate�s

zRobotFileParser.request_ratecCs0|j}|jdk	r||jg}djtt|��dS)N�
)rr�join�map�str)rrr
r
r�__str__�s
zRobotFileParser.__str__N)r)�__name__�
__module__�__qualname__�__doc__rrrr	rr(rrCrDrErJr
r
r
rrs
	
	Cc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r5zoA rule line is a single "Allow:" (allowance==True) or "Disallow:"
       (allowance==False) followed by a path.cCs>|dkr|rd}tjjtjj|��}tjj|�|_||_dS)NrT)rrr>rr?rrA)rrrAr
r
rr�s
zRuleLine.__init__cCs|jdkp|j|j�S)Nr$)r�
startswith)r�filenamer
r
rr@�szRuleLine.applies_tocCs|jr
dndd|jS)NZAllowZDisallowz: )rAr)rr
r
rrJ�szRuleLine.__str__N)rKrLrMrNrr@rJr
r
r
rr5�sr5c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r-z?An entry has one or more user-agents and zero or more rulelinescCsg|_g|_d|_d|_dS)N)r%r4r8r9)rr
r
rr�szEntry.__init__cCs�g}x|jD]}|jd|���qW|jdk	r@|jd|j���|jdk	rj|j}|jd|j�d|j���|jtt|j	��|jd�dj
|�S)NzUser-agent: z
Crawl-delay: zRequest-rate: r,rrF)r%r&r8r9ZrequestsZseconds�extendrHrIr4rG)rZret�agentZrater
r
rrJ�s


z
Entry.__str__cCsF|jd�dj�}x.|jD]$}|dkr*dS|j�}||krdSqWdS)z2check if this entry applies to the specified agentr,rr$TF)r0r2r%)rrBrRr
r
rr@�szEntry.applies_tocCs$x|jD]}|j|�r|jSqWdS)zZPreconditions:
        - our agent applies to this entry
        - filename is URL decodedT)r4r@rA)rrPr<r
r
rrA�s

zEntry.allowanceN)rKrLrMrNrrJr@rAr
r
r
rr-�s


r-)rN�collectionsZurllib.parserZurllib.request�__all__�
namedtuplerrr5r-r
r
r
r�<module>s2PK�@�\�2`zzrequest.cpython-36.opt-1.pycnu�[���3

���i~��)@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+m,Z,yddl-Z-Wne.k
�r&dZ/YnXdZ/dd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(g!Z0d)e
j1dd*�Z2da3dej4fddddd+�d,d�Z5d-d �Z6gZ7d~d.d%�Z8d/d&�Z9e
j:d0e
j;�Z<d1d2�Z=Gd3d�d�Z>Gd4d	�d	�Z?d5d!�Z@Gd6d
�d
�ZAGd7d�deA�ZBGd8d�deA�ZCGd9d�deA�ZDd:d;�ZEGd<d�deA�ZFGd=d�d�ZGGd>d�deG�ZHGd?d�deH�ZIGd@d�d�ZJGdAd�deJeA�ZKGdBd�deJeA�ZLejMZNGdCd�d�ZOGdDd�deAeO�ZPGdEd�deAeO�ZQGdFdG�dGeA�ZRGdHd�deR�ZSeTejUdI��r2GdJdK�dKeR�ZVe0jWdK�GdLd
�d
eA�ZXGdMd�deA�ZYdNdO�ZZdPdQ�Z[GdRd�deA�Z\dSdT�Z]GdUd�deA�Z^GdVd�de^�Z_GdWd�deA�Z`dXZaejbdYk�r�ddZlcmdZdmeZend[d#�Zdd\d"�ZeiZfGd]d'�d'�ZgGd^d(�d(eg�Zhdaid_d`�Zjdakdadb�Zldamdcdd�Zndaodedf�ZpGdgdh�dh�Zqdidj�Zrddkdl�Zsdmdn�Zte
judok�r�ddplvmwZwmxZxdqdr�Zydsdt�Zzdudv�Z{dwd$�Z|n6ejbdYk�r�dxdy�Z}dzd$�Z|d{d|�Z~d}dv�Z{nerZ|esZ{dS)�a�
An extensible library for opening URLs using a variety of protocols

The simplest way to use this module is to call the urlopen function,
which accepts a string containing a URL or a Request object (described
below).  It opens the URL and returns the results as file-like
object; the returned object has some extra methods described below.

The OpenerDirector manages a collection of Handler objects that do
all the actual work.  Each Handler implements a particular protocol or
option.  The OpenerDirector is a composite object that invokes the
Handlers needed to open the requested URL.  For example, the
HTTPHandler performs HTTP GET and POST requests and deals with
non-error returns.  The HTTPRedirectHandler automatically deals with
HTTP 301, 302, 303 and 307 redirect errors, and the HTTPDigestAuthHandler
deals with digest authentication.

urlopen(url, data=None) -- Basic usage is the same as original
urllib.  pass the url and optionally data to post to an HTTP URL, and
get a file-like object back.  One difference is that you can also pass
a Request instance instead of URL.  Raises a URLError (subclass of
OSError); for HTTP errors, raises an HTTPError, which can also be
treated as a valid response.

build_opener -- Function that creates a new OpenerDirector instance.
Will install the default handlers.  Accepts one or more Handlers as
arguments, either instances or Handler classes that it will
instantiate.  If one of the argument is a subclass of the default
handler, the argument will be installed instead of the default.

install_opener -- Installs a new opener as the default opener.

objects of interest:

OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
the Handler classes, while dealing with requests and responses.

Request -- An object that encapsulates the state of a request.  The
state can be as simple as the URL.  It can also include extra HTTP
headers, e.g. a User-Agent.

BaseHandler --

internals:
BaseHandler and parent
_call_chain conventions

Example usage:

import urllib.request

# set up authentication info
authinfo = urllib.request.HTTPBasicAuthHandler()
authinfo.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='geheim$parole')

proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})

# build a new opener that adds authentication and caching FTP handlers
opener = urllib.request.build_opener(proxy_support, authinfo,
                                     urllib.request.CacheFTPHandler)

# install it
urllib.request.install_opener(opener)

f = urllib.request.urlopen('http://www.python.org/')
�N)�URLError�	HTTPError�ContentTooShortError)�urlparse�urlsplit�urljoin�unwrap�quote�unquote�	splittype�	splithost�	splitport�	splituser�splitpasswd�	splitattr�
splitquery�
splitvalue�splittag�to_bytes�unquote_to_bytes�
urlunparse)�
addinfourl�addclosehookFT�Request�OpenerDirector�BaseHandler�HTTPDefaultErrorHandler�HTTPRedirectHandler�HTTPCookieProcessor�ProxyHandler�HTTPPasswordMgr�HTTPPasswordMgrWithDefaultRealm�HTTPPasswordMgrWithPriorAuth�AbstractBasicAuthHandler�HTTPBasicAuthHandler�ProxyBasicAuthHandler�AbstractDigestAuthHandler�HTTPDigestAuthHandler�ProxyDigestAuthHandler�HTTPHandler�FileHandler�
FTPHandler�CacheFTPHandler�DataHandler�UnknownHandler�HTTPErrorProcessor�urlopen�install_opener�build_opener�pathname2url�url2pathname�
getproxies�urlretrieve�
urlcleanup�	URLopener�FancyURLopenerz%d.%d�)�cafile�capath�	cadefault�contextc
Cs�|s|s|rfddl}|jdtd�|dk	r2td��ts>td��tjtjj||d�}t	|d�}t
|�}	n0|r~t	|d�}t
|�}	ntdkr�t
�a}	nt}	|	j|||�S)	a$
Open the URL url, which can be either a string or a Request object.

    *data* must be an object specifying additional data to be sent to
    the server, or None if no such data is needed.  See Request for
    details.

    urllib.request module uses HTTP/1.1 and includes a "Connection:close"
    header in its HTTP requests.

    The optional *timeout* parameter specifies a timeout in seconds for
    blocking operations like the connection attempt (if not specified, the
    global default timeout setting will be used). This only works for HTTP,
    HTTPS and FTP connections.

    If *context* is specified, it must be a ssl.SSLContext instance describing
    the various SSL options. See HTTPSConnection for more details.

    The optional *cafile* and *capath* parameters specify a set of trusted CA
    certificates for HTTPS requests. cafile should point to a single file
    containing a bundle of CA certificates, whereas capath should point to a
    directory of hashed certificate files. More information can be found in
    ssl.SSLContext.load_verify_locations().

    The *cadefault* parameter is ignored.

    This function always returns an object which can work as a context
    manager and has methods such as

    * geturl() - return the URL of the resource retrieved, commonly used to
      determine if a redirect was followed

    * info() - return the meta-information of the page, such as headers, in the
      form of an email.message_from_string() instance (see Quick Reference to
      HTTP Headers)

    * getcode() - return the HTTP status code of the response.  Raises URLError
      on errors.

    For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse
    object slightly modified. In addition to the three new methods above, the
    msg attribute contains the same information as the reason attribute ---
    the reason phrase returned by the server --- instead of the response
    headers as it is specified in the documentation for HTTPResponse.

    For FTP, file, and data URLs and requests explicitly handled by legacy
    URLopener and FancyURLopener classes, this function returns a
    urllib.response.addinfourl object.

    Note that None may be returned if no handler handles the request (though
    the default installed global OpenerDirector uses UnknownHandler to ensure
    this never happens).

    In addition, if proxy settings are detected (for example, when a *_proxy
    environment variable like http_proxy is set), ProxyHandler is default
    installed and makes sure the requests are handled through the proxy.

    rNzJcafile, capath and cadefault are deprecated, use a custom context instead.r:zDYou can't pass both context and any of cafile, capath, and cadefaultzSSL support not available)r;r<)r>)
�warnings�warn�DeprecationWarning�
ValueError�	_have_ssl�sslZcreate_default_contextZPurposeZSERVER_AUTH�HTTPSHandlerr2�_opener�open)
�url�data�timeoutr;r<r=r>r?Z
https_handler�opener�rL�&/usr/lib64/python3.6/urllib/request.pyr0�s*<




cCs|adS)N)rF)rKrLrLrMr1�scCs4t|�\}}tjt||����}|j�}|dkrD|rDtjj|�|fS|rTt|d�}nt	j
dd�}|j}tj
|�|��||f}	d
}
d}d}d}
d	|kr�t|d
�}|r�||
|
|�xB|j|
�}|s�P|t|�7}|j|�|
d7}
|r�||
|
|�q�WWdQRXWdQRX|dk�r0||k�r0td||f|	��|	S)aW
    Retrieve a URL into a temporary location on disk.

    Requires a URL argument. If a filename is passed, it is used as
    the temporary file location. The reporthook argument should be
    a callable that accepts a block number, a read size, and the
    total file size of the URL target. The data argument should be
    valid URL encoded data.

    If a filename is passed and the URL points to a local resource,
    the result is a copy from local file to new file.

    Returns a tuple containing the path to the newly created
    data file as well as the resulting HTTPMessage object.
    �file�wbF)�deletei��rzcontent-lengthzContent-LengthNz1retrieval incomplete: got only %i out of %i bytesi ���)r�
contextlib�closingr0�info�os�path�normpathrG�tempfileZNamedTemporaryFile�name�_url_tempfiles�append�int�read�len�writer)rH�filename�
reporthookrIZurl_typerX�fp�headers�tfp�result�bs�sizer_�blocknum�blockrLrLrMr6�sD


$cCsHx0tD](}ytj|�Wqtk
r,YqXqWtdd�=trDdadS)z0Clean up temporary files from urlretrieve calls.N)r\rW�unlink�OSErrorrF)Z	temp_filerLrLrMr7%s


z:\d+$cCs<|j}t|�d}|dkr&|jdd�}tjd|d�}|j�S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    rR��Host)�full_urlr�
get_header�_cut_port_re�sub�lower)�requestrH�hostrLrLrM�request_host4srwc@s�eZdZdidddfdd�Zedd��Zejdd��Zejdd��Zed	d
��Zejdd
��Zejdd
��Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd#dd�Zdd �Zd!d"�ZdS)$rNFc	Csp||_i|_i|_d|_||_d|_x |j�D]\}}|j||�q.W|dkrVt|�}||_	||_
|rl||_dS)N)rpre�unredirected_hdrs�_datarI�_tunnel_host�items�
add_headerrw�origin_req_host�unverifiable�method)	�selfrHrIrer}r~r�key�valuerLrLrM�__init__FszRequest.__init__cCs|jrdj|j|j�S|jS)Nz{}#{})�fragment�format�	_full_url)r�rLrLrMrpXszRequest.full_urlcCs(t|�|_t|j�\|_|_|j�dS)N)rr�rr��_parse)r�rHrLrLrMrp^s
cCsd|_d|_d|_dS)Nrn)r�r��selector)r�rLrLrMrpescCs|jS)N)ry)r�rLrLrMrIkszRequest.datacCs(||jkr$||_|jd�r$|jd�dS)NzContent-length)ry�
has_header�
remove_header)r�rIrLrLrMrIos

cCs
d|_dS)N)rI)r�rLrLrMrIyscCsNt|j�\|_}|jdkr(td|j��t|�\|_|_|jrJt|j�|_dS)Nzunknown url type: %r)	rr��typerBrprrvr�r
)r��restrLrLrMr�}s
zRequest._parsecCs|jdk	rdnd}t|d|�S)z3Return a string indicating the HTTP request method.N�POST�GETr)rI�getattr)r�Zdefault_methodrLrLrM�
get_method�szRequest.get_methodcCs|jS)N)rp)r�rLrLrM�get_full_url�szRequest.get_full_urlcCs4|jdkr|jr|j|_n||_|j|_||_dS)N�https)r�rzrvrpr�)r�rvr�rLrLrM�	set_proxy�s

zRequest.set_proxycCs|j|jkS)N)r�rp)r�rLrLrM�	has_proxy�szRequest.has_proxycCs||j|j�<dS)N)re�
capitalize)r�r��valrLrLrMr|�szRequest.add_headercCs||j|j�<dS)N)rxr�)r�r�r�rLrLrM�add_unredirected_header�szRequest.add_unredirected_headercCs||jkp||jkS)N)rerx)r��header_namerLrLrMr��s
zRequest.has_headercCs|jj||jj||��S)N)re�getrx)r�r��defaultrLrLrMrq�szRequest.get_headercCs |jj|d�|jj|d�dS)N)re�poprx)r�r�rLrLrMr��szRequest.remove_headercCs"|jj�}|j|j�t|j��S)N)rx�copy�updatere�listr{)r��hdrsrLrLrM�header_items�s
zRequest.header_items)N)�__name__�
__module__�__qualname__r��propertyrp�setter�deleterrIr�r�r�r�r�r|r�r�rqr�r�rLrLrLrMrDs(

c@sNeZdZdd�Zdd�Zdd�Zdd�Zd	ejfd
d�Z	ddd
�Z
dd�Zd	S)rcCs6dt}d|fg|_g|_i|_i|_i|_i|_dS)NzPython-urllib/%sz
User-agent)�__version__�
addheaders�handlers�handle_open�handle_error�process_response�process_request)r�Zclient_versionrLrLrMr��szOpenerDirector.__init__cCsZt|d�stdt|���d}�xt|�D�]}|dkr:q*|jd�}|d|�}||dd�}|jd	�r�|jd�|d}||dd�}yt|�}Wntk
r�YnX|jj	|i�}	|	|j|<n>|d
kr�|}|j
}	n*|dkr�|}|j}	n|dkr*|}|j}	nq*|	j
|g�}
|
�r&tj|
|�n
|
j|�d
}q*W|�rVtj|j|�|j|�dS)N�
add_parentz%expected BaseHandler instance, got %rF�redirect_request�do_open�
proxy_open�_rR�errorrG�responseruT)r�r�r�)�hasattr�	TypeErrorr��dir�find�
startswithr^rBr�r�r�r�r��
setdefault�bisectZinsortr]r�r�)r��handlerZadded�meth�i�protocolZ	condition�j�kind�lookupr�rLrLrM�add_handler�sJ



zOpenerDirector.add_handlercCsdS)NrL)r�rLrLrM�close�szOpenerDirector.closec	Gs<|j|f�}x*|D]"}t||�}||�}|dk	r|SqWdS)N)r�r�)	r��chainr��	meth_name�argsr�r��funcrgrLrLrM�_call_chain�s

zOpenerDirector._call_chainNc
Cs�t|t�rt||�}n|}|dk	r(||_||_|j}|d}x(|jj|g�D]}t||�}||�}qLW|j	||�}	|d}x*|j
j|g�D]}t||�}|||	�}	q�W|	S)NZ_requestZ	_response)�
isinstance�strrrIrJr�r�r�r��_openr�)
r��fullurlrIrJ�reqr�r�Z	processorr�r�rLrLrMrG�s"


zOpenerDirector.opencCsP|j|jdd|�}|r|S|j}|j|j||d|�}|r>|S|j|jdd|�S)Nr�Zdefault_openr��unknown�unknown_open)r�r�r�)r�r�rIrgr�rLrLrMr�s


zOpenerDirector._opencGs~|d
kr,|jd}|d}d|}d}|}n|j}|d}d}|||f|}|j|�}|r^|S|rz|dd	f|}|j|�SdS)N�httpr�r:z
http_error_%srRZ_errorrr��http_error_default)r�r�)r�r�)r��protor��dictr�Zhttp_errZ	orig_argsrgrLrLrMr�'s 

zOpenerDirector.error)N)r�r�r�r�r�r�r��socket�_GLOBAL_DEFAULT_TIMEOUTrGr�r�rLrLrLrMr�s/
c	Gs�t�}ttttttttt	g	}t
tjd�r2|j
t�t�}xN|D]F}x@|D]8}t|t�rlt||�r�|j|�qHt||�rH|j|�qHWq>Wx|D]}|j|�q�Wx|D]}|j|��q�Wx&|D]}t|t�r�|�}|j|�q�W|S)a*Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP, FTP and when applicable HTTPS.

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    �HTTPSConnection)rrr.r)rrr+r*r/r-r�r��clientr]rE�setr�r��
issubclass�add�remover�)r�rKZdefault_classes�skip�klassZcheck�hrLrLrMr2@s0	









c@s(eZdZdZdd�Zdd�Zdd�ZdS)	ri�cCs
||_dS)N)�parent)r�r�rLrLrMr�gszBaseHandler.add_parentcCsdS)NrL)r�rLrLrMr�jszBaseHandler.closecCst|d�sdS|j|jkS)N�
handler_orderT)r�r�)r��otherrLrLrM�__lt__ns
zBaseHandler.__lt__N)r�r�r�r�r�r�r�rLrLrLrMrdsc@s eZdZdZdZdd�ZeZdS)r/zProcess HTTP error responses.i�cCsJ|j|j|j�}}}d|ko*dknsF|jjd|||||�}|S)N��i,r�)�code�msgrVr�r�)r�rur�r�r�r�rLrLrM�
http_response{s
z HTTPErrorProcessor.http_responseN)r�r�r��__doc__r�r��https_responserLrLrLrMr/wsc@seZdZdd�ZdS)rcCst|j||||��dS)N)rrp)r�r�rdr�r�r�rLrLrMr��sz*HTTPDefaultErrorHandler.http_error_defaultN)r�r�r�r�rLrLrLrMr�sc@s4eZdZdZdZdd�Zdd�ZeZZZ	dZ
dS)	r��
c	sx|j�}|dkr|dkp&|dko&|dks:t|j||||��|jdd	�}d�t�fdd
�|jj�D��}t|||jdd�S)a�Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        �-�.�/�3r��HEADr�� z%20�content-length�content-typec3s&|]\}}|j��kr||fVqdS)N)rt)�.0�k�v)�CONTENT_HEADERSrLrM�	<genexpr>�sz7HTTPRedirectHandler.redirect_request.<locals>.<genexpr>T)rer}r~)r�r�r�r�)r�r�)r�r�r�)r�r�)	r�rrp�replacer�rer{rr})	r�r�rdr�r�re�newurl�mZ
newheadersrL)r�rMr��s
z$HTTPRedirectHandler.redirect_requestc
CsNd|kr|d}nd|kr$|d}ndSt|�}|jdkrRt||d||f||��|jrp|jrpt|�}d|d	<t|�}t|d
tj	d�}t
|j|�}|j||||||�}|dkr�dSt
|d��r|j}	|_|	j|d
�|jks�t|	�|jk�rt|j||j|||��ni}	|_|_|	j|d
�d|	|<|j�|j�|jj||jd�S)N�location�urir�r��ftprnz+%s - Redirection to url '%s' is not allowed�/r:z
iso-8859-1)�encoding�safe�
redirect_dictrrR)rJ)r�r�r�rn)r�schemerrXZnetlocr�rr	�stringZpunctuationrrpr�r�rr��max_repeatsr`�max_redirections�inf_msgr_r�r�rGrJ)
r�r�rdr�r�rer��urlparts�newZvisitedrLrLrM�http_error_302�s@



z"HTTPRedirectHandler.http_error_302zoThe HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
N)r�r�r�rrr�r
�http_error_301�http_error_303�http_error_307rrLrLrLrMr�s&<c	Cs�t|�\}}|jd�s d}|}n:|jd�s6td|��|jdd�}|dkrNd}|d|�}t|�\}}|dk	r|t|�\}}nd}}||||fS)aReturn (scheme, user, password, host/port) given a URL or an authority.

    If a URL is supplied, it must have an authority (host:port) component.
    According to RFC 3986, having an authority component means the URL must
    have two slashes after the scheme.
    r�Nz//zproxy URL with no authority: %rr:rRrS)rr�rBr�rr)	�proxyrZr_scheme�	authority�endZuserinfo�hostport�user�passwordrLrLrM�_parse_proxy�s

rc@s"eZdZdZddd�Zdd�ZdS)r�dNcCsL|dkrt�}||_x2|j�D]&\}}t|d||||jfdd��qWdS)Nz%s_opencSs||||�S)NrL)�rrr�r�rLrLrM�<lambda>%sz'ProxyHandler.__init__.<locals>.<lambda>)r5�proxiesr{�setattrr�)r�rr�rHrLrLrMr�s
zProxyHandler.__init__cCs�|j}t|�\}}}}|dkr"|}|jr6t|j�r6dS|rv|rvdt|�t|�f}	tj|	j��jd�}
|j	dd|
�t|�}|j
||�||ks�|dkr�dS|jj||j
d�SdS)Nz%s:%s�asciizProxy-authorizationzBasic r�)rJ)r�rrv�proxy_bypassr
�base64�	b64encode�encode�decoder|r�r�rGrJ)r�r�rr�Z	orig_typeZ
proxy_typerrrZ	user_passZcredsrLrLrMr�(s zProxyHandler.proxy_open)N)r�r�r�r�r�r�rLrLrLrMrs

c@s6eZdZdd�Zdd�Zdd�Zd
dd	�Zd
d�ZdS)r cCs
i|_dS)N)�passwd)r�rLrLrMr�FszHTTPPasswordMgr.__init__cs`t|t�r|g}|�jkr$i�j|<x6dD].�t��fdd�|D��}||f�j||<q*WdS)NTFcsg|]}�j|���qSrL)�
reduce_uri)r��u)�default_portr�rLrM�
<listcomp>Qsz0HTTPPasswordMgr.add_password.<locals>.<listcomp>)TF)r�r�r �tuple)r��realmr�rr �reduced_urirL)r#r�rM�add_passwordIs



zHTTPPasswordMgr.add_passwordc	Cs`|jj|i�}xLdD]D}|j||�}x2|j�D]&\}}x|D]}|j||�r<|Sq<Wq.WqWdS)NTF)TF)NN)r r�r!r{�	is_suburi)	r�r&�authuriZdomainsr#�reduced_authuriZurisZauthinfor�rLrLrM�find_user_passwordTs

z"HTTPPasswordMgr.find_user_passwordTc
Cs�t|�}|dr.|d}|d}|dp*d}nd}|}d}t|�\}}|r~|dkr~|dk	r~ddd�j|�}	|	dk	r~d	||	f}||fS)
z@Accept authority or URI and extract only the authority and path.rRrr:r�N�Pi�)r�r�z%s:%d)rr
r�)
r�r�r#�partsrrrXrv�portZdportrLrLrMr!^s zHTTPPasswordMgr.reduce_uricCsR||krdS|d|dkr dStj|d|df�}t|�t|d�krNdSdS)zcCheck if test is below base in a URI tree

        Both args must be URIs in reduced form.
        TrFrR)�	posixpath�commonprefixr`)r��base�test�commonrLrLrMr)uszHTTPPasswordMgr.is_suburiN)T)r�r�r�r�r(r,r!r)rLrLrLrMr Ds


c@seZdZdd�ZdS)r!cCs0tj|||�\}}|dk	r"||fStj|d|�S)N)r r,)r�r&r*rrrLrLrMr,�s

z2HTTPPasswordMgrWithDefaultRealm.find_user_passwordN)r�r�r�r,rLrLrLrMr!�scs<eZdZ�fdd�Zd
�fdd�	Zddd�Zdd	�Z�ZS)r"csi|_t�j||�dS)N)�
authenticated�superr�)r�r��kwargs)�	__class__rLrMr��sz%HTTPPasswordMgrWithPriorAuth.__init__Fcs<|j||�|dk	r&t�jd|||�t�j||||�dS)N)�update_authenticatedr6r()r�r&r�rr �is_authenticated)r8rLrMr(�sz)HTTPPasswordMgrWithPriorAuth.add_passwordcCsFt|t�r|g}x0dD](}x"|D]}|j||�}||j|<q WqWdS)NTF)TF)r�r�r!r5)r�r�r:r#r"r'rLrLrMr9�s


z1HTTPPasswordMgrWithPriorAuth.update_authenticatedcCsDx>dD]6}|j||�}x$|jD]}|j||�r|j|SqWqWdS)NTF)TF)r!r5r))r�r*r#r+r�rLrLrMr:�s

z-HTTPPasswordMgrWithPriorAuth.is_authenticated)F)F)r�r�r�r�r(r9r:�
__classcell__rLrL)r8rMr"�s

c@sTeZdZejdej�Zddd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZeZ
eZdS)r#z1(?:^|,)[ 	]*([^ 	,]+)[ 	]+realm=(["']?)([^"']*)\2NcCs"|dkrt�}||_|jj|_dS)N)r r r()r�Zpassword_mgrrLrLrMr��sz!AbstractBasicAuthHandler.__init__ccstd}xFtjj|�D]6}|j�\}}}|d	kr:tjdtd�||fVd}qW|sp|rb|j�d}nd}|dfVdS)
NF�"�'zBasic Auth Realm was unquoted�Trrn)r<r=)r#�rx�finditer�groupsr?r@�UserWarning�split)r��headerZfound_challengeZmorr	r&rLrLrM�_parse_realm�s
z%AbstractBasicAuthHandler._parse_realmc	Cs~|j|�}|sdSd}xL|D]D}x>|j|�D]0\}}|j�dkrF|}q,|dk	r,|j|||�Sq,WqW|dk	rztd|f��dS)N�basiczBAbstractBasicAuthHandler does not support the following scheme: %r)Zget_allrErt�retry_http_basic_authrB)	r��authreqrvr�reZunsupportedrDrr&rLrLrM�http_error_auth_reqed�s

z.AbstractBasicAuthHandler.http_error_auth_reqedcCs||jj||�\}}|dk	rtd||f}dtj|j��jd�}|j|jd�|krTdS|j|j|�|j	j
||jd�SdSdS)Nz%s:%szBasic r)rJ)r r,rrrrrq�auth_headerr�r�rGrJ)r�rvr�r&r�pw�raw�authrLrLrMrG�sz.AbstractBasicAuthHandler.retry_http_basic_authcCsxt|jd�s|jj|j�r"|S|jd�st|jjd|j�\}}dj||�j�}tj	|�j
�}|jddj|j���|S)Nr:�
Authorizationz{0}:{1}zBasic {})
r�r r:rpr�r,r�rrZstandard_b64encoderr��strip)r�r�rr ZcredentialsZauth_strrLrLrM�http_requests
z%AbstractBasicAuthHandler.http_requestcCsLt|jd�rHd|jko dknr8|jj|jd�n|jj|jd�|S)Nr:r�i,TF)r�r r�r9rp)r�r�r�rLrLrMr�s
z&AbstractBasicAuthHandler.http_response)N)r�r�r��re�compile�Ir?r�rErIrGrPr��
https_requestr�rLrLrLrMr#�s

c@seZdZdZdd�ZdS)r$rNcCs|j}|jd|||�}|S)Nzwww-authenticate)rprI)r�r�rdr�r�rerHr�rLrLrM�http_error_401 s
z#HTTPBasicAuthHandler.http_error_401N)r�r�r�rJrUrLrLrLrMr$sc@seZdZdZdd�ZdS)r%zProxy-authorizationcCs|j}|jd|||�}|S)Nzproxy-authenticate)rvrI)r�r�rdr�r�rerr�rLrLrM�http_error_407+s
z$ProxyBasicAuthHandler.http_error_407N)r�r�r�rJrVrLrLrLrMr%'sc@sNeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)r&NcCs4|dkrt�}||_|jj|_d|_d|_d|_dS)Nr)r r r(�retried�nonce_count�
last_nonce)r�r rLrLrMr�Es
z"AbstractDigestAuthHandler.__init__cCs
d|_dS)Nr)rW)r�rLrLrM�reset_retry_countNsz+AbstractDigestAuthHandler.reset_retry_countcCs||j|d�}|jdkr*t|jdd|d��n|jd7_|rx|j�d}|j�dkr`|j||�S|j�dkrxtd|��dS)	N�i�zdigest auth failedrRrZdigestrFzEAbstractDigestAuthHandler does not support the following scheme: '%s')r�rWrrprCrt�retry_http_digest_authrB)r�rJrvr�rerHrrLrLrMrIQs


z/AbstractDigestAuthHandler.http_error_auth_reqedcCsz|jdd�\}}ttdt|���}|j||�}|rvd|}|jj|jd�|krRdS|j|j|�|j	j
||jd�}|SdS)Nr�rRz	Digest %s)rJ)rC�parse_keqv_list�filter�parse_http_list�get_authorizationrer�rJr�r�rGrJ)r�r�rM�tokenZ	challenge�chalZauth_valZresprLrLrMr\esz0AbstractDigestAuthHandler.retry_http_digest_authcCs@d|j|tj�f}|jd�td�}tj|�j�}|dd�S)Nz	%s:%s:%s:rrQ�)rX�timeZctimer�_randombytes�hashlib�sha1�	hexdigest)r��nonce�s�b�digrLrLrM�
get_cnonceqsz$AbstractDigestAuthHandler.get_cnoncecCs�y6|d}|d}|jd�}|jdd�}|jdd�}Wntk
rJdSX|j|�\}}	|dkrfdS|jj||j�\}
}|
dkr�dS|jdk	r�|j|j|�}nd}d|
||f}
d|j�|j	f}|d	k�r.||j
kr�|jd
7_nd
|_||_
d|j}|j|�}d||||||�f}|	||
�|�}n2|dk�rT|	||
�d|||�f�}nt
d
|��d|
|||j	|f}|�r�|d|7}|�r�|d|7}|d|7}|�r�|d||f7}|S)Nr&ri�qop�	algorithm�MD5�opaquez%s:%s:%sz%s:%srMrRz%08xz%s:%s:%s:%s:%szqop '%s' is not supported.z>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z
, digest="%s"z, algorithm="%s"z, qop=auth, nc=%s, cnonce="%s")r��KeyError�get_algorithm_implsr r,rprI�get_entity_digestr�r�rYrXrmr)r�r�rbr&rirnrorq�H�KDrrKZentdigZA1ZA2ZncvalueZcnonceZnoncebitZrespdigr2rLrLrMr`|sV








z+AbstractDigestAuthHandler.get_authorizationcsD|dkrdd��n|dkr$dd��ntd|���fdd�}�|fS)NrpcSstj|jd��j�S)Nr)rfZmd5rrh)�xrLrLrMr�sz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>ZSHAcSstj|jd��j�S)Nr)rfrgrrh)rwrLrLrMr�sz.Unsupported digest authentication algorithm %rcs�d||f�S)Nz%s:%srL)rj�d)rurLrMr�s)rB)r�rorvrL)rurMrs�s

z-AbstractDigestAuthHandler.get_algorithm_implscCsdS)NrL)r�rIrbrLrLrMrt�sz+AbstractDigestAuthHandler.get_entity_digest)N)r�r�r�r�rZrIr\rmr`rsrtrLrLrLrMr&:s
	<
c@s eZdZdZdZdZdd�ZdS)r'z�An authentication protocol defined by RFC 2069

    Digest authentication improves on basic authentication because it
    does not transmit passwords in the clear.
    rNi�cCs*t|j�d}|jd|||�}|j�|S)NrRzwww-authenticate)rrprIrZ)r�r�rdr�r�rerv�retryrLrLrMrU�s

z$HTTPDigestAuthHandler.http_error_401N)r�r�r�r�rJr�rUrLrLrLrMr'�sc@seZdZdZdZdd�ZdS)r(zProxy-Authorizationi�cCs"|j}|jd|||�}|j�|S)Nzproxy-authenticate)rvrIrZ)r�r�rdr�r�rervryrLrLrMrV�s

z%ProxyDigestAuthHandler.http_error_407N)r�r�r�rJr�rVrLrLrLrMr(�sc@s6eZdZd
dd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�AbstractHTTPHandlerrcCs
||_dS)N)�_debuglevel)r��
debuglevelrLrLrMr��szAbstractHTTPHandler.__init__cCs
||_dS)N)r{)r��levelrLrLrM�set_http_debuglevel�sz'AbstractHTTPHandler.set_http_debuglevelcCstjjj|j|j��S)N)r�r��HTTPConnection�_get_content_lengthrIr�)r�rurLrLrMr��sz'AbstractHTTPHandler._get_content_lengthcCs
|j}|std��|jdk	r�|j}t|t�r8d}t|��|jd�sN|jdd�|jd�r�|jd�r�|j|�}|dk	r�|jdt|��n|jdd�|}|j	�r�t
|j�\}}t|�\}}	|jd�s�|jd|�x2|j
jD]&\}
}|
j�}
|j|
�s�|j|
|�q�W|S)	Nz
no host givenz\POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.zContent-typez!application/x-www-form-urlencodedzContent-lengthzTransfer-encodingZchunkedro)rvrrIr�r�r�r�r�r�r�rr�rr�r�r�)r�rurvrIr�Zcontent_lengthZsel_hostrZselZsel_pathr[r�rLrLrM�do_request_�s>





zAbstractHTTPHandler.do_request_c
s\|j}|std��||fd|ji|��}|j|j�t|j���jt�fdd�|jj	�D���d�d<tdd��j	�D���|j
r�i}d}|�kr��|||<�|=|j|j
|d	�y`y&|j|j
�|j|j�|jd
�d�Wn,tk
�r
}zt|��WYdd}~XnX|j�}	Wn|j��YnX|j�rF|jj�d|_|j�|	_|	j|	_|	S)
z�Return an HTTPResponse object for the request, using http_class.

        http_class must implement the HTTPConnection API from http.client.
        z
no host givenrJc3s"|]\}}|�kr||fVqdS)NrL)r�r�r�)rerLrMr�)sz.AbstractHTTPHandler.do_open.<locals>.<genexpr>r��
Connectioncss|]\}}|j�|fVqdS)N)�title)r�r[r�rLrLrMr�6szProxy-Authorization)rezTransfer-encoding)Zencode_chunkedN)rvrrJZset_debuglevelr{r�rxr�rer{rzZ
set_tunnelrur�r�rIr�rm�getresponser�Zsockr�rH�reasonr�)
r�Z
http_classr�Zhttp_conn_argsrvr�Ztunnel_headersZproxy_auth_hdr�errrrL)rerMr�s@
"

zAbstractHTTPHandler.do_openN)r)r�r�r�r�r~r�r�r�rLrLrLrMrz�s

&rzc@seZdZdd�ZejZdS)r)cCs|jtjj|�S)N)r�r�r�r)r�r�rLrLrM�	http_open`szHTTPHandler.http_openN)r�r�r�r�rzr�rPrLrLrLrMr)^sr�c@s$eZdZddd�Zdd�ZejZdS)rErNcCstj||�||_||_dS)N)rzr��_context�_check_hostname)r�r|r>�check_hostnamerLrLrMr�iszHTTPSHandler.__init__cCs|jtjj||j|jd�S)N)r>r�)r�r�r�r�r�r�)r�r�rLrLrM�
https_opennszHTTPSHandler.https_open)rNN)r�r�r�r�r�rzr�rTrLrLrLrMrEgs
rEc@s.eZdZddd�Zdd�Zdd�ZeZeZdS)	rNcCs$ddl}|dkr|jj�}||_dS)Nr)Zhttp.cookiejar�	cookiejarZ	CookieJar)r�r�r�rLrLrMr�ws
zHTTPCookieProcessor.__init__cCs|jj|�|S)N)r�Zadd_cookie_header)r�rurLrLrMrP}sz HTTPCookieProcessor.http_requestcCs|jj||�|S)N)r�Zextract_cookies)r�rur�rLrLrMr��sz!HTTPCookieProcessor.http_response)N)r�r�r�r�rPr�rTr�rLrLrLrMrvs

c@seZdZdd�ZdS)r.cCs|j}td|��dS)Nzunknown url type: %s)r�r)r�r�r�rLrLrMr��szUnknownHandler.unknown_openN)r�r�r�r�rLrLrLrMr.�scCsRi}xH|D]@}|jdd�\}}|ddkrB|ddkrB|dd�}|||<q
W|S)z>Parse list of key=value strings where keys are not duplicated.�=rRrr<rSrS)rC)�lZparsedZeltr�r�rLrLrMr]�s
r]cCs�g}d}d}}xt|D]l}|r,||7}d}q|rV|dkr@d}qn|dkrLd}||7}q|dkrn|j|�d}q|dkrzd}||7}qW|r�|j|�dd�|D�S)	apParse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Neither commas nor quotes count if they are escaped.
    Only double-quotes count, not single-quotes.
    rnF�\Tr<�,cSsg|]}|j��qSrL)rO)r��partrLrLrMr$�sz#parse_http_list.<locals>.<listcomp>)r])rj�resr��escaper	ZcurrLrLrMr_�s4	


r_c@s(eZdZdd�ZdZdd�Zdd�ZdS)r*cCs\|j}|dd�dkrN|dd�dkrN|jrN|jdkrN|j|j�krXtd��n
|j|�SdS)Nr:z//r>r��	localhostz-file:// scheme is supported only on localhost)r�rv�	get_namesr�open_local_file)r�r�rHrLrLrM�	file_open�s&

zFileHandler.file_openNcCs`tjdkrZy*ttjd�dtjtj��d�t_Wn$tjk
rXtjd�ft_YnXtjS)Nr�r:)r*�namesr%r��gethostbyname_ex�gethostname�gaierror�
gethostbyname)r�rLrLrMr��s
zFileHandler.get_namescCsddl}ddl}|j}|j}t|�}y�tj|�}|j}|jj	|j
dd�}	|j|�d}
|jd|
pbd||	f�}|r~t
|�\}}|s�|r�t|�|j�kr�|r�d||}
nd|}
tt|d�||
�SWn*tk
r�}zt|��WYdd}~XnXtd��dS)	NrT)�usegmtz6Content-type: %s
Content-length: %d
Last-modified: %s
z
text/plainzfile://�rbzfile not on local host)�email.utils�	mimetypesrvr�r4rW�stat�st_size�utils�
formatdate�st_mtime�
guess_type�message_from_stringr
�_safe_gethostbynamer�rrGrmr)r�r��emailr�rvrbZ	localfile�statsri�modified�mtyperer/Zorigurl�exprLrLrMr��s0
zFileHandler.open_local_file)r�r�r�r�r�r�r�rLrLrLrMr*�s
cCs&y
tj|�Stjk
r dSXdS)N)r�r�r�)rvrLrLrMr��s
r�c@seZdZdd�Zdd�ZdS)r+cCs.ddl}ddl}|j}|s"td��t|�\}}|dkr>|j}nt|�}t|�\}}|rdt|�\}}nd}t	|�}|pvd}|p~d}yt
j|�}Wn*tk
r�}zt|��WYdd}~XnXt
|j�\}	}
|	jd�}ttt	|��}|dd�|d}}|�r|d�r|dd�}y�|j||||||j�}
|�r8d�p:d}x:|
D]2}t|�\}}|j�dk�rB|dk�rB|j�}�qBW|
j||�\}}d}|j|j�d}|�r�|d
|7}|dk	�r�|dk�r�|d|7}tj|�}t|||j�S|jk
�r(}z$td|�}|jtj �d��WYdd}~XnXdS)Nrzftp error: no host givenrnr�rRrS�Dr��a�Ar�rxzContent-type: %s
zContent-length: %d
z
ftp error: %rr:rSrS)r�r�r�rSrxr�)!�ftplibr�rvrr
�FTP_PORTr^rrr
r�r�rmrr�rCr��map�connect_ftprJrrt�upper�retrfiler�rpr�r�r�
all_errors�with_traceback�sys�exc_info)r�r�r�r�rvr/rr r�rX�attrs�dirsrN�fwr��attrr�rd�retrlenrer�r��excrLrLrM�ftp_open�s\



zFTPHandler.ftp_openc	Cst||||||dd�S)NF)�
persistent)�
ftpwrapper)r�rr rvr/r�rJrLrLrMr�1szFTPHandler.connect_ftpN)r�r�r�r�r�rLrLrLrMr+�s5c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r,cCs"i|_i|_d|_d|_d|_dS)Nr�<rc)�cacherJ�soonest�delay�	max_conns)r�rLrLrMr�8s
zCacheFTPHandler.__init__cCs
||_dS)N)r�)r��trLrLrM�
setTimeout?szCacheFTPHandler.setTimeoutcCs
||_dS)N)r�)r�r�rLrLrM�setMaxConnsBszCacheFTPHandler.setMaxConnscCsr|||dj|�|f}||jkr4tj�|j|j|<n,t||||||�|j|<tj�|j|j|<|j�|j|S)Nr�)�joinr�rdr�rJr��check_cache)r�rr rvr/r�rJr�rLrLrMr�Es

zCacheFTPHandler.connect_ftpcCs�tj�}|j|krTx@t|jj��D].\}}||kr"|j|j�|j|=|j|=q"Wtt|jj���|_t	|j�|j
kr�x6t|jj��D]$\}}||jkr�|j|=|j|=Pq�Wtt|jj���|_dS)N)rdr�r�rJr{r�r��min�valuesr`r�)r�r�r�r�rLrLrMr�Ps

zCacheFTPHandler.check_cachecCs4x|jj�D]}|j�qW|jj�|jj�dS)N)r�r�r��clearrJ)r��connrLrLrM�clear_cacheds
zCacheFTPHandler.clear_cacheN)	r�r�r�r�r�r�r�r�r�rLrLrLrMr,5sc@seZdZdd�ZdS)r-cCs~|j}|jdd�\}}|jdd�\}}t|�}|jd�rNtj|�}|dd�}|sVd}tjd|t|�f�}t	t
j|�||�S)	N�:rRr�z;base64�ztext/plain;charset=US-ASCIIz$Content-type: %s
Content-length: %d
i����)rprCr�endswithr�decodebytesr�r�r`r�io�BytesIO)r�r�rHrrIZ	mediatypererLrLrM�	data_openks


zDataHandler.data_openN)r�r�r�r�rLrLrLrMr-jsr��nt)r4r3cCst|�S)zOS-specific conversion from a relative URL of the 'file' scheme
        to a file system path; not recommended for general use.)r
)�pathnamerLrLrMr4�scCst|�S)zOS-specific conversion from a file system path to a relative URL
        of the 'file' scheme; not recommended for general use.)r	)r�rLrLrMr3�sc@s�eZdZdZdZdeZd*dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zd+dd�Zd,dd�Z
d-dd�Zd.dd�Zdd�Zd/dd�Zd0dd�Zdd�Zer�dd�Zd1d d!�Zd"d#�Zd$d%�Zd&d'�Zd2d(d)�ZdS)3r8a,Class to open URLs.
    This is a class rather than just a subroutine because we may need
    more than one set of global protocol-specific options.
    Note -- this is a base class for those who don't want the
    automatic handling of errors type 302 (relocated) and 401
    (authorization needed).NzPython-urllib/%scKszdd|jji}tj|tdd�|dkr.t�}||_|jd�|_|jd�|_	d|j
fd
g|_g|_t
j|_d|_t|_dS)NzW%(class)s style of invoking requests is deprecated. Use newer urlopen functions/methods�classr>)�
stacklevel�key_file�	cert_filez
User-Agent�Accept�*/*)r�r�)r8r�r?r@rAr5rr�r�r��versionr��_URLopener__tempfilesrWrl�_URLopener__unlink�	tempcache�ftpcache)r�rZx509r�rLrLrMr��szURLopener.__init__cCs|j�dS)N)r�)r�rLrLrM�__del__�szURLopener.__del__cCs|j�dS)N)�cleanup)r�rLrLrMr��szURLopener.closecCsZ|jrFx2|jD](}y|j|�Wqtk
r4YqXqW|jdd�=|jrV|jj�dS)N)r�r�rmr�r�)r�rNrLrLrMr��s
zURLopener.cleanupcGs|jj|�dS)zdAdd a header to be used by the HTTP interface only
        e.g. u.addheader('Accept', 'sound/basic')N)r�r])r�r�rLrLrM�	addheader�szURLopener.addheadercCsntt|��}t|dd�}|jrL||jkrL|j|\}}t|d�}t|||�St|�\}}|s`d}||jkr�|j|}t|�\}}	t|	�\}
}|
|f}nd}d|}||_	|j
dd�}t||�s�|d	kr�|r�|j|||�S|j
||�Sy,|dk�rt||�|�St||�||�SWnVttfk
�r.�Yn<tk
�rh}
ztd
|
�jtj�d��WYdd}
~
XnXdS)z6Use URLopener().open(file) instead of open(file, 'r').z%/:=&?~#+!$,;'@()*[]|)rr�rNNZopen_�-r�r�zsocket errorr:)rrr	r�rGrrrrr�r�r��open_unknown_proxy�open_unknownr�rrrmr�r�r�)r�r�rIrbrerd�urltyperHr�	proxyhostrvr�r[r�rLrLrMrG�s<




zURLopener.opencCst|�\}}tdd|��dS)z/Overridable interface to open unknown URL type.z	url errorzunknown url typeN)rrm)r�r�rIr�rHrLrLrMr�szURLopener.open_unknowncCs t|�\}}tdd||��dS)z/Overridable interface to open unknown URL type.z	url errorzinvalid proxy for %sN)rrm)r�rr�rIr�rHrLrLrMr�	szURLopener.open_unknown_proxyc Cs&tt|��}|jr&||jkr&|j|St|�\}}|dkr�|sH|dkr�y.|j|�}|j�}|j�tt|�d�|fSt	k
r�}	zWYdd}	~	XnX|j
||�}�zH|j�}
|r�t
|d�}n|ddl}t|�\}
}t|p�d�\}
}t|p�d�\}}
t
|�pd�\}}
tjj|�d}|j|�\}}|jj|�tj|d�}z�||
f}|jdk	�r^||j|<d}d
}d}d}d	|
k�r�t|
d
�}|�r�||||�xH|j|�}|�s�P|t|�7}|j|�|d7}|�r�||||��q�WWd|j�XWd|j�X|dk�r"||k�r"td||f|��|S)ztretrieve(url) returns (filename, headers) for a local object
        or (tempfilename, headers) for a remote object.NrNrRrOrrnirQzcontent-lengthzContent-Lengthz1retrieval incomplete: got only %i out of %i bytesi rS)rrr�rr�rVr�r4rrmrGrZrrrWrX�splitextZmkstempr�r]�fdopenr^r_r`rar)r�rHrbrcrIr�Zurl1rdr�r�rerfrZZgarbagerX�suffix�fdrgrhrir_rjrkrLrLrM�retrievesl






zURLopener.retrievecCs(d}d}t|t�r<t|�\}}|r6t|�\}}t|�}|}nt|\}}t|�\}}t|�\}	}
|
}d}|	j�dkrvd}n:t|
�\}}
|r�t|�\}}|r�d|	||
f}t|�r�|}|s�tdd��|r�t|�}t	j
|j��jd�}nd}|�rt|�}t	j
|j��jd�}nd}||�}
i}|�r*d||d<|�r<d||d	<|�rJ||d
<d|d<x|j
D]\}}|||<�qZW|dk	�r�d
|d<|
jd|||�n|
jd||d�y|
j�}Wn"tjjk
�r�td��YnXd|jk�o�dkn�rt||jd||j�S|j||j|j|j|j|�SdS)a�Make an HTTP connection using connection_class.

        This is an internal method that should be called from
        open_http() or open_https().

        Arguments:
        - connection_factory should take a host name and return an
          HTTPConnection instance.
        - url is the url to retrieval or a host, relative-path pair.
        - data is payload for a POST request or None.
        Nr�z	%s://%s%sz
http errorz
no host givenrzBasic %szProxy-AuthorizationrNror�r�z!application/x-www-form-urlencodedzContent-Typer�r�)rez$http protocol error: bad status liner�i,zhttp:)r�r�rrr
rrtrrmrrrrr�rur�r�r�Z
BadStatusLinerZstatusrr��
http_errorrdr�)r�Zconnection_factoryrHrIZuser_passwdZproxy_passwdrvr�Zrealhostr�r�Z
proxy_authrMZ	http_connrerDr�r�rLrLrM�_open_generic_httpQsr



zURLopener._open_generic_httpcCs|jtjj||�S)zUse HTTP protocol.)r�r�r�r)r�rHrIrLrLrM�	open_http�szURLopener.open_httpc
Csbd|}t||�rPt||�}|dkr6||||||�}	n|||||||�}	|	rP|	S|j|||||�S)z�Handle http errors.

        Derived class can override this, or provide specific handlers
        named http_error_DDD where DDD is the 3-digit error code.z
http_error_%dN)r�r�r�)
r�rHrd�errcode�errmsgrerIr[rrgrLrLrMr��s

zURLopener.http_errorcCs|j�t||||d��dS)z>Default error handler: close the connection and raise OSError.N)r�r)r�rHrdr�r�rerLrLrMr��szURLopener.http_error_defaultcCstjj||j|jd�S)N)r�r�)r�r�r�r�r�)r�rvrLrLrM�_https_connection�szURLopener._https_connectioncCs|j|j||�S)zUse HTTPS protocol.)r�r�)r�rHrIrLrLrM�
open_https�szURLopener.open_httpscCs^t|t�std��|dd�dkrP|dd�dkrP|dd�j�dkrPtd	��n
|j|�SdS)
z/Use local file or FTP depending on form of URL.zEfile error: proxy support for file protocol currently not implementedNr:z//r>r��z
localhost/z-file:// scheme is supported only on localhost)r�r�rrtrBr�)r�rHrLrLrM�	open_file�s

4
zURLopener.open_filecCs\ddl}ddl}t|�\}}t|�}ytj|�}Wn0tk
rb}zt|j|j	��WYdd}~XnX|j
}	|jj|j
dd�}
|j|�d}|jd|p�d|	|
f�}|s�|}
|dd�dkr�d	|}
tt|d
�||
�St|�\}}|o�tj|�t�ft�k�rP|}
|dd�dk�r d	|}
n|dd�dk�r>td
|��tt|d
�||
�Std��dS)zUse local file.rNT)r�z6Content-Type: %s
Content-Length: %d
Last-modified: %s
z
text/plainrRr�zfile://r�r:z./zAlocal file url may start with / or file:. Unknown url of type: %sz#local file error: not on local host)r�r�rr4rWr�rmr�strerrorrbr�r�r�r�r�r�rrGr
r�r�r��thishostrB)r�rHr�r�rvrNZ	localnamer��erir�r�reZurlfiler/rLrLrMr��s: 
zURLopener.open_local_filecCs�t|t�std��ddl}t|�\}}|s2td��t|�\}}t|�\}}|r\t|�\}}nd}t|�}t|ppd�}t|p|d�}t	j
|�}|s�ddl}|j}nt
|�}t|�\}}	t|�}|jd�}
|
dd�|
d}
}|
o�|
d�r�|
dd�}
|
�r|
d�rd|
d<|||dj|
�f}t|j�tk�rlx8t|j�D]*}
|
|k�r>|j|
}|j|
=|j��q>Wy�||jk�r�t|||||
�|j|<|�s�d}nd	}x:|	D]2}t|�\}}|j�d
k�r�|dk�r�|j�}�q�W|j|j||�\}}|jd|�d}d}|�r|d|7}|dk	�r:|dk�r:|d|7}tj|�}t||d|�St�k
�r�}z td|�j t!j"�d��WYdd}~XnXdS)zUse FTP protocol.zCftp error: proxy support for ftp protocol currently not implementedrNzftp error: no host givenrnr�rRr�rSr�r�r�r�rxzftp:zContent-Type: %s
zContent-Length: %d
zftp error %rr:rSrS)r�r�r�rSrxr�)#r�r�rr�rr
rrr
r�r�r�r�r^rrCr�r`r��MAXFTPCACHEr�r�r�rrtr�r�r�r�r�r�	ftperrorsr�r�r�)r�rHr�rvrXr/rr r�r�r�rNr�r�r�r�r�r�rdr�r�rer�rLrLrM�open_ftp�sp







zURLopener.open_ftpc	Cs<t|t�std��y|jdd�\}}Wntk
rDtdd��YnX|sNd}|jd�}|dkr�d	||d
�kr�||dd
�}|d
|�}nd}g}|jdtj	d
tj
tj����|jd|�|dkr�tj|j
d��jd�}nt|�}|jdt|��|jd�|j|�dj|�}tj|�}tj|�}t|||�S)zUse "data" URL.zEdata error: proxy support for data protocol currently not implementedr�rRz
data errorzbad data URLztext/plain;charset=US-ASCII�;rr�NrnzDate: %sz%a, %d %b %Y %H:%M:%S GMTzContent-type: %srrzlatin-1zContent-Length: %d�
)r�r�rrCrBrm�rfindr]rdZstrftimeZgmtimerr�rrr
r`r�r�r�r��StringIOr)	r�rHrIr�Zsemirr�re�frLrLrM�	open_data3s6






zURLopener.open_data)N)N)N)N)NNN)N)N)N)N)r�r�r�r�r�r�r�r�r�r�r�r�rGr�r�r�r�r�r�r�rCr�r�r�r�rrrLrLrLrMr8�s.

$


B\


	 :c@s�eZdZdZdd�Zdd�Zd#dd�Zd	d
�Zd$dd�Zd%d
d�Z	d&dd�Z
d'dd�Zd(dd�Zd)dd�Z
d*dd�Zd+dd�Zd,dd�Zd-dd �Zd!d"�ZdS).r9z?Derived class with handlers for errors we can handle (perhaps).cOs(tj|f|�|�i|_d|_d|_dS)Nrr�)r8r��
auth_cache�tries�maxtries)r�r�r7rLrLrMr�`szFancyURLopener.__init__cCst||d||�S)z3Default error handling -- don't raise an exception.zhttp:)r)r�rHrdr�r�rerLrLrMr�fsz!FancyURLopener.http_error_defaultNc	
Csn|jd7_zR|jrJ|j|jkrJt|d�r4|j}n|j}|||dd|�S|j||||||�}|Sd|_XdS)z%Error 302 -- relocated (temporarily).rR�http_error_500i�z)Internal Server Error: Redirect RecursionNr)r
rr�rr��redirect_internal)	r�rHrdr�r�rerIr�rgrLrLrMr
js
zFancyURLopener.http_error_302c	Csxd|kr|d}nd|kr$|d}ndS|j�t|jd||�}t|�}|jd	krnt|||d|||��|j|�S)
Nr�r�r�r�r�r�rnz( Redirection to url '%s' is not allowed.)r�r�r�rn)r�rr�rrrrG)	r�rHrdr�r�rerIr�rrLrLrMr
|s


z FancyURLopener.redirect_internalcCs|j||||||�S)z*Error 301 -- also relocated (permanently).)r
)r�rHrdr�r�rerIrLrLrMr�szFancyURLopener.http_error_301cCs|j||||||�S)z;Error 303 -- also relocated (essentially identical to 302).)r
)r�rHrdr�r�rerIrLrLrMr�szFancyURLopener.http_error_303cCs2|dkr|j||||||�S|j|||||�SdS)z1Error 307 -- relocated, but turn POST into error.N)r
r�)r�rHrdr�r�rerIrLrLrMr
�szFancyURLopener.http_error_307Fc
Cs�d|krtj||||||�|d}tjd|�}	|	sHtj||||||�|	j�\}
}|
j�dkrttj||||||�|s�tj||||||�d|jd}|dkr�t||�||�St||�|||�SdS)z_Error 401 -- authentication required.
        This function supports Basic authentication only.zwww-authenticatez![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"rFZretry_�_basic_authN)r8r�rQ�matchrArtr�r�)
r�rHrdr�r�rerIry�stuffrrr&r[rLrLrMrU�s&





zFancyURLopener.http_error_401c
Cs�d|krtj||||||�|d}tjd|�}	|	sHtj||||||�|	j�\}
}|
j�dkrttj||||||�|s�tj||||||�d|jd}|dkr�t||�||�St||�|||�SdS)zeError 407 -- proxy authentication required.
        This function supports Basic authentication only.zproxy-authenticatez![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"rFZretry_proxy_rN)r8r�rQrrArtr�r�)
r�rHrdr�r�rerIryrrrr&r[rLrLrMrV�s&





zFancyURLopener.http_error_407cCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|d�}	|j|	||�\}}
|pl|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|j|�S|j||�SdS)Nzhttp://r��@rRz%s:%s@%srn)r)rrrr��get_user_passwdr	rG)r�rHr&rIrvr�r�rr�r��
proxyselectorr�rr rLrLrM�retry_proxy_http_basic_auth�s 

z*FancyURLopener.retry_proxy_http_basic_authcCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|d�}	|j|	||�\}}
|pl|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|j|�S|j||�SdS)Nzhttps://r�rrRz%s:%s@%srn)r)rrrr�rr	rG)r�rHr&rIrvr�r�rr�r�rr�rr rLrLrM�retry_proxy_https_basic_auth�s 

z+FancyURLopener.retry_proxy_https_basic_authc
Cs�t|�\}}|jd�d}||d�}|j|||�\}}|p>|sDdSdt|dd�t|dd�|f}d||}	|dkr�|j|	�S|j|	|�SdS)NrrRz%s:%s@%srn)rzhttp://)rr�rr	rG)
r�rHr&rIrvr�r�rr r�rLrLrMrG�s
z$FancyURLopener.retry_http_basic_authc
Cs�t|�\}}|jd�d}||d�}|j|||�\}}|p>|sDdSdt|dd�t|dd�|f}d||}	|dkr�|j|	�S|j|	|�SdS)NrrRz%s:%s@%srn)rzhttps://)rr�rr	rG)
r�rHr&rIrvr�r�rr r�rLrLrM�retry_https_basic_auth	s
z%FancyURLopener.retry_https_basic_authrcCs`|d|j�}||jkr2|r(|j|=n
|j|S|j||�\}}|sJ|rX||f|j|<||fS)Nr)rtr	�prompt_user_passwd)r�rvr&r�r�rr rLrLrMr	s


zFancyURLopener.get_user_passwdcCsTddl}y,td||f�}|jd|||f�}||fStk
rNt�dSXdS)z#Override this in a GUI environment!rNzEnter username for %s at %s: z#Enter password for %s in %s at %s: )NN)�getpass�input�KeyboardInterrupt�print)r�rvr&rrr rLrLrMr$	sz!FancyURLopener.prompt_user_passwd)N)N)N)N)NF)NF)N)N)N)N)r)r�r�r�r�r�r�r
r
rrr
rUrVrrrGrrrrLrLrLrMr9]s$










cCstdkrtjd�atS)z8Return the IP address of the magic hostname 'localhost'.Nr�)�
_localhostr�r�rLrLrLrMr�4	s
r�cCsPtdkrLyttjtj��d�aWn(tjk
rJttjd�d�aYnXtS)z,Return the IP addresses of the current host.Nr:r�)�	_thishostr%r�r�r�r�rLrLrLrMr�<	sr�cCstdkrddl}|jatS)z1Return the set of errors raised by the FTP class.Nr)�
_ftperrorsr�r�)r�rLrLrMrG	srcCstdkrtjd�atS)z%Return an empty email Message object.Nrn)�
_noheadersr�r�rLrLrLrM�	noheadersP	s
r c@sJeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)r�z;Class used by open_ftp() for cache of open FTP connections.NTc	CsX||_||_||_||_||_||_d|_||_y|j�Wn|j	��YnXdS)Nr)
rr rvr/r�rJ�refcount�	keepalive�initr�)r�rr rvr/r�rJr�rLrLrMr�]	szftpwrapper.__init__cCs\ddl}d|_|j�|_|jj|j|j|j�|jj|j	|j
�dj|j�}|jj
|�dS)Nrr�)r��busyZFTPr�Zconnectrvr/rJZloginrr r�r��cwd)r�r�Z_targetrLrLrMr#m	s
zftpwrapper.initc-Cs�ddl}|j�|dkr"d}d}nd|}d}y|jj|�Wn*|jk
rh|j�|jj|�YnXd}|r�|r�yd|}|jj|�\}}WnR|jk
r�}z4t|�dd�d	kr�t	d
|�j
tj�d��WYdd}~XnX|�s�|jjd�|�rn|jj
�}	zJy|jj|�Wn4|jk
�rP}zt	d
|�|�WYdd}~XnXWd|jj|	�Xd|}nd
}|jj|�\}}d|_t|jd�|j�}
|jd7_|j�|
|fS)Nrrxr�zTYPE ArRzTYPE zRETR r>Z550z
ftp error: %rr:zLIST ZLISTr�)rxr�)r��endtransferr�Zvoidcmdr�r#ZntransfercmdZ
error_permr�rr�r�r��pwdr%r$r�makefile�
file_closer!r�)r�rNr�r��cmd�isdirr�r�r�r'ZftpobjrLrLrMr�v	sN
 
$
zftpwrapper.retrfilecCs
d|_dS)Nr)r$)r�rLrLrMr&�	szftpwrapper.endtransfercCsd|_|jdkr|j�dS)NFr)r"r!�
real_close)r�rLrLrMr��	s
zftpwrapper.closecCs4|j�|jd8_|jdkr0|jr0|j�dS)NrRr)r&r!r"r,)r�rLrLrMr)�	szftpwrapper.file_closecCs2|j�y|jj�Wnt�k
r,YnXdS)N)r&r�r�r)r�rLrLrMr,�	s
zftpwrapper.real_close)NT)r�r�r�r�r�r#r�r&r�r)r,rLrLrLrMr�Z	s
	-r�cCs�i}xBtjj�D]4\}}|j�}|r|dd�dkr|||dd�<qWdtjkr^|jdd�xXtjj�D]J\}}|dd�dkrj|j�}|r�|||dd	�<qj|j|dd
�d�qjW|S)aReturn a dictionary of scheme -> proxy server URL mappings.

    Scan the environment for variables named <scheme>_proxy;
    this seems to be the standard convention.  If you need a
    different way, you can pass a proxies dictionary to the
    [Fancy]URLopener constructor.

    �N�_proxyZREQUEST_METHODr�i����i����i����i����i����)rW�environr{rtr�)rr[r�rLrLrM�getproxies_environment�	s	
r0c
Cs�|dkrt�}y|d}Wntk
r.dSX|dkr<dSt|�\}}dd�|jd�D�}xP|D]H}|rb|jd	�}tj|�}d
|}tj||tj�s�tj||tj�rbdSqbWdS)z�Test if proxies should not be used for a particular host.

    Checks the proxy dict for the value of no_proxy, which should
    be a list of comma separated DNS suffixes, or '*' for all hosts.

    N�nor�*rRcSsg|]}|j��qSrL)rO)r�rrLrLrMr$�	sz,proxy_bypass_environment.<locals>.<listcomp>r��.z
(.+\.)?%s$)	r0rrr
rC�lstriprQr�rrS)rvrZno_proxy�hostonlyr/Z
no_proxy_listr[�patternrLrLrM�proxy_bypass_environment�	s&


r7c
Csddlm}t|�\}}dd�}d|kr4|dr4dSd}x�|jd	f�D]�}|sPqFtjd
|�}|dk	�r|dkr�ytj|�}||�}Wntk
r�wFYnX||jd��}	|jd�}
|
dkr�d
|jd�j	d�d}
nt
|
dd��}
d|
}
||
?|	|
?k�rdSqF|||�rFdSqFWdS)aj
    Return True iff this host shouldn't be accessed using a proxy

    This function uses the MacOSX framework SystemConfiguration
    to fetch the proxy information.

    proxy_settings come from _scproxy._get_proxy_settings or get mocked ie:
    { 'exclude_simple': bool,
      'exceptions': ['foo.bar', '*.bar.com', '127.0.0.1', '10.1', '10.0/16']
    }
    r)�fnmatchcSsh|jd�}ttt|��}t|�dkr<|ddddgdd�}|dd>|dd>B|dd>B|d	BS)
Nr3r�r�rRrcr:rQr>)rCr�r�r^r`)ZipAddrr.rLrLrM�ip2num
s

z,_proxy_bypass_macosx_sysconf.<locals>.ip2numr3Zexclude_simpleTN�
exceptionsz(\d+(?:\.\d+)*)(/\d+)?rRr:rQ� F)r8r
r�rQrr�r�rm�group�countr^)rv�proxy_settingsr8r5r/r:ZhostIPr�r�r2�maskrLrLrM�_proxy_bypass_macosx_sysconf�	s:



rA�darwin)�_get_proxy_settings�_get_proxiescCst�}t||�S)N)rCrA)rvr?rLrLrM�proxy_bypass_macosx_sysconf:
srEcCst�S)z�Return a dictionary of scheme -> proxy server URL mappings.

        This function uses the MacOSX framework SystemConfiguration
        to fetch the proxy information.
        )rDrLrLrLrM�getproxies_macosx_sysconf>
srFcCs t�}|rt||�St|�SdS)z�Return True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or from the MacOSX framework SystemConfiguration.

        N)r0r7rE)rvrrLrLrMrH
s
rcCst�p
t�S)N)r0rFrLrLrLrMr5U
scCsi}yddl}Wntk
r$|SXy�|j|jd�}|j|d�d}|r�t|j|d�d�}d|kr�x�|jd�D]4}|jdd�\}}tjd	|�s�d
||f}|||<qrWn>|dd�dkr�||d
<n$d||d
<d||d<d||d<|j	�Wnt
ttfk
�rYnX|S)zxReturn a dictionary of scheme -> proxy server URL mappings.

        Win32 uses the registry to store proxies.

        rNz;Software\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyEnableZProxyServerr�rrRz^([^/:]+)://z%s://%sr[zhttp:r�z	http://%sz
https://%sr�zftp://%sr�)
�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�QueryValueExr�rCrQrZClosermrBr�)rrH�internetSettings�proxyEnableZproxyServer�pr�ZaddressrLrLrM�getproxies_registryZ
s8

rPcCst�p
t�S)z�Return a dictionary of scheme -> proxy server URL mappings.

        Returns settings gathered from the environment, if specified,
        or the registry.

        )r0rPrLrLrLrMr5�
sc&Cs~yddl}Wntk
r dSXy6|j|jd�}|j|d�d}t|j|d�d�}Wntk
rldSX|sz|r~dSt|�\}}|g}y tj	|�}||kr�|j
|�Wntk
r�YnXy tj|�}||kr�|j
|�Wntk
�r�YnX|jd�}xp|D]h}	|	dk�r*d|k�r*dS|	j
dd	�}	|	j
d
d�}	|	j
dd�}	x$|D]}
tj|	|
tj��rTdS�qTW�qWdS)
Nrz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsrGZ
ProxyOverriderz<local>r3rRz\.r2z.*�?)rHrIrJrKrLr�rmr
r�r�r]ZgetfqdnrCr�rQrrS)rvrHrMrNZ
proxyOverrideZrawHostr/ZaddrZfqdnr3r�rLrLrM�proxy_bypass_registry�
sR







rRcCs t�}|rt||�St|�SdS)z�Return True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.

        N)r0r7rR)rvrrLrLrMr�
s
)NNN)N)r�rr�r�rfZhttp.clientr�r�rWr0rQr�rr�rd�collectionsrZrTr?Zurllib.errorrrrZurllib.parserrrrr	r
rrr
rrrrrrrrrZurllib.responserrrDrIrC�__all__�version_infor�rFr�r0r1r\r6r7rR�ASCIIrrrwrrr2rr/rrrrr r!r"r#r$r%�urandomrer&r'r(rzr)r�r�rEr]rr.r]r_r*r�r+r,r-rr[Z
nturl2pathr4r3r�r8r9rr�rr�rrrr r�r0r7rA�platformZ_scproxyrCrDrErFrr5rPrRrLrLrLrM�<module>Ds�P
T
?n$q*@
ov

+3:5!AW

_
#<

-	2
PK�@�\>eddparse.cpython-36.opt-2.pycnu�[���3

���ie��@s�ddlZddlZddlZddlZddlZdddddddd	d
ddd
dddddddddgZdddddddddd d!d"d#d$d%d&d'd(d)gZdddddd*dddd!dd d+d"d#d$d,d&d'd%d-d.d/d(d)gZddd0d"dddd d#d$d1d2d!d%d3gZdd0d4d5d*ddd+d1d2g
Z	dddddd d!dd#d$d1d2gZ
ddd0ddd5dddd d+dd"g
Zd6Zd7Z
d8d9d:gZd;ZiZd<d=�Zd>Zd?Zd@dA�ZeefdBdC�ZeefdDdE�ZdFdG�ZGdHdI�dIe�ZGdJdK�dKe�ZGdLdM�dMe�ZGdNdO�dOee�ZGdPdQ�dQee�ZddRlmZeddS�ZeddT�Z eddU�Z!dVe_"dWej#_"dXej$_"dYe _"dZe j%_"d[e j&_"d\e j'_"d]e j(_"d^e j$_"d_e!_"e j%j"e!j%_"e j&j"e!j&_"e j'j"e!j'_"d`e!j)_"e j(j"e!j(_"e j$j"e!j$_"eZ*Gdad�dee�Z+Gdbd�de e�Z,Gdcd�de!e�Z-Gddd�dee�Z.Gded�de e�Z/Gdfd�de!e�Z0dgdh�Z1e1�[1d�djd�Z2dkdl�Z3d�dmdn�Z4dodp�Z5dqdr�Z6dsdt�Z7dudv�Z8d�dwd�Z9dxd�Z:dyd�Z;d�dzd�Z<d{d�Z=d|Z>da?d}d�Z@ejAd~�ZBd�d�d�ZCd�d�d	�ZDGd�d��d�eE�ZFd�ZGdaHd�d�d
�ZId�d�d�ZJeKd��ZLeMeL�ZNiZOGd�d��d�ejP�ZQd�d�d�ZRd�d�d�ZSd�d�d
�ZTd�dddeSfd�d�ZUd�d��ZVd�d��ZWdaXd�d��ZYdaZd�d��Z[d�d��Z\d�d��Z]da^d�d��Z_d�d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��ZddS)��N�urlparse�
urlunparse�urljoin�	urldefrag�urlsplit�
urlunsplit�	urlencode�parse_qs�	parse_qsl�quote�
quote_plus�quote_from_bytes�unquote�unquote_plus�unquote_to_bytes�DefragResult�ParseResult�SplitResult�DefragResultBytes�ParseResultBytes�SplitResultBytes�Zftp�httpZgopherZnntpZimapZwais�fileZhttpsZshttpZmmsZprosperoZrtspZrtspuZsftpZsvnzsvn+sshZwsZwssZtelnetZsnewsZrsyncZnfsZgitzgit+sshZhdlZsipZsipsZtelZmailtoZnewszAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.z!	

 �	�
�
�cCstj�tj�dS)N)�_parse_cache�clear�
_safe_quoters�r!r!�$/usr/lib64/python3.6/urllib/parse.py�clear_cache`sr#�ascii�strictcCs|S)Nr!)�objr!r!r"�_nooposr'cCs|j||�S)N)�encode)r&�encoding�errorsr!r!r"�_encode_resultrsr+cst��fdd�|D��S)Nc3s"|]}|r|j���ndVqdS)rN)�decode)�.0�x)r)r*r!r"�	<genexpr>xsz_decode_args.<locals>.<genexpr>)�tuple)�argsr)r*r!)r)r*r"�_decode_argsvsr2cGsZt|dt�}x.|dd�D]}|rt|t�|krtd��qW|rL|tfSt|�tfS)Nr�z$Cannot mix str and non-str arguments)�
isinstance�str�	TypeErrorr'r2r+)r1Z	str_input�argr!r!r"�_coerce_argszs
r8c@seZdZfZddd�ZdS)�_ResultMixinStrr$r%cs|j��fdd�|D��S)Nc3s|]}|j���VqdS)N)r()r-r.)r)r*r!r"r/�sz)_ResultMixinStr.encode.<locals>.<genexpr>)�_encoded_counterpart)�selfr)r*r!)r)r*r"r(�sz_ResultMixinStr.encodeN)r$r%)�__name__�
__module__�__qualname__�	__slots__r(r!r!r!r"r9�sr9c@seZdZfZddd�ZdS)�_ResultMixinBytesr$r%cs|j��fdd�|D��S)Nc3s|]}|j���VqdS)N)r,)r-r.)r)r*r!r"r/�sz+_ResultMixinBytes.decode.<locals>.<genexpr>)�_decoded_counterpart)r;r)r*r!)r)r*r"r,�sz_ResultMixinBytes.decodeN)r$r%)r<r=r>r?r,r!r!r!r"r@�sr@c@s@eZdZfZedd��Zedd��Zedd��Zedd��Zd	S)
�_NetlocResultMixinBasecCs
|jdS)Nr)�	_userinfo)r;r!r!r"�username�sz_NetlocResultMixinBase.usernamecCs
|jdS)Nr3)rC)r;r!r!r"�password�sz_NetlocResultMixinBase.passwordcCsD|jd}|sdSt|t�r dnd}|j|�\}}}|j�||S)Nr�%�%)�	_hostinfor4r5�	partition�lower)r;�hostname�	separatorZpercentZzoner!r!r"rK�s
z_NetlocResultMixinBase.hostnamecCs@|jd}|dk	r<t|d�}d|ko.dkns<td��|S)Nr3�
ri��zPort out of range 0-65535)rH�int�
ValueError)r;�portr!r!r"rP�s

z_NetlocResultMixinBase.portN)	r<r=r>r?�propertyrDrErKrPr!r!r!r"rB�s
rBc@s(eZdZfZedd��Zedd��ZdS)�_NetlocResultMixinStrcCsD|j}|jd�\}}}|r4|jd�\}}}|s<d}nd}}||fS)N�@�:)�netloc�
rpartitionrI)r;rU�userinfo�	have_info�hostinforD�
have_passwordrEr!r!r"rC�sz_NetlocResultMixinStr._userinfocCsl|j}|jd�\}}}|jd�\}}}|rL|jd�\}}}|jd�\}}}n|jd�\}}}|sdd}||fS)NrS�[�]rT)rUrVrI)r;rU�_rY�have_open_br�	bracketedrKrPr!r!r"rH�sz_NetlocResultMixinStr._hostinfoN)r<r=r>r?rQrCrHr!r!r!r"rR�srRc@s(eZdZfZedd��Zedd��ZdS)�_NetlocResultMixinBytescCsD|j}|jd�\}}}|r4|jd�\}}}|s<d}nd}}||fS)N�@�:)rUrVrI)r;rUrWrXrYrDrZrEr!r!r"rC�sz!_NetlocResultMixinBytes._userinfocCsl|j}|jd�\}}}|jd�\}}}|rL|jd�\}}}|jd�\}}}n|jd�\}}}|sdd}||fS)Nra�[�]rb)rUrVrI)r;rUr]rYr^r_rKrPr!r!r"rH�sz!_NetlocResultMixinBytes._hostinfoN)r<r=r>r?rQrCrHr!r!r!r"r`�sr`)�
namedtuplezurl fragmentz!scheme netloc path query fragmentz(scheme netloc path params query fragmentz�
DefragResult(url, fragment)

A 2-tuple that contains the url without fragment identifier and the fragment
identifier as a separate argument.
z$The URL with no fragment identifier.z�
Fragment identifier separated from URL, that allows indirect identification of a
secondary resource by reference to a primary resource and additional identifying
information.
z�
SplitResult(scheme, netloc, path, query, fragment)

A 5-tuple that contains the different components of a URL. Similar to
ParseResult, but does not split params.
z%Specifies URL scheme for the request.z0
Network location where the request is made to.
z@
The hierarchical path, such as the path to a file to download.
z�
The query component, that contains non-hierarchical data, that along with data
in path component, identifies a resource in the scope of URI's scheme and
network location.
z�
Fragment identifier, that allows indirect identification of a secondary resource
by reference to a primary resource and additional identifying information.
zr
ParseResult(scheme, netloc, path, params,  query, fragment)

A 6-tuple that contains components of a parsed URL.
z�
Parameters for last path element used to dereference the URI in order to provide
access to perform some operation on the resource.
c@seZdZfZdd�ZdS)rcCs |jr|jd|jS|jSdS)N�#)�fragment�url)r;r!r!r"�geturlEszDefragResult.geturlN)r<r=r>r?rir!r!r!r"rCsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"riMszSplitResult.geturlN)r<r=r>r?rir!r!r!r"rKsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"riRszParseResult.geturlN)r<r=r>r?rir!r!r!r"rPsc@seZdZfZdd�ZdS)rcCs |jr|jd|jS|jSdS)N�#)rgrh)r;r!r!r"riXszDefragResultBytes.geturlN)r<r=r>r?rir!r!r!r"rVsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"ri`szSplitResultBytes.geturlN)r<r=r>r?rir!r!r!r"r^sc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rieszParseResultBytes.geturlN)r<r=r>r?rir!r!r!r"rcscCs8ttfttfttff}x|D]\}}||_||_qWdS)N)rrrrrrr:rA)Z
_result_pairsZ_decodedZ_encodedr!r!r"�_fix_result_transcodingis
rkTc
Csft||�\}}}t|||�}|\}}}}}|tkrHd|krHt|�\}}nd}t||||||�}	||	�S)N�;r)r8r�uses_params�_splitparamsr)
rh�scheme�allow_fragments�_coerce_resultZsplitresultrU�queryrg�params�resultr!r!r"rvscCsRd|kr,|jd|jd��}|dkr6|dfSn
|jd�}|d|�||dd�fS)N�/rlrrr3)�find�rfind)rh�ir!r!r"rn�s

rncCsLt|�}x*dD]"}|j||�}|dkrt||�}qW|||�||d�fS)Nz/?#r)�lenrv�min)rh�start�delim�cZwdelimr!r!r"�_splitnetloc�s
r~cCs�|stdd�|D��rdSddl}|jdd�}|jdd�}|jdd�}|jdd�}|jd	|�}||krndSx(d
D] }||krttd|dd
��qtWdS)Ncss|]}t|�dkVqdS)�N)�ord)r-r}r!r!r"r/�sz_checknetloc.<locals>.<genexpr>rrSrrTrf�?�NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)�any�unicodedata�replace�	normalizerO)rUr��nZnetloc2r}r!r!r"�_checknetloc�s
r�cCsxtD]}|j|d�}qW|S)Nr)�_UNSAFE_URL_BYTES_TO_REMOVEr�)rh�br!r!r"�_remove_unsafe_bytes_from_url�s
r�cCst|jd�d}|jd�\}}}|rX|r.td��|jd�\}}}|rh|jd�rhtd��n|jd�\}}}t|�dS)NrS�r[zInvalid IPv6 URLr\rT)rVrIrO�
startswith�_check_bracketed_host)rUZhostname_and_portZbefore_bracketr^r_rKr]rPr!r!r"�_check_bracketed_netloc�s
r�cCsB|jd�r tjd|�s>td��ntj|�}t|tj�r>td��dS)N�vz\Av[a-fA-F0-9]+\..+\ZzIPvFuture address is invalidz%An IPv4 address cannot be in brackets)r��re�matchrO�	ipaddressZ
ip_addressr4ZIPv4Address)rKZipr!r!r"r��s


r�c
Cs�t||�\}}}t|�}t|�}|jt�}|jt�}t|�}|||t|�t|�f}tj|d�}|rj||�St	t�t
kr|t�d}}}|jd�}	|	dk�r�|d|	�dk�r~|d|	�j
�}||	dd�}|dd�dk�rt|d�\}}d|ko�d	|k�sd	|k�rd|k�rtd
��|�r<d|k�r<|jdd�\}}d|k�rV|jdd�\}}t|�t|||||�}
|
t|<||
�Sxd|d|	�D]}|tk�r�P�q�W||	dd�}|�s�td
d�|D���r�|d|	�j
�|}}|dd�dk�rPt|d�\}}d|k�rd	|k�s,d	|k�r4d|k�r4td
��d|k�rPd	|k�rPt|�|�rpd|k�rp|jdd�\}}d|k�r�|jdd�\}}t|�t|||||�}
|
t|<||
�S)NrrTrrr3r�z//r[r\zInvalid IPv6 URLrfr�css|]}|dkVqdS)�
0123456789Nr!)r-r}r!r!r"r/�szurlsplit.<locals>.<genexpr>)r8r��lstrip�_WHATWG_C0_CONTROL_OR_SPACE�strip�bool�typer�getry�MAX_CACHE_SIZEr#rvrJr~rO�splitr�r�scheme_charsr�r�)
rhrorprq�key�cachedrUrrrgrxr�r}�restr!r!r"r�sh






cCs<t|�\}}}}}}}|r&d||f}|t|||||f��S)Nz%s;%s)r8r)�
componentsrorUrhrsrrrgrqr!r!r"rscCs�t|�\}}}}}}|s4|r`|tkr`|dd�dkr`|rP|dd�dkrPd|}d|pXd|}|rp|d|}|r�|d|}|r�|d|}||�S)	Nr�z//r3rurrTr�rf)r8�uses_netloc)r�rorUrhrrrgrqr!r!r"rs cCs�|s|S|s|St||�\}}}t|d|�\}}}}}}	t|||�\}
}}}
}}|
|ks`|
tkrh||�S|
tkr�|r�|t|
|||
||f��S|}|r�|
r�|}|}
|s�|}|t|
|||
||f��S|jd�}|ddkr�|d=|dd�dk�r�|jd�}n(||jd�}td|dd��|dd	�<g}xX|D]P}|dk�rdy|j�Wntk
�r`YnXn|dk�rt�q0n
|j	|��q0W|d
dk�r�|j	d�|t|
|dj
|��p�d|
||f��S)Nrrur3�..�.���r�r�r�r�)r�r�)r8r�
uses_relativer�rr��filter�pop�
IndexError�append�join)�baserhrprqZbschemeZbnetlocZbpathZbparamsZbqueryZ	bfragmentrorU�pathrsrrrgZ
base_partsZsegmentsZ
resolved_pathZsegr!r!r"r*sT






c	CsTt|�\}}d|kr>t|�\}}}}}}t|||||df�}nd}|}|t||��S)Nrfr)r8rrr)	rhrq�sr��p�a�qZfragZdefragr!r!r"rosZ0123456789ABCDEFabcdefcCs�|s|jdSt|t�r"|jd�}|jd�}t|�dkr<|S|dg}|j}tdkrbdd�tD�axb|dd�D]R}y(|t|dd��||dd��Wqptk
r�|d�||�YqpXqpWdj	|�S)	N�zutf-8rGr3rcSs4i|],}tD]"}tt||d�g�||j��qqS)�)�_hexdig�bytesrNr()r-r�r�r!r!r"�
<dictcomp>�sz$unquote_to_bytes.<locals>.<dictcomp>r�)
r�r4r5r(ryr��
_hextobyter��KeyErrorr�)�string�bits�resr��itemr!r!r"r�s*



z([-]+)�utf-8r�cCs�d|kr|j|S|dkrd}|dkr*d}tj|�}|dg}|j}x@tdt|�d�D],}|t||�j||��|||d�qVWdj|�S)NrFzutf-8r�rr3r�r)r��_asciirer��rangeryrr,r�)r�r)r*r�r�r�rxr!r!r"r�s


Fc	CsRi}t|||||||d�}x2|D]*\}	}
|	|kr@||	j|
�q |
g||	<q W|S)N)r)r*�max_num_fieldsrL)r
r�)�qs�keep_blank_values�strict_parsingr)r*r�rLZ
parsed_result�pairs�name�valuer!r!r"r	�sc@seZdZdS)�_QueryStringSeparatorWarningN)r<r=r>r!r!r!r"r��sr�z/etc/python/urllib.cfgcCs�t|�\}}t|t�r |jd�}|s6t|ttf�rF|dk	rFtd��t�}|dk�rVt}d}	|dkrvtj	j
|	�}d}
|dkr�ytt�}Wnt
k
r�YnJX|�:ddl}|jdd&d�}
|
j|�|
j
d|	dd	�}|aWdQRXt}
|dk�rd
|k�rddlm}|d,tdd�d}n:|dk�r,|}n*t|�dk�rVt|	�d|
�d�dd��|dk	�r�||k�r�d|jd�|jd
�}nd|j|�}||k�r�td��||k�r�dd�|jd�D�}ndd�|j|�D�}g}x�|D]�}|�r�|�r��q�|jd d�}t|�dk�r>|�r(td!|f��|�r�|jd"�n�q�t|d��sR|�r�|djd#d$�}t|||d%�}||�}|djd#d$�}t|||d%�}||�}|j||f��q�W|S)-Nr$z*Separator must be of type string or bytes.ZPYTHON_URLLIB_QS_SEPARATORzenvironment variablerrf)Z
interpolationZcomment_prefixesr	)Zfallbackrl)�warnz4The default separator of urllib.parse.parse_qsl and z1parse_qs was changed to '&' to avoid a web cache z"poisoning issue (CVE-2021-23336). z4By default, semicolons no longer act as query field zseparators. z3See https://access.redhat.com/articles/5860431 for z
more details.r�)�
stacklevel�&Zlegacyr3z (from z) must contain z1 character, or "legacy". See z<https://access.redhat.com/articles/5860431 for more details.zMax number of fields exceededcSs g|]}|jd�D]}|�qqS)rl)r�)r-�s1�s2r!r!r"�
<listcomp>Lszparse_qsl.<locals>.<listcomp>cSsg|]}|�qSr!r!)r-r�r!r!r"r�Ns�=zbad query field: %rr�+� )r)r*)rfzeThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for aThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for more details.)r8r4r�r,r5rO�object�_default_qs_separator�os�environr��open�_QS_SEPARATOR_CONFIG_FILENAME�FileNotFoundError�configparserZConfigParserZ	read_file�warningsr�r�ry�countr�r�r�r)r�r�r�r)r*r�rLrqZ_legacyZenvvar_nameZ
config_sourcerr��configr��
num_fieldsr��rZ
name_valueZnvr�r�r!r!r"r
�s�












cCs|jdd�}t|||�S)Nr�r�)r�r)r�r)r*r!r!r"rfssAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-c@s$eZdZdd�Zdd�Zdd�ZdS)�QuotercCstj|�|_dS)N)�_ALWAYS_SAFE�union�safe)r;r�r!r!r"�__init__~szQuoter.__init__cCsd|jjt|�fS)Nz<%s %r>)�	__class__r<�dict)r;r!r!r"�__repr__�szQuoter.__repr__cCs(||jkrt|�ndj|�}|||<|S)Nz%{:02X})r��chr�format)r;r�r�r!r!r"�__missing__�szQuoter.__missing__N)r<r=r>r�r�r�r!r!r!r"r�vsr�rucCsbt|t�r8|s|S|dkrd}|dkr*d}|j||�}n |dk	rHtd��|dk	rXtd��t||�S)Nzutf-8r%z,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)r4r5r(r6r
)r�r�r)r*r!r!r"r�s
cCsdt|t�rd|ks$t|t�r2d|kr2t||||�St|t�rBd}nd}t|||||�}|jdd�S)Nr�� r�)r4r5r�rr�)r�r�r)r*Zspacer!r!r"r�s
cs�t|ttf�std��|sdSt|t�r6|jdd�}ntdd�|D��}|jt|�s^|j�Syt	|�Wn&t
k
r�t|�jt	|<�YnXdj
�fdd�|D��S)Nz!quote_from_bytes() expected bytesrr$�ignorecSsg|]}|dkr|�qS)�r!)r-r}r!r!r"r��sz$quote_from_bytes.<locals>.<listcomp>csg|]}�|��qSr!r!)r-�char)�quoterr!r"r��s)r4r��	bytearrayr6r5r(�rstrip�_ALWAYS_SAFE_BYTESr,r r�r��__getitem__r�)Zbsr�r!)r�r"r
�s
cCst|d�r|j�}nRy t|�r2t|dt�r2t�Wn0tk
rdtj�\}}}td�j|��YnXg}	|s�xr|D]j\}
}t|
t	�r�||
|�}
n|t
|
�|||�}
t|t	�r�|||�}n|t
|�|||�}|	j|
d|�qtW�n,�x(|D�]\}
}t|
t	��r||
|�}
n|t
|
�|||�}
t|t	��rL|||�}|	j|
d|�q�t|t
��rz|||||�}|	j|
d|�q�yt|�}Wn:tk
�r�|t
|�|||�}|	j|
d|�Yq�XxJ|D]B}
t|
t	��r�||
|�}
n|t
|
�|||�}
|	j|
d|
��q�Wq�Wdj|	�S)N�itemsrz1not a valid non-string sequence or mapping objectr�r�)
�hasattrr�ryr4r0r6�sys�exc_info�with_tracebackr�r5r�r�)rrZdoseqr�r)r*Z	quote_viaZtyZva�tb�l�kr�r.Zeltr!r!r"r�sP





cCsJt|t�rFy|jd�j�}Wn(tk
rDtdt|�d��YnX|S)N�ASCIIzURL z contains non-ASCII characters)r4r5r(r,�UnicodeError�repr)rhr!r!r"�to_bytes/s
r�cCs`t|�j�}|dd�dkr<|dd�dkr<|dd�j�}|dd�dkr\|dd�j�}|S)Nr3�<�>�zURL:r�r�)r5r�)rhr!r!r"�unwrap<s rcCsDtdkrtjdtj�atj|�}|r<|j�\}}|j�|fSd|fS)Nz
([^/:]+):(.*))�	_typeprogr��compile�DOTALLr��groupsrJ)rhr�ro�datar!r!r"�	splittypeEs
rcCsXtdkrtjdtj�atj|�}|rP|j�\}}|rH|ddkrHd|}||fSd|fS)Nz//([^/#?]*)(.*)rru)�	_hostprogr�rrr�r)rhr�Z	host_portr�r!r!r"�	splithostRs
r	cCs |jd�\}}}|r|nd|fS)NrS)rV)�host�userr|r!r!r"�	splituser`srcCs |jd�\}}}||r|ndfS)NrT)rI)rr|Zpasswdr!r!r"�splitpasswdesr
cCsDtdkrtjdtj�atj|�}|r<|j�\}}|r<||fS|dfS)Nz(.*):([0-9]*)$)�	_portprogr�rrr�r)r
r�rPr!r!r"�	splitportls
rr3cCsT|jd�\}}}|s|}n2|rLyt|�}Wntk
rBd}YnX||fS||fS)NrT)rVrNrO)r
Zdefportr|rPZnportr!r!r"�
splitnportys
rcCs$|jd�\}}}|r||fS|dfS)Nr�)rV)rhr�r|rrr!r!r"�
splitquery�srcCs$|jd�\}}}|r||fS|dfS)Nrf)rV)rhr�r|�tagr!r!r"�splittag�srcCs|jd�}|d|dd�fS)Nrlrr3)r�)rhZwordsr!r!r"�	splitattr�s
rcCs |jd�\}}}||r|ndfS)Nr�)rI)�attrr|r�r!r!r"�
splitvalue�sr)rT)r)rT)T)r�r�)FFr�r�NN)FFr�r�NN)r�r�)ruNN)rNN)rur�)r�)er�r�r��collectionsr��__all__r�r�rmZnon_hierarchicalZ
uses_queryZ
uses_fragmentr�r�r�r�rr#Z_implicit_encodingZ_implicit_errorsr'r+r2r8r�r9r@rBrRr`reZ_DefragResultBaseZ_SplitResultBaseZ_ParseResultBase�__doc__rhrgrorUr�rrrsZ
ResultBaserrrrrrrkrrnr~r�r�r�r�rrrrrr�r�rrr�rr	�RuntimeWarningr�r�r�r
r�	frozensetr�r�r�r �defaultdictr�rrr
rr�rrrrr	rr
rrrrrrrr!r!r!r"�<module>"s





!


	
	
B
E


&
y
	
,

O

PK�@�\���;!!error.cpython-36.opt-2.pycnu�[���3


 \Q
�@sLddlZdddgZGdd�de�ZGdd�deejj�ZGdd�de�ZdS)�N�URLError�	HTTPError�ContentTooShortErrorc@seZdZddd�Zdd�ZdS)rNcCs |f|_||_|dk	r||_dS)N)�args�reason�filename)�selfrr�r	�$/usr/lib64/python3.6/urllib/error.py�__init__szURLError.__init__cCs
d|jS)Nz<urlopen error %s>)r)rr	r	r
�__str__szURLError.__str__)N)�__name__�
__module__�__qualname__rrr	r	r	r
rs
c@sTeZdZejjjZdd�Zdd�Zdd�Z	e
dd��Ze
d	d
��Zej
dd
��ZdS)
rcCs:||_||_||_||_||_|dk	r6|j||||�dS)N)�code�msg�hdrs�fpr�_HTTPError__super_init)rZurlrrrrr	r	r
r'szHTTPError.__init__cCsd|j|jfS)NzHTTP Error %s: %s)rr)rr	r	r
r4szHTTPError.__str__cCsd|j|jfS)Nz<HTTPError %s: %r>)rr)rr	r	r
�__repr__7szHTTPError.__repr__cCs|jS)N)r)rr	r	r
r<szHTTPError.reasoncCs|jS)N)r)rr	r	r
�headers@szHTTPError.headerscCs
||_dS)N)r)rrr	r	r
rDsN)r
rr�urllib�response�
addinfourlrrrr�propertyrr�setterr	r	r	r
r#s

c@seZdZdd�ZdS)rcCstj||�||_dS)N)rr�content)r�messagerr	r	r
rKszContentTooShortError.__init__N)r
rrrr	r	r	r
rIs)	Zurllib.responser�__all__�OSErrorrrrrrr	r	r	r
�<module>s
&PK�@�\�
��� robotparser.cpython-36.opt-1.pycnu�[���3


 \�"�@s\dZddlZddlZddlZdgZejdd�ZGdd�d�ZGdd�d�Z	Gd	d
�d
�Z
dS)a% robotparser.py

    Copyright (C) 2000  Bastian Kleineidam

    You can choose between two licenses when using this package:
    1) GNU GPLv2
    2) PSF license for Python 2.2

    The robots.txt Exclusion Protocol is implemented as specified in
    http://www.robotstxt.org/norobots-rfc.txt
�N�RobotFileParser�RequestRatezrequests secondsc@sjeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rzs This class provides a set of methods to read, parse and answer
    questions about a single robots.txt file.

    �cCs,g|_d|_d|_d|_|j|�d|_dS)NFr)�entries�
default_entry�disallow_all�	allow_all�set_url�last_checked)�self�url�r
�*/usr/lib64/python3.6/urllib/robotparser.py�__init__s
zRobotFileParser.__init__cCs|jS)z�Returns the time the robots.txt file was last fetched.

        This is useful for long-running web spiders that need to
        check for new robots.txt files periodically.

        )r
)rr
r
r�mtime$szRobotFileParser.mtimecCsddl}|j�|_dS)zYSets the time the robots.txt file was last fetched to the
        current time.

        rN)�timer
)rrr
r
r�modified-szRobotFileParser.modifiedcCs&||_tjj|�dd�\|_|_dS)z,Sets the URL referring to a robots.txt file.��N)r�urllib�parse�urlparse�host�path)rrr
r
rr	5szRobotFileParser.set_urlcCs�ytjj|j�}WnRtjjk
rd}z2|jdkr:d|_n|jdkrT|jdkrTd|_WYdd}~XnX|j	�}|j
|jd�j��dS)	z4Reads the robots.txt URL and feeds it to the parser.��Ti�i�Nzutf-8)rr)
rZrequestZurlopenr�errorZ	HTTPError�coderr�readr�decode�
splitlines)r�f�err�rawr
r
rr:s
zRobotFileParser.readcCs,d|jkr|jdkr(||_n|jj|�dS)N�*)�
useragentsrr�append)r�entryr
r
r�
_add_entryGs

zRobotFileParser._add_entrycCs6d}t�}|j��x|D�]�}|sT|dkr8t�}d}n|dkrT|j|�t�}d}|jd�}|dkrr|d|�}|j�}|s�q|jdd�}t|�dkr|dj�j�|d<tj	j
|dj��|d<|ddk�r|dkr�|j|�t�}|jj|d�d}q|ddk�r4|dk�r|j
jt|dd	��d}q|dd
k�rh|dk�r|j
jt|dd��d}q|ddk�r�|dk�r|dj�j��r�t|d�|_d}q|dd
kr|dkr|djd�}t|�dk�r|dj�j��r|dj�j��rtt|d�t|d��|_d}qW|dk�r2|j|�dS)z�Parse the input lines from a robots.txt file.

        We allow that a user-agent: line is not preceded by
        one or more blank lines.
        rr��#N�:z
user-agentZdisallowFZallowTzcrawl-delayzrequest-rate�/)�Entryrr(�find�strip�split�len�lowerrr�unquoter%r&�	rulelines�RuleLine�isdigit�int�delayr�req_rate)r�lines�stater'�line�iZnumbersr
r
rrPsd






 
zRobotFileParser.parsecCs�|jr
dS|jrdS|jsdStjjtjj|��}tjjdd|j|j	|j
|jf�}tjj|�}|sfd}x"|j
D]}|j|�rn|j|�SqnW|jr�|jj|�SdS)z=using the parsed robots.txt decide if useragent can fetch urlFTrr,)rrr
rrrr3�
urlunparserZparamsZqueryZfragment�quoter�
applies_to�	allowancer)r�	useragentrZ
parsed_urlr'r
r
r�	can_fetch�s$
zRobotFileParser.can_fetchcCs4|j�sdSx|jD]}|j|�r|jSqW|jjS)N)rrr@r8r)rrBr'r
r
r�crawl_delay�s

zRobotFileParser.crawl_delaycCs4|j�sdSx|jD]}|j|�r|jSqW|jjS)N)rrr@r9r)rrBr'r
r
r�request_rate�s

zRobotFileParser.request_ratecCs0|j}|jdk	r||jg}djtt|��dS)N�
)rr�join�map�str)rrr
r
r�__str__�s
zRobotFileParser.__str__N)r)�__name__�
__module__�__qualname__�__doc__rrrr	rr(rrCrDrErJr
r
r
rrs
	
	Cc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r5zoA rule line is a single "Allow:" (allowance==True) or "Disallow:"
       (allowance==False) followed by a path.cCs>|dkr|rd}tjjtjj|��}tjj|�|_||_dS)NrT)rrr>rr?rrA)rrrAr
r
rr�s
zRuleLine.__init__cCs|jdkp|j|j�S)Nr$)r�
startswith)r�filenamer
r
rr@�szRuleLine.applies_tocCs|jr
dndd|jS)NZAllowZDisallowz: )rAr)rr
r
rrJ�szRuleLine.__str__N)rKrLrMrNrr@rJr
r
r
rr5�sr5c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r-z?An entry has one or more user-agents and zero or more rulelinescCsg|_g|_d|_d|_dS)N)r%r4r8r9)rr
r
rr�szEntry.__init__cCs�g}x|jD]}|jd|���qW|jdk	r@|jd|j���|jdk	rj|j}|jd|j�d|j���|jtt|j	��|jd�dj
|�S)NzUser-agent: z
Crawl-delay: zRequest-rate: r,rrF)r%r&r8r9ZrequestsZseconds�extendrHrIr4rG)rZret�agentZrater
r
rrJ�s


z
Entry.__str__cCsF|jd�dj�}x.|jD]$}|dkr*dS|j�}||krdSqWdS)z2check if this entry applies to the specified agentr,rr$TF)r0r2r%)rrBrRr
r
rr@�szEntry.applies_tocCs$x|jD]}|j|�r|jSqWdS)zZPreconditions:
        - our agent applies to this entry
        - filename is URL decodedT)r4r@rA)rrPr<r
r
rrA�s

zEntry.allowanceN)rKrLrMrNrrJr@rAr
r
r
rr-�s


r-)rN�collectionsZurllib.parserZurllib.request�__all__�
namedtuplerrr5r-r
r
r
r�<module>s2PK�@�\��d��
�
error.cpython-36.pycnu�[���3


 \Q
�@sPdZddlZdddgZGdd�de�ZGdd�deejj�ZGdd�de�Z	dS)	a�Exception classes raised by urllib.

The base exception class is URLError, which inherits from OSError.  It
doesn't define any behavior of its own, but is the base class for all
exceptions defined in this package.

HTTPError is an exception class that is also a valid HTTP response
instance.  It behaves this way because HTTP protocol errors are valid
responses, with a status code, headers, and a body.  In some contexts,
an application may want to handle an exception like a regular
response.
�N�URLError�	HTTPError�ContentTooShortErrorc@seZdZddd�Zdd�ZdS)rNcCs |f|_||_|dk	r||_dS)N)�args�reason�filename)�selfrr�r	�$/usr/lib64/python3.6/urllib/error.py�__init__szURLError.__init__cCs
d|jS)Nz<urlopen error %s>)r)rr	r	r
�__str__szURLError.__str__)N)�__name__�
__module__�__qualname__rrr	r	r	r
rs
c@sXeZdZdZejjjZdd�Zdd�Z	dd�Z
edd	��Zed
d��Z
e
jdd��Z
d
S)rzBRaised when HTTP error occurs, but also acts like non-error returncCs:||_||_||_||_||_|dk	r6|j||||�dS)N)�code�msg�hdrs�fpr�_HTTPError__super_init)rZurlrrrrr	r	r
r'szHTTPError.__init__cCsd|j|jfS)NzHTTP Error %s: %s)rr)rr	r	r
r4szHTTPError.__str__cCsd|j|jfS)Nz<HTTPError %s: %r>)rr)rr	r	r
�__repr__7szHTTPError.__repr__cCs|jS)N)r)rr	r	r
r<szHTTPError.reasoncCs|jS)N)r)rr	r	r
�headers@szHTTPError.headerscCs
||_dS)N)r)rrr	r	r
rDsN)r
rr�__doc__�urllib�response�
addinfourlrrrr�propertyrr�setterr	r	r	r
r#s

c@seZdZdZdd�ZdS)rzDException raised when downloaded size does not match content-length.cCstj||�||_dS)N)rr�content)r�messagerr	r	r
rKszContentTooShortError.__init__N)r
rrrrr	r	r	r
rIs)
rZurllib.responser�__all__�OSErrorrrrrrr	r	r	r
�<module>s

&PK�@�\�I�����parse.cpython-36.pycnu�[���3

���ie��@s�dZddlZddlZddlZddlZddlZddddddd	d
ddd
ddddddddddgZddddddddd d!d"d#d$d%d&d'd(d)d*gZdddddd+dddd"d d!d,d#d$d%d-d'd(d&d.d/d0d)d*gZddd1d#ddd d!d$d%d2d3d"d&d4gZ	dd1d5d6d+ddd,d2d3g
Z
ddddd d!d"dd$d%d2d3gZddd1ddd6ddd d!d,dd#g
Zd7Z
d8Zd9d:d;gZd<ZiZd=d>�Zd?Zd@ZdAdB�ZeefdCdD�ZeefdEdF�ZdGdH�ZGdIdJ�dJe�ZGdKdL�dLe�ZGdMdN�dNe�ZGdOdP�dPee�ZGdQdR�dRee�ZddSlmZeddT�Z eddU�Z!eddV�Z"dWe _dXe j#_dYe j$_dZe!_d[e!j%_d\e!j&_d]e!j'_d^e!j(_d_e!j$_d`e"_e!j%je"j%_e!j&je"j&_e!j'je"j'_dae"j)_e!j(je"j(_e!j$je"j$_eZ*Gdbd�de e�Z+Gdcd�de!e�Z,Gddd�de"e�Z-Gded�de e�Z.Gdfd�de!e�Z/Gdgd�de"e�Z0dhdi�Z1e1�[1d�dkd�Z2dldm�Z3d�dndo�Z4dpdq�Z5drds�Z6dtdu�Z7dvdw�Z8d�dxd�Z9dyd�Z:dzd�Z;d�d{d�Z<d|d�Z=d}Z>da?d~d�Z@ejAd�ZBd�d�d�ZCd�d�d
�ZDGd�d��d�eE�ZFd�ZGdaHd�d�d�ZId�d�d�ZJeKd��ZLeMeL�ZNiZOGd�d��d�ejP�ZQd�d�d�ZRd�d�d
�ZSd�d�d�ZTd�dddeSfd�d	�ZUd�d��ZVd�d��ZWdaXd�d��ZYdaZd�d��Z[d�d��Z\d�d��Z]da^d�d��Z_d�d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��ZddS)�a3Parse (absolute and relative) URLs.

urlparse module is based upon the following RFC specifications.

RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
and L.  Masinter, January 2005.

RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
and L.Masinter, December 1999.

RFC 2396:  "Uniform Resource Identifiers (URI)": Generic Syntax by T.
Berners-Lee, R. Fielding, and L. Masinter, August 1998.

RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998.

RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June
1995.

RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M.
McCahill, December 1994

RFC 3986 is considered the current standard and any future changes to
urlparse module should conform with it.  The urlparse module is
currently not entirely compliant with this RFC due to defacto
scenarios for parsing, and for backward compatibility purposes, some
parsing quirks from older RFCs are retained. The testcases in
test_urlparse.py provides a good indicator of parsing behavior.

The WHATWG URL Parser spec should also be considered.  We are not compliant with
it either due to existing user code API behavior expectations (Hyrum's Law).
It serves as a useful guide when making changes.
�N�urlparse�
urlunparse�urljoin�	urldefrag�urlsplit�
urlunsplit�	urlencode�parse_qs�	parse_qsl�quote�
quote_plus�quote_from_bytes�unquote�unquote_plus�unquote_to_bytes�DefragResult�ParseResult�SplitResult�DefragResultBytes�ParseResultBytes�SplitResultBytes�Zftp�httpZgopherZnntpZimapZwais�fileZhttpsZshttpZmmsZprosperoZrtspZrtspuZsftpZsvnzsvn+sshZwsZwssZtelnetZsnewsZrsyncZnfsZgitzgit+sshZhdlZsipZsipsZtelZmailtoZnewszAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.z!	

 �	�
�
�cCstj�tj�dS)z,Clear the parse cache and the quoters cache.N)�_parse_cache�clear�
_safe_quoters�r!r!�$/usr/lib64/python3.6/urllib/parse.py�clear_cache`sr#�ascii�strictcCs|S)Nr!)�objr!r!r"�_nooposr'cCs|j||�S)N)�encode)r&�encoding�errorsr!r!r"�_encode_resultrsr+cst��fdd�|D��S)Nc3s"|]}|r|j���ndVqdS)rN)�decode)�.0�x)r)r*r!r"�	<genexpr>xsz_decode_args.<locals>.<genexpr>)�tuple)�argsr)r*r!)r)r*r"�_decode_argsvsr2cGsZt|dt�}x.|dd�D]}|rt|t�|krtd��qW|rL|tfSt|�tfS)Nr�z$Cannot mix str and non-str arguments)�
isinstance�str�	TypeErrorr'r2r+)r1Z	str_input�argr!r!r"�_coerce_argszs
r8c@seZdZdZfZddd�ZdS)�_ResultMixinStrz>Standard approach to encoding parsed results from str to bytesr$r%cs|j��fdd�|D��S)Nc3s|]}|j���VqdS)N)r()r-r.)r)r*r!r"r/�sz)_ResultMixinStr.encode.<locals>.<genexpr>)�_encoded_counterpart)�selfr)r*r!)r)r*r"r(�sz_ResultMixinStr.encodeN)r$r%)�__name__�
__module__�__qualname__�__doc__�	__slots__r(r!r!r!r"r9�sr9c@seZdZdZfZddd�ZdS)�_ResultMixinBytesz>Standard approach to decoding parsed results from bytes to strr$r%cs|j��fdd�|D��S)Nc3s|]}|j���VqdS)N)r,)r-r.)r)r*r!r"r/�sz+_ResultMixinBytes.decode.<locals>.<genexpr>)�_decoded_counterpart)r;r)r*r!)r)r*r"r,�sz_ResultMixinBytes.decodeN)r$r%)r<r=r>r?r@r,r!r!r!r"rA�srAc@sDeZdZdZfZedd��Zedd��Zedd��Zedd	��Z	d
S)�_NetlocResultMixinBasezHShared methods for the parsed result objects containing a netloc elementcCs
|jdS)Nr)�	_userinfo)r;r!r!r"�username�sz_NetlocResultMixinBase.usernamecCs
|jdS)Nr3)rD)r;r!r!r"�password�sz_NetlocResultMixinBase.passwordcCsD|jd}|sdSt|t�r dnd}|j|�\}}}|j�||S)Nr�%�%)�	_hostinfor4r5�	partition�lower)r;�hostname�	separatorZpercentZzoner!r!r"rL�s
z_NetlocResultMixinBase.hostnamecCs@|jd}|dk	r<t|d�}d|ko.dkns<td��|S)Nr3�
ri��zPort out of range 0-65535)rI�int�
ValueError)r;�portr!r!r"rQ�s

z_NetlocResultMixinBase.portN)
r<r=r>r?r@�propertyrErFrLrQr!r!r!r"rC�srCc@s(eZdZfZedd��Zedd��ZdS)�_NetlocResultMixinStrcCsD|j}|jd�\}}}|r4|jd�\}}}|s<d}nd}}||fS)N�@�:)�netloc�
rpartitionrJ)r;rV�userinfo�	have_info�hostinforE�
have_passwordrFr!r!r"rD�sz_NetlocResultMixinStr._userinfocCsl|j}|jd�\}}}|jd�\}}}|rL|jd�\}}}|jd�\}}}n|jd�\}}}|sdd}||fS)NrT�[�]rU)rVrWrJ)r;rV�_rZ�have_open_br�	bracketedrLrQr!r!r"rI�sz_NetlocResultMixinStr._hostinfoN)r<r=r>r@rRrDrIr!r!r!r"rS�srSc@s(eZdZfZedd��Zedd��ZdS)�_NetlocResultMixinBytescCsD|j}|jd�\}}}|r4|jd�\}}}|s<d}nd}}||fS)N�@�:)rVrWrJ)r;rVrXrYrZrEr[rFr!r!r"rD�sz!_NetlocResultMixinBytes._userinfocCsl|j}|jd�\}}}|jd�\}}}|rL|jd�\}}}|jd�\}}}n|jd�\}}}|sdd}||fS)Nrb�[�]rc)rVrWrJ)r;rVr^rZr_r`rLrQr!r!r"rI�sz!_NetlocResultMixinBytes._hostinfoN)r<r=r>r@rRrDrIr!r!r!r"ra�sra)�
namedtuplezurl fragmentz!scheme netloc path query fragmentz(scheme netloc path params query fragmentz�
DefragResult(url, fragment)

A 2-tuple that contains the url without fragment identifier and the fragment
identifier as a separate argument.
z$The URL with no fragment identifier.z�
Fragment identifier separated from URL, that allows indirect identification of a
secondary resource by reference to a primary resource and additional identifying
information.
z�
SplitResult(scheme, netloc, path, query, fragment)

A 5-tuple that contains the different components of a URL. Similar to
ParseResult, but does not split params.
z%Specifies URL scheme for the request.z0
Network location where the request is made to.
z@
The hierarchical path, such as the path to a file to download.
z�
The query component, that contains non-hierarchical data, that along with data
in path component, identifies a resource in the scope of URI's scheme and
network location.
z�
Fragment identifier, that allows indirect identification of a secondary resource
by reference to a primary resource and additional identifying information.
zr
ParseResult(scheme, netloc, path, params,  query, fragment)

A 6-tuple that contains components of a parsed URL.
z�
Parameters for last path element used to dereference the URI in order to provide
access to perform some operation on the resource.
c@seZdZfZdd�ZdS)rcCs |jr|jd|jS|jSdS)N�#)�fragment�url)r;r!r!r"�geturlEszDefragResult.geturlN)r<r=r>r@rjr!r!r!r"rCsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rjMszSplitResult.geturlN)r<r=r>r@rjr!r!r!r"rKsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rjRszParseResult.geturlN)r<r=r>r@rjr!r!r!r"rPsc@seZdZfZdd�ZdS)rcCs |jr|jd|jS|jSdS)N�#)rhri)r;r!r!r"rjXszDefragResultBytes.geturlN)r<r=r>r@rjr!r!r!r"rVsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rj`szSplitResultBytes.geturlN)r<r=r>r@rjr!r!r!r"r^sc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rjeszParseResultBytes.geturlN)r<r=r>r@rjr!r!r!r"rcscCs8ttfttfttff}x|D]\}}||_||_qWdS)N)rrrrrrr:rB)Z
_result_pairsZ_decodedZ_encodedr!r!r"�_fix_result_transcodingis
rlTc
Csft||�\}}}t|||�}|\}}}}}|tkrHd|krHt|�\}}nd}t||||||�}	||	�S)a#Parse a URL into 6 components:
    <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
    Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
    Note that we don't break the components up in smaller bits
    (e.g. netloc is a single string) and we don't expand % escapes.�;r)r8r�uses_params�_splitparamsr)
ri�scheme�allow_fragments�_coerce_resultZsplitresultrV�queryrh�params�resultr!r!r"rvscCsRd|kr,|jd|jd��}|dkr6|dfSn
|jd�}|d|�||dd�fS)N�/rmrrr3)�find�rfind)ri�ir!r!r"ro�s

rocCsLt|�}x*dD]"}|j||�}|dkrt||�}qW|||�||d�fS)Nz/?#r)�lenrw�min)ri�start�delim�cZwdelimr!r!r"�_splitnetloc�s
rcCs�|stdd�|D��rdSddl}|jdd�}|jdd�}|jdd�}|jdd�}|jd	|�}||krndSx(d
D] }||krttd|dd
��qtWdS)Ncss|]}t|�dkVqdS)�N)�ord)r-r~r!r!r"r/�sz_checknetloc.<locals>.<genexpr>rrTrrUrg�?�NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)�any�unicodedata�replace�	normalizerP)rVr��nZnetloc2r~r!r!r"�_checknetloc�s
r�cCsxtD]}|j|d�}qW|S)Nr)�_UNSAFE_URL_BYTES_TO_REMOVEr�)ri�br!r!r"�_remove_unsafe_bytes_from_url�s
r�cCst|jd�d}|jd�\}}}|rX|r.td��|jd�\}}}|rh|jd�rhtd��n|jd�\}}}t|�dS)NrT�r\zInvalid IPv6 URLr]rU)rWrJrP�
startswith�_check_bracketed_host)rVZhostname_and_portZbefore_bracketr_r`rLr^rQr!r!r"�_check_bracketed_netloc�s
r�cCsB|jd�r tjd|�s>td��ntj|�}t|tj�r>td��dS)N�vz\Av[a-fA-F0-9]+\..+\ZzIPvFuture address is invalidz%An IPv4 address cannot be in brackets)r��re�matchrP�	ipaddressZ
ip_addressr4ZIPv4Address)rLZipr!r!r"r��s


r�c
Cs�t||�\}}}t|�}t|�}|jt�}|jt�}t|�}|||t|�t|�f}tj|d�}|rj||�St	t�t
kr|t�d}}}|jd�}	|	dk�r�|d|	�dk�r~|d|	�j
�}||	dd�}|dd�dk�rt|d�\}}d	|ko�d
|k�sd
|k�rd	|k�rtd��|�r<d|k�r<|jdd�\}}d
|k�rV|jd
d�\}}t|�t|||||�}
|
t|<||
�Sxd|d|	�D]}|tk�r�P�q�W||	dd�}|�s�tdd�|D���r�|d|	�j
�|}}|dd�dk�rPt|d�\}}d	|k�rd
|k�s,d
|k�r4d	|k�r4td��d	|k�rPd
|k�rPt|�|�rpd|k�rp|jdd�\}}d
|k�r�|jd
d�\}}t|�t|||||�}
|
t|<||
�S)aParse a URL into 5 components:
    <scheme>://<netloc>/<path>?<query>#<fragment>
    Return a 5-tuple: (scheme, netloc, path, query, fragment).
    Note that we don't break the components up in smaller bits
    (e.g. netloc is a single string) and we don't expand % escapes.NrrUrrr3r�z//r\r]zInvalid IPv6 URLrgr�css|]}|dkVqdS)�
0123456789Nr!)r-r~r!r!r"r/�szurlsplit.<locals>.<genexpr>)r8r��lstrip�_WHATWG_C0_CONTROL_OR_SPACE�strip�bool�typer�getrz�MAX_CACHE_SIZEr#rwrKrrP�splitr�r�scheme_charsr�r�)
rirprqrr�key�cachedrVrsrhryr�r~�restr!r!r"r�sh






cCs<t|�\}}}}}}}|r&d||f}|t|||||f��S)z�Put a parsed URL back together again.  This may result in a
    slightly different, but equivalent URL, if the URL that was parsed
    originally had redundant delimiters, e.g. a ? with an empty query
    (the draft states that these are equivalent).z%s;%s)r8r)�
componentsrprVrirtrsrhrrr!r!r"rscCs�t|�\}}}}}}|s4|r`|tkr`|dd�dkr`|rP|dd�dkrPd|}d|pXd|}|rp|d|}|r�|d|}|r�|d	|}||�S)
akCombine the elements of a tuple as returned by urlsplit() into a
    complete URL as a string. The data argument can be any five-item iterable.
    This may result in a slightly different, but equivalent URL, if the URL that
    was parsed originally had unnecessary delimiters (for example, a ? with an
    empty query; the RFC states that these are equivalent).Nr�z//r3rvrrUr�rg)r8�uses_netloc)r�rprVrirsrhrrr!r!r"rs cCs�|s|S|s|St||�\}}}t|d|�\}}}}}}	t|||�\}
}}}
}}|
|ks`|
tkrh||�S|
tkr�|r�|t|
|||
||f��S|}|r�|
r�|}|}
|s�|}|t|
|||
||f��S|jd�}|ddkr�|d=|dd�dk�r�|jd�}n(||jd�}td|dd	��|dd
�<g}xX|D]P}|dk�rdy|j�Wntk
�r`YnXn|dk�rt�q0n
|j	|��q0W|ddk�r�|j	d�|t|
|dj
|��p�d|
||f��S)
zaJoin a base URL and a possibly relative URL to form an absolute
    interpretation of the latter.rrvr3N�..�.���r�r�r�r�)r�r�)r8r�
uses_relativer�rr��filter�pop�
IndexError�append�join)�baserirqrrZbschemeZbnetlocZbpathZbparamsZbqueryZ	bfragmentrprV�pathrtrsrhZ
base_partsZsegmentsZ
resolved_pathZsegr!r!r"r*sT






c	CsTt|�\}}d|kr>t|�\}}}}}}t|||||df�}nd}|}|t||��S)z�Removes any existing fragment from URL.

    Returns a tuple of the defragmented URL and the fragment.  If
    the URL contained no fragments, the second element is the
    empty string.
    rgr)r8rrr)	rirr�sr��p�a�qZfragZdefragr!r!r"rosZ0123456789ABCDEFabcdefcCs�|s|jdSt|t�r"|jd�}|jd�}t|�dkr<|S|dg}|j}tdkrbdd�tD�axb|dd�D]R}y(|t|dd	��||d	d��Wqptk
r�|d�||�YqpXqpWdj	|�S)
z,unquote_to_bytes('abc%20def') -> b'abc def'.�zutf-8rHr3rNcSs4i|],}tD]"}tt||d�g�||j��qqS)�)�_hexdig�bytesrOr()r-r�r�r!r!r"�
<dictcomp>�sz$unquote_to_bytes.<locals>.<dictcomp>r�)
r�r4r5r(rzr��
_hextobyter��KeyErrorr�)�string�bits�resr��itemr!r!r"r�s*



z([-]+)�utf-8r�cCs�d|kr|j|S|dkrd}|dkr*d}tj|�}|dg}|j}x@tdt|�d�D],}|t||�j||��|||d�qVWdj|�S)	a�Replace %xx escapes by their single-character equivalent. The optional
    encoding and errors parameters specify how to decode percent-encoded
    sequences into Unicode characters, as accepted by the bytes.decode()
    method.
    By default, percent-encoded sequences are decoded with UTF-8, and invalid
    sequences are replaced by a placeholder character.

    unquote('abc%20def') -> 'abc def'.
    rGNzutf-8r�rr3r�r)r��_asciirer��rangerzrr,r�)r�r)r*r�r�r�ryr!r!r"r�s


Fc	CsRi}t|||||||d�}x2|D]*\}	}
|	|kr@||	j|
�q |
g||	<q W|S)a�Parse a query given as a string argument.

        Arguments:

        qs: percent-encoded query string to be parsed

        keep_blank_values: flag indicating whether blank values in
            percent-encoded queries should be treated as blank strings.
            A true value indicates that blanks should be retained as
            blank strings.  The default false value indicates that
            blank values are to be ignored and treated as if they were
            not included.

        strict_parsing: flag indicating what to do with parsing errors.
            If false (the default), errors are silently ignored.
            If true, errors raise a ValueError exception.

        encoding and errors: specify how to decode percent-encoded sequences
            into Unicode characters, as accepted by the bytes.decode() method.

        max_num_fields: int. If set, then throws a ValueError if there
            are more than n fields read by parse_qsl().

        Returns a dictionary.
    )r)r*�max_num_fieldsrM)r
r�)�qs�keep_blank_values�strict_parsingr)r*r�rMZ
parsed_result�pairs�name�valuer!r!r"r	�sc@seZdZdZdS)�_QueryStringSeparatorWarningz>Warning for using default `separator` in parse_qs or parse_qslN)r<r=r>r?r!r!r!r"r��sr�z/etc/python/urllib.cfgcCs�t|�\}}t|t�r |jd�}|s6t|ttf�rF|dk	rFtd��t�}|dk�rVt}d}	|dkrvtj	j
|	�}d}
|dkr�ytt�}Wnt
k
r�YnJX|�:ddl}|jdd'd�}
|
j|�|
j
d	|	dd
�}|aWdQRXt}
|dk�rd|k�rddlm}|d-tdd�d}n:|dk�r,|}n*t|�dk�rVt|	�d|
�d�dd��|dk	�r�||k�r�d|jd�|jd�}nd|j|�}||k�r�td��||k�r�dd�|jd�D�}nd d�|j|�D�}g}x�|D]�}|�r�|�r��q�|jd!d�}t|�dk�r>|�r(td"|f��|�r�|jd#�n�q�t|d��sR|�r�|djd$d%�}t|||d&�}||�}|djd$d%�}t|||d&�}||�}|j||f��q�W|S).a�Parse a query given as a string argument.

        Arguments:

        qs: percent-encoded query string to be parsed

        keep_blank_values: flag indicating whether blank values in
            percent-encoded queries should be treated as blank strings.
            A true value indicates that blanks should be retained as blank
            strings.  The default false value indicates that blank values
            are to be ignored and treated as if they were  not included.

        strict_parsing: flag indicating what to do with parsing errors. If
            false (the default), errors are silently ignored. If true,
            errors raise a ValueError exception.

        encoding and errors: specify how to decode percent-encoded sequences
            into Unicode characters, as accepted by the bytes.decode() method.

        max_num_fields: int. If set, then throws a ValueError
            if there are more than n fields read by parse_qsl().

        Returns a list, as G-d intended.
    r$Nz*Separator must be of type string or bytes.ZPYTHON_URLLIB_QS_SEPARATORzenvironment variablerrg)Z
interpolationZcomment_prefixesr	)Zfallbackrm)�warnz4The default separator of urllib.parse.parse_qsl and z1parse_qs was changed to '&' to avoid a web cache z"poisoning issue (CVE-2021-23336). z4By default, semicolons no longer act as query field zseparators. z3See https://access.redhat.com/articles/5860431 for z
more details.r�)�
stacklevel�&Zlegacyr3z (from z) must contain z1 character, or "legacy". See z<https://access.redhat.com/articles/5860431 for more details.zMax number of fields exceededcSs g|]}|jd�D]}|�qqS)rm)r�)r-�s1�s2r!r!r"�
<listcomp>Lszparse_qsl.<locals>.<listcomp>cSsg|]}|�qSr!r!)r-r�r!r!r"r�Ns�=zbad query field: %rr�+� )r)r*)rgzeThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for aThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for more details.)r8r4r�r,r5rP�object�_default_qs_separator�os�environr��open�_QS_SEPARATOR_CONFIG_FILENAME�FileNotFoundError�configparserZConfigParserZ	read_file�warningsr�r�rz�countr�r�r�r)r�r�r�r)r*r�rMrrZ_legacyZenvvar_nameZ
config_sourcerr��configr��
num_fieldsr��rZ
name_valueZnvr�r�r!r!r"r
�s�












cCs|jdd�}t|||�S)z�Like unquote(), but also replace plus signs by spaces, as required for
    unquoting HTML form values.

    unquote_plus('%7e/abc+def') -> '~/abc def'
    r�r�)r�r)r�r)r*r!r!r"rfssAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Quoterz�A mapping from bytes (in range(0,256)) to strings.

    String values are percent-encoded byte values, unless the key < 128, and
    in the "safe" set (either the specified safe set, or default set).
    cCstj|�|_dS)zsafe: bytes object.N)�_ALWAYS_SAFE�union�safe)r;r�r!r!r"�__init__~szQuoter.__init__cCsd|jjt|�fS)Nz<%s %r>)�	__class__r<�dict)r;r!r!r"�__repr__�szQuoter.__repr__cCs(||jkrt|�ndj|�}|||<|S)Nz%{:02X})r��chr�format)r;r�r�r!r!r"�__missing__�szQuoter.__missing__N)r<r=r>r?r�r�r�r!r!r!r"r�vsr�rvcCsbt|t�r8|s|S|dkrd}|dkr*d}|j||�}n |dk	rHtd��|dk	rXtd��t||�S)a�quote('abc def') -> 'abc%20def'

    Each part of a URL, e.g. the path info, the query, etc., has a
    different set of reserved characters that must be quoted.

    RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
    the following reserved characters.

    reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                  "$" | ","

    Each of these characters is reserved in some component of a URL,
    but not necessarily in all of them.

    By default, the quote function is intended for quoting the path
    section of a URL.  Thus, it will not encode '/'.  This character
    is reserved, but in typical usage the quote function is being
    called on a path where the existing slash characters are used as
    reserved characters.

    string and safe may be either str or bytes objects. encoding and errors
    must not be specified if string is a bytes object.

    The optional encoding and errors parameters specify how to deal with
    non-ASCII characters, as accepted by the str.encode method.
    By default, encoding='utf-8' (characters are encoded with UTF-8), and
    errors='strict' (unsupported characters raise a UnicodeEncodeError).
    Nzutf-8r%z,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)r4r5r(r6r
)r�r�r)r*r!r!r"r�s
cCsdt|t�rd|ks$t|t�r2d|kr2t||||�St|t�rBd}nd}t|||||�}|jdd�S)z�Like quote(), but also replace ' ' with '+', as required for quoting
    HTML form values. Plus signs in the original string are escaped unless
    they are included in safe. It also does not have safe default to '/'.
    r�� r�)r4r5r�rr�)r�r�r)r*Zspacer!r!r"r�s
cs�t|ttf�std��|sdSt|t�r6|jdd�}ntdd�|D��}|jt|�s^|j�Syt	|�Wn&t
k
r�t|�jt	|<�YnXdj
�fdd�|D��S)z�Like quote(), but accepts a bytes object rather than a str, and does
    not perform string-to-bytes encoding.  It always returns an ASCII string.
    quote_from_bytes(b'abc def?') -> 'abc%20def%3f'
    z!quote_from_bytes() expected bytesrr$�ignorecSsg|]}|dkr|�qS)�r!)r-r~r!r!r"r��sz$quote_from_bytes.<locals>.<listcomp>csg|]}�|��qSr!r!)r-�char)�quoterr!r"r��s)r4r��	bytearrayr6r5r(�rstrip�_ALWAYS_SAFE_BYTESr,r r�r��__getitem__r�)Zbsr�r!)r�r"r
�s
cCst|d�r|j�}nRy t|�r2t|dt�r2t�Wn0tk
rdtj�\}}}td�j|��YnXg}	|s�xr|D]j\}
}t|
t	�r�||
|�}
n|t
|
�|||�}
t|t	�r�|||�}n|t
|�|||�}|	j|
d|�qtW�n,�x(|D�]\}
}t|
t	��r||
|�}
n|t
|
�|||�}
t|t	��rL|||�}|	j|
d|�q�t|t
��rz|||||�}|	j|
d|�q�yt|�}Wn:tk
�r�|t
|�|||�}|	j|
d|�Yq�XxJ|D]B}
t|
t	��r�||
|�}
n|t
|
�|||�}
|	j|
d|
��q�Wq�Wdj|	�S)a^Encode a dict or sequence of two-element tuples into a URL query string.

    If any values in the query arg are sequences and doseq is true, each
    sequence element is converted to a separate parameter.

    If the query arg is a sequence of two-element tuples, the order of the
    parameters in the output will match the order of parameters in the
    input.

    The components of a query arg may each be either a string or a bytes type.

    The safe, encoding, and errors parameters are passed down to the function
    specified by quote_via (encoding and errors only if a component is a str).
    �itemsrz1not a valid non-string sequence or mapping objectr�r�)
�hasattrr�rzr4r0r6�sys�exc_info�with_tracebackr�r5r�r�)rsZdoseqr�r)r*Z	quote_viaZtyZva�tb�l�kr�r.Zeltr!r!r"r�sP





cCsJt|t�rFy|jd�j�}Wn(tk
rDtdt|�d��YnX|S)zto_bytes(u"URL") --> 'URL'.�ASCIIzURL z contains non-ASCII characters)r4r5r(r,�UnicodeError�repr)rir!r!r"�to_bytes/s
r�cCs`t|�j�}|dd�dkr<|dd�dkr<|dd�j�}|dd�dkr\|dd�j�}|S)	z8unwrap('<URL:type://host/path>') --> 'type://host/path'.Nr3�<�>�zURL:r�r�)r5r�)rir!r!r"�unwrap<s rcCsDtdkrtjdtj�atj|�}|r<|j�\}}|j�|fSd|fS)z:splittype('type:opaquestring') --> 'type', 'opaquestring'.Nz
([^/:]+):(.*))�	_typeprogr��compile�DOTALLr��groupsrK)rir�rp�datar!r!r"�	splittypeEs
rcCsXtdkrtjdtj�atj|�}|rP|j�\}}|rH|ddkrHd|}||fSd|fS)z;splithost('//host[:port]/path') --> 'host[:port]', '/path'.Nz//([^/#?]*)(.*)rrv)�	_hostprogr�rrr�r)rir�Z	host_portr�r!r!r"�	splithostRs
r
cCs |jd�\}}}|r|nd|fS)zJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.rTN)rW)�host�userr}r!r!r"�	splituser`sr
cCs |jd�\}}}||r|ndfS)z/splitpasswd('user:passwd') -> 'user', 'passwd'.rUN)rJ)rr}Zpasswdr!r!r"�splitpasswdesrcCsDtdkrtjdtj�atj|�}|r<|j�\}}|r<||fS|dfS)z*splitport('host:port') --> 'host', 'port'.Nz(.*):([0-9]*)$)�	_portprogr�rrr�r)rr�rQr!r!r"�	splitportls
rr3cCsT|jd�\}}}|s|}n2|rLyt|�}Wntk
rBd}YnX||fS||fS)z�Split host and port, returning numeric port.
    Return given default port if no ':' found; defaults to -1.
    Return numerical port if a valid number are found after ':'.
    Return None if ':' but not a valid number.rUN)rWrOrP)rZdefportr}rQZnportr!r!r"�
splitnportys
rcCs$|jd�\}}}|r||fS|dfS)z/splitquery('/path?query') --> '/path', 'query'.r�N)rW)rir�r}rsr!r!r"�
splitquery�srcCs$|jd�\}}}|r||fS|dfS)z)splittag('/path#tag') --> '/path', 'tag'.rgN)rW)rir�r}�tagr!r!r"�splittag�srcCs|jd�}|d|dd�fS)zksplitattr('/path;attr1=value1;attr2=value2;...') ->
        '/path', ['attr1=value1', 'attr2=value2', ...].rmrr3N)r�)riZwordsr!r!r"�	splitattr�s
rcCs |jd�\}}}||r|ndfS)z-splitvalue('attr=value') --> 'attr', 'value'.r�N)rJ)�attrr}r�r!r!r"�
splitvalue�sr)rT)r)rT)T)r�r�)FFr�r�NN)FFr�r�NN)r�r�)rvNN)rNN)rvr�)r�)er?r�r�r��collectionsr��__all__r�r�rnZnon_hierarchicalZ
uses_queryZ
uses_fragmentr�r�r�r�rr#Z_implicit_encodingZ_implicit_errorsr'r+r2r8r�r9rArCrSrarfZ_DefragResultBaseZ_SplitResultBaseZ_ParseResultBaserirhrprVr�rsrtZ
ResultBaserrrrrrrlrrorr�r�r�r�rrrrrr�r�rrr�rr	�RuntimeWarningr�r�r�r
r�	frozensetr�r�r�r �defaultdictr�rrr
rr�rrrr	r
r
rrrrrrrrr!r!r!r"�<module> s





!


	
	
B
E


&
y
	
,

O

PK�@�\��P2��response.cpython-36.pycnu�[���3


 \��@s^dZddlZddddgZGdd�dej�ZGdd�de�ZGd	d�de�ZGd
d�de�ZdS)aResponse classes used by urllib.

The base class, addbase, defines a minimal file-like interface,
including read() and readline().  The typical response object is an
addinfourl instance, which defines an info() method that returns
headers and a geturl() method that returns the url.
�N�addbase�addclosehook�addinfo�
addinfourlcs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
rzOBase class for addinfo and addclosehook. Is a good idea for garbage collection.cs tt|�j|ddd�||_dS)Nz<urllib response>F)�delete)�superr�__init__�fp)�selfr	)�	__class__��'/usr/lib64/python3.6/urllib/response.pyrszaddbase.__init__cCsd|jjt|�|jfS)Nz<%s at %r whose fp = %r>)r�__name__�id�file)r
rrr
�__repr__szaddbase.__repr__cCs|jjrtd��|S)NzI/O operation on closed file)r	�closed�
ValueError)r
rrr
�	__enter__szaddbase.__enter__cCs|j�dS)N)�close)r
�type�value�	tracebackrrr
�__exit__!szaddbase.__exit__)	r�
__module__�__qualname__�__doc__rrrr�
__classcell__rr)rr
rs
cs,eZdZdZ�fdd�Z�fdd�Z�ZS)rz*Class to add a close hook to an open file.cs tt|�j|�||_||_dS)N)rrr�	closehook�hookargs)r
r	rr)rrr
r(szaddclosehook.__init__cs>z(|j}|j}|r&d|_d|_||�Wdtt|�j�XdS)N)rrrrr)r
rr)rrr
r-szaddclosehook.close)rrrrrrrrr)rr
r%scs(eZdZdZ�fdd�Zdd�Z�ZS)rz.class to add an info() method to an open file.cstt|�j|�||_dS)N)rrr�headers)r
r	r )rrr
r<szaddinfo.__init__cCs|jS)N)r )r
rrr
�info@szaddinfo.info)rrrrrr!rrr)rr
r9scs2eZdZdZd	�fdd�	Zdd�Zdd�Z�ZS)
rz9class to add info() and geturl() methods to an open file.Ncs"tt|�j||�||_||_dS)N)rrr�url�code)r
r	r r"r#)rrr
rGszaddinfourl.__init__cCs|jS)N)r#)r
rrr
�getcodeLszaddinfourl.getcodecCs|jS)N)r")r
rrr
�geturlOszaddinfourl.geturl)N)rrrrrr$r%rrr)rr
rDs)rZtempfile�__all__Z_TemporaryFileWrapperrrrrrrrr
�<module>sPK�@�\w��33 robotparser.cpython-36.opt-2.pycnu�[���3


 \�"�@sXddlZddlZddlZdgZejdd�ZGdd�d�ZGdd�d�ZGdd	�d	�Z	dS)
�N�RobotFileParser�RequestRatezrequests secondsc@sfeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r�cCs,g|_d|_d|_d|_|j|�d|_dS)NFr)�entries�
default_entry�disallow_all�	allow_all�set_url�last_checked)�self�url�r
�*/usr/lib64/python3.6/urllib/robotparser.py�__init__s
zRobotFileParser.__init__cCs|jS)N)r
)rr
r
r�mtime$szRobotFileParser.mtimecCsddl}|j�|_dS)Nr)�timer
)rrr
r
r�modified-szRobotFileParser.modifiedcCs&||_tjj|�dd�\|_|_dS)N��)r�urllib�parse�urlparse�host�path)rrr
r
rr	5szRobotFileParser.set_urlcCs�ytjj|j�}WnRtjjk
rd}z2|jdkr:d|_n|jdkrT|jdkrTd|_WYdd}~XnX|j	�}|j
|jd�j��dS)N��Ti�i�zutf-8)rr)
rZrequestZurlopenr�errorZ	HTTPError�coderr�readr�decode�
splitlines)r�f�err�rawr
r
rr:s
zRobotFileParser.readcCs,d|jkr|jdkr(||_n|jj|�dS)N�*)�
useragentsrr�append)r�entryr
r
r�
_add_entryGs

zRobotFileParser._add_entrycCs6d}t�}|j��x|D�]�}|sT|dkr8t�}d}n|dkrT|j|�t�}d}|jd�}|dkrr|d|�}|j�}|s�q|jdd�}t|�dkr|dj�j�|d<tj	j
|dj��|d<|ddk�r|dkr�|j|�t�}|jj|d�d}q|ddk�r4|dk�r|j
jt|dd��d}q|dd	k�rh|dk�r|j
jt|dd
��d}q|ddk�r�|dk�r|dj�j��r�t|d�|_d}q|ddkr|dkr|djd
�}t|�dk�r|dj�j��r|dj�j��rtt|d�t|d��|_d}qW|dk�r2|j|�dS)Nrr��#�:z
user-agentZdisallowFZallowTzcrawl-delayzrequest-rate�/)�Entryrr(�find�strip�split�len�lowerrr�unquoter%r&�	rulelines�RuleLine�isdigit�int�delayr�req_rate)r�lines�stater'�line�iZnumbersr
r
rrPsd






 
zRobotFileParser.parsecCs�|jr
dS|jrdS|jsdStjjtjj|��}tjjdd|j|j	|j
|jf�}tjj|�}|sfd}x"|j
D]}|j|�rn|j|�SqnW|jr�|jj|�SdS)NFTrr,)rrr
rrrr3�
urlunparserZparamsZqueryZfragment�quoter�
applies_to�	allowancer)r�	useragentrZ
parsed_urlr'r
r
r�	can_fetch�s$
zRobotFileParser.can_fetchcCs4|j�sdSx|jD]}|j|�r|jSqW|jjS)N)rrr@r8r)rrBr'r
r
r�crawl_delay�s

zRobotFileParser.crawl_delaycCs4|j�sdSx|jD]}|j|�r|jSqW|jjS)N)rrr@r9r)rrBr'r
r
r�request_rate�s

zRobotFileParser.request_ratecCs0|j}|jdk	r||jg}djtt|��dS)N�
)rr�join�map�str)rrr
r
r�__str__�s
zRobotFileParser.__str__N)r)�__name__�
__module__�__qualname__rrrr	rr(rrCrDrErJr
r
r
rrs
	
	Cc@s$eZdZdd�Zdd�Zdd�ZdS)r5cCs>|dkr|rd}tjjtjj|��}tjj|�|_||_dS)NrT)rrr>rr?rrA)rrrAr
r
rr�s
zRuleLine.__init__cCs|jdkp|j|j�S)Nr$)r�
startswith)r�filenamer
r
rr@�szRuleLine.applies_tocCs|jr
dndd|jS)NZAllowZDisallowz: )rAr)rr
r
rrJ�szRuleLine.__str__N)rKrLrMrr@rJr
r
r
rr5�sr5c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r-cCsg|_g|_d|_d|_dS)N)r%r4r8r9)rr
r
rr�szEntry.__init__cCs�g}x|jD]}|jd|���qW|jdk	r@|jd|j���|jdk	rj|j}|jd|j�d|j���|jtt|j	��|jd�dj
|�S)NzUser-agent: z
Crawl-delay: zRequest-rate: r,rrF)r%r&r8r9ZrequestsZseconds�extendrHrIr4rG)rZret�agentZrater
r
rrJ�s


z
Entry.__str__cCsF|jd�dj�}x.|jD]$}|dkr*dS|j�}||krdSqWdS)Nr,rr$TF)r0r2r%)rrBrQr
r
rr@�szEntry.applies_tocCs$x|jD]}|j|�r|jSqWdS)NT)r4r@rA)rrOr<r
r
rrA�s

zEntry.allowanceN)rKrLrMrrJr@rAr
r
r
rr-�s

r-)
�collectionsZurllib.parserZurllib.request�__all__�
namedtuplerrr5r-r
r
r
r�<module>
s2PK�@�\���request.cpython-36.pycnu�[���3

���i~��)@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+m,Z,yddl-Z-Wne.k
�r&dZ/YnXdZ/dd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(g!Z0d)e
j1dd*�Z2da3dej4fddddd+�d,d�Z5d-d �Z6gZ7d~d.d%�Z8d/d&�Z9e
j:d0e
j;�Z<d1d2�Z=Gd3d�d�Z>Gd4d	�d	�Z?d5d!�Z@Gd6d
�d
�ZAGd7d�deA�ZBGd8d�deA�ZCGd9d�deA�ZDd:d;�ZEGd<d�deA�ZFGd=d�d�ZGGd>d�deG�ZHGd?d�deH�ZIGd@d�d�ZJGdAd�deJeA�ZKGdBd�deJeA�ZLejMZNGdCd�d�ZOGdDd�deAeO�ZPGdEd�deAeO�ZQGdFdG�dGeA�ZRGdHd�deR�ZSeTejUdI��r2GdJdK�dKeR�ZVe0jWdK�GdLd
�d
eA�ZXGdMd�deA�ZYdNdO�ZZdPdQ�Z[GdRd�deA�Z\dSdT�Z]GdUd�deA�Z^GdVd�de^�Z_GdWd�deA�Z`dXZaejbdYk�r�ddZlcmdZdmeZend[d#�Zdd\d"�ZeiZfGd]d'�d'�ZgGd^d(�d(eg�Zhdaid_d`�Zjdakdadb�Zldamdcdd�Zndaodedf�ZpGdgdh�dh�Zqdidj�Zrddkdl�Zsdmdn�Zte
judok�r�ddplvmwZwmxZxdqdr�Zydsdt�Zzdudv�Z{dwd$�Z|n6ejbdYk�r�dxdy�Z}dzd$�Z|d{d|�Z~d}dv�Z{nerZ|esZ{dS)�a�
An extensible library for opening URLs using a variety of protocols

The simplest way to use this module is to call the urlopen function,
which accepts a string containing a URL or a Request object (described
below).  It opens the URL and returns the results as file-like
object; the returned object has some extra methods described below.

The OpenerDirector manages a collection of Handler objects that do
all the actual work.  Each Handler implements a particular protocol or
option.  The OpenerDirector is a composite object that invokes the
Handlers needed to open the requested URL.  For example, the
HTTPHandler performs HTTP GET and POST requests and deals with
non-error returns.  The HTTPRedirectHandler automatically deals with
HTTP 301, 302, 303 and 307 redirect errors, and the HTTPDigestAuthHandler
deals with digest authentication.

urlopen(url, data=None) -- Basic usage is the same as original
urllib.  pass the url and optionally data to post to an HTTP URL, and
get a file-like object back.  One difference is that you can also pass
a Request instance instead of URL.  Raises a URLError (subclass of
OSError); for HTTP errors, raises an HTTPError, which can also be
treated as a valid response.

build_opener -- Function that creates a new OpenerDirector instance.
Will install the default handlers.  Accepts one or more Handlers as
arguments, either instances or Handler classes that it will
instantiate.  If one of the argument is a subclass of the default
handler, the argument will be installed instead of the default.

install_opener -- Installs a new opener as the default opener.

objects of interest:

OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
the Handler classes, while dealing with requests and responses.

Request -- An object that encapsulates the state of a request.  The
state can be as simple as the URL.  It can also include extra HTTP
headers, e.g. a User-Agent.

BaseHandler --

internals:
BaseHandler and parent
_call_chain conventions

Example usage:

import urllib.request

# set up authentication info
authinfo = urllib.request.HTTPBasicAuthHandler()
authinfo.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='geheim$parole')

proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})

# build a new opener that adds authentication and caching FTP handlers
opener = urllib.request.build_opener(proxy_support, authinfo,
                                     urllib.request.CacheFTPHandler)

# install it
urllib.request.install_opener(opener)

f = urllib.request.urlopen('http://www.python.org/')
�N)�URLError�	HTTPError�ContentTooShortError)�urlparse�urlsplit�urljoin�unwrap�quote�unquote�	splittype�	splithost�	splitport�	splituser�splitpasswd�	splitattr�
splitquery�
splitvalue�splittag�to_bytes�unquote_to_bytes�
urlunparse)�
addinfourl�addclosehookFT�Request�OpenerDirector�BaseHandler�HTTPDefaultErrorHandler�HTTPRedirectHandler�HTTPCookieProcessor�ProxyHandler�HTTPPasswordMgr�HTTPPasswordMgrWithDefaultRealm�HTTPPasswordMgrWithPriorAuth�AbstractBasicAuthHandler�HTTPBasicAuthHandler�ProxyBasicAuthHandler�AbstractDigestAuthHandler�HTTPDigestAuthHandler�ProxyDigestAuthHandler�HTTPHandler�FileHandler�
FTPHandler�CacheFTPHandler�DataHandler�UnknownHandler�HTTPErrorProcessor�urlopen�install_opener�build_opener�pathname2url�url2pathname�
getproxies�urlretrieve�
urlcleanup�	URLopener�FancyURLopenerz%d.%d�)�cafile�capath�	cadefault�contextc
Cs�|s|s|rfddl}|jdtd�|dk	r2td��ts>td��tjtjj||d�}t	|d�}t
|�}	n0|r~t	|d�}t
|�}	ntdkr�t
�a}	nt}	|	j|||�S)	a$
Open the URL url, which can be either a string or a Request object.

    *data* must be an object specifying additional data to be sent to
    the server, or None if no such data is needed.  See Request for
    details.

    urllib.request module uses HTTP/1.1 and includes a "Connection:close"
    header in its HTTP requests.

    The optional *timeout* parameter specifies a timeout in seconds for
    blocking operations like the connection attempt (if not specified, the
    global default timeout setting will be used). This only works for HTTP,
    HTTPS and FTP connections.

    If *context* is specified, it must be a ssl.SSLContext instance describing
    the various SSL options. See HTTPSConnection for more details.

    The optional *cafile* and *capath* parameters specify a set of trusted CA
    certificates for HTTPS requests. cafile should point to a single file
    containing a bundle of CA certificates, whereas capath should point to a
    directory of hashed certificate files. More information can be found in
    ssl.SSLContext.load_verify_locations().

    The *cadefault* parameter is ignored.

    This function always returns an object which can work as a context
    manager and has methods such as

    * geturl() - return the URL of the resource retrieved, commonly used to
      determine if a redirect was followed

    * info() - return the meta-information of the page, such as headers, in the
      form of an email.message_from_string() instance (see Quick Reference to
      HTTP Headers)

    * getcode() - return the HTTP status code of the response.  Raises URLError
      on errors.

    For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse
    object slightly modified. In addition to the three new methods above, the
    msg attribute contains the same information as the reason attribute ---
    the reason phrase returned by the server --- instead of the response
    headers as it is specified in the documentation for HTTPResponse.

    For FTP, file, and data URLs and requests explicitly handled by legacy
    URLopener and FancyURLopener classes, this function returns a
    urllib.response.addinfourl object.

    Note that None may be returned if no handler handles the request (though
    the default installed global OpenerDirector uses UnknownHandler to ensure
    this never happens).

    In addition, if proxy settings are detected (for example, when a *_proxy
    environment variable like http_proxy is set), ProxyHandler is default
    installed and makes sure the requests are handled through the proxy.

    rNzJcafile, capath and cadefault are deprecated, use a custom context instead.r:zDYou can't pass both context and any of cafile, capath, and cadefaultzSSL support not available)r;r<)r>)
�warnings�warn�DeprecationWarning�
ValueError�	_have_ssl�sslZcreate_default_contextZPurposeZSERVER_AUTH�HTTPSHandlerr2�_opener�open)
�url�data�timeoutr;r<r=r>r?Z
https_handler�opener�rL�&/usr/lib64/python3.6/urllib/request.pyr0�s*<




cCs|adS)N)rF)rKrLrLrMr1�scCs4t|�\}}tjt||����}|j�}|dkrD|rDtjj|�|fS|rTt|d�}nt	j
dd�}|j}tj
|�|��||f}	d
}
d}d}d}
d	|kr�t|d
�}|r�||
|
|�xB|j|
�}|s�P|t|�7}|j|�|
d7}
|r�||
|
|�q�WWdQRXWdQRX|dk�r0||k�r0td||f|	��|	S)aW
    Retrieve a URL into a temporary location on disk.

    Requires a URL argument. If a filename is passed, it is used as
    the temporary file location. The reporthook argument should be
    a callable that accepts a block number, a read size, and the
    total file size of the URL target. The data argument should be
    valid URL encoded data.

    If a filename is passed and the URL points to a local resource,
    the result is a copy from local file to new file.

    Returns a tuple containing the path to the newly created
    data file as well as the resulting HTTPMessage object.
    �file�wbF)�deletei��rzcontent-lengthzContent-LengthNz1retrieval incomplete: got only %i out of %i bytesi ���)r�
contextlib�closingr0�info�os�path�normpathrG�tempfileZNamedTemporaryFile�name�_url_tempfiles�append�int�read�len�writer)rH�filename�
reporthookrIZurl_typerX�fp�headers�tfp�result�bs�sizer_�blocknum�blockrLrLrMr6�sD


$cCsHx0tD](}ytj|�Wqtk
r,YqXqWtdd�=trDdadS)z0Clean up temporary files from urlretrieve calls.N)r\rW�unlink�OSErrorrF)Z	temp_filerLrLrMr7%s


z:\d+$cCs<|j}t|�d}|dkr&|jdd�}tjd|d�}|j�S)z�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    rR��Host)�full_urlr�
get_header�_cut_port_re�sub�lower)�requestrH�hostrLrLrM�request_host4srwc@s�eZdZdidddfdd�Zedd��Zejdd��Zejdd��Zed	d
��Zejdd
��Zejdd
��Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd#dd�Zdd �Zd!d"�ZdS)$rNFc	Csp||_i|_i|_d|_||_d|_x |j�D]\}}|j||�q.W|dkrVt|�}||_	||_
|rl||_dS)N)rpre�unredirected_hdrs�_datarI�_tunnel_host�items�
add_headerrw�origin_req_host�unverifiable�method)	�selfrHrIrer}r~r�key�valuerLrLrM�__init__FszRequest.__init__cCs|jrdj|j|j�S|jS)Nz{}#{})�fragment�format�	_full_url)r�rLrLrMrpXszRequest.full_urlcCs(t|�|_t|j�\|_|_|j�dS)N)rr�rr��_parse)r�rHrLrLrMrp^s
cCsd|_d|_d|_dS)Nrn)r�r��selector)r�rLrLrMrpescCs|jS)N)ry)r�rLrLrMrIkszRequest.datacCs(||jkr$||_|jd�r$|jd�dS)NzContent-length)ry�
has_header�
remove_header)r�rIrLrLrMrIos

cCs
d|_dS)N)rI)r�rLrLrMrIyscCsNt|j�\|_}|jdkr(td|j��t|�\|_|_|jrJt|j�|_dS)Nzunknown url type: %r)	rr��typerBrprrvr�r
)r��restrLrLrMr�}s
zRequest._parsecCs|jdk	rdnd}t|d|�S)z3Return a string indicating the HTTP request method.N�POST�GETr)rI�getattr)r�Zdefault_methodrLrLrM�
get_method�szRequest.get_methodcCs|jS)N)rp)r�rLrLrM�get_full_url�szRequest.get_full_urlcCs4|jdkr|jr|j|_n||_|j|_||_dS)N�https)r�rzrvrpr�)r�rvr�rLrLrM�	set_proxy�s

zRequest.set_proxycCs|j|jkS)N)r�rp)r�rLrLrM�	has_proxy�szRequest.has_proxycCs||j|j�<dS)N)re�
capitalize)r�r��valrLrLrMr|�szRequest.add_headercCs||j|j�<dS)N)rxr�)r�r�r�rLrLrM�add_unredirected_header�szRequest.add_unredirected_headercCs||jkp||jkS)N)rerx)r��header_namerLrLrMr��s
zRequest.has_headercCs|jj||jj||��S)N)re�getrx)r�r��defaultrLrLrMrq�szRequest.get_headercCs |jj|d�|jj|d�dS)N)re�poprx)r�r�rLrLrMr��szRequest.remove_headercCs"|jj�}|j|j�t|j��S)N)rx�copy�updatere�listr{)r��hdrsrLrLrM�header_items�s
zRequest.header_items)N)�__name__�
__module__�__qualname__r��propertyrp�setter�deleterrIr�r�r�r�r�r|r�r�rqr�r�rLrLrLrMrDs(

c@sNeZdZdd�Zdd�Zdd�Zdd�Zd	ejfd
d�Z	ddd
�Z
dd�Zd	S)rcCs6dt}d|fg|_g|_i|_i|_i|_i|_dS)NzPython-urllib/%sz
User-agent)�__version__�
addheaders�handlers�handle_open�handle_error�process_response�process_request)r�Zclient_versionrLrLrMr��szOpenerDirector.__init__cCsZt|d�stdt|���d}�xt|�D�]}|dkr:q*|jd�}|d|�}||dd�}|jd	�r�|jd�|d}||dd�}yt|�}Wntk
r�YnX|jj	|i�}	|	|j|<n>|d
kr�|}|j
}	n*|dkr�|}|j}	n|dkr*|}|j}	nq*|	j
|g�}
|
�r&tj|
|�n
|
j|�d
}q*W|�rVtj|j|�|j|�dS)N�
add_parentz%expected BaseHandler instance, got %rF�redirect_request�do_open�
proxy_open�_rR�errorrG�responseruT)r�r�r�)�hasattr�	TypeErrorr��dir�find�
startswithr^rBr�r�r�r�r��
setdefault�bisectZinsortr]r�r�)r��handlerZadded�meth�i�protocolZ	condition�j�kind�lookupr�rLrLrM�add_handler�sJ



zOpenerDirector.add_handlercCsdS)NrL)r�rLrLrM�close�szOpenerDirector.closec	Gs<|j|f�}x*|D]"}t||�}||�}|dk	r|SqWdS)N)r�r�)	r��chainr��	meth_name�argsr�r��funcrgrLrLrM�_call_chain�s

zOpenerDirector._call_chainNc
Cs�t|t�rt||�}n|}|dk	r(||_||_|j}|d}x(|jj|g�D]}t||�}||�}qLW|j	||�}	|d}x*|j
j|g�D]}t||�}|||	�}	q�W|	S)NZ_requestZ	_response)�
isinstance�strrrIrJr�r�r�r��_openr�)
r��fullurlrIrJ�reqr�r�Z	processorr�r�rLrLrMrG�s"


zOpenerDirector.opencCsP|j|jdd|�}|r|S|j}|j|j||d|�}|r>|S|j|jdd|�S)Nr�Zdefault_openr��unknown�unknown_open)r�r�r�)r�r�rIrgr�rLrLrMr�s


zOpenerDirector._opencGs~|d
kr,|jd}|d}d|}d}|}n|j}|d}d}|||f|}|j|�}|r^|S|rz|dd	f|}|j|�SdS)N�httpr�r:z
http_error_%srRZ_errorrr��http_error_default)r�r�)r�r�)r��protor��dictr�Zhttp_errZ	orig_argsrgrLrLrMr�'s 

zOpenerDirector.error)N)r�r�r�r�r�r�r��socket�_GLOBAL_DEFAULT_TIMEOUTrGr�r�rLrLrLrMr�s/
c	Gs�t�}ttttttttt	g	}t
tjd�r2|j
t�t�}xN|D]F}x@|D]8}t|t�rlt||�r�|j|�qHt||�rH|j|�qHWq>Wx|D]}|j|�q�Wx|D]}|j|��q�Wx&|D]}t|t�r�|�}|j|�q�W|S)a*Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP, FTP and when applicable HTTPS.

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    �HTTPSConnection)rrr.r)rrr+r*r/r-r�r��clientr]rE�setr�r��
issubclass�add�remover�)r�rKZdefault_classes�skip�klassZcheck�hrLrLrMr2@s0	









c@s(eZdZdZdd�Zdd�Zdd�ZdS)	ri�cCs
||_dS)N)�parent)r�r�rLrLrMr�gszBaseHandler.add_parentcCsdS)NrL)r�rLrLrMr�jszBaseHandler.closecCst|d�sdS|j|jkS)N�
handler_orderT)r�r�)r��otherrLrLrM�__lt__ns
zBaseHandler.__lt__N)r�r�r�r�r�r�r�rLrLrLrMrdsc@s eZdZdZdZdd�ZeZdS)r/zProcess HTTP error responses.i�cCsJ|j|j|j�}}}d|ko*dknsF|jjd|||||�}|S)N��i,r�)�code�msgrVr�r�)r�rur�r�r�r�rLrLrM�
http_response{s
z HTTPErrorProcessor.http_responseN)r�r�r��__doc__r�r��https_responserLrLrLrMr/wsc@seZdZdd�ZdS)rcCst|j||||��dS)N)rrp)r�r�rdr�r�r�rLrLrMr��sz*HTTPDefaultErrorHandler.http_error_defaultN)r�r�r�r�rLrLrLrMr�sc@s4eZdZdZdZdd�Zdd�ZeZZZ	dZ
dS)	r��
c	sx|j�}|dkr|dkp&|dko&|dks:t|j||||��|jdd	�}d�t�fdd
�|jj�D��}t|||jdd�S)a�Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        �-�.�/�3r��HEADr�� z%20�content-length�content-typec3s&|]\}}|j��kr||fVqdS)N)rt)�.0�k�v)�CONTENT_HEADERSrLrM�	<genexpr>�sz7HTTPRedirectHandler.redirect_request.<locals>.<genexpr>T)rer}r~)r�r�r�r�)r�r�)r�r�r�)r�r�)	r�rrp�replacer�rer{rr})	r�r�rdr�r�re�newurl�mZ
newheadersrL)r�rMr��s
z$HTTPRedirectHandler.redirect_requestc
CsNd|kr|d}nd|kr$|d}ndSt|�}|jdkrRt||d||f||��|jrp|jrpt|�}d|d	<t|�}t|d
tj	d�}t
|j|�}|j||||||�}|dkr�dSt
|d��r|j}	|_|	j|d
�|jks�t|	�|jk�rt|j||j|||��ni}	|_|_|	j|d
�d|	|<|j�|j�|jj||jd�S)N�location�urir�r��ftprnz+%s - Redirection to url '%s' is not allowed�/r:z
iso-8859-1)�encoding�safe�
redirect_dictrrR)rJ)r�r�r�rn)r�schemerrXZnetlocr�rr	�stringZpunctuationrrpr�r�rr��max_repeatsr`�max_redirections�inf_msgr_r�r�rGrJ)
r�r�rdr�r�rer��urlparts�newZvisitedrLrLrM�http_error_302�s@



z"HTTPRedirectHandler.http_error_302zoThe HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
N)r�r�r�rrr�r
�http_error_301�http_error_303�http_error_307rrLrLrLrMr�s&<c	Cs�t|�\}}|jd�s d}|}n:|jd�s6td|��|jdd�}|dkrNd}|d|�}t|�\}}|dk	r|t|�\}}nd}}||||fS)aReturn (scheme, user, password, host/port) given a URL or an authority.

    If a URL is supplied, it must have an authority (host:port) component.
    According to RFC 3986, having an authority component means the URL must
    have two slashes after the scheme.
    r�Nz//zproxy URL with no authority: %rr:rRrS)rr�rBr�rr)	�proxyrZr_scheme�	authority�endZuserinfo�hostport�user�passwordrLrLrM�_parse_proxy�s

rc@s"eZdZdZddd�Zdd�ZdS)r�dNcCs^|dkrt�}t|d�s td��||_x2|j�D]&\}}t|d||||jfdd��q0WdS)N�keyszproxies must be a mappingz%s_opencSs||||�S)NrL)�rrr�r�rLrLrM�<lambda>%sz'ProxyHandler.__init__.<locals>.<lambda>)r5r��AssertionError�proxiesr{�setattrr�)r�rr�rHrLrLrMr�s
zProxyHandler.__init__cCs�|j}t|�\}}}}|dkr"|}|jr6t|j�r6dS|rv|rvdt|�t|�f}	tj|	j��jd�}
|j	dd|
�t|�}|j
||�||ks�|dkr�dS|jj||j
d�SdS)Nz%s:%s�asciizProxy-authorizationzBasic r�)rJ)r�rrv�proxy_bypassr
�base64�	b64encode�encode�decoder|r�r�rGrJ)r�r�rr�Z	orig_typeZ
proxy_typerrrZ	user_passZcredsrLrLrMr�(s zProxyHandler.proxy_open)N)r�r�r�r�r�r�rLrLrLrMrs

c@s6eZdZdd�Zdd�Zdd�Zd
dd	�Zd
d�ZdS)r cCs
i|_dS)N)�passwd)r�rLrLrMr�FszHTTPPasswordMgr.__init__cs`t|t�r|g}|�jkr$i�j|<x6dD].�t��fdd�|D��}||f�j||<q*WdS)NTFcsg|]}�j|���qSrL)�
reduce_uri)r��u)�default_portr�rLrM�
<listcomp>Qsz0HTTPPasswordMgr.add_password.<locals>.<listcomp>)TF)r�r�r"�tuple)r��realmr�rr"�reduced_urirL)r%r�rM�add_passwordIs



zHTTPPasswordMgr.add_passwordc	Cs`|jj|i�}xLdD]D}|j||�}x2|j�D]&\}}x|D]}|j||�r<|Sq<Wq.WqWdS)NTF)TF)NN)r"r�r#r{�	is_suburi)	r�r(�authuriZdomainsr%�reduced_authuriZurisZauthinfor�rLrLrM�find_user_passwordTs

z"HTTPPasswordMgr.find_user_passwordTc
Cs�t|�}|dr.|d}|d}|dp*d}nd}|}d}t|�\}}|r~|dkr~|dk	r~ddd�j|�}	|	dk	r~d	||	f}||fS)
z@Accept authority or URI and extract only the authority and path.rRrr:r�N�Pi�)r�r�z%s:%d)rr
r�)
r�r�r%�partsrrrXrv�portZdportrLrLrMr#^s zHTTPPasswordMgr.reduce_uricCsR||krdS|d|dkr dStj|d|df�}t|�t|d�krNdSdS)zcCheck if test is below base in a URI tree

        Both args must be URIs in reduced form.
        TrFrR)�	posixpath�commonprefixr`)r��base�test�commonrLrLrMr+uszHTTPPasswordMgr.is_suburiN)T)r�r�r�r�r*r.r#r+rLrLrLrMr Ds


c@seZdZdd�ZdS)r!cCs0tj|||�\}}|dk	r"||fStj|d|�S)N)r r.)r�r(r,rrrLrLrMr.�s

z2HTTPPasswordMgrWithDefaultRealm.find_user_passwordN)r�r�r�r.rLrLrLrMr!�scs<eZdZ�fdd�Zd
�fdd�	Zddd�Zdd	�Z�ZS)r"csi|_t�j||�dS)N)�
authenticated�superr�)r�r��kwargs)�	__class__rLrMr��sz%HTTPPasswordMgrWithPriorAuth.__init__Fcs<|j||�|dk	r&t�jd|||�t�j||||�dS)N)�update_authenticatedr8r*)r�r(r�rr"�is_authenticated)r:rLrMr*�sz)HTTPPasswordMgrWithPriorAuth.add_passwordcCsFt|t�r|g}x0dD](}x"|D]}|j||�}||j|<q WqWdS)NTF)TF)r�r�r#r7)r�r�r<r%r$r)rLrLrMr;�s


z1HTTPPasswordMgrWithPriorAuth.update_authenticatedcCsDx>dD]6}|j||�}x$|jD]}|j||�r|j|SqWqWdS)NTF)TF)r#r7r+)r�r,r%r-r�rLrLrMr<�s

z-HTTPPasswordMgrWithPriorAuth.is_authenticated)F)F)r�r�r�r�r*r;r<�
__classcell__rLrL)r:rMr"�s

c@sTeZdZejdej�Zddd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZeZ
eZdS)r#z1(?:^|,)[ 	]*([^ 	,]+)[ 	]+realm=(["']?)([^"']*)\2NcCs"|dkrt�}||_|jj|_dS)N)r r"r*)r�Zpassword_mgrrLrLrMr��sz!AbstractBasicAuthHandler.__init__ccstd}xFtjj|�D]6}|j�\}}}|d	kr:tjdtd�||fVd}qW|sp|rb|j�d}nd}|dfVdS)
NF�"�'zBasic Auth Realm was unquoted�Trrn)r>r?)r#�rx�finditer�groupsr?r@�UserWarning�split)r��headerZfound_challengeZmorr	r(rLrLrM�_parse_realm�s
z%AbstractBasicAuthHandler._parse_realmc	Cs~|j|�}|sdSd}xL|D]D}x>|j|�D]0\}}|j�dkrF|}q,|dk	r,|j|||�Sq,WqW|dk	rztd|f��dS)N�basiczBAbstractBasicAuthHandler does not support the following scheme: %r)Zget_allrGrt�retry_http_basic_authrB)	r��authreqrvr�reZunsupportedrFrr(rLrLrM�http_error_auth_reqed�s

z.AbstractBasicAuthHandler.http_error_auth_reqedcCs||jj||�\}}|dk	rtd||f}dtj|j��jd�}|j|jd�|krTdS|j|j|�|j	j
||jd�SdSdS)Nz%s:%szBasic r)rJ)r"r.rrr r!rq�auth_headerr�r�rGrJ)r�rvr�r(r�pw�raw�authrLrLrMrI�sz.AbstractBasicAuthHandler.retry_http_basic_authcCsxt|jd�s|jj|j�r"|S|jd�st|jjd|j�\}}dj||�j�}tj	|�j
�}|jddj|j���|S)Nr<�
Authorizationz{0}:{1}zBasic {})
r�r"r<rpr�r.r�r rZstandard_b64encoder!r��strip)r�r�rr"ZcredentialsZauth_strrLrLrM�http_requests
z%AbstractBasicAuthHandler.http_requestcCsLt|jd�rHd|jko dknr8|jj|jd�n|jj|jd�|S)Nr<r�i,TF)r�r"r�r;rp)r�r�r�rLrLrMr�s
z&AbstractBasicAuthHandler.http_response)N)r�r�r��re�compile�IrAr�rGrKrIrRr��
https_requestr�rLrLrLrMr#�s

c@seZdZdZdd�ZdS)r$rPcCs|j}|jd|||�}|S)Nzwww-authenticate)rprK)r�r�rdr�r�rerHr�rLrLrM�http_error_401 s
z#HTTPBasicAuthHandler.http_error_401N)r�r�r�rLrWrLrLrLrMr$sc@seZdZdZdd�ZdS)r%zProxy-authorizationcCs|j}|jd|||�}|S)Nzproxy-authenticate)rvrK)r�r�rdr�r�rerr�rLrLrM�http_error_407+s
z$ProxyBasicAuthHandler.http_error_407N)r�r�r�rLrXrLrLrLrMr%'sc@sNeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)r&NcCs4|dkrt�}||_|jj|_d|_d|_d|_dS)Nr)r r"r*�retried�nonce_count�
last_nonce)r�r"rLrLrMr�Es
z"AbstractDigestAuthHandler.__init__cCs
d|_dS)Nr)rY)r�rLrLrM�reset_retry_countNsz+AbstractDigestAuthHandler.reset_retry_countcCs||j|d�}|jdkr*t|jdd|d��n|jd7_|rx|j�d}|j�dkr`|j||�S|j�dkrxtd|��dS)	N�i�zdigest auth failedrRrZdigestrHzEAbstractDigestAuthHandler does not support the following scheme: '%s')r�rYrrprErt�retry_http_digest_authrB)r�rLrvr�rerJrrLrLrMrKQs


z/AbstractDigestAuthHandler.http_error_auth_reqedcCsz|jdd�\}}ttdt|���}|j||�}|rvd|}|jj|jd�|krRdS|j|j|�|j	j
||jd�}|SdS)Nr�rRz	Digest %s)rJ)rE�parse_keqv_list�filter�parse_http_list�get_authorizationrer�rLr�r�rGrJ)r�r�rO�tokenZ	challenge�chalZauth_valZresprLrLrMr^esz0AbstractDigestAuthHandler.retry_http_digest_authcCs@d|j|tj�f}|jd�td�}tj|�j�}|dd�S)Nz	%s:%s:%s:rrQ�)rZ�timeZctimer �_randombytes�hashlib�sha1�	hexdigest)r��nonce�s�b�digrLrLrM�
get_cnonceqsz$AbstractDigestAuthHandler.get_cnoncecCs�y6|d}|d}|jd�}|jdd�}|jdd�}Wntk
rJdSX|j|�\}}	|dkrfdS|jj||j�\}
}|
dkr�dS|jdk	r�|j|j|�}nd}d|
||f}
d|j�|j	f}|d	k�r.||j
kr�|jd
7_nd
|_||_
d|j}|j|�}d||||||�f}|	||
�|�}n2|dk�rT|	||
�d|||�f�}nt
d
|��d|
|||j	|f}|�r�|d|7}|�r�|d|7}|d|7}|�r�|d||f7}|S)Nr(rk�qop�	algorithm�MD5�opaquez%s:%s:%sz%s:%srOrRz%08xz%s:%s:%s:%s:%szqop '%s' is not supported.z>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z
, digest="%s"z, algorithm="%s"z, qop=auth, nc=%s, cnonce="%s")r��KeyError�get_algorithm_implsr"r.rprI�get_entity_digestr�r�r[rZror)r�r�rdr(rkrprqrs�H�KDrrMZentdigZA1ZA2ZncvalueZcnonceZnoncebitZrespdigr4rLrLrMrb|sV








z+AbstractDigestAuthHandler.get_authorizationcsD|dkrdd��n|dkr$dd��ntd|���fdd�}�|fS)NrrcSstj|jd��j�S)Nr)rhZmd5r rj)�xrLrLrMr�sz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>ZSHAcSstj|jd��j�S)Nr)rhrir rj)ryrLrLrMr�sz.Unsupported digest authentication algorithm %rcs�d||f�S)Nz%s:%srL)rl�d)rwrLrMr�s)rB)r�rqrxrL)rwrMru�s

z-AbstractDigestAuthHandler.get_algorithm_implscCsdS)NrL)r�rIrdrLrLrMrv�sz+AbstractDigestAuthHandler.get_entity_digest)N)r�r�r�r�r\rKr^rorbrurvrLrLrLrMr&:s
	<
c@s eZdZdZdZdZdd�ZdS)r'z�An authentication protocol defined by RFC 2069

    Digest authentication improves on basic authentication because it
    does not transmit passwords in the clear.
    rPi�cCs*t|j�d}|jd|||�}|j�|S)NrRzwww-authenticate)rrprKr\)r�r�rdr�r�rerv�retryrLrLrMrW�s

z$HTTPDigestAuthHandler.http_error_401N)r�r�r�r�rLr�rWrLrLrLrMr'�sc@seZdZdZdZdd�ZdS)r(zProxy-Authorizationi�cCs"|j}|jd|||�}|j�|S)Nzproxy-authenticate)rvrKr\)r�r�rdr�r�rervr{rLrLrMrX�s

z%ProxyDigestAuthHandler.http_error_407N)r�r�r�rLr�rXrLrLrLrMr(�sc@s6eZdZd
dd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�AbstractHTTPHandlerrcCs
||_dS)N)�_debuglevel)r��
debuglevelrLrLrMr��szAbstractHTTPHandler.__init__cCs
||_dS)N)r})r��levelrLrLrM�set_http_debuglevel�sz'AbstractHTTPHandler.set_http_debuglevelcCstjjj|j|j��S)N)r�r��HTTPConnection�_get_content_lengthrIr�)r�rurLrLrMr��sz'AbstractHTTPHandler._get_content_lengthcCs
|j}|std��|jdk	r�|j}t|t�r8d}t|��|jd�sN|jdd�|jd�r�|jd�r�|j|�}|dk	r�|jdt|��n|jdd�|}|j	�r�t
|j�\}}t|�\}}	|jd�s�|jd|�x2|j
jD]&\}
}|
j�}
|j|
�s�|j|
|�q�W|S)	Nz
no host givenz\POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.zContent-typez!application/x-www-form-urlencodedzContent-lengthzTransfer-encodingZchunkedro)rvrrIr�r�r�r�r�r�r�rr�rr�r�r�)r�rurvrIr�Zcontent_lengthZsel_hostrZselZsel_pathr[r�rLrLrM�do_request_�s>





zAbstractHTTPHandler.do_request_c
s\|j}|std��||fd|ji|��}|j|j�t|j���jt�fdd�|jj	�D���d�d<tdd��j	�D���|j
r�i}d}|�kr��|||<�|=|j|j
|d	�y`y&|j|j
�|j|j�|jd
�d�Wn,tk
�r
}zt|��WYdd}~XnX|j�}	Wn|j��YnX|j�rF|jj�d|_|j�|	_|	j|	_|	S)
z�Return an HTTPResponse object for the request, using http_class.

        http_class must implement the HTTPConnection API from http.client.
        z
no host givenrJc3s"|]\}}|�kr||fVqdS)NrL)r�r�r�)rerLrMr�)sz.AbstractHTTPHandler.do_open.<locals>.<genexpr>r��
Connectioncss|]\}}|j�|fVqdS)N)�title)r�r[r�rLrLrMr�6szProxy-Authorization)rezTransfer-encoding)Zencode_chunkedN)rvrrJZset_debuglevelr}r�rxr�rer{rzZ
set_tunnelrur�r�rIr�rm�getresponser�Zsockr�rH�reasonr�)
r�Z
http_classr�Zhttp_conn_argsrvr�Ztunnel_headersZproxy_auth_hdr�errrrL)rerMr�s@
"

zAbstractHTTPHandler.do_openN)r)r�r�r�r�r�r�r�r�rLrLrLrMr|�s

&r|c@seZdZdd�ZejZdS)r)cCs|jtjj|�S)N)r�r�r�r�)r�r�rLrLrM�	http_open`szHTTPHandler.http_openN)r�r�r�r�r|r�rRrLrLrLrMr)^sr�c@s$eZdZddd�Zdd�ZejZdS)rErNcCstj||�||_||_dS)N)r|r��_context�_check_hostname)r�r~r>�check_hostnamerLrLrMr�iszHTTPSHandler.__init__cCs|jtjj||j|jd�S)N)r>r�)r�r�r�r�r�r�)r�r�rLrLrM�
https_opennszHTTPSHandler.https_open)rNN)r�r�r�r�r�r|r�rVrLrLrLrMrEgs
rEc@s.eZdZddd�Zdd�Zdd�ZeZeZdS)	rNcCs$ddl}|dkr|jj�}||_dS)Nr)Zhttp.cookiejar�	cookiejarZ	CookieJar)r�r�r�rLrLrMr�ws
zHTTPCookieProcessor.__init__cCs|jj|�|S)N)r�Zadd_cookie_header)r�rurLrLrMrR}sz HTTPCookieProcessor.http_requestcCs|jj||�|S)N)r�Zextract_cookies)r�rur�rLrLrMr��sz!HTTPCookieProcessor.http_response)N)r�r�r�r�rRr�rVr�rLrLrLrMrvs

c@seZdZdd�ZdS)r.cCs|j}td|��dS)Nzunknown url type: %s)r�r)r�r�r�rLrLrMr��szUnknownHandler.unknown_openN)r�r�r�r�rLrLrLrMr.�scCsRi}xH|D]@}|jdd�\}}|ddkrB|ddkrB|dd�}|||<q
W|S)z>Parse list of key=value strings where keys are not duplicated.�=rRrr>rSrS)rE)�lZparsedZeltr�r�rLrLrMr_�s
r_cCs�g}d}d}}xt|D]l}|r,||7}d}q|rV|dkr@d}qn|dkrLd}||7}q|dkrn|j|�d}q|dkrzd}||7}qW|r�|j|�dd�|D�S)	apParse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Neither commas nor quotes count if they are escaped.
    Only double-quotes count, not single-quotes.
    rnF�\Tr>�,cSsg|]}|j��qSrL)rQ)r��partrLrLrMr&�sz#parse_http_list.<locals>.<listcomp>)r])rl�resr��escaper	ZcurrLrLrMra�s4	


rac@s(eZdZdd�ZdZdd�Zdd�ZdS)r*cCs\|j}|dd�dkrN|dd�dkrN|jrN|jdkrN|j|j�krXtd��n
|j|�SdS)Nr:z//r@r��	localhostz-file:// scheme is supported only on localhost)r�rv�	get_namesr�open_local_file)r�r�rHrLrLrM�	file_open�s&

zFileHandler.file_openNcCs`tjdkrZy*ttjd�dtjtj��d�t_Wn$tjk
rXtjd�ft_YnXtjS)Nr�r:)r*�namesr'r��gethostbyname_ex�gethostname�gaierror�
gethostbyname)r�rLrLrMr��s
zFileHandler.get_namescCsddl}ddl}|j}|j}t|�}y�tj|�}|j}|jj	|j
dd�}	|j|�d}
|jd|
pbd||	f�}|r~t
|�\}}|s�|r�t|�|j�kr�|r�d||}
nd|}
tt|d�||
�SWn*tk
r�}zt|��WYdd}~XnXtd��dS)	NrT)�usegmtz6Content-type: %s
Content-length: %d
Last-modified: %s
z
text/plainzfile://�rbzfile not on local host)�email.utils�	mimetypesrvr�r4rW�stat�st_size�utils�
formatdate�st_mtime�
guess_type�message_from_stringr
�_safe_gethostbynamer�rrGrmr)r�r��emailr�rvrbZ	localfile�statsri�modified�mtyperer1Zorigurl�exprLrLrMr��s0
zFileHandler.open_local_file)r�r�r�r�r�r�r�rLrLrLrMr*�s
cCs&y
tj|�Stjk
r dSXdS)N)r�r�r�)rvrLrLrMr��s
r�c@seZdZdd�Zdd�ZdS)r+cCs.ddl}ddl}|j}|s"td��t|�\}}|dkr>|j}nt|�}t|�\}}|rdt|�\}}nd}t	|�}|pvd}|p~d}yt
j|�}Wn*tk
r�}zt|��WYdd}~XnXt
|j�\}	}
|	jd�}ttt	|��}|dd�|d}}|�r|d�r|dd�}y�|j||||||j�}
|�r8d�p:d}x:|
D]2}t|�\}}|j�dk�rB|dk�rB|j�}�qBW|
j||�\}}d}|j|j�d}|�r�|d
|7}|dk	�r�|dk�r�|d|7}tj|�}t|||j�S|jk
�r(}z$td|�}|jtj �d��WYdd}~XnXdS)Nrzftp error: no host givenrnr�rRrU�Dr��a�Ar�rzzContent-type: %s
zContent-length: %d
z
ftp error: %rr:rSrS)r�r�r�rUrzr�)!�ftplibr�rvrr
�FTP_PORTr^rrr
r�r�rmrr�rEr��map�connect_ftprJrrt�upper�retrfiler�rpr�r�r�
all_errors�with_traceback�sys�exc_info)r�r�r�r�rvr1rr"r�rX�attrs�dirsrN�fwr��attrr�rd�retrlenrer�r��excrLrLrM�ftp_open�s\



zFTPHandler.ftp_openc	Cst||||||dd�S)NF)�
persistent)�
ftpwrapper)r�rr"rvr1r�rJrLrLrMr�1szFTPHandler.connect_ftpN)r�r�r�r�r�rLrLrLrMr+�s5c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r,cCs"i|_i|_d|_d|_d|_dS)Nr�<re)�cacherJ�soonest�delay�	max_conns)r�rLrLrMr�8s
zCacheFTPHandler.__init__cCs
||_dS)N)r�)r��trLrLrM�
setTimeout?szCacheFTPHandler.setTimeoutcCs
||_dS)N)r�)r�r�rLrLrM�setMaxConnsBszCacheFTPHandler.setMaxConnscCsr|||dj|�|f}||jkr4tj�|j|j|<n,t||||||�|j|<tj�|j|j|<|j�|j|S)Nr�)�joinr�rfr�rJr��check_cache)r�rr"rvr1r�rJr�rLrLrMr�Es

zCacheFTPHandler.connect_ftpcCs�tj�}|j|krTx@t|jj��D].\}}||kr"|j|j�|j|=|j|=q"Wtt|jj���|_t	|j�|j
kr�x6t|jj��D]$\}}||jkr�|j|=|j|=Pq�Wtt|jj���|_dS)N)rfr�r�rJr{r�r��min�valuesr`r�)r�r�r�r�rLrLrMr�Ps

zCacheFTPHandler.check_cachecCs4x|jj�D]}|j�qW|jj�|jj�dS)N)r�r�r��clearrJ)r��connrLrLrM�clear_cacheds
zCacheFTPHandler.clear_cacheN)	r�r�r�r�r�r�r�r�r�rLrLrLrMr,5sc@seZdZdd�ZdS)r-cCs~|j}|jdd�\}}|jdd�\}}t|�}|jd�rNtj|�}|dd�}|sVd}tjd|t|�f�}t	t
j|�||�S)	N�:rRr�z;base64�ztext/plain;charset=US-ASCIIz$Content-type: %s
Content-length: %d
i����)rprEr�endswithr�decodebytesr�r�r`r�io�BytesIO)r�r�rHrrIZ	mediatypererLrLrM�	data_openks


zDataHandler.data_openN)r�r�r�r�rLrLrLrMr-jsr��nt)r4r3cCst|�S)zOS-specific conversion from a relative URL of the 'file' scheme
        to a file system path; not recommended for general use.)r
)�pathnamerLrLrMr4�scCst|�S)zOS-specific conversion from a file system path to a relative URL
        of the 'file' scheme; not recommended for general use.)r	)r�rLrLrMr3�sc@s�eZdZdZdZdeZd*dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zd+dd�Zd,dd�Z
d-dd�Zd.dd�Zdd�Zd/dd�Zd0dd�Zdd�Zer�dd�Zd1d d!�Zd"d#�Zd$d%�Zd&d'�Zd2d(d)�ZdS)3r8a,Class to open URLs.
    This is a class rather than just a subroutine because we may need
    more than one set of global protocol-specific options.
    Note -- this is a base class for those who don't want the
    automatic handling of errors type 302 (relocated) and 401
    (authorization needed).NzPython-urllib/%scKs�dd|jji}tj|tdd�|dkr.t�}t|d�s@td��||_|j	d�|_
|j	d�|_d	|jfdg|_
g|_tj|_d|_t|_dS)
NzW%(class)s style of invoking requests is deprecated. Use newer urlopen functions/methods�classr@)�
stacklevelrzproxies must be a mapping�key_file�	cert_filez
User-Agent�Accept�*/*)r�r�)r:r�r?r@rAr5r�rrr�r�r��versionr��_URLopener__tempfilesrWrl�_URLopener__unlink�	tempcache�ftpcache)r�rZx509r�rLrLrMr��szURLopener.__init__cCs|j�dS)N)r�)r�rLrLrM�__del__�szURLopener.__del__cCs|j�dS)N)�cleanup)r�rLrLrMr��szURLopener.closecCsZ|jrFx2|jD](}y|j|�Wqtk
r4YqXqW|jdd�=|jrV|jj�dS)N)r�r�rmr�r�)r�rNrLrLrMr��s
zURLopener.cleanupcGs|jj|�dS)zdAdd a header to be used by the HTTP interface only
        e.g. u.addheader('Accept', 'sound/basic')N)r�r])r�r�rLrLrM�	addheader�szURLopener.addheadercCsntt|��}t|dd�}|jrL||jkrL|j|\}}t|d�}t|||�St|�\}}|s`d}||jkr�|j|}t|�\}}	t|	�\}
}|
|f}nd}d|}||_	|j
dd�}t||�s�|d	kr�|r�|j|||�S|j
||�Sy,|dk�rt||�|�St||�||�SWnVttfk
�r.�Yn<tk
�rh}
ztd
|
�jtj�d��WYdd}
~
XnXdS)z6Use URLopener().open(file) instead of open(file, 'r').z%/:=&?~#+!$,;'@()*[]|)rr�rNNZopen_�-r�r�zsocket errorr:)rrr	r�rGrrrrr�r�r��open_unknown_proxy�open_unknownr�rrrmr�r�r�)r�r�rIrbrerd�urltyperHr�	proxyhostrvr�r[r�rLrLrMrG�s<




zURLopener.opencCst|�\}}tdd|��dS)z/Overridable interface to open unknown URL type.z	url errorzunknown url typeN)rrm)r�r�rIr�rHrLrLrMr�szURLopener.open_unknowncCs t|�\}}tdd||��dS)z/Overridable interface to open unknown URL type.z	url errorzinvalid proxy for %sN)rrm)r�rr�rIr�rHrLrLrMr�	szURLopener.open_unknown_proxyc Cs&tt|��}|jr&||jkr&|j|St|�\}}|dkr�|sH|dkr�y.|j|�}|j�}|j�tt|�d�|fSt	k
r�}	zWYdd}	~	XnX|j
||�}�zH|j�}
|r�t
|d�}n|ddl}t|�\}
}t|p�d�\}
}t|p�d�\}}
t
|�pd�\}}
tjj|�d}|j|�\}}|jj|�tj|d�}z�||
f}|jdk	�r^||j|<d}d
}d}d}d	|
k�r�t|
d
�}|�r�||||�xH|j|�}|�s�P|t|�7}|j|�|d7}|�r�||||��q�WWd|j�XWd|j�X|dk�r"||k�r"td||f|��|S)ztretrieve(url) returns (filename, headers) for a local object
        or (tempfilename, headers) for a remote object.NrNrRrOrrnirQzcontent-lengthzContent-Lengthz1retrieval incomplete: got only %i out of %i bytesi rS)rrr�rr�rVr�r4rrmrGrZrrrWrX�splitextZmkstempr�r]�fdopenr^r_r`rar)r�rHrbrcrIr�Zurl1rdr�r�rerfrZZgarbagerX�suffix�fdrgrhrir_rjrkrLrLrM�retrievesl






zURLopener.retrievecCs(d}d}t|t�r<t|�\}}|r6t|�\}}t|�}|}nt|\}}t|�\}}t|�\}	}
|
}d}|	j�dkrvd}n:t|
�\}}
|r�t|�\}}|r�d|	||
f}t|�r�|}|s�tdd��|r�t|�}t	j
|j��jd�}nd}|�rt|�}t	j
|j��jd�}nd}||�}
i}|�r*d||d<|�r<d||d	<|�rJ||d
<d|d<x|j
D]\}}|||<�qZW|dk	�r�d
|d<|
jd|||�n|
jd||d�y|
j�}Wn"tjjk
�r�td��YnXd|jk�o�dkn�rt||jd||j�S|j||j|j|j|j|�SdS)a�Make an HTTP connection using connection_class.

        This is an internal method that should be called from
        open_http() or open_https().

        Arguments:
        - connection_factory should take a host name and return an
          HTTPConnection instance.
        - url is the url to retrieval or a host, relative-path pair.
        - data is payload for a POST request or None.
        Nr�z	%s://%s%sz
http errorz
no host givenrzBasic %szProxy-AuthorizationrPror�r�z!application/x-www-form-urlencodedzContent-Typer�r�)rez$http protocol error: bad status liner�i,zhttp:)r�r�rrr
rrtrrmrrr r!r�rur�r�r�Z
BadStatusLinerZstatusrr��
http_errorrdr�)r�Zconnection_factoryrHrIZuser_passwdZproxy_passwdrvr�Zrealhostr�r�Z
proxy_authrOZ	http_connrerFr�r�rLrLrM�_open_generic_httpQsr



zURLopener._open_generic_httpcCs|jtjj||�S)zUse HTTP protocol.)r�r�r�r�)r�rHrIrLrLrM�	open_http�szURLopener.open_httpc
Csbd|}t||�rPt||�}|dkr6||||||�}	n|||||||�}	|	rP|	S|j|||||�S)z�Handle http errors.

        Derived class can override this, or provide specific handlers
        named http_error_DDD where DDD is the 3-digit error code.z
http_error_%dN)r�r�r�)
r�rHrd�errcode�errmsgrerIr[rrgrLrLrMr��s

zURLopener.http_errorcCs|j�t||||d��dS)z>Default error handler: close the connection and raise OSError.N)r�r)r�rHrdr�r�rerLrLrMr��szURLopener.http_error_defaultcCstjj||j|jd�S)N)r�r�)r�r�r�r�r�)r�rvrLrLrM�_https_connection�szURLopener._https_connectioncCs|j|j||�S)zUse HTTPS protocol.)r�r�)r�rHrIrLrLrM�
open_https�szURLopener.open_httpscCs^t|t�std��|dd�dkrP|dd�dkrP|dd�j�dkrPtd	��n
|j|�SdS)
z/Use local file or FTP depending on form of URL.zEfile error: proxy support for file protocol currently not implementedNr:z//r@r��z
localhost/z-file:// scheme is supported only on localhost)r�r�rrtrBr�)r�rHrLrLrM�	open_file�s

4
zURLopener.open_filecCs\ddl}ddl}t|�\}}t|�}ytj|�}Wn0tk
rb}zt|j|j	��WYdd}~XnX|j
}	|jj|j
dd�}
|j|�d}|jd|p�d|	|
f�}|s�|}
|dd�dkr�d	|}
tt|d
�||
�St|�\}}|o�tj|�t�ft�k�rP|}
|dd�dk�r d	|}
n|dd�dk�r>td
|��tt|d
�||
�Std��dS)zUse local file.rNT)r�z6Content-Type: %s
Content-Length: %d
Last-modified: %s
z
text/plainrRr�zfile://r�r:z./zAlocal file url may start with / or file:. Unknown url of type: %sz#local file error: not on local host)r�r�rr4rWr�rmr�strerrorrbr�r�r�r�r�r�rrGr
r�r�r��thishostrB)r�rHr�r�rvrNZ	localnamer��erir�r�reZurlfiler1rLrLrMr��s: 
zURLopener.open_local_filecCs�t|t�std��ddl}t|�\}}|s2td��t|�\}}t|�\}}|r\t|�\}}nd}t|�}t|ppd�}t|p|d�}t	j
|�}|s�ddl}|j}nt
|�}t|�\}}	t|�}|jd�}
|
dd�|
d}
}|
o�|
d�r�|
dd�}
|
�r|
d�rd|
d<|||dj|
�f}t|j�tk�rlx8t|j�D]*}
|
|k�r>|j|
}|j|
=|j��q>Wy�||jk�r�t|||||
�|j|<|�s�d}nd	}x:|	D]2}t|�\}}|j�d
k�r�|dk�r�|j�}�q�W|j|j||�\}}|jd|�d}d}|�r|d|7}|dk	�r:|dk�r:|d|7}tj|�}t||d|�St�k
�r�}z td|�j t!j"�d��WYdd}~XnXdS)zUse FTP protocol.zCftp error: proxy support for ftp protocol currently not implementedrNzftp error: no host givenrnr�rRr�rUr�r�r�r�rzzftp:zContent-Type: %s
zContent-Length: %d
zftp error %rr:rSrS)r�r�r�rUrzr�)#r�r�rr�rr
rrr
r�r�r�r�r^rrEr�r`r��MAXFTPCACHEr�r�r�rrtr�r�r�r�r�r�	ftperrorsr�r�r�)r�rHr�rvrXr1rr"r�r�r�rNr�r�r�r�r�r�rdr�r�rer�rLrLrM�open_ftp�sp







zURLopener.open_ftpc	Cs<t|t�std��y|jdd�\}}Wntk
rDtdd��YnX|sNd}|jd�}|dkr�d	||d
�kr�||dd
�}|d
|�}nd}g}|jdtj	d
tj
tj����|jd|�|dkr�tj|j
d��jd�}nt|�}|jdt|��|jd�|j|�dj|�}tj|�}tj|�}t|||�S)zUse "data" URL.zEdata error: proxy support for data protocol currently not implementedr�rRz
data errorzbad data URLztext/plain;charset=US-ASCII�;rr�NrnzDate: %sz%a, %d %b %Y %H:%M:%S GMTzContent-type: %srrzlatin-1zContent-Length: %d�
)r�r�rrErBrm�rfindr]rfZstrftimeZgmtimerr�r r!r
r`r�r�r�r��StringIOr)	r�rHrIr�Zsemirr�re�frLrLrM�	open_data3s6






zURLopener.open_data)N)N)N)N)NNN)N)N)N)N)r�r�r�r�r�r�r�r�r�r�r�r�rGr�r�r�r�r�r�r�rCr�r�r�r�rr
rLrLrLrMr8�s.

$


B\


	 :c@s�eZdZdZdd�Zdd�Zd#dd�Zd	d
�Zd$dd�Zd%d
d�Z	d&dd�Z
d'dd�Zd(dd�Zd)dd�Z
d*dd�Zd+dd�Zd,dd�Zd-dd �Zd!d"�ZdS).r9z?Derived class with handlers for errors we can handle (perhaps).cOs(tj|f|�|�i|_d|_d|_dS)Nrr�)r8r��
auth_cache�tries�maxtries)r�r�r9rLrLrMr�`szFancyURLopener.__init__cCst||d||�S)z3Default error handling -- don't raise an exception.zhttp:)r)r�rHrdr�r�rerLrLrMr�fsz!FancyURLopener.http_error_defaultNc	
Csn|jd7_zR|jrJ|j|jkrJt|d�r4|j}n|j}|||dd|�S|j||||||�}|Sd|_XdS)z%Error 302 -- relocated (temporarily).rR�http_error_500i�z)Internal Server Error: Redirect RecursionNr)rr
r�rr��redirect_internal)	r�rHrdr�r�rerIr�rgrLrLrMr
js
zFancyURLopener.http_error_302c	Csxd|kr|d}nd|kr$|d}ndS|j�t|jd||�}t|�}|jd	krnt|||d|||��|j|�S)
Nr�r�r�r�r�r�rnz( Redirection to url '%s' is not allowed.)r�r�r�rn)r�rr�rrrrG)	r�rHrdr�r�rerIr�rrLrLrMr|s


z FancyURLopener.redirect_internalcCs|j||||||�S)z*Error 301 -- also relocated (permanently).)r
)r�rHrdr�r�rerIrLrLrMr�szFancyURLopener.http_error_301cCs|j||||||�S)z;Error 303 -- also relocated (essentially identical to 302).)r
)r�rHrdr�r�rerIrLrLrMr�szFancyURLopener.http_error_303cCs2|dkr|j||||||�S|j|||||�SdS)z1Error 307 -- relocated, but turn POST into error.N)r
r�)r�rHrdr�r�rerIrLrLrMr
�szFancyURLopener.http_error_307Fc
Cs�d|krtj||||||�|d}tjd|�}	|	sHtj||||||�|	j�\}
}|
j�dkrttj||||||�|s�tj||||||�d|jd}|dkr�t||�||�St||�|||�SdS)z_Error 401 -- authentication required.
        This function supports Basic authentication only.zwww-authenticatez![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"rHZretry_�_basic_authN)r8r�rS�matchrCrtr�r�)
r�rHrdr�r�rerIr{�stuffrrr(r[rLrLrMrW�s&





zFancyURLopener.http_error_401c
Cs�d|krtj||||||�|d}tjd|�}	|	sHtj||||||�|	j�\}
}|
j�dkrttj||||||�|s�tj||||||�d|jd}|dkr�t||�||�St||�|||�SdS)zeError 407 -- proxy authentication required.
        This function supports Basic authentication only.zproxy-authenticatez![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"rHZretry_proxy_rN)r8r�rSrrCrtr�r�)
r�rHrdr�r�rerIr{rrrr(r[rLrLrMrX�s&





zFancyURLopener.http_error_407cCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|d�}	|j|	||�\}}
|pl|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|j|�S|j||�SdS)Nzhttp://r��@rRz%s:%s@%srn)r)rrrr��get_user_passwdr	rG)r�rHr(rIrvr�r�rr�r��
proxyselectorr�rr"rLrLrM�retry_proxy_http_basic_auth�s 

z*FancyURLopener.retry_proxy_http_basic_authcCs�t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|d�}	|j|	||�\}}
|pl|
srdSdt|dd�t|
dd�|	f}	d|	|
|jd<|dkr�|j|�S|j||�SdS)Nzhttps://r�rrRz%s:%s@%srn)r)rrrr�rr	rG)r�rHr(rIrvr�r�rr�r�rr�rr"rLrLrM�retry_proxy_https_basic_auth�s 

z+FancyURLopener.retry_proxy_https_basic_authc
Cs�t|�\}}|jd�d}||d�}|j|||�\}}|p>|sDdSdt|dd�t|dd�|f}d||}	|dkr�|j|	�S|j|	|�SdS)NrrRz%s:%s@%srn)rzhttp://)rr�rr	rG)
r�rHr(rIrvr�r�rr"r�rLrLrMrI�s
z$FancyURLopener.retry_http_basic_authc
Cs�t|�\}}|jd�d}||d�}|j|||�\}}|p>|sDdSdt|dd�t|dd�|f}d||}	|dkr�|j|	�S|j|	|�SdS)NrrRz%s:%s@%srn)rzhttps://)rr�rr	rG)
r�rHr(rIrvr�r�rr"r�rLrLrM�retry_https_basic_auth	s
z%FancyURLopener.retry_https_basic_authrcCs`|d|j�}||jkr2|r(|j|=n
|j|S|j||�\}}|sJ|rX||f|j|<||fS)Nr)rtr�prompt_user_passwd)r�rvr(r�r�rr"rLrLrMr	s


zFancyURLopener.get_user_passwdcCsTddl}y,td||f�}|jd|||f�}||fStk
rNt�dSXdS)z#Override this in a GUI environment!rNzEnter username for %s at %s: z#Enter password for %s in %s at %s: )NN)�getpass�input�KeyboardInterrupt�print)r�rvr(rrr"rLrLrMr$	sz!FancyURLopener.prompt_user_passwd)N)N)N)N)NF)NF)N)N)N)N)r)r�r�r�r�r�r�r
rrrr
rWrXrrrIrrrrLrLrLrMr9]s$










cCstdkrtjd�atS)z8Return the IP address of the magic hostname 'localhost'.Nr�)�
_localhostr�r�rLrLrLrMr�4	s
r�cCsPtdkrLyttjtj��d�aWn(tjk
rJttjd�d�aYnXtS)z,Return the IP addresses of the current host.Nr:r�)�	_thishostr'r�r�r�r�rLrLrLrMr<	srcCstdkrddl}|jatS)z1Return the set of errors raised by the FTP class.Nr)�
_ftperrorsr�r�)r�rLrLrMrG	srcCstdkrtjd�atS)z%Return an empty email Message object.Nrn)�
_noheadersr�r�rLrLrLrM�	noheadersP	s
r"c@sJeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)r�z;Class used by open_ftp() for cache of open FTP connections.NTc	CsX||_||_||_||_||_||_d|_||_y|j�Wn|j	��YnXdS)Nr)
rr"rvr1r�rJ�refcount�	keepalive�initr�)r�rr"rvr1r�rJr�rLrLrMr�]	szftpwrapper.__init__cCs\ddl}d|_|j�|_|jj|j|j|j�|jj|j	|j
�dj|j�}|jj
|�dS)Nrr�)r��busyZFTPr�Zconnectrvr1rJZloginrr"r�r��cwd)r�r�Z_targetrLrLrMr%m	s
zftpwrapper.initc-Cs�ddl}|j�|dkr"d}d}nd|}d}y|jj|�Wn*|jk
rh|j�|jj|�YnXd}|r�|r�yd|}|jj|�\}}WnR|jk
r�}z4t|�dd�d	kr�t	d
|�j
tj�d��WYdd}~XnX|�s�|jjd�|�rn|jj
�}	zJy|jj|�Wn4|jk
�rP}zt	d
|�|�WYdd}~XnXWd|jj|	�Xd|}nd
}|jj|�\}}d|_t|jd�|j�}
|jd7_|j�|
|fS)Nrrzr�zTYPE ArRzTYPE zRETR r@Z550z
ftp error: %rr:zLIST ZLISTr�)rzr�)r��endtransferr�Zvoidcmdr�r%ZntransfercmdZ
error_permr�rr�r�r��pwdr'r&r�makefile�
file_closer#r�)r�rNr�r��cmd�isdirr�r�r�r)ZftpobjrLrLrMr�v	sN
 
$
zftpwrapper.retrfilecCs
d|_dS)Nr)r&)r�rLrLrMr(�	szftpwrapper.endtransfercCsd|_|jdkr|j�dS)NFr)r$r#�
real_close)r�rLrLrMr��	s
zftpwrapper.closecCs4|j�|jd8_|jdkr0|jr0|j�dS)NrRr)r(r#r$r.)r�rLrLrMr+�	szftpwrapper.file_closecCs2|j�y|jj�Wnt�k
r,YnXdS)N)r(r�r�r)r�rLrLrMr.�	s
zftpwrapper.real_close)NT)r�r�r�r�r�r%r�r(r�r+r.rLrLrLrMr�Z	s
	-r�cCs�i}xBtjj�D]4\}}|j�}|r|dd�dkr|||dd�<qWdtjkr^|jdd�xXtjj�D]J\}}|dd�dkrj|j�}|r�|||dd	�<qj|j|dd
�d�qjW|S)aReturn a dictionary of scheme -> proxy server URL mappings.

    Scan the environment for variables named <scheme>_proxy;
    this seems to be the standard convention.  If you need a
    different way, you can pass a proxies dictionary to the
    [Fancy]URLopener constructor.

    �N�_proxyZREQUEST_METHODr�i����i����i����i����i����)rW�environr{rtr�)rr[r�rLrLrM�getproxies_environment�	s	
r2c
Cs�|dkrt�}y|d}Wntk
r.dSX|dkr<dSt|�\}}dd�|jd�D�}xP|D]H}|rb|jd	�}tj|�}d
|}tj||tj�s�tj||tj�rbdSqbWdS)z�Test if proxies should not be used for a particular host.

    Checks the proxy dict for the value of no_proxy, which should
    be a list of comma separated DNS suffixes, or '*' for all hosts.

    N�nor�*rRcSsg|]}|j��qSrL)rQ)r�rrLrLrMr&�	sz,proxy_bypass_environment.<locals>.<listcomp>r��.z
(.+\.)?%s$)	r2rtr
rE�lstriprSr�rrU)rvrZno_proxy�hostonlyr1Z
no_proxy_listr[�patternrLrLrM�proxy_bypass_environment�	s&


r9c
Csddlm}t|�\}}dd�}d|kr4|dr4dSd}x�|jd	f�D]�}|sPqFtjd
|�}|dk	�r|dkr�ytj|�}||�}Wntk
r�wFYnX||jd��}	|jd�}
|
dkr�d
|jd�j	d�d}
nt
|
dd��}
d|
}
||
?|	|
?k�rdSqF|||�rFdSqFWdS)aj
    Return True iff this host shouldn't be accessed using a proxy

    This function uses the MacOSX framework SystemConfiguration
    to fetch the proxy information.

    proxy_settings come from _scproxy._get_proxy_settings or get mocked ie:
    { 'exclude_simple': bool,
      'exceptions': ['foo.bar', '*.bar.com', '127.0.0.1', '10.1', '10.0/16']
    }
    r)�fnmatchcSsh|jd�}ttt|��}t|�dkr<|ddddgdd�}|dd>|dd>B|dd>B|d	BS)
Nr5r�r�rRrer:rQr@)rEr�r�r^r`)ZipAddrr0rLrLrM�ip2num
s

z,_proxy_bypass_macosx_sysconf.<locals>.ip2numr5Zexclude_simpleTN�
exceptionsz(\d+(?:\.\d+)*)(/\d+)?rRr:rQ� F)r:r
r�rSrr�r�rm�group�countr^)rv�proxy_settingsr:r7r1r<ZhostIPr�r�r4�maskrLrLrM�_proxy_bypass_macosx_sysconf�	s:



rC�darwin)�_get_proxy_settings�_get_proxiescCst�}t||�S)N)rErC)rvrArLrLrM�proxy_bypass_macosx_sysconf:
srGcCst�S)z�Return a dictionary of scheme -> proxy server URL mappings.

        This function uses the MacOSX framework SystemConfiguration
        to fetch the proxy information.
        )rFrLrLrLrM�getproxies_macosx_sysconf>
srHcCs t�}|rt||�St|�SdS)z�Return True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or from the MacOSX framework SystemConfiguration.

        N)r2r9rG)rvrrLrLrMrH
s
rcCst�p
t�S)N)r2rHrLrLrLrMr5U
scCsi}yddl}Wntk
r$|SXy�|j|jd�}|j|d�d}|r�t|j|d�d�}d|kr�x�|jd�D]4}|jdd�\}}tjd	|�s�d
||f}|||<qrWn>|dd�dkr�||d
<n$d||d
<d||d<d||d<|j	�Wnt
ttfk
�rYnX|S)zxReturn a dictionary of scheme -> proxy server URL mappings.

        Win32 uses the registry to store proxies.

        rNz;Software\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyEnableZProxyServerr�rrRz^([^/:]+)://z%s://%sr]zhttp:r�z	http://%sz
https://%sr�zftp://%sr�)
�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�QueryValueExr�rErSrZClosermrBr�)rrJ�internetSettings�proxyEnableZproxyServer�pr�ZaddressrLrLrM�getproxies_registryZ
s8

rRcCst�p
t�S)z�Return a dictionary of scheme -> proxy server URL mappings.

        Returns settings gathered from the environment, if specified,
        or the registry.

        )r2rRrLrLrLrMr5�
sc&Cs~yddl}Wntk
r dSXy6|j|jd�}|j|d�d}t|j|d�d�}Wntk
rldSX|sz|r~dSt|�\}}|g}y tj	|�}||kr�|j
|�Wntk
r�YnXy tj|�}||kr�|j
|�Wntk
�r�YnX|jd�}xp|D]h}	|	dk�r*d|k�r*dS|	j
dd	�}	|	j
d
d�}	|	j
dd�}	x$|D]}
tj|	|
tj��rTdS�qTW�qWdS)
Nrz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsrIZ
ProxyOverriderz<local>r5rRz\.r4z.*�?)rJrKrLrMrNr�rmr
r�r�r]ZgetfqdnrEr�rSrrU)rvrJrOrPZ
proxyOverrideZrawHostr1ZaddrZfqdnr5r�rLrLrM�proxy_bypass_registry�
sR







rTcCs t�}|rt||�St|�SdS)z�Return True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.

        N)r2r9rT)rvrrLrLrMr�
s
)NNN)N)r�rr�r�rhZhttp.clientr�r�rWr2rSr�rr�rf�collectionsrZrTr?Zurllib.errorrrrZurllib.parserrrrr	r
rrr
rrrrrrrrrZurllib.responserrrDrKrC�__all__�version_infor�rFr�r0r1r\r6r7rT�ASCIIrrrwrrr2rr/rrrrr r!r"r#r$r%�urandomrgr&r'r(r|r)r�r�rEr]rr.r_rar*r�r+r,r-rr[Z
nturl2pathr4r3r�r8r9rr�rrr rr!r"r�r2r9rC�platformZ_scproxyrErFrGrHrr5rRrTrLrLrLrM�<module>Ds�P
T
?n$q*@
ov

+3:5!AW

_
#<

-	2
PK�@�\�I�����parse.cpython-36.opt-1.pycnu�[���3

���ie��@s�dZddlZddlZddlZddlZddlZddddddd	d
ddd
ddddddddddgZddddddddd d!d"d#d$d%d&d'd(d)d*gZdddddd+dddd"d d!d,d#d$d%d-d'd(d&d.d/d0d)d*gZddd1d#ddd d!d$d%d2d3d"d&d4gZ	dd1d5d6d+ddd,d2d3g
Z
ddddd d!d"dd$d%d2d3gZddd1ddd6ddd d!d,dd#g
Zd7Z
d8Zd9d:d;gZd<ZiZd=d>�Zd?Zd@ZdAdB�ZeefdCdD�ZeefdEdF�ZdGdH�ZGdIdJ�dJe�ZGdKdL�dLe�ZGdMdN�dNe�ZGdOdP�dPee�ZGdQdR�dRee�ZddSlmZeddT�Z eddU�Z!eddV�Z"dWe _dXe j#_dYe j$_dZe!_d[e!j%_d\e!j&_d]e!j'_d^e!j(_d_e!j$_d`e"_e!j%je"j%_e!j&je"j&_e!j'je"j'_dae"j)_e!j(je"j(_e!j$je"j$_eZ*Gdbd�de e�Z+Gdcd�de!e�Z,Gddd�de"e�Z-Gded�de e�Z.Gdfd�de!e�Z/Gdgd�de"e�Z0dhdi�Z1e1�[1d�dkd�Z2dldm�Z3d�dndo�Z4dpdq�Z5drds�Z6dtdu�Z7dvdw�Z8d�dxd�Z9dyd�Z:dzd�Z;d�d{d�Z<d|d�Z=d}Z>da?d~d�Z@ejAd�ZBd�d�d�ZCd�d�d
�ZDGd�d��d�eE�ZFd�ZGdaHd�d�d�ZId�d�d�ZJeKd��ZLeMeL�ZNiZOGd�d��d�ejP�ZQd�d�d�ZRd�d�d
�ZSd�d�d�ZTd�dddeSfd�d	�ZUd�d��ZVd�d��ZWdaXd�d��ZYdaZd�d��Z[d�d��Z\d�d��Z]da^d�d��Z_d�d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��ZddS)�a3Parse (absolute and relative) URLs.

urlparse module is based upon the following RFC specifications.

RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
and L.  Masinter, January 2005.

RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
and L.Masinter, December 1999.

RFC 2396:  "Uniform Resource Identifiers (URI)": Generic Syntax by T.
Berners-Lee, R. Fielding, and L. Masinter, August 1998.

RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998.

RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June
1995.

RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M.
McCahill, December 1994

RFC 3986 is considered the current standard and any future changes to
urlparse module should conform with it.  The urlparse module is
currently not entirely compliant with this RFC due to defacto
scenarios for parsing, and for backward compatibility purposes, some
parsing quirks from older RFCs are retained. The testcases in
test_urlparse.py provides a good indicator of parsing behavior.

The WHATWG URL Parser spec should also be considered.  We are not compliant with
it either due to existing user code API behavior expectations (Hyrum's Law).
It serves as a useful guide when making changes.
�N�urlparse�
urlunparse�urljoin�	urldefrag�urlsplit�
urlunsplit�	urlencode�parse_qs�	parse_qsl�quote�
quote_plus�quote_from_bytes�unquote�unquote_plus�unquote_to_bytes�DefragResult�ParseResult�SplitResult�DefragResultBytes�ParseResultBytes�SplitResultBytes�Zftp�httpZgopherZnntpZimapZwais�fileZhttpsZshttpZmmsZprosperoZrtspZrtspuZsftpZsvnzsvn+sshZwsZwssZtelnetZsnewsZrsyncZnfsZgitzgit+sshZhdlZsipZsipsZtelZmailtoZnewszAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.z!	

 �	�
�
�cCstj�tj�dS)z,Clear the parse cache and the quoters cache.N)�_parse_cache�clear�
_safe_quoters�r!r!�$/usr/lib64/python3.6/urllib/parse.py�clear_cache`sr#�ascii�strictcCs|S)Nr!)�objr!r!r"�_nooposr'cCs|j||�S)N)�encode)r&�encoding�errorsr!r!r"�_encode_resultrsr+cst��fdd�|D��S)Nc3s"|]}|r|j���ndVqdS)rN)�decode)�.0�x)r)r*r!r"�	<genexpr>xsz_decode_args.<locals>.<genexpr>)�tuple)�argsr)r*r!)r)r*r"�_decode_argsvsr2cGsZt|dt�}x.|dd�D]}|rt|t�|krtd��qW|rL|tfSt|�tfS)Nr�z$Cannot mix str and non-str arguments)�
isinstance�str�	TypeErrorr'r2r+)r1Z	str_input�argr!r!r"�_coerce_argszs
r8c@seZdZdZfZddd�ZdS)�_ResultMixinStrz>Standard approach to encoding parsed results from str to bytesr$r%cs|j��fdd�|D��S)Nc3s|]}|j���VqdS)N)r()r-r.)r)r*r!r"r/�sz)_ResultMixinStr.encode.<locals>.<genexpr>)�_encoded_counterpart)�selfr)r*r!)r)r*r"r(�sz_ResultMixinStr.encodeN)r$r%)�__name__�
__module__�__qualname__�__doc__�	__slots__r(r!r!r!r"r9�sr9c@seZdZdZfZddd�ZdS)�_ResultMixinBytesz>Standard approach to decoding parsed results from bytes to strr$r%cs|j��fdd�|D��S)Nc3s|]}|j���VqdS)N)r,)r-r.)r)r*r!r"r/�sz+_ResultMixinBytes.decode.<locals>.<genexpr>)�_decoded_counterpart)r;r)r*r!)r)r*r"r,�sz_ResultMixinBytes.decodeN)r$r%)r<r=r>r?r@r,r!r!r!r"rA�srAc@sDeZdZdZfZedd��Zedd��Zedd��Zedd	��Z	d
S)�_NetlocResultMixinBasezHShared methods for the parsed result objects containing a netloc elementcCs
|jdS)Nr)�	_userinfo)r;r!r!r"�username�sz_NetlocResultMixinBase.usernamecCs
|jdS)Nr3)rD)r;r!r!r"�password�sz_NetlocResultMixinBase.passwordcCsD|jd}|sdSt|t�r dnd}|j|�\}}}|j�||S)Nr�%�%)�	_hostinfor4r5�	partition�lower)r;�hostname�	separatorZpercentZzoner!r!r"rL�s
z_NetlocResultMixinBase.hostnamecCs@|jd}|dk	r<t|d�}d|ko.dkns<td��|S)Nr3�
ri��zPort out of range 0-65535)rI�int�
ValueError)r;�portr!r!r"rQ�s

z_NetlocResultMixinBase.portN)
r<r=r>r?r@�propertyrErFrLrQr!r!r!r"rC�srCc@s(eZdZfZedd��Zedd��ZdS)�_NetlocResultMixinStrcCsD|j}|jd�\}}}|r4|jd�\}}}|s<d}nd}}||fS)N�@�:)�netloc�
rpartitionrJ)r;rV�userinfo�	have_info�hostinforE�
have_passwordrFr!r!r"rD�sz_NetlocResultMixinStr._userinfocCsl|j}|jd�\}}}|jd�\}}}|rL|jd�\}}}|jd�\}}}n|jd�\}}}|sdd}||fS)NrT�[�]rU)rVrWrJ)r;rV�_rZ�have_open_br�	bracketedrLrQr!r!r"rI�sz_NetlocResultMixinStr._hostinfoN)r<r=r>r@rRrDrIr!r!r!r"rS�srSc@s(eZdZfZedd��Zedd��ZdS)�_NetlocResultMixinBytescCsD|j}|jd�\}}}|r4|jd�\}}}|s<d}nd}}||fS)N�@�:)rVrWrJ)r;rVrXrYrZrEr[rFr!r!r"rD�sz!_NetlocResultMixinBytes._userinfocCsl|j}|jd�\}}}|jd�\}}}|rL|jd�\}}}|jd�\}}}n|jd�\}}}|sdd}||fS)Nrb�[�]rc)rVrWrJ)r;rVr^rZr_r`rLrQr!r!r"rI�sz!_NetlocResultMixinBytes._hostinfoN)r<r=r>r@rRrDrIr!r!r!r"ra�sra)�
namedtuplezurl fragmentz!scheme netloc path query fragmentz(scheme netloc path params query fragmentz�
DefragResult(url, fragment)

A 2-tuple that contains the url without fragment identifier and the fragment
identifier as a separate argument.
z$The URL with no fragment identifier.z�
Fragment identifier separated from URL, that allows indirect identification of a
secondary resource by reference to a primary resource and additional identifying
information.
z�
SplitResult(scheme, netloc, path, query, fragment)

A 5-tuple that contains the different components of a URL. Similar to
ParseResult, but does not split params.
z%Specifies URL scheme for the request.z0
Network location where the request is made to.
z@
The hierarchical path, such as the path to a file to download.
z�
The query component, that contains non-hierarchical data, that along with data
in path component, identifies a resource in the scope of URI's scheme and
network location.
z�
Fragment identifier, that allows indirect identification of a secondary resource
by reference to a primary resource and additional identifying information.
zr
ParseResult(scheme, netloc, path, params,  query, fragment)

A 6-tuple that contains components of a parsed URL.
z�
Parameters for last path element used to dereference the URI in order to provide
access to perform some operation on the resource.
c@seZdZfZdd�ZdS)rcCs |jr|jd|jS|jSdS)N�#)�fragment�url)r;r!r!r"�geturlEszDefragResult.geturlN)r<r=r>r@rjr!r!r!r"rCsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rjMszSplitResult.geturlN)r<r=r>r@rjr!r!r!r"rKsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rjRszParseResult.geturlN)r<r=r>r@rjr!r!r!r"rPsc@seZdZfZdd�ZdS)rcCs |jr|jd|jS|jSdS)N�#)rhri)r;r!r!r"rjXszDefragResultBytes.geturlN)r<r=r>r@rjr!r!r!r"rVsc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rj`szSplitResultBytes.geturlN)r<r=r>r@rjr!r!r!r"r^sc@seZdZfZdd�ZdS)rcCst|�S)N)r)r;r!r!r"rjeszParseResultBytes.geturlN)r<r=r>r@rjr!r!r!r"rcscCs8ttfttfttff}x|D]\}}||_||_qWdS)N)rrrrrrr:rB)Z
_result_pairsZ_decodedZ_encodedr!r!r"�_fix_result_transcodingis
rlTc
Csft||�\}}}t|||�}|\}}}}}|tkrHd|krHt|�\}}nd}t||||||�}	||	�S)a#Parse a URL into 6 components:
    <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
    Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
    Note that we don't break the components up in smaller bits
    (e.g. netloc is a single string) and we don't expand % escapes.�;r)r8r�uses_params�_splitparamsr)
ri�scheme�allow_fragments�_coerce_resultZsplitresultrV�queryrh�params�resultr!r!r"rvscCsRd|kr,|jd|jd��}|dkr6|dfSn
|jd�}|d|�||dd�fS)N�/rmrrr3)�find�rfind)ri�ir!r!r"ro�s

rocCsLt|�}x*dD]"}|j||�}|dkrt||�}qW|||�||d�fS)Nz/?#r)�lenrw�min)ri�start�delim�cZwdelimr!r!r"�_splitnetloc�s
rcCs�|stdd�|D��rdSddl}|jdd�}|jdd�}|jdd�}|jdd�}|jd	|�}||krndSx(d
D] }||krttd|dd
��qtWdS)Ncss|]}t|�dkVqdS)�N)�ord)r-r~r!r!r"r/�sz_checknetloc.<locals>.<genexpr>rrTrrUrg�?�NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)�any�unicodedata�replace�	normalizerP)rVr��nZnetloc2r~r!r!r"�_checknetloc�s
r�cCsxtD]}|j|d�}qW|S)Nr)�_UNSAFE_URL_BYTES_TO_REMOVEr�)ri�br!r!r"�_remove_unsafe_bytes_from_url�s
r�cCst|jd�d}|jd�\}}}|rX|r.td��|jd�\}}}|rh|jd�rhtd��n|jd�\}}}t|�dS)NrT�r\zInvalid IPv6 URLr]rU)rWrJrP�
startswith�_check_bracketed_host)rVZhostname_and_portZbefore_bracketr_r`rLr^rQr!r!r"�_check_bracketed_netloc�s
r�cCsB|jd�r tjd|�s>td��ntj|�}t|tj�r>td��dS)N�vz\Av[a-fA-F0-9]+\..+\ZzIPvFuture address is invalidz%An IPv4 address cannot be in brackets)r��re�matchrP�	ipaddressZ
ip_addressr4ZIPv4Address)rLZipr!r!r"r��s


r�c
Cs�t||�\}}}t|�}t|�}|jt�}|jt�}t|�}|||t|�t|�f}tj|d�}|rj||�St	t�t
kr|t�d}}}|jd�}	|	dk�r�|d|	�dk�r~|d|	�j
�}||	dd�}|dd�dk�rt|d�\}}d	|ko�d
|k�sd
|k�rd	|k�rtd��|�r<d|k�r<|jdd�\}}d
|k�rV|jd
d�\}}t|�t|||||�}
|
t|<||
�Sxd|d|	�D]}|tk�r�P�q�W||	dd�}|�s�tdd�|D���r�|d|	�j
�|}}|dd�dk�rPt|d�\}}d	|k�rd
|k�s,d
|k�r4d	|k�r4td��d	|k�rPd
|k�rPt|�|�rpd|k�rp|jdd�\}}d
|k�r�|jd
d�\}}t|�t|||||�}
|
t|<||
�S)aParse a URL into 5 components:
    <scheme>://<netloc>/<path>?<query>#<fragment>
    Return a 5-tuple: (scheme, netloc, path, query, fragment).
    Note that we don't break the components up in smaller bits
    (e.g. netloc is a single string) and we don't expand % escapes.NrrUrrr3r�z//r\r]zInvalid IPv6 URLrgr�css|]}|dkVqdS)�
0123456789Nr!)r-r~r!r!r"r/�szurlsplit.<locals>.<genexpr>)r8r��lstrip�_WHATWG_C0_CONTROL_OR_SPACE�strip�bool�typer�getrz�MAX_CACHE_SIZEr#rwrKrrP�splitr�r�scheme_charsr�r�)
rirprqrr�key�cachedrVrsrhryr�r~�restr!r!r"r�sh






cCs<t|�\}}}}}}}|r&d||f}|t|||||f��S)z�Put a parsed URL back together again.  This may result in a
    slightly different, but equivalent URL, if the URL that was parsed
    originally had redundant delimiters, e.g. a ? with an empty query
    (the draft states that these are equivalent).z%s;%s)r8r)�
componentsrprVrirtrsrhrrr!r!r"rscCs�t|�\}}}}}}|s4|r`|tkr`|dd�dkr`|rP|dd�dkrPd|}d|pXd|}|rp|d|}|r�|d|}|r�|d	|}||�S)
akCombine the elements of a tuple as returned by urlsplit() into a
    complete URL as a string. The data argument can be any five-item iterable.
    This may result in a slightly different, but equivalent URL, if the URL that
    was parsed originally had unnecessary delimiters (for example, a ? with an
    empty query; the RFC states that these are equivalent).Nr�z//r3rvrrUr�rg)r8�uses_netloc)r�rprVrirsrhrrr!r!r"rs cCs�|s|S|s|St||�\}}}t|d|�\}}}}}}	t|||�\}
}}}
}}|
|ks`|
tkrh||�S|
tkr�|r�|t|
|||
||f��S|}|r�|
r�|}|}
|s�|}|t|
|||
||f��S|jd�}|ddkr�|d=|dd�dk�r�|jd�}n(||jd�}td|dd	��|dd
�<g}xX|D]P}|dk�rdy|j�Wntk
�r`YnXn|dk�rt�q0n
|j	|��q0W|ddk�r�|j	d�|t|
|dj
|��p�d|
||f��S)
zaJoin a base URL and a possibly relative URL to form an absolute
    interpretation of the latter.rrvr3N�..�.���r�r�r�r�)r�r�)r8r�
uses_relativer�rr��filter�pop�
IndexError�append�join)�baserirqrrZbschemeZbnetlocZbpathZbparamsZbqueryZ	bfragmentrprV�pathrtrsrhZ
base_partsZsegmentsZ
resolved_pathZsegr!r!r"r*sT






c	CsTt|�\}}d|kr>t|�\}}}}}}t|||||df�}nd}|}|t||��S)z�Removes any existing fragment from URL.

    Returns a tuple of the defragmented URL and the fragment.  If
    the URL contained no fragments, the second element is the
    empty string.
    rgr)r8rrr)	rirr�sr��p�a�qZfragZdefragr!r!r"rosZ0123456789ABCDEFabcdefcCs�|s|jdSt|t�r"|jd�}|jd�}t|�dkr<|S|dg}|j}tdkrbdd�tD�axb|dd�D]R}y(|t|dd	��||d	d��Wqptk
r�|d�||�YqpXqpWdj	|�S)
z,unquote_to_bytes('abc%20def') -> b'abc def'.�zutf-8rHr3rNcSs4i|],}tD]"}tt||d�g�||j��qqS)�)�_hexdig�bytesrOr()r-r�r�r!r!r"�
<dictcomp>�sz$unquote_to_bytes.<locals>.<dictcomp>r�)
r�r4r5r(rzr��
_hextobyter��KeyErrorr�)�string�bits�resr��itemr!r!r"r�s*



z([-]+)�utf-8r�cCs�d|kr|j|S|dkrd}|dkr*d}tj|�}|dg}|j}x@tdt|�d�D],}|t||�j||��|||d�qVWdj|�S)	a�Replace %xx escapes by their single-character equivalent. The optional
    encoding and errors parameters specify how to decode percent-encoded
    sequences into Unicode characters, as accepted by the bytes.decode()
    method.
    By default, percent-encoded sequences are decoded with UTF-8, and invalid
    sequences are replaced by a placeholder character.

    unquote('abc%20def') -> 'abc def'.
    rGNzutf-8r�rr3r�r)r��_asciirer��rangerzrr,r�)r�r)r*r�r�r�ryr!r!r"r�s


Fc	CsRi}t|||||||d�}x2|D]*\}	}
|	|kr@||	j|
�q |
g||	<q W|S)a�Parse a query given as a string argument.

        Arguments:

        qs: percent-encoded query string to be parsed

        keep_blank_values: flag indicating whether blank values in
            percent-encoded queries should be treated as blank strings.
            A true value indicates that blanks should be retained as
            blank strings.  The default false value indicates that
            blank values are to be ignored and treated as if they were
            not included.

        strict_parsing: flag indicating what to do with parsing errors.
            If false (the default), errors are silently ignored.
            If true, errors raise a ValueError exception.

        encoding and errors: specify how to decode percent-encoded sequences
            into Unicode characters, as accepted by the bytes.decode() method.

        max_num_fields: int. If set, then throws a ValueError if there
            are more than n fields read by parse_qsl().

        Returns a dictionary.
    )r)r*�max_num_fieldsrM)r
r�)�qs�keep_blank_values�strict_parsingr)r*r�rMZ
parsed_result�pairs�name�valuer!r!r"r	�sc@seZdZdZdS)�_QueryStringSeparatorWarningz>Warning for using default `separator` in parse_qs or parse_qslN)r<r=r>r?r!r!r!r"r��sr�z/etc/python/urllib.cfgcCs�t|�\}}t|t�r |jd�}|s6t|ttf�rF|dk	rFtd��t�}|dk�rVt}d}	|dkrvtj	j
|	�}d}
|dkr�ytt�}Wnt
k
r�YnJX|�:ddl}|jdd'd�}
|
j|�|
j
d	|	dd
�}|aWdQRXt}
|dk�rd|k�rddlm}|d-tdd�d}n:|dk�r,|}n*t|�dk�rVt|	�d|
�d�dd��|dk	�r�||k�r�d|jd�|jd�}nd|j|�}||k�r�td��||k�r�dd�|jd�D�}nd d�|j|�D�}g}x�|D]�}|�r�|�r��q�|jd!d�}t|�dk�r>|�r(td"|f��|�r�|jd#�n�q�t|d��sR|�r�|djd$d%�}t|||d&�}||�}|djd$d%�}t|||d&�}||�}|j||f��q�W|S).a�Parse a query given as a string argument.

        Arguments:

        qs: percent-encoded query string to be parsed

        keep_blank_values: flag indicating whether blank values in
            percent-encoded queries should be treated as blank strings.
            A true value indicates that blanks should be retained as blank
            strings.  The default false value indicates that blank values
            are to be ignored and treated as if they were  not included.

        strict_parsing: flag indicating what to do with parsing errors. If
            false (the default), errors are silently ignored. If true,
            errors raise a ValueError exception.

        encoding and errors: specify how to decode percent-encoded sequences
            into Unicode characters, as accepted by the bytes.decode() method.

        max_num_fields: int. If set, then throws a ValueError
            if there are more than n fields read by parse_qsl().

        Returns a list, as G-d intended.
    r$Nz*Separator must be of type string or bytes.ZPYTHON_URLLIB_QS_SEPARATORzenvironment variablerrg)Z
interpolationZcomment_prefixesr	)Zfallbackrm)�warnz4The default separator of urllib.parse.parse_qsl and z1parse_qs was changed to '&' to avoid a web cache z"poisoning issue (CVE-2021-23336). z4By default, semicolons no longer act as query field zseparators. z3See https://access.redhat.com/articles/5860431 for z
more details.r�)�
stacklevel�&Zlegacyr3z (from z) must contain z1 character, or "legacy". See z<https://access.redhat.com/articles/5860431 for more details.zMax number of fields exceededcSs g|]}|jd�D]}|�qqS)rm)r�)r-�s1�s2r!r!r"�
<listcomp>Lszparse_qsl.<locals>.<listcomp>cSsg|]}|�qSr!r!)r-r�r!r!r"r�Ns�=zbad query field: %rr�+� )r)r*)rgzeThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. z�The default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for aThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for more details.)r8r4r�r,r5rP�object�_default_qs_separator�os�environr��open�_QS_SEPARATOR_CONFIG_FILENAME�FileNotFoundError�configparserZConfigParserZ	read_file�warningsr�r�rz�countr�r�r�r)r�r�r�r)r*r�rMrrZ_legacyZenvvar_nameZ
config_sourcerr��configr��
num_fieldsr��rZ
name_valueZnvr�r�r!r!r"r
�s�












cCs|jdd�}t|||�S)z�Like unquote(), but also replace plus signs by spaces, as required for
    unquoting HTML form values.

    unquote_plus('%7e/abc+def') -> '~/abc def'
    r�r�)r�r)r�r)r*r!r!r"rfssAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Quoterz�A mapping from bytes (in range(0,256)) to strings.

    String values are percent-encoded byte values, unless the key < 128, and
    in the "safe" set (either the specified safe set, or default set).
    cCstj|�|_dS)zsafe: bytes object.N)�_ALWAYS_SAFE�union�safe)r;r�r!r!r"�__init__~szQuoter.__init__cCsd|jjt|�fS)Nz<%s %r>)�	__class__r<�dict)r;r!r!r"�__repr__�szQuoter.__repr__cCs(||jkrt|�ndj|�}|||<|S)Nz%{:02X})r��chr�format)r;r�r�r!r!r"�__missing__�szQuoter.__missing__N)r<r=r>r?r�r�r�r!r!r!r"r�vsr�rvcCsbt|t�r8|s|S|dkrd}|dkr*d}|j||�}n |dk	rHtd��|dk	rXtd��t||�S)a�quote('abc def') -> 'abc%20def'

    Each part of a URL, e.g. the path info, the query, etc., has a
    different set of reserved characters that must be quoted.

    RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
    the following reserved characters.

    reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                  "$" | ","

    Each of these characters is reserved in some component of a URL,
    but not necessarily in all of them.

    By default, the quote function is intended for quoting the path
    section of a URL.  Thus, it will not encode '/'.  This character
    is reserved, but in typical usage the quote function is being
    called on a path where the existing slash characters are used as
    reserved characters.

    string and safe may be either str or bytes objects. encoding and errors
    must not be specified if string is a bytes object.

    The optional encoding and errors parameters specify how to deal with
    non-ASCII characters, as accepted by the str.encode method.
    By default, encoding='utf-8' (characters are encoded with UTF-8), and
    errors='strict' (unsupported characters raise a UnicodeEncodeError).
    Nzutf-8r%z,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)r4r5r(r6r
)r�r�r)r*r!r!r"r�s
cCsdt|t�rd|ks$t|t�r2d|kr2t||||�St|t�rBd}nd}t|||||�}|jdd�S)z�Like quote(), but also replace ' ' with '+', as required for quoting
    HTML form values. Plus signs in the original string are escaped unless
    they are included in safe. It also does not have safe default to '/'.
    r�� r�)r4r5r�rr�)r�r�r)r*Zspacer!r!r"r�s
cs�t|ttf�std��|sdSt|t�r6|jdd�}ntdd�|D��}|jt|�s^|j�Syt	|�Wn&t
k
r�t|�jt	|<�YnXdj
�fdd�|D��S)z�Like quote(), but accepts a bytes object rather than a str, and does
    not perform string-to-bytes encoding.  It always returns an ASCII string.
    quote_from_bytes(b'abc def?') -> 'abc%20def%3f'
    z!quote_from_bytes() expected bytesrr$�ignorecSsg|]}|dkr|�qS)�r!)r-r~r!r!r"r��sz$quote_from_bytes.<locals>.<listcomp>csg|]}�|��qSr!r!)r-�char)�quoterr!r"r��s)r4r��	bytearrayr6r5r(�rstrip�_ALWAYS_SAFE_BYTESr,r r�r��__getitem__r�)Zbsr�r!)r�r"r
�s
cCst|d�r|j�}nRy t|�r2t|dt�r2t�Wn0tk
rdtj�\}}}td�j|��YnXg}	|s�xr|D]j\}
}t|
t	�r�||
|�}
n|t
|
�|||�}
t|t	�r�|||�}n|t
|�|||�}|	j|
d|�qtW�n,�x(|D�]\}
}t|
t	��r||
|�}
n|t
|
�|||�}
t|t	��rL|||�}|	j|
d|�q�t|t
��rz|||||�}|	j|
d|�q�yt|�}Wn:tk
�r�|t
|�|||�}|	j|
d|�Yq�XxJ|D]B}
t|
t	��r�||
|�}
n|t
|
�|||�}
|	j|
d|
��q�Wq�Wdj|	�S)a^Encode a dict or sequence of two-element tuples into a URL query string.

    If any values in the query arg are sequences and doseq is true, each
    sequence element is converted to a separate parameter.

    If the query arg is a sequence of two-element tuples, the order of the
    parameters in the output will match the order of parameters in the
    input.

    The components of a query arg may each be either a string or a bytes type.

    The safe, encoding, and errors parameters are passed down to the function
    specified by quote_via (encoding and errors only if a component is a str).
    �itemsrz1not a valid non-string sequence or mapping objectr�r�)
�hasattrr�rzr4r0r6�sys�exc_info�with_tracebackr�r5r�r�)rsZdoseqr�r)r*Z	quote_viaZtyZva�tb�l�kr�r.Zeltr!r!r"r�sP





cCsJt|t�rFy|jd�j�}Wn(tk
rDtdt|�d��YnX|S)zto_bytes(u"URL") --> 'URL'.�ASCIIzURL z contains non-ASCII characters)r4r5r(r,�UnicodeError�repr)rir!r!r"�to_bytes/s
r�cCs`t|�j�}|dd�dkr<|dd�dkr<|dd�j�}|dd�dkr\|dd�j�}|S)	z8unwrap('<URL:type://host/path>') --> 'type://host/path'.Nr3�<�>�zURL:r�r�)r5r�)rir!r!r"�unwrap<s rcCsDtdkrtjdtj�atj|�}|r<|j�\}}|j�|fSd|fS)z:splittype('type:opaquestring') --> 'type', 'opaquestring'.Nz
([^/:]+):(.*))�	_typeprogr��compile�DOTALLr��groupsrK)rir�rp�datar!r!r"�	splittypeEs
rcCsXtdkrtjdtj�atj|�}|rP|j�\}}|rH|ddkrHd|}||fSd|fS)z;splithost('//host[:port]/path') --> 'host[:port]', '/path'.Nz//([^/#?]*)(.*)rrv)�	_hostprogr�rrr�r)rir�Z	host_portr�r!r!r"�	splithostRs
r
cCs |jd�\}}}|r|nd|fS)zJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.rTN)rW)�host�userr}r!r!r"�	splituser`sr
cCs |jd�\}}}||r|ndfS)z/splitpasswd('user:passwd') -> 'user', 'passwd'.rUN)rJ)rr}Zpasswdr!r!r"�splitpasswdesrcCsDtdkrtjdtj�atj|�}|r<|j�\}}|r<||fS|dfS)z*splitport('host:port') --> 'host', 'port'.Nz(.*):([0-9]*)$)�	_portprogr�rrr�r)rr�rQr!r!r"�	splitportls
rr3cCsT|jd�\}}}|s|}n2|rLyt|�}Wntk
rBd}YnX||fS||fS)z�Split host and port, returning numeric port.
    Return given default port if no ':' found; defaults to -1.
    Return numerical port if a valid number are found after ':'.
    Return None if ':' but not a valid number.rUN)rWrOrP)rZdefportr}rQZnportr!r!r"�
splitnportys
rcCs$|jd�\}}}|r||fS|dfS)z/splitquery('/path?query') --> '/path', 'query'.r�N)rW)rir�r}rsr!r!r"�
splitquery�srcCs$|jd�\}}}|r||fS|dfS)z)splittag('/path#tag') --> '/path', 'tag'.rgN)rW)rir�r}�tagr!r!r"�splittag�srcCs|jd�}|d|dd�fS)zksplitattr('/path;attr1=value1;attr2=value2;...') ->
        '/path', ['attr1=value1', 'attr2=value2', ...].rmrr3N)r�)riZwordsr!r!r"�	splitattr�s
rcCs |jd�\}}}||r|ndfS)z-splitvalue('attr=value') --> 'attr', 'value'.r�N)rJ)�attrr}r�r!r!r"�
splitvalue�sr)rT)r)rT)T)r�r�)FFr�r�NN)FFr�r�NN)r�r�)rvNN)rNN)rvr�)r�)er?r�r�r��collectionsr��__all__r�r�rnZnon_hierarchicalZ
uses_queryZ
uses_fragmentr�r�r�r�rr#Z_implicit_encodingZ_implicit_errorsr'r+r2r8r�r9rArCrSrarfZ_DefragResultBaseZ_SplitResultBaseZ_ParseResultBaserirhrprVr�rsrtZ
ResultBaserrrrrrrlrrorr�r�r�r�rrrrrr�r�rrr�rr	�RuntimeWarningr�r�r�r
r�	frozensetr�r�r�r �defaultdictr�rrr
rr�rrrr	r
r
rrrrrrrrr!r!r!r"�<module> s





!


	
	
B
E


&
y
	
,

O

PK�[�\�`7btm_matcher.cpython-38.pycnu�[���U

e5d��@sldZdZddlZddlZddlmZddlmZddlm	Z	Gdd	�d	e
�ZGd
d�de
�Zia
dd
�ZdS)a�A bottom-up tree matching algorithm implementation meant to speed
up 2to3's matching process. After the tree patterns are reduced to
their rarest linear path, a linear Aho-Corasick automaton is
created. The linear automaton traverses the linear paths from the
leaves to the root of the AST and returns a set of nodes for further
matching. This reduces significantly the number of candidate nodes.z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@s eZdZdZe��Zdd�ZdS)�BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content��self�r�+/usr/lib64/python3.8/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__�__doc__�	itertoolsrrrrrrrsrc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
BottomMatcherzgThe main matcher class. After instantiating the patterns should
    be added using the add_fixer methodcCs0t�|_t�|_|jg|_g|_t�d�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�loggingZ	getLoggerZloggerrrrrrs

zBottomMatcher.__init__cCsH|j�|�t|j�}|��}|j||jd�}|D]}|j�|�q2dS)z�Reduces a fixer's pattern tree to a linear path and adds it
        to the matcher(a common Aho-Corasick automaton). The fixer is
        appended on the matching states and called when they are
        reached��startN)r	�appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr�	add_fixer%s
zBottomMatcher.add_fixerc	Cs�|s
|gSt|dt�r`g}|dD]6}|j||d�}|D]}|�|�|dd�|��q:q$|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)z5Recursively adds a linear pattern to the AC automatonrrrN)�
isinstance�tupler �extendrr)r�patternrr"�alternativeZ	end_nodes�endZ	next_noderrrr 1s"zBottomMatcher.addc	Cs�|j}tt�}|D]�}|}|rd|_|jD]$}t|tj�r*|jdkr*d|_qPq*|j	dkrb|j}n|j	}||j
kr�|j
|}|jD]}||�|�q�nH|j}|j
dk	r�|j
jr�q||j
kr�|j
|}|jD]}||�|�q�|j
}qq|S)auThe main interface with the bottom matcher. The tree is
        traversed from the bottom using the constructed
        automaton. Nodes are only checked once as the tree is
        retraversed. When the automaton fails, we give it one more
        shot(in case the above tree matches as a whole with the
        rejected leaf), then we break for the next leaf. There is the
        special case of multiple arguments(see code comments) where we
        recheck the nodes

        Args:
           The leaves of the AST tree to be matched

        Returns:
           A dictionary of node matches with fixers as the keys
        T�;FrN)rr�listZwas_checkedZchildrenr$rZLeaf�value�typerr	r�parent)	rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenr!rrr�runSs8





�



zBottomMatcher.runcs*td��fdd���|j�td�dS)z<Prints a graphviz diagram of the BM automaton(for debugging)z
digraph g{csZ|j��D]J}|j|}td|j|jt|�t|j�f�|dkrLt|j��|�q
dS)Nz%d -> %d [label=%s] //%sr)r�keys�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode��
print_noderrr5�s
�
z*BottomMatcher.print_ac.<locals>.print_node�}N)r1rrrr4r�print_ac�s
zBottomMatcher.print_acN)	rrrrrr#r r/r7rrrrrs"8rcCsDts8ddlm}|j��D]\}}t|�tkr|t|<qt�||�S)Nr)�python_symbols)�_type_reprsZpygramr8�__dict__�itemsr-�int�
setdefault)Ztype_numr8�name�valrrrr2�s
r2)r�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr9r2rrrr�<module>s	PK�[�\��fbtm_utils.cpython-38.opt-1.pycnu�[���U

e5d�&�@s|dZddlmZddlmZmZddlmZmZeZ	eZ
ejZeZ
dZdZdZGdd	�d	e�Zddd�Zd
d�Zdd�Zd
S)z0Utility functions used by the btm_matcher module�)�pytree)�grammar�token)�pattern_symbols�python_symbols���������c@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�MinNodez�This class serves as an intermediate representation of the
    pattern tree during the conversion to sets of leaf-to-root
    subpatternsNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfrr�r�)/usr/lib64/python3.8/lib2to3/btm_utils.py�__init__szMinNode.__init__cCst|j�dt|j�S)N� )�strrr)rrrr�__repr__szMinNode.__repr__cCs�|}g}|r�|jtkr^|j�|�t|j�t|j�krRt|j�g}g|_|j}qn|j}d}q�|jtkr�|j	�|�t|j	�t|j�kr�t
|j	�}g|_	|j}qn|j}d}q�|jtjkr�|j
r�|�|j
�n|�|j�|j}q|S)z�Internal method. Returns a characteristic path of the
        pattern tree. This method must be run for all leaves until the
        linear subpatterns are merged into a singleN)r�TYPE_ALTERNATIVESr�append�lenr
�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s8


zMinNode.leaf_to_rootcCs&|��D]}|��}|r|SqdS)a�Drives the leaf_to_root method. The reason that
        leaf_to_root must be run multiple times is because we need to
        reject 'group' matches; for example the alternative form
        (a | b c) creates a group [b c] that needs to be matched. Since
        matching multiple linear patterns overcomes the automaton's
        capabilities, leaf_to_root merges each group into a single
        choice based on 'characteristic'ity,

        i.e. (a|b c) -> (a|b) if b more characteristic than c

        Returns: The most 'characteristic'(as defined by
          get_characteristic_subpattern) path for the compiled pattern
          tree.
        N)�leavesr#)r�lr"rrr�get_linear_subpatternKszMinNode.get_linear_subpatternccs*|jD]}|��EdHq|js&|VdS)z-Generator that returns the leaves of the treeN)r
r$)r�childrrrr$`s
zMinNode.leaves)NN)	�__name__�
__module__�__qualname__�__doc__rrr#r&r$rrrrr
s
	*r
Nc
Cs�d}|jtjkr|jd}|jtjkr�t|j�dkrFt|jd|�}nFttd�}|jD]4}|j�	|�drlqVt||�}|dk	rV|j�
|�qV�n|jtjkr�t|j�dkr�ttd�}|jD]}t||�}|r�|j�
|�q�|js�d}nt|jd|�}�n�|jtj
k�r�t|jdtj��r>|jdjdk�r>t|jd|�St|jdtj��rd|jdjdk�s�t|j�dk�r�t|jdd��r�|jdjdk�r�dSd	}d}d}d
}d}	d
}
|jD]d}|jtjk�r�d
}|}n*|jtjk�r�d	}|}	n|jtjk�r|}t|d��r�|jdk�r�d	}
�q�|
�rT|jd}t|d��r^|jdk�r^|jd}n
|jd}|jtjk�r�|jd
k�r�ttd�}n4tt|j��r�ttt|j�d�}nttt|j�d�}n\|jtjk�r�|j�d�}|tk�r�tt|d�}nttj|d�}n|jtjk�rt||�}|�rL|	jdjdk�r4d}n|	jdjdk�rHnt�|�r�|dk	�r�|jdd�D]&}t||�}|dk	�rj|j�
|��qj|�r�||_|S)z�
    Internal function. Reduces a compiled pattern tree to an
    intermediate representation suitable for feeding the
    automaton. This also trims off any optional pattern elements(like
    [a], a*).
    N��)rr�(�[�valueTF�=��any�')rr�*�+r)r�symsZMatcherr
ZAlternativesr�reduce_treer
r�indexrZAlternativerZUnit�
isinstancerZLeafr0�hasattrZDetailsZRepeaterrr �TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r!rZnew_noder'ZreducedrZdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr8gs�






�����






r8cs�t|t�s|St|�dkr"|dSg}g}dddddg�g}d�|D]d}tt|d	d
���rDtt|�fdd
���r||�|�qDtt|�fdd
���r�|�|�qD|�|�qD|r�|}n|r�|}n|r�|}t|td
�S)z�Picks the most characteristic from a list of linear patterns
    Current order used is:
    names > common_names > common_chars
    rr,�in�for�if�not�Nonez[]().,:cSst|�tkS�N)rr��xrrr�<lambda>��z/get_characteristic_subpattern.<locals>.<lambda>cst|t�o|�kSrH�r:rrI)�common_charsrrrKrLcst|t�o|�kSrHrMrI)�common_namesrrrKrL)�key)r:�listrr3�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rNrOrr�s6

�
�rccs8|D].}t|ttf�r(t||�EdHq||�VqdS)zPTests test_func on all items of sequence and items of included
    sub-iterablesN)r:rQrrR)ZsequenceZ	test_funcrJrrrrRsrR)N)r+�rZpgen2rrZpygramrrr7r>ZopmaprArr<rr�objectr
r8rrRrrrr�<module>sW
%PK�[�\-8e��pygram.cpython-38.opt-1.pycnu�[���U

e5d�@s�dZddlZddlmZddlmZddlmZej�ej�	e
�d�Zej�ej�	e
�d�ZGd	d
�d
e
�Ze�de�Zee�Ze��Zejd=e��Zejd
=e�de�Zee�ZdS)z&Export the Python grammar and symbols.�N�)�token)�driver)�pytreezGrammar.txtzPatternGrammar.txtc@seZdZdd�ZdS)�SymbolscCs$|j��D]\}}t|||�q
dS)z�Initializer.

        Creates an attribute for each grammar symbol (nonterminal),
        whose value is the symbol's type (an int >= 256).
        N)Z
symbol2number�items�setattr)�selfZgrammar�nameZsymbol�r�&/usr/lib64/python3.8/lib2to3/pygram.py�__init__szSymbols.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrZlib2to3�print�exec)�__doc__�osZpgen2rr�r�path�join�dirname�__file__Z
_GRAMMAR_FILEZ_PATTERN_GRAMMAR_FILE�objectrZload_packaged_grammarZpython_grammarZpython_symbols�copyZ!python_grammar_no_print_statement�keywordsZ*python_grammar_no_print_and_exec_statementZpattern_grammarZpattern_symbolsrrrr�<module>s"�PK�[�\��patcomp.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZdZddlZddlmZmZmZmZmZm	Z	ddl
mZddl
mZGdd	�d	e
�Zd
d�ZGdd
�d
e�Zejejejdd�Zdd�Zdd�Zdd�ZdS)z�Pattern compiler.

The grammar is taken from PatternGrammar.txt.

The compiler compiles a pattern to a pytree.*Pattern instance.
z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�'/usr/lib64/python3.8/lib2to3/patcomp.pyrsrc	csLtjtjtjh}t�t�|�j�}|D] }|\}}}}}||kr&|Vq&dS)z6Tokenizes a string suppressing significant whitespace.N)	r�NEWLINE�INDENT�DEDENTr�generate_tokens�io�StringIO�readline)	�input�skip�tokensZ	quintuple�type�value�start�endZ	line_textrrr�tokenize_wrappersrc@s:eZdZd
dd�Zddd�Zdd�Zdd	d
�Zdd�ZdS)�PatternCompilerNcCsZ|dkrtj|_tj|_nt�|�|_t�|j�|_tj|_	tj
|_tj|jt
d�|_dS)z^Initializer.

        Takes an optional alternative filename for the pattern grammar.
        N)Zconvert)r
Zpattern_grammarrZpattern_symbols�symsrZload_grammarZSymbolsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__(s
zPatternCompiler.__init__Fc
Cspt|�}z|jj||d�}Wn2tjk
rN}ztt|��d�W5d}~XYnX|rb|�|�|fS|�|�SdS)z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)rrZparse_tokensrZ
ParseErrorr�str�compile_node)r$rr&Z	with_treer�root�errr�compile_pattern7s zPatternCompiler.compile_patternc
sV|j�jjkr|jd}|j�jjkrz�fdd�|jddd�D�}t|�dkrX|dStjdd�|D�ddd�}|��S|j�jj	krʇfd	d�|jD�}t|�dkr�|dStj|gddd�}|��S|j�jj
kr���|jdd��}t�|�}|��Sd}|j}t|�d
k�r>|djt
jk�r>|dj}|dd�}d}t|�dk�rx|dj�jjk�rx|d}|dd�}��||�}|dk	�r>|j}	|	d}
|
jt
jk�r�d}tj}nX|
jt
jk�r�d}tj}n>|
jt
jk�r��|	d�}}t|	�dk�r��|	d
�}n|dk�s"|dk�r>|��}tj|gg||d�}|dk	�rN||_|��S)
zXCompiles a node, recursively.

        This is one big switch on the node type.
        rcsg|]}��|��qSr�r(��.0Zch�r$rr�
<listcomp>Osz0PatternCompiler.compile_node.<locals>.<listcomp>N�rcSsg|]
}|g�qSrr)r.�arrrr0Rs��min�maxcsg|]}��|��qSrr,r-r/rrr0Vs�����)rr!ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�get_int�name)
r$�nodeZalts�pZunits�patternrC�nodes�repeatr9Zchildr4r5rr/rr(Cs^

 
"

zPatternCompiler.compile_nodecCs@|d}|jtjkr4tt�|j��}t�t	|�|�S|jtj
kr�|j}|��r�|tkrbt
d|��|dd�rvt
d��t�t|�S|dkr�d}n,|�d�s�t|j|d�}|dkr�t
d|��|dd�r�|�|djd�g}nd}t�||�SnH|jdk�r|�|d�S|jd	k�r<|�|d�}tj|ggddd
�SdS)NrzInvalid token: %rrzCan't have details for token�any�_zInvalid symbol: %r�(�[r3)rr�STRINGr'rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr"r(r9ZNodePatternr;)r$rGrHrDrrZcontent�
subpatternrrrr=�s8
zPatternCompiler.compile_basiccCs
t|j�S�N)�intr)r$rDrrrrB�szPatternCompiler.get_int)N)FF)N)rr
rr%r+r(r=rBrrrrr &s


G
#r )rOrM�NUMBERZTOKENcCs.|d��rtjS|tjkr&tj|SdSdS)Nr)�isalpharrOrZopmap)rrrrrN�s


rNcCs>|\}}}}|s||jkr*tj|||d�Stj|||d�SdS)z9Converts raw node information to a Node or Leaf instance.)�contextN)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrrYr9rrrr#�sr#cCst��|�SrU)r r+)rFrrrr+�sr+)�__doc__�
__author__rZpgen2rrrrrr�r	r
�	Exceptionrr�objectr rOrMrWrQrNr#r+rrrr�<module>s" 
�		PK�[�\�`7 btm_matcher.cpython-38.opt-1.pycnu�[���U

e5d��@sldZdZddlZddlZddlmZddlmZddlm	Z	Gdd	�d	e
�ZGd
d�de
�Zia
dd
�ZdS)a�A bottom-up tree matching algorithm implementation meant to speed
up 2to3's matching process. After the tree patterns are reduced to
their rarest linear path, a linear Aho-Corasick automaton is
created. The linear automaton traverses the linear paths from the
leaves to the root of the AST and returns a set of nodes for further
matching. This reduces significantly the number of candidate nodes.z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@s eZdZdZe��Zdd�ZdS)�BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content��self�r�+/usr/lib64/python3.8/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__�__doc__�	itertoolsrrrrrrrsrc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
BottomMatcherzgThe main matcher class. After instantiating the patterns should
    be added using the add_fixer methodcCs0t�|_t�|_|jg|_g|_t�d�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�loggingZ	getLoggerZloggerrrrrrs

zBottomMatcher.__init__cCsH|j�|�t|j�}|��}|j||jd�}|D]}|j�|�q2dS)z�Reduces a fixer's pattern tree to a linear path and adds it
        to the matcher(a common Aho-Corasick automaton). The fixer is
        appended on the matching states and called when they are
        reached��startN)r	�appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr�	add_fixer%s
zBottomMatcher.add_fixerc	Cs�|s
|gSt|dt�r`g}|dD]6}|j||d�}|D]}|�|�|dd�|��q:q$|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)z5Recursively adds a linear pattern to the AC automatonrrrN)�
isinstance�tupler �extendrr)r�patternrr"�alternativeZ	end_nodes�endZ	next_noderrrr 1s"zBottomMatcher.addc	Cs�|j}tt�}|D]�}|}|rd|_|jD]$}t|tj�r*|jdkr*d|_qPq*|j	dkrb|j}n|j	}||j
kr�|j
|}|jD]}||�|�q�nH|j}|j
dk	r�|j
jr�q||j
kr�|j
|}|jD]}||�|�q�|j
}qq|S)auThe main interface with the bottom matcher. The tree is
        traversed from the bottom using the constructed
        automaton. Nodes are only checked once as the tree is
        retraversed. When the automaton fails, we give it one more
        shot(in case the above tree matches as a whole with the
        rejected leaf), then we break for the next leaf. There is the
        special case of multiple arguments(see code comments) where we
        recheck the nodes

        Args:
           The leaves of the AST tree to be matched

        Returns:
           A dictionary of node matches with fixers as the keys
        T�;FrN)rr�listZwas_checkedZchildrenr$rZLeaf�value�typerr	r�parent)	rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenr!rrr�runSs8





�



zBottomMatcher.runcs*td��fdd���|j�td�dS)z<Prints a graphviz diagram of the BM automaton(for debugging)z
digraph g{csZ|j��D]J}|j|}td|j|jt|�t|j�f�|dkrLt|j��|�q
dS)Nz%d -> %d [label=%s] //%sr)r�keys�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode��
print_noderrr5�s
�
z*BottomMatcher.print_ac.<locals>.print_node�}N)r1rrrr4r�print_ac�s
zBottomMatcher.print_acN)	rrrrrr#r r/r7rrrrrs"8rcCsDts8ddlm}|j��D]\}}t|�tkr|t|<qt�||�S)Nr)�python_symbols)�_type_reprsZpygramr8�__dict__�itemsr-�int�
setdefault)Ztype_numr8�name�valrrrr2�s
r2)r�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr9r2rrrr�<module>s	PK�[�\���__pytree.cpython-38.pycnu�[���U

e5d8m�@s�dZdZddlZddlmZdZiadd�ZGdd	�d	e�Z	Gd
d�de	�Z
Gdd
�d
e	�Zdd�ZGdd�de�Z
Gdd�de
�ZGdd�de
�ZGdd�de
�ZGdd�de
�Zdd�ZdS)z�
Python parse tree definitions.

This is a very concrete parse tree; we need to keep every token and
even the comments and whitespace between tokens.

There's also a pattern matching implementation here.
z#Guido van Rossum <guido@python.org>�N)�StringIOi���cCsDts8ddlm}|j��D]\}}t|�tkr|t|<qt�||�S)N�)�python_symbols)�_type_reprsZpygramr�__dict__�items�type�int�
setdefault)Ztype_numr�name�val�r
�&/usr/lib64/python3.8/lib2to3/pytree.py�	type_reprs
rc@s�eZdZdZdZdZdZdZdZdd�Z	dd�Z
dZd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zdd�Zdd �Zd!d"�Zejd#kr�d$d%�ZdS)&�Basez�
    Abstract base class for Node and Leaf.

    This provides some default functionality and boilerplate using the
    template pattern.

    A node may be a subnode of at most one parent.
    Nr
FcOs|tk	std��t�|�S)z7Constructor that prevents Base from being instantiated.zCannot instantiate Base)r�AssertionError�object�__new__��cls�args�kwdsr
r
rr1szBase.__new__cCs|j|jk	rtS|�|�S)zW
        Compare two nodes for equality.

        This calls the method _eq().
        )�	__class__�NotImplemented�_eq��self�otherr
r
r�__eq__6szBase.__eq__cCst�dS)a_
        Compare two nodes for equality.

        This is called by __eq__ and __ne__.  It is only called if the two nodes
        have the same type.  This must be implemented by the concrete subclass.
        Nodes should be considered equal if they have the same structure,
        ignoring the prefix string and other context information.
        N��NotImplementedErrorrr
r
rrBs	zBase._eqcCst�dS)zr
        Return a cloned (deep) copy of self.

        This must be implemented by the concrete subclass.
        Nr�rr
r
r�cloneMsz
Base.clonecCst�dS)zx
        Return a post-order iterator for the tree.

        This must be implemented by the concrete subclass.
        Nrr!r
r
r�
post_orderUszBase.post_ordercCst�dS)zw
        Return a pre-order iterator for the tree.

        This must be implemented by the concrete subclass.
        Nrr!r
r
r�	pre_order]szBase.pre_ordercCs�|jdk	stt|���|dk	s"t�t|t�s2|g}g}d}|jjD]D}||kr||rdt|jj||f��|dk	rv|�|�d}qB|�|�qB|s�t|j||f��|j��||j_|D]}|j|_q�d|_dS)z/Replace this node with a new one in the parent.NFT)	�parentr�str�
isinstance�list�children�extend�append�changed)r�newZ
l_children�found�ch�xr
r
r�replacees&



zBase.replacecCs*|}t|t�s$|jsdS|jd}q|jS)z9Return the line number which generated the invocant node.Nr)r'�Leafr)�lineno�r�noder
r
r�
get_lineno|s
zBase.get_linenocCs|jr|j��d|_dS)NT)r%r,�was_changedr!r
r
rr,�s
zBase.changedcCsJ|jrFt|jj�D]2\}}||kr|j��|jj|=d|_|SqdS)z�
        Remove the node from the tree. Returns the position of the node in its
        parent's children before it was removed.
        N)r%�	enumerater)r,)r�ir5r
r
r�remove�s

zBase.removec	Cs`|jdkrdSt|jj�D]@\}}||krz|jj|dWStk
rXYdSXqdS)z�
        The node immediately following the invocant in their parent's children
        list. If the invocant does not have a next sibling, it is None
        Nr)r%r8r)�
IndexError�rr9�childr
r
r�next_sibling�s
zBase.next_siblingcCsR|jdkrdSt|jj�D]2\}}||kr|dkr8dS|jj|dSqdS)z�
        The node immediately preceding the invocant in their parent's children
        list. If the invocant does not have a previous sibling, it is None.
        Nrr)r%r8r)r<r
r
r�prev_sibling�s
zBase.prev_siblingccs|jD]}|��EdHqdS�N)r)�leaves�rr=r
r
rrA�s
zBase.leavescCs|jdkrdSd|j��S)Nrr)r%�depthr!r
r
rrC�s
z
Base.depthcCs|j}|dkrdS|jS)z�
        Return the string immediately following the invocant node. This is
        effectively equivalent to node.next_sibling.prefix
        N�)r>�prefix)rZnext_sibr
r
r�
get_suffix�szBase.get_suffix��rcCst|��d�S)N�ascii)r&�encoder!r
r
r�__str__�szBase.__str__)�__name__�
__module__�__qualname__�__doc__rr%r)r7Zwas_checkedrr�__hash__rr"r#r$r1r6r,r:�propertyr>r?rArCrF�sys�version_inforKr
r
r
rrs4

	




rc@s�eZdZdZddd�Zdd�Zdd�Zejd	kr4eZ	d
d�Z
dd
�Zdd�Zdd�Z
edd��Zejdd��Zdd�Zdd�Zdd�ZdS)�Nodez+Concrete implementation for interior nodes.NcCst|dkst|��||_t|�|_|jD] }|jdks@tt|���||_q&|dk	rV||_|rj|dd�|_nd|_dS)z�
        Initializer.

        Takes a type constant (a symbol number >= 256), a sequence of
        child nodes, and an optional context keyword argument.

        As a side effect, the parent pointers of the children are updated.
        �N)rrr(r)r%�reprrE�fixers_applied)rrr)�contextrErWr/r
r
r�__init__�s

z
Node.__init__cCsd|jjt|j�|jfS)�)Return a canonical string representation.z
%s(%s, %r))rrLrrr)r!r
r
r�__repr__�s�z
Node.__repr__cCsd�tt|j��S)�k
        Return a pretty string representation.

        This reproduces the input source exactly.
        rD)�join�mapr&r)r!r
r
r�__unicode__�szNode.__unicode__rGcCs|j|jf|j|jfkS�zCompare two nodes for equality.)rr)rr
r
rr�szNode._eqcCst|jdd�|jD�|jd�S)�$Return a cloned (deep) copy of self.cSsg|]}|���qSr
)r")�.0r/r
r
r�
<listcomp>szNode.clone.<locals>.<listcomp>�rW)rTrr)rWr!r
r
rr"s�z
Node.cloneccs$|jD]}|��EdHq|VdS�z*Return a post-order iterator for the tree.N)r)r#rBr
r
rr#s
zNode.post_orderccs$|V|jD]}|��EdHqdS�z)Return a pre-order iterator for the tree.N)r)r$rBr
r
rr$s
zNode.pre_ordercCs|js
dS|jdjS)zO
        The whitespace and comments preceding this node in the input.
        rDr�r)rEr!r
r
rrEszNode.prefixcCs|jr||jd_dS�Nrrg�rrEr
r
rrEscCs(||_d|j|_||j|<|��dS)z�
        Equivalent to 'node.children[i] = child'. This method also sets the
        child's parent attribute appropriately.
        N)r%r)r,r<r
r
r�	set_child s
zNode.set_childcCs ||_|j�||�|��dS)z�
        Equivalent to 'node.children.insert(i, child)'. This method also sets
        the child's parent attribute appropriately.
        N)r%r)�insertr,r<r
r
r�insert_child*szNode.insert_childcCs||_|j�|�|��dS)z�
        Equivalent to 'node.children.append(child)'. This method also sets the
        child's parent attribute appropriately.
        N)r%r)r+r,rBr
r
r�append_child3szNode.append_child)NNN)rLrMrNrOrYr[r_rRrSrKrr"r#r$rQrE�setterrjrlrmr
r
r
rrT�s(�




	rTc@s�eZdZdZdZdZdZddgfdd�Zdd�Zd	d
�Z	e
jdkrFe	Zdd
�Z
dd�Zdd�Zdd�Zdd�Zedd��Zejdd��ZdS)r2z'Concrete implementation for leaf nodes.rDrNcCsdd|krdksnt|��|dk	r8|\|_\|_|_||_||_|dk	rR||_|dd�|_dS)z�
        Initializer.

        Takes a type constant (a token number < 256), a string value, and an
        optional context keyword argument.
        rrUN)r�_prefixr3�columnr�valuerW)rrrqrXrErWr
r
rrYFs
z
Leaf.__init__cCsd|jj|j|jfS)rZz
%s(%r, %r))rrLrrqr!r
r
rr[Ys�z
Leaf.__repr__cCs|jt|j�S)r\)rEr&rqr!r
r
rr__szLeaf.__unicode__rGcCs|j|jf|j|jfkSr`)rrqrr
r
rrjszLeaf._eqcCs$t|j|j|j|j|jff|jd�S)rard)r2rrqrEr3rprWr!r
r
rr"ns
�z
Leaf.cloneccs
|VdSr@r
r!r
r
rrAtszLeaf.leavesccs
|VdSrer
r!r
r
rr#wszLeaf.post_orderccs
|VdSrfr
r!r
r
rr${szLeaf.pre_ordercCs|jS)zP
        The whitespace and comments preceding this token in the input.
        )ror!r
r
rrEszLeaf.prefixcCs|��||_dSr@)r,rorir
r
rrE�s)rLrMrNrOror3rprYr[r_rRrSrKrr"rAr#r$rQrErnr
r
r
rr2=s*�


r2cCsN|\}}}}|s||jkr<t|�dkr.|dSt|||d�St|||d�SdS)z�
    Convert raw node information to a Node or Leaf instance.

    This is passed to the parser driver which calls it whenever a reduction of a
    grammar rule produces a new complete node, so that the tree is build
    strictly bottom-up.
    rr)rXN)Z
number2symbol�lenrTr2)ZgrZraw_noderrqrXr)r
r
r�convert�srsc@sPeZdZdZdZdZdZdd�Zdd�Zdd�Z	dd	d
�Z
ddd�Zd
d�ZdS)�BasePatterna�
    A pattern is a tree matching pattern.

    It looks for a specific node type (token or symbol), and
    optionally for a specific content.

    This is an abstract base class.  There are three concrete
    subclasses:

    - LeafPattern matches a single leaf node;
    - NodePattern matches a single node (usually non-leaf);
    - WildcardPattern matches a sequence of nodes of variable length.
    NcOs|tk	std��t�|�S)z>Constructor that prevents BasePattern from being instantiated.zCannot instantiate BasePattern)rtrrrrr
r
rr�szBasePattern.__new__cCsHt|j�|j|jg}|r,|ddkr,|d=qd|jjd�tt|��fS)N���z%s(%s)z, )	rr�contentrrrLr]r^rV)rrr
r
rr[�szBasePattern.__repr__cCs|S)z�
        A subclass can define this as a hook for optimizations.

        Returns either self or another node with the same effect.
        r
r!r
r
r�optimize�szBasePattern.optimizecCsn|jdk	r|j|jkrdS|jdk	rRd}|dk	r4i}|�||�sDdS|rR|�|�|dk	rj|jrj|||j<dS)a#
        Does this pattern exactly match a node?

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        Default implementation for non-wildcard patterns.
        NFT)rrv�	_submatch�updater)rr5�results�rr
r
r�match�s


zBasePattern.matchcCs t|�dkrdS|�|d|�S)z�
        Does this pattern exactly match a sequence of nodes?

        Default implementation for non-wildcard patterns.
        rFr)rrr|)r�nodesrzr
r
r�	match_seq�szBasePattern.match_seqccs&i}|r"|�|d|�r"d|fVdS)z}
        Generator yielding all matches for this pattern.

        Default implementation for non-wildcard patterns.
        rrN)r|)rr}r{r
r
r�generate_matches�szBasePattern.generate_matches)N)N)
rLrMrNrOrrvrrr[rwr|r~rr
r
r
rrt�s


rtc@s*eZdZddd�Zd	dd�Zd
dd�ZdS)�LeafPatternNcCsZ|dk	r&d|krdks&nt|��|dk	rDt|t�sDtt|���||_||_||_dS)ap
        Initializer.  Takes optional type, content, and name.

        The type, if given must be a token type (< 256).  If not given,
        this matches any *leaf* node; the content may still be required.

        The content, if given, must be a string.

        If a name is given, the matching node is stored in the results
        dict under that key.
        NrrU)rr'r&rVrrvr)rrrvrr
r
rrY�szLeafPattern.__init__cCst|t�sdSt�|||�S)z*Override match() to insist on a leaf node.F)r'r2rtr|�rr5rzr
r
rr|
s
zLeafPattern.matchcCs|j|jkS)�
        Match the pattern's content to the node's children.

        This assumes the node type matches and self.content is not None.

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        When returning False, the results dict may still be updated.
        )rvrqr�r
r
rrxs
zLeafPattern._submatch)NNN)N)N)rLrMrNrYr|rxr
r
r
rr��s

r�c@s$eZdZdZddd�Zddd�ZdS)	�NodePatternFNcCs�|dk	r|dkst|��|dk	rvt|t�r6tt|���t|�}t|�D].\}}t|t�sdt||f��t|t�rFd|_qF||_	||_
||_dS)ad
        Initializer.  Takes optional type, content, and name.

        The type, if given, must be a symbol type (>= 256).  If the
        type is None this matches *any* single node (leaf or not),
        except if content is not None, in which it only matches
        non-leaf nodes that also match the content pattern.

        The content, if not None, must be a sequence of Patterns that
        must match the node's children exactly.  If the content is
        given, the type must not be None.

        If a name is given, the matching node is stored in the results
        dict under that key.
        NrUT)rr'r&rVr(r8rt�WildcardPattern�	wildcardsrrvr)rrrvrr9�itemr
r
rrY$s
zNodePattern.__init__cCs�|jrHt|j|j�D].\}}|t|j�kr|dk	r<|�|�dSqdSt|j�t|j�kr`dSt|j|j�D]\}}|�||�sndSqndS)r�NTF)r�rrvr)rrry�zipr|)rr5rz�cr{�
subpatternr=r
r
rrxAs

zNodePattern._submatch)NNN)N)rLrMrNr�rYrxr
r
r
rr� s
r�c@s^eZdZdZddedfdd�Zdd�Zddd	�Zdd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)r�a
    A wildcard pattern can match zero or more nodes.

    This has all the flexibility needed to implement patterns like:

    .*      .+      .?      .{m,n}
    (a b c | d e | f)
    (...)*  (...)+  (...)?  (...){m,n}

    except it always uses non-greedy matching.
    NrcCs�d|kr|krtks,nt||f��|dk	rtttt|��}t|�sVtt|���|D]}t|�sZtt|���qZ||_||_||_||_	dS)a�
        Initializer.

        Args:
            content: optional sequence of subsequences of patterns;
                     if absent, matches one node;
                     if present, each subsequence is an alternative [*]
            min: optional minimum number of times to match, default 0
            max: optional maximum number of times to match, default HUGE
            name: optional name assigned to this match

        [*] Thus, if content is [[a, b, c], [d, e], [f, g, h]] this is
            equivalent to (a b c | d e | f g h); if content is None,
            this is equivalent to '.' in regular expression terms.
            The min and max parameters work as follows:
                min=0, max=maxint: .*
                min=1, max=maxint: .+
                min=0, max=1: .?
                min=1, max=1: .
            If content is not None, replace the dot with the parenthesized
            list of alternatives, e.g. (a b c | d e | f g h)*
        rN)
�HUGEr�tupler^rrrVrv�min�maxr)rrvr�r�r�altr
r
rrYks,zWildcardPattern.__init__cCs�d}|jdk	r<t|j�dkr<t|jd�dkr<|jdd}|jdkr�|jdkr�|jdkrft|jd�S|dk	r�|j|jkr�|��S|jdkr�t|t�r�|jdkr�|j|jkr�t|j|j|j|j|j|j�S|S)z+Optimize certain stacked wildcard patterns.Nrr)r)	rvrrr�r�r�rrwr'r�)rr�r
r
rrw�s.
��
�
�

�zWildcardPattern.optimizecCs|�|g|�S)z'Does this pattern exactly match a node?)r~r�r
r
rr|�szWildcardPattern.matchcCsP|�|�D]@\}}|t|�kr
|dk	rD|�|�|jrDt|�||j<dSq
dS)z4Does this pattern exactly match a sequence of nodes?NTF)rrrryrr()rr}rzr�r{r
r
rr~�s
zWildcardPattern.match_seqc	cs,|jdkrTt|jdtt|�|j��D]*}i}|jrF|d|�||j<||fVq&n�|jdkrl|�|�Vn�ttd�r�tj	}t
�t_	z�z<|�|d�D]*\}}|jr�|d|�||j<||fVq�WnLtk
�r|�
|�D]*\}}|jr�|d|�||j<||fVq�YnXW5ttd��r&|t_	XdS)a"
        Generator yielding matches for a sequence of nodes.

        Args:
            nodes: sequence of nodes

        Yields:
            (count, results) tuples where:
            count: the match comprises nodes[:count];
            results: dict containing named submatches.
        NrZ	bare_name�getrefcountr)rv�ranger�rrr�r�_bare_name_matches�hasattrrR�stderrr�_recursive_matches�RuntimeError�_iterative_matches)rr}�countr{Zsave_stderrr
r
rr�s.
 

z WildcardPattern.generate_matchesccs�t|�}d|jkrdifVg}|jD]0}t||�D] \}}||fV|�||f�q4q&|r�g}|D]�\}}	||krd||jkrd|jD]`}t|||d��D]H\}
}|
dkr�i}|�|	�|�|�||
|fV|�||
|f�q�q�qd|}qXdS)z(Helper to iteratively yield the matches.rN)rrr�rvrr+r�ry)rr}Znodelenrzr�r�r{Znew_results�c0�r0�c1�r1r
r
rr��s*






z"WildcardPattern._iterative_matchescCspd}i}d}t|�}|sV||krVd}|jD](}|d�|||�r*|d7}d}qq*q|d|�||j<||fS)z(Special optimized matcher for bare_name.rFTrN)rrrvr|r)rr}r�r{Zdoner�Zleafr
r
rr��s
z"WildcardPattern._bare_name_matchesc	cs�|jdk	st�||jkr"difV||jkr�|jD]`}t||�D]P\}}|�||d�|d�D].\}}i}|�|�|�|�|||fVq`q@q2dS)z(Helper to recursively yield the matches.Nrr)rvrr�r�rr�ry)	rr}r�r�r�r�r�r�r{r
r
rr�
s



 

z"WildcardPattern._recursive_matches)N)N)
rLrMrNrOr�rYrwr|r~rr�r�r�r
r
r
rr�]s#

-r�c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�NegatedPatternNcCs(|dk	rt|t�stt|���||_dS)a
        Initializer.

        The argument is either a pattern or None.  If it is None, this
        only matches an empty sequence (effectively '$' in regex
        lingo).  If it is not None, this matches whenever the argument
        pattern doesn't have any matches.
        N)r'rtrrVrv)rrvr
r
rrYs	zNegatedPattern.__init__cCsdS)NFr
r4r
r
rr|(szNegatedPattern.matchcCst|�dkSrh)rr)rr}r
r
rr~,szNegatedPattern.match_seqccsJ|jdkr"t|�dkrFdifVn$|j�|�D]\}}dSdifVdSrh)rvrrr)rr}r�r{r
r
rr0s
zNegatedPattern.generate_matches)N)rLrMrNrYr|r~rr
r
r
rr�s

r�c	cs�|sdifVn||d|dd�}}|�|�D]Z\}}|sH||fVq0t|||d��D].\}}i}|�|�|�|�|||fVqZq0dS)aR
    Generator yielding matches for a sequence of patterns and nodes.

    Args:
        patterns: a sequence of patterns
        nodes: a sequence of nodes

    Yields:
        (count, results) tuples where:
        count: the entire sequence of patterns matches nodes[:count];
        results: dict containing named submatches.
        rrN)rry)	Zpatternsr}�p�restr�r�r�r�r{r
r
rr<s


r)rO�
__author__rR�iorr�rrrrrTr2rsrtr�r�r�r�rr
r
r
r�<module>s$	
1nNV,==#PK�[�\�`�~�� btm_matcher.cpython-38.opt-2.pycnu�[���U

e5d��@shdZddlZddlZddlmZddlmZddlmZGdd�de	�Z
Gd	d
�d
e	�Ziadd�Z
dS)
z+George Boutsioukis <gboutsioukis@gmail.com>�N)�defaultdict�)�pytree)�reduce_treec@seZdZe��Zdd�ZdS)�BMNodecCs"i|_g|_ttj�|_d|_dS)N�)�transition_table�fixers�nextr�count�id�content��self�r�+/usr/lib64/python3.8/lib2to3/btm_matcher.py�__init__szBMNode.__init__N)�__name__�
__module__�__qualname__�	itertoolsrrrrrrrsrc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
BottomMatchercCs0t�|_t�|_|jg|_g|_t�d�|_dS)NZRefactoringTool)	�set�matchr�rootZnodesr	�loggingZ	getLoggerZloggerrrrrrs

zBottomMatcher.__init__cCsH|j�|�t|j�}|��}|j||jd�}|D]}|j�|�q2dS)N��start)r	�appendrZpattern_treeZget_linear_subpattern�addr)r�fixerZtreeZlinear�match_nodesZ
match_noderrr�	add_fixer%s
zBottomMatcher.add_fixerc	Cs�|s
|gSt|dt�r`g}|dD]6}|j||d�}|D]}|�|�|dd�|��q:q$|S|d|jkr�t�}||j|d<n|j|d}|dd�r�|j|dd�|d�}n|g}|SdS)Nrrr)�
isinstance�tupler�extendrr)r�patternrr!�alternativeZ	end_nodes�endZ	next_noderrrr1s"zBottomMatcher.addc	Cs�|j}tt�}|D]�}|}|rd|_|jD]$}t|tj�r*|jdkr*d|_qPq*|j	dkrb|j}n|j	}||j
kr�|j
|}|jD]}||�|�q�nH|j}|j
dk	r�|j
jr�q||j
kr�|j
|}|jD]}||�|�q�|j
}qq|S)NT�;Fr)rr�listZwas_checkedZchildrenr#rZLeaf�value�typerr	r�parent)	rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ
node_tokenr rrr�runSs8





�



zBottomMatcher.runcs*td��fdd���|j�td�dS)Nz
digraph g{csZ|j��D]J}|j|}td|j|jt|�t|j�f�|dkrLt|j��|�q
dS)Nz%d -> %d [label=%s] //%sr)r�keys�printr�	type_repr�strr	r
)ZnodeZsubnode_keyZsubnode��
print_noderrr4�s
�
z*BottomMatcher.print_ac.<locals>.print_node�})r0rrrr3r�print_ac�s
zBottomMatcher.print_acN)rrrrr"rr.r6rrrrrs
"8rcCsDts8ddlm}|j��D]\}}t|�tkr|t|<qt�||�S)Nr)�python_symbols)�_type_reprsZpygramr7�__dict__�itemsr,�int�
setdefault)Ztype_numr7�name�valrrrr1�s
r1)�
__author__rr�collectionsrrrZ	btm_utilsr�objectrrr8r1rrrr�<module>s	PK�[�\8C�24'4'fixer_util.cpython-38.opt-2.pycnu�[���U

e5dg;�
@s�ddlmZddlmZmZddlmZddlm	Z	dd�Z
dd�Zd	d
�Zdd�Z
dVdd�Zdd�Zdd�Zdd�Ze�e�fdd�ZdWdd�Zdd�Zdd�ZdXdd�Zd d!�ZdYd"d#�ZdZd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1d2d3d4d5d6d7d8d9h
Zd:d;�Z d<a!d=a"d>a#d?a$d@dA�Z%dBdC�Z&dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,ej-ej.hZ/d[dPdQ�Z0ej.ej-ej1hZ2dRdS�Z3d\dTdU�Z4d
S)]�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�*/usr/lib64/python3.8/lib2to3/fixer_util.py�
KeywordArgs�rcCsttjd�S)N�()rr�LPARrrrr
�LParensrcCsttjd�S)N�))rr�RPARrrrr
�RParensrcCsHt|t�s|g}t|t�s&d|_|g}ttj|ttjddd�g|�S)N� r��prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

�rNcCsttj||d�S�Nr)rr�NAME)�namerrrr
�Name$sr!cCs|ttjt�|g�gS�N)rr�trailer�Dot)�obj�attrrrr
�Attr(sr'cCsttjd�S)N�,)rr�COMMArrrr
�Comma,sr*cCsttjd�S)N�.)rr�DOTrrrr
r$0sr$cCs4ttj|��|��g�}|r0|�dttj|��|S)Nr)rrr#�clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr2cCs&ttj|t|�g�}|dk	r"||_|Sr")rr�powerr2r)Z	func_namer0rr1rrr
�Call;sr4cCsttjd�S)N�
�rr�NEWLINErrrr
�NewlineBsr8cCsttjd�S)N�r6rrrr
�	BlankLineFsr:cCsttj||d�Sr)rr�NUMBER)�nrrrr
�NumberJsr=cCs"ttjttjd�|ttjd�g�S)N�[�])rrr#rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMs
�rBcCsttj||d�Sr)rr�STRING)�stringrrrr
�StringSsrEc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|�ttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)Nr9r�for�in�ifr>r?)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr@rA)	Zxp�fp�itZtestZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs(

��rMcCsV|D]}|��qttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)N�fromrr�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos


�rUc	Cs�|d��}|jtjkr"|��}nttj|��g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|d��||d��g�g|�}|j	|_	|S)	Nr%�aftercSsg|]}|���qSr)r-)�.0r<rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r-�typerr/rr3r'r!r#r)r1�results�namesr%Z
newarglistrV�newrrr
�
ImportAndCall�s*


�����r^cCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)NT�rYr�rr)rrrSrr�lenrr�r1rrr
�is_tuple�s
������rccCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)NrrY���r>r?)rrrarSrrrbrrr
�is_list�s
�����recCsttjt�|t�g�Sr")rrrrrrbrrr
�parenthesize�srf�sortedr�set�any�all�tuple�sum�min�max�	enumerateccs$t||�}|r |Vt||�}q
dSr")�getattr)r%r&�nextrrr
�
attr_chain�s
rrzefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     z�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
z`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
FcCspts&t�t�at�t�at�t�adatttg}t|t|d��D]*\}}i}|�||�r@|d|kr@dSq@dS)NT�parentr1F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprr�match)r1Zpatterns�patternrsr[rrr
�in_special_context�s



r{cCs�|j}|dk	r|jtjkrdS|j}|jtjtjfkr:dS|jtjkrX|j	d|krXdS|jtj
ks�|jtjkr�|dk	r�|jtjks�|j	d|kr�dSdS)NFrYT)
Zprev_siblingrZrr,rsr�funcdef�classdef�	expr_stmtrSZ
parametersZ
typedargslistr))r1�prevrsrrr
�is_probably_builtin�s&
��
��r�cCsJ|dk	rF|jtjkr>t|j�dkr>|jd}|jtjkr>|jS|j}qdS)Nr`rr9)	rZr�suiterarSr�INDENTrrs)r1�indentrrr
�find_indentations
r�cCs>|jtjkr|S|��}|jd}|_ttj|g�}||_|Sr")rZrr�r-rsr)r1rsr�rrr
�
make_suitesr�cCs$|jtjkr |j}|std��q|S)Nz,root found before file_input node was found.)rZrZ
file_inputrs�
ValueErrorrbrrr
�	find_root&s

r�cCst|t|�|�}t|�Sr")�find_bindingr��bool)�packager r1Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfkSr")rZr�import_namerRrbrrr
�	is_import7sr�cCs.dd�}t|�}t|||�r dSd}}t|j�D]F\}}||�sDq2t|j|d��D]\}}||�sVqlqV||}qzq2|dkr�t|j�D]8\}}|jtjkr�|jr�|jdjtjkr�|d}q�q�|dkr�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|�|t	tj|
��dS)NcSs |jtjko|jot|jd�S)NrY)rZr�simple_stmtrSr�rbrrr
�is_import_stmt>s�z$touch_import.<locals>.is_import_stmtrYrrOrr)r�r�rorSrZrr�rrCrr�rrrUr8r.)r�r r1r��rootZ
insert_pos�offset�idxZnode2�import_rSrrr
�touch_import;s8�
�
r�cCs�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n0|jtjtjfkr�t|t|jd�|�}|r�|}�n�|jtj	k�rt|t|jd�|�}|r�|}nTt
|jdd��D]@\}}|jtjkr�|j
dkr�t|t|j|d�|�}|r�|}q�nx|jtk�r2|jdj
|k�r2|}nTt|||��rF|}n@|jtjk�rbt|||�}n$|jtjk�r�t||jd��r�|}|r|�s�|St|�r|SqdS)Nrrdr`r_�:�rY)rSrZrZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtror�COLONr�	_def_syms�_is_import_bindingr�r~r�)r r1r��childZretr<�iZkidrrr
r�isH
r�cCsT|g}|rP|��}|jdkr4|jtkr4|�|j�q|jtjkr|j|kr|SqdS)N�)�poprZ�_block_syms�extendrSrrr)r r1Znodesrrr
r��sr�cCs�|jtjkr�|s�|jd}|jtjkrx|jD]H}|jtjkrV|jdj|krt|Sq,|jtjkr,|j|kr,|Sq,nL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd���|kr�dS|jd}|�rtd|��rdS|jtj
k�r0t||��r0|S|jtjk�rh|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)Nrr`rdr_�as)rZrr�rSZdotted_as_namesZdotted_as_namerrrrR�str�stripr�rQZimport_as_name�STAR)r1r r�rTr�Zlastr<rrr
r��s@





r�)N)NN)N)N)N)N)N)5Zpgen2rZpytreerrZpygramrrr9rrrrrr!r'r*r$r2r4r8r:r=rBrErMrUr^rcrerfZconsuming_callsrrrurvrwrtr{r�r�r�r�r�r�r�r}r|r�r�r#r�r�r�rrrr
�<module>s^




�		-
*
PK�[�\��B!!pygram.cpython-38.opt-2.pycnu�[���U

e5d�@s�ddlZddlmZddlmZddlmZej�ej�e	�d�Z
ej�ej�e	�d�ZGdd	�d	e�Z
e�d
e
�Ze
e�Ze��Zejd=e��Zejd=e�d
e�Ze
e�ZdS)
�N�)�token)�driver)�pytreezGrammar.txtzPatternGrammar.txtc@seZdZdd�ZdS)�SymbolscCs$|j��D]\}}t|||�q
dS)N)Z
symbol2number�items�setattr)�selfZgrammar�nameZsymbol�r�&/usr/lib64/python3.8/lib2to3/pygram.py�__init__szSymbols.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrZlib2to3�print�exec)�osZpgen2rr�r�path�join�dirname�__file__Z
_GRAMMAR_FILEZ_PATTERN_GRAMMAR_FILE�objectrZload_packaged_grammarZpython_grammarZpython_symbols�copyZ!python_grammar_no_print_statement�keywordsZ*python_grammar_no_print_and_exec_statementZpattern_grammarZpattern_symbolsrrrr�<module>s �PK�[�\��fbtm_utils.cpython-38.pycnu�[���U

e5d�&�@s|dZddlmZddlmZmZddlmZmZeZ	eZ
ejZeZ
dZdZdZGdd	�d	e�Zddd�Zd
d�Zdd�Zd
S)z0Utility functions used by the btm_matcher module�)�pytree)�grammar�token)�pattern_symbols�python_symbols���������c@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�MinNodez�This class serves as an intermediate representation of the
    pattern tree during the conversion to sets of leaf-to-root
    subpatternsNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfrr�r�)/usr/lib64/python3.8/lib2to3/btm_utils.py�__init__szMinNode.__init__cCst|j�dt|j�S)N� )�strrr)rrrr�__repr__szMinNode.__repr__cCs�|}g}|r�|jtkr^|j�|�t|j�t|j�krRt|j�g}g|_|j}qn|j}d}q�|jtkr�|j	�|�t|j	�t|j�kr�t
|j	�}g|_	|j}qn|j}d}q�|jtjkr�|j
r�|�|j
�n|�|j�|j}q|S)z�Internal method. Returns a characteristic path of the
        pattern tree. This method must be run for all leaves until the
        linear subpatterns are merged into a singleN)r�TYPE_ALTERNATIVESr�append�lenr
�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s8


zMinNode.leaf_to_rootcCs&|��D]}|��}|r|SqdS)a�Drives the leaf_to_root method. The reason that
        leaf_to_root must be run multiple times is because we need to
        reject 'group' matches; for example the alternative form
        (a | b c) creates a group [b c] that needs to be matched. Since
        matching multiple linear patterns overcomes the automaton's
        capabilities, leaf_to_root merges each group into a single
        choice based on 'characteristic'ity,

        i.e. (a|b c) -> (a|b) if b more characteristic than c

        Returns: The most 'characteristic'(as defined by
          get_characteristic_subpattern) path for the compiled pattern
          tree.
        N)�leavesr#)r�lr"rrr�get_linear_subpatternKszMinNode.get_linear_subpatternccs*|jD]}|��EdHq|js&|VdS)z-Generator that returns the leaves of the treeN)r
r$)r�childrrrr$`s
zMinNode.leaves)NN)	�__name__�
__module__�__qualname__�__doc__rrr#r&r$rrrrr
s
	*r
Nc
Cs�d}|jtjkr|jd}|jtjkr�t|j�dkrFt|jd|�}nFttd�}|jD]4}|j�	|�drlqVt||�}|dk	rV|j�
|�qV�n|jtjkr�t|j�dkr�ttd�}|jD]}t||�}|r�|j�
|�q�|js�d}nt|jd|�}�n�|jtj
k�r�t|jdtj��r>|jdjdk�r>t|jd|�St|jdtj��rd|jdjdk�s�t|j�dk�r�t|jdd��r�|jdjdk�r�dSd	}d}d}d
}d}	d
}
|jD]d}|jtjk�r�d
}|}n*|jtjk�r�d	}|}	n|jtjk�r|}t|d��r�|jdk�r�d	}
�q�|
�rT|jd}t|d��r^|jdk�r^|jd}n
|jd}|jtjk�r�|jd
k�r�ttd�}n4tt|j��r�ttt|j�d�}nttt|j�d�}n\|jtjk�r�|j�d�}|tk�r�tt|d�}nttj|d�}n|jtjk�rt||�}|�rL|	jdjdk�r4d}n|	jdjdk�rHnt�|�r�|dk	�r�|jdd�D]&}t||�}|dk	�rj|j�
|��qj|�r�||_|S)z�
    Internal function. Reduces a compiled pattern tree to an
    intermediate representation suitable for feeding the
    automaton. This also trims off any optional pattern elements(like
    [a], a*).
    N��)rr�(�[�valueTF�=��any�')rr�*�+r)r�symsZMatcherr
ZAlternativesr�reduce_treer
r�indexrZAlternativerZUnit�
isinstancerZLeafr0�hasattrZDetailsZRepeaterrr �TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r!rZnew_noder'ZreducedrZdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr8gs�






�����






r8cs�t|t�s|St|�dkr"|dSg}g}dddddg�g}d�|D]d}tt|d	d
���rDtt|�fdd
���r||�|�qDtt|�fdd
���r�|�|�qD|�|�qD|r�|}n|r�|}n|r�|}t|td
�S)z�Picks the most characteristic from a list of linear patterns
    Current order used is:
    names > common_names > common_chars
    rr,�in�for�if�not�Nonez[]().,:cSst|�tkS�N)rr��xrrr�<lambda>��z/get_characteristic_subpattern.<locals>.<lambda>cst|t�o|�kSrH�r:rrI)�common_charsrrrKrLcst|t�o|�kSrHrMrI)�common_namesrrrKrL)�key)r:�listrr3�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rNrOrr�s6

�
�rccs8|D].}t|ttf�r(t||�EdHq||�VqdS)zPTests test_func on all items of sequence and items of included
    sub-iterablesN)r:rQrrR)ZsequenceZ	test_funcrJrrrrRsrR)N)r+�rZpgen2rrZpygramrrr7r>ZopmaprArr<rr�objectr
r8rrRrrrr�<module>sW
%PK�[�\0�F�/�/fixer_util.cpython-38.opt-1.pycnu�[���U

e5dg;�
@s�dZddlmZddlmZmZddlmZddl	m
Z
dd�Zdd	�Zd
d�Z
dd
�ZdWdd�Zdd�Zdd�Zdd�Ze�e
�fdd�ZdXdd�Zdd�Zdd�ZdYdd �Zd!d"�ZdZd#d$�Zd[d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2d3d4d5d6d7d8d9d:h
Z d;d<�Z!d=a"d>a#d?a$d@a%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)dIdJ�Z*dKdL�Z+dMdN�Z,dOdP�Z-ej.ej/hZ0d\dQdR�Z1ej/ej.ej2hZ3dSdT�Z4d]dUdV�Z5dS)^z1Utility functions, node construction macros, etc.�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�*/usr/lib64/python3.8/lib2to3/fixer_util.py�
KeywordArgs�rcCsttjd�S)N�()rr�LPARrrrr
�LParensrcCsttjd�S)N�))rr�RPARrrrr
�RParensrcCsHt|t�s|g}t|t�s&d|_|g}ttj|ttjddd�g|�S)zBuild an assignment statement� r��prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

�rNcCsttj||d�S)zReturn a NAME leafr)rr�NAME)�namerrrr
�Name$sr cCs|ttjt�|g�gS)zA node tuple for obj.attr)rr�trailer�Dot)�obj�attrrrr
�Attr(sr%cCsttjd�S)zA comma leaf�,)rr�COMMArrrr
�Comma,sr(cCsttjd�S)zA period (.) leaf�.)rr�DOTrrrr
r"0sr"cCs4ttj|��|��g�}|r0|�dttj|��|S)z-A parenthesised argument list, used by Call()r)rrr!�clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr0cCs&ttj|t|�g�}|dk	r"||_|S)zA function callN)rr�powerr0r)Z	func_namer.rr/rrr
�Call;sr2cCsttjd�S)zA newline literal�
�rr�NEWLINErrrr
�NewlineBsr6cCsttjd�S)zA blank line�r4rrrr
�	BlankLineFsr8cCsttj||d�S)Nr)rr�NUMBER)�nrrrr
�NumberJsr;cCs"ttjttjd�|ttjd�g�S)zA numeric or string subscript�[�])rrr!rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMs
�r@cCsttj||d�S)z
A string leafr)rr�STRING)�stringrrrr
�StringSsrCc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|�ttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)zuA list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
    r7r�for�in�ifr<r=)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr>r?)	Zxp�fp�itZtestZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs(

��rKcCsV|D]}|��qttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)zO Return an import statement in the form:
        from package import name_leafs�fromrr�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos


�rSc	Cs�|d��}|jtjkr"|��}nttj|��g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|d��||d��g�g|�}|j	|_	|S)	zfReturns an import statement and calls a method
    of the module:

    import module
    module.name()r#�aftercSsg|]}|���qSr)r+)�.0r:rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r+�typerr-rr1r%r r!r)r/�results�namesr#Z
newarglistrT�newrrr
�
ImportAndCall�s*


�����r\cCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)z(Does the node represent a tuple literal?T�rWr�rr)rrrQrr�lenrr�r/rrr
�is_tuple�s
������racCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)z'Does the node represent a list literal?rrW���r<r=)rrr_rQrrr`rrr
�is_list�s
�����rccCsttjt�|t�g�S�N)rrrrrr`rrr
�parenthesize�sre�sortedr�set�any�all�tuple�sum�min�max�	enumerateccs$t||�}|r |Vt||�}q
dS)alFollow an attribute chain.

    If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
    use this to iterate over all objects in the chain. Iteration is
    terminated by getattr(x, attr) is None.

    Args:
        obj: the starting object
        attr: the name of the chaining attribute

    Yields:
        Each successive object in the chain.
    N)�getattr)r#r$�nextrrr
�
attr_chain�s
rqzefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     z�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
z`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
FcCspts&t�t�at�t�at�t�adatttg}t|t|d��D]*\}}i}|�||�r@|d|kr@dSq@dS)a Returns true if node is in an environment where all that is required
        of it is being iterable (ie, it doesn't matter if it returns a list
        or an iterator).
        See test_map_nochange in test_fixers.py for some examples and tests.
        T�parentr/F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprq�match)r/Zpatterns�patternrrrYrrr
�in_special_context�s



rzcCs�|j}|dk	r|jtjkrdS|j}|jtjtjfkr:dS|jtjkrX|j	d|krXdS|jtj
ks�|jtjkr�|dk	r�|jtjks�|j	d|kr�dSdS)zG
    Check that something isn't an attribute or function name etc.
    NFrWT)
Zprev_siblingrXrr*rrr�funcdef�classdef�	expr_stmtrQZ
parametersZ
typedargslistr')r/�prevrrrrr
�is_probably_builtin�s&
��
��rcCsJ|dk	rF|jtjkr>t|j�dkr>|jd}|jtjkr>|jS|j}qdS)zFind the indentation of *node*.Nr^rr7)	rXr�suiter_rQr�INDENTrrr)r/�indentrrr
�find_indentations
r�cCs>|jtjkr|S|��}|jd}|_ttj|g�}||_|Srd)rXrr�r+rrr)r/rrr�rrr
�
make_suitesr�cCs$|jtjkr |j}|std��q|S)zFind the top level namespace.z,root found before file_input node was found.)rXrZ
file_inputrr�
ValueErrorr`rrr
�	find_root&s

r�cCst|t|�|�}t|�S)z� Returns true if name is imported from package at the
        top level of the tree which node belongs to.
        To cover the case of an import like 'import foo', use
        None for the package and 'foo' for the name. )�find_bindingr��bool)�packagerr/Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfkS)z0Returns true if the node is an import statement.)rXr�import_namerPr`rrr
�	is_import7sr�cCs.dd�}t|�}t|||�r dSd}}t|j�D]F\}}||�sDq2t|j|d��D]\}}||�sVqlqV||}qzq2|dkr�t|j�D]8\}}|jtjkr�|jr�|jdjtjkr�|d}q�q�|dkr�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|�|t	tj|
��dS)	z\ Works like `does_tree_import` but adds an import statement
        if it was not imported. cSs |jtjko|jot|jd�S)NrW)rXr�simple_stmtrQr�r`rrr
�is_import_stmt>s�z$touch_import.<locals>.is_import_stmtNrWrrMrr)r�r�rnrQrXrr�rrArr�rrrSr6r,)r�rr/r��rootZ
insert_pos�offset�idxZnode2�import_rQrrr
�touch_import;s8�
�
r�cCs�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n0|jtjtjfkr�t|t|jd�|�}|r�|}�n�|jtj	k�rt|t|jd�|�}|r�|}nTt
|jdd��D]@\}}|jtjkr�|j
dkr�t|t|j|d�|�}|r�|}q�nx|jtk�r2|jdj
|k�r2|}nTt|||��rF|}n@|jtjk�rbt|||�}n$|jtjk�r�t||jd��r�|}|r|�s�|St|�r|SqdS)	z� Returns the node which binds variable name, otherwise None.
        If optional argument package is supplied, only imports will
        be returned.
        See test cases for examples.Nrrbr^r]�:�rW)rQrXrZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrnr�COLONr�	_def_syms�_is_import_bindingr�r}r�)rr/r��childZretr:�iZkidrrr
r�isH
r�cCsT|g}|rP|��}|jdkr4|jtkr4|�|j�q|jtjkr|j|kr|SqdS)N�)�poprX�_block_syms�extendrQrrr)rr/Znodesrrr
r��sr�cCs�|jtjkr�|s�|jd}|jtjkrx|jD]H}|jtjkrV|jdj|krt|Sq,|jtjkr,|j|kr,|Sq,nL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd���|kr�dS|jd}|�rtd|��rdS|jtj
k�r0t||��r0|S|jtjk�rh|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)z� Will reuturn node if node will import name, or node
        will import * from package.  None is returned otherwise.
        See test cases for examples. rr^rbNr]�as)rXrr�rQZdotted_as_namesZdotted_as_namerrrrP�str�stripr�rOZimport_as_name�STAR)r/rr�rRr�Zlastr:rrr
r��s@





r�)N)NN)N)N)N)N)N)6�__doc__Zpgen2rZpytreerrZpygramrrr7rrrrrr r%r(r"r0r2r6r8r;r@rCrKrSr\rarcreZconsuming_callsrqrtrurvrsrzrr�r�r�r�r�r�r|r{r�r�r!r�r�r�rrrr
�<module>s`




�		-
*
PK�[�\�o�m:m:pytree.cpython-38.opt-2.pycnu�[���U

e5d8m�@s�dZddlZddlmZdZiadd�ZGdd�de�ZGd	d
�d
e�Z	Gdd�de�Z
d
d�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�Zdd�ZdS)z#Guido van Rossum <guido@python.org>�N)�StringIOi���cCsDts8ddlm}|j��D]\}}t|�tkr|t|<qt�||�S)N�)�python_symbols)�_type_reprsZpygramr�__dict__�items�type�int�
setdefault)Ztype_numr�name�val�r
�&/usr/lib64/python3.8/lib2to3/pytree.py�	type_reprs
rc@s�eZdZdZdZdZdZdZdd�Zdd�Z	dZ
dd	�Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zd d!�Zejd"kr�d#d$�ZdS)%�BaseNr
FcOs
t�|�S�N��object�__new__��cls�args�kwdsr
r
rr1szBase.__new__cCs|j|jk	rtS|�|�Sr)�	__class__�NotImplemented�_eq��self�otherr
r
r�__eq__6szBase.__eq__cCst�dSr��NotImplementedErrorrr
r
rrBs	zBase._eqcCst�dSrr �rr
r
r�cloneMsz
Base.clonecCst�dSrr r"r
r
r�
post_orderUszBase.post_ordercCst�dSrr r"r
r
r�	pre_order]szBase.pre_ordercCs~t|t�s|g}g}d}|jjD].}||krD|dk	r>|�|�d}q |�|�q |j��||j_|D]}|j|_qfd|_dS�NFT)�
isinstance�list�parent�children�extend�append�changed)r�newZ
l_children�found�ch�xr
r
r�replacees



zBase.replacecCs*|}t|t�s$|jsdS|jd}q|jS�Nr)r'�Leafr*�lineno�r�noder
r
r�
get_lineno|s
zBase.get_linenocCs|jr|j��d|_dS�NT)r)r-�was_changedr"r
r
rr-�s
zBase.changedcCsJ|jrFt|jj�D]2\}}||kr|j��|jj|=d|_|SqdSr)r)�	enumerater*r-)r�ir7r
r
r�remove�s

zBase.removec	Cs`|jdkrdSt|jj�D]@\}}||krz|jj|dWStk
rXYdSXqdS)Nr)r)r;r*�
IndexError�rr<�childr
r
r�next_sibling�s
zBase.next_siblingcCsR|jdkrdSt|jj�D]2\}}||kr|dkr8dS|jj|dSqdS�Nrr)r)r;r*r?r
r
r�prev_sibling�s
zBase.prev_siblingccs|jD]}|��EdHqdSr)r*�leaves�rr@r
r
rrD�s
zBase.leavescCs|jdkrdSd|j��SrB)r)�depthr"r
r
rrF�s
z
Base.depthcCs|j}|dkrdS|jS�N�)rA�prefix)rZnext_sibr
r
r�
get_suffix�szBase.get_suffix��rcCst|��d�S)N�ascii)�str�encoder"r
r
r�__str__�szBase.__str__)�__name__�
__module__�__qualname__rr)r*r:Zwas_checkedrr�__hash__rr#r$r%r2r8r-r=�propertyrArCrDrFrJ�sys�version_inforPr
r
r
rrs2
	




rc@s�eZdZddd�Zdd�Zdd�Zejdkr0eZd	d
�Z	dd�Z
d
d�Zdd�Ze
dd��Zejdd��Zdd�Zdd�Zdd�ZdS)�NodeNcCsN||_t|�|_|jD]
}||_q|dk	r0||_|rD|dd�|_nd|_dSr)rr(r*r)rI�fixers_applied)rrr*�contextrIrYr0r
r
r�__init__�s


z
Node.__init__cCsd|jjt|j�|jfS)Nz
%s(%s, %r))rrQrrr*r"r
r
r�__repr__�s�z
Node.__repr__cCsd�tt|j��SrG)�join�maprNr*r"r
r
r�__unicode__�szNode.__unicode__rKcCs|j|jf|j|jfkSr)rr*rr
r
rr�szNode._eqcCst|jdd�|jD�|jd�S)NcSsg|]}|���qSr
)r#)�.0r0r
r
r�
<listcomp>szNode.clone.<locals>.<listcomp>�rY)rXrr*rYr"r
r
rr#s�z
Node.cloneccs$|jD]}|��EdHq|VdSr)r*r$rEr
r
rr$s
zNode.post_orderccs$|V|jD]}|��EdHqdSr)r*r%rEr
r
rr%s
zNode.pre_ordercCs|js
dS|jdjS)NrHr�r*rIr"r
r
rrIszNode.prefixcCs|jr||jd_dSr3rc�rrIr
r
rrIscCs(||_d|j|_||j|<|��dSr)r)r*r-r?r
r
r�	set_child s
zNode.set_childcCs ||_|j�||�|��dSr)r)r*�insertr-r?r
r
r�insert_child*szNode.insert_childcCs||_|j�|�|��dSr)r)r*r,r-rEr
r
r�append_child3szNode.append_child)NNN)rQrRrSr[r\r_rVrWrPrr#r$r%rUrI�setterrergrhr
r
r
rrX�s&�




	rXc@s�eZdZdZdZdZddgfdd�Zdd�Zdd	�Ze	j
d
krBeZdd�Zd
d�Z
dd�Zdd�Zdd�Zedd��Zejdd��ZdS)r4rHrNcCsF|dk	r|\|_\|_|_||_||_|dk	r4||_|dd�|_dSr)�_prefixr5�columnr�valuerY)rrrlrZrIrYr
r
rr[Fsz
Leaf.__init__cCsd|jj|j|jfS)Nz
%s(%r, %r))rrQrrlr"r
r
rr\Ys�z
Leaf.__repr__cCs|jt|j�Sr)rIrNrlr"r
r
rr__szLeaf.__unicode__rKcCs|j|jf|j|jfkSr)rrlrr
r
rrjszLeaf._eqcCs$t|j|j|j|j|jff|jd�S)Nrb)r4rrlrIr5rkrYr"r
r
rr#ns
�z
Leaf.cloneccs
|VdSrr
r"r
r
rrDtszLeaf.leavesccs
|VdSrr
r"r
r
rr$wszLeaf.post_orderccs
|VdSrr
r"r
r
rr%{szLeaf.pre_ordercCs|jSr)rjr"r
r
rrIszLeaf.prefixcCs|��||_dSr)r-rjrdr
r
rrI�s)rQrRrSrjr5rkr[r\r_rVrWrPrr#rDr$r%rUrIrir
r
r
rr4=s(�


r4cCsN|\}}}}|s||jkr<t|�dkr.|dSt|||d�St|||d�SdS)Nrr)rZ)Z
number2symbol�lenrXr4)ZgrZraw_noderrlrZr*r
r
r�convert�srnc@sLeZdZdZdZdZdd�Zdd�Zdd�Zddd	�Z	dd
d�Z
dd
�ZdS)�BasePatternNcOs
t�|�Srrrr
r
rr�szBasePattern.__new__cCsHt|j�|j|jg}|r,|ddkr,|d=qd|jjd�tt|��fS)N���z%s(%s)z, )	rr�contentrrrQr]r^�repr)rrr
r
rr\�szBasePattern.__repr__cCs|Srr
r"r
r
r�optimize�szBasePattern.optimizecCsn|jdk	r|j|jkrdS|jdk	rRd}|dk	r4i}|�||�sDdS|rR|�|�|dk	rj|jrj|||j<dSr&)rrq�	_submatch�updater)rr7�results�rr
r
r�match�s


zBasePattern.matchcCs t|�dkrdS|�|d|�S)NrFr)rmrx)r�nodesrvr
r
r�	match_seq�szBasePattern.match_seqccs&i}|r"|�|d|�r"d|fVdSrB)rx)rryrwr
r
r�generate_matches�szBasePattern.generate_matches)N)N)rQrRrSrrqrrr\rsrxrzr{r
r
r
rro�s


roc@s*eZdZddd�Zd	dd�Zd
dd�ZdS)�LeafPatternNcCs&|dk	r|dk	r||_||_||_dSr)rrqr)rrrqrr
r
rr[�s
zLeafPattern.__init__cCst|t�sdSt�|||�S�NF)r'r4rorx�rr7rvr
r
rrx
s
zLeafPattern.matchcCs|j|jkSr)rqrlr~r
r
rrts
zLeafPattern._submatch)NNN)N)N)rQrRrSr[rxrtr
r
r
rr|�s

r|c@s$eZdZdZddd�Zddd�ZdS)	�NodePatternFNcCsP|dk	r|dk	r:t|�}t|�D]\}}t|t�r d|_q ||_||_||_dSr9)r(r;r'�WildcardPattern�	wildcardsrrqr)rrrqrr<�itemr
r
rr[$s
zNodePattern.__init__cCs�|jrHt|j|j�D].\}}|t|j�kr|dk	r<|�|�dSqdSt|j�t|j�kr`dSt|j|j�D]\}}|�||�sndSqndS�NTF)r�r{rqr*rmru�ziprx)rr7rv�crw�
subpatternr@r
r
rrtAs

zNodePattern._submatch)NNN)N)rQrRrSr�r[rtr
r
r
rr s
rc@sZeZdZddedfdd�Zdd�Zddd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)r�NrcCs<|dk	r ttt|��}|D]}q||_||_||_||_dSr)�tupler^rq�min�maxr)rrqr�r�r�altr
r
rr[kszWildcardPattern.__init__cCs�d}|jdk	r<t|j�dkr<t|jd�dkr<|jdd}|jdkr�|jdkr�|jdkrft|jd�S|dk	r�|j|jkr�|��S|jdkr�t|t�r�|jdkr�|j|jkr�t|j|j|j|j|j|j�S|S)Nrr)r)	rqrmr�r�rrrsr'r�)rr�r
r
rrs�s.
��
�
�

�zWildcardPattern.optimizecCs|�|g|�Sr)rzr~r
r
rrx�szWildcardPattern.matchcCsP|�|�D]@\}}|t|�kr
|dk	rD|�|�|jrDt|�||j<dSq
dSr�)r{rmrurr()rryrvr�rwr
r
rrz�s
zWildcardPattern.match_seqc	cs,|jdkrTt|jdtt|�|j��D]*}i}|jrF|d|�||j<||fVq&n�|jdkrl|�|�Vn�ttd�r�tj	}t
�t_	z�z<|�|d�D]*\}}|jr�|d|�||j<||fVq�WnLtk
�r|�
|�D]*\}}|jr�|d|�||j<||fVq�YnXW5ttd��r&|t_	XdS)NrZ	bare_name�getrefcountr)rq�ranger�rmr�r�_bare_name_matches�hasattrrV�stderrr�_recursive_matches�RuntimeError�_iterative_matches)rry�countrwZsave_stderrr
r
rr{�s.
 

z WildcardPattern.generate_matchesccs�t|�}d|jkrdifVg}|jD]0}t||�D] \}}||fV|�||f�q4q&|r�g}|D]�\}}	||krd||jkrd|jD]`}t|||d��D]H\}
}|
dkr�i}|�|	�|�|�||
|fV|�||
|f�q�q�qd|}qXdSr3)rmr�rqr{r,r�ru)rryZnodelenrvr�r�rwZnew_results�c0�r0�c1�r1r
r
rr��s*






z"WildcardPattern._iterative_matchescCspd}i}d}t|�}|sV||krVd}|jD](}|d�|||�r*|d7}d}qq*q|d|�||j<||fS)NrFTr)rmrqrxr)rryr�rwZdoner�Zleafr
r
rr��s
z"WildcardPattern._bare_name_matchesc	cs�||jkrdifV||jkr�|jD]`}t||�D]P\}}|�||d�|d�D].\}}i}|�|�|�|�|||fVqRq2q$dSrB)r�r�rqr{r�ru)	rryr�r�r�r�r�r�rwr
r
rr�
s



 

z"WildcardPattern._recursive_matches)N)N)rQrRrS�HUGEr[rsrxrzr{r�r�r�r
r
r
rr�]s#

-r�c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�NegatedPatternNcCs|dk	r||_dSr)rq)rrqr
r
rr[s	zNegatedPattern.__init__cCsdSr}r
r6r
r
rrx(szNegatedPattern.matchcCst|�dkSr3)rm)rryr
r
rrz,szNegatedPattern.match_seqccsJ|jdkr"t|�dkrFdifVn$|j�|�D]\}}dSdifVdSr3)rqrmr{)rryr�rwr
r
rr{0s
zNegatedPattern.generate_matches)N)rQrRrSr[rxrzr{r
r
r
rr�s

r�c	cs�|sdifVn||d|dd�}}|�|�D]Z\}}|sH||fVq0t|||d��D].\}}i}|�|�|�|�|||fVqZq0dSrB)r{ru)	Zpatternsry�p�restr�r�r�r�rwr
r
rr{<s


r{)�
__author__rV�iorr�rrrrrXr4rnror|rr�r�r{r
r
r
r�<module>
s"
1nNV,==#PK�[�\��IW�?�?refactor.cpython-38.opt-2.pycnu�[���U

e5dk�@s
dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZddlmZd d
d�ZGdd
�d
e�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!dS)!z#Guido van Rossum <guido@python.org>�N)�chain�)�driver�tokenize�token)�	find_root)�pytree�pygram)�btm_matcherTcCsTt|ggdg�}g}t�|j�D].\}}}|�d�r |rD|dd�}|�|�q |S)N�*�fix_�)�
__import__�pkgutilZiter_modules�__path__�
startswith�append)Z	fixer_pkgZ
remove_prefixZpkgZ	fix_names�finder�nameZispkg�r�(/usr/lib64/python3.8/lib2to3/refactor.py�get_all_fix_namess
rc@seZdZdS)�
_EveryNodeN��__name__�
__module__�__qualname__rrrrr+srcCs�t|tjtjf�r(|jdkr t�|jhSt|tj�rH|jrDt|j�St�t|tj	�r�t
�}|jD]}|D]}|�t|��qhq`|Std|��dS)Nz$Oh no! I don't understand pattern %s)
�
isinstancerZNodePatternZLeafPattern�typerZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update�	Exception)Zpat�r�p�xrrrr/s


rc	Cs�t�t�}g}|D]x}|jrdzt|j�}Wntk
rH|�|�Yq�X|D]}||�|�qNq|jdk	r�||j�|�q|�|�qtt	j
j��t	j
j
�D]}||�|�q�t|�S�N)�collections�defaultdict�list�patternrrrZ_accept_typerr	�python_grammarZ
symbol2number�values�tokens�extend�dict)Z
fixer_listZ
head_nodesZevery�fixerZheadsZ	node_typerrr�_get_headnode_dictKs$

�r1cs�fdd�t�d�D�S)Ncsg|]}�d|�qS��.r)�.0�fix_name�Zpkg_namerr�
<listcomp>hs�z+get_fixers_from_package.<locals>.<listcomp>F)rr6rr6r�get_fixers_from_packageds
�r8cCs|Sr&r)�objrrr�	_identityksr:csXd}t�t�|�j���fdd�}ttjtjtj	h�}t
�}z�|�\}}||krTq>q>|tjkrl|rf�q6d}q>|tjk�r6|dk�r6|�\}}|tjks�|dkr��q6|�\}}|tjks�|dkrq6|�\}}|tj
kr�|dkr�|�\}}|tjk�r4|�|�|�\}}|tj
k�s.|d	k�r"�q4|�\}}q�q>�q6q>Wntk
�rNYnXt|�S)
NFcst��}|d|dfS)Nrr)�next)�tok��genrr�advancersz(_detect_future_features.<locals>.advanceT�fromZ
__future__�import�(�,)r�generate_tokens�io�StringIO�readline�	frozensetr�NEWLINE�NL�COMMENTr �STRING�NAME�OP�add�
StopIteration)�sourceZhave_docstringr?�ignore�features�tp�valuerr=r�_detect_future_featuresosB








rVc@seZdZdS)�
FixerErrorNrrrrrrW�srWc@s�eZdZddd�ZdZdZd4dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zd7dd�Zdd�Zd8dd�Zdd�Zd d!�Zd9d"d#�Zd:d$d%�Zd&Zd'Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS);�RefactoringToolF)�print_function�write_unchanged_filesZFixrNcCs.||_|pg|_|j��|_|dk	r0|j�|�|jdrDtj|_ntj	|_|j�
d�|_g|_t
�d�|_g|_d|_tj|jtj|jd�|_|��\|_|_g|_t��|_g|_g|_t|j|j�D]F}|j r�|j�!|�q�||jkr�|j�"|�q�||jkr�|j�"|�q�t#|j�|_$t#|j�|_%dS)NrYrZrXF)�convert�logger)&�fixers�explicit�_default_options�copy�optionsr!r	�!python_grammar_no_print_statement�grammarr+�getrZ�errors�loggingZ	getLoggerr\�	fixer_log�wroterZDriverrr[�
get_fixers�	pre_order�
post_order�files�bmZ
BottomMatcher�BMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr1�bmi_pre_order_heads�bmi_post_order_heads)�selfZfixer_namesrar^r0rrr�__init__�s>


�


zRefactoringTool.__init__c	CsXg}g}|jD�]}t|iidg�}|�dd�d}|�|j�rR|t|j�d�}|�d�}|jd�dd�|D��}zt	||�}Wn&t
k
r�td	||f�d�YnX||j|j
�}	|	jr�|jd
k	r�||jkr�|�d|�q|�d|�|	jd
k�r|�|	�q|	jdk�r|�|	�qtd|	j��qt�d�}
|j|
d�|j|
d�||fS)Nrr3r����_�cSsg|]}|���qSr)�title)r4r$rrrr7�sz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order��key)r]r�rsplitr�FILE_PREFIX�len�split�CLASS_PREFIX�join�getattr�AttributeErrorrWrargr^�log_message�	log_debug�orderr�operator�
attrgetter�sort)rqZpre_order_fixersZpost_order_fixersZfix_mod_path�modr5�parts�
class_nameZ	fix_classr0Zkey_funcrrrri�s:
�
zRefactoringTool.get_fixerscOs�dSr&r)rq�msg�args�kwdsrrr�	log_error�szRefactoringTool.log_errorcGs|r||}|j�|�dSr&)r\�info�rqr�r�rrrr�szRefactoringTool.log_messagecGs|r||}|j�|�dSr&)r\�debugr�rrrr�	szRefactoringTool.log_debugcCsdSr&r)rq�old_text�new_text�filename�equalrrr�print_outputszRefactoringTool.print_outputcCs8|D].}tj�|�r$|�|||�q|�|||�qdSr&)�os�path�isdir�refactor_dir�
refactor_file)rq�items�write�
doctests_onlyZdir_or_filerrr�refactorszRefactoringTool.refactorc
Cs�tjd}t�|�D]�\}}}|�d|�|��|��|D]>}|�d�s>tj�|�d|kr>tj�||�}	|�	|	||�q>dd�|D�|dd�<qdS)N�pyzDescending into %sr3rcSsg|]}|�d�s|�qSr2)r)r4Zdnrrrr7.s
z0RefactoringTool.refactor_dir.<locals>.<listcomp>)
r��extsep�walkr�r�rr��splitextr~r�)
rqZdir_namer�r�Zpy_ext�dirpathZdirnames�	filenamesr�fullnamerrrr�s

�zRefactoringTool.refactor_dirc
Cs�zt|d�}Wn6tk
rD}z|�d||�WY�dSd}~XYnXzt�|j�d}W5|��Xtj|d|dd��}|��|fW5QR�SQRXdS)N�rbzCan't open %s: %s)NNrr#ru��encoding�newline)	�open�OSErrorr��closer�detect_encodingrGrE�read)rqr��f�errr�rrr�_read_python_source0s
z#RefactoringTool._read_python_sourcecCs�|�|�\}}|dkrdS|d7}|rn|�d|�|�||�}|jsL||kr`|�|||||�q�|�d|�nH|�||�}|js�|r�|jr�|jt|�dd�|||d�n|�d|�dS)N�
zRefactoring doctests in %szNo doctest changes in %srs)r�r�zNo changes in %s)r�r��refactor_docstringrZ�processed_file�refactor_string�was_changed�str)rqr�r�r��inputr��output�treerrrr�@s"�zRefactoringTool.refactor_filec
Cs�t|�}d|krtj|j_zVz|j�|�}Wn@tk
rl}z"|�d||jj	|�WY�W�dSd}~XYnXW5|j|j_X||_
|�d|�|�||�|S)NrYzCan't parse %s: %s: %szRefactoring %s)
rVr	rbrrcZparse_stringr"r��	__class__r�future_featuresr��
refactor_tree)rq�datarrSr�r�rrrr�Ws"
� zRefactoringTool.refactor_stringcCs�tj��}|rN|�d�|�|d�}|js2||krB|�|d|�q�|�d�n:|�|d�}|jsj|r~|jr~|�t	|�d|�n
|�d�dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
�sys�stdinr�r�r�rZr�r�r�r�)rqr�r�r�r�rrr�refactor_stdinrs

zRefactoringTool.refactor_stdinc

Cs�t|j|j�D]}|�||�q|�|j|���|�|j|���|j�|�	��}t
|����r�|jjD�]D}||krj||rj||j
tjjdd�|jr�||j
tjjd�t||�D]�}|||kr�||�|�zt|�Wntk
�rYq�YnX|j�r||jk�rq�|�|�}|r�|�||�}|dk	r�|�|�|��D] }|j�s^g|_|j�|��qL|j�|�	��}|D]*}	|	|k�r�g||	<||	�||	��q�q�qjqTt|j|j�D]}|�||��q�|jS)NT)rx�reverserw)rrjrkZ
start_tree�traverse_byrorprn�runZleaves�anyr,r]r�rZBaseZdepthZkeep_line_orderZ
get_linenor)�remover�
ValueErrorZfixers_applied�match�	transform�replacerr.Zfinish_treer�)
rqr�rr0Z	match_set�node�results�newZnew_matchesZfxrrrrr��sJ



zRefactoringTool.refactor_treecCsV|sdS|D]D}||jD]4}|�|�}|r|�||�}|dk	r|�|�|}qqdSr&)rr�r�r�)rqr]Z	traversalr�r0r�r�rrrr��s

zRefactoringTool.traverse_bycCs�|j�|�|dkr.|�|�d}|dkr.dS||k}|�||||�|r`|�d|�|js`dS|rv|�||||�n|�d|�dS)NrzNo changes to %szNot writing changes to %s)rlrr�r�r�rZ�
write_file)rqr�r�r�r�r�r�rrrr��szRefactoringTool.processed_filecCs�ztj|d|dd�}Wn6tk
rL}z|�d||�WY�dSd}~XYnX|�Fz|�|�Wn0tk
r�}z|�d||�W5d}~XYnXW5QRX|�d|�d|_dS)N�wrur�zCan't create %s: %szCan't write %s: %szWrote changes to %sT)rEr�r�r�r�r�rh)rqr�r�r�r��fpr�rrrr��s*zRefactoringTool.write_filez>>> z... c
	Csg}d}d}d}d}|jdd�D]�}|d7}|���|j�r~|dk	rZ|�|�||||��|}|g}|�|j�}	|d|	�}q |dk	r�|�||j�s�|||j��dkr�|�	|�q |dk	r�|�|�||||��d}d}|�	|�q |dk	�r
|�|�||||��d�
|�S)NrT��keependsrr�ru)�
splitlines�lstripr�PS1r.�refactor_doctest�find�PS2�rstriprr~)
rqr�r��result�blockZblock_lineno�indent�lineno�line�irrrr�sJ����
�z"RefactoringTool.refactor_docstringc

sz��||��}Wnjtk
r|}zL�j�tj�rN|D]}��d|�d��q6��d|||j	j
|�|WY�Sd}~XYnX��||��rt|�j
dd�}|d|d�||dd�}	}|d�d�s�|dd7<��j|�d�g}|�r|��fd	d
�|D�7}|S)Nz
Source: %sr�z+Can't parse docstring in %s line %s: %s: %sTr�rrsrcsg|]}��j|�qSr)r�)r4r��r�rqrrr7Zsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>)�parse_blockr"r\ZisEnabledForrf�DEBUGr�r�r�r�rr�r�r��endswithr��pop)
rqr�r�r�r�r�r�r�r�Zclippedrr�rr�@s,�"z RefactoringTool.refactor_doctestcCs�|jrd}nd}|js$|�d|�n"|�d|�|jD]}|�|�q6|jrl|�d�|jD]}|�|�q\|jr�t|j�dkr�|�d�n|�dt|j��|jD]\}}}|j|f|�|�q�dS)	N�werez
need to bezNo files %s modified.zFiles that %s modified:z$Warnings/messages while refactoring:rzThere was 1 error:zThere were %d errors:)rhrlr�rgrer{)rqr��file�messager�r�r�rrr�	summarize]s$


zRefactoringTool.summarizecCs"|j�|�|||��}t�|_|Sr&)rZparse_tokens�	wrap_toksrHr�)rqr�r�r�r�rrrr�tszRefactoringTool.parse_blockccsdt�|�||�j�}|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqdS)Nr)rrD�	gen_lines�__next__)rqr�r�r�r-rrUZline0Zcol0Zline1Zcol1Z	line_textrrrr�~s
zRefactoringTool.wrap_toksccsx||j}||j}|}|D]N}|�|�r>|t|�d�Vn(||��dkrVdVntd||f��|}qdVqldS)Nr�zline=%r, prefix=%rru)r�r�rr{r��AssertionError)rqr�r��prefix1Zprefix2�prefixr�rrrr��s


zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rrrr_r}rzrrrir�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrX�s>�
4(
	


O�

+
rXc@seZdZdS)�MultiprocessingUnsupportedNrrrrrr��sr�csBeZdZ�fdd�Zd�fdd�	Z�fdd�Z�fd	d
�Z�ZS)�MultiprocessRefactoringToolcs"tt|�j||�d|_d|_dSr&)�superr�rr�queue�output_lock�rqr��kwargs�r�rrrr�sz$MultiprocessRefactoringTool.__init__Frc
s�|dkrtt���|||�Szddl�Wntk
r@t�YnX�jdk	rTtd������_��	��_
��fdd�t|�D�}z*|D]}|��q�tt���|||�W5�j��t|�D]}�j�
d�q�|D]}|��r�|��q�d�_XdS)Nrrz already doing multiple processescsg|]}�j�jd��qS))�target)ZProcess�_child)r4r���multiprocessingrqrrr7�s�z8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)r�r�r�r��ImportErrorr�r��RuntimeErrorZ
JoinableQueueZLockr��ranger~�putZis_alive�start)rqr�r�r�Z
num_processesZ	processesr�r$r�r�rr��s<
�



�
�

z$MultiprocessRefactoringTool.refactorcsN|j��}|dk	rJ|\}}ztt|�j||�W5|j��X|j��}q
dSr&)r�rdZ	task_doner�r�r�)rqZtaskr�r�r�rrr��s

�z"MultiprocessRefactoringTool._childcs2|jdk	r|j�||f�ntt|�j||�SdSr&)r�r�r�r�r�r�r�rrr��s

�z)MultiprocessRefactoringTool.refactor_file)FFr)rrrrrr�r�r��
__classcell__rrr�rr��s�r�)T)"�
__author__rEr�rr�rfr�r'�	itertoolsrZpgen2rrrZ
fixer_utilrrurr	r
rmrr"rrr1r8r:rVrW�objectrXr�r�rrrr�<module>s6
(	PK�[�\��M*�O�Orefactor.cpython-38.opt-1.pycnu�[���U

e5dk�@sdZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZddlmZddlmZmZdd	lmZd!dd�ZGd
d�de�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd �d e �Z"dS)"z�Refactoring framework.

Used as a main program, this can refactor any number of files and/or
recursively descend down directories.  Imported as a module, this
provides infrastructure to write your own refactoring tool.
z#Guido van Rossum <guido@python.org>�N)�chain�)�driver�tokenize�token)�	find_root)�pytree�pygram)�btm_matcherTcCsTt|ggdg�}g}t�|j�D].\}}}|�d�r |rD|dd�}|�|�q |S)zEReturn a sorted list of all available fix names in the given package.�*�fix_�N)�
__import__�pkgutilZiter_modules�__path__�
startswith�append)Z	fixer_pkgZ
remove_prefixZpkgZ	fix_names�finder�nameZispkg�r�(/usr/lib64/python3.8/lib2to3/refactor.py�get_all_fix_namess
rc@seZdZdS)�
_EveryNodeN��__name__�
__module__�__qualname__rrrrr+srcCs�t|tjtjf�r(|jdkr t�|jhSt|tj�rH|jrDt|j�St�t|tj	�r�t
�}|jD]}|D]}|�t|��qhq`|Std|��dS)zf Accepts a pytree Pattern Node and returns a set
        of the pattern types which will match first. Nz$Oh no! I don't understand pattern %s)
�
isinstancerZNodePatternZLeafPattern�typerZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update�	Exception)Zpat�r�p�xrrrr/s


rc	Cs�t�t�}g}|D]x}|jrdzt|j�}Wntk
rH|�|�Yq�X|D]}||�|�qNq|jdk	r�||j�|�q|�|�qtt	j
j��t	j
j
�D]}||�|�q�t|�S)z^ Accepts a list of fixers and returns a dictionary
        of head node type --> fixer list.  N)�collections�defaultdict�list�patternrrrZ_accept_typerr	�python_grammarZ
symbol2number�values�tokens�extend�dict)Z
fixer_listZ
head_nodesZevery�fixerZheadsZ	node_typerrr�_get_headnode_dictKs$

�r0cs�fdd�t�d�D�S)zN
    Return the fully qualified names for fixers in the package pkg_name.
    csg|]}�d|�qS��.r)�.0�fix_name�Zpkg_namerr�
<listcomp>hs�z+get_fixers_from_package.<locals>.<listcomp>F)rr5rr5r�get_fixers_from_packageds
�r7cCs|S�Nr)�objrrr�	_identityksr:csXd}t�t�|�j���fdd�}ttjtjtj	h�}t
�}z�|�\}}||krTq>q>|tjkrl|rf�q6d}q>|tjk�r6|dk�r6|�\}}|tjks�|dkr��q6|�\}}|tjks�|dkrq6|�\}}|tj
kr�|dkr�|�\}}|tjk�r4|�|�|�\}}|tj
k�s.|d	k�r"�q4|�\}}q�q>�q6q>Wntk
�rNYnXt|�S)
NFcst��}|d|dfS)Nrr)�next)�tok��genrr�advancersz(_detect_future_features.<locals>.advanceT�fromZ
__future__�import�(�,)r�generate_tokens�io�StringIO�readline�	frozensetr�NEWLINE�NL�COMMENTr �STRING�NAME�OP�add�
StopIteration)�sourceZhave_docstringr?�ignore�features�tp�valuerr=r�_detect_future_featuresosB








rVc@seZdZdZdS)�
FixerErrorzA fixer could not be loaded.N)rrr�__doc__rrrrrW�srWc@s�eZdZddd�ZdZdZd4dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zd7dd�Zdd�Zd8dd�Zdd�Zd d!�Zd9d"d#�Zd:d$d%�Zd&Zd'Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS);�RefactoringToolF)�print_function�write_unchanged_filesZFixrNcCs.||_|pg|_|j��|_|dk	r0|j�|�|jdrDtj|_ntj	|_|j�
d�|_g|_t
�d�|_g|_d|_tj|jtj|jd�|_|��\|_|_g|_t��|_g|_g|_t|j|j�D]F}|j r�|j�!|�q�||jkr�|j�"|�q�||jkr�|j�"|�q�t#|j�|_$t#|j�|_%dS)z�Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: a dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
        NrZr[rYF)�convert�logger)&�fixers�explicit�_default_options�copy�optionsr!r	�!python_grammar_no_print_statement�grammarr*�getr[�errors�loggingZ	getLoggerr]�	fixer_log�wroterZDriverrr\�
get_fixers�	pre_order�
post_order�files�bmZ
BottomMatcher�BMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr0�bmi_pre_order_heads�bmi_post_order_heads)�selfZfixer_namesrbr_r/rrr�__init__�s>


�


zRefactoringTool.__init__c	CsXg}g}|jD�]}t|iidg�}|�dd�d}|�|j�rR|t|j�d�}|�d�}|jd�dd	�|D��}zt	||�}Wn&t
k
r�td
||f�d�YnX||j|j
�}	|	jr�|jdk	r�||jkr�|�d|�q|�d
|�|	jdk�r|�|	�q|	jdk�r|�|	�qtd|	j��qt�d�}
|j|
d�|j|
d�||fS)aInspects the options to load the requested patterns and handlers.

        Returns:
          (pre_order, post_order), where pre_order is the list of fixers that
          want a pre-order AST traversal, and post_order is the list that want
          post-order traversal.
        rr2r���N�_�cSsg|]}|���qSr)�title)r3r$rrrr6�sz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order��key)r^r�rsplitr�FILE_PREFIX�len�split�CLASS_PREFIX�join�getattr�AttributeErrorrWrbrhr_�log_message�	log_debug�orderr�operator�
attrgetter�sort)rrZpre_order_fixersZpost_order_fixersZfix_mod_path�modr4�parts�
class_nameZ	fix_classr/Zkey_funcrrrrj�s:
�
zRefactoringTool.get_fixerscOs�dS)zCalled when an error occurs.Nr)rr�msg�args�kwdsrrr�	log_error�szRefactoringTool.log_errorcGs|r||}|j�|�dS)zHook to log a message.N)r]�info�rrr�r�rrrr�szRefactoringTool.log_messagecGs|r||}|j�|�dSr8)r]�debugr�rrrr�	szRefactoringTool.log_debugcCsdS)zTCalled with the old version, new version, and filename of a
        refactored file.Nr)rr�old_text�new_text�filename�equalrrr�print_outputszRefactoringTool.print_outputcCs8|D].}tj�|�r$|�|||�q|�|||�qdS)z)Refactor a list of files and directories.N)�os�path�isdir�refactor_dir�
refactor_file)rr�items�write�
doctests_onlyZdir_or_filerrr�refactorszRefactoringTool.refactorc
Cs�tjd}t�|�D]�\}}}|�d|�|��|��|D]>}|�d�s>tj�|�d|kr>tj�||�}	|�	|	||�q>dd�|D�|dd�<qdS)z�Descends down a directory and refactor every Python file found.

        Python files are assumed to have a .py extension.

        Files and subdirectories starting with '.' are skipped.
        �pyzDescending into %sr2rcSsg|]}|�d�s|�qSr1)r)r3Zdnrrrr6.s
z0RefactoringTool.refactor_dir.<locals>.<listcomp>N)
r��extsep�walkr�r�rr��splitextrr�)
rrZdir_namer�r�Zpy_ext�dirpathZdirnames�	filenamesr�fullnamerrrr�s

�zRefactoringTool.refactor_dirc
Cs�zt|d�}Wn6tk
rD}z|�d||�WY�dSd}~XYnXzt�|j�d}W5|��Xtj|d|dd��}|��|fW5QR�SQRXdS)	zG
        Do our best to decode a Python source file correctly.
        �rbzCan't open %s: %s)NNNrr#rv��encoding�newline)	�open�OSErrorr��closer�detect_encodingrGrE�read)rrr��f�errr�rrr�_read_python_source0s
z#RefactoringTool._read_python_sourcecCs�|�|�\}}|dkrdS|d7}|rn|�d|�|�||�}|jsL||kr`|�|||||�q�|�d|�nH|�||�}|js�|r�|jr�|jt|�dd�|||d�n|�d|�dS)zRefactors a file.N�
zRefactoring doctests in %szNo doctest changes in %srt)r�r�zNo changes in %s)r�r��refactor_docstringr[�processed_file�refactor_string�was_changed�str)rrr�r�r��inputr��output�treerrrr�@s"�zRefactoringTool.refactor_filec
Cs�t|�}d|krtj|j_zVz|j�|�}Wn@tk
rl}z"|�d||jj	|�WY�W�dSd}~XYnXW5|j|j_X||_
|�d|�|�||�|S)aFRefactor a given input string.

        Args:
            data: a string holding the code to be refactored.
            name: a human-readable name for use in error/log messages.

        Returns:
            An AST corresponding to the refactored input stream; None if
            there were errors during the parse.
        rZzCan't parse %s: %s: %sNzRefactoring %s)
rVr	rcrrdZparse_stringr"r��	__class__r�future_featuresr��
refactor_tree)rr�datarrSr�r�rrrr�Ws"
� zRefactoringTool.refactor_stringcCs�tj��}|rN|�d�|�|d�}|js2||krB|�|d|�q�|�d�n:|�|d�}|jsj|r~|jr~|�t	|�d|�n
|�d�dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
�sys�stdinr�r�r�r[r�r�r�r�)rrr�r�r�r�rrr�refactor_stdinrs

zRefactoringTool.refactor_stdinc

Cs�t|j|j�D]}|�||�q|�|j|���|�|j|���|j�|�	��}t
|����r�|jjD�]D}||krj||rj||j
tjjdd�|jr�||j
tjjd�t||�D]�}|||kr�||�|�zt|�Wntk
�rYq�YnX|j�r||jk�rq�|�|�}|r�|�||�}|dk	r�|�|�|��D] }|j�s^g|_|j�|��qL|j�|�	��}|D]*}	|	|k�r�g||	<||	�||	��q�q�qjqTt|j|j�D]}|�||��q�|jS)a�Refactors a parse tree (modifying the tree in place).

        For compatible patterns the bottom matcher module is
        used. Otherwise the tree is traversed node-to-node for
        matches.

        Args:
            tree: a pytree.Node instance representing the root of the tree
                  to be refactored.
            name: a human-readable name for this tree.

        Returns:
            True if the tree was modified, False otherwise.
        T)ry�reverserxN)rrkrlZ
start_tree�traverse_byrprqro�runZleaves�anyr+r^r�rZBaseZdepthZkeep_line_orderZ
get_linenor(�remover�
ValueErrorZfixers_applied�match�	transform�replacerr-Zfinish_treer�)
rrr�rr/Z	match_set�node�results�newZnew_matchesZfxrrrrr��sJ



zRefactoringTool.refactor_treecCsV|sdS|D]D}||jD]4}|�|�}|r|�||�}|dk	r|�|�|}qqdS)aTraverse an AST, applying a set of fixers to each node.

        This is a helper method for refactor_tree().

        Args:
            fixers: a list of fixer instances.
            traversal: a generator that yields AST nodes.

        Returns:
            None
        N)rr�r�r�)rrr^Z	traversalr�r/r�r�rrrr��s

zRefactoringTool.traverse_bycCs�|j�|�|dkr.|�|�d}|dkr.dS||k}|�||||�|r`|�d|�|js`dS|rv|�||||�n|�d|�dS)zR
        Called when a file has been refactored and there may be changes.
        NrzNo changes to %szNot writing changes to %s)rmrr�r�r�r[�
write_file)rrr�r�r�r�r�r�rrrr��szRefactoringTool.processed_filecCs�ztj|d|dd�}Wn6tk
rL}z|�d||�WY�dSd}~XYnX|�Fz|�|�Wn0tk
r�}z|�d||�W5d}~XYnXW5QRX|�d|�d|_dS)	z�Writes a string to a file.

        It first shows a unified diff between the old text and the new text, and
        then rewrites the file; the latter is only done if the write option is
        set.
        �wrvr�zCan't create %s: %sNzCan't write %s: %szWrote changes to %sT)rEr�r�r�r�r�ri)rrr�r�r�r��fpr�rrrr��s*zRefactoringTool.write_filez>>> z... c
	Csg}d}d}d}d}|jdd�D]�}|d7}|���|j�r~|dk	rZ|�|�||||��|}|g}|�|j�}	|d|	�}q |dk	r�|�||j�s�|||j��dkr�|�	|�q |dk	r�|�|�||||��d}d}|�	|�q |dk	�r
|�|�||||��d�
|�S)a�Refactors a docstring, looking for doctests.

        This returns a modified version of the input string.  It looks
        for doctests, which start with a ">>>" prompt, and may be
        continued with "..." prompts, as long as the "..." is indented
        the same as the ">>>".

        (Unfortunately we can't use the doctest module's parser,
        since, like most parsers, it is not geared towards preserving
        the original source.)
        NrT��keependsrr�rv)�
splitlines�lstripr�PS1r-�refactor_doctest�find�PS2�rstriprr)
rrr�r��result�blockZblock_lineno�indent�lineno�line�irrrr�sJ����
�z"RefactoringTool.refactor_docstringc

sz��||��}Wnjtk
r|}zL�j�tj�rN|D]}��d|�d��q6��d|||j	j
|�|WY�Sd}~XYnX��||��rt|�j
dd�}|d|d�||dd�}	}|d�d�s�|dd7<��j|�d	�g}|�r|��fd
d�|D�7}|S)z�Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).

        z
Source: %sr�z+Can't parse docstring in %s line %s: %s: %sNTr�rrtrcsg|]}��j|�qSr)r�)r3r��r�rrrrr6Zsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>)�parse_blockr"r]ZisEnabledForrg�DEBUGr�r�r�r�rr�r�r��endswithr��pop)
rrr�r�r�r�r�r�r�r�Zclippedrr�rr�@s,�"z RefactoringTool.refactor_doctestcCs�|jrd}nd}|js$|�d|�n"|�d|�|jD]}|�|�q6|jrl|�d�|jD]}|�|�q\|jr�t|j�dkr�|�d�n|�dt|j��|jD]\}}}|j|f|�|�q�dS)	N�werez
need to bezNo files %s modified.zFiles that %s modified:z$Warnings/messages while refactoring:rzThere was 1 error:zThere were %d errors:)rirmr�rhrfr|)rrr��file�messager�r�r�rrr�	summarize]s$


zRefactoringTool.summarizecCs"|j�|�|||��}t�|_|S)z�Parses a block into a tree.

        This is necessary to get correct line number / offset information
        in the parser diagnostics and embedded into the parse tree.
        )rZparse_tokens�	wrap_toksrHr�)rrr�r�r�r�rrrr�tszRefactoringTool.parse_blockccsdt�|�||�j�}|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqdS)z;Wraps a tokenize stream to systematically modify start/end.rN)rrD�	gen_lines�__next__)rrr�r�r�r,rrUZline0Zcol0Zline1Zcol1Z	line_textrrrr�~s
zRefactoringTool.wrap_toksccsx||j}||j}|}|D]N}|�|�r>|t|�d�Vn(||��dkrVdVntd||f��|}qdVqldS)z�Generates lines as expected by tokenize from a list of lines.

        This strips the first len(indent + self.PS1) characters off each line.
        Nr�zline=%r, prefix=%rrv)r�r�rr|r��AssertionError)rrr�r��prefix1Zprefix2�prefixr�rrrr��s


zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rrrr`r~r{rsrjr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrY�s>�
4(
	


O�

+
rYc@seZdZdS)�MultiprocessingUnsupportedNrrrrrr��sr�csBeZdZ�fdd�Zd�fdd�	Z�fdd�Z�fd	d
�Z�ZS)�MultiprocessRefactoringToolcs"tt|�j||�d|_d|_dSr8)�superr�rs�queue�output_lock�rrr��kwargs�r�rrrs�sz$MultiprocessRefactoringTool.__init__Frc
s�|dkrtt���|||�Szddl�Wntk
r@t�YnX�jdk	rTtd������_��	��_
��fdd�t|�D�}z*|D]}|��q�tt���|||�W5�j��t|�D]}�j�
d�q�|D]}|��r�|��q�d�_XdS)Nrrz already doing multiple processescsg|]}�j�jd��qS))�target)ZProcess�_child)r3r���multiprocessingrrrrr6�s�z8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)r�r�r�r��ImportErrorr�r��RuntimeErrorZ
JoinableQueueZLockr��ranger�putZis_alive�start)rrr�r�r�Z
num_processesZ	processesr�r$r�r�rr��s<
�



�
�

z$MultiprocessRefactoringTool.refactorcsN|j��}|dk	rJ|\}}ztt|�j||�W5|j��X|j��}q
dSr8)r�reZ	task_doner�r�r�)rrZtaskr�r�r�rrr��s

�z"MultiprocessRefactoringTool._childcs2|jdk	r|j�||f�ntt|�j||�SdSr8)r�r�r�r�r�r�r�rrr��s

�z)MultiprocessRefactoringTool.refactor_file)FFr)rrrrsr�r�r��
__classcell__rrr�rr��s�r�)T)#rX�
__author__rEr�rr�rgr�r&�	itertoolsrZpgen2rrrZ
fixer_utilrrvrr	r
rnrr"rrr0r7r:rVrW�objectrYr�r�rrrr�<module>s8
(	PK�[�\Kuw�  btm_utils.cpython-38.opt-2.pycnu�[���U

e5d�&�@sxddlmZddlmZmZddlmZmZeZeZ	ej
ZeZdZ
dZdZGdd�de�Zdd
d�Zdd
�Zdd�Zd	S)�)�pytree)�grammar�token)�pattern_symbols�python_symbols���������c@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�MinNodeNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfrr�r�)/usr/lib64/python3.8/lib2to3/btm_utils.py�__init__szMinNode.__init__cCst|j�dt|j�S)N� )�strrr)rrrr�__repr__szMinNode.__repr__cCs�|}g}|r�|jtkr^|j�|�t|j�t|j�krRt|j�g}g|_|j}qn|j}d}q�|jtkr�|j	�|�t|j	�t|j�kr�t
|j	�}g|_	|j}qn|j}d}q�|jtjkr�|j
r�|�|j
�n|�|j�|j}q|S�N)r�TYPE_ALTERNATIVESr�append�lenr
�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s8


zMinNode.leaf_to_rootcCs&|��D]}|��}|r|SqdSr)�leavesr$)r�lr#rrr�get_linear_subpatternKszMinNode.get_linear_subpatternccs*|jD]}|��EdHq|js&|VdSr)r
r%)r�childrrrr%`s
zMinNode.leaves)NN)�__name__�
__module__�__qualname__rrr$r'r%rrrrr
s

	*r
Nc
Cs�d}|jtjkr|jd}|jtjkr�t|j�dkrFt|jd|�}nFttd�}|jD]4}|j�	|�drlqVt||�}|dk	rV|j�
|�qV�n|jtjkr�t|j�dkr�ttd�}|jD]}t||�}|r�|j�
|�q�|js�d}nt|jd|�}�n�|jtj
k�r�t|jdtj��r>|jdjdk�r>t|jd|�St|jdtj��rd|jdjdk�s�t|j�dk�r�t|jdd��r�|jdjdk�r�dSd}d}d}d	}d}	d	}
|jD]d}|jtjk�r�d	}|}n*|jtjk�r�d}|}	n|jtjk�r|}t|d��r�|jd
k�r�d}
�q�|
�rT|jd}t|d��r^|jdk�r^|jd}n
|jd}|jtjk�r�|jdk�r�ttd�}n4tt|j��r�ttt|j�d�}nttt|j�d�}n\|jtjk�r�|j�d
�}|tk�r�tt|d�}nttj|d�}n|jtjk�rt||�}|�rL|	jdjdk�r4d}n|	jdjdk�rHnt�|�r�|dk	�r�|jdd�D]&}t||�}|dk	�rj|j�
|��qj|�r�||_|S)N��)rr�(�[�valueTF�=��any�')rr�*�+r)r�symsZMatcherr
ZAlternativesr�reduce_treer
r�indexrZAlternativerZUnit�
isinstancerZLeafr0�hasattrZDetailsZRepeaterr r!�TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r"rZnew_noder(ZreducedrZdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr8gs�






�����






r8cs�t|t�s|St|�dkr"|dSg}g}dddddg�g}d�|D]d}tt|d	d
���rDtt|�fdd
���r||�|�qDtt|�fdd
���r�|�|�qD|�|�qD|r�|}n|r�|}n|r�|}t|td
�S)Nrr,�in�for�if�not�Nonez[]().,:cSst|�tkSr)rr��xrrr�<lambda>��z/get_characteristic_subpattern.<locals>.<lambda>cst|t�o|�kSr�r:rrH)�common_charsrrrJrKcst|t�o|�kSrrLrH)�common_namesrrrJrK)�key)r:�listrr3�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rMrNrr�s6

�
�rccs8|D].}t|ttf�r(t||�EdHq||�VqdSr)r:rPrrQ)ZsequenceZ	test_funcrIrrrrQsrQ)N)�rZpgen2rrZpygramrrr7r>ZopmaprAr r<rr�objectr
r8rrQrrrr�<module>sW
%PK�[�\����O�Orefactor.cpython-38.pycnu�[���U

e5dk�@sdZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZddlmZddlmZmZdd	lmZd!dd�ZGd
d�de�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd �d e �Z"dS)"z�Refactoring framework.

Used as a main program, this can refactor any number of files and/or
recursively descend down directories.  Imported as a module, this
provides infrastructure to write your own refactoring tool.
z#Guido van Rossum <guido@python.org>�N)�chain�)�driver�tokenize�token)�	find_root)�pytree�pygram)�btm_matcherTcCsTt|ggdg�}g}t�|j�D].\}}}|�d�r |rD|dd�}|�|�q |S)zEReturn a sorted list of all available fix names in the given package.�*�fix_�N)�
__import__�pkgutilZiter_modules�__path__�
startswith�append)Z	fixer_pkgZ
remove_prefixZpkgZ	fix_names�finder�nameZispkg�r�(/usr/lib64/python3.8/lib2to3/refactor.py�get_all_fix_namess
rc@seZdZdS)�
_EveryNodeN��__name__�
__module__�__qualname__rrrrr+srcCs�t|tjtjf�r(|jdkr t�|jhSt|tj�rH|jrDt|j�St�t|tj	�r�t
�}|jD]}|D]}|�t|��qhq`|Std|��dS)zf Accepts a pytree Pattern Node and returns a set
        of the pattern types which will match first. Nz$Oh no! I don't understand pattern %s)
�
isinstancerZNodePatternZLeafPattern�typerZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update�	Exception)Zpat�r�p�xrrrr/s


rc	Cs�t�t�}g}|D]x}|jrdzt|j�}Wntk
rH|�|�Yq�X|D]}||�|�qNq|jdk	r�||j�|�q|�|�qtt	j
j��t	j
j
�D]}||�|�q�t|�S)z^ Accepts a list of fixers and returns a dictionary
        of head node type --> fixer list.  N)�collections�defaultdict�list�patternrrrZ_accept_typerr	�python_grammarZ
symbol2number�values�tokens�extend�dict)Z
fixer_listZ
head_nodesZevery�fixerZheadsZ	node_typerrr�_get_headnode_dictKs$

�r0cs�fdd�t�d�D�S)zN
    Return the fully qualified names for fixers in the package pkg_name.
    csg|]}�d|�qS��.r)�.0�fix_name�Zpkg_namerr�
<listcomp>hs�z+get_fixers_from_package.<locals>.<listcomp>F)rr5rr5r�get_fixers_from_packageds
�r7cCs|S�Nr)�objrrr�	_identityksr:csXd}t�t�|�j���fdd�}ttjtjtj	h�}t
�}z�|�\}}||krTq>q>|tjkrl|rf�q6d}q>|tjk�r6|dk�r6|�\}}|tjks�|dkr��q6|�\}}|tjks�|dkrq6|�\}}|tj
kr�|dkr�|�\}}|tjk�r4|�|�|�\}}|tj
k�s.|d	k�r"�q4|�\}}q�q>�q6q>Wntk
�rNYnXt|�S)
NFcst��}|d|dfS)Nrr)�next)�tok��genrr�advancersz(_detect_future_features.<locals>.advanceT�fromZ
__future__�import�(�,)r�generate_tokens�io�StringIO�readline�	frozensetr�NEWLINE�NL�COMMENTr �STRING�NAME�OP�add�
StopIteration)�sourceZhave_docstringr?�ignore�features�tp�valuerr=r�_detect_future_featuresosB








rVc@seZdZdZdS)�
FixerErrorzA fixer could not be loaded.N)rrr�__doc__rrrrrW�srWc@s�eZdZddd�ZdZdZd4dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zd7dd�Zdd�Zd8dd�Zdd�Zd d!�Zd9d"d#�Zd:d$d%�Zd&Zd'Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS);�RefactoringToolF)�print_function�write_unchanged_filesZFixrNcCs.||_|pg|_|j��|_|dk	r0|j�|�|jdrDtj|_ntj	|_|j�
d�|_g|_t
�d�|_g|_d|_tj|jtj|jd�|_|��\|_|_g|_t��|_g|_g|_t|j|j�D]F}|j r�|j�!|�q�||jkr�|j�"|�q�||jkr�|j�"|�q�t#|j�|_$t#|j�|_%dS)z�Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: a dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
        NrZr[rYF)�convert�logger)&�fixers�explicit�_default_options�copy�optionsr!r	�!python_grammar_no_print_statement�grammarr*�getr[�errors�loggingZ	getLoggerr]�	fixer_log�wroterZDriverrr\�
get_fixers�	pre_order�
post_order�files�bmZ
BottomMatcher�BMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr0�bmi_pre_order_heads�bmi_post_order_heads)�selfZfixer_namesrbr_r/rrr�__init__�s>


�


zRefactoringTool.__init__c	CsXg}g}|jD�]}t|iidg�}|�dd�d}|�|j�rR|t|j�d�}|�d�}|jd�dd	�|D��}zt	||�}Wn&t
k
r�td
||f�d�YnX||j|j
�}	|	jr�|jdk	r�||jkr�|�d|�q|�d
|�|	jdk�r|�|	�q|	jdk�r|�|	�qtd|	j��qt�d�}
|j|
d�|j|
d�||fS)aInspects the options to load the requested patterns and handlers.

        Returns:
          (pre_order, post_order), where pre_order is the list of fixers that
          want a pre-order AST traversal, and post_order is the list that want
          post-order traversal.
        rr2r���N�_�cSsg|]}|���qSr)�title)r3r$rrrr6�sz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order��key)r^r�rsplitr�FILE_PREFIX�len�split�CLASS_PREFIX�join�getattr�AttributeErrorrWrbrhr_�log_message�	log_debug�orderr�operator�
attrgetter�sort)rrZpre_order_fixersZpost_order_fixersZfix_mod_path�modr4�parts�
class_nameZ	fix_classr/Zkey_funcrrrrj�s:
�
zRefactoringTool.get_fixerscOs�dS)zCalled when an error occurs.Nr)rr�msg�args�kwdsrrr�	log_error�szRefactoringTool.log_errorcGs|r||}|j�|�dS)zHook to log a message.N)r]�info�rrr�r�rrrr�szRefactoringTool.log_messagecGs|r||}|j�|�dSr8)r]�debugr�rrrr�	szRefactoringTool.log_debugcCsdS)zTCalled with the old version, new version, and filename of a
        refactored file.Nr)rr�old_text�new_text�filename�equalrrr�print_outputszRefactoringTool.print_outputcCs8|D].}tj�|�r$|�|||�q|�|||�qdS)z)Refactor a list of files and directories.N)�os�path�isdir�refactor_dir�
refactor_file)rr�items�write�
doctests_onlyZdir_or_filerrr�refactorszRefactoringTool.refactorc
Cs�tjd}t�|�D]�\}}}|�d|�|��|��|D]>}|�d�s>tj�|�d|kr>tj�||�}	|�	|	||�q>dd�|D�|dd�<qdS)z�Descends down a directory and refactor every Python file found.

        Python files are assumed to have a .py extension.

        Files and subdirectories starting with '.' are skipped.
        �pyzDescending into %sr2rcSsg|]}|�d�s|�qSr1)r)r3Zdnrrrr6.s
z0RefactoringTool.refactor_dir.<locals>.<listcomp>N)
r��extsep�walkr�r�rr��splitextrr�)
rrZdir_namer�r�Zpy_ext�dirpathZdirnames�	filenamesr�fullnamerrrr�s

�zRefactoringTool.refactor_dirc
Cs�zt|d�}Wn6tk
rD}z|�d||�WY�dSd}~XYnXzt�|j�d}W5|��Xtj|d|dd��}|��|fW5QR�SQRXdS)	zG
        Do our best to decode a Python source file correctly.
        �rbzCan't open %s: %s)NNNrr#rv��encoding�newline)	�open�OSErrorr��closer�detect_encodingrGrE�read)rrr��f�errr�rrr�_read_python_source0s
z#RefactoringTool._read_python_sourcecCs�|�|�\}}|dkrdS|d7}|rn|�d|�|�||�}|jsL||kr`|�|||||�q�|�d|�nH|�||�}|js�|r�|jr�|jt|�dd�|||d�n|�d|�dS)zRefactors a file.N�
zRefactoring doctests in %szNo doctest changes in %srt)r�r�zNo changes in %s)r�r��refactor_docstringr[�processed_file�refactor_string�was_changed�str)rrr�r�r��inputr��output�treerrrr�@s"�zRefactoringTool.refactor_filec
Cs�t|�}d|krtj|j_zVz|j�|�}Wn@tk
rl}z"|�d||jj	|�WY�W�dSd}~XYnXW5|j|j_X||_
|�d|�|�||�|S)aFRefactor a given input string.

        Args:
            data: a string holding the code to be refactored.
            name: a human-readable name for use in error/log messages.

        Returns:
            An AST corresponding to the refactored input stream; None if
            there were errors during the parse.
        rZzCan't parse %s: %s: %sNzRefactoring %s)
rVr	rcrrdZparse_stringr"r��	__class__r�future_featuresr��
refactor_tree)rr�datarrSr�r�rrrr�Ws"
� zRefactoringTool.refactor_stringcCs�tj��}|rN|�d�|�|d�}|js2||krB|�|d|�q�|�d�n:|�|d�}|jsj|r~|jr~|�t	|�d|�n
|�d�dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
�sys�stdinr�r�r�r[r�r�r�r�)rrr�r�r�r�rrr�refactor_stdinrs

zRefactoringTool.refactor_stdinc

Cs�t|j|j�D]}|�||�q|�|j|���|�|j|���|j�|�	��}t
|����r�|jjD�]D}||krj||rj||j
tjjdd�|jr�||j
tjjd�t||�D]�}|||kr�||�|�zt|�Wntk
�rYq�YnX|j�r||jk�rq�|�|�}|r�|�||�}|dk	r�|�|�|��D] }|j�s^g|_|j�|��qL|j�|�	��}|D]*}	|	|k�r�g||	<||	�||	��q�q�qjqTt|j|j�D]}|�||��q�|jS)a�Refactors a parse tree (modifying the tree in place).

        For compatible patterns the bottom matcher module is
        used. Otherwise the tree is traversed node-to-node for
        matches.

        Args:
            tree: a pytree.Node instance representing the root of the tree
                  to be refactored.
            name: a human-readable name for this tree.

        Returns:
            True if the tree was modified, False otherwise.
        T)ry�reverserxN)rrkrlZ
start_tree�traverse_byrprqro�runZleaves�anyr+r^r�rZBaseZdepthZkeep_line_orderZ
get_linenor(�remover�
ValueErrorZfixers_applied�match�	transform�replacerr-Zfinish_treer�)
rrr�rr/Z	match_set�node�results�newZnew_matchesZfxrrrrr��sJ



zRefactoringTool.refactor_treecCsV|sdS|D]D}||jD]4}|�|�}|r|�||�}|dk	r|�|�|}qqdS)aTraverse an AST, applying a set of fixers to each node.

        This is a helper method for refactor_tree().

        Args:
            fixers: a list of fixer instances.
            traversal: a generator that yields AST nodes.

        Returns:
            None
        N)rr�r�r�)rrr^Z	traversalr�r/r�r�rrrr��s

zRefactoringTool.traverse_bycCs�|j�|�|dkr.|�|�d}|dkr.dS||k}|�||||�|r`|�d|�|js`dS|rv|�||||�n|�d|�dS)zR
        Called when a file has been refactored and there may be changes.
        NrzNo changes to %szNot writing changes to %s)rmrr�r�r�r[�
write_file)rrr�r�r�r�r�r�rrrr��szRefactoringTool.processed_filecCs�ztj|d|dd�}Wn6tk
rL}z|�d||�WY�dSd}~XYnX|�Fz|�|�Wn0tk
r�}z|�d||�W5d}~XYnXW5QRX|�d|�d|_dS)	z�Writes a string to a file.

        It first shows a unified diff between the old text and the new text, and
        then rewrites the file; the latter is only done if the write option is
        set.
        �wrvr�zCan't create %s: %sNzCan't write %s: %szWrote changes to %sT)rEr�r�r�r�r�ri)rrr�r�r�r��fpr�rrrr��s*zRefactoringTool.write_filez>>> z... c
	Csg}d}d}d}d}|jdd�D]�}|d7}|���|j�r~|dk	rZ|�|�||||��|}|g}|�|j�}	|d|	�}q |dk	r�|�||j�s�|||j��dkr�|�	|�q |dk	r�|�|�||||��d}d}|�	|�q |dk	�r
|�|�||||��d�
|�S)a�Refactors a docstring, looking for doctests.

        This returns a modified version of the input string.  It looks
        for doctests, which start with a ">>>" prompt, and may be
        continued with "..." prompts, as long as the "..." is indented
        the same as the ">>>".

        (Unfortunately we can't use the doctest module's parser,
        since, like most parsers, it is not geared towards preserving
        the original source.)
        NrT��keependsrr�rv)�
splitlines�lstripr�PS1r-�refactor_doctest�find�PS2�rstriprr)
rrr�r��result�blockZblock_lineno�indent�lineno�line�irrrr�sJ����
�z"RefactoringTool.refactor_docstringc

s.z��||��}Wnjtk
r|}zL�j�tj�rN|D]}��d|�d��q6��d|||j	j
|�|WY�Sd}~XYnX��||��r*t|�j
dd�}|d|d�||dd�}	}|	dg|dks�t|	��|d�d�s�|dd7<��j|�d	�g}|�r*|��fd
d�|D�7}|S)z�Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).

        z
Source: %sr�z+Can't parse docstring in %s line %s: %s: %sNTr�rrtrcsg|]}��j|�qSr)r�)r3r��r�rrrrr6Zsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>)�parse_blockr"r]ZisEnabledForrg�DEBUGr�r�r�r�rr�r�r��AssertionError�endswithr��pop)
rrr�r�r�r�r�r�r�r�Zclippedrr�rr�@s.�"z RefactoringTool.refactor_doctestcCs�|jrd}nd}|js$|�d|�n"|�d|�|jD]}|�|�q6|jrl|�d�|jD]}|�|�q\|jr�t|j�dkr�|�d�n|�dt|j��|jD]\}}}|j|f|�|�q�dS)	N�werez
need to bezNo files %s modified.zFiles that %s modified:z$Warnings/messages while refactoring:rzThere was 1 error:zThere were %d errors:)rirmr�rhrfr|)rrr��file�messager�r�r�rrr�	summarize]s$


zRefactoringTool.summarizecCs"|j�|�|||��}t�|_|S)z�Parses a block into a tree.

        This is necessary to get correct line number / offset information
        in the parser diagnostics and embedded into the parse tree.
        )rZparse_tokens�	wrap_toksrHr�)rrr�r�r�r�rrrr�tszRefactoringTool.parse_blockccsdt�|�||�j�}|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqdS)z;Wraps a tokenize stream to systematically modify start/end.rN)rrD�	gen_lines�__next__)rrr�r�r�r,rrUZline0Zcol0Zline1Zcol1Z	line_textrrrr�~s
zRefactoringTool.wrap_toksccsx||j}||j}|}|D]N}|�|�r>|t|�d�Vn(||��dkrVdVntd||f��|}qdVqldS)z�Generates lines as expected by tokenize from a list of lines.

        This strips the first len(indent + self.PS1) characters off each line.
        Nr�zline=%r, prefix=%rrv)r�r�rr|r�r�)rrr�r��prefix1Zprefix2�prefixr�rrrr��s


zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rrrr`r~r{rsrjr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrY�s>�
4(
	


O�

+
rYc@seZdZdS)�MultiprocessingUnsupportedNrrrrrr��sr�csBeZdZ�fdd�Zd�fdd�	Z�fdd�Z�fd	d
�Z�ZS)�MultiprocessRefactoringToolcs"tt|�j||�d|_d|_dSr8)�superr�rs�queue�output_lock�rrr��kwargs�r�rrrs�sz$MultiprocessRefactoringTool.__init__Frc
s�|dkrtt���|||�Szddl�Wntk
r@t�YnX�jdk	rTtd������_��	��_
��fdd�t|�D�}z*|D]}|��q�tt���|||�W5�j��t|�D]}�j�
d�q�|D]}|��r�|��q�d�_XdS)Nrrz already doing multiple processescsg|]}�j�jd��qS))�target)ZProcess�_child)r3r���multiprocessingrrrrr6�s�z8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)r�r�r�r��ImportErrorr�r��RuntimeErrorZ
JoinableQueueZLockr��ranger�putZis_alive�start)rrr�r�r�Z
num_processesZ	processesr�r$r�r�rr��s<
�



�
�

z$MultiprocessRefactoringTool.refactorcsN|j��}|dk	rJ|\}}ztt|�j||�W5|j��X|j��}q
dSr8)r�reZ	task_doner�r�r�)rrZtaskr�r�r�rrr��s

�z"MultiprocessRefactoringTool._childcs2|jdk	r|j�||f�ntt|�j||�SdSr8)r�r�r�r�r�r�r�rrr��s

�z)MultiprocessRefactoringTool.refactor_file)FFr)rrrrsr�r�r��
__classcell__rrr�rr��s�r�)T)#rX�
__author__rEr�rr�rgr�r&�	itertoolsrZpgen2rrrZ
fixer_utilrrvrr	r
rnrr"rrr0r7r:rVrW�objectrYr�r�rrrr�<module>s8
(	PK�[�\�b�hpatcomp.cpython-38.opt-2.pycnu�[���U

e5d��@s�dZddlZddlmZmZmZmZmZmZddl	m
Z
ddl	mZGdd�de�Z
d	d
�ZGdd�de�Zejejejdd
�Zdd�Zdd�Zdd�ZdS)z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�'/usr/lib64/python3.8/lib2to3/patcomp.pyrsrc	csLtjtjtjh}t�t�|�j�}|D] }|\}}}}}||kr&|Vq&dS�N)	r�NEWLINE�INDENT�DEDENTr�generate_tokens�io�StringIO�readline)	�input�skip�tokensZ	quintuple�type�value�start�endZ	line_textrrr�tokenize_wrappersr c@s:eZdZd
dd�Zddd�Zdd�Zdd	d
�Zdd�ZdS)�PatternCompilerNcCsZ|dkrtj|_tj|_nt�|�|_t�|j�|_tj|_	tj
|_tj|jt
d�|_dS)N)Zconvert)r
Zpattern_grammarrZpattern_symbols�symsrZload_grammarZSymbolsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__(s
zPatternCompiler.__init__Fc
Cspt|�}z|jj||d�}Wn2tjk
rN}ztt|��d�W5d}~XYnX|rb|�|�|fS|�|�SdS)N)�debug)r rZparse_tokensrZ
ParseErrorr�str�compile_node)r%rr'Z	with_treer�root�errr�compile_pattern7s zPatternCompiler.compile_patternc
sV|j�jjkr|jd}|j�jjkrz�fdd�|jddd�D�}t|�dkrX|dStjdd�|D�ddd�}|��S|j�jj	krʇfdd�|jD�}t|�dkr�|dStj|gddd�}|��S|j�jj
kr���|jdd��}t�|�}|��Sd}|j}t|�d	k�r>|djt
jk�r>|dj}|dd�}d}t|�dk�rx|d
j�jjk�rx|d
}|dd
�}��||�}|dk	�r>|j}	|	d}
|
jt
jk�r�d}tj}nX|
jt
jk�r�d}tj}n>|
jt
jk�r��|	d�}}t|	�dk�r��|	d	�}n|dk�s"|dk�r>|��}tj|gg||d�}|dk	�rN||_|��S)Nrcsg|]}��|��qSr�r)��.0Zch�r%rr�
<listcomp>Osz0PatternCompiler.compile_node.<locals>.<listcomp>�rcSsg|]
}|g�qSrr)r/�arrrr1Rs��min�maxcsg|]}��|��qSrr-r.r0rrr1Vs�����)rr"ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�get_int�name)
r%�nodeZalts�pZunits�patternrD�nodes�repeatr:Zchildr5r6rr0rr)Cs^

 
"

zPatternCompiler.compile_nodecCs@|d}|jtjkr4tt�|j��}t�t	|�|�S|jtj
kr�|j}|��r�|tkrbt
d|��|dd�rvt
d��t�t|�S|dkr�d}n,|�d�s�t|j|d�}|dkr�t
d|��|dd�r�|�|djd�g}nd}t�||�SnH|jdk�r|�|d�S|jd	k�r<|�|d�}tj|ggddd
�SdS)NrzInvalid token: %rrzCan't have details for token�any�_zInvalid symbol: %r�(�[r4)rr�STRINGr(rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr#r)r:ZNodePatternr<)r%rHrIrErrZcontent�
subpatternrrrr>�s8
zPatternCompiler.compile_basiccCs
t|j�Sr)�intr)r%rErrrrC�szPatternCompiler.get_int)N)FF)N)rr
rr&r,r)r>rCrrrrr!&s


G
#r!)rPrN�NUMBERZTOKENcCs.|d��rtjS|tjkr&tj|SdSdS)Nr)�isalpharrPrZopmap)rrrrrO�s


rOcCs>|\}}}}|s||jkr*tj|||d�Stj|||d�SdS)N)�context)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrrYr:rrrr$�sr$cCst��|�Sr)r!r,)rGrrrr,�sr,)�
__author__rZpgen2rrrrrr�r	r
�	Exceptionrr �objectr!rPrNrWrRrOr$r,rrrr�<module>s  
�		PK�[�\-8e��pygram.cpython-38.pycnu�[���U

e5d�@s�dZddlZddlmZddlmZddlmZej�ej�	e
�d�Zej�ej�	e
�d�ZGd	d
�d
e
�Ze�de�Zee�Ze��Zejd=e��Zejd
=e�de�Zee�ZdS)z&Export the Python grammar and symbols.�N�)�token)�driver)�pytreezGrammar.txtzPatternGrammar.txtc@seZdZdd�ZdS)�SymbolscCs$|j��D]\}}t|||�q
dS)z�Initializer.

        Creates an attribute for each grammar symbol (nonterminal),
        whose value is the symbol's type (an int >= 256).
        N)Z
symbol2number�items�setattr)�selfZgrammar�nameZsymbol�r�&/usr/lib64/python3.8/lib2to3/pygram.py�__init__szSymbols.__init__N)�__name__�
__module__�__qualname__r
rrrrrsrZlib2to3�print�exec)�__doc__�osZpgen2rr�r�path�join�dirname�__file__Z
_GRAMMAR_FILEZ_PATTERN_GRAMMAR_FILE�objectrZload_packaged_grammarZpython_grammarZpython_symbols�copyZ!python_grammar_no_print_statement�keywordsZ*python_grammar_no_print_and_exec_statementZpattern_grammarZpattern_symbolsrrrr�<module>s"�PK�[�\��;�
�
fixer_base.cpython-38.opt-2.pycnu�[���U

e5d"�@sPddlZddlmZddlmZddlmZGdd�de�ZGdd	�d	e�Z	dS)
�N�)�PatternCompiler)�pygram)�does_tree_importc@s�eZdZdZdZdZdZdZe�	d�Z
e�ZdZ
dZdZdZdZdZejZdd�Zdd	�Zd
d�Zdd
�Zdd�Zddd�Zdd�Zddd�Zdd�Zdd�Zdd�Z dS)�BaseFixNrZpostF�cCs||_||_|��dS�N)�options�log�compile_pattern)�selfr	r
�r
�*/usr/lib64/python3.8/lib2to3/fixer_base.py�__init__/szBaseFix.__init__cCs,|jdk	r(t�}|j|jdd�\|_|_dS)NT)Z	with_tree)�PATTERNrr�pattern�pattern_tree)rZPCr
r
rr;s

�zBaseFix.compile_patterncCs
||_dSr)�filename)rrr
r
r�set_filenameFszBaseFix.set_filenamecCsd|i}|j�||�o|S)N�node)r�match�rrZresultsr
r
rrMs	z
BaseFix.matchcCs
t��dSr)�NotImplementedErrorrr
r
r�	transformYszBaseFix.transform�xxx_todo_changemecCs2|}||jkr"|tt|j��}q|j�|�|Sr)�
used_names�str�next�numbers�add)r�template�namer
r
r�new_nameis

zBaseFix.new_namecCs.|jrd|_|j�d|j�|j�|�dS)NFz### In file %s ###)�	first_logr
�appendr)r�messager
r
r�log_messagetszBaseFix.log_messagecCs>|��}|��}d|_d}|�|||f�|r:|�|�dS)N�zLine %d: could not convert: %s)�
get_linenoZclone�prefixr&)rr�reason�linenoZ
for_output�msgr
r
r�cannot_convertzszBaseFix.cannot_convertcCs|��}|�d||f�dS)NzLine %d: %s)r(r&)rrr*r+r
r
r�warning�szBaseFix.warningcCs(|j|_|�|�t�d�|_d|_dS)NrT)rr�	itertools�countrr#�rZtreerr
r
r�
start_tree�s
zBaseFix.start_treecCsdSrr
r1r
r
r�finish_tree�szBaseFix.finish_tree)r)N)!�__name__�
__module__�__qualname__rrrr	rr/r0r�setr�orderZexplicitZ	run_orderZ_accept_typeZkeep_line_orderZ
BM_compatiblerZpython_symbolsZsymsrrrrrr"r&r-r.r2r3r
r
r
rrs2




rcs(eZdZdZ�fdd�Zdd�Z�ZS)�ConditionalFixNcstt|�j|�d|_dSr)�superr9r2�_should_skip)r�args��	__class__r
rr2�szConditionalFix.start_treecCsJ|jdk	r|jS|j�d�}|d}d�|dd��}t|||�|_|jS)N�.���)r;�skip_on�split�joinr)rrZpkgr!r
r
r�should_skip�s
zConditionalFix.should_skip)r4r5r6rAr2rD�
__classcell__r
r
r=rr9�sr9)
r/Zpatcomprr'rZ
fixer_utilr�objectrr9r
r
r
r�<module>sPK�[�\0�F�/�/fixer_util.cpython-38.pycnu�[���U

e5dg;�
@s�dZddlmZddlmZmZddlmZddl	m
Z
dd�Zdd	�Zd
d�Z
dd
�ZdWdd�Zdd�Zdd�Zdd�Ze�e
�fdd�ZdXdd�Zdd�Zdd�ZdYdd �Zd!d"�ZdZd#d$�Zd[d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2d3d4d5d6d7d8d9d:h
Z d;d<�Z!d=a"d>a#d?a$d@a%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)dIdJ�Z*dKdL�Z+dMdN�Z,dOdP�Z-ej.ej/hZ0d\dQdR�Z1ej/ej.ej2hZ3dSdT�Z4d]dUdV�Z5dS)^z1Utility functions, node construction macros, etc.�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�*/usr/lib64/python3.8/lib2to3/fixer_util.py�
KeywordArgs�rcCsttjd�S)N�()rr�LPARrrrr
�LParensrcCsttjd�S)N�))rr�RPARrrrr
�RParensrcCsHt|t�s|g}t|t�s&d|_|g}ttj|ttjddd�g|�S)zBuild an assignment statement� r��prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

�rNcCsttj||d�S)zReturn a NAME leafr)rr�NAME)�namerrrr
�Name$sr cCs|ttjt�|g�gS)zA node tuple for obj.attr)rr�trailer�Dot)�obj�attrrrr
�Attr(sr%cCsttjd�S)zA comma leaf�,)rr�COMMArrrr
�Comma,sr(cCsttjd�S)zA period (.) leaf�.)rr�DOTrrrr
r"0sr"cCs4ttj|��|��g�}|r0|�dttj|��|S)z-A parenthesised argument list, used by Call()r)rrr!�clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr0cCs&ttj|t|�g�}|dk	r"||_|S)zA function callN)rr�powerr0r)Z	func_namer.rr/rrr
�Call;sr2cCsttjd�S)zA newline literal�
�rr�NEWLINErrrr
�NewlineBsr6cCsttjd�S)zA blank line�r4rrrr
�	BlankLineFsr8cCsttj||d�S)Nr)rr�NUMBER)�nrrrr
�NumberJsr;cCs"ttjttjd�|ttjd�g�S)zA numeric or string subscript�[�])rrr!rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMs
�r@cCsttj||d�S)z
A string leafr)rr�STRING)�stringrrrr
�StringSsrCc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rtd|_ttjd�}d|_|�ttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�g�S)zuA list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
    r7r�for�in�ifr<r=)
rrrr�appendrrZcomp_ifZ	listmakerZcomp_forrr>r?)	Zxp�fp�itZtestZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs(

��rKcCsV|D]}|��qttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)zO Return an import statement in the form:
        from package import name_leafs�fromrr�import)�removerrrrr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos


�rSc	Cs�|d��}|jtjkr"|��}nttj|��g�}|d}|rNdd�|D�}ttjtt|d�t|d��ttj|d��||d��g�g|�}|j	|_	|S)	zfReturns an import statement and calls a method
    of the module:

    import module
    module.name()r#�aftercSsg|]}|���qSr)r+)�.0r:rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r+�typerr-rr1r%r r!r)r/�results�namesr#Z
newarglistrT�newrrr
�
ImportAndCall�s*


�����r\cCs�t|t�r |jt�t�gkr dSt|t�o�t|j�dko�t|jdt�o�t|jdt�o�t|jdt�o�|jdjdko�|jdjdkS)z(Does the node represent a tuple literal?T�rWr�rr)rrrQrr�lenrr�r/rrr
�is_tuple�s
������racCsXt|t�oVt|j�dkoVt|jdt�oVt|jdt�oV|jdjdkoV|jdjdkS)z'Does the node represent a list literal?rrW���r<r=)rrr_rQrrr`rrr
�is_list�s
�����rccCsttjt�|t�g�S�N)rrrrrr`rrr
�parenthesize�sre�sortedr�set�any�all�tuple�sum�min�max�	enumerateccs$t||�}|r |Vt||�}q
dS)alFollow an attribute chain.

    If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
    use this to iterate over all objects in the chain. Iteration is
    terminated by getattr(x, attr) is None.

    Args:
        obj: the starting object
        attr: the name of the chaining attribute

    Yields:
        Each successive object in the chain.
    N)�getattr)r#r$�nextrrr
�
attr_chain�s
rqzefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     z�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
z`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
FcCspts&t�t�at�t�at�t�adatttg}t|t|d��D]*\}}i}|�||�r@|d|kr@dSq@dS)a Returns true if node is in an environment where all that is required
        of it is being iterable (ie, it doesn't matter if it returns a list
        or an iterator).
        See test_map_nochange in test_fixers.py for some examples and tests.
        T�parentr/F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprq�match)r/Zpatterns�patternrrrYrrr
�in_special_context�s



rzcCs�|j}|dk	r|jtjkrdS|j}|jtjtjfkr:dS|jtjkrX|j	d|krXdS|jtj
ks�|jtjkr�|dk	r�|jtjks�|j	d|kr�dSdS)zG
    Check that something isn't an attribute or function name etc.
    NFrWT)
Zprev_siblingrXrr*rrr�funcdef�classdef�	expr_stmtrQZ
parametersZ
typedargslistr')r/�prevrrrrr
�is_probably_builtin�s&
��
��rcCsJ|dk	rF|jtjkr>t|j�dkr>|jd}|jtjkr>|jS|j}qdS)zFind the indentation of *node*.Nr^rr7)	rXr�suiter_rQr�INDENTrrr)r/�indentrrr
�find_indentations
r�cCs>|jtjkr|S|��}|jd}|_ttj|g�}||_|Srd)rXrr�r+rrr)r/rrr�rrr
�
make_suitesr�cCs$|jtjkr |j}|std��q|S)zFind the top level namespace.z,root found before file_input node was found.)rXrZ
file_inputrr�
ValueErrorr`rrr
�	find_root&s

r�cCst|t|�|�}t|�S)z� Returns true if name is imported from package at the
        top level of the tree which node belongs to.
        To cover the case of an import like 'import foo', use
        None for the package and 'foo' for the name. )�find_bindingr��bool)�packagerr/Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfkS)z0Returns true if the node is an import statement.)rXr�import_namerPr`rrr
�	is_import7sr�cCs.dd�}t|�}t|||�r dSd}}t|j�D]F\}}||�sDq2t|j|d��D]\}}||�sVqlqV||}qzq2|dkr�t|j�D]8\}}|jtjkr�|jr�|jdjtjkr�|d}q�q�|dkr�t	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|�|t	tj|
��dS)	z\ Works like `does_tree_import` but adds an import statement
        if it was not imported. cSs |jtjko|jot|jd�S)NrW)rXr�simple_stmtrQr�r`rrr
�is_import_stmt>s�z$touch_import.<locals>.is_import_stmtNrWrrMrr)r�r�rnrQrXrr�rrArr�rrrSr6r,)r�rr/r��rootZ
insert_pos�offset�idxZnode2�import_rQrrr
�touch_import;s8�
�
r�cCs�|jD�]�}d}|jtjkrVt||jd�r4|St|t|jd�|�}|rR|}�n0|jtjtjfkr�t|t|jd�|�}|r�|}�n�|jtj	k�rt|t|jd�|�}|r�|}nTt
|jdd��D]@\}}|jtjkr�|j
dkr�t|t|j|d�|�}|r�|}q�nx|jtk�r2|jdj
|k�r2|}nTt|||��rF|}n@|jtjk�rbt|||�}n$|jtjk�r�t||jd��r�|}|r|�s�|St|�r|SqdS)	z� Returns the node which binds variable name, otherwise None.
        If optional argument package is supplied, only imports will
        be returned.
        See test cases for examples.Nrrbr^r]�:�rW)rQrXrZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrnr�COLONr�	_def_syms�_is_import_bindingr�r}r�)rr/r��childZretr:�iZkidrrr
r�isH
r�cCsT|g}|rP|��}|jdkr4|jtkr4|�|j�q|jtjkr|j|kr|SqdS)N�)�poprX�_block_syms�extendrQrrr)rr/Znodesrrr
r��sr�cCs�|jtjkr�|s�|jd}|jtjkrx|jD]H}|jtjkrV|jdj|krt|Sq,|jtjkr,|j|kr,|Sq,nL|jtjkr�|jd}|jtjkr�|j|kr�|Sn|jtjkr�|j|kr�|Sn�|jtj	k�r�|r�t
|jd���|kr�dS|jd}|�rtd|��rdS|jtj
k�r0t||��r0|S|jtjk�rh|jd}|jtjk�r�|j|k�r�|Sn6|jtjk�r�|j|k�r�|S|�r�|jtjk�r�|SdS)z� Will reuturn node if node will import name, or node
        will import * from package.  None is returned otherwise.
        See test cases for examples. rr^rbNr]�as)rXrr�rQZdotted_as_namesZdotted_as_namerrrrP�str�stripr�rOZimport_as_name�STAR)r/rr�rRr�Zlastr:rrr
r��s@





r�)N)NN)N)N)N)N)N)6�__doc__Zpgen2rZpytreerrZpygramrrr7rrrrrr r%r(r"r0r2r6r8r;r@rCrKrSr\rarcreZconsuming_callsrqrtrurvrsrzrr�r�r�r�r�r�r|r{r�r�r!r�r�r�rrrr
�<module>s`




�		-
*
PK�[�\�-M		patcomp.cpython-38.pycnu�[���U

e5d��@s�dZdZddlZddlmZmZmZmZmZm	Z	ddl
mZddl
mZGdd	�d	e
�Zd
d�ZGdd
�d
e�Zejejejdd�Zdd�Zdd�Zdd�ZdS)z�Pattern compiler.

The grammar is taken from PatternGrammar.txt.

The compiler compiles a pattern to a pytree.*Pattern instance.
z#Guido van Rossum <guido@python.org>�N�)�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramc@seZdZdS)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__�rr�'/usr/lib64/python3.8/lib2to3/patcomp.pyrsrc	csLtjtjtjh}t�t�|�j�}|D] }|\}}}}}||kr&|Vq&dS)z6Tokenizes a string suppressing significant whitespace.N)	r�NEWLINE�INDENT�DEDENTr�generate_tokens�io�StringIO�readline)	�input�skip�tokensZ	quintuple�type�value�start�endZ	line_textrrr�tokenize_wrappersrc@s:eZdZd
dd�Zddd�Zdd�Zdd	d
�Zdd�ZdS)�PatternCompilerNcCsZ|dkrtj|_tj|_nt�|�|_t�|j�|_tj|_	tj
|_tj|jt
d�|_dS)z^Initializer.

        Takes an optional alternative filename for the pattern grammar.
        N)Zconvert)r
Zpattern_grammarrZpattern_symbols�symsrZload_grammarZSymbolsZpython_grammarZ	pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filerrr�__init__(s
zPatternCompiler.__init__Fc
Cspt|�}z|jj||d�}Wn2tjk
rN}ztt|��d�W5d}~XYnX|rb|�|�|fS|�|�SdS)z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)rrZparse_tokensrZ
ParseErrorr�str�compile_node)r$rr&Z	with_treer�root�errr�compile_pattern7s zPatternCompiler.compile_patternc
s�|j�jjkr|jd}|j�jjkrz�fdd�|jddd�D�}t|�dkrX|dStjdd�|D�ddd�}|��S|j�jj	krʇfd	d�|jD�}t|�dkr�|dStj|gddd�}|��S|j�jj
kr���|jdd��}t�|�}|��S|j�jj
k�st�d}|j}t|�d
k�rR|djtjk�rR|dj}|dd�}d}t|�dk�r�|dj�jjk�r�|d}|dd�}��||�}|dk	�r�|j�jjk�s�t�|j}	|	d}
|
jtjk�r�d}tj}n�|
jtjk�r�d}tj}np|
jtjk�r^|	djtjk�st�t|	�dk�s.t���|	d�}}t|	�d
k�rh��|	d
�}n
d�sht�|dk�s||dk�r�|��}tj|gg||d�}|dk	�r�||_|��S)zXCompiles a node, recursively.

        This is one big switch on the node type.
        rcsg|]}��|��qSr�r(��.0Zch�r$rr�
<listcomp>Osz0PatternCompiler.compile_node.<locals>.<listcomp>N�rcSsg|]
}|g�qSrr)r.�arrrr0Rs��min�maxcsg|]}��|��qSrr,r-r/rrr0Vs����)r6�r8F)rr!ZMatcher�childrenZAlternatives�lenr	�WildcardPattern�optimizeZAlternativeZNegatedUnit�
compile_basicZNegatedPatternZUnit�AssertionErrorr�EQUALrZRepeater�STARZHUGE�PLUS�LBRACE�RBRACE�get_int�name)
r$�nodeZalts�pZunits�patternrE�nodes�repeatr9Zchildr4r5rr/rr(Csh

 
"


zPatternCompiler.compile_nodecCsnt|�dkst�|d}|jtjkrDtt�|j��}t	�
t|�|�S|jtjk�r|j}|�
�r�|tkrttd|��|dd�r�td��t	�
t|�S|dkr�d}n,|�d�s�t|j|d�}|dkr�td|��|dd�r�|�|djd�g}nd}t	�||�SnV|jdk�r |�|d�S|jd	k�r\|dk�s:t�|�|d�}t	j|ggddd
�Sd�sjt|��dS)NrrzInvalid token: %rzCan't have details for token�any�_zInvalid symbol: %r�(�[r3F)r:r>rr�STRINGr'rZ
evalStringrr	ZLeafPattern�_type_of_literal�NAME�isupper�	TOKEN_MAPr�
startswith�getattrr"r(r9ZNodePatternr;)r$rIrJrFrrZcontent�
subpatternrrrr=�s<
zPatternCompiler.compile_basiccCs|jtjkst�t|j�S�N)rr�NUMBERr>�intr)r$rFrrrrD�szPatternCompiler.get_int)N)FF)N)rr
rr%r+r(r=rDrrrrr &s


G
#r )rQrOrXZTOKENcCs.|d��rtjS|tjkr&tj|SdSdS)Nr)�isalpharrQrZopmap)rrrrrP�s


rPcCs>|\}}}}|s||jkr*tj|||d�Stj|||d�SdS)z9Converts raw node information to a Node or Leaf instance.)�contextN)Z
number2symbolr	ZNodeZLeaf)rZ
raw_node_inforrr[r9rrrr#�sr#cCst��|�SrW)r r+)rHrrrr+�sr+)�__doc__�
__author__rZpgen2rrrrrr�r	r
�	Exceptionrr�objectr rQrOrXrSrPr#r+rrrr�<module>s" 
�		PK�[�\��l\l\pytree.cpython-38.opt-1.pycnu�[���U

e5d8m�@s�dZdZddlZddlmZdZiadd�ZGdd	�d	e�Z	Gd
d�de	�Z
Gdd
�d
e	�Zdd�ZGdd�de�Z
Gdd�de
�ZGdd�de
�ZGdd�de
�ZGdd�de
�Zdd�ZdS)z�
Python parse tree definitions.

This is a very concrete parse tree; we need to keep every token and
even the comments and whitespace between tokens.

There's also a pattern matching implementation here.
z#Guido van Rossum <guido@python.org>�N)�StringIOi���cCsDts8ddlm}|j��D]\}}t|�tkr|t|<qt�||�S)N�)�python_symbols)�_type_reprsZpygramr�__dict__�items�type�int�
setdefault)Ztype_numr�name�val�r
�&/usr/lib64/python3.8/lib2to3/pytree.py�	type_reprs
rc@s�eZdZdZdZdZdZdZdZdd�Z	dd�Z
dZd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zdd�Zdd �Zd!d"�Zejd#kr�d$d%�ZdS)&�Basez�
    Abstract base class for Node and Leaf.

    This provides some default functionality and boilerplate using the
    template pattern.

    A node may be a subnode of at most one parent.
    Nr
FcOs
t�|�S)z7Constructor that prevents Base from being instantiated.��object�__new__��cls�args�kwdsr
r
rr1szBase.__new__cCs|j|jk	rtS|�|�S)zW
        Compare two nodes for equality.

        This calls the method _eq().
        )�	__class__�NotImplemented�_eq��self�otherr
r
r�__eq__6szBase.__eq__cCst�dS)a_
        Compare two nodes for equality.

        This is called by __eq__ and __ne__.  It is only called if the two nodes
        have the same type.  This must be implemented by the concrete subclass.
        Nodes should be considered equal if they have the same structure,
        ignoring the prefix string and other context information.
        N��NotImplementedErrorrr
r
rrBs	zBase._eqcCst�dS)zr
        Return a cloned (deep) copy of self.

        This must be implemented by the concrete subclass.
        Nr�rr
r
r�cloneMsz
Base.clonecCst�dS)zx
        Return a post-order iterator for the tree.

        This must be implemented by the concrete subclass.
        Nrr!r
r
r�
post_orderUszBase.post_ordercCst�dS)zw
        Return a pre-order iterator for the tree.

        This must be implemented by the concrete subclass.
        Nrr!r
r
r�	pre_order]szBase.pre_ordercCs~t|t�s|g}g}d}|jjD].}||krD|dk	r>|�|�d}q |�|�q |j��||j_|D]}|j|_qfd|_dS)z/Replace this node with a new one in the parent.FNT)�
isinstance�list�parent�children�extend�append�changed)r�newZ
l_children�found�ch�xr
r
r�replacees



zBase.replacecCs*|}t|t�s$|jsdS|jd}q|jS)z9Return the line number which generated the invocant node.Nr)r%�Leafr(�lineno�r�noder
r
r�
get_lineno|s
zBase.get_linenocCs|jr|j��d|_dS)NT)r'r+�was_changedr!r
r
rr+�s
zBase.changedcCsJ|jrFt|jj�D]2\}}||kr|j��|jj|=d|_|SqdS)z�
        Remove the node from the tree. Returns the position of the node in its
        parent's children before it was removed.
        N)r'�	enumerater(r+)r�ir4r
r
r�remove�s

zBase.removec	Cs`|jdkrdSt|jj�D]@\}}||krz|jj|dWStk
rXYdSXqdS)z�
        The node immediately following the invocant in their parent's children
        list. If the invocant does not have a next sibling, it is None
        Nr)r'r7r(�
IndexError�rr8�childr
r
r�next_sibling�s
zBase.next_siblingcCsR|jdkrdSt|jj�D]2\}}||kr|dkr8dS|jj|dSqdS)z�
        The node immediately preceding the invocant in their parent's children
        list. If the invocant does not have a previous sibling, it is None.
        Nrr)r'r7r(r;r
r
r�prev_sibling�s
zBase.prev_siblingccs|jD]}|��EdHqdS�N)r(�leaves�rr<r
r
rr@�s
zBase.leavescCs|jdkrdSd|j��S)Nrr)r'�depthr!r
r
rrB�s
z
Base.depthcCs|j}|dkrdS|jS)z�
        Return the string immediately following the invocant node. This is
        effectively equivalent to node.next_sibling.prefix
        N�)r=�prefix)rZnext_sibr
r
r�
get_suffix�szBase.get_suffix��rcCst|��d�S)N�ascii)�str�encoder!r
r
r�__str__�szBase.__str__)�__name__�
__module__�__qualname__�__doc__rr'r(r6Zwas_checkedrr�__hash__rr"r#r$r0r5r+r9�propertyr=r>r@rBrE�sys�version_inforKr
r
r
rrs4

	




rc@s�eZdZdZddd�Zdd�Zdd�Zejd	kr4eZ	d
d�Z
dd
�Zdd�Zdd�Z
edd��Zejdd��Zdd�Zdd�Zdd�ZdS)�Nodez+Concrete implementation for interior nodes.NcCsN||_t|�|_|jD]
}||_q|dk	r0||_|rD|dd�|_nd|_dS)z�
        Initializer.

        Takes a type constant (a symbol number >= 256), a sequence of
        child nodes, and an optional context keyword argument.

        As a side effect, the parent pointers of the children are updated.
        N)rr&r(r'rD�fixers_applied)rrr(�contextrDrUr.r
r
r�__init__�s


z
Node.__init__cCsd|jjt|j�|jfS)�)Return a canonical string representation.z
%s(%s, %r))rrLrrr(r!r
r
r�__repr__�s�z
Node.__repr__cCsd�tt|j��S)�k
        Return a pretty string representation.

        This reproduces the input source exactly.
        rC)�join�maprIr(r!r
r
r�__unicode__�szNode.__unicode__rFcCs|j|jf|j|jfkS�zCompare two nodes for equality.)rr(rr
r
rr�szNode._eqcCst|jdd�|jD�|jd�S)�$Return a cloned (deep) copy of self.cSsg|]}|���qSr
)r")�.0r.r
r
r�
<listcomp>szNode.clone.<locals>.<listcomp>�rU)rTrr(rUr!r
r
rr"s�z
Node.cloneccs$|jD]}|��EdHq|VdS�z*Return a post-order iterator for the tree.N)r(r#rAr
r
rr#s
zNode.post_orderccs$|V|jD]}|��EdHqdS�z)Return a pre-order iterator for the tree.N)r(r$rAr
r
rr$s
zNode.pre_ordercCs|js
dS|jdjS)zO
        The whitespace and comments preceding this node in the input.
        rCr�r(rDr!r
r
rrDszNode.prefixcCs|jr||jd_dS�Nrre�rrDr
r
rrDscCs(||_d|j|_||j|<|��dS)z�
        Equivalent to 'node.children[i] = child'. This method also sets the
        child's parent attribute appropriately.
        N)r'r(r+r;r
r
r�	set_child s
zNode.set_childcCs ||_|j�||�|��dS)z�
        Equivalent to 'node.children.insert(i, child)'. This method also sets
        the child's parent attribute appropriately.
        N)r'r(�insertr+r;r
r
r�insert_child*szNode.insert_childcCs||_|j�|�|��dS)z�
        Equivalent to 'node.children.append(child)'. This method also sets the
        child's parent attribute appropriately.
        N)r'r(r*r+rAr
r
r�append_child3szNode.append_child)NNN)rLrMrNrOrWrYr]rRrSrKrr"r#r$rQrD�setterrhrjrkr
r
r
rrT�s(�




	rTc@s�eZdZdZdZdZdZddgfdd�Zdd�Zd	d
�Z	e
jdkrFe	Zdd
�Z
dd�Zdd�Zdd�Zdd�Zedd��Zejdd��ZdS)r1z'Concrete implementation for leaf nodes.rCrNcCsF|dk	r|\|_\|_|_||_||_|dk	r4||_|dd�|_dS)z�
        Initializer.

        Takes a type constant (a token number < 256), a string value, and an
        optional context keyword argument.
        N)�_prefixr2�columnr�valuerU)rrrorVrDrUr
r
rrWFsz
Leaf.__init__cCsd|jj|j|jfS)rXz
%s(%r, %r))rrLrror!r
r
rrYYs�z
Leaf.__repr__cCs|jt|j�S)rZ)rDrIror!r
r
rr]_szLeaf.__unicode__rFcCs|j|jf|j|jfkSr^)rrorr
r
rrjszLeaf._eqcCs$t|j|j|j|j|jff|jd�S)r_rb)r1rrorDr2rnrUr!r
r
rr"ns
�z
Leaf.cloneccs
|VdSr?r
r!r
r
rr@tszLeaf.leavesccs
|VdSrcr
r!r
r
rr#wszLeaf.post_orderccs
|VdSrdr
r!r
r
rr${szLeaf.pre_ordercCs|jS)zP
        The whitespace and comments preceding this token in the input.
        )rmr!r
r
rrDszLeaf.prefixcCs|��||_dSr?)r+rmrgr
r
rrD�s)rLrMrNrOrmr2rnrWrYr]rRrSrKrr"r@r#r$rQrDrlr
r
r
rr1=s*�


r1cCsN|\}}}}|s||jkr<t|�dkr.|dSt|||d�St|||d�SdS)z�
    Convert raw node information to a Node or Leaf instance.

    This is passed to the parser driver which calls it whenever a reduction of a
    grammar rule produces a new complete node, so that the tree is build
    strictly bottom-up.
    rr)rVN)Z
number2symbol�lenrTr1)ZgrZraw_noderrorVr(r
r
r�convert�srqc@sPeZdZdZdZdZdZdd�Zdd�Zdd�Z	dd	d
�Z
ddd�Zd
d�ZdS)�BasePatterna�
    A pattern is a tree matching pattern.

    It looks for a specific node type (token or symbol), and
    optionally for a specific content.

    This is an abstract base class.  There are three concrete
    subclasses:

    - LeafPattern matches a single leaf node;
    - NodePattern matches a single node (usually non-leaf);
    - WildcardPattern matches a sequence of nodes of variable length.
    NcOs
t�|�S)z>Constructor that prevents BasePattern from being instantiated.rrr
r
rr�szBasePattern.__new__cCsHt|j�|j|jg}|r,|ddkr,|d=qd|jjd�tt|��fS)N���z%s(%s)z, )	rr�contentrrrLr[r\�repr)rrr
r
rrY�szBasePattern.__repr__cCs|S)z�
        A subclass can define this as a hook for optimizations.

        Returns either self or another node with the same effect.
        r
r!r
r
r�optimize�szBasePattern.optimizecCsn|jdk	r|j|jkrdS|jdk	rRd}|dk	r4i}|�||�sDdS|rR|�|�|dk	rj|jrj|||j<dS)a#
        Does this pattern exactly match a node?

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        Default implementation for non-wildcard patterns.
        NFT)rrt�	_submatch�updater)rr4�results�rr
r
r�match�s


zBasePattern.matchcCs t|�dkrdS|�|d|�S)z�
        Does this pattern exactly match a sequence of nodes?

        Default implementation for non-wildcard patterns.
        rFr)rpr{)r�nodesryr
r
r�	match_seq�szBasePattern.match_seqccs&i}|r"|�|d|�r"d|fVdS)z}
        Generator yielding all matches for this pattern.

        Default implementation for non-wildcard patterns.
        rrN)r{)rr|rzr
r
r�generate_matches�szBasePattern.generate_matches)N)N)
rLrMrNrOrrtrrrYrvr{r}r~r
r
r
rrr�s


rrc@s*eZdZddd�Zd	dd�Zd
dd�ZdS)�LeafPatternNcCs&|dk	r|dk	r||_||_||_dS)ap
        Initializer.  Takes optional type, content, and name.

        The type, if given must be a token type (< 256).  If not given,
        this matches any *leaf* node; the content may still be required.

        The content, if given, must be a string.

        If a name is given, the matching node is stored in the results
        dict under that key.
        N)rrtr)rrrtrr
r
rrW�s
zLeafPattern.__init__cCst|t�sdSt�|||�S)z*Override match() to insist on a leaf node.F)r%r1rrr{�rr4ryr
r
rr{
s
zLeafPattern.matchcCs|j|jkS)�
        Match the pattern's content to the node's children.

        This assumes the node type matches and self.content is not None.

        Returns True if it matches, False if not.

        If results is not None, it must be a dict which will be
        updated with the nodes matching named subpatterns.

        When returning False, the results dict may still be updated.
        )rtror�r
r
rrws
zLeafPattern._submatch)NNN)N)N)rLrMrNrWr{rwr
r
r
rr�s

rc@s$eZdZdZddd�Zddd�ZdS)	�NodePatternFNcCsP|dk	r|dk	r:t|�}t|�D]\}}t|t�r d|_q ||_||_||_dS)ad
        Initializer.  Takes optional type, content, and name.

        The type, if given, must be a symbol type (>= 256).  If the
        type is None this matches *any* single node (leaf or not),
        except if content is not None, in which it only matches
        non-leaf nodes that also match the content pattern.

        The content, if not None, must be a sequence of Patterns that
        must match the node's children exactly.  If the content is
        given, the type must not be None.

        If a name is given, the matching node is stored in the results
        dict under that key.
        NT)r&r7r%�WildcardPattern�	wildcardsrrtr)rrrtrr8�itemr
r
rrW$s
zNodePattern.__init__cCs�|jrHt|j|j�D].\}}|t|j�kr|dk	r<|�|�dSqdSt|j�t|j�kr`dSt|j|j�D]\}}|�||�sndSqndS)r�NTF)r�r~rtr(rprx�zipr{)rr4ry�crz�
subpatternr<r
r
rrwAs

zNodePattern._submatch)NNN)N)rLrMrNr�rWrwr
r
r
rr� s
r�c@s^eZdZdZddedfdd�Zdd�Zddd	�Zdd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)r�a
    A wildcard pattern can match zero or more nodes.

    This has all the flexibility needed to implement patterns like:

    .*      .+      .?      .{m,n}
    (a b c | d e | f)
    (...)*  (...)+  (...)?  (...){m,n}

    except it always uses non-greedy matching.
    NrcCs<|dk	r ttt|��}|D]}q||_||_||_||_dS)a�
        Initializer.

        Args:
            content: optional sequence of subsequences of patterns;
                     if absent, matches one node;
                     if present, each subsequence is an alternative [*]
            min: optional minimum number of times to match, default 0
            max: optional maximum number of times to match, default HUGE
            name: optional name assigned to this match

        [*] Thus, if content is [[a, b, c], [d, e], [f, g, h]] this is
            equivalent to (a b c | d e | f g h); if content is None,
            this is equivalent to '.' in regular expression terms.
            The min and max parameters work as follows:
                min=0, max=maxint: .*
                min=1, max=maxint: .+
                min=0, max=1: .?
                min=1, max=1: .
            If content is not None, replace the dot with the parenthesized
            list of alternatives, e.g. (a b c | d e | f g h)*
        N)�tupler\rt�min�maxr)rrtr�r�r�altr
r
rrWkszWildcardPattern.__init__cCs�d}|jdk	r<t|j�dkr<t|jd�dkr<|jdd}|jdkr�|jdkr�|jdkrft|jd�S|dk	r�|j|jkr�|��S|jdkr�t|t�r�|jdkr�|j|jkr�t|j|j|j|j|j|j�S|S)z+Optimize certain stacked wildcard patterns.Nrr)r)	rtrpr�r�r�rrvr%r�)rr�r
r
rrv�s.
��
�
�

�zWildcardPattern.optimizecCs|�|g|�S)z'Does this pattern exactly match a node?)r}r�r
r
rr{�szWildcardPattern.matchcCsP|�|�D]@\}}|t|�kr
|dk	rD|�|�|jrDt|�||j<dSq
dS)z4Does this pattern exactly match a sequence of nodes?NTF)r~rprxrr&)rr|ryr�rzr
r
rr}�s
zWildcardPattern.match_seqc	cs,|jdkrTt|jdtt|�|j��D]*}i}|jrF|d|�||j<||fVq&n�|jdkrl|�|�Vn�ttd�r�tj	}t
�t_	z�z<|�|d�D]*\}}|jr�|d|�||j<||fVq�WnLtk
�r|�
|�D]*\}}|jr�|d|�||j<||fVq�YnXW5ttd��r&|t_	XdS)a"
        Generator yielding matches for a sequence of nodes.

        Args:
            nodes: sequence of nodes

        Yields:
            (count, results) tuples where:
            count: the match comprises nodes[:count];
            results: dict containing named submatches.
        NrZ	bare_name�getrefcountr)rt�ranger�rpr�r�_bare_name_matches�hasattrrR�stderrr�_recursive_matches�RuntimeError�_iterative_matches)rr|�countrzZsave_stderrr
r
rr~�s.
 

z WildcardPattern.generate_matchesccs�t|�}d|jkrdifVg}|jD]0}t||�D] \}}||fV|�||f�q4q&|r�g}|D]�\}}	||krd||jkrd|jD]`}t|||d��D]H\}
}|
dkr�i}|�|	�|�|�||
|fV|�||
|f�q�q�qd|}qXdS)z(Helper to iteratively yield the matches.rN)rpr�rtr~r*r�rx)rr|Znodelenryr�r�rzZnew_results�c0�r0�c1�r1r
r
rr��s*






z"WildcardPattern._iterative_matchescCspd}i}d}t|�}|sV||krVd}|jD](}|d�|||�r*|d7}d}qq*q|d|�||j<||fS)z(Special optimized matcher for bare_name.rFTrN)rprtr{r)rr|r�rzZdoner�Zleafr
r
rr��s
z"WildcardPattern._bare_name_matchesc	cs�||jkrdifV||jkr�|jD]`}t||�D]P\}}|�||d�|d�D].\}}i}|�|�|�|�|||fVqRq2q$dS)z(Helper to recursively yield the matches.rNr)r�r�rtr~r�rx)	rr|r�r�r�r�r�r�rzr
r
rr�
s



 

z"WildcardPattern._recursive_matches)N)N)
rLrMrNrO�HUGErWrvr{r}r~r�r�r�r
r
r
rr�]s#

-r�c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�NegatedPatternNcCs|dk	r||_dS)a
        Initializer.

        The argument is either a pattern or None.  If it is None, this
        only matches an empty sequence (effectively '$' in regex
        lingo).  If it is not None, this matches whenever the argument
        pattern doesn't have any matches.
        N)rt)rrtr
r
rrWs	zNegatedPattern.__init__cCsdS)NFr
r3r
r
rr{(szNegatedPattern.matchcCst|�dkSrf)rp)rr|r
r
rr},szNegatedPattern.match_seqccsJ|jdkr"t|�dkrFdifVn$|j�|�D]\}}dSdifVdSrf)rtrpr~)rr|r�rzr
r
rr~0s
zNegatedPattern.generate_matches)N)rLrMrNrWr{r}r~r
r
r
rr�s

r�c	cs�|sdifVn||d|dd�}}|�|�D]Z\}}|sH||fVq0t|||d��D].\}}i}|�|�|�|�|||fVqZq0dS)aR
    Generator yielding matches for a sequence of patterns and nodes.

    Args:
        patterns: a sequence of patterns
        nodes: a sequence of nodes

    Yields:
        (count, results) tuples where:
        count: the entire sequence of patterns matches nodes[:count];
        results: dict containing named submatches.
        rrN)r~rx)	Zpatternsr|�p�restr�r�r�r�rzr
r
rr~<s


r~)rO�
__author__rR�iorr�rrrrrTr1rqrrrr�r�r�r~r
r
r
r�<module>s$	
1nNV,==#PK�[�\R=o�oofixer_base.cpython-38.pycnu�[���U

e5d"�@sTdZddlZddlmZddlmZddlmZGdd�de�Z	Gd	d
�d
e	�Z
dS)z2Base class for fixers (optional, but recommended).�N�)�PatternCompiler)�pygram)�does_tree_importc@s�eZdZdZdZdZdZdZdZe	�
d�Ze�Z
dZdZdZdZdZdZejZdd�Zd	d
�Zdd�Zd
d�Zdd�Zddd�Zdd�Zddd�Zdd�Zdd�Z dd�Z!dS) �BaseFixaOptional base class for fixers.

    The subclass name must be FixFooBar where FooBar is the result of
    removing underscores and capitalizing the words of the fix name.
    For example, the class name for a fixer named 'has_key' should be
    FixHasKey.
    NrZpostF�cCs||_||_|��dS)aInitializer.  Subclass may override.

        Args:
            options: a dict containing the options passed to RefactoringTool
            that could be used to customize the fixer through the command line.
            log: a list to append warnings and other messages to.
        N)�options�log�compile_pattern)�selfrr	�r�*/usr/lib64/python3.8/lib2to3/fixer_base.py�__init__/szBaseFix.__init__cCs,|jdk	r(t�}|j|jdd�\|_|_dS)z�Compiles self.PATTERN into self.pattern.

        Subclass may override if it doesn't want to use
        self.{pattern,PATTERN} in .match().
        NT)Z	with_tree)�PATTERNrr
�pattern�pattern_tree)rZPCrrr
r
;s

�zBaseFix.compile_patterncCs
||_dS)zOSet the filename.

        The main refactoring tool should call this.
        N)�filename)rrrrr
�set_filenameFszBaseFix.set_filenamecCsd|i}|j�||�o|S)aReturns match for a given parse tree node.

        Should return a true or false object (not necessarily a bool).
        It may return a non-empty dict of matching sub-nodes as
        returned by a matching pattern.

        Subclass may override.
        �node)r�match�rrZresultsrrr
rMs	z
BaseFix.matchcCs
t��dS)a�Returns the transformation for a given parse tree node.

        Args:
          node: the root of the parse tree that matched the fixer.
          results: a dict mapping symbolic names to part of the match.

        Returns:
          None, or a node that is a modified copy of the
          argument node.  The node argument may also be modified in-place to
          effect the same change.

        Subclass *must* override.
        N)�NotImplementedErrorrrrr
�	transformYszBaseFix.transform�xxx_todo_changemecCs2|}||jkr"|tt|j��}q|j�|�|S)z�Return a string suitable for use as an identifier

        The new name is guaranteed not to conflict with other identifiers.
        )�
used_names�str�next�numbers�add)r�template�namerrr
�new_nameis

zBaseFix.new_namecCs.|jrd|_|j�d|j�|j�|�dS)NFz### In file %s ###)�	first_logr	�appendr)r�messagerrr
�log_messagetszBaseFix.log_messagecCs>|��}|��}d|_d}|�|||f�|r:|�|�dS)aWarn the user that a given chunk of code is not valid Python 3,
        but that it cannot be converted automatically.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        �zLine %d: could not convert: %sN)�
get_linenoZclone�prefixr%)rr�reason�linenoZ
for_output�msgrrr
�cannot_convertzszBaseFix.cannot_convertcCs|��}|�d||f�dS)z�Used for warning the user about possible uncertainty in the
        translation.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        zLine %d: %sN)r'r%)rrr)r*rrr
�warning�szBaseFix.warningcCs(|j|_|�|�t�d�|_d|_dS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the start of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        rTN)rr�	itertools�countrr"�rZtreerrrr
�
start_tree�s
zBaseFix.start_treecCsdS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the conclusion of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        Nrr0rrr
�finish_tree�szBaseFix.finish_tree)r)N)"�__name__�
__module__�__qualname__�__doc__rrrrrr.r/r�setr�orderZexplicitZ	run_orderZ_accept_typeZkeep_line_orderZ
BM_compatiblerZpython_symbolsZsymsrr
rrrr!r%r,r-r1r2rrrr
rs4



rcs,eZdZdZdZ�fdd�Zdd�Z�ZS)�ConditionalFixz@ Base class for fixers which not execute if an import is found. Ncstt|�j|�d|_dS)N)�superr9r1�_should_skip)r�args��	__class__rr
r1�szConditionalFix.start_treecCsJ|jdk	r|jS|j�d�}|d}d�|dd��}t|||�|_|jS)N�.���)r;�skip_on�split�joinr)rrZpkgr rrr
�should_skip�s
zConditionalFix.should_skip)r3r4r5r6rAr1rD�
__classcell__rrr=r
r9�sr9)r6r.Zpatcomprr&rZ
fixer_utilr�objectrr9rrrr
�<module>sPK�[�\R=o�oofixer_base.cpython-38.opt-1.pycnu�[���U

e5d"�@sTdZddlZddlmZddlmZddlmZGdd�de�Z	Gd	d
�d
e	�Z
dS)z2Base class for fixers (optional, but recommended).�N�)�PatternCompiler)�pygram)�does_tree_importc@s�eZdZdZdZdZdZdZdZe	�
d�Ze�Z
dZdZdZdZdZdZejZdd�Zd	d
�Zdd�Zd
d�Zdd�Zddd�Zdd�Zddd�Zdd�Zdd�Z dd�Z!dS) �BaseFixaOptional base class for fixers.

    The subclass name must be FixFooBar where FooBar is the result of
    removing underscores and capitalizing the words of the fix name.
    For example, the class name for a fixer named 'has_key' should be
    FixHasKey.
    NrZpostF�cCs||_||_|��dS)aInitializer.  Subclass may override.

        Args:
            options: a dict containing the options passed to RefactoringTool
            that could be used to customize the fixer through the command line.
            log: a list to append warnings and other messages to.
        N)�options�log�compile_pattern)�selfrr	�r�*/usr/lib64/python3.8/lib2to3/fixer_base.py�__init__/szBaseFix.__init__cCs,|jdk	r(t�}|j|jdd�\|_|_dS)z�Compiles self.PATTERN into self.pattern.

        Subclass may override if it doesn't want to use
        self.{pattern,PATTERN} in .match().
        NT)Z	with_tree)�PATTERNrr
�pattern�pattern_tree)rZPCrrr
r
;s

�zBaseFix.compile_patterncCs
||_dS)zOSet the filename.

        The main refactoring tool should call this.
        N)�filename)rrrrr
�set_filenameFszBaseFix.set_filenamecCsd|i}|j�||�o|S)aReturns match for a given parse tree node.

        Should return a true or false object (not necessarily a bool).
        It may return a non-empty dict of matching sub-nodes as
        returned by a matching pattern.

        Subclass may override.
        �node)r�match�rrZresultsrrr
rMs	z
BaseFix.matchcCs
t��dS)a�Returns the transformation for a given parse tree node.

        Args:
          node: the root of the parse tree that matched the fixer.
          results: a dict mapping symbolic names to part of the match.

        Returns:
          None, or a node that is a modified copy of the
          argument node.  The node argument may also be modified in-place to
          effect the same change.

        Subclass *must* override.
        N)�NotImplementedErrorrrrr
�	transformYszBaseFix.transform�xxx_todo_changemecCs2|}||jkr"|tt|j��}q|j�|�|S)z�Return a string suitable for use as an identifier

        The new name is guaranteed not to conflict with other identifiers.
        )�
used_names�str�next�numbers�add)r�template�namerrr
�new_nameis

zBaseFix.new_namecCs.|jrd|_|j�d|j�|j�|�dS)NFz### In file %s ###)�	first_logr	�appendr)r�messagerrr
�log_messagetszBaseFix.log_messagecCs>|��}|��}d|_d}|�|||f�|r:|�|�dS)aWarn the user that a given chunk of code is not valid Python 3,
        but that it cannot be converted automatically.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        �zLine %d: could not convert: %sN)�
get_linenoZclone�prefixr%)rr�reason�linenoZ
for_output�msgrrr
�cannot_convertzszBaseFix.cannot_convertcCs|��}|�d||f�dS)z�Used for warning the user about possible uncertainty in the
        translation.

        First argument is the top-level node for the code in question.
        Optional second argument is why it can't be converted.
        zLine %d: %sN)r'r%)rrr)r*rrr
�warning�szBaseFix.warningcCs(|j|_|�|�t�d�|_d|_dS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the start of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        rTN)rr�	itertools�countrr"�rZtreerrrr
�
start_tree�s
zBaseFix.start_treecCsdS)z�Some fixers need to maintain tree-wide state.
        This method is called once, at the conclusion of tree fix-up.

        tree - the root node of the tree to be processed.
        filename - the name of the file the tree came from.
        Nrr0rrr
�finish_tree�szBaseFix.finish_tree)r)N)"�__name__�
__module__�__qualname__�__doc__rrrrrr.r/r�setr�orderZexplicitZ	run_orderZ_accept_typeZkeep_line_orderZ
BM_compatiblerZpython_symbolsZsymsrr
rrrr!r%r,r-r1r2rrrr
rs4



rcs,eZdZdZdZ�fdd�Zdd�Z�ZS)�ConditionalFixz@ Base class for fixers which not execute if an import is found. Ncstt|�j|�d|_dS)N)�superr9r1�_should_skip)r�args��	__class__rr
r1�szConditionalFix.start_treecCsJ|jdk	r|jS|j�d�}|d}d�|dd��}t|||�|_|jS)N�.���)r;�skip_on�split�joinr)rrZpkgr rrr
�should_skip�s
zConditionalFix.should_skip)r3r4r5r6rAr1rD�
__classcell__rrr=r
r9�sr9)r6r.Zpatcomprr&rZ
fixer_utilr�objectrr9rrrr
�<module>sPK��\ɂ�jjtool.cpython-38.opt-1.pycnu�[���U

e5d��
@sjdZddlZddlZddlZdd�Zedkrfz
e�Wn.ek
rdZze�ej	�W5dZ[XYnXdS)aCommand-line tool to validate and pretty-print JSON

Usage::

    $ echo '{"json":"obj"}' | python -m json.tool
    {
        "json": "obj"
    }
    $ echo '{ 1.2:3.4}' | python -m json.tool
    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

�NcCs4d}d}tj||d�}|jddtjdd�dtjd	�|jd
dtjddd�dtjd	�|jd
dddd�|jddddd�|��}|j}|j	}|j
}|j}|��|�~zJ|r�dd�|D�}nt�
|�f}|D] }	tj|	||dd�|�d�q�Wn,tk
�r}
zt|
��W5d}
~
XYnXW5QRXW5QRXdS)Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)�prog�description�infile�?zutf-8)�encodingz-a JSON file to be validated or pretty-printed)�nargs�type�help�default�outfile�wz%write the output of infile to outfilez--sort-keys�
store_trueFz5sort the output of dictionaries alphabetically by key)�actionr
r	z--json-linesz&parse input using the jsonlines formatcss|]}t�|�VqdS)N)�json�loads)�.0�line�r�!/usr/lib64/python3.8/json/tool.py�	<genexpr>,szmain.<locals>.<genexpr>�)�	sort_keys�indent�
)�argparse�ArgumentParser�add_argumentZFileType�sys�stdin�stdout�
parse_argsrrr�
json_linesr�load�dump�write�
ValueError�
SystemExit)rr�parserZoptionsrrrr!Zobjs�obj�errr�mainsD
��
�
�r*�__main__)
�__doc__rrrr*�__name__�BrokenPipeError�exc�exit�errnorrrr�<module>s$
PK��\�]Ɗ��scanner.cpython-38.opt-1.pycnu�[���U

e5dy	�@sjdZddlZzddlmZWnek
r4dZYnXdgZe�dejej	Bej
B�Zdd�ZepdeZdS)zJSON token scanner
�N)�make_scannerrz)(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?csv|j�	|j�|j�
tj�|j�|j�|j�|j�|j	�|j
�|j�����������	�
�fdd����fdd�}|S)Ncs�z||}Wntk
r*t|�d�YnX|dkrD�
||d��S|dkrf�	||df������S|dkr��||df��S|dkr�|||d�dkr�d|dfS|dkr�|||d�d	kr�d
|dfS|dk�r�|||d�d
k�r�d|dfS�||�}|dk	�r\|��\}}}|�s*|�rH�||�p6d|�p@d�}n�|�}||��fS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r�d�|dfSt|��dS)N�"��{�[�n�Znull�t�trueT�f�ZfalseF��N�ZNaN�I�ZInfinity�-�	z	-Infinity)�
IndexError�
StopIteration�groups�end)�string�idxZnextchar�mZintegerZfracZexp�res��
_scan_onceZmatch_number�memo�object_hook�object_pairs_hook�parse_array�parse_constant�parse_float�	parse_int�parse_object�parse_string�strict��$/usr/lib64/python3.8/json/scanner.pyrsF� 

   z#py_make_scanner.<locals>._scan_oncecsz�||�W�S���XdS)N)�clear)rr)rrr(r)�	scan_onceAsz"py_make_scanner.<locals>.scan_once)r%r!r&�	NUMBER_RE�matchr'r#r$r"rr r)�contextr+r(rr)�py_make_scanners"%r/)
�__doc__�reZ_jsonrZc_make_scanner�ImportError�__all__�compile�VERBOSE�	MULTILINE�DOTALLr,r/r(r(r(r)�<module>s
�:PK��\#ӽx}}scanner.cpython-38.opt-2.pycnu�[���U

e5dy	�@sfddlZzddlmZWnek
r0dZYnXdgZe�dejejBej	B�Z
dd�Zep`eZdS)�N)�make_scannerrz)(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?csv|j�	|j�|j�
tj�|j�|j�|j�|j�|j	�|j
�|j�����������	�
�fdd����fdd�}|S)Ncs�z||}Wntk
r*t|�d�YnX|dkrD�
||d��S|dkrf�	||df������S|dkr��||df��S|dkr�|||d�dkr�d|dfS|dkr�|||d�d	kr�d
|dfS|dk�r�|||d�d
k�r�d|dfS�||�}|dk	�r\|��\}}}|�s*|�rH�||�p6d|�p@d�}n�|�}||��fS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r�d�|dfSt|��dS)N�"��{�[�n�Znull�t�trueT�f�ZfalseF��N�ZNaN�I�ZInfinity�-�	z	-Infinity)�
IndexError�
StopIteration�groups�end)�string�idxZnextchar�mZintegerZfracZexp�res��
_scan_onceZmatch_number�memo�object_hook�object_pairs_hook�parse_array�parse_constant�parse_float�	parse_int�parse_object�parse_string�strict��$/usr/lib64/python3.8/json/scanner.pyrsF� 

   z#py_make_scanner.<locals>._scan_oncecsz�||�W�S���XdS)N)�clear)rr)rrr(r)�	scan_onceAsz"py_make_scanner.<locals>.scan_once)r%r!r&�	NUMBER_RE�matchr'r#r$r"rr r)�contextr+r(rr)�py_make_scanners"%r/)�reZ_jsonrZc_make_scanner�ImportError�__all__�compile�VERBOSE�	MULTILINE�DOTALLr,r/r(r(r(r)�<module>s
�:PK��\�E��decoder.cpython-38.opt-2.pycnu�[���U

e5d�0�	@sddlZddlmZzddlmZWnek
r<dZYnXddgZejej	Bej
BZed�Z
ed�Zed�ZGd	d�de�Zeee
d
�Ze�de�Zdd
ddddddd�Zdd�Zdeejfdd�Zep�eZe�de�ZdZdejefdd�Zejefdd�ZGd d�de�ZdS)!�N)�scanner)�
scanstring�JSONDecoder�JSONDecodeError�nan�infz-infc@seZdZdd�Zdd�ZdS)rcCsb|�dd|�d}||�dd|�}d||||f}t�||�||_||_||_||_||_dS)N�
r�z%s: line %d column %d (char %d))	�count�rfind�
ValueError�__init__�msg�doc�pos�lineno�colno)�selfrrrrr�errmsg�r�$/usr/lib64/python3.8/json/decoder.pyr
szJSONDecodeError.__init__cCs|j|j|j|jffS�N)�	__class__rrr)rrrr�
__reduce__*szJSONDecodeError.__reduce__N)�__name__�
__module__�__qualname__r
rrrrrrs)z	-InfinityZInfinity�NaNz(.*?)(["\\\x00-\x1f])�"�\�/��r�
�	)rrr �b�f�n�r�tcCsb||d|d�}t|�dkrN|ddkrNzt|d�WStk
rLYnXd}t|||��dS)Nr	��ZxX�zInvalid \uXXXX escape)�len�intrr)�sr�escrrrr�
_decode_uXXXX;sr1TcCs�g}|j}|d}|||�}|dkr0td||��|��}|��\}	}
|	rP||	�|
dkr^�q�n.|
dkr�|r�d�|
�}t|||��n
||
�qz||}Wn"tk
r�td||�d�YnX|dk�rz||}
Wn*tk
r�d�|�}t|||��YnX|d7}n�t||�}|d7}d	|k�r2d
k�r�nn`|||d�dk�r�t||d�}d
|k�rrdk�r�nn d|d	d>|d
B}|d7}t|�}
||
�qd�	|�|fS)Nr	zUnterminated string starting atrrz"Invalid control character {0!r} at�uzInvalid \escape: {0!r}r*i�i���z\ui�i��i�
��)
�appendr�end�groups�format�
IndexError�KeyErrorr1�chr�join)r/r8�strictZ_b�_mZchunks�_appendZbegin�chunkZcontent�
terminatorrr0�charZuniZuni2rrr�
py_scanstringEsX


��



2
rEz
[ \t\n\r]*z 	

c
Cs�|\}}	g}
|
j}|dkri}|j}||	|	d�}
|
dkr�|
|krb|||	���}	||	|	d�}
|
dkr�|dk	r�||
�}||	dfSi}
|dk	r�||
�}
|
|	dfS|
dkr�td||	��|	d7}	t||	|�\}}	|||�}||	|	d�dk�r"|||	���}	||	|	d�dk�r"td||	��|	d7}	z:||	|k�rb|	d7}	||	|k�rb|||	d���}	Wntk
�rzYnXz|||	�\}}	Wn4tk
�r�}ztd||j�d�W5d}~XYnX|||f�z0||	}
|
|k�r�|||	d���}	||	}
Wntk
�rd}
YnX|	d7}	|
dk�r4�q�n|
d	k�rNtd
||	d��|||	���}	||	|	d�}
|	d7}	|
dkr�td||	d��q�|dk	�r�||
�}||	fSt|
�}
|dk	�r�||
�}
|
|	fS)Nr	r�}z1Expecting property name enclosed in double quotes�:zExpecting ':' delimiter�Expecting valuer6�,�Expecting ',' delimiter)	r7�
setdefaultr8rrr;�
StopIteration�value�dict)�	s_and_endr?�	scan_once�object_hook�object_pairs_hook�memo�_w�_wsr/r8ZpairsZpairs_appendZmemo_get�nextchar�result�keyrM�errrrr�
JSONObject�s��
"



�

rZc
Cst|\}}g}|||d�}||krF|||d���}|||d�}|dkrZ||dfS|j}z|||�\}	}Wn2tk
r�}
ztd||
j�d�W5d}
~
XYnX||	�|||d�}||kr�|||d���}|||d�}|d7}|dkr��qln|dk�rtd||d��z:|||k�rP|d7}|||k�rP|||d���}Wq`tk
�rhYq`Xq`||fS)Nr	�]rHrIrJ)r8r7rLrrMr;)rOrPrTrUr/r8�valuesrVrArMrYrrr�	JSONArray�s>"
r]c@s<eZdZddddddd�dd�Zejfdd�Zdd	d
�ZdS)rNT)rQ�parse_float�	parse_int�parse_constantr?rRcCsZ||_|pt|_|pt|_|p"tj|_||_||_	t
|_t|_
t|_i|_t�|�|_dSr)rQ�floatr^r.r_�
_CONSTANTS�__getitem__r`r?rRrZZparse_objectr]Zparse_arrayrZparse_stringrSrZmake_scannerrP)rrQr^r_r`r?rRrrrr
s#

zJSONDecoder.__init__cCsF|j|||d���d�\}}|||���}|t|�krBtd||��|S)Nr)�idxz
Extra data)�
raw_decoder8r-r)rr/rT�objr8rrr�decodeLs
zJSONDecoder.decoderc
CsPz|�||�\}}Wn2tk
rF}ztd||j�d�W5d}~XYnX||fS)NrH)rPrLrrM)rr/rdrfr8rYrrrreWs
	"zJSONDecoder.raw_decode)r)rrrr
�
WHITESPACE�matchrgrerrrrr�s�0)�reZjsonrZ_jsonrZc_scanstring�ImportError�__all__�VERBOSE�	MULTILINE�DOTALL�FLAGSrarZPosInfZNegInfrrrb�compileZSTRINGCHUNKZ	BACKSLASHr1rirErhZWHITESPACE_STRrZr]�objectrrrrr�<module>sN
��
�
=�
Q%PK��\ɂ�jjtool.cpython-38.pycnu�[���U

e5d��
@sjdZddlZddlZddlZdd�Zedkrfz
e�Wn.ek
rdZze�ej	�W5dZ[XYnXdS)aCommand-line tool to validate and pretty-print JSON

Usage::

    $ echo '{"json":"obj"}' | python -m json.tool
    {
        "json": "obj"
    }
    $ echo '{ 1.2:3.4}' | python -m json.tool
    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

�NcCs4d}d}tj||d�}|jddtjdd�dtjd	�|jd
dtjddd�dtjd	�|jd
dddd�|jddddd�|��}|j}|j	}|j
}|j}|��|�~zJ|r�dd�|D�}nt�
|�f}|D] }	tj|	||dd�|�d�q�Wn,tk
�r}
zt|
��W5d}
~
XYnXW5QRXW5QRXdS)Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)�prog�description�infile�?zutf-8)�encodingz-a JSON file to be validated or pretty-printed)�nargs�type�help�default�outfile�wz%write the output of infile to outfilez--sort-keys�
store_trueFz5sort the output of dictionaries alphabetically by key)�actionr
r	z--json-linesz&parse input using the jsonlines formatcss|]}t�|�VqdS)N)�json�loads)�.0�line�r�!/usr/lib64/python3.8/json/tool.py�	<genexpr>,szmain.<locals>.<genexpr>�)�	sort_keys�indent�
)�argparse�ArgumentParser�add_argumentZFileType�sys�stdin�stdout�
parse_argsrrr�
json_linesr�load�dump�write�
ValueError�
SystemExit)rr�parserZoptionsrrrr!Zobjs�obj�errr�mainsD
��
�
�r*�__main__)
�__doc__rrrr*�__name__�BrokenPipeError�exc�exit�errnorrrr�<module>s$
PK��\(�#�EEtool.cpython-38.opt-2.pycnu�[���U

e5d��
@sfddlZddlZddlZdd�Zedkrbz
e�Wn.ek
r`Zze�ej�W5dZ[XYnXdS)�NcCs4d}d}tj||d�}|jddtjdd�dtjd	�|jd
dtjddd�dtjd	�|jd
dddd�|jddddd�|��}|j}|j	}|j
}|j}|��|�~zJ|r�dd�|D�}nt�
|�f}|D] }	tj|	||dd�|�d�q�Wn,tk
�r}
zt|
��W5d}
~
XYnXW5QRXW5QRXdS)Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)�prog�description�infile�?zutf-8)�encodingz-a JSON file to be validated or pretty-printed)�nargs�type�help�default�outfile�wz%write the output of infile to outfilez--sort-keys�
store_trueFz5sort the output of dictionaries alphabetically by key)�actionr
r	z--json-linesz&parse input using the jsonlines formatcss|]}t�|�VqdS)N)�json�loads)�.0�line�r�!/usr/lib64/python3.8/json/tool.py�	<genexpr>,szmain.<locals>.<genexpr>�)�	sort_keys�indent�
)�argparse�ArgumentParser�add_argumentZFileType�sys�stdin�stdout�
parse_argsrrr�
json_linesr�load�dump�write�
ValueError�
SystemExit)rr�parserZoptionsrrrr!Zobjs�obj�errr�mainsD
��
�
�r*�__main__)	rrrr*�__name__�BrokenPipeError�exc�exit�errnorrrr�<module>
s$
PK��\e4�"v&v&decoder.cpython-38.pycnu�[���U

e5d�0�	@sdZddlZddlmZzddlmZWnek
r@dZYnXddgZej	ej
BejBZe
d�Ze
d�Ze
d	�ZGd
d�de�Zeeed�Ze�de�Zd
dddddddd�Zdd�Zdeejfdd�Zep�eZe�de�ZdZdejefdd�Zejefdd �ZGd!d�de�ZdS)"zImplementation of JSONDecoder
�N)�scanner)�
scanstring�JSONDecoder�JSONDecodeError�nan�infz-infc@s eZdZdZdd�Zdd�ZdS)ra Subclass of ValueError with the following additional properties:

    msg: The unformatted error message
    doc: The JSON document being parsed
    pos: The start index of doc where parsing failed
    lineno: The line corresponding to pos
    colno: The column corresponding to pos

    cCsb|�dd|�d}||�dd|�}d||||f}t�||�||_||_||_||_||_dS)N�
r�z%s: line %d column %d (char %d))	�count�rfind�
ValueError�__init__�msg�doc�pos�lineno�colno)�selfrrrrr�errmsg�r�$/usr/lib64/python3.8/json/decoder.pyr
szJSONDecodeError.__init__cCs|j|j|j|jffS)N)�	__class__rrr)rrrr�
__reduce__*szJSONDecodeError.__reduce__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrs
)z	-InfinityZInfinity�NaNz(.*?)(["\\\x00-\x1f])�"�\�/��r�
�	)rrr �b�f�n�r�tcCsb||d|d�}t|�dkrN|ddkrNzt|d�WStk
rLYnXd}t|||��dS)Nr	��ZxX�zInvalid \uXXXX escape)�len�intrr)�sr�escrrrr�
_decode_uXXXX;sr1TcCs�g}|j}|d}|||�}|dkr0td||��|��}|��\}	}
|	rP||	�|
dkr^�q�n.|
dkr�|r�d�|
�}t|||��n
||
�qz||}Wn"tk
r�td||�d�YnX|dk�rz||}
Wn*tk
r�d�|�}t|||��YnX|d7}n�t||�}|d	7}d
|k�r2dk�r�nn`|||d�d
k�r�t||d�}d|k�rrdk�r�nn d|d
d>|dB}|d7}t|�}
||
�qd�	|�|fS)a�Scan the string s for a JSON string. End is the index of the
    character in s after the quote that started the JSON string.
    Unescapes all valid JSON string escape sequences and raises ValueError
    on attempt to decode an invalid string. If strict is False then literal
    control characters are allowed in the string.

    Returns a tuple of the decoded string and the index of the character in s
    after the end quote.r	NzUnterminated string starting atrrz"Invalid control character {0!r} at�uzInvalid \escape: {0!r}r*i�i���z\ui�i��i�
��)
�appendr�end�groups�format�
IndexError�KeyErrorr1�chr�join)r/r8�strictZ_b�_mZchunks�_appendZbegin�chunkZcontent�
terminatorrr0�charZuniZuni2rrr�
py_scanstringEsX


��



2
rEz
[ \t\n\r]*z 	

c
Cs�|\}}	g}
|
j}|dkri}|j}||	|	d�}
|
dkr�|
|krb|||	���}	||	|	d�}
|
dkr�|dk	r�||
�}||	dfSi}
|dk	r�||
�}
|
|	dfS|
dkr�td||	��|	d7}	t||	|�\}}	|||�}||	|	d�dk�r"|||	���}	||	|	d�dk�r"td||	��|	d7}	z:||	|k�rb|	d7}	||	|k�rb|||	d���}	Wntk
�rzYnXz|||	�\}}	Wn4tk
�r�}ztd||j�d�W5d}~XYnX|||f�z0||	}
|
|k�r�|||	d���}	||	}
Wntk
�rd}
YnX|	d7}	|
dk�r4�q�n|
d	k�rNtd
||	d��|||	���}	||	|	d�}
|	d7}	|
dkr�td||	d��q�|dk	�r�||
�}||	fSt|
�}
|dk	�r�||
�}
|
|	fS)Nr	r�}z1Expecting property name enclosed in double quotes�:zExpecting ':' delimiter�Expecting valuer6�,�Expecting ',' delimiter)	r7�
setdefaultr8rrr;�
StopIteration�value�dict)�	s_and_endr?�	scan_once�object_hook�object_pairs_hook�memo�_w�_wsr/r8ZpairsZpairs_appendZmemo_get�nextchar�result�keyrM�errrrr�
JSONObject�s��
"



�

rZc
Cst|\}}g}|||d�}||krF|||d���}|||d�}|dkrZ||dfS|j}z|||�\}	}Wn2tk
r�}
ztd||
j�d�W5d}
~
XYnX||	�|||d�}||kr�|||d���}|||d�}|d7}|dkr��qln|dk�rtd||d��z:|||k�rP|d7}|||k�rP|||d���}Wq`tk
�rhYq`Xq`||fS)Nr	�]rHrIrJ)r8r7rLrrMr;)rOrPrTrUr/r8�valuesrVrArMrYrrr�	JSONArray�s>"
r]c@s@eZdZdZddddddd�dd�Zejfdd�Zdd
d�ZdS)
raSimple JSON <http://json.org> decoder

    Performs the following translations in decoding by default:

    +---------------+-------------------+
    | JSON          | Python            |
    +===============+===================+
    | object        | dict              |
    +---------------+-------------------+
    | array         | list              |
    +---------------+-------------------+
    | string        | str               |
    +---------------+-------------------+
    | number (int)  | int               |
    +---------------+-------------------+
    | number (real) | float             |
    +---------------+-------------------+
    | true          | True              |
    +---------------+-------------------+
    | false         | False             |
    +---------------+-------------------+
    | null          | None              |
    +---------------+-------------------+

    It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
    their corresponding ``float`` values, which is outside the JSON spec.

    NT)rQ�parse_float�	parse_int�parse_constantr?rRcCsZ||_|pt|_|pt|_|p"tj|_||_||_	t
|_t|_
t|_i|_t�|�|_dS)a�``object_hook``, if specified, will be called with the result
        of every JSON object decoded and its return value will be used in
        place of the given ``dict``.  This can be used to provide custom
        deserializations (e.g. to support JSON-RPC class hinting).

        ``object_pairs_hook``, if specified will be called with the result of
        every JSON object decoded with an ordered list of pairs.  The return
        value of ``object_pairs_hook`` will be used instead of the ``dict``.
        This feature can be used to implement custom decoders.
        If ``object_hook`` is also defined, the ``object_pairs_hook`` takes
        priority.

        ``parse_float``, if specified, will be called with the string
        of every JSON float to be decoded. By default this is equivalent to
        float(num_str). This can be used to use another datatype or parser
        for JSON floats (e.g. decimal.Decimal).

        ``parse_int``, if specified, will be called with the string
        of every JSON int to be decoded. By default this is equivalent to
        int(num_str). This can be used to use another datatype or parser
        for JSON integers (e.g. float).

        ``parse_constant``, if specified, will be called with one of the
        following strings: -Infinity, Infinity, NaN.
        This can be used to raise an exception if invalid JSON numbers
        are encountered.

        If ``strict`` is false (true is the default), then control
        characters will be allowed inside strings.  Control characters in
        this context are those with character codes in the 0-31 range,
        including ``'\t'`` (tab), ``'\n'``, ``'\r'`` and ``'\0'``.
        N)rQ�floatr^r.r_�
_CONSTANTS�__getitem__r`r?rRrZZparse_objectr]Zparse_arrayrZparse_stringrSrZmake_scannerrP)rrQr^r_r`r?rRrrrr
s#

zJSONDecoder.__init__cCsF|j|||d���d�\}}|||���}|t|�krBtd||��|S)zlReturn the Python representation of ``s`` (a ``str`` instance
        containing a JSON document).

        r)�idxz
Extra data)�
raw_decoder8r-r)rr/rT�objr8rrr�decodeLs
zJSONDecoder.decoderc
CsPz|�||�\}}Wn2tk
rF}ztd||j�d�W5d}~XYnX||fS)a=Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.

        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.

        rHN)rPrLrrM)rr/rdrfr8rYrrrreWs
	"zJSONDecoder.raw_decode)r)	rrrrr
�
WHITESPACE�matchrgrerrrrr�s�0) r�reZjsonrZ_jsonrZc_scanstring�ImportError�__all__�VERBOSE�	MULTILINE�DOTALL�FLAGSrarZPosInfZNegInfrrrb�compileZSTRINGCHUNKZ	BACKSLASHr1rirErhZWHITESPACE_STRrZr]�objectrrrrr�<module>sP
��
�
=�
Q%PK��\e4�"v&v&decoder.cpython-38.opt-1.pycnu�[���U

e5d�0�	@sdZddlZddlmZzddlmZWnek
r@dZYnXddgZej	ej
BejBZe
d�Ze
d�Ze
d	�ZGd
d�de�Zeeed�Ze�de�Zd
dddddddd�Zdd�Zdeejfdd�Zep�eZe�de�ZdZdejefdd�Zejefdd �ZGd!d�de�ZdS)"zImplementation of JSONDecoder
�N)�scanner)�
scanstring�JSONDecoder�JSONDecodeError�nan�infz-infc@s eZdZdZdd�Zdd�ZdS)ra Subclass of ValueError with the following additional properties:

    msg: The unformatted error message
    doc: The JSON document being parsed
    pos: The start index of doc where parsing failed
    lineno: The line corresponding to pos
    colno: The column corresponding to pos

    cCsb|�dd|�d}||�dd|�}d||||f}t�||�||_||_||_||_||_dS)N�
r�z%s: line %d column %d (char %d))	�count�rfind�
ValueError�__init__�msg�doc�pos�lineno�colno)�selfrrrrr�errmsg�r�$/usr/lib64/python3.8/json/decoder.pyr
szJSONDecodeError.__init__cCs|j|j|j|jffS)N)�	__class__rrr)rrrr�
__reduce__*szJSONDecodeError.__reduce__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrs
)z	-InfinityZInfinity�NaNz(.*?)(["\\\x00-\x1f])�"�\�/��r�
�	)rrr �b�f�n�r�tcCsb||d|d�}t|�dkrN|ddkrNzt|d�WStk
rLYnXd}t|||��dS)Nr	��ZxX�zInvalid \uXXXX escape)�len�intrr)�sr�escrrrr�
_decode_uXXXX;sr1TcCs�g}|j}|d}|||�}|dkr0td||��|��}|��\}	}
|	rP||	�|
dkr^�q�n.|
dkr�|r�d�|
�}t|||��n
||
�qz||}Wn"tk
r�td||�d�YnX|dk�rz||}
Wn*tk
r�d�|�}t|||��YnX|d7}n�t||�}|d	7}d
|k�r2dk�r�nn`|||d�d
k�r�t||d�}d|k�rrdk�r�nn d|d
d>|dB}|d7}t|�}
||
�qd�	|�|fS)a�Scan the string s for a JSON string. End is the index of the
    character in s after the quote that started the JSON string.
    Unescapes all valid JSON string escape sequences and raises ValueError
    on attempt to decode an invalid string. If strict is False then literal
    control characters are allowed in the string.

    Returns a tuple of the decoded string and the index of the character in s
    after the end quote.r	NzUnterminated string starting atrrz"Invalid control character {0!r} at�uzInvalid \escape: {0!r}r*i�i���z\ui�i��i�
��)
�appendr�end�groups�format�
IndexError�KeyErrorr1�chr�join)r/r8�strictZ_b�_mZchunks�_appendZbegin�chunkZcontent�
terminatorrr0�charZuniZuni2rrr�
py_scanstringEsX


��



2
rEz
[ \t\n\r]*z 	

c
Cs�|\}}	g}
|
j}|dkri}|j}||	|	d�}
|
dkr�|
|krb|||	���}	||	|	d�}
|
dkr�|dk	r�||
�}||	dfSi}
|dk	r�||
�}
|
|	dfS|
dkr�td||	��|	d7}	t||	|�\}}	|||�}||	|	d�dk�r"|||	���}	||	|	d�dk�r"td||	��|	d7}	z:||	|k�rb|	d7}	||	|k�rb|||	d���}	Wntk
�rzYnXz|||	�\}}	Wn4tk
�r�}ztd||j�d�W5d}~XYnX|||f�z0||	}
|
|k�r�|||	d���}	||	}
Wntk
�rd}
YnX|	d7}	|
dk�r4�q�n|
d	k�rNtd
||	d��|||	���}	||	|	d�}
|	d7}	|
dkr�td||	d��q�|dk	�r�||
�}||	fSt|
�}
|dk	�r�||
�}
|
|	fS)Nr	r�}z1Expecting property name enclosed in double quotes�:zExpecting ':' delimiter�Expecting valuer6�,�Expecting ',' delimiter)	r7�
setdefaultr8rrr;�
StopIteration�value�dict)�	s_and_endr?�	scan_once�object_hook�object_pairs_hook�memo�_w�_wsr/r8ZpairsZpairs_appendZmemo_get�nextchar�result�keyrM�errrrr�
JSONObject�s��
"



�

rZc
Cst|\}}g}|||d�}||krF|||d���}|||d�}|dkrZ||dfS|j}z|||�\}	}Wn2tk
r�}
ztd||
j�d�W5d}
~
XYnX||	�|||d�}||kr�|||d���}|||d�}|d7}|dkr��qln|dk�rtd||d��z:|||k�rP|d7}|||k�rP|||d���}Wq`tk
�rhYq`Xq`||fS)Nr	�]rHrIrJ)r8r7rLrrMr;)rOrPrTrUr/r8�valuesrVrArMrYrrr�	JSONArray�s>"
r]c@s@eZdZdZddddddd�dd�Zejfdd�Zdd
d�ZdS)
raSimple JSON <http://json.org> decoder

    Performs the following translations in decoding by default:

    +---------------+-------------------+
    | JSON          | Python            |
    +===============+===================+
    | object        | dict              |
    +---------------+-------------------+
    | array         | list              |
    +---------------+-------------------+
    | string        | str               |
    +---------------+-------------------+
    | number (int)  | int               |
    +---------------+-------------------+
    | number (real) | float             |
    +---------------+-------------------+
    | true          | True              |
    +---------------+-------------------+
    | false         | False             |
    +---------------+-------------------+
    | null          | None              |
    +---------------+-------------------+

    It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
    their corresponding ``float`` values, which is outside the JSON spec.

    NT)rQ�parse_float�	parse_int�parse_constantr?rRcCsZ||_|pt|_|pt|_|p"tj|_||_||_	t
|_t|_
t|_i|_t�|�|_dS)a�``object_hook``, if specified, will be called with the result
        of every JSON object decoded and its return value will be used in
        place of the given ``dict``.  This can be used to provide custom
        deserializations (e.g. to support JSON-RPC class hinting).

        ``object_pairs_hook``, if specified will be called with the result of
        every JSON object decoded with an ordered list of pairs.  The return
        value of ``object_pairs_hook`` will be used instead of the ``dict``.
        This feature can be used to implement custom decoders.
        If ``object_hook`` is also defined, the ``object_pairs_hook`` takes
        priority.

        ``parse_float``, if specified, will be called with the string
        of every JSON float to be decoded. By default this is equivalent to
        float(num_str). This can be used to use another datatype or parser
        for JSON floats (e.g. decimal.Decimal).

        ``parse_int``, if specified, will be called with the string
        of every JSON int to be decoded. By default this is equivalent to
        int(num_str). This can be used to use another datatype or parser
        for JSON integers (e.g. float).

        ``parse_constant``, if specified, will be called with one of the
        following strings: -Infinity, Infinity, NaN.
        This can be used to raise an exception if invalid JSON numbers
        are encountered.

        If ``strict`` is false (true is the default), then control
        characters will be allowed inside strings.  Control characters in
        this context are those with character codes in the 0-31 range,
        including ``'\t'`` (tab), ``'\n'``, ``'\r'`` and ``'\0'``.
        N)rQ�floatr^r.r_�
_CONSTANTS�__getitem__r`r?rRrZZparse_objectr]Zparse_arrayrZparse_stringrSrZmake_scannerrP)rrQr^r_r`r?rRrrrr
s#

zJSONDecoder.__init__cCsF|j|||d���d�\}}|||���}|t|�krBtd||��|S)zlReturn the Python representation of ``s`` (a ``str`` instance
        containing a JSON document).

        r)�idxz
Extra data)�
raw_decoder8r-r)rr/rT�objr8rrr�decodeLs
zJSONDecoder.decoderc
CsPz|�||�\}}Wn2tk
rF}ztd||j�d�W5d}~XYnX||fS)a=Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.

        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.

        rHN)rPrLrrM)rr/rdrfr8rYrrrreWs
	"zJSONDecoder.raw_decode)r)	rrrrr
�
WHITESPACE�matchrgrerrrrr�s�0) r�reZjsonrZ_jsonrZc_scanstring�ImportError�__all__�VERBOSE�	MULTILINE�DOTALL�FLAGSrarZPosInfZNegInfrrrb�compileZSTRINGCHUNKZ	BACKSLASHr1rirErhZWHITESPACE_STRrZr]�objectrrrrr�<module>sP
��
�
=�
Q%PK��\�n0�+�+encoder.cpython-38.pycnu�[���U

e5d�>�
@s>dZddlZzddlmZWnek
r4dZYnXzddlmZWnek
r^dZYnXzddlmZ	Wnek
r�dZ	YnXe�
d�Ze�
d�Ze�
d�Z
d	d
ddd
ddd�Zed�D]Ze�ee�d�e��q�ed�Zdd�Zep�eZdd�Ze�peZGdd�de�Zeeeeeeee e!ej"f
dd�Z#dS)zImplementation of JSONEncoder
�N)�encode_basestring_ascii)�encode_basestring)�make_encoderz[\x00-\x1f\\"\b\f\n\r\t]z([\\"]|[^\ -~])s[�-�]z\\z\"z\bz\fz\nz\rz\t)�\�"���
�
�	� �	\u{0:04x}�infcCsdd�}dt�||�dS)z5Return a JSON representation of a Python string

    cSst|�d�S)Nr)�
ESCAPE_DCT�group)�match�r�$/usr/lib64/python3.8/json/encoder.py�replace(sz%py_encode_basestring.<locals>.replacer)�ESCAPE�sub��srrrr�py_encode_basestring$srcCsdd�}dt�||�dS)zAReturn an ASCII-only JSON representation of a Python string

    cSs�|�d�}z
t|WStk
rzt|�}|dkrBd�|�YS|d8}d|d?d@B}d|d@B}d�||�YSYnXdS)	Nrir
i��
i�i�z\u{0:04x}\u{1:04x})rr�KeyError�ord�format)rr�n�s1�s2rrrr4s

z+py_encode_basestring_ascii.<locals>.replacer)�ESCAPE_ASCIIrrrrr�py_encode_basestring_ascii0sr"c	@sNeZdZdZdZdZddddddddd�dd	�Zd
d�Zdd
�Zddd�Z	dS)�JSONEncoderaZExtensible JSON <http://json.org> encoder for Python data structures.

    Supports the following objects and types by default:

    +-------------------+---------------+
    | Python            | JSON          |
    +===================+===============+
    | dict              | object        |
    +-------------------+---------------+
    | list, tuple       | array         |
    +-------------------+---------------+
    | str               | string        |
    +-------------------+---------------+
    | int, float        | number        |
    +-------------------+---------------+
    | True              | true          |
    +-------------------+---------------+
    | False             | false         |
    +-------------------+---------------+
    | None              | null          |
    +-------------------+---------------+

    To extend this to recognize other objects, subclass and implement a
    ``.default()`` method with another method that returns a serializable
    object for ``o`` if possible, otherwise it should call the superclass
    implementation (to raise ``TypeError``).

    z, z: FTN)�skipkeys�ensure_ascii�check_circular�	allow_nan�	sort_keys�indent�
separators�defaultc	CsZ||_||_||_||_||_||_|dk	r:|\|_|_n|dk	rHd|_|dk	rV||_dS)a�Constructor for JSONEncoder, with sensible defaults.

        If skipkeys is false, then it is a TypeError to attempt
        encoding of keys that are not str, int, float or None.  If
        skipkeys is True, such items are simply skipped.

        If ensure_ascii is true, the output is guaranteed to be str
        objects with all incoming non-ASCII characters escaped.  If
        ensure_ascii is false, the output can contain non-ASCII characters.

        If check_circular is true, then lists, dicts, and custom encoded
        objects will be checked for circular references during encoding to
        prevent an infinite recursion (which would cause an OverflowError).
        Otherwise, no such check takes place.

        If allow_nan is true, then NaN, Infinity, and -Infinity will be
        encoded as such.  This behavior is not JSON specification compliant,
        but is consistent with most JavaScript based encoders and decoders.
        Otherwise, it will be a ValueError to encode such floats.

        If sort_keys is true, then the output of dictionaries will be
        sorted by key; this is useful for regression tests to ensure
        that JSON serializations can be compared on a day-to-day basis.

        If indent is a non-negative integer, then JSON array
        elements and object members will be pretty-printed with that
        indent level.  An indent level of 0 will only insert newlines.
        None is the most compact representation.

        If specified, separators should be an (item_separator, key_separator)
        tuple.  The default is (', ', ': ') if *indent* is ``None`` and
        (',', ': ') otherwise.  To get the most compact JSON representation,
        you should specify (',', ':') to eliminate whitespace.

        If specified, default is a function that gets called for objects
        that can't otherwise be serialized.  It should return a JSON encodable
        version of the object or raise a ``TypeError``.

        N�,)	r$r%r&r'r(r)�item_separator�
key_separatorr+)	�selfr$r%r&r'r(r)r*r+rrr�__init__hs+zJSONEncoder.__init__cCstd|jj�d���dS)alImplement this method in a subclass such that it returns
        a serializable object for ``o``, or calls the base implementation
        (to raise a ``TypeError``).

        For example, to support arbitrary iterators, you could
        implement default like this::

            def default(self, o):
                try:
                    iterable = iter(o)
                except TypeError:
                    pass
                else:
                    return list(iterable)
                # Let the base class default method raise the TypeError
                return JSONEncoder.default(self, o)

        zObject of type z is not JSON serializableN)�	TypeError�	__class__�__name__)r/�orrrr+�szJSONEncoder.defaultcCsNt|t�r |jrt|�St|�S|j|dd�}t|ttf�sDt|�}d�|�S)z�Return a JSON string representation of a Python data structure.

        >>> from json.encoder import JSONEncoder
        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
        '{"foo": ["bar", "baz"]}'

        T)�	_one_shot�)	�
isinstance�strr%rr�
iterencode�list�tuple�join)r/r4�chunksrrr�encode�s	
zJSONEncoder.encodecCs�|jri}nd}|jrt}nt}|jtjttfdd�}|rvtdk	rv|j	dkrvt||j
||j	|j|j|j
|j|j�	}n&t||j
||j	||j|j|j
|j|�
}||d�S)z�Encode the given object and yield each string
        representation as available.

        For example::

            for chunk in JSONEncoder().iterencode(bigobject):
                mysocket.write(chunk)

        NcSsJ||krd}n$||krd}n||kr*d}n||�S|sFtdt|���|S)NZNaNZInfinityz	-Infinityz2Out of range float values are not JSON compliant: )�
ValueError�repr)r4r'Z_reprZ_infZ_neginf�textrrr�floatstr�s��z(JSONEncoder.iterencode.<locals>.floatstrr)r&r%rrr'�float�__repr__�INFINITY�c_make_encoderr)r+r.r-r(r$�_make_iterencode)r/r4r5�markers�_encoderrB�_iterencoderrrr9�sL
�
���zJSONEncoder.iterencode)F)
r3�
__module__�__qualname__�__doc__r-r.r0r+r>r9rrrrr#Is�8r#cs��dk	r����sd�����������	�
��������fdd��	���������	�
���
��������fdd����������	�
��������fdd���S)N� c	3s�|sdVdS�dk	r6�|�}|�kr.�d��|�|<d}�dk	rh|d7}d�|}�|}||7}nd}�}d}|D]�}|r�d}n|}�
|��r�|�|�Vqx|dkr�|dVqx|dkr�|d	Vqx|dkr�|d
Vqx�
|��r�|�|�Vqx�
|�
��r|�|�Vqx|V�
|��f��r8�||�}n"�
|�	��rP�||�}n
�||�}|EdHqx|dk	�r�|d8}d�|VdV�dk	�r��|=dS)Nz[]�Circular reference detected�[�r	TF�null�true�false�]r)	Zlst�_current_indent_level�markeridZbuf�newline_indentZ	separator�first�valuer=)r?rI�	_floatstr�_indent�_intstr�_item_separatorrJ�_iterencode_dict�_iterencode_list�dictrC�id�intr7r:rHr8r;rrr`s\





z*_make_iterencode.<locals>._iterencode_listc
3s:|sdVdS�dk	r6�|�}|�kr.�d��|�|<dV�dk	rh|d7}d�|}�|}|Vnd}�}d}�r�t|���}n|��}|D�]j\}}�|��r�nn�|�
�r��|�}nZ|dkr�d}nL|dkr�d	}n>|dkr�d
}n0�|��r��|�}n�
�rq�ntd|jj����|�r"d}n|V�|�V�	V�|���rP�|�Vq�|dk�rbd
Vq�|dk�rtdVq�|dk�r�d	Vq��|���r��|�Vq��|�
��r��|�Vq��|��f��r҈||�}	n"�|���r�||�}	n
�||�}	|	EdHq�|dk	�r |d8}d�|VdV�dk	�r6�|=dS)
Nz{}rO�{rQr	TrSFrTrRz0keys must be str, int, float, bool or None, not �})�sorted�itemsr1r2r3)
ZdctrVrWrXr-rYrg�keyrZr=)r?rIr[r\r]r^rJr_r`�_key_separator�	_skipkeys�
_sort_keysrarCrbrcr7r:rHr8r;rrr_Ms�











z*_make_iterencode.<locals>._iterencode_dictc3s�|��r�|�Vn�|dkr&dVn�|dkr6dVn�|dkrFdVn��|��r\�|�Vn��|�	�rr�|�Vn��|�
�f�r��||�EdHnj�|��r��||�EdHnN�dk	rֈ
|�}|�krΈd��|�|<�|�}�||�EdH�dk	r��|=dS)NrRTrSFrTrOr)r4rVrW)r?�_defaultrIr[r]rJr_r`rarCrbrcr7r:rHr8r;rrrJ�s2



z%_make_iterencode.<locals>._iterencoder)rHrlrIr\r[rir^rkrjr5r?rarCrbrcr7r:r8r;r]r)r?rlrIr[r\r]r^rJr_r`rirjrkrarCrbrcr7r:rHr8r;rrGs.84P,rG)$rM�reZ_jsonrZc_encode_basestring_ascii�ImportErrorrZc_encode_basestringrrF�compilerr!ZHAS_UTF8r�range�i�
setdefault�chrrrCrErr"�objectr#r?rarbrcr7r:r8r;rDrGrrrr�<module>sZ





�		�>�PK��\�n0�+�+encoder.cpython-38.opt-1.pycnu�[���U

e5d�>�
@s>dZddlZzddlmZWnek
r4dZYnXzddlmZWnek
r^dZYnXzddlmZ	Wnek
r�dZ	YnXe�
d�Ze�
d�Ze�
d�Z
d	d
ddd
ddd�Zed�D]Ze�ee�d�e��q�ed�Zdd�Zep�eZdd�Ze�peZGdd�de�Zeeeeeeee e!ej"f
dd�Z#dS)zImplementation of JSONEncoder
�N)�encode_basestring_ascii)�encode_basestring)�make_encoderz[\x00-\x1f\\"\b\f\n\r\t]z([\\"]|[^\ -~])s[�-�]z\\z\"z\bz\fz\nz\rz\t)�\�"���
�
�	� �	\u{0:04x}�infcCsdd�}dt�||�dS)z5Return a JSON representation of a Python string

    cSst|�d�S)Nr)�
ESCAPE_DCT�group)�match�r�$/usr/lib64/python3.8/json/encoder.py�replace(sz%py_encode_basestring.<locals>.replacer)�ESCAPE�sub��srrrr�py_encode_basestring$srcCsdd�}dt�||�dS)zAReturn an ASCII-only JSON representation of a Python string

    cSs�|�d�}z
t|WStk
rzt|�}|dkrBd�|�YS|d8}d|d?d@B}d|d@B}d�||�YSYnXdS)	Nrir
i��
i�i�z\u{0:04x}\u{1:04x})rr�KeyError�ord�format)rr�n�s1�s2rrrr4s

z+py_encode_basestring_ascii.<locals>.replacer)�ESCAPE_ASCIIrrrrr�py_encode_basestring_ascii0sr"c	@sNeZdZdZdZdZddddddddd�dd	�Zd
d�Zdd
�Zddd�Z	dS)�JSONEncoderaZExtensible JSON <http://json.org> encoder for Python data structures.

    Supports the following objects and types by default:

    +-------------------+---------------+
    | Python            | JSON          |
    +===================+===============+
    | dict              | object        |
    +-------------------+---------------+
    | list, tuple       | array         |
    +-------------------+---------------+
    | str               | string        |
    +-------------------+---------------+
    | int, float        | number        |
    +-------------------+---------------+
    | True              | true          |
    +-------------------+---------------+
    | False             | false         |
    +-------------------+---------------+
    | None              | null          |
    +-------------------+---------------+

    To extend this to recognize other objects, subclass and implement a
    ``.default()`` method with another method that returns a serializable
    object for ``o`` if possible, otherwise it should call the superclass
    implementation (to raise ``TypeError``).

    z, z: FTN)�skipkeys�ensure_ascii�check_circular�	allow_nan�	sort_keys�indent�
separators�defaultc	CsZ||_||_||_||_||_||_|dk	r:|\|_|_n|dk	rHd|_|dk	rV||_dS)a�Constructor for JSONEncoder, with sensible defaults.

        If skipkeys is false, then it is a TypeError to attempt
        encoding of keys that are not str, int, float or None.  If
        skipkeys is True, such items are simply skipped.

        If ensure_ascii is true, the output is guaranteed to be str
        objects with all incoming non-ASCII characters escaped.  If
        ensure_ascii is false, the output can contain non-ASCII characters.

        If check_circular is true, then lists, dicts, and custom encoded
        objects will be checked for circular references during encoding to
        prevent an infinite recursion (which would cause an OverflowError).
        Otherwise, no such check takes place.

        If allow_nan is true, then NaN, Infinity, and -Infinity will be
        encoded as such.  This behavior is not JSON specification compliant,
        but is consistent with most JavaScript based encoders and decoders.
        Otherwise, it will be a ValueError to encode such floats.

        If sort_keys is true, then the output of dictionaries will be
        sorted by key; this is useful for regression tests to ensure
        that JSON serializations can be compared on a day-to-day basis.

        If indent is a non-negative integer, then JSON array
        elements and object members will be pretty-printed with that
        indent level.  An indent level of 0 will only insert newlines.
        None is the most compact representation.

        If specified, separators should be an (item_separator, key_separator)
        tuple.  The default is (', ', ': ') if *indent* is ``None`` and
        (',', ': ') otherwise.  To get the most compact JSON representation,
        you should specify (',', ':') to eliminate whitespace.

        If specified, default is a function that gets called for objects
        that can't otherwise be serialized.  It should return a JSON encodable
        version of the object or raise a ``TypeError``.

        N�,)	r$r%r&r'r(r)�item_separator�
key_separatorr+)	�selfr$r%r&r'r(r)r*r+rrr�__init__hs+zJSONEncoder.__init__cCstd|jj�d���dS)alImplement this method in a subclass such that it returns
        a serializable object for ``o``, or calls the base implementation
        (to raise a ``TypeError``).

        For example, to support arbitrary iterators, you could
        implement default like this::

            def default(self, o):
                try:
                    iterable = iter(o)
                except TypeError:
                    pass
                else:
                    return list(iterable)
                # Let the base class default method raise the TypeError
                return JSONEncoder.default(self, o)

        zObject of type z is not JSON serializableN)�	TypeError�	__class__�__name__)r/�orrrr+�szJSONEncoder.defaultcCsNt|t�r |jrt|�St|�S|j|dd�}t|ttf�sDt|�}d�|�S)z�Return a JSON string representation of a Python data structure.

        >>> from json.encoder import JSONEncoder
        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
        '{"foo": ["bar", "baz"]}'

        T)�	_one_shot�)	�
isinstance�strr%rr�
iterencode�list�tuple�join)r/r4�chunksrrr�encode�s	
zJSONEncoder.encodecCs�|jri}nd}|jrt}nt}|jtjttfdd�}|rvtdk	rv|j	dkrvt||j
||j	|j|j|j
|j|j�	}n&t||j
||j	||j|j|j
|j|�
}||d�S)z�Encode the given object and yield each string
        representation as available.

        For example::

            for chunk in JSONEncoder().iterencode(bigobject):
                mysocket.write(chunk)

        NcSsJ||krd}n$||krd}n||kr*d}n||�S|sFtdt|���|S)NZNaNZInfinityz	-Infinityz2Out of range float values are not JSON compliant: )�
ValueError�repr)r4r'Z_reprZ_infZ_neginf�textrrr�floatstr�s��z(JSONEncoder.iterencode.<locals>.floatstrr)r&r%rrr'�float�__repr__�INFINITY�c_make_encoderr)r+r.r-r(r$�_make_iterencode)r/r4r5�markers�_encoderrB�_iterencoderrrr9�sL
�
���zJSONEncoder.iterencode)F)
r3�
__module__�__qualname__�__doc__r-r.r0r+r>r9rrrrr#Is�8r#cs��dk	r����sd�����������	�
��������fdd��	���������	�
���
��������fdd����������	�
��������fdd���S)N� c	3s�|sdVdS�dk	r6�|�}|�kr.�d��|�|<d}�dk	rh|d7}d�|}�|}||7}nd}�}d}|D]�}|r�d}n|}�
|��r�|�|�Vqx|dkr�|dVqx|dkr�|d	Vqx|dkr�|d
Vqx�
|��r�|�|�Vqx�
|�
��r|�|�Vqx|V�
|��f��r8�||�}n"�
|�	��rP�||�}n
�||�}|EdHqx|dk	�r�|d8}d�|VdV�dk	�r��|=dS)Nz[]�Circular reference detected�[�r	TF�null�true�false�]r)	Zlst�_current_indent_level�markeridZbuf�newline_indentZ	separator�first�valuer=)r?rI�	_floatstr�_indent�_intstr�_item_separatorrJ�_iterencode_dict�_iterencode_list�dictrC�id�intr7r:rHr8r;rrr`s\





z*_make_iterencode.<locals>._iterencode_listc
3s:|sdVdS�dk	r6�|�}|�kr.�d��|�|<dV�dk	rh|d7}d�|}�|}|Vnd}�}d}�r�t|���}n|��}|D�]j\}}�|��r�nn�|�
�r��|�}nZ|dkr�d}nL|dkr�d	}n>|dkr�d
}n0�|��r��|�}n�
�rq�ntd|jj����|�r"d}n|V�|�V�	V�|���rP�|�Vq�|dk�rbd
Vq�|dk�rtdVq�|dk�r�d	Vq��|���r��|�Vq��|�
��r��|�Vq��|��f��r҈||�}	n"�|���r�||�}	n
�||�}	|	EdHq�|dk	�r |d8}d�|VdV�dk	�r6�|=dS)
Nz{}rO�{rQr	TrSFrTrRz0keys must be str, int, float, bool or None, not �})�sorted�itemsr1r2r3)
ZdctrVrWrXr-rYrg�keyrZr=)r?rIr[r\r]r^rJr_r`�_key_separator�	_skipkeys�
_sort_keysrarCrbrcr7r:rHr8r;rrr_Ms�











z*_make_iterencode.<locals>._iterencode_dictc3s�|��r�|�Vn�|dkr&dVn�|dkr6dVn�|dkrFdVn��|��r\�|�Vn��|�	�rr�|�Vn��|�
�f�r��||�EdHnj�|��r��||�EdHnN�dk	rֈ
|�}|�krΈd��|�|<�|�}�||�EdH�dk	r��|=dS)NrRTrSFrTrOr)r4rVrW)r?�_defaultrIr[r]rJr_r`rarCrbrcr7r:rHr8r;rrrJ�s2



z%_make_iterencode.<locals>._iterencoder)rHrlrIr\r[rir^rkrjr5r?rarCrbrcr7r:r8r;r]r)r?rlrIr[r\r]r^rJr_r`rirjrkrarCrbrcr7r:rHr8r;rrGs.84P,rG)$rM�reZ_jsonrZc_encode_basestring_ascii�ImportErrorrZc_encode_basestringrrF�compilerr!ZHAS_UTF8r�range�i�
setdefault�chrrrCrErr"�objectr#r?rarbrcr7r:r8r;rDrGrrrr�<module>sZ





�		�>�PK��\��{��encoder.cpython-38.opt-2.pycnu�[���U

e5d�>�
@s:ddlZzddlmZWnek
r0dZYnXzddlmZWnek
rZdZYnXzddlmZWnek
r�dZYnXe�	d�Z
e�	d�Ze�	d�Zdd	d
ddd
dd�Z
ed�D]Ze
�ee�d�e��q�ed�Zdd�Zep�eZdd�Ze�peZGdd�de�Zeeeeeeeee ej!f
dd�Z"dS)�N)�encode_basestring_ascii)�encode_basestring)�make_encoderz[\x00-\x1f\\"\b\f\n\r\t]z([\\"]|[^\ -~])s[�-�]z\\z\"z\bz\fz\nz\rz\t)�\�"���
�
�	� �	\u{0:04x}�infcCsdd�}dt�||�dS)NcSst|�d�S)Nr)�
ESCAPE_DCT�group)�match�r�$/usr/lib64/python3.8/json/encoder.py�replace(sz%py_encode_basestring.<locals>.replacer)�ESCAPE�sub��srrrr�py_encode_basestring$srcCsdd�}dt�||�dS)NcSs�|�d�}z
t|WStk
rzt|�}|dkrBd�|�YS|d8}d|d?d@B}d|d@B}d�||�YSYnXdS)	Nrir
i��
i�i�z\u{0:04x}\u{1:04x})rr�KeyError�ord�format)rr�n�s1�s2rrrr4s

z+py_encode_basestring_ascii.<locals>.replacer)�ESCAPE_ASCIIrrrrr�py_encode_basestring_ascii0sr"c	@sJeZdZdZdZddddddddd�dd�Zd	d
�Zdd�Zdd
d�ZdS)�JSONEncoderz, z: FTN)�skipkeys�ensure_ascii�check_circular�	allow_nan�	sort_keys�indent�
separators�defaultc	CsZ||_||_||_||_||_||_|dk	r:|\|_|_n|dk	rHd|_|dk	rV||_dS)N�,)	r$r%r&r'r(r)�item_separator�
key_separatorr+)	�selfr$r%r&r'r(r)r*r+rrr�__init__hs+zJSONEncoder.__init__cCstd|jj�d���dS)NzObject of type z is not JSON serializable)�	TypeError�	__class__�__name__)r/�orrrr+�szJSONEncoder.defaultcCsNt|t�r |jrt|�St|�S|j|dd�}t|ttf�sDt|�}d�|�S)NT)�	_one_shot�)	�
isinstance�strr%rr�
iterencode�list�tuple�join)r/r4�chunksrrr�encode�s	
zJSONEncoder.encodecCs�|jri}nd}|jrt}nt}|jtjttfdd�}|rvtdk	rv|j	dkrvt||j
||j	|j|j|j
|j|j�	}n&t||j
||j	||j|j|j
|j|�
}||d�S)NcSsJ||krd}n$||krd}n||kr*d}n||�S|sFtdt|���|S)NZNaNZInfinityz	-Infinityz2Out of range float values are not JSON compliant: )�
ValueError�repr)r4r'Z_reprZ_infZ_neginf�textrrr�floatstr�s��z(JSONEncoder.iterencode.<locals>.floatstrr)r&r%rrr'�float�__repr__�INFINITY�c_make_encoderr)r+r.r-r(r$�_make_iterencode)r/r4r5�markers�_encoderrB�_iterencoderrrr9�sL
�
���zJSONEncoder.iterencode)F)	r3�
__module__�__qualname__r-r.r0r+r>r9rrrrr#Is�8r#cs��dk	r����sd�����������	�
��������fdd��	���������	�
���
��������fdd����������	�
��������fdd���S)N� c	3s�|sdVdS�dk	r6�|�}|�kr.�d��|�|<d}�dk	rh|d7}d�|}�|}||7}nd}�}d}|D]�}|r�d}n|}�
|��r�|�|�Vqx|dkr�|dVqx|dkr�|d	Vqx|dkr�|d
Vqx�
|��r�|�|�Vqx�
|�
��r|�|�Vqx|V�
|��f��r8�||�}n"�
|�	��rP�||�}n
�||�}|EdHqx|dk	�r�|d8}d�|VdV�dk	�r��|=dS)Nz[]�Circular reference detected�[�r	TF�null�true�false�]r)	Zlst�_current_indent_level�markeridZbuf�newline_indentZ	separator�first�valuer=)r?rI�	_floatstr�_indent�_intstr�_item_separatorrJ�_iterencode_dict�_iterencode_list�dictrC�id�intr7r:rHr8r;rrr_s\





z*_make_iterencode.<locals>._iterencode_listc
3s:|sdVdS�dk	r6�|�}|�kr.�d��|�|<dV�dk	rh|d7}d�|}�|}|Vnd}�}d}�r�t|���}n|��}|D�]j\}}�|��r�nn�|�
�r��|�}nZ|dkr�d}nL|dkr�d	}n>|dkr�d
}n0�|��r��|�}n�
�rq�ntd|jj����|�r"d}n|V�|�V�	V�|���rP�|�Vq�|dk�rbd
Vq�|dk�rtdVq�|dk�r�d	Vq��|���r��|�Vq��|�
��r��|�Vq��|��f��r҈||�}	n"�|���r�||�}	n
�||�}	|	EdHq�|dk	�r |d8}d�|VdV�dk	�r6�|=dS)
Nz{}rN�{rPr	TrRFrSrQz0keys must be str, int, float, bool or None, not �})�sorted�itemsr1r2r3)
ZdctrUrVrWr-rXrf�keyrYr=)r?rIrZr[r\r]rJr^r_�_key_separator�	_skipkeys�
_sort_keysr`rCrarbr7r:rHr8r;rrr^Ms�











z*_make_iterencode.<locals>._iterencode_dictc3s�|��r�|�Vn�|dkr&dVn�|dkr6dVn�|dkrFdVn��|��r\�|�Vn��|�	�rr�|�Vn��|�
�f�r��||�EdHnj�|��r��||�EdHnN�dk	rֈ
|�}|�krΈd��|�|<�|�}�||�EdH�dk	r��|=dS)NrQTrRFrSrNr)r4rUrV)r?�_defaultrIrZr\rJr^r_r`rCrarbr7r:rHr8r;rrrJ�s2



z%_make_iterencode.<locals>._iterencoder)rHrkrIr[rZrhr]rjrir5r?r`rCrarbr7r:r8r;r\r)r?rkrIrZr[r\r]rJr^r_rhrirjr`rCrarbr7r:rHr8r;rrGs.84P,rG)#�reZ_jsonrZc_encode_basestring_ascii�ImportErrorrZc_encode_basestringrrF�compilerr!ZHAS_UTF8r�range�i�
setdefault�chrrrCrErr"�objectr#r?r`rarbr7r:r8r;rDrGrrrr�<module>sX





�		�>�PK��\�]Ɗ��scanner.cpython-38.pycnu�[���U

e5dy	�@sjdZddlZzddlmZWnek
r4dZYnXdgZe�dejej	Bej
B�Zdd�ZepdeZdS)zJSON token scanner
�N)�make_scannerrz)(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?csv|j�	|j�|j�
tj�|j�|j�|j�|j�|j	�|j
�|j�����������	�
�fdd����fdd�}|S)Ncs�z||}Wntk
r*t|�d�YnX|dkrD�
||d��S|dkrf�	||df������S|dkr��||df��S|dkr�|||d�dkr�d|dfS|dkr�|||d�d	kr�d
|dfS|dk�r�|||d�d
k�r�d|dfS�||�}|dk	�r\|��\}}}|�s*|�rH�||�p6d|�p@d�}n�|�}||��fS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r��d�|dfS|dk�r�|||d�dk�r�d�|dfSt|��dS)N�"��{�[�n�Znull�t�trueT�f�ZfalseF��N�ZNaN�I�ZInfinity�-�	z	-Infinity)�
IndexError�
StopIteration�groups�end)�string�idxZnextchar�mZintegerZfracZexp�res��
_scan_onceZmatch_number�memo�object_hook�object_pairs_hook�parse_array�parse_constant�parse_float�	parse_int�parse_object�parse_string�strict��$/usr/lib64/python3.8/json/scanner.pyrsF� 

   z#py_make_scanner.<locals>._scan_oncecsz�||�W�S���XdS)N)�clear)rr)rrr(r)�	scan_onceAsz"py_make_scanner.<locals>.scan_once)r%r!r&�	NUMBER_RE�matchr'r#r$r"rr r)�contextr+r(rr)�py_make_scanners"%r/)
�__doc__�reZ_jsonrZc_make_scanner�ImportError�__all__�compile�VERBOSE�	MULTILINE�DOTALLr,r/r(r(r(r)�<module>s
�:PK�
�\4')6OOresult.cpython-38.opt-2.pycnu�[���PK�
�\�f�YY�async_case.cpython-38.pycnu�[���PK�
�\jr�&6�6�<'case.cpython-38.pycnu�[���PK�
�\w;�����__main__.cpython-38.opt-1.pycnu�[���PK�
�\#T�^�%�%��util.cpython-38.opt-2.pycnu�[���PK�
�\2B�Z�"�"�suite.cpython-38.opt-2.pycnu�[���PK�
�\��.z�&�&7suite.cpython-38.pycnu�[���PK�
�\��.z�&�&^suite.cpython-38.opt-1.pycnu�[���PK�
�\�����5�case.cpython-38.opt-1.pycnu�[���PK�
�\w;���~J__main__.cpython-38.pycnu�[���PK�
�\a!n�}}�Kresult.cpython-38.pycnu�[���PK�
�\P�<��^hsignals.cpython-38.opt-1.pycnu�[���PK�
�\��E��Xq__init__.cpython-38.opt-2.pycnu�[���PK�
�\�٢�<�<F~util.cpython-38.pycnu�[���PK�
�\w;���E�__main__.cpython-38.opt-2.pycnu�[���PK�
�\��W�؉؉i�case.cpython-38.opt-2.pycnu�[���PK�
�\�V)��-�-�Floader.cpython-38.opt-2.pycnu�[���PK�
�\P�<���tsignals.cpython-38.opt-2.pycnu�[���PK�
�\�6��jj�}runner.cpython-38.opt-1.pycnu�[���PK�
�\���8�8f�loader.cpython-38.pycnu�[���PK�
�\:��u�runner.cpython-38.opt-2.pycnu�[���PK�
�\�6��jj��runner.cpython-38.pycnu�[���PK�
�\a!n�}}rresult.cpython-38.opt-1.pycnu�[���PK�
�\O��EB1B1:$__init__.cpython-38.pycnu�[���PK�
�\l�k��Uasync_case.cpython-38.opt-2.pycnu�[���PK�
�\���58.8.fmock.cpython-38.opt-1.pycnu�[���PK�
�\��O�!�!��main.cpython-38.opt-1.pycnu�[���PK�
�\O��EB1B1a�__init__.cpython-38.opt-1.pycnu�[���PK�
�\l�k���async_case.cpython-38.opt-1.pycnu�[���PK�
�\P�<��D�signals.cpython-38.pycnu�[���PK�
�\�J���<�<8util.cpython-38.opt-1.pycnu�[���PK�
�\���58.8.=>mock.cpython-38.pycnu�[���PK�
�\-:p_8_8�lloader.cpython-38.opt-1.pycnu�[���PK�
�\ߜ|}�}�b�mock.cpython-38.opt-2.pycnu�[���PK�
�\8O���!�!(�main.cpython-38.pycnu�[���PK�
�\Y'x��
�main.cpython-38.opt-2.pycnu�[���PKX�\_!^+����encoding.cpython-36.opt-1.pycnu�[���PKX�\�''1�logging.cpython-36.pycnu�[���PKX�\a �44��filesystem.cpython-36.pycnu�[���PKX�\& Z���packaging.cpython-36.pycnu�[���PKX�\UtFCC�glibc.cpython-36.opt-1.pycnu�[���PKX�\���~��build.cpython-36.pycnu�[���PKX�\& Z����packaging.cpython-36.opt-1.pycnu�[���PKX�\_!^+���encoding.cpython-36.pycnu�[���PKY�\:��gg�outdated.cpython-36.opt-1.pycnu�[���PKY�\UtFCC�
	glibc.cpython-36.pycnu�[���PKY�\��H���Y	hashes.cpython-36.pycnu�[���PKY�\�3L\%\%5 	ui.cpython-36.pycnu�[���PKY�\2��e�E	appdirs.cpython-36.pycnu�[���PKY�\ �J��d	__init__.cpython-36.pycnu�[���PKY�\:��ggg	outdated.cpython-36.pycnu�[���PKY�\T��44�y	setuptools_build.cpython-36.pycnu�[���PKY�\��H���@{	hashes.cpython-36.opt-1.pycnu�[���PKY�\�''"�	logging.cpython-36.opt-1.pycnu�[���PKY�\b#�-�� ��	deprecation.cpython-36.opt-1.pycnu�[���PKY�\a �44��	filesystem.cpython-36.opt-1.pycnu�[���PKY�\b#�-���	deprecation.cpython-36.pycnu�[���PKY�\ �J���	__init__.cpython-36.opt-1.pycnu�[���PKY�\���~�	build.cpython-36.opt-1.pycnu�[���PKY�\T��44%a�	setuptools_build.cpython-36.opt-1.pycnu�[���PKY�\2��e�	appdirs.cpython-36.opt-1.pycnu�[���PKY�\j���!%!%8�	ui.cpython-36.opt-1.pycnu�[���PK�"�\7������	charset.cpython-38.opt-2.pycnu�[���PK�"�\�إ�����	
message.cpython-38.pycnu�[���PK�"�\u�(JLL�
utils.cpython-38.opt-2.pycnu�[���PK�"�\��|>�,�,��
charset.cpython-38.pycnu�[���PK�"�\�*���
quoprimime.cpython-38.pycnu�[���PK�"�\�ͼc9@9@�header.cpython-38.pycnu�[���PK�"�\vd�8'�'�)yB_header_value_parser.cpython-38.opt-2.pycnu�[���PK�"�\�['ʥ��8base64mime.cpython-38.opt-1.pycnu�[���PK�"�\E��(�(�Efeedparser.cpython-38.opt-1.pycnu�[���PK�"�\{v�?88#8o_encoded_words.cpython-38.opt-1.pycnu�[���PK�"�\�Jtu
u
Åpolicy.cpython-38.opt-2.pycnu�[���PK�"�\p���&%&%��_parseaddr.cpython-38.opt-2.pycnu�[���PK�"�\h��A����iterators.cpython-38.opt-1.pycnu�[���PK�"�\�~�z�0�0�generator.cpython-38.pycnu�[���PK�"�\{v�?88��_encoded_words.cpython-38.pycnu�[���PK�"�\�.�FSFS�
message.cpython-38.opt-2.pycnu�[���PK�"�\V�e�A*A*\
header.cpython-38.opt-2.pycnu�[���PK�"�\�f�\\��
parser.cpython-38.pycnu�[���PK�"�\>~�s�
�
B�
parser.cpython-38.opt-2.pycnu�[���PK�"�\����U�U#�
headerregistry.cpython-38.opt-1.pycnu�[���PK�"�\h��A��\�
iterators.cpython-38.pycnu�[���PK�"�\��Zu�)�)&feedparser.cpython-38.pycnu�[���PK�"�\Ɥ��#0_encoded_words.cpython-38.opt-2.pycnu�[���PK�"�\o��NN0?encoders.cpython-38.opt-1.pycnu�[���PK�"�\�f�\\�Eparser.cpython-38.opt-1.pycnu�[���PK�"�\FN��H%H%r\utils.cpython-38.pycnu�[���PK�"�\�(�%�%��policy.cpython-38.pycnu�[���PK�"�\�(�%�%��policy.cpython-38.opt-1.pycnu�[���PK�"�\l��$?8?8#�_header_value_parser.cpython-38.pycnu�[���PK�"�\m�`�88)�_header_value_parser.cpython-38.opt-1.pycnu�[���PK�"�\�ˠ��?base64mime.cpython-38.opt-2.pycnu�[���PK�"�\o��NNEencoders.cpython-38.pycnu�[���PK�"�\��\w`` �K_policybase.cpython-38.opt-2.pycnu�[���PK�"�\�>rx�,�,Hccharset.cpython-38.opt-1.pycnu�[���PK�"�\P�"�{"{"4�generator.cpython-38.opt-2.pycnu�[���PK�"�\~ov�VV��headerregistry.cpython-38.pycnu�[���PK�"�\�h	iterators.cpython-38.opt-2.pycnu�[���PK�"�\4��#oo�quoprimime.cpython-38.opt-2.pycnu�[���PK�"�\@��}"}"�feedparser.cpython-38.opt-2.pycnu�[���PK�"�\��-���VBerrors.cpython-38.opt-1.pycnu�[���PK�"�\�إ����%Wmessage.cpython-38.opt-1.pycnu�[���PK�"�\o��c��i�contentmanager.cpython-38.pycnu�[���PK�"�\FN��H%H%yutils.cpython-38.opt-1.pycnu�[���PK�"�\o��c��#.contentmanager.cpython-38.opt-2.pycnu�[���PK�"�\#jq�0�0!K_parseaddr.cpython-38.pycnu�[���PK�"�\�*��� |encoders.cpython-38.opt-2.pycnu�[���PK�"�\�.]��9�9 \�_policybase.cpython-38.opt-1.pycnu�[���PK�"�\�~�z�0�0��generator.cpython-38.opt-1.pycnu�[���PK�"�\#jq�0�0��_parseaddr.cpython-38.opt-1.pycnu�[���PK�"�\)Z��g?g?#�headerregistry.cpython-38.opt-2.pycnu�[���PK�"�\�ͼc9@9@�]header.cpython-38.opt-1.pycnu�[���PK�"�\�['ʥ��base64mime.cpython-38.pycnu�[���PK�"�\o��c��#��contentmanager.cpython-38.opt-1.pycnu�[���PK�"�\��-����errors.cpython-38.pycnu�[���PK�"�\�*���quoprimime.cpython-38.opt-1.pycnu�[���PK�"�\�w��
�
#�errors.cpython-38.opt-2.pycnu�[���PK�"�\�.]��9�9�_policybase.cpython-38.pycnu�[���PK�&�\/?d�//$@fixer_util.cpython-36.opt-1.pycnu�[���PK�&�\��2!2!yomain.cpython-36.opt-1.pycnu�[���PK�&�\�K,#
#
 �btm_matcher.cpython-36.opt-2.pycnu�[���PK�&�\/?d�//g�fixer_util.cpython-36.pycnu�[���PK�&�\�Zr~����__main__.cpython-36.opt-2.pycnu�[���PK�&�\0'?QQ��refactor.cpython-36.opt-1.pycnu�[���PK�&�\f<�Q��5 pygram.cpython-36.opt-1.pycnu�[���PK�&�\�	�EFF %btm_matcher.cpython-36.opt-1.pycnu�[���PK�&�\�"��&�&�8fixer_util.cpython-36.opt-2.pycnu�[���PK�&�\�ѝ�_btm_utils.cpython-36.opt-2.pycnu�[���PK�&�\`l��:�:�qpytree.cpython-36.opt-2.pycnu�[���PK�&�\�O�����pygram.cpython-36.opt-2.pycnu�[���PK�&�\vá�FAFA�refactor.cpython-36.opt-2.pycnu�[���PK�&�\�Zr~����__main__.cpython-36.pycnu�[���PK�&�\))]QQ��fixer_base.cpython-36.opt-1.pycnu�[���PK�&�\7`4��[btm_utils.cpython-36.pycnu�[���PK�&�\4�P�T!T!�$main.cpython-36.pycnu�[���PK�&�\Q��_�_/Fpytree.cpython-36.opt-1.pycnu�[���PK�&�\7`4����btm_utils.cpython-36.opt-1.pycnu�[���PK�&�\))]QQ>�fixer_base.cpython-36.pycnu�[���PK�&�\f<�Q����pygram.cpython-36.pycnu�[���PK�&�\\�!Y����patcomp.cpython-36.opt-1.pycnu�[���PK�&�\�Zr~����__main__.cpython-36.opt-1.pycnu�[���PK�&�\�	�EFF�btm_matcher.cpython-36.pycnu�[���PK�&�\�����patcomp.cpython-36.opt-2.pycnu�[���PK�&�\�sdr0b0b�pytree.cpython-36.pycnu�[���PK�&�\H�4I7Q7QL{refactor.cpython-36.pycnu�[���PK�&�\��WWW��main.cpython-36.opt-2.pycnu�[���PK�&�\euf���j�patcomp.cpython-36.pycnu�[���PK�&�\�7M:�
�
��fixer_base.cpython-36.opt-2.pycnu�[���PK�&�\!�����k__init__.cpython-36.opt-2.pycnu�[���PK�+�\�s55[dictconfig.cpython-36.pycnu�[���PK�+�\�s55�Adictconfig.cpython-36.opt-1.pycnu�[���PK|/�\~!�A�A�wserver.cpython-38.pycnu�[���PK|/�\I�����cookiejar.cpython-38.pycnu�[���PK|/�\�70]�]�m�client.cpython-38.pycnu�[���PK|/�\�;�[ddZclient.cpython-38.opt-2.pycnu�[���PK|/�\���I*I*u�cookies.cpython-38.opt-2.pycnu�[���PK|/�\M3�1����
�cookiejar.cpython-38.opt-1.pycnu�[���PK|/�\2�uI2Y2Y�server.cpython-38.opt-2.pycnu�[���PK|/�\b��:�����client.cpython-38.opt-1.pycnu�[���PK|/�\ߺ��v;v;ޛcookies.cpython-38.opt-1.pycnu�[���PK|/�\�q5��;�;��cookies.cpython-38.pycnu�[���PK|/�\CQ�����cookiejar.cpython-38.opt-2.pycnu�[���PK|/�\~!�A�A���server.cpython-38.opt-1.pycnu�[���PK0�\7�!�!0protocols.cpython-38.opt-1.pycnu�[���PK0�\T=T\W�W� Rbase_events.cpython-38.opt-2.pycnu�[���PK0�\���I�I��events.cpython-38.opt-2.pycnu�[���PK0�\�S�Y�s�s$�? selector_events.cpython-38.opt-1.pycnu�[���PK0�\���kk߳ staggered.cpython-38.opt-1.pycnu�[���PK0�\�o2y�/�/�� transports.cpython-38.pycnu�[���PK0�\�H��m�m�� events.cpython-38.pycnu�[���PK0�\�x��**#�a!format_helpers.cpython-38.opt-2.pycnu�[���PK0�\�Ŀ � &j!queues.cpython-38.pycnu�[���PK0�\j�xx*�!constants.cpython-38.opt-1.pycnu�[���PK0�\`��S�S�!sslproto.cpython-38.opt-1.pycnu�[���PK0�\ۂ�U
+
+��!futures.cpython-38.opt-1.pycnu�[���PK0�\��M%!%!?"trsock.cpython-38.pycnu�[���PK0�\[k�AA�2"tasks.cpython-38.opt-2.pycnu�[���PK0�\H�� �[�[#�s"windows_events.cpython-38.opt-2.pycnu�[���PK0�\���1N�N���"base_events.cpython-38.pycnu�[���PK0�\9c��_�_#u�#windows_events.cpython-38.opt-1.pycnu�[���PK0�\�h�����#runners.cpython-38.opt-1.pycnu�[���PK0�\���E��#staggered.cpython-38.pycnu�[���PK0�\��b���$subprocess.cpython-38.pycnu�[���PK0�\���
		-$format_helpers.cpython-38.pycnu�[���PK0�\$��'��n6$base_tasks.cpython-38.opt-1.pycnu�[���PK0�\��gF�� W>$unix_events.cpython-38.opt-2.pycnu�[���PK0�\��M%!%!��$trsock.cpython-38.opt-1.pycnu�[���PK0�\�N&#�$coroutines.cpython-38.pycnu�[���PK0�\��Kl�l� l%base_events.cpython-38.opt-1.pycnu�[���PK0�\��?�?(�%locks.cpython-38.opt-1.pycnu�[���PK0�\˼��-�-� d&unix_events.cpython-38.opt-1.pycnu�[���PK0�\ٗ'99�&sslproto.cpython-38.opt-2.pycnu�[���PK0�\k*�	�	G�&exceptions.cpython-38.pycnu�[���PK0�\\dkss"��&windows_utils.cpython-38.opt-2.pycnu�[���PK
0�\���+�+L�&futures.cpython-38.pycnu�[���PK
0�\�O�=]=]$M'proactor_events.cpython-38.opt-1.pycnu�[���PK
0�\�\@��/�/�|'transports.cpython-38.opt-1.pycnu�[���PK
0�\���  ��'futures.cpython-38.opt-2.pycnu�[���PK
0�\wI<wssc�'exceptions.cpython-38.opt-2.pycnu�[���PK
0�\k*�	�	%�'exceptions.cpython-38.opt-1.pycnu�[���PK
0�\�Ŀ � k�'queues.cpython-38.opt-1.pycnu�[���PK
0�\�ۤ�YmYm$u�'selector_events.cpython-38.opt-2.pycnu�[���PK
0�\�P�% % "l(trsock.cpython-38.opt-2.pycnu�[���PK
0�\��?�?��(locks.cpython-38.pycnu�[���PK
0�\C��ktTtT��(sslproto.cpython-38.pycnu�[���PK
0�\j�xx�!)constants.cpython-38.opt-2.pycnu�[���PK
0�\@c.�
	
	I()log.cpython-38.pycnu�[���PK
0�\�����1)coroutines.cpython-38.opt-1.pycnu�[���PK
0�\�с�^�^�K)tasks.cpython-38.opt-1.pycnu�[���PK
0�\������)coroutines.cpython-38.opt-2.pycnu�[���PK
0�\��xx��)constants.cpython-38.pycnu�[���PK
0�\��+�[�[$Q�)proactor_events.cpython-38.opt-2.pycnu�[���PK
0�\��,�R&*staggered.cpython-38.opt-2.pycnu�[���PK
0�\�m���8�8�-*streams.cpython-38.opt-2.pycnu�[���PK
0�\���b�s�s�f*selector_events.cpython-38.pycnu�[���PK
0�\2�
����*transports.cpython-38.opt-2.pycnu�[���PK
0�\�	�j$j$$�*base_subprocess.cpython-38.opt-1.pycnu�[���PK
0�\�]�������+unix_events.cpython-38.pycnu�[���PK
0�\�	u�

��+protocols.cpython-38.opt-2.pycnu�[���PK
0�\7�!�!�+protocols.cpython-38.pycnu�[���PK
0�\$��'����+base_tasks.cpython-38.pycnu�[���PK
0�\�ar�$�$��+base_subprocess.cpython-38.pycnu�[���PK
0�\�;j%%"�,windows_utils.cpython-38.opt-1.pycnu�[���PK
0�\)��(&(&O",locks.cpython-38.opt-2.pycnu�[���PK
0�\i�.CHH�H,queues.cpython-38.opt-2.pycnu�[���PK
0�\r׉nn!T_,base_futures.cpython-38.opt-2.pycnu�[���PK
0�\@c.�
	
	f,log.cpython-38.opt-1.pycnu�[���PK
0�\ߋ�ѢP�Pho,streams.cpython-38.pycnu�[���PK
0�\�?�`��P�,runners.cpython-38.opt-2.pycnu�[���PK
0�\ft�,S^S^��,proactor_events.cpython-38.pycnu�[���PK0�\��M�""0$-subprocess.cpython-38.opt-2.pycnu�[���PK0�\��q�ll!�@-base_futures.cpython-38.opt-1.pycnu�[���PK0�\��yy^H-windows_utils.cpython-38.pycnu�[���PK0�\�h���#Z-runners.cpython-38.pycnu�[���PK0�\���/$$$b-base_subprocess.cpython-38.opt-2.pycnu�[���PK0�\���
		#`�-format_helpers.cpython-38.opt-1.pycnu�[���PK0�\g<2��^�^я-tasks.cpython-38.pycnu�[���PK0�\������-subprocess.cpython-38.opt-1.pycnu�[���PK0�\��q�ll�.base_futures.cpython-38.pycnu�[���PK0�\?��O�O�.streams.cpython-38.opt-1.pycnu�[���PK0�\l[˅	`	`sc.windows_events.cpython-38.pycnu�[���PK0�\	�?�/m/m��.events.cpython-38.opt-1.pycnu�[���PK0�\$��'��C1/base_tasks.cpython-38.opt-2.pycnu�[���PK0�\U�u��,9/log.cpython-38.opt-2.pycnu�[���PK12�\�ht+�9�9DB/msvccompiler.cpython-38.pycnu�[���PK12�\�5����|/core.cpython-38.pycnu�[���PK12�\e9-/�/versionpredicate.cpython-38.pycnu�[���PK12�\�^(�=�="��/msvc9compiler.cpython-38.opt-2.pycnu�[���PK12�\
R4�����/cmd.cpython-38.opt-2.pycnu�[���PK12�\� ���0dep_util.cpython-38.opt-2.pycnu�[���PK22�\�ht+�9�9!�
0msvccompiler.cpython-38.opt-1.pycnu�[���PK22�\��))!�G0fancy_getopt.cpython-38.opt-1.pycnu�[���PK22�\I��q0core.cpython-38.opt-2.pycnu�[���PK22�\�~��//�}0file_util.cpython-38.opt-1.pycnu�[���PK22�\��cE!v�0fancy_getopt.cpython-38.opt-2.pycnu�[���PK22�\�g:-D-D"�0msvc9compiler.cpython-38.opt-1.pycnu�[���PK22�\�
�,JJ"e�0unixccompiler.cpython-38.opt-1.pycnu�[���PK22�\4��!�
�
1config.cpython-38.opt-1.pycnu�[���PK22�\��V����"1ccompiler.cpython-38.opt-1.pycnu�[���PK22�\|�����1spawn.cpython-38.opt-1.pycnu�[���PK22�\0�oa����#�1dist.cpython-38.opt-1.pycnu�[���PK22�\4#�Z��*?2dir_util.cpython-38.pycnu�[���PK22�\�uU]]!2V2bcppcompiler.cpython-38.opt-2.pycnu�[���PK22�\p|t����n2version.cpython-38.opt-2.pycnu�[���PK22�\O�

�~2extension.cpython-38.opt-1.pycnu�[���PK22�\e9-%�2versionpredicate.cpython-38.opt-1.pycnu�[���PK22�\�{<���|�2archive_util.cpython-38.pycnu�[���PK22�\�~��//T�2file_util.cpython-38.pycnu�[���PK22�\
d�"~6~6��2cmd.cpython-38.opt-1.pycnu�[���PK32�\xQ%udd�3version.cpython-38.opt-1.pycnu�[���PK32�\%E�,}}A33bcppcompiler.cpython-38.pycnu�[���PK32�\
d�"~6~6	M3cmd.cpython-38.pycnu�[���PK32�\�fIx��Ƀ3file_util.cpython-38.opt-2.pycnu�[���PK32�\|�����3spawn.cpython-38.pycnu�[���PK32�\�(���A�A%�3ccompiler.cpython-38.opt-2.pycnu�[���PK32�\/h��hDhDU�3msvc9compiler.cpython-38.pycnu�[���PK32�\6��1�2�2	.4_msvccompiler.cpython-38.pycnu�[���PK32�\�Z@+n/n/�`4sysconfig.cpython-38.pycnu�[���PK32�\�v��
�
��4dep_util.cpython-38.opt-1.pycnu�[���PK32�\��˰����4spawn.cpython-38.opt-2.pycnu�[���PK32�\����)�)ª4fancy_getopt.cpython-38.pycnu�[���PK32�\O�

��4extension.cpython-38.pycnu�[���PK32�\�u�3&3&�4filelist.cpython-38.opt-1.pycnu�[���PK32�\4#�Z���5dir_util.cpython-38.opt-1.pycnu�[���PK32�\��ES���-5debug.cpython-38.pycnu�[���PK32�\�Ɓ�k
k
�.5extension.cpython-38.opt-2.pycnu�[���PK32�\���G��S<5ccompiler.cpython-38.pycnu�[���PK32�\�5������5core.cpython-38.opt-1.pycnu�[���PK32�\`=x��!��5archive_util.cpython-38.opt-2.pycnu�[���PK32�\�VH9�-�-"��5_msvccompiler.cpython-38.opt-2.pycnu�[���PK42�\�$�

�6text_file.cpython-38.opt-2.pycnu�[���PK42�\�x�a
a
%Q&6versionpredicate.cpython-38.opt-2.pycnu�[���PK42�\
8$ow
w
16dir_util.cpython-38.opt-2.pycnu�[���PK42�\�
�,JJ�>6unixccompiler.cpython-38.pycnu�[���PK42�\\�p���aZ6version.cpython-38.pycnu�[���PK42�\%E�,}}!8w6bcppcompiler.cpython-38.opt-1.pycnu�[���PK42�\4��!�
�
�6config.cpython-38.pycnu�[���PK42�\�T� � �6text_file.cpython-38.opt-1.pycnu�[���PK42�\�6�m2m2"I�6_msvccompiler.cpython-38.opt-1.pycnu�[���PK42�\���~�!�!�6cygwinccompiler.cpython-38.pycnu�[���PK42�\�{<���!�7archive_util.cpython-38.opt-1.pycnu�[���PK42�\0�oa�����.7dist.cpython-38.pycnu�[���PK42�\LvV�00۵7config.cpython-38.opt-2.pycnu�[���PK42�\kLjGsbsbV�7dist.cpython-38.opt-2.pycnu�[���PK42�\��(S��%8filelist.cpython-38.opt-2.pycnu�[���PK42�\��ES��[@8debug.cpython-38.opt-2.pycnu�[���PK42�\|�W�!�!iA8sysconfig.cpython-38.opt-2.pycnu�[���PK42�\zw�\HH$�c8cygwinccompiler.cpython-38.opt-2.pycnu�[���PK42�\U�����"$8unixccompiler.cpython-38.opt-2.pycnu�[���PK42�\�Z@+n/n/K�8sysconfig.cpython-38.opt-1.pycnu�[���PK42�\�v��
�
�8dep_util.cpython-38.pycnu�[���PK42�\�T� � ��8text_file.cpython-38.pycnu�[���PK42�\��ES��+�8debug.cpython-38.opt-1.pycnu�[���PK42�\���~�!�!$9�8cygwinccompiler.cpython-38.opt-1.pycnu�[���PK42�\�YyF�&�&39filelist.cpython-38.pycnu�[���PK42�\���^3^3!>9msvccompiler.cpython-38.opt-2.pycnu�[���PK=�\ϤУ�q9base_futures.cpython-36.pycnu�[���PK=�\�������z9base_events.cpython-36.pycnu�[���PK=�\�������:subprocess.cpython-36.opt-2.pycnu�[���PK=�\����N�N3.:sslproto.cpython-36.opt-1.pycnu�[���PK=�\�%�O�S�S#/}:windows_events.cpython-36.opt-1.pycnu�[���PK=�\6߾ê�z�:subprocess.cpython-36.pycnu�[���PK=�\�R�ӸA�Am�:proactor_events.cpython-36.pycnu�[���PK=�\G��4GGs.;base_tasks.cpython-36.pycnu�[���PK=�\H�V1  6;coroutines.cpython-36.opt-2.pycnu�[���PK=�\�`���hV;protocols.cpython-36.opt-2.pycnu�[���PK=�\�H�O�O#d_;windows_events.cpython-36.opt-2.pycnu�[���PK=�\C�s//W�;transports.cpython-36.opt-1.pycnu�[���PK=�\{fU�����;constants.cpython-36.opt-2.pycnu�[���PK=�\��o�5�5��;futures.cpython-36.pycnu�[���PK=�\���ee"�<windows_utils.cpython-36.opt-2.pycnu�[���PK=�\�;�.4.4�(<streams.cpython-36.opt-2.pycnu�[���PK=�\�»��]<subprocess.cpython-36.opt-1.pycnu�[���PK=�\��yOyO�w<sslproto.cpython-36.pycnu�[���PK=�\K�[[��<protocols.cpython-36.opt-1.pycnu�[���PK=�\�E(�ggF�<compat.cpython-36.opt-2.pycnu�[���PK=�\"4�����<queues.cpython-36.opt-2.pycnu�[���PK=�\1<���J�J�<tasks.cpython-36.pycnu�[���PK=�\��� � �B=coroutines.cpython-36.opt-1.pycnu�[���PK=�\����j#j#$d=base_subprocess.cpython-36.opt-2.pycnu�[���PK=�\5�h�@�@$Ї=proactor_events.cpython-36.opt-1.pycnu�[���PK=�\Y����#�=futures.cpython-36.opt-2.pycnu�[���PK=�\6����D�DA�=events.cpython-36.opt-2.pycnu�[���PK=�\3'~��!�,>base_futures.cpython-36.opt-2.pycnu�[���PK=�\��z�4�43>futures.cpython-36.opt-1.pycnu�[���PK=�\�>B��h>transports.cpython-36.opt-2.pycnu�[���PK=�\Ea�#mm$�>selector_events.cpython-36.opt-2.pycnu�[���PK=�\��ь��M�>constants.cpython-36.opt-1.pycnu�[���PK=�\�pä�b�b��>events.cpython-36.pycnu�[���PK=�\�x�mDmD�S?test_utils.cpython-36.opt-1.pycnu�[���PK=�\��t�GsGs$��?selector_events.cpython-36.opt-1.pycnu�[���PK=�\�a��Z<Z<0@locks.cpython-36.pycnu�[���PK=�\��ېb�b�H@events.cpython-36.opt-1.pycnu�[���PK=�\ϤУ!��@base_futures.cpython-36.opt-1.pycnu�[���PK=�\�������@compat.cpython-36.opt-1.pycnu�[���PK=�\P���ŘŘ $�@base_events.cpython-36.opt-1.pycnu�[���PK=�\�a��Z<Z<9PAlocks.cpython-36.opt-1.pycnu�[���PK=�\D��o?o?$݌Aproactor_events.cpython-36.opt-2.pycnu�[���PK=�\G��4GG��Abase_tasks.cpython-36.opt-1.pycnu�[���PK=�\s�58�s�s6�Aselector_events.cpython-36.pycnu�[���PK=�\K�[[HBprotocols.cpython-36.pycnu�[���PK=�\�#�~� � �_Bqueues.cpython-36.pycnu�[���PK=�\P�f�#�#$ÀBbase_subprocess.cpython-36.opt-1.pycnu�[���PK=�\Q*_//�Btransports.cpython-36.pycnu�[���PK=�\�����N�Blog.cpython-36.opt-1.pycnu�[���PK=�\�����r�Blog.cpython-36.pycnu�[���PK=�\�������Bcompat.cpython-36.pycnu�[���PK=�\�%�O�S�S��Bwindows_events.cpython-36.pycnu�[���PK=�\$��dvv �-Cunix_events.cpython-36.opt-1.pycnu�[���PK=�\4]�j!j!N�Ccoroutines.cpython-36.pycnu�[���PK=�\	��[?[?�Ctest_utils.cpython-36.opt-2.pycnu�[���PK=�\G��4GG�Dbase_tasks.cpython-36.opt-2.pycnu�[���PK=�\i|MZ�.�.A
Dtasks.cpython-36.opt-2.pycnu�[���PK=�\h8�"��"y<Dwindows_utils.cpython-36.opt-1.pycnu�[���PK=�\�gғg�g yQDunix_events.cpython-36.opt-2.pycnu�[���PK=�\/F\:\�Dwindows_utils.cpython-36.pycnu�[���PK=�\�X��"�"��Dlocks.cpython-36.opt-2.pycnu�[���PK=�\������Dlog.cpython-36.opt-2.pycnu�[���PK=�\��ь����Dconstants.cpython-36.pycnu�[���PK=�\�ny�0$0$�Dbase_subprocess.cpython-36.pycnu�[���PK=�\VWX�EE�Etest_utils.cpython-36.pycnu�[���PK=�\��S�zz �]Ebase_events.cpython-36.opt-2.pycnu�[���PK=�\�#�~� � O�Equeues.cpython-36.opt-1.pycnu�[���PK=�\#���]w]wp�Eunix_events.cpython-36.pycnu�[���PK=�\����M�MqFstreams.cpython-36.pycnu�[���PK=�\mʀ��L�L*�Fstreams.cpython-36.opt-1.pycnu�[���PK=�\ U��44*Gsslproto.cpython-36.opt-2.pycnu�[���PK=�\�f��I�Ix@Gtasks.cpython-36.opt-1.pycnu�[���PK��\�Q9����Gentities.cpython-36.opt-1.pycnu�[���PK��\�˫Q__PHparser.cpython-36.opt-1.pycnu�[���PK��\�˫Q__�fHparser.cpython-36.pycnu�[���PK��\�x�D����S}Hentities.cpython-36.opt-2.pycnu�[���PK��\��U��
�
}BIparser.cpython-36.opt-2.pycnu�[���PK��\�Q9��[MIentities.cpython-36.pycnu�[���PKb��\�N�xx�Jiterators.cpython-36.opt-1.pycnu�[���PKb��\��Y�;�;yJ_policybase.cpython-36.pycnu�[���PKb��\��8�%�%{VJpolicy.cpython-36.opt-1.pycnu�[���PKb��\���AjjZ|Jencoders.cpython-36.pycnu�[���PKb��\M��v�R�R#�Jheaderregistry.cpython-36.opt-1.pycnu�[���PKb��\R���F�Jbase64mime.cpython-36.opt-1.pycnu�[���PKb��\l�Ɠzz#)�Jcontentmanager.cpython-36.opt-1.pycnu�[���PKb��\+M�

��Jiterators.cpython-36.opt-2.pycnu�[���PKb��\�=�8�$�$NKutils.cpython-36.opt-2.pycnu�[���PKb��\�N�xxk*Kiterators.cpython-36.pycnu�[���PKb��\v��K
K
+2Kpolicy.cpython-36.opt-2.pycnu�[���PKb��\��b@b@�?Kheader.cpython-36.pycnu�[���PKb��\�٢,e%e%h�Kgenerator.cpython-36.opt-2.pycnu�[���PKb��\��_j�j��Kmessage.cpython-36.opt-1.pycnu�[���PKb��\R�9~Z)Z))�:L_header_value_parser.cpython-36.opt-1.pycnu�[���PKb��\�� S S�dMheaderregistry.cpython-36.pycnu�[���PKb��\E��=�Mquoprimime.cpython-36.opt-1.pycnu�[���PKb��\p�JjmmB�Mquoprimime.cpython-36.opt-2.pycnu�[���PKb��\���"��Mcharset.cpython-36.opt-2.pycnu�[���PKb��\��á�_�Merrors.cpython-36.opt-2.pycnu�[���PKb��\JO(X�,�,KNcharset.cpython-36.opt-1.pycnu�[���PKb��\p`a�{"{"k;Nfeedparser.cpython-36.opt-2.pycnu�[���PKb��\E��=5^Nquoprimime.cpython-36.pycnu�[���PKb��\��-K�0�0�|N_parseaddr.cpython-36.opt-1.pycnu�[���PKb��\Ol�����)��N_header_value_parser.cpython-36.opt-2.pycnu�[���PKc��\��-K�0�0�O_parseaddr.cpython-36.pycnu�[���PKc��\]䕟���Oerrors.cpython-36.opt-1.pycnu�[���PKc��\�ǜD�)�)#�O_header_value_parser.cpython-36.pycnu�[���PKc��\y�����#Q_encoded_words.cpython-36.opt-1.pycnu�[���PKc��\�>��3�3%!Qutils.cpython-36.opt-1.pycnu�[���PKc��\��~j*j*UQheader.cpython-36.opt-2.pycnu�[���PKc��\�	5T�,�,�Qcharset.cpython-36.pycnu�[���PKc��\J��]<]<#��Qheaderregistry.cpython-36.opt-2.pycnu�[���PKc��\Z�a��Qencoders.cpython-36.opt-2.pycnu�[���PKc��\l�Ɠzz#�Qcontentmanager.cpython-36.opt-2.pycnu�[���PKc��\��b@b@�Rheader.cpython-36.opt-1.pycnu�[���PKc��\�Z��)�)|LRfeedparser.cpython-36.pycnu�[���PKc��\l�Ɠzz[vRcontentmanager.cpython-36.pycnu�[���PKc��\��Y�;�; "�R_policybase.cpython-36.opt-1.pycnu�[���PKc��\��8�%�%*�Rpolicy.cpython-36.pycnu�[���PKc��\V�74�3�3�Rgenerator.cpython-36.opt-1.pycnu�[���PKc��\�$f�(�(&)Sfeedparser.cpython-36.opt-1.pycnu�[���PKc��\"}Htt#qRS_encoded_words.cpython-36.opt-2.pycnu�[���PKc��\���Ajj8aSencoders.cpython-36.opt-1.pycnu�[���PKc��\]䕟���gSerrors.cpython-36.pycnu�[���PKc��\y������S_encoded_words.cpython-36.pycnu�[���PKc��\b�UC%C%!�S_parseaddr.cpython-36.opt-2.pycnu�[���PKc��\9T*����Sbase64mime.cpython-36.opt-2.pycnu�[���PKc��\�>��3�3��Sutils.cpython-36.pycnu�[���PKc��\��3��S�S��Smessage.cpython-36.opt-2.pycnu�[���PKc��\Hsn�� fJT_policybase.cpython-36.opt-2.pycnu�[���PKc��\V�74�3�36bTgenerator.cpython-36.pycnu�[���PKc��\��_j�j�S�Tmessage.cpython-36.pycnu�[���PKc��\R���+Ubase64mime.cpython-36.pycnu�[���PK��\^b�ZHH�7Udump.cpython-36.opt-2.pycnu�[���PK��\�!j�||q>Udump.cpython-36.pycnu�[���PK��\��'��	�	0FUdbapi2.cpython-36.pycnu�[���PK��\�!j�||PUdump.cpython-36.opt-1.pycnu�[���PK��\��'��	�	�WUdbapi2.cpython-36.opt-1.pycnu�[���PK��\��'��	�	�aUdbapi2.cpython-36.opt-2.pycnu�[���PKg�\l
��~~�kUserver.cpython-36.pycnu�[���PKg�\m$�w�>�>(�Ucookies.cpython-36.opt-1.pycnu�[���PKg�\���0�0�^)Vclient.cpython-36.opt-1.pycnu�[���PKg�\l
��~~ٲVserver.cpython-36.opt-1.pycnu�[���PKg�\��yi??<1Wcookies.cpython-36.pycnu�[���PKg�\�-�fdfd�pWclient.cpython-36.opt-2.pycnu�[���PKg�\�>��?�?�M�Wcookiejar.cpython-36.opt-1.pycnu�[���PKg�\�w3��O�OڧXserver.cpython-36.opt-2.pycnu�[���PKg�\�ǫ�a-a-��Xcookies.cpython-36.opt-2.pycnu�[���PKg�\t�]�	�	�_%Ycookiejar.cpython-36.opt-2.pycnu�[���PKg�\;mj�������Ycookiejar.cpython-36.pycnu�[���PKg�\:v~�����Zclient.cpython-36.pycnu�[���PK*�\D��@�*�*�[simpledialog.cpython-38.pycnu�[���PK*�\ҧ����	C[dialog.cpython-38.pycnu�[���PK*�\b
p�nnI[ttk.cpython-38.opt-2.pycnu�[���PK*�\[_��S
S
u�[messagebox.cpython-38.opt-2.pycnu�[���PK+�\��00�[filedialog.cpython-38.opt-1.pycnu�[���PK+�\寉�CC!w�[colorchooser.cpython-38.opt-2.pycnu�[���PK+�\��z`,,�[dnd.cpython-38.opt-1.pycnu�[���PK+�\M�С�S#\font.cpython-38.opt-1.pycnu�[���PK+�\M�С�=<\font.cpython-38.pycnu�[���PK+�\v��ZZ!U\commondialog.cpython-38.pycnu�[���PK+�\��00�Y\filedialog.cpython-38.pycnu�[���PK+�\ҧ���� �\dialog.cpython-38.opt-1.pycnu�[���PK+�\�(1616-�\tix.cpython-38.pycnu�[���PK+�\v��ZZ!��]commondialog.cpython-38.opt-1.pycnu�[���PK+�\�T—|�|�K�]ttk.cpython-38.opt-1.pycnu�[���PK+�\�(1616�^tix.cpython-38.opt-1.pycnu�[���PK+�\�#�N����_colorchooser.cpython-38.pycnu�[���PK+�\s����!��_scrolledtext.cpython-38.opt-1.pycnu�[���PK+�\ҧ����u�_dialog.cpython-38.opt-2.pycnu�[���PK+�\v��ZZ!��_commondialog.cpython-38.opt-2.pycnu�[���PK+�\V�Fi-�_font.cpython-38.opt-2.pycnu�[���PK+�\�T—|�|�{`ttk.cpython-38.pycnu�[���PK+�\���i�(�(9�`filedialog.cpython-38.opt-2.pycnu�[���PK+�\�#�N��!zacolorchooser.cpython-38.opt-1.pycnu�[���PK+�\wbh^��� adnd.cpython-38.opt-2.pycnu�[���PK+�\D��@�*�*!�9asimpledialog.cpython-38.opt-1.pycnu�[���PK+�\�1&����damessagebox.cpython-38.opt-1.pycnu�[���PK+�\�1&����pamessagebox.cpython-38.pycnu�[���PK+�\z��YVV!�|ascrolledtext.cpython-38.opt-2.pycnu�[���PK+�\��z`,,q�adnd.cpython-38.pycnu�[���PK+�\ ���I�I���atix.cpython-38.opt-2.pycnu�[���PK+�\�x��2$2$!D�bsimpledialog.cpython-38.opt-2.pycnu�[���PK+�\s����Ƿbscrolledtext.cpython-38.pycnu�[���PKq#�\=տ��btool.cpython-36.pycnu�[���PKq#�\ީi����btool.cpython-36.opt-2.pycnu�[���PKq#�\�.kW�&�&�bdecoder.cpython-36.pycnu�[���PKq#�\N�TM�+�+=�bencoder.cpython-36.opt-1.pycnu�[���PKq#�\N�TM�+�+�cencoder.cpython-36.pycnu�[���PKq#�\�������Kcscanner.cpython-36.pycnu�[���PKq#�\�������Scscanner.cpython-36.opt-1.pycnu�[���PKq#�\��]����[cscanner.cpython-36.opt-2.pycnu�[���PKq#�\=տ�cctool.cpython-36.opt-1.pycnu�[���PKq#�\�.kW�&�&�icdecoder.cpython-36.opt-1.pycnu�[���PKq#�\���� �cencoder.cpython-36.opt-2.pycnu�[���PKq#�\f	n��h�cdecoder.cpython-36.opt-2.pycnu�[���PK86�\�W�~�~e�ctopics.cpython-38.opt-1.pycnu�[���PK86�\�W�~�~6Bjtopics.cpython-38.pycnu�[���PK86�\�W�~�~�ptopics.cpython-38.opt-2.pycnu�[���PK�@�\��P2���?wresponse.cpython-36.opt-1.pycnu�[���PK�@�\��d��
�
�Lwerror.cpython-36.opt-1.pycnu�[���PK�@�\3<�Z
Z
�Wwresponse.cpython-36.opt-2.pycnu�[���PK�@�\pl�	2�2�qbwrequest.cpython-36.opt-2.pycnu�[���PK�@�\�
����Nxrobotparser.cpython-36.pycnu�[���PK�@�\�2`zz�jxrequest.cpython-36.opt-1.pycnu�[���PK�@�\>edd��yparse.cpython-36.opt-2.pycnu�[���PK�@�\���;!!��yerror.cpython-36.opt-2.pycnu�[���PK�@�\�
��� B�yrobotparser.cpython-36.opt-1.pycnu�[���PK�@�\��d��
�
zerror.cpython-36.pycnu�[���PK�@�\�I�����'zparse.cpython-36.pycnu�[���PK�@�\��P2���zresponse.cpython-36.pycnu�[���PK�@�\w��33 ��zrobotparser.cpython-36.opt-2.pycnu�[���PK�@�\�����zrequest.cpython-36.pycnu�[���PK�@�\�I�������{parse.cpython-36.opt-1.pycnu�[���PK�[�\�`7�k|btm_matcher.cpython-38.pycnu�[���PK�[�\��f|btm_utils.cpython-38.opt-1.pycnu�[���PK�[�\-8e��s�|pygram.cpython-38.opt-1.pycnu�[���PK�[�\����|patcomp.cpython-38.opt-1.pycnu�[���PK�[�\�`7 �|btm_matcher.cpython-38.opt-1.pycnu�[���PK�[�\���__n�|pytree.cpython-38.pycnu�[���PK�[�\�`�~�� �$}btm_matcher.cpython-38.opt-2.pycnu�[���PK�[�\8C�24'4'2}fixer_util.cpython-38.opt-2.pycnu�[���PK�[�\��B!!�Y}pygram.cpython-38.opt-2.pycnu�[���PK�[�\��f�]}btm_utils.cpython-38.pycnu�[���PK�[�\0�F�/�/Fv}fixer_util.cpython-38.opt-1.pycnu�[���PK�[�\�o�m:m:=�}pytree.cpython-38.opt-2.pycnu�[���PK�[�\��IW�?�?��}refactor.cpython-38.opt-2.pycnu�[���PK�[�\��M*�O�O-!~refactor.cpython-38.opt-1.pycnu�[���PK�[�\Kuw�  3q~btm_utils.cpython-38.opt-2.pycnu�[���PK�[�\����O�O��~refactor.cpython-38.pycnu�[���PK�[�\�b�h��~patcomp.cpython-38.opt-2.pycnu�[���PK�[�\-8e��)�~pygram.cpython-38.pycnu�[���PK�[�\��;�
�
\�~fixer_base.cpython-38.opt-2.pycnu�[���PK�[�\0�F�/�/[�~fixer_util.cpython-38.pycnu�[���PK�[�\�-M		L*patcomp.cpython-38.pycnu�[���PK�[�\��l\l\�@pytree.cpython-38.opt-1.pycnu�[���PK�[�\R=o�ooR�fixer_base.cpython-38.pycnu�[���PK�[�\R=o�oo
�fixer_base.cpython-38.opt-1.pycnu�[���PK��\ɂ�jj��tool.cpython-38.opt-1.pycnu�[���PK��\�]Ɗ��{�scanner.cpython-38.opt-1.pycnu�[���PK��\#ӽx}}h�scanner.cpython-38.opt-2.pycnu�[���PK��\�E��1�decoder.cpython-38.opt-2.pycnu�[���PK��\ɂ�jj^�tool.cpython-38.pycnu�[���PK��\(�#�EE�tool.cpython-38.opt-2.pycnu�[���PK��\e4�"v&v&��decoder.cpython-38.pycnu�[���PK��\e4�"v&v&U2�decoder.cpython-38.opt-1.pycnu�[���PK��\�n0�+�+Y�encoder.cpython-38.pycnu�[���PK��\�n0�+�+��encoder.cpython-38.opt-1.pycnu�[���PK��\��{���encoder.cpython-38.opt-2.pycnu�[���PK��\�]Ɗ���ˀscanner.cpython-38.pycnu�[���PK66\��Ӏ