MINI MINI MANI MO
3
  \O                 @   sj  d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd dZG dd	 d	Z	G d
d de
Zdd
 ZG dd dZ
G dd de
ZG dd dZG dd deZG dd dZG dd deZG dd deZG dd deZG dd dZG d d! d!ZG d"d# d#eZG d$d% d%eZG d&d' d'Zeeeeeeeeeeeeeeeeeeed(ZG d)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^   e Zd ZdddZedd Zedd Zed	d
 Zedd Zd
d Z	dd Z
dd ZdS )Address Nc             C   sl   |dk	rV|s|rt dtj|\}}|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   )	TypeErrorparserZ
get_addr_spec
ValueErrorformatall_defects
local_partdomain
_display_name	_username_domain)selfdisplay_nameusernamer   	addr_specZa_srest r   ,/usr/lib64/python3.6/email/headerregistry.py__init__   s    
zAddress.__init__c             C   s   | j S )N)r   )r   r   r   r   r   7   s    zAddress.display_namec             C   s   | j S )N)r   )r   r   r   r   r   ;   s    zAddress.usernamec             C   s   | j S )N)r   )r   r   r   r   r   ?   s    zAddress.domainc             C   sT   t | j}t|t|tj kr.tj| j}n| j}| jrH|d | j S |sPdS |S )zThe 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_ENDSquote_stringr   )r   namesetZlpr   r   r   r   C   s    
zAddress.addr_specc             C   s   dj | jj| j| j| jS )Nz1{}(display_name={!r}, username={!r}, domain={!r}))r   	__class____name__r   r   r   )r   r   r   r   __repr__S   s    zAddress.__repr__c             C   s^   t | j}t|t|tj kr.tj| j}n| j}|rX| jdkrFdn| j}dj||S | jS )Nz<>r   z{} <{}>)r   r   r   r	   SPECIALSr   r   r   )r   r   dispr   r   r   r   __str__X   s    
zAddress.__str__c             C   s8   t |t | krdS | j|jko6| j|jko6| j|jkS )NF)typer   r   r   )r   otherr   r   r   __eq__c   s
    zAddress.__eq__)r   r   r   N)r    
__module____qualname__r   propertyr   r   r   r   r!   r$   r'   r   r   r   r   r      s   
%r   c               @   sF   e Zd ZdddZedd Zedd Zdd	 Zd
d Zdd
 Z	dS )GroupNc             C   s   || _ |rt|nt | _dS )a  Create 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)r   r   	addressesr   r   r   r   m   s    zGroup.__init__c             C   s   | j S )N)r   )r   r   r   r   r      s    zGroup.display_namec             C   s   | j S )N)r-   )r   r   r   r   r.      s    zGroup.addressesc             C   s   dj | jj| j| jS )Nz${}(display_name={!r}, addresses={!r})r   r   r    r   r.   )r   r   r   r   r!      s    zGroup.__repr__c             C   s   | j d kr&t| jdkr&t| jd S | j }|d k	r\t|}t|t|tj kr\tj|}djdd | jD }|r~d| n|}dj	||S )N   r   z, c             s   s   | ]}t |V  qd S )N)str).0xr   r   r   	<genexpr>