
    \jI{                     `   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZ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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 dZ e j>                  d	e j@                  e jB                  
       eee"e#f   ee"e#ee#ef   f   f   Z$ee$   Z% G d de      Z&y)    N)JSONEncoder)AnyCallableDictListLiteralOptionalSequenceSetTupleTypeUnionoverload)UnsupportedFeature   )BaseProvider)	TypesSpecT	faker-csv)quotingc                      e Zd ZdEdedefdZdee   fdZdFdedefdZ	e
defd       Ze
ded	   defd
       Ze
ded   defd       ZdGdedeeef   fdZe
defd       Ze
ded	   defd       Ze
ded   defd       ZdGdedeeef   fdZe
defd       Ze
ded	   defd       Ze
ded   defd       ZdGdedeeef   fdZe
defd       Ze
dddej&                  fd       Ze
deej&                  gef   defd       Ze
deej&                  gef   defd       Zefdeeeej&                  gef   eej&                  gef   f      deeeej&                  f   fdZ	 	 	 	 	 dHdedededed edefd!Z	 	 	 	 dId"ed#ed$ed%ee   def
d&Z	 	 	 	 dId"ed#ed$ed%ee   def
d'Z	 	 	 	 dJd(eeef   d)ed*eeeee   ef      d+ee   def
d,Z	 	 	 	 	 dKd-ed.eee      d/eeef   d0ed1ed2edefd3Z	 	 	 	 dLd.eee      d/eeef   d0ed1edef
d4Z	 	 	 	 dLd.eee      d/eeef   d0ed1edef
d5Z	 	 	 	 dLd.eee      d/eeef   d0ed1edef
d6Z	 	 	 	 dMd/ee    d0ed7ee   d8ee!e"      def
d9Z#	 	 	 	 dMd/ee    d0ed7ee   d8ee!e"      def
d:Z$	 	 	 	 dNd;ed<ed=ee%   d>ee%   def
d?Z&dOd/ee'   d0ed@edefdAZ(dBedCedeeef   fdDZ)y)PProviderchance_of_getting_truereturnc                 T    | j                   j                  j                  dd      |k  S )zGenerate a random boolean value based on ``chance_of_getting_true``.

        :sample: chance_of_getting_true=25
        :sample: chance_of_getting_true=50
        :sample: chance_of_getting_true=75
           d   	generatorrandomrandint)selfr   s     G/root/env/lib/python3.12/site-packages/faker/providers/misc/__init__.pybooleanzProvider.boolean   s'     ~~$$,,Q48NNN    c                 \    dddd| j                   j                  j                  dd         S )zGGenerate ``None``, ``True``, or ``False``, each with equal probability.NTF)r   r   r&   r   r   r!   s    r"   null_booleanzProvider.null_boolean'   s8     
 ..


'
'A
.	0 	0r$   lengthc                     | j                   j                  rFt        |      D cg c]'  }| j                   j                  j	                  d      ) }}t        |      S t        j                  |      S c c}w )zGenerate a random binary blob of ``length`` bytes.

        If this faker instance has been seeded, performance will be signficiantly reduced, to conform
        to the seeding.

        :sample: length=64
           )r   
_is_seededranger   	randrangebytesosurandom)r!   r)   _blobs       r"   binaryzProvider.binary0   s^     >>$$BG-PQDNN))33C8PDP; zz&!!	 Qs   ,A2c                      y N r'   s    r"   md5zProvider.md5@   s    r$   
raw_outputTc                      y r6   r7   r!   r9   s     r"   r8   zProvider.md5C       7:r$   Fc                      y r6   r7   r;   s     r"   r8   zProvider.md5F   s    69r$   c                     t        j                  t        | j                  j                  j	                               j                               }|r|j                         S |j                         S )a2  Generate a random MD5 hash.

        If ``raw_output`` is ``False`` (default), a hexadecimal string representation of the MD5 hash
        will be returned. If ``True``, a ``bytes`` object representation will be returned instead.

        :sample: raw_output=False
        :sample: raw_output=True
        )hashlibr8   strr   r   encodedigest	hexdigestr!   r9   ress      r"   r8   zProvider.md5I   sN     %[[T^^-B-B-I-I-K)L)S)S)UV::<}}r$   c                      y r6   r7   r'   s    r"   sha1zProvider.sha1W   s    r$   c                      y r6   r7   r;   s     r"   rG   zProvider.sha1Z   s    8;r$   c                      y r6   r7   r;   s     r"   rG   zProvider.sha1]   r<   r$   c                     t        j                  t        | j                  j                  j	                               j                               }|r|j                         S |j                         S )a6  Generate a random SHA-1 hash.

        If ``raw_output`` is ``False`` (default), a hexadecimal string representation of the SHA-1 hash
        will be returned. If ``True``, a ``bytes`` object representation will be returned instead.

        :sample: raw_output=False
        :sample: raw_output=True
        )r?   rG   r@   r   r   rA   rB   rC   rD   s      r"   rG   zProvider.sha1`   sN     %\\#dnn.C.C.J.J.L*M*T*T*VW::<}}r$   c                      y r6   r7   r'   s    r"   sha256zProvider.sha256n   s     r$   c                      y r6   r7   r;   s     r"   rL   zProvider.sha256q   s    :=r$   c                      y r6   r7   r;   s     r"   rL   zProvider.sha256t   s    9<r$   c                     t        j                  t        | j                  j                  j	                               j                               }|r|j                         S |j                         S )a:  Generate a random SHA-256 hash.

        If ``raw_output`` is ``False`` (default), a hexadecimal string representation of the SHA-256 hash
        will be returned. If ``True``, a ``bytes`` object representation will be returned instead.

        :sample: raw_output=False
        :sample: raw_output=True
        )r?   rL   r@   r   r   rA   rB   rC   rD   s      r"   rL   zProvider.sha256w   sN     %^^C0E0E0L0L0N,O,V,V,XY::<}}r$   c                      y r6   r7   r'   s    r"   uuid4zProvider.uuid4   s    r$   cast_toNc                      y r6   r7   r!   rR   s     r"   rQ   zProvider.uuid4   s    14r$   c                      y r6   r7   rT   s     r"   rQ   zProvider.uuid4   s    ADr$   c                      y r6   r7   rT   s     r"   rQ   zProvider.uuid4   s    EHr$   c                     t        j                  | j                  j                  j	                  d      d      }| ||      S |S )a"  Generate a random UUID4 object and cast it to another type if specified using a callable ``cast_to``.

        By default, ``cast_to`` is set to ``str``.

        May be called with ``cast_to=None`` to return a full-fledged ``UUID``.

        :sample:
        :sample: cast_to=None
              )intversion)uuidUUIDr   r   getrandbits)r!   rR   generated_uuids      r"   rQ   zProvider.uuid4   sB     %)II$..2G2G2S2STW2Xbc$d>**r$   special_charsdigits
