ó
    Ñ]j`  ã                   ó(  • S r SSKJr  SSKJrJrJrJrJ	r	J
r
  SSKJrJrJr  SSKJrJr  SSKJrJr  SSKJr  / SQr " S	 S
\5      r " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      r " S S\5      rg)zMVarious display related classes.

Authors : MinRK, gregcaporaso, dannystaple
é    )Úescape)ÚexistsÚisfileÚsplitextÚabspathÚjoinÚisdir)ÚwalkÚsepÚfsdecode)ÚDisplayObjectÚTextDisplayObject)ÚTupleÚOptional)ÚIterable)ÚAudioÚIFrameÚYouTubeVideoÚ
VimeoVideoÚScribdDocumentÚFileLinkÚ	FileLinksÚCodec                   ó¸   ^ • \ rS rSrSrSrSSS.U 4S jjjrU 4S jr\S 5       r	\S	\
\\4   4S
 j5       r\S 5       r\S 5       rS rS rS rS rS rSrU =r$ )r   é   am  Create an audio object.

When this object is returned by an input cell or passed to the
display function, it will result in Audio controls being displayed
in the frontend (only works in the notebook).

Parameters
----------
data : numpy array, list, unicode, str or bytes
    Can be one of

      * Numpy 1d array containing the desired waveform (mono)
      * Numpy 2d array containing waveforms for each channel.
        Shape=(NCHAN, NSAMPLES). For the standard channel order, see
        http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx
      * List of float or integer representing the waveform (mono)
      * String containing the filename
      * Bytestring containing raw PCM data or
      * URL pointing to a file on the web.

    If the array option is used, the waveform will be normalized.

    If a filename or url is used, the format support will be browser
    dependent.
url : unicode
    A URL to download the data from.
filename : unicode
    Path to a local file to load the data from.
embed : boolean
    Should the audio data be embedded using a data URI (True) or should
    the original source be referenced. Set this to True if you want the
    audio to playable later with no internet connection in the notebook.

    Default is `True`, unless the keyword argument `url` is set, then
    default value is `False`.
rate : integer
    The sampling rate of the raw data.
    Only required when data parameter is being used as an array
autoplay : bool
    Set to True if the audio should immediately start playing.
    Default is `False`.
normalize : bool
    Whether audio should be normalized (rescaled) to the maximum possible
    range. Default is `True`. When set to `False`, `data` must be between
    -1 and 1 (inclusive), otherwise an error is raised.
    Applies only when `data` is a list or array of samples; other types of
    audio are never normalized.

Examples
--------

>>> import pytest
>>> np = pytest.importorskip("numpy")

Generate a sound

>>> import numpy as np
>>> framerate = 44100
>>> t = np.linspace(0,5,framerate*5)
>>> data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)
>>> Audio(data, rate=framerate)
<IPython.lib.display.Audio object>

Can also do stereo or more channels

>>> dataleft = np.sin(2*np.pi*220*t)
>>> dataright = np.sin(2*np.pi*224*t)
>>> Audio([dataleft, dataright], rate=framerate)
<IPython.lib.display.Audio object>

From URL:

>>> Audio("http://www.nch.com.au/acm/8k16bitpcm.wav")  # doctest: +SKIP
>>> Audio(url="http://www.w3schools.com/html/horse.ogg")  # doctest: +SKIP

From a File:

>>> Audio('IPython/lib/tests/test.wav')  # doctest: +SKIP
>>> Audio(filename='IPython/lib/tests/test.wav')  # doctest: +SKIP

From Bytes:

>>> Audio(b'RAW_WAV_DATA..')  # doctest: +SKIP
>>> Audio(data=b'RAW_WAV_DATA..')  # doctest: +SKIP

See Also
--------
ipywidgets.Audio

     Audio widget with more more flexibility and options.

ÚrbN©Ú
element_idc                ól  >• Uc  Uc  Uc  [        S5      eUSL a  Uc  [        S5      eUb  USLa  SU l        OSU l        X`l        X€l        [        [
        U ]  XUS9  U R                  bJ  [        U R                  [        5      (       d*  Uc  [        S5      e[
        R                  XU5      U l        g g g )Nz6No audio data found. Expecting filename, url, or data.Fz,No url found. Expecting url when embed=FalseT©ÚdataÚurlÚfilenamezKrate must be specified when data is a numpy array or list of audio samples.)Ú
ValueErrorÚembedÚautoplayr   Úsuperr   Ú__init__r!   Ú
isinstanceÚbytesÚ	_make_wav)
Úselfr!   r#   r"   r%   Úrater&   Ú	normalizer   Ú	__class__s
            €ÚP/home/mande/repo/quber/.venv/lib/python3.13/site-packages/IPython/lib/display.pyr(   ÚAudio.__init__q   s²   ø€ àÑ ¡°±ÜÐUÓVÐVØ�EŠ>˜c™kÜÐKÓLÐLà‰?˜u¨DÒ0ØˆD�JàˆDŒJØ ŒØ$ŒÜŒe�TÑ#¨ÀÐ#ÑJà�9‰9Ñ ¬°D·I±I¼u×)EÑ)EØ‰|Ü Ð!nÓoÐoÜŸ™¨°IÓ>ˆD�Ið *FÐ ó    c                 ó&  >• SSK nU R                  (       a  [        [        U ]  5         U R
                  b$  UR                  U R
                  5      S   U l        gU R                  b$  UR                  U R                  5      S   U l        gSU l        g)z%Reload the raw data from file or URL.r   Nz	audio/wav)	Ú	mimetypesr%   r'   r   Úreloadr#   Ú
guess_typeÚmimetyper"   )r,   r4   r/   s     €r0   r5   ÚAudio.reload…   sk   ø€ ãØ�:�:Ü”%˜Ñ%Ô'à�=‰=Ñ$Ø%×0Ñ0°·±Ó?ÀÑBˆD�MØ�X‰XÑ!Ø%×0Ñ0°·±Ó:¸1Ñ=ˆD�Mà'ˆD�Mr2   c                 ó²  • SSK Jn  SSKn [        R	                  X5      u  pVU" 5       nUR                  USS9nUR                  U5        UR                  U5        UR                  S5        UR                  SS5        UR                  U5        UR                  5       n	UR                  5         U	$ ! [
         a    [        R                  X5      u  pV N²f = f)z,Transform a numpy array to a PCM bytestring r   )ÚBytesIONÚwb)Úmodeé   ÚNONE)Úior:   Úwaver   Ú"_validate_and_normalize_with_numpyÚImportErrorÚ%_validate_and_normalize_without_numpyÚopenÚsetnchannelsÚsetframerateÚsetsampwidthÚsetcomptypeÚwriteframesÚgetvalueÚclose)
