U
    [e'%                     @   s  d Z ddlmZ zddlZ[W n& ek
rD   ddlmZ dZY ntX ddlm	Z
 ddlmZmZ ddlmZmZ dd	lmZ dd
lmZmZmZmZmZmZmZmZ ddlmZ ddlmZm Z  ddlm!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z)m*Z*m+Z, dZedZ-eede-f ge-f Z.ze/ W n e0k
rB   e1Z/Y nX dd Z2da3e#d)ddZ4e#d*ddZ5e#d+ddZ6e#d,dd Z7d!d" Z8da9e#d#d$ Z:e#d%d& Z;e#d'd( Z<dS )-z
Hypothesis strategies.
    )absolute_importN)Tuple )reader)dirnamejoin)ascii_lettersdigits)
maxunicode)CallableIterableListOptionalSequenceTextTypeVarcast)open   )
DecodedURL
EncodedURL)assume)	compositeintegerslistssampled_fromtext)	IDNAErrorcheck_labelencode)decoded_urlsencoded_urlshostname_labels	hostnames	idna_textpathsport_numbersT.c               	   C   s   t sg } tttd}t|}tdd |D dd}t| |D ]}|\}}}|dkrZqB|d dd	}t|d	kr|	|d  d
d |D \}	}
t
|	|
d	 D ]}|tkr qB| 	t| qqBW 5 Q R X d| a t S )z>
        Returns a string containing IDNA characters.
        zidna-tables-properties.csv.gzc                 s   s   | ]}| d V  qdS )utf-8N)decode).0liner   r   V/var/www/html/services/stratfitenv/lib/python3.8/site-packages/hyperlink/hypothesis.py	<genexpr>Q   s     z"idna_characters.<locals>.<genexpr>,)	delimiterPVALIDr   -r   c                 s   s   | ]}t |d V  qdS )   N)int)r*   ir   r   r,   r-   b   s      )_idnaCharactersr   r   __file__	open_gzip
csv_readernextsplitlenappendranger
   unichr)resultZdataFileNameZdataFiler   rowcodespropdescriptionZstartEndstartendr4   r   r   r,   idna_characters?   s4     


rG   r5   c                 C   sl   t  }|dkst|dk	r&|dks&ttt| t|||d}zt| W n tk
rf   td Y nX |S )a(  
        A strategy which generates IDNA-encodable text.

        @param min_size: The minimum number of characters in the text.
            C{None} is treated as C{0}.

        @param max_size: The maximum number of characters in the text.
            Use C{None} for an unbounded size.
        r   Nmin_sizemax_sizealphabetF)rG   AssertionErrorr   r   r   idna_encoder   r   )drawrI   rJ   rK   r@   r   r   r,   r$   o   s    r$   Fc                 C   s$   |r
d}nd}t t| t|ddS )z
        A strategy which generates port numbers.

        @param allow_zero: Whether to allow port C{0} as a possible value.
        r   r   i  )	min_valueZ	max_value)r   r3   r   )rN   
allow_zerorO   r   r   r,   r&      s    r&   Tc              	   C   s   |rht t| tddd}z|d W q tk
rd   t|ddtd kr`|dd }q8Y qX n$t t| tddttt d	 d
}zt	| W n t
k
r   td Y nX |S )z
        A strategy which generates host name labels.

        @param allow_idn: Whether to allow non-ASCII characters as allowed by
            internationalized domain names (IDNs).
        r   ?   rI   rJ   asciipunycodezxn--Nr1   rH   F)r   r   r$   r   UnicodeEncodeErrorr<   r   r   r	   r   UnicodeErrorr   )rN   	allow_idnlabelr   r   r,   r"      s,    	r"   c              	      s   t t| t|d fddg}|t tt | tt|dddd7 }tdd |D t| d d	krz|d
d }qJd|S )aD  
        A strategy which generates host names.

        @param allow_leading_digit: Whether to allow a leading digit in host
            names; they were not allowed prior to RFC 1123.

        @param allow_idn: Whether to allow non-ASCII characters as allowed by
            internationalized domain names (IDNs).
        )rX   c                    s    rdS | d t kS )NTr   )r	   )lallow_leading_digitr   r,   <lambda>   s    zhostnames.<locals>.<lambda>r      rR   c                 s   s   | ]}t |V  qd S )N)r<   )r*   rY   r   r   r,   r-      s     zhostnames.<locals>.<genexpr>   NrU   .)	r   r   r"   filterr   r   sumr<   r   )rN   r\   rX   labelsr   r[   r,   r#      s,    

"r#   c                  C   s    t dkrdd } d|  a t S )zH
        Returns a string containing valid URL path characters.
        Nc               	   s   sR   t tD ]D} t| }|dkrqz|d W n tk
rD   Y qY nX |V  qd S )Nz#/?r(   )r>   r
   r?   r   rV   )r4   cr   r   r,   chars  s    
zpath_characters.<locals>.charsr5   )_path_charactersr   )re   r   r   r,   path_characters   s    rg   c                 C   s$   t tt | ttdt dddS )Nr   )rI   rK   
   )rJ   )r   r   r   r   r   rg   rN   r   r   r,   r%     s    r%   c                 C   sf   t tt | tdd}t t| t }t tt | t }|dkrHd}tt t| t	d|||dS )z
        A strategy which generates L{EncodedURL}s.
        Call the L{EncodedURL.to_uri} method on each URL to get an HTTP
        protocol-friendly URI.
        T)rP   r   N)httphttps)schemehostportpath)
r   r   r3   r&   r   r#   r   r%   r   r   )rN   rn   rm   ro   r   r   r,   r!   #  s    r!   c                 C   s   t | t S )z
        A strategy which generates L{DecodedURL}s.
        Call the L{EncodedURL.to_uri} method on each URL to get an HTTP
        protocol-friendly URI.
        )r   r!   ri   r   r   r,   r    9  s    r    )r   N)F)T)TT)=__doc__
__future__r   Z
hypothesisImportErrortypingr   __all__csvr   r9   os.pathr   r   stringr   r	   sysr
   r   r   r   r   r   r   r   r   gzipr   r8   r5   r   r   r   Zhypothesis.strategiesr   r   r   r   r   idnar   r   r   rM   r'   ZDrawCallabler?   	NameErrorchrrG   r6   r$   r&   r"   r#   rg   rf   r%   r!   r    r   r   r   r,   <module>   sT   (


. -+
	
