U
    mhb                     @   s   d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZ e dZe d	Ze d
Ze dZe dZe dZe dZe
dZeee eeef f ZG dd dZG dd deZdS )    N)OrderedDict)Any
CollectionListOptionalSequenceTypeVarUnion   )	Generator)OrderedDictType)choices_distributionchoices_distribution_unique#%z\$!@z\?z\^Tc                   @   s  e Zd ZU dZdZee ed< dZddddd	d
dd
d	ddddddd
d
dddd
ddddddddddddd d
d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1dd2d	d
dd3dd4d
d
d5d6d7d8d9dd:d3d;d<d=d;d4d>d?d@dAdBd
dCd
d
dDddEdFdGdHd/dIdJdKdLdd
d
dMddNdOd
dPd
d
dQdRdSddTdUdVdWdXdYdTddddZd
dd[d\dd]d^dd
d_d`dad
d
d/d[dTd;dbddcdddedfdgdddhdiddjd
d
dkdldVd2ddmd,ddndddodd%d[dpddqdrdsdd*dd%d3dtduddvZ	e
ddwdxdyZedzd{d|Zedzd}d~ZdeeeedddZedzddZedzddZedzddZeeef dzddZeeef dzddZdee eedddZedzddZdeee dddZedzddZedzddZdee ee eee ee dddZdee ee ee dddZ dee edddZ!dee ee ee dddZ"deeeee ee edddZ#deedddZ$de%j&feeedddZ'de%j&feeedddZ(deeedddZ)dS )BaseProviderbaseN__lang__F)DJERET)ZA)ZGH)r   )ES)IN)ZAEZBHr   DZZEGZEHr   ILr   IQZJOZKMZKWZLBZLYMAZMRZOMZPSZQAZSAZSDSOZSSZSYZTDZTNZYE)PE)ZAZr   )ZBY)ZM)r   r    )ZBG)BDr   )CNr   )FR)ZBA)r   )ZADr   r&   IT)RU)r   )TW)UA)ZCZ)ZPL)GB)DK)ATBECHDEZLILU)ZMV)ZBT)ZGRCY)ZAGZAUr$   ZBWCAr,   r+   HKIEr   NGNZPHPKSGUSr   r#   ZZW)r;   )ZARZBOZCLZCOCRZCUZDOZECr   GTZHNMXZNIZPAr"   ZPRZPYZSVr;   ZUYZVE)ZEE)r   r&   )ZIR)ZSN)FI)r8   )ZFO)r3   r/   r&   r1   )r'   )NLr0   )r5   )r   r   )r6   )r   )ZHR)r0   )ZHT)ZHU)ZAM)ZID)r3   )ZIS)r/   r'   )ZJP)ZGE)ZKZ)ZGL)ZKH)ZKR)TR)ZKG)r1   )ZUG)r.   r@   )ZCD)ZLA)LT)ZLV)ZMG)r7   )ZMK)ZMN)ZMY)ZMT)ZMM)ZNO)r0   r@   )ZNP)r>   )ZNUr7   )AWr.   r@   )r   KE)r   r9   )ANrC   ZCW)ZAF)ZBRZPT)ZRO)r(   r*   )ZRW)LK)ZSK)ZSI)r   r   rD   r!   )ALZML)ZMEZRS)r?   ZSE)rD   ZTZ)r   rF   )ZTJ)ZTH)ZTM)r2   rA   )r%   )ZUZ)ZVN)r.   )r/   )r4   )r%   r4   r:   r)   )ZaaafZakamanZapnarasastZaycazbeZbemberbgZbhbZbhoZbnZbobrZbrxbsZbyncaZceZckbZcmnZcrhcsZcsbZcvcydadeZdoiZdvZdzeleneoeseteufaZfffiZfilfofrZfurZfygagdZgezglZgugvZhaZhakhehihnehrZhsbZhthuZhyiaidZigZikisitiuiwjakakkklZkmknkoZkokksZkukwkyZlbZlgZliZlijZlnloltlvZlzhZmagmaiZmgZmhrmimkmlZmnZmnimrmsmtmynannbZndsneZnhnZniunlnnnrnsoocZomorospaZpapplZpsptZquzZrajrorurwsasatZscsdZseZshssiZsidskslsosqsrssstsvswZszltaZtcytetgthZtheZtiZtigtktltntrtsttZugukZunmuruzveviwaZwaeZwalZwoxhyiZyoZyuezhzu)	generatorreturnc                 C   s
   || _ dS )zc
        Base class for fake data providers
        :param generator: `Generator` instance
        N)r   )selfr    r   `/var/www/html/peyman_registration/venvv2/lib/python3.8/site-packages/faker/providers/__init__.py__init__  s    zBaseProvider.__init__)r   c                 C   s    |   }|d | tj|  S )z<Generate a random underscored i18n locale code (e.g. en_US)._)language_coderandom_elementr   language_locale_codes)r   r   r   r   r   locale$  s    zBaseProvider.localec                 C   s   |  tj S )z/Generate a random i18n language code (e.g. en).)r   r   r   keysr   r   r   r   r   0  s    zBaseProvider.language_coder   '     )minmaxstepr   c                 C   s   | j j||d |S )aZ  Generate a random integer between two integers ``min`` and ``max`` inclusive
        while observing the provided ``step`` value.

        This method is functionally equivalent to randomly sampling an integer
        from the sequence ``range(min, max + 1, step)``.

        :sample: min=0, max=15
        :sample: min=0, max=15, step=3
        r   )r   random	randrange)r   r   r   r   r   r   r   
