Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/email/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`s�dZddlmZddlmZddlmZddlmZddlmZddlm Z ddl
mZdd l
mZdd
l
m
Zdefd��YZd
efd��YZdefd��YZd�Zdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZd
efd!��YZd"efd#��YZd$efd%��YZd&efd'��YZd(efd)��YZd*efd+��YZ
ied,6ed-6ed.6ed/6ed06ed16ed26ed36ed46ed56ed66ed76ed86ed96ed:6ed;6ed<6ed=6e
d>6Z!d?efd@��YZ"dAS(Bu;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.
i(tunicode_literals(tdivision(tabsolute_import(tsuper(tstr(ttext_to_native_str(tutils(terrors(t_header_value_parsertAddresscB`steZdddd d�Zed��Zed��Zed��Zed��Zd�Z d�Z
d�ZRS(
ucC`s�|dk r�|s|r'td��ntj|�\}}|r]tdj||���n|jrv|jd�n|j}|j}n||_ ||_
||_dS(u�Create an object represeting 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.
u=addrspec specified when username and/or domain also
specifiedu6Invalid addr_spec; only '{}' could be parsed from
'{}'iN(tNonet TypeErrortparsert
get_addr_spect
ValueErrortformattall_defectst
local_parttdomaint
_display_namet _usernamet_domain(tselftdisplay_nametusernameRt addr_specta_strest((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt__init__s cC`s|jS(N(R(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR<scC`s|jS(N(R(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR@scC`s|jS(N(R(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRDscC`srt|j�}t|�t|tj�krCtj|j�}n |j}|jrd|d|jS|sndS|S(u�The
addr_spec (username@domain) portion of the address, quoted
according to RFC 5322 rules, but with no Content Transfer Encoding.
u@u<>(tsetRtlenRt
DOT_ATOM_ENDStquote_stringR(Rtnamesettlp((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRHs cC`sdj|j|j|j�S(Nu6Address(display_name={!r},
username={!r},
domain={!r})(RRRR(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt__repr__XscC`s�t|j�}t|�t|tj�krCtj|j�}n |j}|r�|jdkrgdn|j}dj||�S|jS(Nu<>uu{}
<{}>(RRRRtSPECIALSR
RR(RR!tdispR((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt__str__\s cC`sPt|�t|�krtS|j|jkoO|j|jkoO|j|jkS(N(ttypetFalseRRR(Rtother((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt__eq__gs
N(t__name__t
__module__R
RtpropertyRRRRR#R&R*(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR s% tGroupcB`sPeZddd�Zed��Zed��Zd�Zd�Zd�Z RS(cC`s+||_|rt|�nt�|_dS(uCreate
an object representing an address group.
An address group consists of a display_name followed by colon and
an
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(Rttuplet
_addresses(RRt addresses((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRqs cC`s|jS(N(R(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR�scC`s|jS(N(R0(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR1�scC`sdj|j|j�S(Nu'Group(display_name={!r},
addresses={!r}(RRR1(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR#�scC`s�|jdkr5t|j�dkr5t|jd�S|j}|dk r�t|�}t|�t|tj�kr�tj|�}q�ndj d�|jD��}|r�d|n|}dj
||�S(Niiu,
cs`s|]}t|�VqdS(N(R(t.0tx((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pys <genexpr>�su
u{}:{};(RR
RR1RRRR$R
tjoinR(RR%R!tadrstr((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR&�s$ cC`s>t|�t|�krtS|j|jko=|j|jkS(N(R'R(RR1(RR)((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR*�sN(
R+R,R
RR-RR1R#R&R*(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR.os t
BaseHeadercB`s_eZdZd�Zd�Zed��Zed��Zd�Ze d��Z
d�ZRS(u|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.
cC`stigd6}|j||�tj|d�rJtj|d�|d<ntj||d�}|j||�|S(Nudefectsudecoded(tparseRt_has_surrogatest _sanitizeRt__new__tinit(tclstnametvaluetkwdsR((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR:�s
cK`sA|d}|d=|d}|d=||_||_||_dS(Nudefectsu
parse_tree(t_namet_parse_treet_defects(RR=t_3to2kwargstdefectst
parse_tree((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;�s
cC`s|jS(N(R@(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR=�scC`s
t|j�S(N(R/RB(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRD�scC`s+t|jj|jjt|�f|jfS(N(t_reconstruct_headert __class__R+t __bases__Rt__dict__(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt
__reduce__�s
cC`stj||�S(N(RR:(R<R>((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt_reconstruct�scK`s~|d}|d=tjtjtj|jd�tjdd�g�tjtjdd�g�|jg�}|jd|�S(Nupolicyuheader-nameu:u
header-sepu
ufwstpolicy( RtHeadertHeaderLabelt
ValueTerminalR=tCFWSListtWhiteSpaceTerminalRAtfold(RRCRLtheader((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRR�s
(R+R,t__doc__R:R;R-R=RDRJtclassmethodRKRR(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR6�s
cC`stt|�|i�j|�S(N(R'RRK(tcls_nametbasesR>((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRFstUnstructuredHeadercB`s,eZdZeej�Zed��Z RS(cC`s+|j|�|d<t|d�|d<dS(Nu
parse_treeudecoded(tvalue_parserR(R<R>R?((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR7sN(
R+R,R
t max_counttstaticmethodRtget_unstructuredRYRUR7(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRXstUniqueUnstructuredHeadercB`seZdZRS(i(R+R,RZ(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR]st
DateHeadercB`sJeZdZdZeej�Ze d��Z
d�Zed��Z
RS(u�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.
cC`s�|sE|djtj��d|d<d|d<tj�|d<dSt|t�rftj |�}n||d<tj
|d�|d<|j|d�|d<dS(Nudefectsudatetimeuudecodedu
parse_tree(tappendRtHeaderMissingRequiredValueR
Rt TokenListt
isinstanceRRtparsedate_to_datetimetformat_datetimeRY(R<R>R?((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR7,s
cO`s)|jd�|_t�j||�dS(Nudatetime(tpopt _datetimeRR;(Rtargstkw((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;:scC`s|jS(N(Rf(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pytdatetime>sN(R+R,RTR
RZR[RR\RYRUR7R;R-Ri(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR^s tUniqueDateHeadercB`seZdZRS(i(R+R,RZ(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRjCst
AddressHeadercB`sSeZdZed��Zed��Zd�Ze d��Z
e d��ZRS(cC`s,tj|�\}}|s(td��|S(Nuthis should
not
happen(Rtget_address_listtAssertionError(R>taddress_list((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRYLsc
C`smt|t�r�|j|�|d<}g}xg|jD]\}|jt|jg|jD]3}t|jpjd|j pvd|j
p�d�^qU��q6Wt|j�}n[t
|d�s�|g}ng|D]-}t
|d�s�td|g�n|^q�}g}||d<||d<djg|D]}t|�^q$�|d<d|kri|j|d�|d<ndS( Nu
parse_treeuu__iter__u addressesugroupsudefectsu,
udecoded(RbRRYR1R_R.Rt
all_mailboxesR RRtlistRthasattrR
R4( R<R>R?RntgroupstaddrtmbRDtitem((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR7Rs$H7
,cO`s8t|jd��|_d|_t�j||�dS(Nugroups(R/Ret_groupsR
R0RR;(RRgRh((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;ns cC`s|jS(N(Rv(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRrsscC`sN|jdkrGtg|jD]}|jD]}|^q)q�|_n|jS(N(R0R
R/RvR1(Rtgrouptaddress((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR1ws%N(R+R,R
RZR[RYRUR7R;R-RrR1(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRkHs tUniqueAddressHeadercB`seZdZRS(i(R+R,RZ(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRystSingleAddressHeadercB`seZed��ZRS(cC`s;t|j�dkr0tdj|j���n|jdS(Niu9value
of single address header {} is not a single
addressi(RR1RRR=(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRx�s (R+R,R-Rx(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyRz�stUniqueSingleAddressHeadercB`seZdZRS(i(R+R,RZ(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR{�stMIMEVersionHeadercB`sbeZdZeej�Zed��Zd�Z e
d��Ze
d��Ze
d��Z
RS(icC`s�|j|�|d<}t|�|d<|dj|j�|jdkrPdn|j|d<|j|d<|jdk r�dj|d|d�|d<n
d|d<dS(Nu
parse_treeudecodedudefectsumajoruminoru{}.{}uversion(RYRtextendRtminorR
tmajorR(R<R>R?RE((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR7�s"
!cO`sM|jd�|_|jd�|_|jd�|_t�j||�dS(Nuversionumajoruminor(Ret_versiont_majort_minorRR;(RRgRh((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;�scC`s|jS(N(R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR�scC`s|jS(N(R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR~�scC`s|jS(N(R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pytversion�s(R+R,RZR[Rtparse_mime_versionRYRUR7R;R-RR~R�(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR|�s tParameterizedMIMEHeadercB`s5eZdZed��Zd�Zed��ZRS(icC`sx|j|�|d<}t|�|d<|dj|j�|jdkrWi|d<ntd�|jD��|d<dS(Nu
parse_treeudecodedudefectsuparamscs`s9|]/\}}tj|�j�tj|�fVqdS(N(RR9tlower(R2R=R>((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pys <genexpr>�s(RYRR}RtparamsR
tdict(R<R>R?RE((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR7�s
cO`s)|jd�|_t�j||�dS(Nuparams(Ret_paramsRR;(RRgRh((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;�scC`s
|jj�S(N(R�tcopy(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��s(R+R,RZRUR7R;R-R�(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��s
tContentTypeHeadercB`sMeZeej�Zd�Zed��Zed��Z ed��Z
RS(cO`sGt�j||�tj|jj�|_tj|jj�|_dS(N( RR;RR9RAtmaintypet _maintypetsubtypet_subtype(RRgRh((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;�scC`s|jS(N(R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��scC`s|jS(N(R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��scC`s|jd|jS(Nu/(R�R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pytcontent_type�s(R+R,R[Rtparse_content_type_headerRYR;R-R�R�R�(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��s
tContentDispositionHeadercB`s/eZeej�Zd�Zed��ZRS(cO`sGt�j||�|jj}|dkr1|ntj|�|_dS(N(RR;RAtcontent_dispositionR
RR9t_content_disposition(RRgRhtcd((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;�scC`s|jS(N(R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��s( R+R,R[Rt
parse_content_disposition_headerRYR;R-R�(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��s tContentTransferEncodingHeadercB`sDeZdZeej�Zed��Zd�Z e
d��ZRS(icC`s?|j|�|d<}t|�|d<|dj|j�dS(Nu
parse_treeudecodedudefects(RYRR}R(R<R>R?RE((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR7�scO`s/t�j||�tj|jj�|_dS(N(RR;RR9RAtctet_cte(RRgRh((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR;scC`s|jS(N(R�(R((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR� s(R+R,RZR[Rt&parse_content_transfer_encoding_headerRYRUR7R;R-R�(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR��s
usubjectudateuresent-dateu orig-dateusenderu
resent-senderutou resent-touccu resent-ccubccu
resent-bccufromuresent-fromureply-toumime-versionucontent-typeucontent-dispositionucontent-transfer-encodingtHeaderRegistrycB`s;eZdZeeed�Zd�Zd�Zd�Z RS(u%A
header_factory and header
registry.cC`s8i|_||_||_|r4|jjt�ndS(u�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(tregistryt
base_classt
default_classtupdatet_default_header_map(RR�R�tuse_default_map((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR*s
cC`s||j|j�<dS(uLRegister cls as the specialized
class for handling "name" headers.
N(R�R�(RR=R<((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pytmap_to_type<scC`sD|jj|j�|j�}ttd|j�||jfi�S(Nu_(R�tgetR�R�R'RR+R�(RR=R<((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt__getitem__BscC`s||||�S(u�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.
((RR=R>((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt__call__Fs
(
R+R,RTR6RXtTrueRR�R�R�(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyR�&s N(#RTt
__future__RRRtfuture.builtinsRRtfuture.utilsRtfuture.backports.emailRRRRtobjectR R.R6RFRXR]R^RjRkRyRzR{R|R�R�R�R�R�R�(((sI/usr/lib/python2.7/site-packages/future/backports/email/headerregistry.pyt<module> s^Z5d '7
%