r!   r-   r.   r:   r@   ÚscaledÚnchanÚfpÚwaveobjÚvals
             r0   r+   ÚAudio._make_wav’   sÅ   € õ 	Ûð	YÜ!×DÑDÀTÓU‰MˆFñ ‹YˆØ—)‘)˜B D�)Ð)ˆØ×Ñ˜UÔ#Ø×Ñ˜TÔ"Ø×Ñ˜QÔØ×Ñ˜F 6Ô*Ø×Ñ˜FÔ#Ø�k‰k‹mˆØ�‰Œàˆ
øô ó 	YÜ!×GÑGÈÓX‰MˆF‘Eð	Yús   ŒB2 Â2!CÃCÚreturnc                 óÀ  • SS K nUR                  U [        S9n [        U R                  5      S:X  a  SnON[        U R                  5      S:X  a*  U R                  S   nU R
                  R                  5       n O[        S5      eUR                  UR                  U 5      5      n[        R                  XA5      nX-  S-  nUR                  S5      R                  5       U4$ )Nr   )Údtypeé   r=   z*Array audio input must be a 1D or 2D arrayéÿ  z<h)ÚnumpyÚarrayÚfloatÚlenÚshapeÚTÚravelr$   ÚmaxÚabsr   Ú_get_normalization_factorÚastypeÚtobytes)r!   r.   ÚnprM   Úmax_abs_valueÚnormalization_factorrL   s          r0   rA   Ú(Audio._validate_and_normalize_with_numpy©   s·   € ãà�x‰x˜¤EˆxÐ*ˆÜˆt�z‰z‹?˜aÓØ‰EÜ�—‘‹_ Ó!ð
 —J‘J˜q‘MˆEØ—6‘6—<‘<“>‰DäÐIÓJÐJàŸ™˜rŸv™v d›|Ó,ˆÜ$×>Ñ>¸}ÓXÐØÑ,¨uÑ4ˆØ�}‰}˜TÓ"×*Ñ*Ó,¨eÐ3Ð3r2   c           
      óØ  • SS K nSS KnUR                  SU 5      n  [        [        U  Vs/ s H  n[	        U5      PM     sn5      5      n[        R                  XQ5      nUR                  SU  Vs/ s H  n[        XG-  S-  5      PM     sn5      nUR                  S:X  a  UR                  5         Sn	UR                  5       U	4$ s  snf ! [
         a  n[        S5      UeS nAff = fs  snf )Nr   Úfz@Only lists of mono audio are supported if numpy is not installedÚhrV   ÚbigrU   )rX   ÚsysrY   r^   r_   Ú	TypeErrorr   r`   ÚintÚ	byteorderÚbyteswaprb   )
r!   r.   rX   rk   Úxrd   Úere   rL   rM   s
             r0   rC   Ú+Audio._validate_and_normalize_without_numpy¿   sÝ   € ãÛà�{‰{˜3 Ó%ˆð	>Ü!¤#±tÓ&<²t°!¤s¨1¦v±tÑ&<Ó"=Ó>ˆMô
  %×>Ñ>¸}ÓXÐØ—‘˜SÑRVÓ"WÒRVÈQ¤3 qÑ'?À%Ñ'GÖ#HÑRVÑ"WÓXˆØ�=‰=˜EÓ!Ø�O‰OÔØˆØ�~‰~Ó Ð&Ð&ùò '=øÜó 	>Üð 6ó 7Ø<=ð>ûð	>üò
 #Xs-   œC	 ªC¿C	 Á/C'
ÃC	 Ã	
C$ÃCÃC$c                 óH   • U(       d  U S:”  a  [        S5      eU(       a  U $ S$ )NrU   z9Audio data must be between -1 and 1 when normalize=False.)r$   )rd   r.   s     r0   r`   ÚAudio._get_normalization_factorÓ   s%   € æ˜]¨QÓ.ÜÐXÓYÐYÞ )ˆ}Ð0¨qÐ0r2   c                 óˆ   • 0 nU R                   (       a  U R                   US'   U(       a  U R                  U4$ U R                  $ )z@shortcut for returning metadata with url information, if definedr"   )r"   r!   )r,   Úmds     r0   Ú_data_and_metadataÚAudio._data_and_metadataÙ   s6   € àˆØ�8�8ØŸ™ˆBˆu‰IÞØ—9‘9˜b�=Ð à—9‘9Ðr2   c                 ó’   • SnUR                  U R                  5       U R                  U R                  5       U R	                  5       S9$ )Nzê
                <audio {element_id} controls="controls" {autoplay}>
                    <source src="{src}" type="{type}" />
                    Your browser does not support the audio element.
                </audio>
              )ÚsrcÚtyper&   r   )ÚformatÚsrc_attrr7   Úautoplay_attrÚelement_id_attr)r,   rz   s     r0   Ú_repr_html_ÚAudio._repr_html_ã   sF   € ðˆð �z‰z˜dŸm™m›o°D·M±MÈD×L^ÑL^ÓL`Ø%)×%9Ñ%9Ó%;ð ð =ð 	=r2   c                 ó  • SS K nU R                  (       aR  U R                  bE  UR                  U R                  5      R	                  S5      =p!SR                  U R                  US9$ U R                  b  U R                  $ g)Nr   Úasciizdata:{type};base64,{base64})r{   Úbase64Ú )r„   r%   r!   Ú	b64encodeÚdecoder|   r7   r"   )r,   r„   r!   s      r0   r}   ÚAudio.src_attrí   sp   € ÛØ�:�:˜4Ÿ9™9Ñ0Ø ×*Ñ*¨4¯9©9Ó5×<Ñ<¸WÓEÐEˆDØ4×;Ñ;ÀÇÁØCGð <ð Ið Ià�X‰XÑ!Ø—8‘8ˆOàr2   c                 ó(   • U R                   (       a  gg)Nzautoplay="autoplay"r…   )r&   ©r,   s    r0   r~   ÚAudio.autoplay_attrø   s   € Ø�=�=Ø(àr2   c                 óX   • U R                   (       a  SR                  U R                   S9$ g)Nzid="{element_id}"r   r…   )r   r|   rŠ   s    r0   r   ÚAudio.element_id_attrþ   s$   € Ø�O�OØ&×-Ñ-¸¿¹Ð-ÐIÐIàr2   )r&   r!   r   r%   r7   )NNNNNFT)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_read_flagsr(   r5   Ústaticmethodr+   r   r*   rm   rA   rC   r`   rw   r€   r}   r~   r   Ú__static_attributes__Ú__classcell__©r/   s   @r0   r   r      s¦   ø† ñ[ðx €Kð?Ø ÷?ñ ?õ((ð ñó ðð, ð4¸uÀUÈCÀZÑ?Pó 4ó ð4ð* ñ'ó ð'ð& ñ1ó ð1ò
ò=ò	ò÷ð r2   r   c                   óB   • \ rS rSrSrSr S	S\\\      4S jjr	S r
Srg)
r   i  z9
Generic class to embed an iframe in an IPython notebook
zÓ
        <iframe
            width="{width}"
            height="{height}"
            src="{src}{params}"
            frameborder="0"
            allowfullscreen
            {extras}
        ></iframe>
        NÚextrasc                 óJ   • Uc  / nXl         X l        X0l        X@l        XPl        g ©N)rz   ÚwidthÚheightr™   Úparams)r,   rz   rœ   r�   r™   Úkwargss         r0   r(   ÚIFrame.__init__  s'   € ð ‰>ØˆFàŒØŒ
ØŒØŒØ�r2   c           	      ó  • U R                   (       a  SSKJn  SU" U R                   5      -   nOSnU R                  R	                  U R
                  U R                  U R                  USR                  U R                  5      S9$ )zreturn the embed iframer   )Ú	urlencodeÚ?r…   Ú )rz   rœ   r�   rž   r™   )