random_int5  s    
zBaseProvider.random_intc                 C   s   | j jddS )z!Generate a random digit (0 to 9).r   	   r   r   randintr   r   r   r   random_digitA  s    zBaseProvider.random_digitc                 C   s   | j jddS )z*Generate a random non-zero digit (1 to 9).r   r   r   r   r   r   r   random_digit_not_nullF  s    z"BaseProvider.random_digit_not_nullc                 C   s   | j jddS )z1Generate a random digit above value two (2 to 9).r
   r   r   r   r   r   r   random_digit_above_twoK  s    z#BaseProvider.random_digit_above_twoc                 C   s(   | j jddr | j jddS dS dS )zGenerate a random digit (0 to 9) or an empty string.

        This method will return an empty string 50% of the time,
        and each digit has a 1/20 chance of being generated.
        r   r   r    Nr   r   r   r   r   random_digit_or_emptyP  s    z"BaseProvider.random_digit_or_emptyc                 C   s(   | j jddr | j jddS dS dS )zGenerate a random non-zero digit (1 to 9) or an empty string.

        This method will return an empty string 50% of the time,
        and each digit has a 1/18 chance of being generated.
        r   r   r   r   Nr   r   r   r   r   random_digit_not_null_or_empty\  s    z+BaseProvider.random_digit_not_null_or_empty)digitsfix_lenr   c                 C   sx   |dkr|   }|dk r td|rZ|dkrP| jjtd|d td|d S tdn| jjdtd|d S dS )aX  Generate a random integer according to the following rules:

        - If ``digits`` is ``None`` (default), its value will be set to a random
          integer from 1 to 9.
        - If ``fix_len`` is ``False`` (default), all integers that do not exceed
          the number of ``digits`` can be generated.
        - If ``fix_len`` is ``True``, only integers with the exact number of
          ``digits`` can be generated.

        :sample: fix_len=False
        :sample: fix_len=True
        :sample: digits=3
        :sample: digits=3, fix_len=False
        :sample: digits=3, fix_len=True
        Nr   z7The digit parameter must be greater than or equal to 0.
   r   z=A number of fixed length cannot have less than 1 digit in it.)r   
ValueErrorr   r   r   pow)r   r   r   r   r   r   random_numberh  s    $
zBaseProvider.random_numberc                 C   s   | j jttdtjS )z-Generate a random ASCII letter (a-z and A-Z).letters)r   r   choicegetattrstringascii_lettersr   r   r   r   random_letter  s    zBaseProvider.random_letter   )lengthr   c                 C   s   | j ttdtj|dS )zwGenerate a list of random ASCII letters (a-z and A-Z) of the specified ``length``.

        :sample: length=10
        r   r   )random_choicesr   r   r   )r   r   r   r   r   random_letters  s    zBaseProvider.random_lettersc                 C   s   | j jtjS )z/Generate a random lowercase ASCII letter (a-z).)r   r   r   r   ascii_lowercaser   r   r   r   random_lowercase_letter  s    z$BaseProvider.random_lowercase_letterc                 C   s   | j jtjS )z/Generate a random uppercase ASCII letter (A-Z).)r   r   r   r   ascii_uppercaser   r   r   r   random_uppercase_letter  s    z$BaseProvider.random_uppercase_letterabc)elementsr   uniqueuse_weightingr   c                 C   s   |dk	r|n| j }t|tr.t|ts.td|r6tnt}|dkrV| jj	dt
