
    \j                     j   U d dl Z d dlZd dlmZ d dlZd dlmZmZmZmZm	Z	m
Z
  e
d      Zej                  rd dlmZ d dlmZ  G d de      Zi d	ej"                  d
ej$                  dej&                  dej(                  dej*                  dej,                  dej$                  ej,                  z   dej*                  ej,                  z   dej.                  dej"                  j1                         dej$                  ej*                  z   dz   dej$                  ej*                  z   dz   ddj3                   eej"                        j7                  ej$                  ej*                  z   dz               ddj3                   eej$                  ej*                  z         j7                  d            dej$                  ej*                  z   dz   dej$                  ej*                  z   dz   dej$                  ej*                  z   d z   Zeeef   ed!<    G d" d#      Z G d$ d%e       Z!y)&    N)partial)IterableListMappingOptionalSequenceTypeVar_T)Random)Protocolc                   >    e Zd Z	 	 	 	 ddee   dee   dededef
dZy)	_PartialRstrFuncstart_range	end_rangeincludeexcludereturnc                      y N )selfr   r   r   r   s        8/root/env/lib/python3.12/site-packages/rstr/rstr_base.py__call__z_PartialRstrFunc.__call__/   s         N)....)__name__
__module____qualname__r   intstrr   r   r   r   r   r   -   sM     *-'*	!#	  }	 		
 	 	r   r   	printableletters	uppercase	lowercasedigitspunctuation	nondigits
nonletters
whitespacenonwhitespacenormal word_nonword unambiguous0O1lI
postalsafez .-#/urlsafez-._~
domainsafe-	ALPHABETSc                        e Zd ZdZdddeddf fdZded	eddfd
ZdeddfdZdee   de	de
e   fdZ	 	 	 	 ddee   dee	   dee	   dee   dee   defdZ xZS )RstrBasea  Create random strings from a variety of alphabets.

    The alphabets for printable(), uppercase(), lowercase(), digits(), and
    punctuation() are equivalent to the constants by those same names in the
    standard library string module.

    nondigits() uses an alphabet of string.letters + string.punctuation

    nonletters() uses an alphabet of string.digits + string.punctuation

    nonwhitespace() uses an alphabet of string.printable.strip()

    normal() uses an alphabet of string.letters + string.digits + ' ' (the
    space character)

    postalsafe() is based on USPS Publication 28 - Postal Addressing Standards:
    http://pe.usps.com/text/pub28/pub28c2.html
    The characters allowed in postal addresses are letters and digits, periods,
    slashes, the pound sign, and the hyphen.

    urlsafe() uses an alphabet of unreserved characters safe for use in URLs.
    From section 2.3 of RFC 3986: "Characters that are allowed in a URI but
    do not have a reserved purpose are called unreserved. These include
    uppercase and lowercase letters, decimal digits, hyphen, period,
    underscore, and tilde.

    domainsafe() uses an alphabet of characters allowed in hostnames, and
    consequently, in internet domains: letters, digits, and the hyphen.

    _randomr   custom_alphabetsr   Nc                     t         |           || _        t        t              | _        |j                         D ]  \  }}| j                  ||        y r   )super__init__r9   dictr6   
_alphabetsitemsadd_alphabet)r   r9   r:   
alpha_namealphabet	__class__s        r   r=   zRstrBase.__init__p   sM    y/$4$:$:$< 	4 Jj(3	4r   rB   
charactersc                 "    || j                   |<   y)zhAdd an additional alphabet to an Rstr instance and make it available
        via method calls.

        N)r?   )r   rB   rE   s      r   rA   zRstrBase.add_alphabetw   s    
 '1
#r   attrr   c                     || j                   v r#t        | j                  | j                   |         S d| }t        |      )Nz Rstr instance has no attribute: )r?   r   rstrAttributeError)r   rG   messages      r   __getattr__zRstrBase.__getattr__~   s?    4??"499dood&;<<4TF;W%%r   
populationkc                     t        j                  d|      D cg c]  }| j                  j                  |       c}S c c}w )z>Samples k random elements (with replacement) from a populationN)	itertoolsrepeatr9   choice)r   rM   rN   is       r   	sample_wrzRstrBase.sample_wr   s3    9B9I9I$PQ9RSA##J/SSSs   ">rC   r   r   r   r   c                    t        |      j                  |      }|r=dj                  t        |      dkD  rdnddj	                  |            }t        |      t        |      D cg c]  }|t        |      vs| }	}||d\  }}n|}
n|d}|r| j                  j                  ||      }

t        |      z
  }
| j                  |	|
      t        |      z   }| j                  j                  |       dj	                  |      S c c}w )aP  Generate a random string containing elements from 'alphabet'

        By default, rstr() will return a string between 1 and 10 characters.
        You can specify a second argument to get an exact length of string.

        If you want a string in a range of lengths, specify the start and end
        of that range as the second and third arguments.

        If you want to make certain that particular characters appear in the
        generated string, specify them as "include".

        If you want to *prevent* certain characters from appearing, pass them
        as 'exclude'.

        zLinclude and exclude parameters contain same character{plural} ({characters})   sr/   z, )pluralrE   )rV   
   )setintersectionformatlenjoinSameCharacterErrorlistr9   randintrT   shuffle)r   rC   r   r   r   r   same_charactersrK   charpopulrN   results               r   rI   zRstrBase.rstr   s   . g,33G<dkk!/2Q6sB99_5 l G %W--"&x.N$DW4MNN")0&Y K$$[)<A Gq)DM9V$wwv% Os   'D:D)NNr/   r/   )r   r   r   __doc__r   r=   rA   rL   r   r   r   rT   r   r   rI   __classcell__)rD   s   @r   r8   r8   P   s    >4 4c 4d 41s 1 1 1& &(: &THSM Tc Td3i T &*#'!#!#13-1 c]1 C=	1
 #1 #1 
1r   r8   c                       e Zd Zy)r_   N)r   r   r   r   r   r   r_   r_      s    r   r_   )"rP   string	functoolsr   typingr   r   r   r   r   r	   r
   TYPE_CHECKINGrandomr   r   r   r    ascii_lettersascii_uppercaseascii_lowercaser$   r%   r(   stripr^   rZ   
differencer6   r   __annotations__r8   
ValueErrorr_   r   r   r   <module>rv      sT  <     G G T] 
	8 	 !! v##  ''  ''	 
 fmm  6%%  %%(:(::  &--&"4"44  &##  V%%++-  f""V]]2S8  F  6==036  rwwF(()=)=)MPS)ST   2773v33fmmCDOOPWXY! " &&&6@# $ v##fmm3f<% & &&&6<' 	738 .i iX	 	r   