upper_case
lower_casec                 &   d}g }|r9|j                  | j                  j                  j                  d             |dz  }|rU|j                  | j                  j                  j                  t        j
                               |t        j
                  z  }|rU|j                  | j                  j                  j                  t        j                               |t        j                  z  }|rU|j                  | j                  j                  j                  t        j                               |t        j                  z  }t        |      |k  sJ d       | j                  ||      }t               }	t        |	      t        |      k  rY|	j                  | j                  j                  j                  dt        |      dz
               t        |	      t        |      k  rYt        |	      D ]  \  }
}||
   ||<    dj                  |      S )a  Generate a random password of the specified ``length``.

        The arguments ``special_chars``, ``digits``, ``upper_case``, and ``lower_case`` control
        what category of characters will appear in the generated password. If set to ``True``
        (default), at least one character from the corresponding category is guaranteed to appear.
        Special characters are characters from ``!@#$%^&*()_+``, digits are characters from
        ``0123456789``, and uppercase and lowercase characters are characters from the ASCII set of
        letters.

        :sample: length=12
        :sample: length=40, special_chars=False, upper_case=False
         z!@#$%^&*()_+z3Required length is shorter than required characters)r)   r   r   )appendr   r   choicestringra   ascii_uppercaseascii_lowercaselenrandom_choicessetaddr    	enumeratejoin)r!   r)   r`   ra   rb   rc   choicesrequired_tokenscharsrandom_indexesiindexs               r"   passwordzProvider.password   s   ( ""4>>#8#8#?#?#OP~%G""4>>#8#8#?#?#NOv}}$G""4>>#8#8#?#?@V@V#WXv---G""4>>#8#8#?#?@V@V#WXv---G?#v-d/dd- (((@ $'5.!C$88t~~44<<QE
