�
Ϫ�f�9 � �� � d Z ddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlm
Z
mZ ddlmZ ddlmZ ddlmZmZmZ ddlmZ ddlmZ dd lmZmZ dd
lmZm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z) dd
l*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z=m>Z>m?Z@mAZBmCZDmEZFmGZHmIZJmKZLmMZNmOZOmPZQ ddlRmSZSmTZT ddlUmVZVmWZW ddlXmYZYmZZZm[Z[m\Z\m]Z] e^ e_ e`dd� dj� � � � Zbd� Zcd� Zd G d� d� Ze G d� d� Zf G d� d� Zg G d� d� Zh G d� d � Zid!Zj ek e e`d"� e`d#d$� � � Zld%ejz elz Zmemj� d&� Zo ej� d'eoz d(z � Zq ekd)� e`d$� D � � Zr eeF� G d*� d+eSj� eTj� � � Zu e j� � Zw eeF� G d,� d-eSj� eTj� � � Zxdwd.�Zyd/Zzd0Z{e|Z}dxd1�Z~d2� Zd3� Z�dwd4�Z�d5� Z�d6� Z�d7� Z�dyd8�Z�d9� Z�d:ekd;ekfd<�Z� G d=� d>� Z�d?Z�d@� Z�dA� Z�dB� Z�dC� Z�dD� Z� ee=� G dE� dF� � Z� eeO� G dG� dHe�� � Z�dIdJdKdLdMdN�Z�dO� Z�dP� Z�dQ� Z�dR� Z�dS� Z�dT� Z�dU� Z� G dV� dW� Z� G dX� dYe�� Z� G dZ� d[e�� Z� G d\� d]e�� Z� G d^� d_e�� Z�dzd`�Z�da� Z�db� Z�dc� Z� G dd� de� Z� G df� dg� Z� G dh� di� Z�dj� Z� e�e�dkdl� � Z�dm� Z�dn� Z�dwdo�Z�dwdp�Z� G dq� dre�jZ � Z� G ds� dte�j\ � Z� e�j^ e�e�e�e�� Z�du� Z� e�jd e�� g dv�Z�y){a�
An IMAP4 protocol implementation
@author: Jp Calderone
To do::
Suspend idle timeout while server is processing
Use an async message parser instead of buffering in memory
Figure out a way to not queue multi-message client requests (Flow? A simple callback?)
Clarify some API docs (Query, etc)
Make APPEND recognize (again) non-existent mailboxes before accepting the literal
� N)�decodebytes�encodebytes)�BytesIO)�chain)�Any�List�cast)�implementer)�credentials)�UnauthorizedLogin�UnhandledCredentials)�defer�error�
interfaces)�
maybeDeferred)�CramMD5ClientAuthenticator�LOGINAuthenticator�LOGINCredentials�PLAINAuthenticator�PLAINCredentials)�IllegalClientResponse�IllegalIdentifierError�IllegalMailboxEncoding�IllegalOperation�IllegalQueryError�IllegalServerResponse�IMAP4Exception�MailboxCollision�MailboxException�MismatchedNesting�MismatchedQuoting�NegativeResponse�
NoSuchMailbox�NoSupportedAuthentication�ReadOnlyMailbox�UnhandledResponse)�IAccountIMAP�IClientAuthentication�ICloseableMailboxIMAP�IMailboxIMAP�IMailboxIMAPInfo�IMailboxIMAPListener�IMessageIMAP�IMessageIMAPCopier�IMessageIMAPFile�IMessageIMAPPart�INamespacePresenter�ISearchableIMAPMailbox)�basic�policies)�log�text)�_get_async_param�_matchingString� iterbytes�nativeString�
networkString� �
z/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decc � � | |u r|S | S )z�
Swap C{this} with C{that} if C{this} is C{ifIs}.
@param this: The object that may be replaced.
@param that: The object that may replace C{this}.
@param ifIs: An object whose identity will be compared to
C{this}.
� )�this�that�ifIss �4/usr/lib/python3/dist-packages/twisted/mail/imap4.py�_swaprD ` s � � �4�<�4�)�T�)� c
�h � | D ��cg c] \ }}t |||� t |||� f��! c}}S c c}}w )a�
Swap each element in each pair in C{of} with C{that} it is
C{ifIs}.
@param of: A list of 2-L{tuple}s, whose members may be the object
C{that}
@type of: L{list} of 2-L{tuple}s
@param ifIs: An object whose identity will be compared to members
of each pair in C{of}
@return: A L{list} of 2-L{tuple}s with all occurences of C{ifIs}
replaced with C{that}
)rD )�ofrA rB �first�seconds rC �
_swapAllPairsrJ n s> |