|}|rn|t
|krntdt|trt|dst| |_|j}|rt| nd}n|r| jj||S |}d}|t||| jj|dS )a	  Generate a list of randomly sampled objects from ``elements``.

        Set ``unique`` to ``False`` for random sampling with replacement, and set ``unique`` to
        ``True`` for random sampling without replacement.

        If ``length`` is set to ``None`` or is omitted, ``length`` will be set to a random
        integer from 1 to the size of ``elements``.

        The value of ``length`` cannot be greater than the number of objects
        in ``elements`` if ``unique`` is set to ``True``.

        The value of ``elements`` can be any sequence type (``list``, ``tuple``, ``set``,
        ``string``, etc) or an ``OrderedDict`` type. If it is the latter, the keys will be
        used as the objects for sampling, and the values will be used as weighted probabilities
        if ``unique`` is set to ``False``. For example:

        .. code-block:: python

            # Random sampling with replacement
            fake.random_elements(
                elements=OrderedDict([
                    ("variable_1", 0.5),        # Generates "variable_1" 50% of the time
                    ("variable_2", 0.2),        # Generates "variable_2" 20% of the time
                    ("variable_3", 0.2),        # Generates "variable_3" 20% of the time
                    ("variable_4": 0.1),        # Generates "variable_4" 10% of the time
                ]), unique=False
            )

            # Random sampling without replacement (defaults to uniform distribution)
            fake.random_elements(
                elements=OrderedDict([
                    ("variable_1", 0.5),
                    ("variable_2", 0.2),
                    ("variable_3", 0.2),
                    ("variable_4": 0.1),
                ]), unique=True
            )

        :sample: elements=('a', 'b', 'c', 'd'), unique=False
        :sample: elements=('a', 'b', 'c', 'd'), unique=True
        :sample: elements=('a', 'b', 'c', 'd'), length=10, unique=False
        :sample: elements=('a', 'b', 'c', 'd'), length=4, unique=True
        :sample: elements=OrderedDict([
                        ("a", 0.45),
                        ("b", 0.35),
                       ("c", 0.15),
                       ("d", 0.05),
                   ]), length=20, unique=False
        :sample: elements=OrderedDict([
                       ("a", 0.45),
                       ("b", 0.35),
                       ("c", 0.15),
                       ("d", 0.05),
                   ]), unique=True
        NzFUse OrderedDict only to avoid dependency on PYTHONHASHSEED (See #363).r   zOSample length cannot be longer than the number of unique elements to pick from.
_key_cacher   )__use_weighting__
isinstancedictr   r   r   r   r   r   r   lenhasattrtupler   r   valuessample)r   r   r   r   r   fnchoicesZprobabilitiesr   r   r   random_elements  s.    >