QOP .!C$88 ".1 	.HAu*1-E%L	. wwu~r$   uncompressed_size	num_filesmin_file_sizecompressionc                    t        t        |t               xs |dk  t        |t               xs |dk  t        |t               xs |dk  g      rt        d      ||z  |kD  rt	        d      |dv rt
        j                  }n:|dv rt
        j                  }n%|dv rt
        j                  }nt
        j                  }t        j                         }|}t        j                  |d|      5 }t        d	|d	z         D ]  }	| j                  j                         t!        |	      z   }
|||	z
  |z  z
  }|	|k  r,| j                  j"                  j%                  ||      }||z
  }n|}| j                  j'                  |      }|j)                  |
|        	 d
d
d
       |j+                         S # 1 sw Y   |j+                         S xY w)a  Generate a bytes object containing a random valid zip archive file.

        The number and sizes of files contained inside the resulting archive can be controlled
        using the following arguments:

        - ``uncompressed_size`` - the total size of files before compression, 16 KiB by default
        - ``num_files`` - the number of files archived in resulting zip file, 1 by default
        - ``min_file_size`` - the minimum size of each file before compression, 4 KiB by default

        No compression is used by default, but setting ``compression`` to one of the values listed
        below will use the corresponding compression type.

        - ``'bzip2'`` or ``'bz2'`` for BZIP2
        - ``'lzma'`` or ``'xz'`` for LZMA
        - ``'deflate'``, ``'gzip'``, or ``'gz'`` for GZIP

        :sample: uncompressed_size=256, num_files=4, min_file_size=32
        :sample: uncompressed_size=256, num_files=32, min_file_size=4, compression='bz2'
        r   O`num_files`, `min_file_size`, and `uncompressed_size` must be positive integersH`uncompressed_size` is smaller than the calculated minimum required sizebzip2bz2lzmaxz)deflategzipgzw)moder{   r   N)any
isinstancerZ   
ValueErrorAssertionErrorzipfile	ZIP_BZIP2ZIP_LZMAZIP_DEFLATED
ZIP_STOREDioBytesIOZipFiler-   r   pystrr@   r   r    r4   writestrgetvalue)r!   rx   ry   rz   r{   compression_
zip_bufferremaining_size
zip_handlefile_numberfilenamemax_allowed_size	file_sizedatas                 r"   zipzProvider.zip   s   4 y#..@)q.}c22Hmq6H0#66P:Kq:P
 a  9$'88 Z  **",,LN*"++L55"//L"--LZZ\
*__Zc|L 	4PZ$Q	A6 4>>//1C4DD#1Y5LP]4]#] * $ 5 5 = =mM] ^I%3i%?N .I~~,,Y7##Hd34	4 ""$$	4 ""$$s   ,B&F++Gc                    t        t        |t               xs |dk  t        |t               xs |dk  t        |t               xs |dk  g      rt        d      ||z  |kD  rt	        d      d}|dv rd}n|dv rd}n|d	v rd
}t        j                         }|}t        j                  ||      5 }t        d|dz         D ]  }	t        j                         }
| j                  j                         t        |	      z   }|||	z
  |z  z
  }|	|k  r,| j                  j                  j                  ||      }||z
  }n|}t        j                  |      }| j                  j!                  |      }|