rž   Úurllib.parser¢   Úiframer|   rz   rœ   r�   r   r™   )r,   r¢   rž   s      r0   r€   ÚIFrame._repr_html_   sh   € à�;�;Ý.Ø™9 T§[¡[Ó1Ñ1‰FàˆFØ�{‰{×!Ñ!Ø—‘Ø—*‘*Ø—;‘;ØØ—8‘8˜DŸK™KÓ(ð "ð 
ð 	
r2   )r™   r�   rž   rz   rœ   r›   )rŽ   r�   r�   r‘   r’   r¦   r   r   Ústrr(   r€   r•   © r2   r0   r   r     s0   † ñð	€Fð EIñ
Ø*2°8¸C±=Ñ*Aõ
õ
r2   r   c                   ó6   ^ • \ rS rSrSrSU 4S jjrS rSrU =r$ )r   i0  a½  Class for embedding a YouTube Video in an IPython session, based on its video id.

e.g. to embed the video from https://www.youtube.com/watch?v=foo , you would
do::

    vid = YouTubeVideo("foo")
    display(vid)

To start from 30 seconds::

    vid = YouTubeVideo("abc", start=30)
    display(vid)

To calculate seconds from time as hours, minutes, seconds use
:class:`datetime.timedelta`::

    start=int(timedelta(hours=1, minutes=46, seconds=40).total_seconds())

Other parameters can be provided as documented at
https://developers.google.com/youtube/player_parameters#Parameters

When converting the notebook using nbconvert, a jpeg representation of the video
will be inserted in the document.
c                 óÌ   >• Xl         SR                  U5      nU(       a/  [        UR                  S/ 5      5      S/-   nUR	                  SUS9  [
        [        U ]  " XbU40 UD6  g )Nz!https://www.youtube.com/embed/{0}r™   zallow="autoplay"rU   )r&   r™   )Úidr|   ÚlistÚgetÚupdater'   r   r(   )	r,   r¬   rœ   r�   Úallow_autoplayrŸ   rz   r™   r/   s	           €r0   r(   ÚYouTubeVideo.__init__J  s_   ø€ ØŒØ1×8Ñ8¸Ó<ˆÞÜ˜&Ÿ*™* X¨rÓ2Ó3Ð7IÐ6JÑJˆFØ�M‰M 1¨VˆMÑ4ÜŒl˜DÒ*¨3°vÑHÀÓHr2   c                 óŠ   • SSK Jn   U" SR                  U R                  S95      R	                  5       $ ! [
         a     g f = f)Nr   )Úurlopenz-https://img.youtube.com/vi/{id}/hqdefault.jpg©r¬   )Úurllib.requestr³   r|   r¬   ÚreadÚIOError)r,   r³   s     r0   Ú_repr_jpeg_ÚYouTubeVideo._repr_jpeg_R  sF   € å*ð	ÙÐJ×QÑQÐUY×U\ÑU\ÐQÐ]Ó^×cÑcÓeÐeøÜó 	Ùð	ús   ˆ,5 µ
AÁAr´   )é�  é,  F)	rŽ   r�   r�   r‘   r’   r(   r¸   r•   r–   r—   s   @r0   r   r   0  s   ø† ñ÷2I÷ð r2   r   c                   ó0   ^ • \ rS rSrSrSU 4S jjrSrU =r$ )r   i[  zQ
Class for embedding a Vimeo video in an IPython session, based on its video id.
c                 óT   >• SR                  U5      n[        [        U ]  " XRU40 UD6  g )Nz"https://player.vimeo.com/video/{0})r|   r'   r   r(   ©r,   r¬   rœ   r�   rŸ   rz   r/   s         €r0   r(   ÚVimeoVideo.__init__`  s)   ø€ Ø0×7Ñ7¸Ó;ˆÜŒj˜$Ò(¨°VÑF¸vÓFr2   r©   ©rº   r»   ©rŽ   r�   r�   r‘   r’   r(   r•   r–   r—   s   @r0   r   r   [  s   ø† ñ÷Gõ Gr2   r   c                   ó0   ^ • \ rS rSrSrSU 4S jjrSrU =r$ )r   id  av  
Class for embedding a Scribd document in an IPython session

Use the start_page params to specify a starting point in the document
Use the view_mode params to specify display type one off scroll | slideshow | book

e.g to Display Wes' foundational paper about PANDAS in book mode from page 3

ScribdDocument(71048089, width=800, height=400, start_page=3, view_mode="book")
c                 óT   >• SR                  U5      n[        [        U ]  " XRU40 UD6  g )Nz)https://www.scribd.com/embeds/{0}/content)r|   r'   r   r(   r¾   s         €r0   r(   ÚScribdDocument.__init__p  s)   ø€ Ø7×>Ñ>¸rÓBˆÜŒn˜dÒ,¨S¸ÑJÀ6ÓJr2   r©   rÀ   rÁ   r—   s   @r0   r   r   d  s   ø† ñ	÷Kõ Kr2   r   c                   ó>   • \ rS rSrSrSr   S
S jrS rS rS r	Sr
g	)r   it  a+  Class for embedding a local file link in an IPython session, based on path

e.g. to embed a link that was generated in the IPython notebook as my/data.txt

you would do::

    local_file = FileLink("my/data.txt")
    display(local_file)

or in the HTML notebook, just::

    FileLink("my/data.txt")
z#<a href='%s' target='_blank'>%s</a>c                 ó„   • [        U5      (       a  [        SU-  5      e[        U5      U l        X l        X0l        X@l        g)a_  
Parameters
----------
path : str
    path to the file or directory that should be formatted
url_prefix : str
    prefix to be prepended to all files to form a working link [default:
    '']
result_html_prefix : str
    text to append to beginning to link [default: '']
result_html_suffix : str
    text to append at the end of link [default: '<br>']
zICannot display a directory using FileLink. Use FileLinks to display '%s'.N)r	   r$   r   ÚpathÚ
url_prefixÚresult_html_prefixÚresult_html_suffix)r,   rÇ   rÈ   rÉ   rÊ   s        r0   r(   ÚFileLink.__init__…  sC   € ô$ ��;‰;Üð /Ø15ñ6ó 7ð 7ä˜T“NˆŒ	Ø$ŒØ"4ÔØ"4Õr2   c           
      óô   • SR                  U R                  [        U R                  5      /5      nSR                  U R                  U R
                  U[        U R                  SS94-  U R                  /5      $ )Nr…   F)Úquote)r   rÈ   Úhtml_escaperÇ   rÉ   Úhtml_link_strrÊ   )r,   rN   s     r0   Ú_format_pathÚFileLink._format_pathŸ  sk   € Ø�W‰W�d—o‘o¤{°4·9±9Ó'=Ð>Ó?ˆØ�w‰w˜×/Ñ/Ø×*Ñ*Ø¤¨T¯Y©Y¸eÑ!DÐEñFà×/Ñ/ð1ó 2ð 	2r2   c                 ót   • [        U R                  5      (       d  SU R                  -  $ U R                  5       $ )z!return html link to file
        zxPath (<tt>%s</tt>) doesn't exist. It may still be in the process of being generated, or you may have the incorrect path.)r   rÇ   rÐ   rŠ   s    r0   r€   ÚFileLink._repr_html_¦  s<   € ô �d—i‘i× Ñ ð&ð )-¯	©	ñ2ð 3ð
 × Ñ Ó"Ð"r2   c                 ó,   • [        U R                  5      $ )z%return absolute path to file
        )r   rÇ   rŠ   s    r0   Ú__repr__ÚFileLink.__repr__±  s   € ô �t—y‘yÓ!Ð!r2   )rÇ   rÉ   rÊ   rÈ   N)r…   r…   ú<br>)rŽ   r�   r�   r‘   r’   rÏ   r(   rÐ   r€   rÕ   r•   r©   r2   r0   r   r   t  s-   † ñð :€Mð Ø$&Ø$*ô	5ò42ò	#õ"r2   r   c                   ó`   • \ rS rSrSr       SS jr SS jr SS jr SS jrS r	S	 r
S
rg)r   i¶  a2  Class for embedding local file links in an IPython session, based on path

