
    h]              	           S SK Jr  S SKJrJrJrJrJrJrJ	r	J
r
JrJrJrJrJr  SSKrSSKrSSKrSSKrSSKJr  S\4S jrS r  SS	\S
\S\S\4S jjrSS jrS rSS jrSS jrg)   )EmailSyntaxError)EMAIL_MAX_LENGTHLOCAL_PART_MAX_LENGTHDOMAIN_MAX_LENGTHDOT_ATOM_TEXTDOT_ATOM_TEXT_INTLATEXT_REATEXT_INTL_REATEXT_HOSTNAME_INTL
QTEXT_INTLDNS_LABEL_LENGTH_LIMITDOT_ATOM_TEXT_HOSTNAMEDOMAIN_NAME_REGEXDOMAIN_LITERAL_CHARS    N)OptionalFc                 ^    [        U 5      U-
  nU(       a  SOSnUS:  a  SOSnSU U SU S3$ )zEHelper function to return an error message related to invalid length.z	at least  r   s(z
 characterz
 too many))len)addrutf8limitdiffprefixsuffixs         kC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\email_validator/syntax.pyget_length_reasonr      s?    t9uD [bF1HS"FvhtfJvhj99    c                 *   U S:X  a  SU  S3$ [         R                  " U 5      S   S;   a  [        U 5      $ [        U 5      S:  a  S[        U 5      S 3R	                  5       nOS[        U 5      S 3R	                  5       n[         R
                  " X5      $ )	N\"r   LNPSi  zU+04x08x)unicodedatacategoryreprorduppername)chs     r   safe_character_displayr3      s    DyA3bzAq!%99Aw 1vQ##%Q##% A!!r    localallow_smtputf8allow_empty_localquoted_local_partc                    [        U 5      S:X  a  U(       d  [        S5      eU U SS.$ [        U 5      [        :  a  [        U [        S9n[        SU S35      e[        R
                  " U 5      nU(       a  U U SS.$ SnSn[        R
                  " U 5      nU(       aY  U(       dM  [        S	 U  5       5      nU(       a)  [        S
SR                  [        U5      5      -   S-   5      e[        S5      eSnSnOU(       a  [        S U  5       5      nU(       a)  [        SSR                  [        U5      5      -   S-   5      e[        S U  5       5      nU(       a2  SnU(       d)  [        S
SR                  [        U5      5      -   S-   5      eSnU(       ak  [        R                  " SU 5      n [        XS:H  S9   U R                  S5        US:X  a  S[        R                   " SSU 5      -   S-   n U U(       d  U US.$ SUS.$ [        S U  5       5      nU(       a)  [        SSR                  [        U5      5      -   S-   5      e[#        U SSSS9  [        S5      e! [         a    [        S5      ef = f) z;Validates the syntax of the local part of an email address.r   z*There must be something before the @-sign.F)
local_partascii_local_partsmtputf8r   z0The email address is too long before the @-sign .Nc              3   r   #    U  H-  n[         R                  " U5      (       a  M   [        U5      v   M/     g 7fN)r	   matchr3   .0r1   s     r   	<genexpr>,validate_email_local_part.<locals>.<genexpr>c   s.      A~~a( *&q))   77zBInternationalized characters before the @-sign are not supported: , zAInternationalized characters before the @-sign are not supported.zdot-atomTc              3   r   #    U  H-  n[         R                  " U5      (       a  M   [        U5      v   M/     g 7fr?   )r   r@   r3   rA   s     r   rC   rD   {   s0      
##A& &"1%%rE   zKThe email address contains invalid characters in quotes before the @-sign: c              3   l   #    U  H*  nS [        U5      s=::  a  S::  a  M  O  [        U5      v   M,     g7f)    ~   N)r.   r3   rA   s     r   rC   rD      s8      
#a&'C' &' #1%%s   44quotedNFC)allow_spacer   z0The email address contains an invalid character.r#   z(["\\])z\\\1c              3   r   #    U  H-  n[         R                  " U5      (       a  M   [        U5      v   M/     g 7fr?   )r
   r@   r3   rA   s     r   rC   rD      s0      A""1% 	"q!!rE   zAThe email address contains invalid characters before the @-sign: z(An email address cannot start with a {}.z@An email address cannot have a {} immediately before the @-sign.is_hostnamez@The email address contains invalid characters before the @-sign.)r   r   r   r   r   r@   r   setjoinsortedr+   	normalizecheck_unsafe_charsencode
ValueErrorresubcheck_dot_atom)	r4   r5   r6   r7   reasonmvalidrequires_smtputf8	bad_charss	            r   validate_email_local_partr`   &   sI    5zQ "#OPP
 $$)!  5z))"50EF!QRXQYYZ[\\ 	E"A   %
 	
  E  'A   I
 &'knrnwnwx~  @I  yJ  oK  (K  NQ  (Q  R  R ##fgg   

  

 
	
 "#psws|s|  ~D  EN  ~O  tP  $P  SV  $V  W  W  

 
	
  $ "&'knrnwnwx~  @I  yJ  oK  (K  NQ  (Q  R  R   %%eU3 	5/@B
	WLL  H"&&We<<sBE  ->)
 	
DH)
 	
   I
 beienenouv  pA  fB   B  EH   H  I  	I 5D  GI  W\  ] ]
^^I  	W"#UVV	Ws   6I I,c           	         [        5       n[        U 5       H  u  p4[        R                  " U5      nUS   S;   a  M&  US   S:X  a  US:X  a  UR	                  U5        MH  MJ  US:X  a  U(       d  UR	                  U5        Mj  Ml  US   S:X  a  UR	                  U5        M  US   S;   a  UR	                  U5        M  UR	                  U5        M     U(       a0  [        SSR                  S	 [        U5       5       5      -   S
-   5      eg )Nr   r$   MZsZ)Crd   z.The email address contains unsafe characters: rF   c              3   8   #    U  H  n[        U5      v   M     g 7fr?   )r3   rA   s     r   rC   %check_unsafe_chars.<locals>.<genexpr>   s     *`N_+A!+D+DN_s   r=   )rQ   	enumerater+   r,   addr   rR   rS   )r   rM   r_   ir1   r,   s         r   rU   rU      s    I!''*A;..a[C
 Ava   a  a[C
 MM!a[J& MM! MM!U V O!%*`fU^N_*`!` acf g h 	h r    c                    U R                  S5      (       a  [        UR                  S5      5      eU R                  S5      (       a  [        UR                  S5      5      eSU ;   a  [        S5      eU(       ax  U R                  S5      (       a  [        UR                  S5      5      eU R                  S5      (       a  [        UR                  S5      5      eSU ;   d  SU ;   a  [        S	5      eg g )
Nr=   periodz..z2An email address cannot have two periods in a row.-hyphenz.-z-.zFAn email address cannot have a period and a hyphen next to each other.)endswithr   format
startswith)labelstart_descr	end_descrrP   s       r   rZ   rZ     s    ~~cy//9::{11(;<<u}STT>>#"9#3#3H#=>>C  ";#5#5h#?@@5=DEM"#kll * r    c                    [        S U  5       5      nU(       a)  [        SSR                  [        U5      5      -   S-   5      e[	        U 5         [
        R                  " U SSS9n [        U S
SSS9  U R                  S5       H9  n[        R                  " SU[        R                  5      (       d  M0  [        S5      e   [        R                  " U 5      (       a  U nOM [
        R                  " U SS9R                  S5      n[        R                  " U5      nU(       d  [        S5      e[#        U5      [$        :  a  ['        U[$        S9n[        SU S35      eUR                  S5       H3  n[#        U5      [(        :  d  M  ['        U[(        S9n[        SU S35      e   U(       aD  SU;  a  US:X  a  U(       d  [        S5      e[*        R,                  " U5      (       d  [        S5      eSSKJn	  U	 H;  n
U
S:X  a	  U(       a  M  Xj:X  d  UR3                  SU
-   5      (       d  M2  [        S5      e    [
        R                  " UR                  S5      5      n[        S U  5       5      nU(       a)  [        SSR                  [        U5      5      -   S-   5      e[	        U 5        UUS .$ ! [
        R                   a  n[        SU S35      eS	nAff = f! [
        R                   a.  nS[!        U5      ;   a  [        S5      e[        SU S35      eS	nAff = f! [
        R                   a  n[        SU S35      eS	nAff = f)!z<Validates the syntax of the domain part of an email address.c              3   r   #    U  H-  n[         R                  " U5      (       a  M   [        U5      v   M/     g 7fr?   r   r@   r3   rA   s     r   rC   -validate_email_domain_name.<locals>.<genexpr>  0      A"((+ 	"q!!rE   z7The part after the @-sign contains invalid characters: rF   r=   F)
std3_rulestransitionalz7The part after the @-sign contains invalid characters ().Nz?An email address cannot have a {} immediately after the @-sign.z&An email address cannot end with a {}.TrO   z
(?!xn)..--zAn email address cannot have two letters followed by two dashes immediately after the @-sign or after a period, except Punycode.)uts46asciizDomain too longz/The email address is too long after the @-sign.zSThe email address contains invalid characters after the @-sign after IDNA encoding.r<   z/The email address is too long after the @-sign zDAfter the @-sign, periods cannot be separated by so many characters testz@The part after the @-sign is not valid. It should have a period.zRThe part after the @-sign is not valid. It is not within a valid top-level domain.r   )SPECIAL_USE_DOMAIN_NAMESz[The part after the @-sign is a special-use or reserved name that cannot be used with email.z-The part after the @-sign is not valid IDNA (c              3   r   #    U  H-  n[         R                  " U5      (       a  M   [        U5      v   M/     g 7fr?   rw   rA   s     r   rC   rx     ry   rE   )ascii_domaindomain)rQ   r   rR   rS   rU   idnauts46_remap	IDNAErrorrZ   splitrX   r@   Ir   rV   decodestrr   r   r   r   r   searchr   r   ro   )r   test_environmentglobally_deliverabler_   err   r   r\   r[   r   ddomain_i18ns               r   validate_email_domain_namer     s^   
   I
 X[_[d[dekluev[wwz}}~~ v`!!&UO 6\  _G  UY  Z c"88M5"$$//"  $f  g  g # ##F++		d;;vU;BB7KL #((6"#xyy <,,"<7HI!PQWPXXYZ[[ ##C(u:..&u4JKF"%ijpiqqr#stt )
  l"LF,BGW"#eff !''55"#wxx +%;+ 5 5cAg > >"  $A  B  B &Vkk,"5"5g">?   I
 X[_[d[dekluev[wwz}}~~v % } >> `!XYZX[[]^__`J ~~ 	d CF*
 ''XYY"%\]^\__a#bcc	dJ >> V!NqcQSTUUVsH   J, $K 5%L ,K KKL+)LLM0L??Mc                    [         R                  " SU 5      (       a2   [        R                  " U 5      nU(       d  [        S5      eUSU S3S.$ U R                  S5      (       a?   [        R                  " U S	S  5      nU(       d  [        S5      eUSUR                   S3S.$ SU ;  a  [        S5      e[        S U  5       5      nU(       a)  [        SSR                  [        U5      5      -   S-   5      e[        S5      e! [         a  n[        SU S35      eS nAff = f! [         a  n[        S
U S35      eS nAff = f)Nz
^[0-9\.]+$zRThe address in brackets after the @-sign is not valid: It is not an IPv4 address (z') or is missing an address literal tag.z>A bracketed IPv4 address after the @-sign is not allowed here.[])domain_addressr   zIPv6:   z<The IPv6 address in brackets after the @-sign is not valid (r|   z>A bracketed IPv6 address after the @-sign is not allowed here.z[IPv6::z\The part after the @-sign in brackets is not an IPv4 address and has no address literal tag.c              3   r   #    U  H-  n[         R                  " U5      (       a  M   [        U5      v   M/     g 7fr?   )r   r@   r3   rA   s     r   rC   0validate_email_domain_literal.<locals>.<genexpr>  s0      A#))!, 	"q!!rE   zCThe part after the @-sign contains invalid characters in brackets: rF   r=   zNThe part after the @-sign contains an invalid address literal tag in brackets.)rX   r@   	ipaddressIPv4AddressrW   r   rq   IPv6Address
compressedrQ   rR   rS   )domain_literalallow_domain_literalr   r   r_   s        r   validate_email_domain_literalr     s    
xx~..	d((8D $"#cdd #$qk
 	
   ))	i(();<D $"#cdd
 #t/q1
 	

 . }~~   I
 dgkgpgpqw  yB  rC  hD   D  GJ   J  K  	K k
ll]  	d"%wxywz  {b  $c  d  d	d  	i"%abcaddf#ghh	is/   D &D# 
D DD #
E-D<<E)TFF)F)FT)exceptions_typesr   rfc_constantsr   r   r   r   r   r	   r
   r   r   r   r   r   r   rX   r+   r   r   typingr   r   r3   r   boolr`   rU   rZ   r   r    r    r   <module>r      s    .\ \ \ \ 
     "'.> :"" bg8=d_S d_$ d_Z^ d_15d_N1hhm&[|9mr    