zBaseProvider.random_elements)r   r   r   c                 C   s   | j ||ddS )a\  Generate a list of objects randomly sampled from ``elements`` with replacement.

        For information on the ``elements`` and ``length`` arguments, please refer to
        :meth:`random_elements() <faker.providers.BaseProvider.random_elements>` which
        is used under the hood with the ``unique`` argument explicitly set to ``False``.

        :sample: elements=('a', 'b', 'c', 'd')
        :sample: elements=('a', 'b', 'c', 'd'), length=10
        :sample: elements=OrderedDict([
                     ("a", 0.45),
                     ("b", 0.35),
                     ("c", 0.15),
                     ("d", 0.05),
                 ])
        :sample: elements=OrderedDict([
                     ("a", 0.45),
                     ("b", 0.35),
                     ("c", 0.15),
                     ("d", 0.05),
                 ]), length=20
        Fr   r   r   r   r   r   r   r   r     s    zBaseProvider.random_choices)r   r   c                 C   s   | j |ddd S )aW  Generate a randomly sampled object from ``elements``.

        For information on the ``elements`` argument, please refer to
        :meth:`random_elements() <faker.providers.BaseProvider.random_elements>` which
        is used under the hood with the ``unique`` argument set to ``False`` and the
        ``length`` argument set to ``1``.

        :sample: elements=('a', 'b', 'c', 'd')
        :sample size=10: elements=OrderedDict([
                     ("a", 0.45),
                     ("b", 0.35),
                     ("c", 0.15),
                     ("d", 0.05),
                 ])
        r   r   r   r   )r   r   r   r   r   r     s    zBaseProvider.random_elementc                 C   s   | j ||ddS )a  Generate a list of objects randomly sampled from ``elements`` without replacement.

        For information on the ``elements`` and ``length`` arguments, please refer to
        :meth:`random_elements() <faker.providers.BaseProvider.random_elements>` which
        is used under the hood with the ``unique`` argument explicitly set to ``True``.

        :sample: elements=('a', 'b', 'c', 'd', 'e', 'f')
        :sample: elements=('a', 'b', 'c', 'd', 'e', 'f'), length=3
        Tr   r   r   r   r   r   random_sample+  s    zBaseProvider.random_sampler   )numberleger   r   r   c           	      C   sl   |r|r|S |rdnd}|r dnd}t || jj|| d }|dk	rT||k rT|}|dk	rh||krh|}|S )a1  Generate a random integer near ``number`` according to the following rules:

        - If ``le`` is ``False`` (default), allow generation up to 140% of ``number``.
          If ``True``, upper bound generation is capped at 100%.
        - If ``ge`` is ``False`` (default), allow generation down to 60% of ``number``.
          If ``True``, lower bound generation is capped at 100%.
        - If a numerical value for ``min`` is provided, generated values less than ``min``
          will be clamped at ``min``.
        - If a numerical value for ``max`` is provided, generated values greater than
          ``max`` will be clamped at ``max``.
        - If both ``le`` and ``ge`` are ``True``, the value of ``number`` will automatically
          be returned, regardless of the values supplied for ``min`` and ``max``.

        :sample: number=100
        :sample: number=100, ge=True
        :sample: number=100, ge=True, min=120
        :sample: number=100, le=True
        :sample: number=100, le=True, max=80
        :sample: number=79, le=True, ge=True, min=80
        d   <      N)intr   r   r   )	r   r  r  r  r   r   _minZ_maxr   r   r   r   randomize_nb_elements9  s    z"BaseProvider.randomize_nb_elements###)textr   c                    sh   t  fdd|}t fdd|}t fdd|}t fdd|}t fdd|}|S )aJ  Generate a string with each placeholder in ``text`` replaced according
        to the following rules:

        - Number signs ('#') are replaced with a random digit (0 to 9).
        - Percent signs ('%') are replaced with a random non-zero digit (1 to 9).
        - Dollar signs ('$') are replaced with a random digit above two (2 to 9).
        - Exclamation marks ('!') are replaced with a random digit or an empty string.
        - At symbols ('@') are replaced with a random non-zero digit or an empty string.

        Under the hood, this method uses :meth:`random_digit() <faker.providers.BaseProvider.random_digit>`,
        :meth:`random_digit_not_null() <faker.providers.BaseProvider.random_digit_not_null>`,
        :meth:`random_digit_or_empty() <faker.providers.BaseProvider.random_digit_or_empty>`,
        and :meth:`random_digit_not_null_or_empty() <faker.providers.BaseProvider.random_digit_not_null_or_empty>`
        to generate the random values.

        :sample: text='Intel Core i%-%%##K vs AMD Ryzen % %%##X'
        :sample: text='!!! !!@ !@! !@@ @!! @!@ @@! @@@'
        c                    s   t   S N)strr   xr   r   r   <lambda>s      z'BaseProvider.numerify.<locals>.<lambda>c                    s   t   S r  )r  r   r  r   r   r   r  t  r  c                    s   t   S r  )r  r   r  r   r   r   r  u  r  c                    s   t   S r  )r  r   r  r   r   r   r  v  r  c                    s   t   S r  )r  r   r  r   r   r   r  w  r  )_re_hashsub_re_perc_re_dol_re_excl_re_at)r   r  r   r   r   numerify`  s    zBaseProvider.numerifyz????)r  r   r   c                    s   t  fdd|S )aS  Generate a string with each question mark ('?') in ``text``
        replaced with a random character from ``letters``.

        By default, ``letters`` contains all ASCII letters, uppercase and lowercase.

        :sample: text='Random Identifier: ??????????'
        :sample: text='Random Identifier: ??????????', letters='ABCDE'
        c                    s
     S r  r   r  r   r   r   r   r    r  z%BaseProvider.lexify.<locals>.<lambda>)_re_qmr  r   r  r   r   r  r   lexifyz  s    	zBaseProvider.lexifyz## ??c                 C   s   | j | ||dS )a  Generate a string with each placeholder in ``text`` replaced according to the following rules:

        - Number signs ('#') are replaced with a random digit (0 to 9).
        - Question marks ('?') are replaced with a random character from ``letters``.

        By default, ``letters`` contains all ASCII letters, uppercase and lowercase.

        Under the hood, this method uses :meth:`numerify() <faker.providers.BaseProvider.numerify>` and
        and :meth:`lexify() <faker.providers.BaseProvider.lexify>` to generate random values for number
        signs and question marks respectively.

        :sample: letters='ABCDE'
        :sample: text='Product Number: ????-########'
        :sample: text='Product Number: ????-########', letters='ABCDE'
        )r   )r  r  r  r   r   r   bothify  s    zBaseProvider.bothify^^^^)r  upperr   c                    s0   t jdd  |r   t fdd|S )a  Generate a string with each circumflex ('^') in ``text``
        replaced with a random hexadecimal character.

        By default, ``upper`` is set to False. If set to ``True``, output
        will be formatted using uppercase hexadecimal characters.

        :sample: text='MAC Address: ^^:^^:^^:^^:^^:^^'
        :sample: text='MAC Address: ^^:^^:^^:^^:^^:^^', upper=True
        Nic                    s
     S r  r  r  r  r   r   r    r  z%BaseProvider.hexify.<locals>.<lambda>)r   	hexdigitsr   _re_cirr  )r   r  r   r   r  r   hexify  s    
