B
    	`[#                 @   s(   d dl mZ dZdZG dd deZdS )   )BaseProviderTZlac               @   sh   e Zd ZdZdZdZdddZdd	d
ZdddZdddZ	dddZ
dddZd ddZd!ddZdS )"Providera  Implement default lorem provider for Faker.

    .. important::
       The default locale of the lorem provider is ``la``. When using a locale
       without a localized lorem provider, the ``la`` lorem provider will be
       used, so generated words will be in pseudo-Latin. The locale used for
       the standard provider docs was ``en_US``, and ``en_US`` has a localized
       lorem provider which is why the samples here show words in American
       English.
     .   NFc             C   s.   |r|n| j }|r | j||dS | j||dS )a  Generate a tuple of words.

        The ``nb`` argument controls the number of words in the resulting list,
        and if ``ext_word_list`` is provided, words from that list will be used
        instead of those from the locale provider's built-in word list.

        If ``unique`` is ``True``, this method will return a list containing
        unique words. Under the hood, |random_sample| will be used for sampling
        without replacement. If ``unique`` is ``False``, |random_choices| is
        used instead, and the list returned may contain duplicates.

        .. warning::
           Depending on the length of a locale provider's built-in word list or
           on the length of ``ext_word_list`` if provided, a large ``nb`` can
           exhaust said lists if ``unique`` is ``True``, raising an exception.

        :sample:
        :sample: nb=5
        :sample: nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        :sample: nb=4, ext_word_list=['abc', 'def', 'ghi', 'jkl'], unique=True
        )length)	word_listZrandom_sampleZrandom_choices)selfnbext_word_listuniquer    r   M/home/dcms/DCMS/lib/python3.7/site-packages/faker/providers/lorem/__init__.pywords   s    zProvider.wordsc             C   s   |  d|d S )zGenerate a word.

        This method uses |words| under the hood with the ``nb`` argument set to
        ``1`` to generate the result.

        :sample:
        :sample: ext_word_list=['abc', 'def', 'ghi', 'jkl']
               )r   )r	   r   r   r   r   word3   s    	zProvider.word   Tc             C   sR   |dkrdS |r| j |dd}t| j||d}|d  |d< | j|| j S )a  Generate a sentence.

        The ``nb_words`` argument controls how many words the sentence will
        contain, and setting ``variable_nb_words`` to ``False`` will generate
        the exact amount, while setting it to ``True`` (default) will generate
        a random amount (+/-40%, minimum of 1) using |randomize_nb_elements|.

        Under the hood, |words| is used to generate the words, so the argument
        ``ext_word_list`` works in the same way here as it would in that method.

        :sample: nb_words=10
        :sample: nb_words=10, variable_nb_words=False
        :sample: nb_words=10, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        :sample: nb_words=10, variable_nb_words=True,
                 ext_word_list=['abc', 'def', 'ghi', 'jkl']
        r    r   )min)r
   r   )randomize_nb_elementslistr   titleword_connectorjoinsentence_punctuation)r	   Znb_wordsZvariable_nb_wordsr   r   r   r   r   sentence>   s    zProvider.sentencec                s    fddt d|D S )a  Generate a list of sentences.

        This method uses |sentence| under the hood to generate sentences, and
        the ``nb`` argument controls exactly how many sentences the list will
        contain. The ``ext_word_list`` argument works in exactly the same way
        as well.

        :sample:
        :sample: nb=5
        :sample: nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        c                s   g | ]}j  d qS ))r   )r   ).0_)r   r	   r   r   
<listcomp>f   s   z&Provider.sentences.<locals>.<listcomp>r   )range)r	   r
   r   r   )r   r	   r   	sentencesZ   s    zProvider.sentencesc             C   s8   |dkrdS |r| j |dd}| j| j||d}|S )a@  Generate a paragraph.

        The ``nb_sentences`` argument controls how many sentences the paragraph
        will contain, and setting ``variable_nb_sentences`` to ``False`` will
        generate the exact amount, while setting it to ``True`` (default) will
        generate a random amount (+/-40%, minimum of 1) using
        |randomize_nb_elements|.

        Under the hood, |sentences| is used to generate the sentences, so the
        argument ``ext_word_list`` works in the same way here as it would in
        that method.

        :sample: nb_sentences=5
        :sample: nb_sentences=5, variable_nb_sentences=False
        :sample: nb_sentences=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        :sample: nb_sentences=5, variable_nb_sentences=False,
                 ext_word_list=['abc', 'def', 'ghi', 'jkl']
        r   r   r   )r   )r   )r   r   r   r!   )r	   Znb_sentencesZvariable_nb_sentencesr   parar   r   r   	paragraphi   s    
zProvider.paragraphc                s    fddt d|D S )a~  Generate a list of paragraphs.

        This method uses |paragraph| under the hood to generate paragraphs, and
        the ``nb`` argument controls exactly how many sentences the list will
        contain. The ``ext_word_list`` argument works in exactly the same way
        as well.

        :sample: nb=5
        :sample: nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl']
        c                s   g | ]}j  d qS ))r   )r#   )r   r   )r   r	   r   r   r      s   z'Provider.paragraphs.<locals>.<listcomp>r   )r    )r	   r
   r   r   )r   r	   r   
paragraphs   s    zProvider.paragraphs   c       	      C   s~  g }|dk rt d|dk rxR|snd}x<||k rb|r:| jnd| j|d }|| |t|7 }q(W |  qW |d d  |d dd  |d< t|d }||  | j7  < n|d	k rx|sd}x>||k r|r| jnd| j|d }|| |t|7 }qW |  qW n\xZ|srd}x@||k rd|r:d
nd| j	|d }|| |t|7 }q&W |  qW d
|S )a"  Generate a text string.

        The ``max_nb_chars`` argument controls the approximate number of
        characters the text string will have, and depending on its value, this
        method may use either |words|, |sentences|, or |paragraphs| for text
        generation. The ``ext_word_list`` argument works in exactly the same way
        it would in any of those methods.

        :sample: max_nb_chars=20
        :sample: max_nb_chars=80
        :sample: max_nb_chars=160
        :sample: ext_word_list=['abc', 'def', 'ghi', 'jkl']
           z6text() can only generate text of at least 5 characters   r   r   )r   r   Nd   
)
ValueErrorr   r   appendlenpopupperr   r   r#   r   )	r	   max_nb_charsr   textsizer   
last_indexr   r#   r   r   r   r0      sD    

$


zProvider.textc                s    fddt d|D S )a   Generate a list of text strings.

        The ``nb_texts`` argument controls how many text strings the list will
        contain, and this method uses |text| under the hood for text generation,
        so the two remaining arguments, ``max_nb_chars`` and ``ext_word_list``
        will work in exactly the same way as well.

        :sample: nb_texts=5
        :sample: nb_texts=5, max_nb_chars=50
        :sample: nb_texts=5, max_nb_chars=50,
                 ext_word_list=['abc', 'def', 'ghi', 'jkl']
        c                s   g | ]}  qS r   )r0   )r   r   )r   r/   r	   r   r   r      s   z"Provider.texts.<locals>.<listcomp>r   )r    )r	   Znb_textsr/   r   r   )r   r/   r	   r   texts   s    zProvider.texts)r   NF)N)r   TN)r   N)r   TN)r   N)r%   N)r   r%   N)__name__
__module____qualname____doc__r   r   r   r   r   r!   r#   r$   r0   r3   r   r   r   r   r   	   s   




  


=r   N)r   r   Z	localizedZdefault_localer   r   r   r   r   <module>   s   