
    \j2:                     Z    d dl 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  G d de
      Zy)    N)OrderedDict)DictLiteralOptionalSequenceUnion   )BaseProviderElementsTypec                      e Zd ZU dZdZee   ed<   dZee   ed<   dZ	ee   ed<   dZ
ee   ed	<   d
Zee   ed<   dZee   ed<   dZee   ed<   dZee   ed<    edefdefde	fde
fdefdefdefdeff      Zeeee   f   ed<   dZee   ed<   dZee   ed<   dZee   ed <   d!Zee   ed"<   d#Zee   ed$<    edefdefd%efdefdeff      Zeeee   f   ed&<   d'd(d)d*d*d)d+Zeeef   ed,<   d-Zee   ed.<   d>d0ee   d1efd2Zd?d0ee   d3ee   d1efd4Zd>d0ee   d1efd5Z	 	 	 	 	 d@d6ed0ee   d3eeee e   f      d7ee!   d8e"d9   d1efd:Z#d>d;ee   d1efd<Z$d>d;ee   d1efd=Z%y/)AProviderz*Implement default file provider for Faker.)zapplication/atom+xmlzapplication/ecmascriptzapplication/EDI-X12zapplication/EDIFACTzapplication/jsonzapplication/javascriptzapplication/octet-streamzapplication/oggzapplication/pdfzapplication/postscriptzapplication/rdf+xmlzapplication/rss+xmlzapplication/soap+xmlzapplication/font-woffzapplication/xhtml+xmlzapplication/xml-dtdzapplication/xop+xmlzapplication/zipzapplication/gzipapplication_mime_types)	zaudio/basicz	audio/L24z	audio/mp4z
audio/mpegz	audio/oggzaudio/vorbiszaudio/vnd.rn-realaudiozaudio/vnd.wavez
audio/webmaudio_mime_types)z	image/gifz
image/jpegzimage/pjpegz	image/pngzimage/svg+xmlz
image/tiffzimage/vnd.microsoft.iconimage_mime_types)zmessage/httpzmessage/imdn+xmlzmessage/partialzmessage/rfc822message_mime_types)zmodel/examplez
model/igesz
model/meshz
model/vrmlzmodel/x3d+binaryzmodel/x3d+vrmlzmodel/x3d+xmlmodel_mime_types)zmultipart/mixedzmultipart/alternativezmultipart/relatedzmultipart/form-datazmultipart/signedzmultipart/encryptedmultipart_mime_types)ztext/cmdztext/cssztext/csvz	text/htmlztext/javascriptz
text/plainz
text/vcardztext/xmltext_mime_types)z
video/mpegz	video/mp4z	video/oggzvideo/quicktimez
video/webmzvideo/x-matroskazvideo/x-ms-wmvzvideo/x-flvvideo_mime_typesapplicationaudioimagemessagemodel	multiparttextvideo
mime_types)flacmp3wavaudio_file_extensions)bmpgifjpegjpgpngtiffimage_file_extensions)csscsvhtmljsjsontxttext_file_extensions)mp4avimovwebmvideo_file_extensions)docdocxxlsxlsxpptpptxodtodsodppagesnumberskeypdfoffice_file_extensionsofficefile_extensionszC:\\)root	separator/)windowslinuxfile_systems_path_rules)sdvdxvdunix_device_prefixesNcategoryreturnc                     |r|n1| j                  t        | j                  j                                     }| j                  | j                  |         S )as  Generate a mime type under the specified ``category``.

        If ``category`` is ``None``, a random category will be used. The list of
        valid categories include ``'application'``, ``'audio'``, ``'image'``,
        ``'message'``, ``'model'``, ``'multipart'``, ``'text'``, and
        ``'video'``.

        :sample:
        :sample: category='application'
        )random_elementlistr   keysselfrQ   s     G/root/env/lib/python3.12/site-packages/faker/providers/file/__init__.py	mime_typezProvider.mime_type   sD      (8T-@-@dooFZFZF\A]-^""4??8#<==    	extensionc                 r    || j                  |      }| j                  j                         }|r| d| S |S )a  Generate a random file name with extension.

        If ``extension`` is ``None``, a random extension will be created
        under the hood using |file_extension| with the specified
        ``category``. If a value for ``extension`` is provided, the
        value will be used instead, and ``category`` will be ignored.
        The actual name part itself is generated using |word|. If
        extension is an empty string then no extension will be added,
        and file_name will be the same as |word|.

        :sample: size=10
        :sample: category='audio'
        :sample: extension='abcdef'
        :sample: category='audio', extension='abcdef'
        :sample: extension=''
        .)file_extension	generatorword)rX   rQ   r\   filenames       rY   	file_namezProvider.file_name   sD    " ++H5I++-,5(1YK(C8Cr[   c                     |2| j                  t        | j                  j                                     }| j                  | j                  |         S )a9  Generate a file extension under the specified ``category``.

        If ``category`` is ``None``, a random category will be used. The list of
        valid categories include: ``'audio'``, ``'image'``, ``'office'``,
        ``'text'``, and ``'video'``.

        :sample:
        :sample: category='image'
        )rT   rU   rE   rV   rW   s     rY   r_   zProvider.file_extension  sJ     **40D0D0I0I0K+LMH""4#7#7#ABBr[   depthabsolutefile_system_rule)rK   rJ   c                 b   |/t        |t              st        |      r| j                  |      }nd}| j                  j                  |d      }|st        d      |d   }|d   }| j                  ||      }	t        d|      D ]"  }