j#                  |       t%        |
j'                               |_        |
j+                  d       |j-                  ||
       |
j/                           	 ddd       |j'                         S # 1 sw Y   |j'                         S xY w)a  Generate a bytes object containing a random valid tar file.

        The number and sizes of files contained inside the resulting archive can be controlled
        using the following arguments:

        - ``uncompressed_size`` - the total size of files before compression, 16 KiB by default
        - ``num_files`` - the number of files archived in resulting zip file, 1 by default
        - ``min_file_size`` - the minimum size of each file before compression, 4 KiB by default

        No compression is used by default, but setting ``compression`` to one of the values listed
        below will use the corresponding compression type.

        - ``'bzip2'`` or ``'bz2'`` for BZIP2
        - ``'lzma'`` or ``'xz'`` for LZMA
        - ``'gzip'`` or ``'gz'`` for GZIP

        :sample: uncompressed_size=256, num_files=4, min_file_size=32
        :sample: uncompressed_size=256, num_files=32, min_file_size=4, compression='bz2'
        r   r}   r~   zw|)r   r   zw|gzr   zw|bz2r   zw|xz)r   fileobjr   )nameN)r   r   rZ   r   r   r   r   tarfileopenr-   r   r   r@   r   r    TarInfor4   writerk   r   sizeseekaddfileclose)r!   rx   ry   rz   r{   r   
tar_bufferr   
tar_handler   file_bufferr   r   r   tarinfor   s                   r"   tarzProvider.tar  s   4 y#..@)q.}c22Hmq6H0#66P:Kq:P
 a  9$'88 Z  8<.(D,,DN*DZZ\
*\\tZ8 	$J$Q	A6 $ jjl>>//1C4DD#1Y5LP]4]#] * $ 5 5 = =mM] ^I%3i%?N .I!//x8~~,,Y7!!$'";#7#7#9:  #""7K8!!##$	$& ""$$'	$& ""$$s   2D"G--Hr   image_formathue
luminosityc           
         	 ddl }ddl}|\  }}|j                  j                  d|| j                  j                  ||            }|j                  j                  |      }	|	j                  t        | j                  dd            D 
cg c]&  }
| j                  d|      | j                  d|      f( c}
| j                  j                  ||      | j                  j                  ||      	       t        j                         5 }|j                  ||
       |j!                  d       |j#                         cddd       S # t        $ r t        dd      w xY wc c}
w # 1 sw Y   yxY w)a;  Generate an image and draw a random polygon on it using the Python Image Library.
        Without it installed, this provider won't be functional. Returns the bytes representing
        the image in a given format.

        The argument ``size`` must be a 2-tuple containing (width, height) in pixels. Defaults to 256x256.

        The argument ``image_format`` can be any valid format to the underlying library like ``'tiff'``,
        ``'jpeg'``, ``'pdf'`` or ``'png'`` (default). Note that some formats need present system libraries
        prior to building the Python Image Library.
        Refer to https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html for details.

        The arguments ``hue`` and ``luminosity`` are the same as in the color provider and are simply forwarded to
        it to generate both the background and the shape colors. Therefore, you can ask for a "dark blue" image, etc.

        :sample: size=(2, 2), hue='purple', luminosity='bright', image_format='pdf'
        :sample: size=(16, 16), hue=[90,270], image_format='ico'
        r   Nz-`image` requires the `Pillow` python library.imageRGB)r   r         )filloutline)format)	PIL.ImagePIL.ImageDrawImportErrorr   Imagenewr   color	ImageDrawDrawpolygonr-   