e.g. to embed links to files that were generated in the IPython notebook
under ``my/data``, you would do::

    local_files = FileLinks("my/data")
    display(local_files)

or in the HTML notebook, just::

    FileLinks("my/data")
Nc	                 ó"  • [        U5      (       a  [        SU-  5      eX0l        UR                  S5      nXl        X l        X@l        XPl        U=(       d    U R                  5       U l	        U=(       d    U R                  5       U l        X€l        g)aè  
See :class:`FileLink` for the ``path``, ``url_prefix``,
``result_html_prefix`` and ``result_html_suffix`` parameters.

included_suffixes : list
  Filename suffixes to include when formatting output [default: include
  all files]

notebook_display_formatter : function
  Used to format links for display in the notebook. See discussion of
  formatter functions below.

terminal_display_formatter : function
  Used to format links for display in the terminal. See discussion of
  formatter functions below.

Formatter functions must be of the form::

    f(dirname, fnames, included_suffixes)

dirname : str
  The name of a directory
fnames : list
  The files in that directory
included_suffixes : list
  The file suffixes that should be included in the output (passing None
  meansto include all suffixes in the output in the built-in formatters)
recursive : boolean
  Whether to recurse into subdirectories. Default is True.

The function should return a list of lines that will be printed in the
notebook (if passing notebook_display_formatter) or the terminal (if
passing terminal_display_formatter). This function is iterated over for
each directory in self.path. Default formatters are in place, can be
passed here to support alternative formatting.