| j                  j                          | |	 }	$ |r||	z   S |	S )a  Generate an pathname to a file.

        This method uses |file_name| under the hood to generate the file
        name itself, and ``depth`` controls the depth of the directory
        path, and |word| is used under the hood to generate the
        different directory names.

        If ``absolute`` is ``True`` (default), the generated path starts
        with ``/`` and is absolute. Otherwise, the generated path is
        relative.

        If used, ``extension`` can be either a string, forcing that
        extension, a sequence of strings (one will be picked at random),
        or an empty sequence (the path will have no extension). Default
        behaviour is the same as |file_name|

        if ``file_system`` is set (default="linux"), the generated path uses
        specified file system path standard, the list of valid file systems include:
        ``'windows'``, ``'linux'``.

        :sample: size=10
        :sample: depth=3
        :sample: depth=5, category='video'
        :sample: depth=5, category='video', extension='abcdef'
        :sample: extension=[]
        :sample: extension=''
        :sample: extension=["a", "bc", "def"]
        :sample: depth=5, category='video', extension='abcdef', file_system='windows'
        N z!Specified file system is invalid.rG   rH   r   )
isinstancestrlenrT   rL   get	TypeErrorrc   ranger`   ra   )rX   re   rQ   r\   rf   rg   fs_rulerG   	seperatorpath_s              rY   	file_pathzProvider.file_path  s    L  Is)C9~ //	:		..223CTJ?@@vK(	NN8Y7q% 	?Ann))+,YKv>D	? 'td{0D0r[   prefixc                     || j                  | j                        }| j                  t        j                        }d| | }|S )zGenerate a Unix device file name.

        If ``prefix`` is ``None``, a random prefix will be used. The list of
        valid prefixes include: ``'sd'``, ``'vd'``, and ``'xvd'``.

        :sample:
        :sample: prefix='mmcblk'
        z/dev/)rT   rP   stringascii_lowercase)rX   ru   suffixrr   s       rY   unix_devicezProvider.unix_deviceH  sJ     >(()B)BCF))&*@*@Avhvh'r[   c                 b    | j                  |      }|t        | j                               z  }|S )zGenerate a Unix partition name.

        This method uses |unix_device| under the hood to create a device file
        name with the specified ``prefix``.

        :sample:
        :sample: prefix='mmcblk'
        )ru   )rz   rk   random_digit)rX   ru   rr   s      rY   unix_partitionzProvider.unix_partitionW  s4     $$F$3D%%'((r[   )N)NN)   NNTrK   )&__name__
__module____qualname____doc__r   r   rk   __annotations__r   r   r   r   r   r   r   r   r   r   r"   r)   r0   r5   rC   rE   rL   rP   r   rZ   rc   r_   intr   r   boolr   rt   rz   r}    r[   rY   r   r   	   s   4&1L- &P+l3' +l3' -S) 
+l3' 
/,s+ *O\#&  
+l3' 
 0;23&'&'*+&'./_%&'		
0JS,s++, 0<, 0<, /,s+ 0<, 1L-   5@+,+,-.)*+,	
5OT#|C001  

 
	0T#t)_ 	 /B,s+A>(3- >3 >D(3- D8C= D\_ D,Cx} C C  "&9=#'8?7171 3-71 E#x}"456	71
 4.71 ""4571 
71r(3- 3 Xc] c r[   r   )rw   collectionsr   typingr   r   r   r   r   ri   r
   r   r   r   r[   rY   <module>r      s"     # ; ; )Y| Yr[   