random_intr   r   saver   read)r!   r   r   r   r   PILwidthheightr   drawr2   fobjs               r"   r   zProvider.image`  sG   0	_  v		eT4>>+?+?CT^+?+_`}}!!%(NSTXTcTcdegiTjNkldooa'F)CDl%%#*%ENN((SZ(H 	 	

 ZZ\ 	TJJtLJ1IIaL99;	 	  	_$%TV]^^	_ m	 	s   E 
+E 	4E%E%E.dialectheaderdata_columnsnum_rowsinclude_row_ids	fmtparamsc                    t        |t              r|dk  rt        d      t        |t        t        f      st        d      |Ct        |t        t        f      st        d      t        |      t        |      k7  rt        d      t        j                         }t        j                  |fd|i|}|r0|rt        |      }|j                  dd       |j                  |       t        d|dz         D ]X  }	|D 
cg c]  }
| j                  j                  |
       }}
|r|j                  dt!        |	             |j                  |       Z |j#                         S c c}
w )	a  Generate random delimiter-separated values.

        This method's behavior share some similarities with ``csv.writer``. The ``dialect`` and
        ``**fmtparams`` arguments are the same arguments expected by ``csv.writer`` to control its
        behavior, and instead of expecting a file-like object to where output will be written, the
        output is controlled by additional keyword arguments and is returned as a string.

        The ``dialect`` argument defaults to ``'faker-csv'`` which is the name of a ``csv.excel``
        subclass with full quoting enabled.

        The ``header`` argument expects a list or a tuple of strings that will serve as the header row
        if supplied. The ``data_columns`` argument expects a list or a tuple of string tokens, and these
        string tokens will be passed to  :meth:`pystr_format() <faker.providers.python.Provider.pystr_format>`
        for data generation. Argument Groups are used to pass arguments to the provider methods.
        Both ``header`` and ``data_columns`` must be of the same length.

        Example:
            fake.set_arguments('top_half', {'min_value': 50, 'max_value': 100})
            fake.dsv(data_columns=('{{ name }}', '{{ pyint:top_half }}'))

        The ``num_rows`` argument controls how many rows of data to generate, and the ``include_row_ids``
        argument may be set to ``True`` to include a sequential row ID column.

        :sample: dialect='excel', data_columns=('{{name}}', '{{address}}')
        :sample: dialect='excel-tab', data_columns=('{{name}}', '{{address}}'), include_row_ids=True
        :sample: data_columns=('{{name}}', '{{address}}'), num_rows=5, delimiter='$'
        r   z%`num_rows` must be a positive integerz(`data_columns` must be a tuple or a listz"`header` must be a tuple or a listz6`header` and `data_columns` must have matching lengthsr   IDr   )r   rZ   r   listtuple	TypeErrorrk   r   StringIOcsvwriterinsertwriterowr-   r   pystr_formatr@   r   )r!   r   r   r   r   r   r   
dsv_bufferr   row_numcolumnrows               r"   dsvzProvider.dsv  s8   J (C(HMDEE,u6FGGftUm4 DEE6{c,// !YZZ[[]
JEE9Efa&OOF#Q1- 	!GEQR64>>..v6RCR

1c'l+OOC 	! ""$$ Ss   ;"Ec                 .    | j                  ||||d      S )a  Generate random comma-separated values.

        For more information on the different arguments of this method, please refer to
        :meth:`dsv() <faker.providers.misc.Provider.dsv>` which is used under the hood.

        :sample: data_columns=('{{name}}', '{{address}}'), num_rows=10, include_row_ids=False
        :sample: header=('Name', 'Address', 'Favorite Color'),
                data_columns=('{{name}}', '{{address}}', '{{safe_color_name}}'),
                num_rows=10, include_row_ids=True
        ,r   r   r   r   	delimiterr   r!   r   r   r   r   s        r"   r   zProvider.csv  )    " xx%+  
 	
r$   c                 .    | j                  ||||d      S )a   Generate random tab-separated values.

        For more information on the different arguments of this method, please refer to
        :meth:`dsv() <faker.providers.misc.Provider.dsv>` which is used under the hood.

        :sample: data_columns=('{{name}}', '{{address}}'), num_rows=10, include_row_ids=False
        :sample: header=('Name', 'Address', 'Favorite Color'),
                data_columns=('{{name}}', '{{address}}', '{{safe_color_name}}'),
                num_rows=10, include_row_ids=True
        	r   r   r   s        r"   tsvzProvider.tsv  s)    " xx%+  
 	
