Your IP : 18.119.116.77
3
\O � @ sj d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd� d�ZG dd � d �Z G d
d� de
�Zdd
� ZG dd� d�Z
G dd� de
�ZG dd� d�ZG dd� de�ZG dd� d�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� d�ZG d d!� d!�ZG d"d#� d#e�ZG d$d%� d%e�ZG 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 Zddd�Zedd� �Zedd� �Zed d
� �Zedd� �Zd
d� Z dd� Z
dd� ZdS )�Address� Nc C sl |dk rV|s|rt d��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__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 )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 �namesetZlpr r r r C s
zAddress.addr_specc C s dj | jj| j| j| j�S )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'