zBaseProvider.hexify)r   r   r   )NF)r   )r   NFN)r   N)r   )r   N)r   FFNN)r
  )r  F)*__name__
__module____qualname____provider__r   r   r  __annotations__r   r   r   r   r   r   r  r   r   r   r   r	   r   r   boolr   r   r   r   r   r   ElementsTyper   r   r   r   r   r	  r  r   r   r  r  r#  r   r   r   r   r      s  
   
    a           'r   c                       sR   e Zd Zdeee ee d fddZeddddZde	ed	d
dZ
  ZS )DynamicProviderN)provider_namer   r   c                    sP   |s
t  }t | |dr(td|| _g | _|r>|| _t| || j dS )a  
        A faker Provider capable of getting a list of elements to randomly select from,
        instead of using the predefined list of elements which exist in the default providers in faker.

        :param provider_name: Name of provider, which would translate into the function name e.g. faker.my_fun().
        :param elements: List of values to randomly select from
        :param generator: Generator object. If missing, the default Generator is used.

        :example:
        >>>from faker import Faker
        >>>from faker.providers import DynamicProvider

        >>>medical_professions_provider = DynamicProvider(
        >>>     provider_name="medical_profession",
        >>>     elements=["dr.", "doctor", "nurse", "surgeon", "clerk"],
        >>>)
        >>>fake = Faker()
        >>>fake.add_provider(medical_professions_provider)

        >>>fake.medical_profession()
        "dr."

        __zBProvider name cannot start with __ as it would be ignored by FakerN)	r   superr   
startswithr   r,  r   setattrget_random_value)r   r,  r   r   	__class__r   r   r     s    
zDynamicProvider.__init__)elementr   c                 C   s   | j | dS )zAdd new element.N)r   append)r   r4  r   r   r   add_element  s    zDynamicProvider.add_elementT)r   r   c                 C   s2   | j rt| j dkrtd| j| j d|dd S )zReturns a random value for this provider.

        :param use_weighting: boolean option to use weighting. Defaults to True
        r   z=Elements should be a list of values the provider samples fromr   )r   r   )r   r   r   r   )r   r   r   r   r   r1    s    z DynamicProvider.get_random_value)NN)T)r$  r%  r&  r  r   r   r   r   r6  r)  r1  __classcell__r   r   r2  r   r+    s     ,r+  )rer   collectionsr   typingr   r   r   r   r   r   r	   r   r   r   Zutils.distributionr   r   compiler  r  r  r  r  r  r"  r   floatr*  r   r+  r   r   r   r   <module>   s,   $






     