r$   c                 .    | j                  ||||d      S )a  Generate random pipe-separated values.

        For more information on the different arguments of this method, please refer to
        :meth:`dsv() <faker.providers.misc.Provider.dsv>` which is used under the hood.

        :sample: data_columns=('{{name}}', '{{address}}'), num_rows=10, include_row_ids=False
        :sample: header=('Name', 'Address', 'Favorite Color'),
                data_columns=('{{name}}', '{{address}}', '{{safe_color_name}}'),
                num_rows=10, include_row_ids=True
        |r   r   r   s        r"   psvzProvider.psv  r   r$   indentclsc                 H    | j                  ||||      j                         S )z
        Generate random JSON structure and return as bytes.

        For more information on the different arguments of this method, refer to
        :meth:`json() <faker.providers.misc.Provider.json>` which is used under the hood.
        )r   r   r   r   )jsonrA   )r!   r   r   r   r   s        r"   
json_byteszProvider.json_bytes  s%     yylXfZ]y^eeggr$   c                    	
 ddd}|r|n|}dt         t           dt        f
 fd
dt        t        t        t
        t        t        t        f   f   dt        f	 fd	dt        t        t        f   dt        f	
fd	}|d
k(  rt        j                   ||      ||      S t        |      D cg c]
  } ||       }}t        j                  |||      S c c}w )a  
        Generate random JSON structure values.

        Using a dictionary or list of records that is passed as ``data_columns``,
        define the structure that is used to build JSON structures.  For complex
        data structures it is recommended to use the dictionary format.

        Data Column Dictionary format:
            {'key name': 'definition'}

        The definition can be 'provider', 'provider:argument_group', tokenized
        'string {{ provider:argument_group }}' that is passed to the python
        provider method pystr_format() for generation, or a fixed '@word'.
        Using Lists, Tuples, and Dicts as a definition for structure.

        Example:
            fake.set_arguments('top_half', {'min_value': 50, 'max_value': 100})
            fake.json(data_columns={'Name': 'name', 'Score': 'pyint:top_half'})

        Data Column List format:
            [('key name', 'definition', {'arguments'})]

        With the list format the definition can be a list of records, to create
        a list within the structure data.  For literal entries within the list,
        set the 'field_name' to None.

        :param data_columns: specification for the data structure
        :type data_columns: dict
        :param num_rows: number of rows the returned
        :type num_rows: int
        :param indent: number of spaces to indent the fields
        :type indent: int
        :param cls: optional json encoder to use for non-standard objects such as datetimes
        :type cls: json.JSONEncoder
        :return: Serialized JSON data
        :rtype: str

        :sample: data_columns={'Spec': '@1.0.1', 'ID': 'pyint',
                'Details': {'Name': 'name', 'Address': 'address'}}, num_rows=2
        :sample: data_columns={'Candidates': ['name', 'name', 'name']},
                num_rows=1
        :sample: data_columns=[('Name', 'name'), ('Points', 'pyint',
                {'min_value': 50, 'max_value': 100})], num_rows=1
        {{name}}{{address}})r   	residencyr   r   c                 f   i }| D ]  ^}}}|r|d   ni }t        |t              st        d      | j                  |fi |c S t        |t              r |      ||<   ]t        |t
        t        f      r|D cg c]  } |g       c}||<    j                  |fi |||<    |S c c}w )Nr   ,Invalid arguments type. Must be a dictionary)r   dictr   _value_format_selectionr   r   rm   )	r   entryr   