zDCannot display a file using FileLinks. Use FileLink to display '%s'.Ú/N)r   r$   Úincluded_suffixesÚrstriprÇ   rÈ   rÉ   rÊ   Ú_get_notebook_display_formatterÚnotebook_display_formatterÚ_get_terminal_display_formatterÚterminal_display_formatterÚ	recursive)	r,   rÇ   rÈ   rÛ   rÉ   rÊ   rÞ   rà   rá   s	            r0   r(   ÚFileLinks.__init__Ã  s�   € ô\ �$�<‰<Üð .Ø04ñ5ó 6ð 6à!2Ôà�{‰{˜3ÓˆàŒ	Ø$ŒØ"4ÔØ"4Ôð (×Q¨4×+OÑ+OÓ+Qð 	Ô'ð (×Q¨4×+OÑ+OÓ+Qð 	Ô'ð #�r2   c                 ó$   ^^^^• SUUUU4S jjnU$ )aû  generate built-in formatter function

this is used to define both the notebook and terminal built-in
 formatters as they only differ by some wrapper text for each entry

dirname_output_format: string to use for formatting directory
 names, dirname will be substituted for a single "%s" which
 must appear in this string
fname_output_format: string to use for formatting file names,
 if a single "%s" appears in the string, fname will be substituted
 if two "%s" appear in the string, the path to fname will be
  substituted for the first and fname will be substituted for the
  second
fp_format: string to use for formatting filepaths, must contain
 exactly two "%s" and the dirname will be substituted for the first
 and fname will be substituted for the second
c                 ó†  >• / n/ nU HF  n[        [        X5      5      (       d  M  Ub  [        U5      S   U;   d  M5  UR                  U5        MH     [	        U5      S:X  a   U$ T	U -  nUR                  U5        U H,  nTX4-  nTb  T" U5      n T
Xu4-  nUR                  U5        M.     U$ ! [
         a    T
U-  n N(f = f)NrU   r   )r   r   r   ÚappendrZ   rl   )ÚdirnameÚfnamesrÛ   ÚresultÚdisplay_fnamesÚfnameÚdirname_output_linerN   Úfname_output_lineÚdirname_output_formatÚfname_output_formatÚ
fp_cleanerÚ	fp_formats            €€€€r0   rh   Ú+FileLinks._get_display_formatter.<locals>.f  sð   ø€ ØˆFð  ˆNÛ�Üœ4 Ó.×/Ó/Ø)Ñ1Ü  ›¨Ñ*Ð.?Õ?Ø$×+Ñ+¨EÖ2ñ	  ô �>Ó" aÓ'ð ð" ˆMð '<¸gÑ&EÐ#Ø—‘Ð1Ô2Û+�EØ" g _Ñ4�BØ!Ñ-Ù'¨›^˜ðHà,?À2À+Ñ,MÐ)ð —M‘MÐ"3Ö4ñ ,ð ˆMøô	 %ó Hà,?À%Ñ,GÒ)ðHús   ÂB.Â.C Â?C r›   r©   )r,   rí   rî   rð   rï   rh   s    ```` r0   Ú_get_display_formatterÚ FileLinks._get_display_formatter  s   û€ ÷(	ò 	ð@ ˆr2   c                 óò   • U R                   S-   U R                  -   nU R                   U-   U R                  -   U R                  -   nU R                  S-   n[        S:X  a  S nOSnU R                  UUUU5      $ )z9generate function to use for notebook formatting
        ú%s/ú%s/%sÚ\c                 ó&   • U R                  SS5      $ )Nr÷   rÚ   )Úreplace)rN   s    r0   rï   Ú=FileLinks._get_notebook_display_formatter.<locals>.fp_cleanerF  s   € ð —z‘z $ sÓ+Ð+r2   N)rÉ   rÊ   rÏ   rÈ   r   rò   )r,   Úspacerrí   rî   rð   rï   s         r0   rÝ   Ú)FileLinks._get_notebook_display_formatter:  s�   € ð
 