definition	argumentskwargsitemprocess_list_structurer!   s	          r"   r  z-Provider.json.<locals>.process_list_structure_  s    $&E04 U,j9)21!&$/#$RSS<7477
MfMMj%0"8"DE$K
T3K8NX"Yd#94&#A"YE$K">$">">z"TV"TE$KU L #Zs   =B.c                    i }t        | t              rj                  |       S t        | t              r| j	                         D ]z  \  }}t        |t
        t        t        f      r|D cg c]
  } |       c}||<   ;t        |t        t        t        t        f      r |      ||<   gj                  |      ||<   | |S | S c c}w r6   )r   r@   r   r   itemsr   r   rm   rZ   floatbool)r   r   r   r   r  process_dict_structurer!   s        r"   r	  z-Provider.json.<locals>.process_dict_structures  s    $&E$$33D99$%(,

 O$D*!*udC.@APZ&['=d'C&[d#JsE40HI&<Z&Hd&*&B&B:&NdO K '\s   *Cr   c                 z    t        | t              r |       S t        | t              r |       S t        d      )Nz7Invalid data_columns type. Must be a dictionary or list)r   r   r   r   )r   r	  r  s    r"   create_json_structurez,Provider.json.<locals>.create_json_structure  s9    ,--l;;,--l;;UVVr$   r   )r   r   )r
   r   r   rZ   r  r  r   r@   r   r   r   dumpsr-   )r!   r   r   r   r   default_data_columnsr  r2   r   r	  r  s   `        @@r"   r   zProvider.json&  s    h & 
 ;G,L`	# 	3 	(	sE4c3h/O)P 	UX 	$	WdDj0A 	Wd 	W q=::3LA&VYZZ=B8_M%l3MMzz$v377 Ns   0Cnb_elementsvariable_nb_elementsvalue_typesallowed_typesc                     	 ddl }| j                  j	                  ||||      }| j                  j                         |i}|j                  |      S # t        $ r t        dd      w xY w)a  
        Returns some XML.

        :nb_elements: number of elements for dictionary
        :variable_nb_elements: is use variable number of elements for dictionary
        :value_types: type of dictionary values

        Note: this provider required xmltodict library installed
        r   Nz.`xml` requires the `xmltodict` Python library.xml)r  r  r  r  )	xmltodictr   r   r   pydictwordunparse)r!   r  r  r  r  r  _dicts          r"   r  zProvider.xml  s~     	^ %%#!5#'	 & 
 $$&.  ''  	^$%UW\]]	^s   A A(alignc           	         dddddifg}||}ddd	d
}g }t        |      D ]  }g }|D ]g  ^}	}
}|r|d   ni }t        |t              st        d       | j                  |
fi |}|j                  ||j                  |d       |	 dd|	        i |j                  dj                  |              dj                  |      S )a  
        Generate random fixed width values.

        Using a list of tuple records that is passed as ``data_columns``, that
        defines the structure that will be generated. Arguments within the
        record are provider specific, and should be a dictionary that will be
        passed to the provider method.

        Data Column List format
            [('field width', 'definition', {'arguments'})]

        The definition can be 'provider', 'provider:argument_group', tokenized
        'string {{ provider:argument_group }}' that is passed to the python
        provider method pystr_format() for generation, or a fixed '@word'.
        Using Lists, Tuples, and Dicts as a definition for structure.

        Argument Groups can be used to pass arguments to the provider methods,
        but will override the arguments supplied in the tuple record.

        Example:
            fake.set_arguments('top_half', {'min_value': 50, 'max_value': 100})
            fake.fixed_width(data_columns=[(20, 'name'), (3, 'pyint:top_half')])

        :param data_columns: specification for the data structure
        :type data_columns: list
        :param num_rows: number of rows the generator will yield
        :type num_rows: int
        :param align: positioning of the value. (left, middle, right)
        :type align: str
        :return: Serialized Fixed Width data
        :rtype: str

        :sample: data_columns=[(20, 'name'), (3, 'pyint', {'min_value': 50,
                'max_value': 100})], align='right', num_rows=2
        )   r   r   pyint	max_valuer  N<^>)leftmiddlerightr   r   re   
)r-   r   r   r   r   rf   getrp   )r!   r   r   r  r  	align_mapr   r2   r   r   r   r  r  results                 r"   fixed_widthzProvider.fixed_width  s   J +r*+ 
 (<L
	
 x 	&AC1= S-zI)21!&$/#$RSS555jKFK

fimmE3&?%@p$GH&5QRS KK%	& yyr$   r   r  c                    t        j                  d|      r| j                  j                  |      S t        j                  d|      r|j	                  d      S t        j                  d|      rh|j                  d      \  }}| j                  j                  |j                               } | j                  j                  |j                         fi |S  | j                  j                  |fi |S )a  
        Formats the string in different ways depending on its contents.

        The return can be the '@word' itself, a '{{ token }}' passed to PyStr,
        or a 'provider:argument_group' format field that returns potentially
        a non-string type.

        This ensures that Numbers, Boolean types that are generated in the
        JSON structures in there proper type, and not just strings.
        z.*\{\{.*\}\}.*z^@.*@z^[a-zA-Z0-9_-]*:\w:)	rematchr   r   lstripsplitget_argumentsstripr   )r!   r   r  argument_groupr  s        r"   r   z Provider._value_format_selection  s     88%z2>>..z:: 88GZ($$S)) 88):6)3)9)9#)>&J44^5I5I5KLI(4>>(()9)9);IyII %t~~$$Z:6::r$   )2   )i   )F)
   TTTT)i   r   i   N))r+   r+   pngNN)r   Nr   r   r4  F)Nr6  r4  F)Nr4  NN)r4  TNN)Nr4  r!  )*__name__
__module____qualname__rZ   r  r#   r	   r(   r/   r4   r   r@   r8   r   r   rG   rL   rQ   r\   r]   r   rw   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r  DataColumnsr(  r   r7   r$   r"   r   r      s`   Oc O4 O0htn 0"S " "  S :gdm:: :9gen99 9d uUCZ/@  c ;wt};; ;:wu~:#: :t eSj0A      ==5= =<<C< < %s
2C  s 4T4dii4 4DXtyyk3&67DCD DHXtyyk5&89HeH H ^a%$))c)9 :Hdii[RWEW<X XYZ 
uc499$	%* "11 1 	1
 1 1 
1j "'!%)@%@% @% 	@%
 c]@% 
@%H "'!%)E%E% E% 	E%
 c]E% 
E%R !+!8<$()CHo) ) eC#345	)
 SM) 
)Z #*.(C %?%?% #'?% CHo	?%
 ?% ?% ?% 
?%F +/(C %
#'
 CHo
 	

 
 

6 +/(C %
#'
 CHo
 	

 
 

6 +/(C %
#'
 CHo
 	

 
 

6 (, $+/htnh h 	h
 d;'(h 
h" (, $+/l8tnl8 l8 	l8
 d;'(l8 
l8` %)+/-1(( #( i(	(
  	*( 
(:>(= >PS >ad >ru >@;# ; ;sTWx ;r$   r   )'r   r?   r   r   r0   r,  rh   r   r\   r   r   typingr   r   r   r   r   r	   r
   r   r   r   r   r   faker.exceptionsr   re   r   pythonr   	localizedregister_dialectexcel	QUOTE_ALLrZ   r@   
ColumnSpecr:  r   r7   r$   r"   <module>rC     s    
  	  	 	      l l l l /  	   [#))S]] C 5c?E#sDcN*B$CCD
:p;| p;r$   