×	 Ñ	  5Ñ	(¨4×+BÑ+BÑ	Bð 	ð 
×	 Ñ	  6Ñ	)¨D×,>Ñ,>Ñ	>À×AXÑAXÑ	Xð 	à—O‘O gÑ-ˆ	Ü�$‹;ó,ð ˆJà×*Ñ*Ð+@Ø+>Ø+4Ø+5ó7ð 	7r2   c                 ó:   • SnUS-   nSnU R                  UUU5      $ )z9generate function to use for terminal formatting
        rõ   z%srö   )rò   )r,   rû   rí   rî   rð   s        r0   rß   Ú)FileLinks._get_terminal_display_formatterS  s5   € ð !&ÐØ$ t™mÐØˆ	à×*Ñ*Ð+@Ø+>Ø+4ó6ð 	6r2   c                 ó:  • / nU R                   (       a  [        [        U R                  5      5      nO[	        [        U R                  5      5      /nUR                  5         U H$  u  p4nXR                  X5U R                  5      -  nM&     SR                  U5      $ )NÚ
)	rá   r­   r
   rÇ   ÚnextÚsortrÞ   rÛ   r   ©r,   Úresult_linesÚ
walked_dirræ   Úsubdirsrç   s         r0   rÐ   ÚFileLinks._format_path_  sx   € ØˆØ�>�>Üœd 4§9¡9›oÓ.‰Jäœt D§I¡I›Ó/Ð0ˆJØ�‰ÔÛ(2Ñ$ˆG˜fØ×;Ñ;¸GÈT×McÑMcÓdÑdŠLñ )3à�y‰y˜Ó&Ð&r2   c                 ó:  • / nU R                   (       a  [        [        U R                  5      5      nO[	        [        U R                  5      5      /nUR                  5         U H$  u  p4nXR                  X5U R                  5      -  nM&     SR                  U5      $ )z0return newline-separated absolute paths
        r   )	rá   r­   r
   rÇ   r  r  rà   rÛ   r   r  s         r0   rÕ   ÚFileLinks.__repr__j  sz   € ð ˆØ�>�>Üœd 4§9¡9›oÓ.‰Jäœt D§I¡I›Ó/Ð0ˆJØ�‰ÔÛ(2Ñ$ˆG˜fØ×;Ñ;¸GÈT×McÑMcÓdÑdŠLñ )3à�y‰y˜Ó&Ð&r2   )rÛ   rÞ   rÇ   rá   rÉ   rÊ   rà   rÈ   )r…   Nr…   r×   NNTr›   )z&nbsp;&nbsp;)z  )rŽ   r�   r�   r‘   r’   r(   rò   rÝ   rß   rÐ   rÕ   r•   r©   r2   r0   r   r   ¶  sO   † ñð Ø#'Ø$&Ø$*Ø,0Ø,0Øô?#ðD QUô4ðn 0>ô7ð4 04ô
6ò	'õ'r2   r   c                   óH   ^ • \ rS rSrSrS	U 4S jjrS rS rS rS r	Sr
U =r$ )
r   ix  aä  Display syntax-highlighted source code.

This uses Pygments to highlight the code for HTML and Latex output.

Parameters
----------
data : str
    The code as a string
url : str
    A URL to fetch the code from
filename : str
    A local filename to load the code from
language : str
    The short name of a Pygments lexer to use for highlighting.
    If not specified, it will guess the lexer based on the filename
    or the code. Available lexers: http://pygments.org/docs/lexers/
c                 ó.   >• X@l         [        TU ]	  XUS9  g )Nr    )Úlanguager'   r(   )r,   r!   r"   r#   r  r/   s        €r0   r(   ÚCode.__init__Š  s   ø€ Ø ŒÜ‰Ñ˜d°hÐÒ?r2   c                 óÖ   • U R                   (       a  SSKJn  U" U R                   5      $ U R                  (       a  SSKJn  U" U R                  5      $ SSKJn  U" U R                  5      $ )Nr   )Úget_lexer_by_name)Úget_lexer_for_filename)Úguess_lexer)r  Úpygments.lexersr  r#   r  r  r!   )r,   r  r  r  s       r0   Ú
_get_lexerÚCode._get_lexerŽ  sF   € Ø�=�=Ý9Ù$ T§]¡]Ó3Ð3Ø�]�]Ý>Ù)¨$¯-©-Ó8Ð8å3Ù˜tŸy™yÓ)Ð)r2   c                 ó   • U R                   $ r›   )r!   rŠ   s    r0   rÕ   ÚCode.__repr__™  s   € Ø�y‰yÐr2   c                 ó°   • SSK Jn  SSKJn  U" 5       nSR	                  UR                  S5      5      nXA" U R                  U R                  5       U5      -   $ )Nr   ©Ú	highlight)ÚHtmlFormatterz<style>{}</style>z.output_html)Úpygmentsr  Úpygments.formattersr  r|   Úget_style_defsr!   r  )r,   r  r  ÚfmtÚstyles        r0   r€   ÚCode._repr_html_œ  sI   € Ý&Ý5Ù‹oˆØ#×*Ñ*¨3×+=Ñ+=¸nÓ+MÓNˆØ�y §¡¨D¯O©OÓ,=¸sÓCÑCÐCr2   c                 óh   • SSK Jn  SSKJn  U" U R                  U R                  5       U" 5       5      $ )Nr   r  )ÚLatexFormatter)r  r  r  r"  r!   r  )r,   r  r"  s      r0   Ú_repr_latex_ÚCode._repr_latex_£  s%   € Ý&Ý6Ù˜Ÿ™ D§O¡OÓ$5±~Ó7GÓHÐHr2   )r  )NNNN)rŽ   r�   r�   r‘   r’   r(   r  rÕ   r€   r#  r•   r–   r—   s   @r0   r   r   x  s*   ø† ñ÷"@ò	*òòD÷Ið Ir2   r   N) r’   Úhtmlr   rÎ   Úos.pathr   r   r   r   r   r	   Úosr
   r   r   ÚIPython.core.displayr   r   Útypingr   r   Úcollections.abcr   Ú__all__r   r   r   r   r   r   r   r   r©   r2   r0   Ú<module>r,     s™   ðñõ 'ß B× Bß "Ñ "ç Aç "Ý $ò,€ôpˆMô p÷d)
ñ )
ôX)�6ô )ôVG�ô GôK�Vô K÷ @"ñ @"ôD'�ô 'ôD.IÐõ .Ir2   